Preserve target formatting when pasting Markdown - #3443
Merged
Julia Roldi (juliaroldi) merged 8 commits intoAug 21, 2026
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…u/juliaroldi/markdown-paste-font
Julia Roldi (juliaroldi)
marked this pull request as ready for review
August 20, 2026 16:18
|
Julia Roldi (juliaroldi)
requested review from
Bryan Valverde U (BryanValverdeU),
Jiuqing Song (JiuqingSong),
flyingbee2012,
Ian Elizondo (ianeli1) and
Vi Nguyen (vinguyen12)
and
a lite review from Copilot
August 21, 2026 14:43
Contributor
There was a problem hiding this comment.
Pull request overview
Updates Markdown paste conversion to preserve destination formatting while retaining heading styles, with regression coverage for styled content.
Changes:
- Uses
preferTargetduring auto-conversion. - Adds tests for preserving font family, size, color, and heading boldness.
- The
asMarkdownpath still requires target-preferred merging. Moderate, 2 votes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Summary |
|---|---|
packages/roosterjs-content-model-markdown/test/plugins/MarkdownPastePluginTest.ts |
Adds regression coverage for styled Markdown headings. |
packages/roosterjs-content-model-markdown/lib/plugins/MarkdownPastePlugin.ts |
Preserves target formatting during auto-conversion; the explicit asMarkdown path still replaces custom font sizes with heading sizing. |
Suppressed comments (1)
packages/roosterjs-content-model-markdown/lib/plugins/MarkdownPastePlugin.ts:98
preferTargetoverrides every segment-format key, not just font family/size/color. A target marker can carry explicititalic: false(the DOM italic handler records normal styles this way) or a non-defaultfontWeight, so Markdown emphasis/heading boldness is then overwritten and disappears. UsekeepSourceEmphasisFormat, or merge only the destination's non-semantic font properties while retaining source emphasis.
mergeFormat: 'preferTarget',
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| }), | ||
| undefined /*context*/, | ||
| { | ||
| mergeFormat: 'preferTarget', |
Jiuqing Song (JiuqingSong)
approved these changes
Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Update
MarkdownPastePluginto merge converted Markdown withpreferTarget, preserving the destination font family, size, and color while still applying Markdown formatting such as heading boldness. Add a regression test covering Markdown pasted into preformatted content.How to test
yarn test:fast --testPathPattern=MarkdownPastePluginTest.