fix: delete table col boundary error #688

This commit is contained in:
Hufe921
2024-07-13 17:56:08 +08:00
parent eb3ea5ed55
commit 3f0a49f56b
+7 -21
View File
@@ -1179,37 +1179,23 @@ export class CommandAdapt {
this.deleteTable() this.deleteTable()
return return
} }
// 跨列处理 // 缩小colspan或删除与当前列重叠的单元格
for (let t = 0; t < curTrList.length; t++) { for (let t = 0; t < curTrList.length; t++) {
const tr = curTrList[t] const tr = curTrList[t]
for (let d = 0; d < tr.tdList.length; d++) { for (let d = 0; d < tr.tdList.length; d++) {
const td = tr.tdList[d] const td = tr.tdList[d]
if (td.colspan > 1) {
const tdColIndex = td.colIndex!
// 交叉减去一列
if ( if (
tdColIndex <= curColIndex && td.colIndex! <= curColIndex &&
tdColIndex + td.colspan - 1 >= curColIndex td.colIndex! + td.colspan > curColIndex
) { ) {
td.colspan -= 1 if (td.colspan > 1) {
td.colspan--
} else {
tr.tdList.splice(d, 1)
} }
} }
} }
} }
// 删除当前列
for (let t = 0; t < curTrList.length; t++) {
const tr = curTrList[t]
let start = -1
for (let d = 0; d < tr.tdList.length; d++) {
const td = tr.tdList[d]
if (td.colIndex === curColIndex) {
start = d
}
}
if (~start) {
tr.tdList.splice(start, 1)
}
}
element.colgroup?.splice(curColIndex, 1) element.colgroup?.splice(curColIndex, 1)
// 重新设置上下文 // 重新设置上下文
this.position.setPositionContext({ this.position.setPositionContext({