Files
multica/packages
n374 8f51b4f62f fix(editor): repair empty list items parsed from a markdown draft (#4869)
The real ordered-list caret bug (MUL-3973). Typing 1. in the comment box
persists the draft "1. \n\n"; on remount @tiptap/markdown parses that empty
item into a schema-invalid, childless listItem, leaving the document with an
AllSelection instead of a text cursor — so the browser paints the caret on the
following block and it can't be moved back into the list.

Verified against the REAL editor (real createEditorExtensions + @tiptap/markdown,
no @tiptap/react mock). Non-empty items round-trip fine; only the empty-item
round-trip corrupts, which the reverted #4813 never exercised.

- repairEmptyListItems(): rebuild from JSON so every list/task item leads with a
  paragraph (covers empty items and nested items whose first child is a
  sub-list); reset the AllSelection first (else setContent collapses the list);
  keep the whole repair off the undo stack; restore the prior caret (sync path)
  or land in the list item (mount).
- Called in onCreate (mount) and after the sync-effect setContent.
- Real-editor tests incl. undo-does-not-revive and nested-list schema validity.

Co-authored-by: multica-agent <github@multica.ai>
2026-07-03 15:16:03 +08:00
..