SD-2440 - fix: toc not loading on paragraphs#2706
Conversation
|
Status: PASS The OOXML field character handling in this PR is spec-compliant. The inline TOC decodes to the standard complex field structure defined in ECMA-376 §17.16.2: All three pieces check out:
The only difference from the block variant is that the runs are returned as a flat array for injection into an existing paragraph rather than being wrapped in |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac0874bd59
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const inlineContentNodes = tocContent.flatMap((n) => { | ||
| const exported = exportSchemaToJson({ ...params, node: n }); | ||
| if (!exported) return []; | ||
| return Array.isArray(exported) ? exported : [exported]; | ||
| }); |
There was a problem hiding this comment.
Decode TOC children only in the active branch
In decode, tocContent is exported once into inlineContentNodes before we know whether the node is inline, and block TOCs then export the same children again into blockContentNodes (next line). This double pass is not just extra work: child decoders are stateful/mutating in this codebase (for example hyperlink decode removes link marks and can append relationships), so the second pass can serialize different output than the first and lose field content metadata in block TOCs. Move the export call inside each branch so each child is decoded exactly once.
Useful? React with 👍 / 👎.
…sed-list-of-tablesfigures-toc
…sed-list-of-tablesfigures-toc
Issue
Importing documents where the TOC field sits inline inside a paragraph crashed because the converter always emitted block
tableOfContentsnodes that expect paragraph parents. When that type of document is imported, SuperDoc crashes completely.Solution
Detect when the parent disallows block nodes and encode the TOC as a new inline
tableOfContentsInlinenode with proper exporter/schema support plus translator tests locking encode/decode behavior. We now are loading that type of document properly, however the TOC is not 100% well formatted - but we'll tackle that separately.