refactor(editor): improve element adapters (#11473)
This commit is contained in:
2
blocksuite/affine/gfx/brush/src/adapter/index.ts
Normal file
2
blocksuite/affine/gfx/brush/src/adapter/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './markdown';
|
||||
export * from './plain-text';
|
||||
18
blocksuite/affine/gfx/brush/src/adapter/markdown/index.ts
Normal file
18
blocksuite/affine/gfx/brush/src/adapter/markdown/index.ts
Normal 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,
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
});
|
||||
11
blocksuite/affine/gfx/brush/src/adapter/plain-text/index.ts
Normal file
11
blocksuite/affine/gfx/brush/src/adapter/plain-text/index.ts
Normal 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 };
|
||||
},
|
||||
});
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './adapter';
|
||||
export * from './brush-tool';
|
||||
export * from './element-renderer';
|
||||
export * from './eraser-tool';
|
||||
|
||||
Reference in New Issue
Block a user