SD-2664 - feature support word style update field interactions for TOC#3120
SD-2664 - feature support word style update field interactions for TOC#3120chittolinag wants to merge 15 commits intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
- tabLeader: 'none' must round-trip via serialize/parse (currently lost
because no \\p is emitted when separator is missing, and the parser has
no way to disambiguate "default = dots" from "explicit none").
- toc.configure({ tabLeader: 'none' }) on a default-leader TOC must not
silently no-op (areTocConfigsEqual reports identical serialized output).
- toc.update mode: 'pageNumbers' must find tocPageNumber marks when the
marked text is nested inside a run wrapper (the rebuild output shape).
All three tests fail on the current branch and lock in the regressions
flagged in code review.
There was a problem hiding this comment.
hey @chittolinag! the \p fix is the right call, but the rebuild path is regressing in a few spots.
pushed bceff5248 - three failing tests for findings 1, 1b, and 2.
left a few inline.
needs work.
| */ | ||
| function deriveTabLeader(separator: string | undefined): TocDisplayConfig['tabLeader'] | undefined { | ||
| if (!separator) return 'none'; | ||
| if (separator === undefined) return undefined; |
There was a problem hiding this comment.
repro: open a TOC with a hyphen leader → editor.doc.toc.configure({ target, patch: { tabLeader: 'none' } }) → toc.update({ target, mode: 'all' }). the rebuilt TOC comes back with dots, not none. on a TOC that already has no leader, configure does nothing - the stored text doesn't change. fix: write \p "" for explicit none, or store the choice in a separate field.
| function readExistingTocEntryTextMarks(node: ProseMirrorNode): EntryTextMark[] { | ||
| let marks: EntryTextMark[] = []; | ||
| node.forEach((paragraph) => { | ||
| if (marks.length > 0 || paragraph.type.name !== 'paragraph') return; |
There was a problem hiding this comment.
repro: open word-fixture-pr-312-bold.docx
(first entry is bold), right-click → "Update table of contents". every entry comes out bold. Word resets to the linked paragraph styles (TOC1, TOC2, …) instead of copying from the first entry - probably the simpler match.
| if (tocTargets.length > 0) { | ||
| if (!dispatch) return true; // can()-style probe | ||
|
|
||
| for (const sdBlockId of tocTargets) { |
There was a problem hiding this comment.
repro: doc with two or more TOCs, press F9. first TOC gets real page numbers, the rest rebuild as 0. each toc.update swaps editor.state.doc, so getPageMap rejects the stored map on the next iteration. fix: grab the page map once before the loop, or batch all updates into one transaction.
Issue
Word-style "Update Field" interactions (context menu + F9) aren't wired up in SuperDoc. The document API already exposes
editor.doc.toc.update(), but no user-facing action calls it. Scope of this PR is Table of Contents only — other field types are deferred.Proposed solution