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 moveColumn(
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 (fromCol < 0 || fromCol >= map.width || toCol < 0 || toCol >= map.width)
return;
const rows: PMNode[] = [];
table.forEach((row) => {
const cells: PMNode[] = [];

View File

@@ -129,8 +129,12 @@ export function TableColumnMenuContent({
.chain()
.focus()
.command(({ tr }) => {
const seen = new Set<number>();
for (let row = map.height - 1; row >= 0; row--) {
const cellOffset = map.map[row * map.width + colIndex];
if (seen.has(cellOffset)) continue;
seen.add(cellOffset);
const cell = table.nodeAt(cellOffset);
if (!cell) continue;
@@ -211,13 +215,17 @@ export function TableColumnMenuContent({
const lastCellPos
= map.map[(map.height - 1) * map.width + colIndex] + tableStart + 1;
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
}