Skip to content

Fix #3292 Put B/I/U/S under hyperlink#3297

Merged
JiuqingSong merged 4 commits intomasterfrom
u/jisong/3292
Mar 11, 2026
Merged

Fix #3292 Put B/I/U/S under hyperlink#3297
JiuqingSong merged 4 commits intomasterfrom
u/jisong/3292

Conversation

@JiuqingSong
Copy link
Collaborator

Call segmentDecorator after formatters for B/I/U/S when handle text, so that B/I/U/S will be put inside <A>.

But keep formatters for SUB/SUP after segmentDecorator to avoid rendering a weird result of SUB/SUP with link.

Add/update test cases acccordingly.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates segment formatting application order during model-to-DOM conversion so that bold/italic/underline/strike are rendered inside hyperlinks, while keeping superscript/subscript behavior unchanged (applied outside hyperlinks) to avoid rendering issues.

Changes:

  • Reorders segmentDecorator vs. segment format application in handleSegmentCommon so B/I/U/S wrappers end up under <a>.
  • Splits superOrSubScript into its own format-applier category so it can be applied after hyperlink decoration.
  • Updates/extends unit and end-to-end tests to reflect the new DOM structure and format-applier ordering.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/roosterjs-content-model-types/lib/contentModel/format/ContentModelFormatMap.ts Adds new superOrSubScript category to the format-map type to enable separate applier ordering.
packages/roosterjs-content-model-dom/lib/modelToDom/utils/handleSegmentCommon.ts Moves segmentDecorator after element-based B/I/U/S and applies superscript/subscript after decoration.
packages/roosterjs-content-model-dom/lib/formatHandlers/defaultFormatHandlers.ts Splits element-based segment format keys into “size-neutral” vs. superOrSubScript, and wires new category into defaults.
packages/roosterjs-content-model-dom/test/modelToDom/utils/handleSegmentCommonTest.ts Updates expected HTML nesting for bold-with-link scenario.
packages/roosterjs-content-model-dom/test/modelToDom/context/createModelToDomContextTest.ts Updates format-applier index expectations due to reordered/split keys.
packages/roosterjs-content-model-dom/test/domToModel/context/createDomToModelContextTest.ts Updates format-parser index expectations due to reordered/split keys.
packages/roosterjs-content-model-dom/test/endToEndTest.ts Adds coverage for link + B/I/U and validates superscript/link output expectations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…/ContentModelFormatMap.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@JiuqingSong JiuqingSong merged commit 28f5018 into master Mar 11, 2026
7 checks passed
@JiuqingSong JiuqingSong deleted the u/jisong/3292 branch March 11, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants