Skip to content

[lexical-table] Bug Fix: Read background-color from shorthand style a…#8317

Draft
tomsarduy wants to merge 1 commit intofacebook:mainfrom
tomsarduy:lexical-table/fix-table-cell-background-color-import
Draft

[lexical-table] Bug Fix: Read background-color from shorthand style a…#8317
tomsarduy wants to merge 1 commit intofacebook:mainfrom
tomsarduy:lexical-table/fix-table-cell-background-color-import

Conversation

@tomsarduy
Copy link
Copy Markdown
Contributor

Description

$convertTableCellNodeElement only read style.backgroundColor when importing table cells from HTML, which misses the two most common ways Excel and some email encode cell background colors:

  • style="background:#F4B084" — the CSS background shorthand. Browsers do compute this into style.backgroundColor on a live DOM, but on detached/fragment DOMs (as used by Lexical's paste engine) some parsers leave style.backgroundColor empty.
  • 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 (explicit background-color:) — preserved ✓
  • style.background shorthand — preserved ✓
  • bgcolor HTML attribute — preserved ✓
  • Unit tests added covering all four cases (including no background color → null)

…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>
@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented Apr 9, 2026

Hi @tomsarduy!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment Apr 9, 2026 1:22pm
lexical-playground Ready Ready Preview, Comment Apr 9, 2026 1:22pm

Request Review

@hanselabreu
Copy link
Copy Markdown
Contributor

Nice!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 9, 2026
@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented Apr 9, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@tomsarduy tomsarduy marked this pull request as draft April 9, 2026 14:11
@etrepum
Copy link
Copy Markdown
Collaborator

etrepum commented Apr 20, 2026

Do you intend to finish this one? It's marked as draft, although other than the conflicts it appears to be fairly complete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants