fix(super-editor): support nested content controls#3616
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Real .docx fixtures + integration test validating the translate-first SDT classifier from PR superdoc-dev#3616: nested block, nested inline, mixed-block (a defensive malformed-normalization case), and inline picture control. Each fixture asserts source XML shape, imported PM node types with no content loss, and export wrapper round-trip. A portable generator regenerates them. Row-level SDTs (w:tbl > w:sdt > w:tr) are out of scope here; see SD-3118/IT-1040.
|
@xy200303 thanks for this. The approach looks right: decide whether a content control is block or inline from where it appears in the document, not only from its direct child nodes. I pushed commit
The tests check the source XML, the imported document shape, and that export keeps the content-control wrappers. Scope note: this covers nested block and inline content controls. Picture controls are preserved, but not fully supported as their own control type yet. Table-row wrappers ( |
Thanks for the review. |
Summary
w:sdt).w:sdtContentXML child names.id,tag,alias,lockMode,controlType, and rawsdtPr.Root Cause
The importer previously decided whether to emit
structuredContentorstructuredContentBlockby checking whether the direct children ofw:sdtContentincludedw:p,w:tbl, or a known block field node.That logic fails for valid Word documents where
w:sdtContentdirectly contains anotherw:sdt. In those cases, the real content shape is only visible after translating the nested SDT. As a result, the importer could emit:structuredContentwith block children, violating the inline-only schema.structuredContentBlockwith bare inline children, violating the block-only schema.This produced errors such as:
RangeError: Invalid content for node structuredContentBlockRangeError: Invalid content for node structuredContentChanges
handleStructuredContentNodeto translate SDT content first, then classify the SDT based on the translated node shape.imageto the inline-node fallback list for schema-unavailable converter paths.w:sdtContent -> w:sdt -> w:sdtContent -> w:pVerification
pnpm --filter @superdoc/super-editor test src/editors/v1/core/super-converter/v3/handlers/w/sdt --runNotes
structuredContentaccepts inline content.structuredContentBlockaccepts block content.