Review fixes

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-04-01 19:44:23 +04:00
parent e5b155a584
commit 821f66cc20
15 changed files with 255 additions and 39 deletions

View File

@@ -70,6 +70,11 @@ export function moveRow(
const table = editor.state.doc.nodeAt(tableNodePos);
if (!table) return;
const map = TableMap.get(table);
if (new Set(map.map).size < map.map.length) return;
if (fromRow < 0 || fromRow >= map.height || toRow < 0 || toRow >= map.height)
return;
const rows: PMNode[] = [];
table.forEach(row => rows.push(row));
const [moved] = rows.splice(fromRow, 1);

View File

@@ -209,13 +209,17 @@ export function TableRowMenuContent({
const lastCellPos
= map.map[rowIndex * map.width + (map.width - 1)] + tableStart;
const $anchor = editor.state.doc.resolve(firstCellPos);
const $head = editor.state.doc.resolve(lastCellPos);
editor.view.dispatch(
editor.state.tr.setSelection(new CellSelection($anchor, $head)),
);
editor.commands.deleteSelection();
editor
.chain()
.focus()
.command(({ tr }) => {
const $anchor = tr.doc.resolve(firstCellPos);
const $head = tr.doc.resolve(lastCellPos);
tr.setSelection(new CellSelection($anchor, $head));
return true;
})
.deleteSelection()
.run();
} catch {
// table may have changed
}