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

Closes: BS-3284
This commit is contained in:
Saul-Mirone
2025-04-22 15:51:22 +00:00
parent 99ad4e871e
commit 43966a6c6b
25 changed files with 160 additions and 54 deletions

View File

@@ -1,3 +1,4 @@
import { getStoreManager } from '@affine/core/blocksuite/manager/migrating-store';
import { AffineContext } from '@affine/core/components/context';
import { AppFallback } from '@affine/core/mobile/components/app-fallback';
import { configureMobileModules } from '@affine/core/mobile/modules';
@@ -306,6 +307,7 @@ const frameworkProvider = framework.provider();
collection: workspace.docCollection,
schema: getAFFiNEWorkspaceSchema(),
markdown,
extensions: getStoreManager().get('store'),
});
const docsService = workspace.scope.get(DocsService);
if (docId) {

View File

@@ -14,6 +14,8 @@ import type { Workspace } from '@blocksuite/affine/store';
import { useServices } from '@toeverything/infra';
import { useCallback, useMemo } from 'react';
import { getStoreManager } from '../manager/migrating-store';
export const usePageHelper = (docCollection: Workspace) => {
const {
docsService,
@@ -121,6 +123,7 @@ export const usePageHelper = (docCollection: Workspace) => {
showImportModal({
collection: docCollection,
schema: getAFFiNEWorkspaceSchema(),
extensions: getStoreManager().get('store'),
onSuccess,
onFail: message => {
reject(new Error(message));

View File

@@ -1,4 +1,5 @@
import { Button, IconButton, Modal } from '@affine/component';
import { getStoreManager } from '@affine/core/blocksuite/manager/migrating-store';
import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks';
import type {
DialogComponentProps,
@@ -145,6 +146,7 @@ const importConfigs: Record<ImportType, ImportConfig> = {
schema: getAFFiNEWorkspaceSchema(),
markdown: text,
fileName,
extensions: getStoreManager().get('store'),
});
if (docId) docIds.push(docId);
}
@@ -163,6 +165,7 @@ const importConfigs: Record<ImportType, ImportConfig> = {
collection: docCollection,
schema: getAFFiNEWorkspaceSchema(),
imported: file,
extensions: getStoreManager().get('store'),
});
return {
docIds,
@@ -182,6 +185,7 @@ const importConfigs: Record<ImportType, ImportConfig> = {
const docId = await HtmlTransformer.importHTMLToDoc({
collection: docCollection,
schema: getAFFiNEWorkspaceSchema(),
extensions: getStoreManager().get('store'),
html: text,
fileName,
});
@@ -203,6 +207,7 @@ const importConfigs: Record<ImportType, ImportConfig> = {
collection: docCollection,
schema: getAFFiNEWorkspaceSchema(),
imported: file,
extensions: getStoreManager().get('store'),
});
return {
docIds: pageIds,

View File

@@ -1,3 +1,4 @@
import { getStoreManager } from '@affine/core/blocksuite/manager/migrating-store';
import { MarkdownTransformer } from '@blocksuite/affine/widgets/linked-doc';
import { Service } from '@toeverything/infra';
@@ -34,6 +35,7 @@ export class ImportClipperService extends Service {
collection: workspace.docCollection,
schema: getAFFiNEWorkspaceSchema(),
markdown: clipperInput.contentMarkdown,
extensions: getStoreManager().get('store'),
});
const docsService = workspace.scope.get(DocsService);
if (docId) {
@@ -67,6 +69,7 @@ export class ImportClipperService extends Service {
collection: docCollection,
schema: getAFFiNEWorkspaceSchema(),
markdown: clipperInput.contentMarkdown,
extensions: getStoreManager().get('store'),
});
}
);

View File

@@ -1,3 +1,4 @@
import { getStoreManager } from '@affine/core/blocksuite/manager/migrating-store';
import { MarkdownTransformer } from '@blocksuite/affine/widgets/linked-doc';
import { Entity } from '@toeverything/infra';
@@ -60,6 +61,7 @@ export class IntegrationWriter extends Entity {
schema: getAFFiNEWorkspaceSchema(),
markdown,
fileName: title,
extensions: getStoreManager().get('store'),
});
if (!newDocId) throw new Error('Failed to create a new doc');
@@ -87,6 +89,7 @@ export class IntegrationWriter extends Entity {
doc,
blockId: noteBlockId,
markdown,
extensions: getStoreManager().get('store'),
});
} else if (updateStrategy === 'append') {
const pageBlockId = doc.getBlocksByFlavour('affine:page')[0]?.id;
@@ -95,6 +98,7 @@ export class IntegrationWriter extends Entity {
doc,
blockId,
markdown: `---\n${markdown}`,
extensions: getStoreManager().get('store'),
});
} else {
throw new Error('Invalid update strategy');