Skip to content

Preserve table cell styles on Google Docs paste #2150

@caio-pizzol

Description

@caio-pizzol

Summary

Preserve table cell background colors, borders, padding, and vertical alignment when pasting from Google Docs.

Problem

Table cell styling is lost when pasting from Google Docs. Cells with background colors paste as plain white, borders and padding are dropped.

Repro

  1. Create a table in Google Docs with colored cells (e.g., yellow background, blue background).
  2. Copy the table and paste into SuperDoc.
  3. All cell colors, borders, and padding are missing.

Expected

Table cell background colors, borders, padding, and vertical alignment from pasted content are preserved.

Notes

table-cell.js has parseDOM: [{ tag: 'td' }] with no attribute extraction. The background attribute has a renderDOM but no parseDOM. Google Docs sends all cell styling as inline CSS on <td> elements:

{"backgroundColor":"rgb(255, 255, 0)","verticalAlign":"top","padding":"5pt","border":"0.681818pt solid rgb(128, 128, 128)"}

The fix should add parseDOM handlers to the background attribute that reads elem.style.backgroundColor and converts it via cssColorToHex. Similarly for verticalAlign, cellMargins (from padding), and borders.

File: packages/super-editor/src/extensions/table-cell/table-cell.js

copy-paste-test.docx


Want to work on this? Check the Contributing Guide to get started. Comment on the GitHub issue to let us know you're picking it up.


Want to work on this? Check the Contributing Guide to get started. Comment on this issue to let us know you're picking it up.

Ref: SD-1979

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions