You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Backspace at the start of a top-level footnote merges it into the previous paragraph and leaves an empty definition #5343
Backspace at the start of a footnote definition behaves differently depending on where the footnote is, and at the top level it leaves the document in an odd state:
Where the footnote is
Backspace at the start of its first paragraph
Top level, after a paragraph
note is merged into the previous paragraph, and an empty definition [^1]: is left behind
Top level, first block of the document
Nothing happens
Inside a blockquote
The footnote wrapper is removed and note stays as a plain paragraph in the quote
Inside a list item
Throws Cannot use numerical key for object container (#5340)
Backspace at the start of a blockquote removes the quote wrapper; a footnote definition should work the same way everywhere.
Related: #5340 (same key, footnote inside a list item).
Steps to Reproduce
Preferences → Markdown → Extensions → turn on Footnote.
Open a document with:
x
[^1]: note
Click in note, move the caret to the start of it, and press Backspace.
Switch to source code mode.
Also try a document that starts with the definition ([^1]: note as the first line) and press Backspace at the start of note.
Expected Behavior
Backspace at the start of the first paragraph of a footnote definition removes the footnote wrapper: its paragraphs stay in place as plain paragraphs and the caret stays at the start of note. For the example above the result is x\n\nnote. The same happens when the footnote is the first block of the document, inside a blockquote, or inside a list item.
Actual Behavior
After a paragraph: the markdown becomes xnote\n\n[^1]: (merged into x, empty definition left).
As the first block: nothing happens.
Screenshots / Logs
State after Backspace (from muya.editor.jsonState.getState()), footnote after a paragraph:
Analysis:ParagraphContent.backspaceHandler() (packages/muya/src/block/content/paragraphContent/index.ts) has no footnote case. _paragraphParentType() only recognizes block-quote / list-item / task-list-item ancestors, so a top-level footnote paragraph is handled as a plain paragraph and merged into the previous content block (leaving the emptied footnote), and at the start of the document there is no previous block, so nothing happens. Inside a blockquote the footnote is only unwrapped because the block-quote handler happens to treat the footnote as the quote.
Reproduced in real Chrome against the muya e2e host.
Operating System
macOS
MarkText Version
develop @ 2164c58 (the code involved is unchanged since v0.20.0-rc.2)
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…