mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
refactor(editor): remove legacy block service spec slots (#11013)
This commit is contained in:
@@ -10,7 +10,6 @@ import {
|
||||
StdIdentifier,
|
||||
} from '../identifier.js';
|
||||
import type { BlockStdScope } from '../scope/index.js';
|
||||
import { getSlots } from '../spec/index.js';
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
@@ -27,8 +26,6 @@ export abstract class BlockService extends Extension {
|
||||
|
||||
readonly flavour: string;
|
||||
|
||||
readonly specSlots = getSlots();
|
||||
|
||||
get collection() {
|
||||
return this.std.workspace;
|
||||
}
|
||||
@@ -108,13 +105,9 @@ export abstract class BlockService extends Extension {
|
||||
}
|
||||
// life cycle end
|
||||
|
||||
mounted() {
|
||||
this.specSlots.mounted.next({ service: this });
|
||||
}
|
||||
mounted() {}
|
||||
|
||||
unmounted() {
|
||||
this.dispose();
|
||||
this.specSlots.unmounted.next({ service: this });
|
||||
this.disposables.dispose();
|
||||
}
|
||||
// event handlers end
|
||||
}
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
export * from './slots.js';
|
||||
export * from './type.js';
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
import type { BlockService } from '../extension/service.js';
|
||||
import type { BlockComponent, WidgetComponent } from '../view/index.js';
|
||||
|
||||
export type BlockSpecSlots<Service extends BlockService = BlockService> = {
|
||||
mounted: Subject<{ service: Service }>;
|
||||
unmounted: Subject<{ service: Service }>;
|
||||
viewConnected: Subject<{ component: BlockComponent; service: Service }>;
|
||||
viewDisconnected: Subject<{ component: BlockComponent; service: Service }>;
|
||||
widgetConnected: Subject<{ component: WidgetComponent; service: Service }>;
|
||||
widgetDisconnected: Subject<{
|
||||
component: WidgetComponent;
|
||||
service: Service;
|
||||
}>;
|
||||
};
|
||||
|
||||
export const getSlots = (): BlockSpecSlots => {
|
||||
return {
|
||||
mounted: new Subject(),
|
||||
unmounted: new Subject(),
|
||||
viewConnected: new Subject(),
|
||||
viewDisconnected: new Subject(),
|
||||
widgetConnected: new Subject(),
|
||||
widgetDisconnected: new Subject(),
|
||||
};
|
||||
};
|
||||
@@ -229,20 +229,6 @@ export class BlockComponent<
|
||||
this.requestUpdate();
|
||||
})
|
||||
);
|
||||
|
||||
this.service?.specSlots.viewConnected.next({
|
||||
service: this.service,
|
||||
component: this,
|
||||
});
|
||||
}
|
||||
|
||||
override disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
|
||||
this.service?.specSlots.viewDisconnected.next({
|
||||
service: this.service,
|
||||
component: this,
|
||||
});
|
||||
}
|
||||
|
||||
protected override async getUpdateComplete(): Promise<boolean> {
|
||||
|
||||
@@ -73,20 +73,11 @@ export class WidgetComponent<
|
||||
override connectedCallback() {
|
||||
super.connectedCallback();
|
||||
this.std.view.setWidget(this);
|
||||
|
||||
this.service?.specSlots.widgetConnected.next({
|
||||
service: this.service,
|
||||
component: this,
|
||||
});
|
||||
}
|
||||
|
||||
override disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
this.std?.view.deleteWidget(this);
|
||||
this.service?.specSlots.widgetDisconnected.next({
|
||||
service: this.service,
|
||||
component: this,
|
||||
});
|
||||
}
|
||||
|
||||
override render(): unknown {
|
||||
|
||||
Reference in New Issue
Block a user