[lexical-table] Bug Fix: Read background-color from shorthand style a…#8317
[lexical-table] Bug Fix: Read background-color from shorthand style a…#8317tomsarduy wants to merge 1 commit intofacebook:mainfrom
Conversation
…nd bgcolor attribute on import Fixes $convertTableCellNodeElement to also check style.background and the bgcolor HTML attribute when importing table cells, so Excel/Outlook pasted content with background colors is preserved correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Hi @tomsarduy! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Nice! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Do you intend to finish this one? It's marked as draft, although other than the conflicts it appears to be fairly complete |
Description
$convertTableCellNodeElementonly readstyle.backgroundColorwhen importing table cells from HTML, which misses the two most common ways Excel and some email encode cell background colors:style="background:#F4B084"— the CSSbackgroundshorthand. Browsers do compute this intostyle.backgroundColoron a live DOM, but on detached/fragment DOMs (as used by Lexical's paste engine) some parsers leavestyle.backgroundColorempty.bgcolor="#F4B084"— the legacy HTML attribute used by older Excel/Outlook versions.The fix reads all three sources in priority order:
style.backgroundColor || style.background || getAttribute('bgcolor').Before
Pasting a table from Excel or some email clients with background color cells would lose all cell background colors. We use the editor in a ticketing system so there is a lot of copy/paste from Excel
After
style.backgroundColor(explicitbackground-color:) — preserved ✓style.backgroundshorthand — preserved ✓bgcolorHTML attribute — preserved ✓null)