Skip to content

fix(table): paste copied table cells into target cells - #9405

Merged
mejo- merged 5 commits into
mainfrom
fix/table_paste_cells
Oct 16, 2026
Merged

mejo- merged 5 commits into
mainfrom
fix/table_paste_cells

Conversation

@mejo-

@mejo- mejo- commented Oct 15, 2026

Copy link
Copy Markdown
Member

Pasting copied table cells into a table cell was refused with a "nested tables are not supported" warning.

Cells and rows copied from a ProseMirror editor (marked with data-pm-slice) now keep their type when parsed. Pasted header cells and rows are converted to body ones. A single copied cell is unwrapped and its content pasted at the cursor. Several cells are handed to the prosemirror-tables paste handler, which writes them into the target cells from the cursor onwards and adds rows and columns as needed. Tables pasted from spreadsheet apps go the same way, instead of keeping only the first cell's content.

Pasting a table together with other content is still rejected as a nested table.

Assisted-by: ClaudeCode:claude-opus-5-5

馃弫 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests

馃 AI (if applicable)

  • The content of this PR was partly or fully generated using AI tools
  • The AI-generated content was reviewed, comprehended and tested by a human

Pasting copied table cells into a table cell was refused with a
"nested tables are not supported" warning.

Cells and rows copied from a ProseMirror editor (marked with
data-pm-slice) now keep their type when parsed. Pasted header cells and
rows are converted to body ones. A single copied cell is unwrapped and
its content pasted at the cursor. Several cells are handed to the
prosemirror-tables paste handler, which writes them into the target
cells from the cursor onwards and adds rows and columns as needed.
Tables pasted from spreadsheet apps go the same way, instead of keeping
only the first cell's content.

Pasting a table together with other content is still rejected as a
nested table.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
@mejo- mejo- self-assigned this Oct 15, 2026
@mejo- mejo- added bug Something isn't working 3. to review feature: tables labels Oct 15, 2026
@github-project-automation github-project-automation Bot moved this to 馃Л Planning evaluation (don't pick) in 馃摑 Productivity team Oct 15, 2026
@mejo- mejo- moved this from 馃Л Planning evaluation (don't pick) to 馃憖 In review in 馃摑 Productivity team Oct 15, 2026
@mejo-

mejo- commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

/backport to stable35

@benjaminfrueh

Copy link
Copy Markdown
Contributor

Hi @mejo- and thanks for this! I was testing this and found a possible regression:

Copying text from inside a table cell and pasting it into another cell no longer works and is rejected with the table was pasted into a table error. On main the text is pasted but as a new line in the cell instead of inline at the cursor.

The single cell case at line 110 would handle this, but it is never reached. For text copied from inside a cell, pastedCells() doesn't find a cell unlike when whole cells are copied. Maybe the pasted content could be adjusted so that pastedCells() finds the single cell here.

@samin-z

samin-z commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

i also found this, if one cell has content with a bullet at the end, if we copy the first cell and paste it in the beginning of another cell with existing content, the second cell's content becomes part of the bullet.
this is because one whole cell is pasted, 'Slice.maxOpen()' opens the paste into the bullet so the text that was already in the cell gets pulled into it. previous code left that text after the list.

mejo- added 3 commits October 16, 2026 18:24
Text copied from inside a table cell is pasted wrapped in the table, row
and cell it was copied from. The cell paste handling did not detect any
cells in it and rejected it as a nested table. Unwrap the content and
paste it at the cursor instead.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Jonas <jonas@freesources.org>
A single copied cell was pasted with its content opened as deep as
possible. Text after the cursor was pulled into a list at the end of the
cell, and a list at the start of the cell was merged into the paragraph
at the cursor. Only merge with the text at the cursor where the cell
content starts or ends with a paragraph.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Jonas <jonas@freesources.org>
Use the wide prop of NcButton instead, which disables the forced width.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
@mejo-

mejo- commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Thanks @benjaminfrueh and @samin-z. Both good catches! Indeed I only tested pasting full copied cells, not selected content from another cell. I pushed a fix for both findings.

@benjaminfrueh benjaminfrueh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice! Looks good to me now 馃殌

The "Add row below" and "Add column after" buttons put the cursor at a
position that has no inline content: in the new row's first cell before
its paragraph, or in the header row before the new header cell.

Typing there made ProseMirror wrap the text in a new node. A new body
cell ended up with an extra empty paragraph below the typed text, and a
new header row got an extra header cell.

Move the cursor into the new cell's inline content instead.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
@mejo-
mejo- merged commit f24db86 into main Oct 16, 2026
62 of 64 checks passed
@mejo-
mejo- deleted the fix/table_paste_cells branch October 16, 2026 17:31
@github-project-automation github-project-automation Bot moved this from 馃憖 In review to 鈽戯笍 Done in 馃摑 Productivity team Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: 鈽戯笍 Done

Development

Successfully merging this pull request may close these issues.

3 participants