Skip to content

Add adjustWordListMarginParser to fix duplicate list indentation when pasting from Word Desktop#3288

Merged
BryanValverdeU merged 1 commit intomasterfrom
u/bvalverde/fixMarginIssueWhenPastingFromWord
Feb 25, 2026
Merged

Add adjustWordListMarginParser to fix duplicate list indentation when pasting from Word Desktop#3288
BryanValverdeU merged 1 commit intomasterfrom
u/bvalverde/fixMarginIssueWhenPastingFromWord

Conversation

@BryanValverdeU
Copy link
Contributor

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

Source
image

Before
image

After
image

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

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 adjustWordListMarginParser that subtracts 40px from marginLeft on MsoListParagraph elements
  • Registered the parser for listItemElement in 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.

@BryanValverdeU BryanValverdeU merged commit 769f74e into master Feb 25, 2026
11 checks passed
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