diff --git a/src/editor/core/draw/Draw.ts b/src/editor/core/draw/Draw.ts index 3b3927c..b99135c 100644 --- a/src/editor/core/draw/Draw.ts +++ b/src/editor/core/draw/Draw.ts @@ -1168,23 +1168,21 @@ export class Draw { this._createPage(i) } } + // 移除多余页 + const curPageCount = this.pageRowList.length + const prePageCount = this.pageList.length + if (prePageCount > curPageCount) { + const deleteCount = prePageCount - curPageCount + this.ctxList.splice(curPageCount, deleteCount) + this.pageList.splice(curPageCount, deleteCount) + .forEach(page => page.remove()) + } // 绘制元素 if (isLazy) { this._lazyRender() } else { this._immediateRender() } - // 移除多余页 - nextTick(() => { - const curPageCount = this.pageRowList.length - const prePageCount = this.pageList.length - if (prePageCount > curPageCount) { - const deleteCount = prePageCount - curPageCount - this.ctxList.splice(curPageCount, deleteCount) - this.pageList.splice(curPageCount, deleteCount) - .forEach(page => page.remove()) - } - }) // 光标重绘 if (isSetCursor) { const positionContext = this.position.getPositionContext() diff --git a/src/editor/core/position/Position.ts b/src/editor/core/position/Position.ts index 2e398d5..63eed8c 100644 --- a/src/editor/core/position/Position.ts +++ b/src/editor/core/position/Position.ts @@ -90,7 +90,7 @@ export class Position { positionList.push(positionItem) index++ x += metrics.width - // 绘制表格内元素 + // 计算表格内元素位置 if (element.type === ElementType.TABLE) { const tdGap = tdPadding * 2 for (let t = 0; t < element.trList!.length; t++) {