| 48 | |
| 49 | export const MarkdownSerializer = { |
| 50 | transform(node: Node, options: MarkdownSerializerOptions = {}): Content[] { |
| 51 | if (Text.isText(node)) return [{ type: 'text', value: node.text }] |
| 52 | const tChildren = () => node.children.map(child => this.transform(child, options)).flat() |
| 53 | if (Editor.isEditor(node)) return tChildren() |
| 54 | const { type = 'paragraph' } = node |
| 55 | |
| 56 | switch (type) { |
| 57 | case 'paragraph': |
| 58 | return [{ type: 'paragraph', children: tChildren() as Paragraph['children'] }] |
| 59 | default: |
| 60 | return [{ type: 'html', value: HTMLSerializer.transform(node) }] |
| 61 | } |
| 62 | }, |
| 63 | |
| 64 | with<T = MarkdownSerializerOptions>(transform: MarkdownSerializerWithTransform<T>, options: T) { |
| 65 | const { transform: t } = this |