mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-11 23:26:30 +08:00
feat(editor): life cycle ext (#10668)
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { DisposableGroup, Slot } from '@blocksuite/global/slot';
|
||||
|
||||
import type { BlockStdScope } from '../scope/block-std-scope';
|
||||
import { LifeCycleWatcher } from './lifecycle-watcher';
|
||||
|
||||
export class EditorLifeCycleExtension extends LifeCycleWatcher {
|
||||
static override key = 'editor-life-cycle';
|
||||
|
||||
disposables = new DisposableGroup();
|
||||
|
||||
readonly slots = {
|
||||
created: new Slot(),
|
||||
mounted: new Slot(),
|
||||
rendered: new Slot(),
|
||||
unmounted: new Slot(),
|
||||
};
|
||||
|
||||
constructor(override readonly std: BlockStdScope) {
|
||||
super(std);
|
||||
|
||||
this.disposables.add(this.slots.created);
|
||||
this.disposables.add(this.slots.mounted);
|
||||
this.disposables.add(this.slots.rendered);
|
||||
this.disposables.add(this.slots.unmounted);
|
||||
}
|
||||
|
||||
override created() {
|
||||
super.created();
|
||||
this.slots.created.emit();
|
||||
}
|
||||
|
||||
override mounted() {
|
||||
super.mounted();
|
||||
this.slots.mounted.emit();
|
||||
}
|
||||
|
||||
override rendered() {
|
||||
super.rendered();
|
||||
this.slots.rendered.emit();
|
||||
}
|
||||
|
||||
override unmounted() {
|
||||
super.unmounted();
|
||||
this.slots.unmounted.emit();
|
||||
|
||||
this.disposables.dispose();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
export * from './block-view.js';
|
||||
export * from './config.js';
|
||||
export * from './dnd/index.js';
|
||||
export * from './editor-life-cycle.js';
|
||||
export * from './flavour.js';
|
||||
export * from './keymap.js';
|
||||
export * from './lifecycle-watcher.js';
|
||||
|
||||
Reference in New Issue
Block a user