mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
feat(editor): add block meta service (#10561)
This commit is contained in:
@@ -11,6 +11,8 @@ export const StoreExtensionIdentifier =
|
||||
export const storeExtensionSymbol = Symbol('StoreExtension');
|
||||
|
||||
export class StoreExtension extends Extension {
|
||||
static readonly key: string;
|
||||
|
||||
constructor(readonly store: Store) {
|
||||
super();
|
||||
}
|
||||
@@ -30,8 +32,6 @@ export class StoreExtension extends Extension {
|
||||
provider.get(this)
|
||||
);
|
||||
}
|
||||
|
||||
static readonly key: string;
|
||||
}
|
||||
|
||||
export function isStoreExtensionConstructor(
|
||||
|
||||
@@ -6,6 +6,7 @@ import { computed, signal } from '@preact/signals-core';
|
||||
import type { ExtensionType } from '../../extension/extension.js';
|
||||
import {
|
||||
BlockSchemaIdentifier,
|
||||
StoreExtensionIdentifier,
|
||||
StoreSelectionExtension,
|
||||
} from '../../extension/index.js';
|
||||
import { Schema } from '../../schema/index.js';
|
||||
@@ -313,6 +314,17 @@ export class Store {
|
||||
}
|
||||
|
||||
constructor({ doc, readonly, query, provider, extensions }: StoreOptions) {
|
||||
this._doc = doc;
|
||||
this.slots = {
|
||||
ready: new Slot(),
|
||||
rootAdded: new Slot(),
|
||||
rootDeleted: new Slot(),
|
||||
blockUpdated: new Slot(),
|
||||
historyUpdated: this._doc.slots.historyUpdated,
|
||||
yBlockUpdated: this._doc.slots.yBlockUpdated,
|
||||
};
|
||||
this._schema = new Schema();
|
||||
|
||||
const container = new Container();
|
||||
container.addImpl(StoreIdentifier, () => this);
|
||||
|
||||
@@ -327,18 +339,6 @@ export class Store {
|
||||
});
|
||||
|
||||
this._provider = container.provider(undefined, provider);
|
||||
this._doc = doc;
|
||||
|
||||
this.slots = {
|
||||
ready: new Slot(),
|
||||
rootAdded: new Slot(),
|
||||
rootDeleted: new Slot(),
|
||||
blockUpdated: new Slot(),
|
||||
historyUpdated: this._doc.slots.historyUpdated,
|
||||
yBlockUpdated: this._doc.slots.yBlockUpdated,
|
||||
};
|
||||
|
||||
this._schema = new Schema();
|
||||
this._provider.getAll(BlockSchemaIdentifier).forEach(schema => {
|
||||
this._schema.register([schema]);
|
||||
});
|
||||
@@ -698,6 +698,7 @@ export class Store {
|
||||
|
||||
load(initFn?: () => void) {
|
||||
this._doc.load(initFn);
|
||||
this._provider.getAll(StoreExtensionIdentifier);
|
||||
this.slots.ready.emit();
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user