diff --git a/packages/affine/block-surface/src/adapters/extension.ts b/packages/affine/block-surface/src/adapters/extension.ts index 46f2de881f39..daa6faec96df 100644 --- a/packages/affine/block-surface/src/adapters/extension.ts +++ b/packages/affine/block-surface/src/adapters/extension.ts @@ -1,3 +1,4 @@ +import { SurfaceBlockHtmlAdapterExtension } from './html-adapter/html.js'; import { EdgelessSurfaceBlockMarkdownAdapterExtension, SurfaceBlockMarkdownAdapterExtension, @@ -10,6 +11,7 @@ import { export const SurfaceBlockAdapterExtensions = [ SurfaceBlockPlainTextAdapterExtension, SurfaceBlockMarkdownAdapterExtension, + SurfaceBlockHtmlAdapterExtension, ]; export const EdgelessSurfaceBlockAdapterExtensions = [ diff --git a/packages/affine/block-surface/src/adapters/html-adapter/html.ts b/packages/affine/block-surface/src/adapters/html-adapter/html.ts new file mode 100644 index 000000000000..95f38441ab01 --- /dev/null +++ b/packages/affine/block-surface/src/adapters/html-adapter/html.ts @@ -0,0 +1,20 @@ +import { + BlockHtmlAdapterExtension, + type BlockHtmlAdapterMatcher, +} from '@blocksuite/affine-shared/adapters'; + +export const surfaceBlockHtmlAdapterMatcher: BlockHtmlAdapterMatcher = { + flavour: 'affine:surface', + toMatch: () => false, + fromMatch: o => o.node.flavour === 'affine:surface', + toBlockSnapshot: {}, + fromBlockSnapshot: { + enter: (_, context) => { + context.walkerContext.skipAllChildren(); + }, + }, +}; + +export const SurfaceBlockHtmlAdapterExtension = BlockHtmlAdapterExtension( + surfaceBlockHtmlAdapterMatcher +);