Skip to content

Commit 9a98074

Browse files
committed
feat(plugin-table): distribute a pasted table fragment over the target cells
Pasting a copied rectangle into a table dropped the whole fragment into one cell (not even schema-legal as a nested table). It now distributes cell-per-cell from the anchor, the spreadsheet convention: the target rectangle's top-left, or the caret's cell. A larger target rectangle only provides the anchor; the extra target cells stay untouched rather than clearing. The interception sits on `clipboard.paste`, before core's expanded-selection `delete` decomposition, because the target rectangle must survive to define the distribution. Detection is not name-sniffing alone: the clipboard's `application/x-portable-text` data goes through the same converter the editor's own paste uses, validating the fragment against this editor's schema down into the cells' blocks, and the result must be a single canonical table. Everything else falls through to the editor's paste handling, keeping the replace-rectangle behavior for non-table content. Two hardening layers the converter cannot provide: the parser preserves existing keys, so every pasted block is re-keyed with markDef references remapped (pasting a column next to itself cannot duplicate keys), and since the converter is deliberately lenient (`validateFields: false`) while the distribution applies content through raw `insert` primitives, cell content is filtered against the cell's own sub-schema: block types the cell does not declare never reach the document, pinned by a rogue-fragment test. A fragment extending past the table's edges grows rows and columns with fully-constructed nodes, padding off-fragment positions with empty cells and extending the positional `alignment` array with `null`s. All raises form one undo step, and the pasted rectangle becomes the selection.
1 parent c39dc5e commit 9a98074

3 files changed

Lines changed: 960 additions & 0 deletions

File tree

0 commit comments

Comments
 (0)