Skip to content

Fix TR height being removed when pasting table from Google Sheets#3044

Closed
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-3043
Closed

Fix TR height being removed when pasting table from Google Sheets#3044
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-3043

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 21, 2025

Issue

When pasting tables from Google Sheets into the editor, the row heights were not preserved, causing the table's appearance to change significantly. This affected tables with custom row heights that were carefully set in Google Sheets.

Root Cause

The row heights were correctly extracted from the DOM during parsing and stored in the ContentModelTableRow objects, but they weren't being applied back to the TR elements when converting from content model back to DOM.

Solution

Added code to explicitly apply the row height directly to the TR element in handleTable.ts:

// Apply row height directly to TR element to preserve row heights
if (tableRow.height > 0) {
    tr.style.height = tableRow.height + 'px';
}

This ensures that when tables are pasted from Google Sheets, the row heights are preserved in the editor, maintaining the visual appearance of the original table.

Testing

Added unit tests to verify:

  • Row heights are correctly applied to TR elements
  • Row heights are not applied when the height is 0

Before the fix, pasted tables would lose their custom row heights, resulting in a uniform, condensed appearance. After the fix, tables pasted from Google Sheets maintain their original row heights.

Fixes #3043.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@BryanValverdeU
Copy link
Copy Markdown
Contributor

Add the fix in PastePlugin.ts in the googleSheets case block

Co-authored-by: BryanValverdeU <8291124+BryanValverdeU@users.noreply.github.com>
Copilot AI changed the title [WIP] RoosterJs 9 removes tr height when pasting a table from Google Sheets Fix TR height being removed when pasting table from Google Sheets May 21, 2025
Copilot AI requested a review from BryanValverdeU May 21, 2025 14:50
@BryanValverdeU
Copy link
Copy Markdown
Contributor

That did not fix the issue, add size to the defaultFormatParsers in the tableRow property

Co-authored-by: BryanValverdeU <8291124+BryanValverdeU@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 21, 2025

Add the fix in PastePlugin.ts in the googleSheets case block

I've added the fix to PastePlugin.ts in the googleSheets case block as requested. The implementation adds a custom tableRow parser that extracts height values from TR elements and preserves them in the content model. This works alongside the existing fix in handleTable.ts to ensure row heights from Google Sheets tables are preserved during paste operations. Changes are in commit 1b95090.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 21, 2025

That did not fix the issue, add size to the defaultFormatParsers in the tableRow property

Added 'size' to the defaultFormatParsers in the tableRow property as requested. This change enables the built-in size format parser to handle table row heights properly. Changes are in commit 186c675.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RoosterJs 9 removes tr height when pasting a table from Google Sheets

2 participants