fix: Preserve table cell styles on Google Docs paste#2628
fix: Preserve table cell styles on Google Docs paste#2628Branc0 wants to merge 15 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.
packages/super-editor/src/editors/v1/extensions/table-cell/table-cell.js
Show resolved
Hide resolved
packages/super-editor/src/editors/v1/extensions/table-row/helpers/parseRowHeight.js
Show resolved
Hide resolved
packages/super-editor/src/editors/v1/extensions/table-cell/helpers/parseCellBorders.js
Show resolved
Hide resolved
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".
| right: cellBounds.touchesRightEdge ? resolveTableBorderValue(cellBorders.right, tableBorders.right) : undefined, | ||
| bottom: touchesBottomBoundary ? resolveTableBorderValue(cellBorders.bottom, tableBorders.bottom) : undefined, |
There was a problem hiding this comment.
Preserve explicit interior cell borders in collapsed mode
In resolveRenderedCellBorders, the collapsed-table branch drops right/bottom for every non-edge cell even when those sides are explicitly set on the cell. This means interior overrides (for example a custom right border on one cell) are silently replaced by table defaults or disappear entirely when insideV/insideH is absent, so pasted/imported tables lose intended border styling whenever tableBorders exists.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
@Branc0 this is intentional — Google Docs always puts the same border on both sides, so nothing gets lost.
packages/super-editor/src/editors/v1/extensions/table-cell/helpers/parseCellMargins.js
Outdated
Show resolved
Hide resolved
packages/super-editor/src/editors/v1/extensions/table-cell/helpers/parseCellMargins.js
Outdated
Show resolved
Hide resolved
|
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.
packages/super-editor/src/editors/v1/extensions/table-cell/helpers/parseCellBorders.js
Show resolved
Hide resolved
| @@ -0,0 +1,52 @@ | |||
| // @ts-check | |||
There was a problem hiding this comment.
re: halfPointToPixels — same formula is now in three files. a small shared helper would keep it in one place, worth doing before more paste handlers land?
There was a problem hiding this comment.
@caio-pizzol, we briefly spoke about this on Friday morning, but I forgot the outcome of our discussion 😅.
halfPointToPixels is already coming from "@core/super-converter/helpers.js", do you want me to change its name, or keep it as it is?
There was a problem hiding this comment.
keep the name, it's fine. the duplication is minor — not worth extracting for this PR.
|
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.
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