editable
editable copied to clipboard
有序,无序列表序列markdown时错误。
Description
const serialize = (value: Descendant[]): string => {
editor.children = value;
const markdownNodesce = MarkdownSerializer.transformWithEditor(editor);
const markdownce = MarkdownSerializer.toMarkdownWithEditor(editor, markdownNodesce);
console.log('查看:', value);
return markdownce;
};
...
...
<>
<EditableProvider
editor={editor}
value={initialValue}
onChange={value => {
const isAstChange = editor.operations.some(
op => 'set_selection' !== op.type
)
if (isAstChange) {
//序列化markdown格式
localStorage.setItem("content", serialize(value));
}
}}
>
<ToolbarComponent className='flex-wrap' editor={editor} disabled={readOnly} />
<ContentEditable />
</EditableProvider>
</>
Recording
保存时 => 获取数据时
Sandbox 沙盒
https://stackblitz.com/edit/stackblitz-starters-axy4bv