Skip to content

fix(editor): 修复 LaTeX 公式导致刷新后笔记内容丢失#116

Open
liamlycoder wants to merge 1 commit into
cropflre:mainfrom
liamlycoder:fix/latex
Open

fix(editor): 修复 LaTeX 公式导致刷新后笔记内容丢失#116
liamlycoder wants to merge 1 commit into
cropflre:mainfrom
liamlycoder:fix/latex

Conversation

@liamlycoder

Copy link
Copy Markdown

importService.ts 导出的 tiptapExtensions 与 TiptapEditor 实际使用的扩展集合 不一致:缺少 MathInline / MathBlock / FootnoteReference / FootnoteDefinition / TextAlign。该数组被 tiptapSchemaRepair.repairTiptapJson 复用做脏 JSON 修复。

事故链:

  1. 用户在 RTE 插入 LaTeX 公式,编辑器持有的 JSON 含 mathInline/mathBlock 节点
  2. onUpdate debounce 后正常保存到数据库
  3. 刷新后 parseContent 调 repairTiptapJson 做 round-trip
  4. generateHTML(json, tiptapExtensions) 内部 Node.fromJSON 遇到 schema 不识别 的 mathInline/mathBlock 节点,抛 RangeError: Invalid node type
  5. catch 兜底返回 EMPTY_DOC,整篇笔记内容被清空

脚注同机制触发同样的"内容消失";TextAlign 不消失但段落对齐会被静默丢失。

修复:把这几个扩展补齐到 importService.ts 的 tiptapExtensions,让这份 schema 与 TiptapEditor.tsx / contentFormat.ts 的扩展集合保持一致。

importService.ts 导出的 tiptapExtensions 与 TiptapEditor 实际使用的扩展集合
不一致:缺少 MathInline / MathBlock / FootnoteReference / FootnoteDefinition /
TextAlign。该数组被 tiptapSchemaRepair.repairTiptapJson 复用做脏 JSON 修复。

事故链:
1. 用户在 RTE 插入 LaTeX 公式,编辑器持有的 JSON 含 mathInline/mathBlock 节点
2. onUpdate debounce 后正常保存到数据库
3. 刷新后 parseContent 调 repairTiptapJson 做 round-trip
4. generateHTML(json, tiptapExtensions) 内部 Node.fromJSON 遇到 schema 不识别
   的 mathInline/mathBlock 节点,抛 RangeError: Invalid node type
5. catch 兜底返回 EMPTY_DOC,整篇笔记内容被清空

脚注同机制触发同样的"内容消失";TextAlign 不消失但段落对齐会被静默丢失。

修复:把这几个扩展补齐到 importService.ts 的 tiptapExtensions,让这份 schema
与 TiptapEditor.tsx / contentFormat.ts 的扩展集合保持一致。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant