Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix romove row on merged cell #152

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 4 additions & 2 deletions src/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,16 @@ export function removeRow(tr, {map, table, tableStart}, row) {
let mapFrom = tr.mapping.maps.length
tr.delete(rowPos + tableStart, nextRow + tableStart)

for (let col = 0, index = row * map.width; col < map.width; col++, index++) {
for (let col = 0, index = row * map.width; col < map.width; col++) {
// col maybe skip with merged cell
index += col
let pos = map.map[index]
if (row > 0 && pos == map.map[index - map.width]) {
// If this cell starts in the row above, simply reduce its rowspan
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]) {
} 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)
Expand Down