lexical icon indicating copy to clipboard operation
lexical copied to clipboard

Bug: Paste tables in tables even if hasNestedTables: false

Open zoltanhosszu opened this issue 10 months ago • 1 comments

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

  1. Select a table and copy it to clipboard
  2. Select multiple cells of the table
  3. 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.

zoltanhosszu avatar Jan 14 '26 22:01 zoltanhosszu

Tried reproducing this on current main. Two scenarios:

  1. Same-table multi-cell paste (issue body) — $insertTableIntoGrid replaces cell contents, no nesting.
  2. 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.

mayrang avatar May 21 '26 09:05 mayrang