Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,15 @@ export function removeRow(tr, {map, table, tableStart}, row) {
let attrs = table.nodeAt(pos).attrs
tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + tableStart), null, setAttr(attrs, "rowspan", attrs.rowspan - 1))
col += attrs.colspan - 1
} else if (row < map.width && pos == map.map[index + map.width]) {
index += attrs.colspan - 1
} else if (row < map.height && pos == map.map[index + map.width]) {
// Else, if it continues in the row below, it has to be moved down
let cell = table.nodeAt(pos)
let copy = cell.type.create(setAttr(cell.attrs, "rowspan", cell.attrs.rowspan - 1), cell.content)
let newPos = map.positionAt(row + 1, col, table)
tr.insert(tr.mapping.slice(mapFrom).map(tableStart + newPos), copy)
col += cell.attrs.colspan - 1
index += cell.attrs.colspan - 1
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions test/test-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,14 @@ describe("deleteRow", () => {
table(tr(c11, c11))))

it("skips columns when adjusting rowspan", () =>
test(table(tr(cCursor, c(2, 2)), tr(c11)),
test(table(tr(cCursor, c(2, 2), c11), tr(c11, c11)),
deleteRow,
table(tr(c11, c(2, 1), c11))))

it("skips columns when adjusting rowspan", () =>
test(table(tr(c11, c(2, 2), c11), tr(c11, cCursor)),
deleteRow,
table(tr(c11, c(2, 1)))))
table(tr(c11, c(2, 1), c11))))

it("can delete a cell selection", () =>
test(table(tr(cAnchor, c11), tr(c11, cEmpty)),
Expand Down