mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
refactor(editor): use transformer from store when possible (#10453)
This commit is contained in:
@@ -9,6 +9,8 @@ import {
|
||||
StoreSelectionExtension,
|
||||
} from '../../extension/index.js';
|
||||
import { Schema } from '../../schema/index.js';
|
||||
import type { TransformerMiddleware } from '../../transformer/middleware.js';
|
||||
import { Transformer } from '../../transformer/transformer.js';
|
||||
import {
|
||||
Block,
|
||||
type BlockModel,
|
||||
@@ -715,4 +717,17 @@ export class Store {
|
||||
get getOptional() {
|
||||
return this.provider.getOptional.bind(this.provider);
|
||||
}
|
||||
|
||||
getTransformer(middlewares: TransformerMiddleware[] = []) {
|
||||
return new Transformer({
|
||||
schema: this.schema,
|
||||
blobCRUD: this.workspace.blobSync,
|
||||
docCRUD: {
|
||||
create: (id: string) => this.workspace.createDoc({ id }),
|
||||
get: (id: string) => this.workspace.getDoc(id),
|
||||
delete: (id: string) => this.workspace.removeDoc(id),
|
||||
},
|
||||
middlewares,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user