refactor(painters/dom): unify SDT container rendering (SD-2838)#3322
Open
luccas-harbour wants to merge 21 commits into
Open
refactor(painters/dom): unify SDT container rendering (SD-2838)#3322luccas-harbour wants to merge 21 commits into
luccas-harbour wants to merge 21 commits into
Conversation
…odule Move sdt-helpers from utils/ into a dedicated sdt/container.ts module and rename applySdtContainerStyling → applySdtContainerChrome. Introduce shouldRenderSdtContainerChrome, getSdtContainerKeyForBlock, and getSdtSiblingBoundaries so renderer.ts and renderTableCell.ts can share the same boundary/suppression logic instead of inlining metadata comparisons. Table cells now receive an ancestorTableSdtKey rather than the raw tableSdt object, making the duplicate-suppression contract explicit and key-based.
Move SDT boundary computation, dataset application, snapshot collection, and inline wrapper helpers out of renderer.ts into dedicated modules under sdt/. Renames runs/sdt.ts to sdt/inline.ts and re-exports remain stable. No behavior change.
8f91a95 to
1ce01ee
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Consolidates SDT (Structured Document Tag) container rendering across paragraphs, tables, and nested tables into a single shared module, then fixes a long tail of nested/split-fragment chrome bugs that the unified pipeline made tractable.
Previously, the duplicate-suppression contract was implicit: cells were handed a raw
tableSdtreference and each renderer reimplemented its own metadata comparisons. With nested tables, idless SDT controls, and split fragments, this produced missing borders, duplicated chrome, clipped labels, and chrome that disappeared across page splits. The new pipeline uses a key-based ancestor chain and an upward chrome-rendered callback, so every renderer (paragraph, table fragment, table cell, embedded table) makes the same decisions from the same data.Changes
New shared module —
painters/dom/src/sdt/container.ts(replacesutils/sdt-helpers.ts)applySdtContainerStyling→applySdtContainerChromeshouldRenderSdtContainerChrome,getSdtContainerKeyForBlock,getSdtSiblingBoundariesSdtAncestorOptionstype —ancestorContainerKey(s)+ancestorContainerSdt(s)chains for explicit suppressionContracts (
contracts/src/sdt-container.ts) — new filegetSdtContainerKey,getSdtContainerMetadata,hasExplicitSdtContainerKey,isSdtContainerMetadatalayout-resolveddrops the localsdtContainerKey.tsand imports from contracts (single source of truth)idlessSdtContainerKeysWeakMap groups id-less sibling controls by identity, with anAIDEV-NOTEexplaining why alias/title matching is unsafeRenderer threading
renderTableFragment,renderTableRow,renderTableCell,renderEmbeddedTable, andrenderParagraphContentall accept theancestorContainerKey(s)/ancestorContainerSdt(s)chain and anonSdtContainerChromecallbackoverflow: visibleonly when a descendant actually renders chrome, not preemptively based on metadatasdtBoundarystart/end flags are now correctly narrowed at split points (paragraph mid-line splits, embedded table mid-row splits)Nested + split-fragment fixes (each is its own commit)
Tests
contracts/src/sdt-container.test.ts(42 lines) andpainters/dom/src/sdt/container.test.ts(200 lines)renderTableCell.test.tsexpanded with ~1.2k lines covering nested SDT casesrenderTableFragment.test.tsadds ~195 lines for ancestor/chrome-callback wiring