refactor(editor): improve element adapters (#11473)

This commit is contained in:
Saul-Mirone
2025-04-05 09:40:13 +00:00
parent 0fbca31c27
commit aed7f40568
45 changed files with 292 additions and 248 deletions

View File

@@ -0,0 +1,2 @@
export * from './markdown';
export * from './plain-text';

View File

@@ -0,0 +1,18 @@
import { ElementToMarkdownAdapterExtension } from '@blocksuite/affine-block-surface';
export const brushToMarkdownAdapterMatcher = ElementToMarkdownAdapterExtension({
name: 'brush',
match: elementModel => elementModel.type === 'brush',
toAST: () => {
const content = `Brush Stroke`;
return {
type: 'paragraph',
children: [
{
type: 'text',
value: content,
},
],
};
},
});

View File

@@ -0,0 +1,11 @@
import { ElementToPlainTextAdapterExtension } from '@blocksuite/affine-block-surface';
export const brushToPlainTextAdapterMatcher =
ElementToPlainTextAdapterExtension({
name: 'brush',
match: elementModel => elementModel.type === 'brush',
toAST: () => {
const content = `Brush Stroke`;
return { content };
},
});

View File

@@ -1,3 +1,4 @@
export * from './adapter';
export * from './brush-tool';
export * from './element-renderer';
export * from './eraser-tool';