Skip to content

refactor(painter-dom): unify footnote/endnote story detection (SD-2838)#3383

Open
luccas-harbour wants to merge 5 commits into
luccas/sd-2838-unify-nested-tables-renderingfrom
luccas/sd-2838-unify-footnotes-endnotes-rendering
Open

refactor(painter-dom): unify footnote/endnote story detection (SD-2838)#3383
luccas-harbour wants to merge 5 commits into
luccas/sd-2838-unify-nested-tables-renderingfrom
luccas/sd-2838-unify-footnotes-endnotes-rendering

Conversation

@luccas-harbour
Copy link
Copy Markdown
Contributor

Summary

Consolidates the footnote/endnote story-block-id checks that were previously duplicated between the DOM painter and the super-editor's body DOM index. This is a pure refactor — no behavioral changes — and continues the SD-2838 effort to unify rendering helpers.

  • Extracts note story detection into painters/dom/src/notes/story.ts:
    • getNoteStoryKind(blockId) — classifies a block id as footnote / endnote / semantic-footnote / semantic-endnote.
    • isNonBodyStoryBlockId(blockId) — boolean shortcut used by the renderer's position-mapping guard and by the editor's DOM index exclusion.
    • shouldApplyPlainFootnotePainterReadOnly(blockId) — encodes the existing rule that only plain footnote-* frames get contenteditable="false" at the painter layer (endnotes and semantic notes have dedicated editing sessions).
  • Extracts the contenteditable-false toggle into notes/frame.ts (applyNoteStoryFrameAttributes) and routes both paint paths in renderer.ts through it.
  • Exports isNonBodyStoryBlockId from @superdoc/painter-dom and replaces the duplicated prefix list in super-editor/.../DomPositionIndex.ts with a single call.
  • Parameterizes the existing renderer position-mapping test and the DomPositionIndex exclusion test with it.each over all four block-id variants so the unified rule is exercised everywhere.
  • Adds dedicated unit tests for the new notes/story.ts and notes/frame.ts helpers, plus a smoke test that isNonBodyStoryBlockId is re-exported from the painter-dom entry point.

Move the footnote/endnote story-block detection out of renderer.ts into
a dedicated notes/story.ts module with explicit kind discrimination, and
add unit tests covering both the helper and the painter read-only side
effect.
Wrap the painter read-only contenteditable assignment into
applyNoteStoryFrameAttributes so the two fragment-frame call sites share
one helper, and move its coverage into a focused test alongside the new
module.
@luccas-harbour luccas-harbour requested a review from a team as a code owner May 19, 2026 14:47
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 19, 2026

SD-2838

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant