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

@chittolinag chittolinag commented May 4, 2026

Copy link
Copy Markdown
Contributor

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

linear Bot commented May 4, 2026

Copy link
Copy Markdown

@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.

@caio-pizzol caio-pizzol left a comment

Copy link
Copy Markdown
Contributor

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
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

@luccas-harbour luccas-harbour left a comment

Copy link
Copy Markdown
Contributor

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

superdoc-bot Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

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

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

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

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

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

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

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

@superdoc-bot

superdoc-bot Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

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

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

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

msviderok pushed a commit to msviderok/superdoc that referenced this pull request May 16, 2026
superdoc-dev#3120)

* chore: save

* feat: update TOC entry in context menu

* fix: update TOC creating extra spaces and changing fonts

* test: created tests around TOC programmatic update

* refactor: removed unused code

* refactor: code style tweaks

* refactor: removed duplicate functions

* test(toc): add regression coverage for SD-2664 review findings

- 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.

* fix: toc context menu update

* refactor: simplified logic

* refactor: removed unnecessary test suite

* refactor: simplified tests

* chore: small comment tweaks

* test: added behavior test for multiple TOCs updates

* fix: inline partial selection to produce inline text

* fix: toc from empty to non-empty

* fix: early return on TOC update

---------

Co-authored-by: Gabriel Chittolina <gabrielchittolina1@gmail.com>
Co-authored-by: Caio Pizzol <caio@superdoc.dev>
@superdoc-bot

superdoc-bot Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in superdoc-sdk v1.10.0

@superdoc-bot

superdoc-bot Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in @superdoc-dev/mcp v0.6.0

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in superdoc v1.34.0

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in @superdoc-dev/react v1.5.0

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in vscode-ext v2.6.0

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