Skip to content

fix(muya): edit a footnote definition as its own container (#5340, #5343) - #5347

Merged
Jocs merged 2 commits into
developfrom
fix/5340-5343-footnote-container
Sep 14, 2026
Merged

Jocs merged 2 commits into
developfrom
fix/5340-5343-footnote-container

Conversation

@Jocs

@Jocs Jocs commented Sep 14, 2026

Copy link
Copy Markdown
Member

Closes #5340
Closes #5343

Summary

A footnote definition is now edited as a container of its own, wherever it sits.

1. fix(muya): remove a footnote wrapper on Backspace at its start (#5343)

Backspace at the start of a top-level footnote handled the paragraph as a plain paragraph: it merged note into the previous block and left an empty [^1]: behind, or did nothing when the footnote was the first block. It now behaves like Backspace at the start of a block-quote: the footnote is replaced by the blocks it held, and the caret stays at the start of the first one. Backspace at the start of a later paragraph still merges it into the previous paragraph inside the footnote.

2. fix(muya): pick Backspace/Enter handling from the paragraph's own container (#5340)

ParagraphContent._paragraphParentType() walked up to the nearest block-quote / list-item / task-list-item ancestor, while those handlers edit the paragraph's grandparent as that container. For list-item > footnote > paragraph:

  • Backspace at the start of note appended a block into the list item's first paragraph, and the next state flush threw Cannot use numerical key for object container.
  • Enter nested a list-item inside the list item.
  • Inside a quote, only the footnote's first paragraph was moved out.

The handling is now resolved from the container that holds the paragraph (this.parent.parent), with footnote as a recognised container. For paragraphs directly in a list item or quote nothing changes. The footnote is the only registered block that can sit between a paragraph and those containers (paragraphs are held by the scroll page, block-quote, list-item, task-list-item and footnote).

Behaviour in real Chrome (muya e2e host, real keys, caret at the start of note / more)

Document Key develop this PR
x + [^1]: note Backspace xnote + empty [^1]: x, note
[^1]: note (first block) Backspace nothing note
x + [^1]: note / more Backspace xnote + [^1]: more x, note, more
x + [^1]: note / more (at more) Backspace [^1]: notemore [^1]: notemore (unchanged)
> a + > [^1]: note Backspace quote(a, note) quote(a, note) (unchanged)
> a + > [^1]: note / more Backspace quote(a, note, [^1]: more) quote(a, note, more)
- a + [^1]: note Backspace throws, edit lost - a / note
- [ ] a + [^1]: note Backspace throws, edit lost - [ ] a / note
x + [^1]: note Enter empty paragraph above note in the footnote unchanged
- a + [^1]: note Enter [^1]: + nested - note empty paragraph above note in the footnote

In every case above on this branch: no renderer error, typing afterwards works, undo restores the loaded document, and reopening the saved markdown gives the same state (except Enter, where an empty first paragraph in a footnote can't be written as markdown — same as top-level footnotes on develop).

Type of change

  • Bug fix (non-breaking, fixes an issue)
  • New feature (non-breaking, adds functionality)
  • Breaking change (causes existing functionality to change)
  • Documentation update

Test plan

  • New tests added — paragraphContent/__tests__/footnoteContainer.spec.ts (happy-dom, flushes the JSON state synchronously so a malformed op throws inside the test):
  • muya: vitest run 226 files / 1588 tests pass; lint (no new warnings), lint:types, check-circular pass.
  • muya e2e (system Chrome): footnote, footnote-scenarios, lists, list-nav-4644, list-paste-outdent-4899, blockquote-and-rule pass; cross-block-enter fails locally on develop as well.
  • Manually tested on: macOS (real Chrome, muya e2e host)

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KGKDSxyPk9WxU2h5DgPcWn

Jocs and others added 2 commits September 14, 2026 15:39
Backspace at the start of a top-level footnote definition handled the
paragraph as a plain paragraph: it merged `note` into the previous block and
left an empty `[^1]: ` definition behind, and did nothing when the footnote
was the first block of the document.

Treat it like Backspace at the start of a block-quote: the footnote is
replaced by the blocks it held and the caret stays at the start of the first
one. Backspace at the start of a later paragraph still merges it into the
previous paragraph inside the footnote.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KGKDSxyPk9WxU2h5DgPcWn
…tainer (#5340)

`_paragraphParentType` walked up to the nearest block-quote or list-item
ancestor, but the block-quote and list handlers edit the paragraph's
grandparent as that container. For a footnote definition inside a list item
(`list-item > footnote > paragraph`), Backspace at the start of the note
appended a block into the list item's first paragraph and the next state
flush threw "Cannot use numerical key for object container"; Enter nested a
list item inside the list item. Inside a quote only the first paragraph of the
footnote was moved out.

Resolve the handling from the container that holds the paragraph, with the
footnote as a container of its own, so a footnote anywhere is edited like a
top-level one. Paragraphs directly in a list item or quote are handled as
before; the footnote is the only block that can sit between a paragraph and
those containers.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KGKDSxyPk9WxU2h5DgPcWn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant