fix: Preserve table cell styles on Google Docs paste#2628
fix: Preserve table cell styles on Google Docs paste#2628caio-pizzol merged 21 commits intosuperdoc-dev:mainfrom
Conversation
| const [bottomValuePt] = parseSizeUnit(style?.paddingBottom); | ||
| const [leftValuePt] = parseSizeUnit(style?.paddingLeft); | ||
|
|
||
| const top = halfPointToPixels(topValuePt); |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
@Branc0 the formula is right, just the name is confusing — we mentioned a shared helper in the inline review.
There was a problem hiding this comment.
💡 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".
|
Still WIP on this one:
|
There was a problem hiding this comment.
@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:


edge cases — GDocs vs SuperDoc:


left a few inline comments.
|
Hey @Branc0, this PR has had no activity for 3 days. |
caio-pizzol
left a comment
There was a problem hiding this comment.
@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.
|
Made some more changes:
|
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.
caio-pizzol
left a comment
There was a problem hiding this comment.
@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.
|
🎉 This PR is included in vscode-ext v1.1.0-next.70 |
|
🎉 This PR is included in @superdoc-dev/react v1.0.0-next.24 The release is available on GitHub release |
|
🎉 This PR is included in esign v2.2.0-next.28 The release is available on GitHub release |
|
🎉 This PR is included in template-builder v1.3.0-next.30 The release is available on GitHub release |
|
🎉 This PR is included in superdoc-cli v0.5.0-next.68 The release is available on GitHub release |
|
🎉 This PR is included in superdoc-sdk v1.3.0-next.69 |
|
🎉 This PR is included in superdoc v1.24.0-next.67 The release is available on GitHub release |
|
🎉 This PR is included in superdoc-sdk v1.4.0 |
|
🎉 This PR is included in superdoc v1.25.0 The release is available on GitHub release |
|
🎉 This PR is included in superdoc-cli v0.6.0 The release is available on GitHub release |
|
🎉 This PR is included in vscode-ext v2.3.0-next.1 |
|
🎉 This PR is included in template-builder v1.5.0-next.1 The release is available on GitHub release |
|
🎉 This PR is included in esign v2.3.0-next.1 The release is available on GitHub release |
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:
Steps for testing