editablejs / editable

🌱 A collaborative rich-text editor framework that focuses on stability, controllability, extensibility, and performance. 一款强到离谱的富文本编辑器框架,专注于稳定性、可控性、扩展性和性能。
https://docs.editablejs.com
Apache License 2.0
1.79k stars 120 forks source link

有序,无序列表序列markdown时错误。 #142

Open guugg opened 11 months ago

guugg commented 11 months ago

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

保存时 => 获取数据时

屏幕截图 2023-09-08 161047.png

Sandbox 沙盒

https://stackblitz.com/edit/stackblitz-starters-axy4bv