Skip to content

SD-2664 - feature support word style update field interactions for TOC#3120

Merged
chittolinag merged 19 commits into
mainfrom
gabriel/sd-2664-feature-support-word-style-update-field-interactions-for
May 8, 2026
Merged

SD-2664 - feature support word style update field interactions for TOC#3120
chittolinag merged 19 commits into
mainfrom
gabriel/sd-2664-feature-support-word-style-update-field-interactions-for

Conversation

@chittolinag
Copy link
Copy Markdown
Contributor

@chittolinag chittolinag commented May 4, 2026

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

  • Right-click → "Update table of contents" when the cursor is inside a TOC.
  • F9 rebuilds every TOC in the document.
  • Fixed a handful of issues in the rebuild path that surfaced once the action was actually exercised end-to-end (font/style preservation, dot leader, spacing, pasted-heading detection).
  • Added unit tests for the context-menu item, the F9 command, and the rebuild helpers, plus a behavior test that loads a TOC docx, presses F9, and verifies the rebuilt entries match the document's headings.

@linear
Copy link
Copy Markdown

linear Bot commented May 4, 2026

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@chittolinag chittolinag marked this pull request as ready for review May 4, 2026 20:25
@chittolinag chittolinag requested a review from a team as a code owner May 4, 2026 20:25
@chittolinag chittolinag changed the title SD-2664 - feature support word style update field interactions for SD-2664 - feature support word style update field interactions for TOC May 4, 2026
- 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.
Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@chittolinag chittolinag requested a review from caio-pizzol May 7, 2026 20:02
@luccas-harbour
Copy link
Copy Markdown
Contributor

hey @chittolinag! this looks pretty cool!

I had a look at this one and found an issue where the text "No table of contents entries found" is not removed after entries are added to the document. Here's how to reproduce it:
a. Open the test-corpus/basic/table-of-contents-sdt.docx into the editor
b. Select the entire contents of the document (except for the TOC itself) and set the style to Normal.
c. Right-click the TOC and update it. The "No table of contents entries found" will now be shown
d. Select the "Lorem ipsum dolor" text and change the style to Heading 1
e. Right-click the TOC and update it again. You'll notice that the heading is added but the "no entries" text is still there.

I also found another one that I posted as an inline comment. ping me if you have any questions!

Comment thread packages/super-editor/src/editors/v1/extensions/field-update/field-update.js Outdated
@chittolinag chittolinag requested review from luccas-harbour and removed request for artem-harbour and caio-pizzol May 8, 2026 17:48
chittolina added 2 commits May 8, 2026 15:18
…re-support-word-style-update-field-interactions-for

# Conflicts:
#	packages/super-editor/src/editors/v1/components/context-menu/constants.js
Copy link
Copy Markdown
Contributor

@luccas-harbour luccas-harbour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chittolinag chittolinag enabled auto-merge (squash) May 8, 2026 18:35
@chittolinag chittolinag requested review from caio-pizzol May 8, 2026 18:36
@chittolinag chittolinag dismissed caio-pizzol’s stale review May 8, 2026 18:36

issues mentioned by him were fixed and he's OOO - as agreed, I'll dismiss.

@chittolinag chittolinag merged commit fd8eabc into main May 8, 2026
65 checks passed
@chittolinag chittolinag deleted the gabriel/sd-2664-feature-support-word-style-update-field-interactions-for branch May 8, 2026 18:52
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 11, 2026

🎉 This PR is included in superdoc v1.30.0-next.71

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 11, 2026

🎉 This PR is included in @superdoc-dev/mcp v0.3.0-next.74

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 11, 2026

🎉 This PR is included in @superdoc-dev/react v1.2.0-next.116

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 11, 2026

🎉 This PR is included in vscode-ext v2.3.0-next.118

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 11, 2026

🎉 This PR is included in superdoc-cli v0.8.0-next.90

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 11, 2026

🎉 This PR is included in superdoc-sdk v1.8.0-next.72

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.

6 participants