You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hi, I find there is a mistake in the function named addRow when I read the source code.
export function addRow(tr, { map, tableStart, table }, row) { let rowPos = tableStart; for (let i = 0; i < row; i++) rowPos += table.child(i).nodeSize; let cells = [], refRow = row > 0 ? -1 : 0; if (rowIsHeader(map, table, row + refRow)) refRow = row == 0 || row == map.height ? null : 0; for (let col = 0, index = map.width * row; col < map.width; col++, index++) { // Covered by a rowspan cell if ( row > 0 && row < map.height && map.map[index] == map.map[index - map.width] ) { let pos = map.map[index], attrs = table.nodeAt(pos).attrs; tr.setNodeMarkup( tableStart + pos, null, setAttr(attrs, 'rowspan', attrs.rowspan + 1), ); col += attrs.colspan - 1; } else { let type = refRow == null ? tableNodeTypes(table.type.schema).cell : table.nodeAt(map.map[index + refRow * map.width]).type; cells.push(type.createAndFill()); } } tr.insert(rowPos, tableNodeTypes(table.type.schema).row.create(null, cells)); return tr; }
the variable of col in the loop may not step by 1 beacuse of col += attrs.colspan - 1;, which cause a mistake that the variable of index is not equel to map.width and the array of cells may miss some cells when the loop is finished. Fortunately,the function of fixTables fix this mistake when dispathing tr.
this function should be like the code below export function addRow(tr, { map, tableStart, table }, row) { let rowPos = tableStart; for (let i = 0; i < row; i++) rowPos += table.child(i).nodeSize; let cells = [], refRow = row > 0 ? -1 : 0; if (rowIsHeader(map, table, row + refRow)) refRow = row == 0 || row == map.height ? null : 0; for (let col = 0, index = map.width * row; col < map.width; col++) { // Covered by a rowspan cell if ( row > 0 && row < map.height && map.map[index + col] == map.map[index + col - map.width] ) { let pos = map.map[index + col], attrs = table.nodeAt(pos).attrs; tr.setNodeMarkup( tableStart + pos, null, setAttr(attrs, 'rowspan', attrs.rowspan + 1), ); col += attrs.colspan - 1; } else { let type = refRow == null ? tableNodeTypes(table.type.schema).cell : table.nodeAt(map.map[index + col + refRow * map.width]).type; cells.push(type.createAndFill()); } } tr.insert(rowPos, tableNodeTypes(table.type.schema).row.create(null, cells)); return tr; }
could I lunch a merge request to this project?
The text was updated successfully, but these errors were encountered:
hi, I find there is a mistake in the function named addRow when I read the source code.
export function addRow(tr, { map, tableStart, table }, row) { let rowPos = tableStart; for (let i = 0; i < row; i++) rowPos += table.child(i).nodeSize; let cells = [], refRow = row > 0 ? -1 : 0; if (rowIsHeader(map, table, row + refRow)) refRow = row == 0 || row == map.height ? null : 0; for (let col = 0, index = map.width * row; col < map.width; col++, index++) { // Covered by a rowspan cell if ( row > 0 && row < map.height && map.map[index] == map.map[index - map.width] ) { let pos = map.map[index], attrs = table.nodeAt(pos).attrs; tr.setNodeMarkup( tableStart + pos, null, setAttr(attrs, 'rowspan', attrs.rowspan + 1), ); col += attrs.colspan - 1; } else { let type = refRow == null ? tableNodeTypes(table.type.schema).cell : table.nodeAt(map.map[index + refRow * map.width]).type; cells.push(type.createAndFill()); } } tr.insert(rowPos, tableNodeTypes(table.type.schema).row.create(null, cells)); return tr; }
the variable of col in the loop may not step by 1 beacuse of
col += attrs.colspan - 1;
, which cause a mistake that the variable of index is not equel to map.width and the array of cells may miss some cells when the loop is finished. Fortunately,the function of fixTables fix this mistake when dispathing tr.this function should be like the code below
export function addRow(tr, { map, tableStart, table }, row) { let rowPos = tableStart; for (let i = 0; i < row; i++) rowPos += table.child(i).nodeSize; let cells = [], refRow = row > 0 ? -1 : 0; if (rowIsHeader(map, table, row + refRow)) refRow = row == 0 || row == map.height ? null : 0; for (let col = 0, index = map.width * row; col < map.width; col++) { // Covered by a rowspan cell if ( row > 0 && row < map.height && map.map[index + col] == map.map[index + col - map.width] ) { let pos = map.map[index + col], attrs = table.nodeAt(pos).attrs; tr.setNodeMarkup( tableStart + pos, null, setAttr(attrs, 'rowspan', attrs.rowspan + 1), ); col += attrs.colspan - 1; } else { let type = refRow == null ? tableNodeTypes(table.type.schema).cell : table.nodeAt(map.map[index + col + refRow * map.width]).type; cells.push(type.createAndFill()); } } tr.insert(rowPos, tableNodeTypes(table.type.schema).row.create(null, cells)); return tr; }
could I lunch a merge request to this project?
The text was updated successfully, but these errors were encountered: