Fix borderFormatHandler to strip 'initial' color value#3350
Open
BryanValverdeU wants to merge 3 commits into
Open
Fix borderFormatHandler to strip 'initial' color value#3350BryanValverdeU wants to merge 3 commits into
BryanValverdeU wants to merge 3 commits into
Conversation
|
When the border color is 'initial', browsers ignore the change when setting it on the inline style of an element. Check the last part of the border value and remove it if it is 'initial' before storing the format. Uses the last element to handle cases where the border value may not have all three parts (width, style, color). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2c2b240 to
35baf53
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a paste-formatting issue where border shorthands containing initial as the color (e.g. 1px solid initial) can be ignored by browsers when re-applied as inline styles, causing borders to be lost after paste. It updates borderFormatHandler to strip the trailing initial token from per-side border shorthand values before storing them in the model, and updates/extends tests to reflect and validate the corrected behavior.
Changes:
- Strip trailing
initialfrom per-side border shorthand strings during DOM→model parsing inborderFormatHandler. - Update Word Online paste expectations to no longer include
initialin stored border strings. - Update/add paste and unit tests to validate border preservation and multi-value
border-styleshorthands.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/roosterjs-content-model-plugins/test/paste/word/processPastedContentFromWacTest.ts | Updates expected pasted table cell border strings to omit initial color. |
| packages/roosterjs-content-model-plugins/test/paste/e2e/cmPasteTest.ts | Strengthens e2e expectations to ensure borders are preserved when border-color: initial is present. |
| packages/roosterjs-content-model-dom/test/formatHandlers/common/borderFormatHandlerTest.ts | Adds coverage for multi-value border-style shorthand serialization across sides. |
| packages/roosterjs-content-model-dom/lib/formatHandlers/common/borderFormatHandler.ts | Implements stripping of trailing initial from border shorthand values before storing format. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
65299c1 to
a0ab9ce
Compare
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.
When the border color is 'initial', browsers ignore the change when setting it on the inline style of an element. Destructure the border value into [width, style, color] and replace 'initial' in the color position with an empty string before storing the format.
To Repro
Create an .html file with this content:
Open the HTML file in browser copy and paste to Rooster
Before

After
