Skip to content

[lexical-table][lexical-playground] Feature: Implement "fit nested tables" for nested table pasting#8097

Merged
etrepum merged 14 commits intofacebook:mainfrom
randal-atticus:fix-nested-table-paste-width
Feb 3, 2026
Merged

[lexical-table][lexical-playground] Feature: Implement "fit nested tables" for nested table pasting#8097
etrepum merged 14 commits intofacebook:mainfrom
randal-atticus:fix-nested-table-paste-width

Conversation

@randal-atticus
Copy link
Contributor

@randal-atticus randal-atticus commented Jan 27, 2026

Description

Adds a hasFitNestedTables flag to TablePlugin that resizes nested tables when pasted into table cells. This is optional, because if you have hasHorizontalScroll (scrollable tables) or scrollable table cells (as in Playground), you don't really need this. However, we do need this for a use case that is designed to be closer to MS Word's tables, and I imagine this could be useful in core.

Screen.Recording.2026-01-28.at.12.31.02.am.mov

Test plan

Before

Tables are pasted at full width. This looks okay with hasHorizontalScroll, but not all Lexical users will be using this flag.

Screen.Recording.2026-01-28.at.12.34.49.am.mov

After

The pasted table is resized to fit inside the parent cell, accounting for "insets" (padding + border). This is done recursively.

Basic case:

Screen.Recording.2026-01-28.at.12.31.02.am.mov

Deeply nested tables are also resized:

Screen.Recording.2026-01-28.at.12.33.34.am.mov

Pasting into a merged cell:

Screen.Recording.2026-01-28.at.1.12.10.pm.mov

@vercel
Copy link

vercel bot commented Jan 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment Feb 2, 2026 6:36am
lexical-playground Ready Ready Preview, Comment Feb 2, 2026 6:36am

Request Review

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 27, 2026
}

export function wrapTableHtml(expected, {ignoreClasses = false} = {}) {
export function wrapTableHtml(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For whatever reason, "dir="auto" wasn't being applied on the nested table when it was pasted. Instead of debugging that, I just added ignoreDir. Then I tried to make it a bit more explicit about what it was doing (moving "dir" up to the div, and optionally adding the scrollable wrapper class).

);
}

// If we reached this point, there's a table in the selection and nested tables are not allowed - reject the paste.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm aware this behaviour is different from #8082. In that PR, tables are stripped from the payload. The non-nested-table case isn't a focus of this specific PR so I didn't try to replicate that - but there will be a merge conflict.

@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Jan 30, 2026
@etrepum etrepum added this pull request to the merge queue Feb 3, 2026
Merged via the queue into facebook:main with commit 80ed4aa Feb 3, 2026
72 of 73 checks passed
rayterion pushed a commit to rayterion/lexical that referenced this pull request Feb 8, 2026
rayterion pushed a commit to rayterion/lexical that referenced this pull request Feb 8, 2026
rayterion pushed a commit to rayterion/lexical that referenced this pull request Feb 9, 2026
rayterion pushed a commit to rayterion/lexical that referenced this pull request Feb 13, 2026
rayterion pushed a commit to rayterion/lexical that referenced this pull request Feb 18, 2026
@etrepum etrepum mentioned this pull request Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants