Skip to content

fix: Preserve table cell styles on Google Docs paste#2628

Merged
caio-pizzol merged 21 commits intosuperdoc-dev:mainfrom
Branc0:2150-preserve-table-styles
Apr 8, 2026
Merged

fix: Preserve table cell styles on Google Docs paste#2628
caio-pizzol merged 21 commits intosuperdoc-dev:mainfrom
Branc0:2150-preserve-table-styles

Conversation

@Branc0
Copy link
Copy Markdown
Contributor

@Branc0 Branc0 commented Mar 30, 2026

Summary

PR for the issue Issue #2150.

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

Additionally, as a side effect of the main fixes, this PR solves two other issues:

  • Google Docs Pasted tables don't persist row height: I had to fix to test vertical alignment.
  • Duplicated borders on the intersections of cells. As we make the borders bigger, this gets more evident.

Steps for testing

  • Create a table in Google Docs with colored cells (e.g., this doc ).
  • Copy the table and paste it into SuperDoc.
  • Table cell background colors, borders, padding, and vertical alignment from pasted content are preserved.

const [bottomValuePt] = parseSizeUnit(style?.paddingBottom);
const [leftValuePt] = parseSizeUnit(style?.paddingLeft);

const top = halfPointToPixels(topValuePt);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was searching for a helper function that converts PT to PX, and I noticed this has the same formula, so I used it despite the name being halfPoint. Let me know if it's okay...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Branc0 the formula is right, just the name is confusing — we mentioned a shared helper in the inline review.

Comment thread packages/super-editor/src/editors/v1/extensions/table-cell/table-cell.js Outdated
Comment thread packages/layout-engine/painters/dom/src/table/renderTableRow.ts
@Branc0 Branc0 marked this pull request as ready for review March 30, 2026 01:21
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5b77732f99

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/layout-engine/painters/dom/src/table/renderTableRow.ts
@Branc0
Copy link
Copy Markdown
Contributor Author

Branc0 commented Mar 30, 2026

Still WIP on this one:

  • The P1 issue from codex: tried a couple of fixes, but they introduced the duplicated border back
  • Integration test

@caio-pizzol caio-pizzol self-assigned this Mar 30, 2026
Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Branc0 tested with real Google Docs tables — backgrounds, borders (solid/dashed/dotted), merged cells, borderless cells, padding, column widths all working. no blockers.

test docs: basic styles · edge cases

basic styles — GDocs vs SuperDoc:
image
image

edge cases — GDocs vs SuperDoc:
image
image

left a few inline comments.

Comment thread packages/layout-engine/painters/dom/src/table/renderTableRow.ts
@caio-pizzol
Copy link
Copy Markdown
Contributor

Hey @Branc0, this PR has had no activity for 3 days.

Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Branc0 tests and comment look good, resolved those two threads.

one thing: Google Docs uses <th> for header rows, but table-header.js only has rendering — it's missing the parsing side for the new attributes. so when you paste a table with a header row, the header cells lose their padding (and would lose background/borders/alignment too if they had any). table-cell.js has both sides, table-header.js needs the same. tested with this doc.

re: the halfPointToPixels name — keep it as is, it's fine.

@Branc0
Copy link
Copy Markdown
Contributor Author

Branc0 commented Apr 8, 2026

Made some more changes:

  • Moved the parsing functions from extensions/table-cell/helpers to extensions/shared
  • Added the parsers for table-headers
  • Added more integration tests + table-headers tests

cssColorToHex returns values with the # prefix (e.g. #ffff00) but the
rest of the system stores background colors as bare hex. renderDOM
prepends # and the OOXML exporter writes background.color directly into
shading.fill, so the mismatch produced ##ffff00 in CSS and #ffff00 in
OOXML — both invalid.

Also adds parseDOM → renderDOM round-trip tests to catch this class of
format mismatch in the future.
Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Branc0 all good from last round.

caught one bug — pasted background colors were stored with a # prefix, but the renderer adds its own #, so colors came out as ##ffff00 (broken). pushed a fix to your branch (6b14e6d8c) that strips the extra # at parse time, plus a round-trip test to prevent it from coming back.

approving.

@caio-pizzol caio-pizzol enabled auto-merge April 8, 2026 01:25
@caio-pizzol caio-pizzol added this pull request to the merge queue Apr 8, 2026
Merged via the queue into superdoc-dev:main with commit 1768159 Apr 8, 2026
51 checks passed
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 8, 2026

🎉 This PR is included in vscode-ext v1.1.0-next.70

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 8, 2026

🎉 This PR is included in @superdoc-dev/react v1.0.0-next.24

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 8, 2026

🎉 This PR is included in esign v2.2.0-next.28

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 8, 2026

🎉 This PR is included in template-builder v1.3.0-next.30

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 8, 2026

🎉 This PR is included in superdoc-cli v0.5.0-next.68

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 8, 2026

🎉 This PR is included in superdoc-sdk v1.3.0-next.69

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 8, 2026

🎉 This PR is included in superdoc v1.24.0-next.67

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in superdoc-sdk v1.4.0

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in superdoc v1.25.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in superdoc-cli v0.6.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in vscode-ext v2.3.0-next.1

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in template-builder v1.5.0-next.1

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in esign v2.3.0-next.1

The release is available on GitHub release

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants