Skip to content

Commit

Permalink
feat(blocks): html adapter skip surface block children when doc mode (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
donteatfriedrice committed Dec 19, 2024
1 parent 4d1534c commit 5605b1a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/affine/block-surface/src/adapters/extension.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SurfaceBlockHtmlAdapterExtension } from './html-adapter/html.js';
import {
EdgelessSurfaceBlockMarkdownAdapterExtension,
SurfaceBlockMarkdownAdapterExtension,
Expand All @@ -10,6 +11,7 @@ import {
export const SurfaceBlockAdapterExtensions = [
SurfaceBlockPlainTextAdapterExtension,
SurfaceBlockMarkdownAdapterExtension,
SurfaceBlockHtmlAdapterExtension,
];

export const EdgelessSurfaceBlockAdapterExtensions = [
Expand Down
20 changes: 20 additions & 0 deletions packages/affine/block-surface/src/adapters/html-adapter/html.ts
Original file line number Diff line number Diff line change
@@ -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
);

0 comments on commit 5605b1a

Please sign in to comment.