feat(editor): use store extension manager (#11891)

Closes: BS-3284
This commit is contained in:
Saul-Mirone
2025-04-22 15:51:23 +00:00
parent 99ad4e871e
commit 43966a6c6b
25 changed files with 160 additions and 54 deletions
@@ -19,6 +19,7 @@ import './left-side-panel.js';
import { defaultImageProxyMiddleware } from '@blocksuite/affine/blocks/image';
import { ExportManager } from '@blocksuite/affine/blocks/surface';
import { toast } from '@blocksuite/affine/components/toast';
import { StoreExtensionManagerIdentifier } from '@blocksuite/affine/ext-loader';
import {
BlockSuiteError,
ErrorCode,
@@ -331,6 +332,10 @@ export class StarterDebugMenu extends ShadowlessElement {
);
}
private _getStoreManager() {
return this.editor.std.get(StoreExtensionManagerIdentifier);
}
private async _importHTML() {
try {
const files = await openFileOrFiles({
@@ -349,6 +354,7 @@ export class StarterDebugMenu extends ShadowlessElement {
schema: this.editor.doc.schema,
html: text,
fileName,
extensions: this._getStoreManager().get('store'),
});
if (pageId) {
pageIds.push(pageId);
@@ -372,6 +378,7 @@ export class StarterDebugMenu extends ShadowlessElement {
collection: this.collection,
schema: this.editor.doc.schema,
imported: file,
extensions: this._getStoreManager().get('store'),
});
if (!this.editor.host) return;
toast(
@@ -401,6 +408,7 @@ export class StarterDebugMenu extends ShadowlessElement {
schema: this.editor.doc.schema,
markdown: text,
fileName,
extensions: this._getStoreManager().get('store'),
});
if (pageId) {
pageIds.push(pageId);
@@ -424,6 +432,7 @@ export class StarterDebugMenu extends ShadowlessElement {
collection: this.collection,
schema: this.editor.doc.schema,
imported: file,
extensions: this._getStoreManager().get('store'),
});
if (!this.editor.host) return;
toast(
@@ -463,6 +472,7 @@ export class StarterDebugMenu extends ShadowlessElement {
collection: this.collection,
schema: this.editor.doc.schema,
imported: file,
extensions: this._getStoreManager().get('store'),
});
if (!this.editor.host) return;
toast(
+2 -2
View File
@@ -1,9 +1,9 @@
import { SpecProvider } from '@blocksuite/affine/shared/utils';
import { TestWorkspace } from '@blocksuite/affine/store/test';
import { getTestStoreManager } from '@blocksuite/integration-test/store';
export function createEmptyDoc() {
const collection = new TestWorkspace();
collection.storeExtensions = SpecProvider._.getSpec('store').value;
collection.storeExtensions = getTestStoreManager().get('store');
collection.meta.initialize();
const doc = collection.createDoc();
const store = doc.getStore();
@@ -1,5 +1,6 @@
import { Text, type Workspace } from '@blocksuite/affine/store';
import { MarkdownTransformer } from '@blocksuite/affine/widgets/linked-doc';
import { getTestStoreManager } from '@blocksuite/integration-test/store';
import type { InitFn } from './utils.js';
@@ -26,6 +27,7 @@ export const preset: InitFn = async (collection: Workspace, id: string) => {
doc,
blockId: noteId,
markdown: presetMarkdown,
extensions: getTestStoreManager().get('store'),
});
doc.resetHistory();
@@ -1,5 +1,6 @@
import { Text, type Workspace } from '@blocksuite/affine/store';
import { MarkdownTransformer } from '@blocksuite/affine/widgets/linked-doc';
import { getTestStoreManager } from '@blocksuite/integration-test/store';
import type { InitFn } from './utils';
@@ -44,6 +45,7 @@ export const synced: InitFn = (collection: Workspace, id: string) => {
doc: docSyncedPage,
blockId: noteId,
markdown: syncedDocMarkdown,
extensions: getTestStoreManager().get('store'),
}).catch(console.error);
});
@@ -63,6 +65,7 @@ export const synced: InitFn = (collection: Workspace, id: string) => {
doc: docSyncedEdgeless,
blockId: noteId,
markdown: syncedDocMarkdown,
extensions: getTestStoreManager().get('store'),
}).catch(console.error);
});
@@ -80,6 +83,7 @@ export const synced: InitFn = (collection: Workspace, id: string) => {
doc: docMain,
blockId: noteId,
markdown: syncedDocMarkdown,
extensions: getTestStoreManager().get('store'),
})
.then(() => {
// Add synced block - self