refactor(editor): use transformer from store when possible (#10453)

This commit is contained in:
Saul-Mirone
2025-02-26 14:15:03 +00:00
parent 1c5e360d7e
commit fd6d96a38e
17 changed files with 75 additions and 215 deletions

View File

@@ -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,
});
}
}