Bug: Paste tables in tables even if hasNestedTables: false
This is a screen recording from the Lexical playground:
https://github.com/user-attachments/assets/efee7e2c-f387-41b1-8b15-59986490bc41
Lexical version: latest on playground
Steps To Reproduce
- Select a table and copy it to clipboard
- Select multiple cells of the table
- Right click and paste
The current behavior
The copied content from the clipboard gets inserted, including a table, within the table.
The expected behavior
The table should be stripped out when pasting into a table.
Impact of fix
This could prevent some abuse of content blocks.
Tried reproducing this on current main. Two scenarios:
- Same-table multi-cell paste (issue body) —
$insertTableIntoGridreplaces cell contents, no nesting. - Table A → table B multi-cell paste — same behavior.
Looking at the paste handler in LexicalTablePluginHelpers.ts:449-498, there are five branches and none of them produce a nested table when hasNestedTables: false: a single-table clipboard gets flattened into the destination cells, and anything else (mixed clipboard) is rejected outright.
git blame puts those two branches on PR #8097 (Feb 4), which restructured this function while landing hasFitNestedTables. The PR didn't link back here, so the issue stayed open.
Didn't try the mixed-clipboard case from the playground directly (hard to construct one there), but the code path covers it.