Repository navigation
Description
Description
With the footnote extension enabled, pressing Backspace at the start of a footnote definition that is indented inside a list item throws Cannot use numerical key for object container. The edit is discarded, and every later edit in the document throws the same error until the file is reloaded.
Pressing Enter at the same spot doesn't throw, but it silently nests a new list item directly inside the list item; after reopening the file the footnote is empty and note has become a nested bullet.
Same error message as #4899 / #5018 (fixed by #4913) and #5315, but a different trigger; the stack below has two drop frames, so it is not a proven match for #5315.
Steps to Reproduce
- Preferences → Markdown → Extensions → turn on Footnote.
- Open a new document, switch to source code mode, and paste:
- a [^1]: note
- Switch back to the WYSIWYG editor. The footnote definition renders inside the list item.
- Click in
noteand move the caret to the start of it (Cmd+← / Home). - Press Backspace.
Expected Behavior
The footnote is handled as its own container, regardless of the list item around it:
- Backspace at the start of
noteremoves the footnote wrapper and keepsnoteas a plain paragraph in the list item:- a\n\n note. This is what already happens today for a footnote inside a blockquote, and what Backspace does at the start of a blockquote. No error, no lost edits. - Enter at the start of
noteinserts an empty paragraph abovenoteinside the footnote, as it does for a top-level footnote or one inside a blockquote. It never creates a list item.
The top-level footnote case (Backspace merges into the previous paragraph and leaves an empty [^1]: ) is tracked in #5343.
Actual Behavior
- "Unexpected error" dialog (renderer):
Cannot use numerical key for object container. - The document is unchanged, and any further typing throws the same error.
- Enter at the start of
noteinstead produces- a\n\n [^1]: \n\n - note(a list item inside the list item).
Screenshots / Logs
Stack from the unminified dev build (@muyajs/core sources):
Error: Cannot use numerical key for object container
at assert (ot-json1.js)
at insertChildMut (ot-json1.js)
at drop (ot-json1.js)
at drop (ot-json1.js)
at Object.apply (ot-json1.js)
at JSONState._apply (packages/muya/src/state/index.ts)
at JSONState._flushOperationCache (packages/muya/src/state/index.ts)
Analysis: ParagraphContent._paragraphParentType() (packages/muya/src/block/content/paragraphContent/index.ts) walks up to the nearest list-item / task-list-item / block-quote ancestor, but the list and block-quote Backspace/Enter handlers then treat the paragraph's grandparent as that container. With a footnote in between (list-item > footnote > paragraph), Backspace appends a block into the list item's first paragraph, producing an op that ot-json1 rejects on the next state flush; Enter inserts a list-item into the list-item.
Reproduced in the built desktop app (Playwright + Electron) and in real Chrome against the muya e2e host.
Operating System
macOS
MarkText Version
develop @ a351c50 (the code involved is unchanged since v0.20.0-rc.2)
OS Version
macOS 27.0
Reproducibility
- I can reliably reproduce this issue
Activity
fix(muya): edit a footnote definition as its own container (#5340, #5343
fix: keep list item kinds and footnote containers in model-backed edi…
fix: keep list item kinds and footnote containers in model-backed edi…
fix: keep list item kinds and footnote containers in model-backed edi…