Add adjustWordListMarginParser to fix duplicate list indentation when pasting from Word Desktop#3288
Merged
BryanValverdeU merged 1 commit intomasterfrom Feb 25, 2026
Conversation
… pasting from Word Desktop Word Desktop pastes list items with full indentation as marginLeft on MsoListParagraph elements, which duplicates the paddingInlineStart (40px) already applied by the browser's default list styling. This parser subtracts the default 40px from the marginLeft of list items with the MsoListParagraph class to correct the indentation. - Add adjustWordListMarginParser using parseValueWithUnit for unit conversion - Register parser for listItemElement in processPastedContentFromWordDesktop - Update addParser call count expectations in pasteTest and ContentModelPastePluginTest - Add dedicated test case for the margin adjustment behavior
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes a list indentation issue when pasting from Word Desktop. Word Desktop adds the full list indentation as marginLeft on MsoListParagraph elements, which duplicates the browser's default 40px paddingInlineStart on list elements. The new adjustWordListMarginParser subtracts 40px from the marginLeft to correct this duplication.
Changes:
- Added
adjustWordListMarginParserthat subtracts 40px from marginLeft on MsoListParagraph elements - Registered the parser for
listItemElementin Word Desktop paste processing - Updated test expectations to reflect the margin adjustment (e.g., 1.5in → 104px)
- Incremented addParser call count expectations in tests
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/roosterjs-content-model-plugins/lib/paste/parsers/adjustWordListMarginParser.ts | New parser that subtracts 40px from marginLeft on MsoListParagraph elements |
| packages/roosterjs-content-model-plugins/lib/paste/WordDesktop/processPastedContentFromWordDesktop.ts | Registers the new parser for listItemElement |
| packages/roosterjs-content-model-plugins/test/paste/word/processPastedContentFromWordDesktopTest.ts | Adds dedicated test case and updates expected margins in existing tests |
| packages/roosterjs-content-model-plugins/test/paste/plugin/ContentModelPastePluginTest.ts | Updates addParser call count from 6 to 7 |
| packages/roosterjs-content-model-core/test/command/paste/pasteTest.ts | Updates addParser call counts to reflect new parser |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
JiuqingSong
approved these changes
Feb 25, 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.
Word Desktop pastes list items with full indentation as marginLeft on MsoListParagraph elements, which duplicates the paddingInlineStart (40px) already applied by the browser's default list styling. This parser subtracts the default 40px from the marginLeft of list items with the MsoListParagraph class to correct the indentation.
Source

Before

After
