diff --git a/blocksuite/affine/shared/src/adapters/index.ts b/blocksuite/affine/shared/src/adapters/index.ts index 50edecbbf6ed3..acd422798e1a8 100644 --- a/blocksuite/affine/shared/src/adapters/index.ts +++ b/blocksuite/affine/shared/src/adapters/index.ts @@ -33,6 +33,9 @@ export { BlockNotionHtmlAdapterMatcherIdentifier, type InlineDeltaToNotionHtmlAdapterMatcher, type NotionHtml, + NotionHtmlAdapter, + NotionHtmlAdapterFactoryExtension, + NotionHtmlAdapterFactoryIdentifier, NotionHtmlASTToDeltaExtension, type NotionHtmlASTToDeltaMatcher, NotionHtmlASTToDeltaMatcherIdentifier, diff --git a/blocksuite/affine/shared/src/adapters/notion-html/index.ts b/blocksuite/affine/shared/src/adapters/notion-html/index.ts index e45efaf7c7a0b..cf987aca9ade1 100644 --- a/blocksuite/affine/shared/src/adapters/notion-html/index.ts +++ b/blocksuite/affine/shared/src/adapters/notion-html/index.ts @@ -1,3 +1,3 @@ export * from './block-adapter.js'; export * from './delta-converter.js'; -export * from './type.js'; +export * from './notion-html.js'; diff --git a/blocksuite/blocks/src/_common/adapters/notion-html/notion-html.ts b/blocksuite/affine/shared/src/adapters/notion-html/notion-html.ts similarity index 97% rename from blocksuite/blocks/src/_common/adapters/notion-html/notion-html.ts rename to blocksuite/affine/shared/src/adapters/notion-html/notion-html.ts index 77a52fcab3ee5..6c1a5fce32d43 100644 --- a/blocksuite/blocks/src/_common/adapters/notion-html/notion-html.ts +++ b/blocksuite/affine/shared/src/adapters/notion-html/notion-html.ts @@ -2,17 +2,6 @@ import { DEFAULT_NOTE_BACKGROUND_COLOR, NoteDisplayMode, } from '@blocksuite/affine-model'; -import { - type AdapterContext, - AdapterFactoryIdentifier, - type BlockNotionHtmlAdapterMatcher, - BlockNotionHtmlAdapterMatcherIdentifier, - HastUtils, - type HtmlAST, - type NotionHtml, - NotionHtmlASTToDeltaMatcherIdentifier, - NotionHtmlDeltaConverter, -} from '@blocksuite/affine-shared/adapters'; import type { ExtensionType } from '@blocksuite/block-std'; import type { ServiceProvider } from '@blocksuite/global/di'; import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions'; @@ -35,6 +24,23 @@ import { import rehypeParse from 'rehype-parse'; import { unified } from 'unified'; +import { + type AdapterContext, + AdapterFactoryIdentifier, +} from '../types/adapter'; +import type { HtmlAST } from '../types/hast'; +import { HastUtils } from '../utils/hast'; +import { + type BlockNotionHtmlAdapterMatcher, + BlockNotionHtmlAdapterMatcherIdentifier, +} from './block-adapter'; +import { + NotionHtmlASTToDeltaMatcherIdentifier, + NotionHtmlDeltaConverter, +} from './delta-converter'; + +export type NotionHtml = string; + type NotionHtmlToSliceSnapshotPayload = { file: NotionHtml; assets?: AssetsManager; diff --git a/blocksuite/affine/shared/src/adapters/notion-html/type.ts b/blocksuite/affine/shared/src/adapters/notion-html/type.ts deleted file mode 100644 index c2d00590b0ea8..0000000000000 --- a/blocksuite/affine/shared/src/adapters/notion-html/type.ts +++ /dev/null @@ -1 +0,0 @@ -export type NotionHtml = string; diff --git a/blocksuite/blocks/src/__tests__/adapters/notion-html.unit.spec.ts b/blocksuite/blocks/src/__tests__/adapters/notion-html.unit.spec.ts index 3807f00d338c2..f8b66a784a993 100644 --- a/blocksuite/blocks/src/__tests__/adapters/notion-html.unit.spec.ts +++ b/blocksuite/blocks/src/__tests__/adapters/notion-html.unit.spec.ts @@ -2,6 +2,7 @@ import { DEFAULT_NOTE_BACKGROUND_COLOR, NoteDisplayMode, } from '@blocksuite/affine-model'; +import { NotionHtmlAdapter } from '@blocksuite/affine-shared/adapters'; import { Container } from '@blocksuite/global/di'; import { AssetsManager, @@ -12,7 +13,6 @@ import { describe, expect, test } from 'vitest'; import { defaultBlockNotionHtmlAdapterMatchers } from '../../_common/adapters/notion-html/block-matcher.js'; import { notionHtmlInlineToDeltaMatchers } from '../../_common/adapters/notion-html/delta-converter/html-inline.js'; -import { NotionHtmlAdapter } from '../../_common/adapters/notion-html/notion-html.js'; import { nanoidReplacement } from '../../_common/test-utils/test-utils.js'; import { createJob } from '../utils/create-job.js'; diff --git a/blocksuite/blocks/src/_common/adapters/extension.ts b/blocksuite/blocks/src/_common/adapters/extension.ts index f5291555dc757..431ace5238331 100644 --- a/blocksuite/blocks/src/_common/adapters/extension.ts +++ b/blocksuite/blocks/src/_common/adapters/extension.ts @@ -1,5 +1,6 @@ import { HtmlAdapterFactoryExtension, + NotionHtmlAdapterFactoryExtension, PlainTextAdapterFactoryExtension, } from '@blocksuite/affine-shared/adapters'; import type { ExtensionType } from '@blocksuite/block-std'; @@ -11,7 +12,6 @@ import { ImageAdapterFactoryExtension } from './image.js'; import { MarkdownAdapterFactoryExtension } from './markdown/markdown.js'; import { MixTextAdapterFactoryExtension } from './mix-text.js'; import { notionHtmlInlineToDeltaMatchers } from './notion-html/delta-converter/html-inline.js'; -import { NotionHtmlAdapterFactoryExtension } from './notion-html/notion-html.js'; import { NotionTextAdapterFactoryExtension } from './notion-text.js'; import { inlineDeltaToPlainTextAdapterMatchers } from './plain-text/delta-converter/inline-delta.js'; diff --git a/blocksuite/blocks/src/_common/adapters/notion-html/index.ts b/blocksuite/blocks/src/_common/adapters/notion-html/index.ts index 54badc175de53..0e7d1f0faa027 100644 --- a/blocksuite/blocks/src/_common/adapters/notion-html/index.ts +++ b/blocksuite/blocks/src/_common/adapters/notion-html/index.ts @@ -1,6 +1,2 @@ export { defaultBlockNotionHtmlAdapterMatchers } from './block-matcher.js'; -export { - NotionHtmlAdapter, - NotionHtmlAdapterFactoryExtension, - NotionHtmlAdapterFactoryIdentifier, -} from './notion-html.js'; +export { notionHtmlInlineToDeltaMatchers } from './delta-converter/html-inline.js'; diff --git a/blocksuite/blocks/src/_common/transformers/notion-html.ts b/blocksuite/blocks/src/_common/transformers/notion-html.ts index aeecb097f6712..c4cb0f7972ad2 100644 --- a/blocksuite/blocks/src/_common/transformers/notion-html.ts +++ b/blocksuite/blocks/src/_common/transformers/notion-html.ts @@ -1,10 +1,10 @@ +import { NotionHtmlAdapter } from '@blocksuite/affine-shared/adapters'; import { Container } from '@blocksuite/global/di'; import { sha } from '@blocksuite/global/utils'; import { type DocCollection, extMimeMap, Job } from '@blocksuite/store'; import { defaultBlockNotionHtmlAdapterMatchers } from '../adapters/notion-html/block-matcher.js'; import { notionHtmlInlineToDeltaMatchers } from '../adapters/notion-html/delta-converter/html-inline.js'; -import { NotionHtmlAdapter } from '../adapters/notion-html/notion-html.js'; import { defaultImageProxyMiddleware } from './middlewares.js'; import { Unzip } from './utils.js'; diff --git a/blocksuite/blocks/src/index.ts b/blocksuite/blocks/src/index.ts index 77619e3b32af4..d4c4dba3f0c89 100644 --- a/blocksuite/blocks/src/index.ts +++ b/blocksuite/blocks/src/index.ts @@ -103,6 +103,9 @@ export { HtmlAdapter, HtmlAdapterFactoryExtension, HtmlAdapterFactoryIdentifier, + NotionHtmlAdapter, + NotionHtmlAdapterFactoryExtension, + NotionHtmlAdapterFactoryIdentifier, PlainTextAdapter, PlainTextAdapterFactoryExtension, PlainTextAdapterFactoryIdentifier,