From 5c3bde7c908a0fce532fd075a7bc51c7d7279cac Mon Sep 17 00:00:00 2001 From: huangmb <286931810@qq.com> Date: Fri, 22 Oct 2021 16:59:49 +0800 Subject: [PATCH] Update commands.js 1. update index if skip merged cell 2. correct mistake of row verify --- src/commands.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/commands.js b/src/commands.js index 65167d89..a74d1a45 100644 --- a/src/commands.js +++ b/src/commands.js @@ -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)