From 1f552a05d588da1a661cbc000f36253f8894377c Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Tue, 15 Aug 2023 20:38:11 +0800 Subject: [PATCH] fix: merge table cell error #241 --- .../core/draw/particle/table/TableParticle.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/editor/core/draw/particle/table/TableParticle.ts b/src/editor/core/draw/particle/table/TableParticle.ts index 0ebf996..017ff03 100644 --- a/src/editor/core/draw/particle/table/TableParticle.ts +++ b/src/editor/core/draw/particle/table/TableParticle.ts @@ -215,9 +215,19 @@ export class TableParticle { // 小于 if (pTdX < x) continue if (pTdX > x) break - if (pTd.x === x && pTdY + pTdHeight > y) { - x += pTdWidth - offsetXIndex += pTd.colspan + if (pTdX === x && pTdY + pTdHeight > y) { + // 中间存在断行,则移到断行后td位置 + const nextPTd = pTr.tdList[pD + 1] + if ( + nextPTd && + pTd.colIndex! + pTd.colspan !== nextPTd.colIndex + ) { + x = nextPTd.x! + offsetXIndex = nextPTd.colIndex! + } else { + x += pTdWidth + offsetXIndex += pTd.colspan + } } } } @@ -301,6 +311,7 @@ export class TableParticle { let endTd = trList[endTrIndex!].tdList[endTdIndex!] // 交换起始位置 if (startTd.x! > endTd.x! || startTd.y! > endTd.y!) { + // prettier-ignore [startTd, endTd] = [endTd, startTd] } const startColIndex = startTd.colIndex!