From 28596c889f1b1d49dfd246d7f7f6c4046483c8eb Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Tue, 21 May 2024 22:34:44 +0800 Subject: [PATCH] fix: update cursor status after setting page mode #588 --- src/editor/core/cursor/Cursor.ts | 5 ++++- src/editor/core/draw/Draw.ts | 13 +++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/editor/core/cursor/Cursor.ts b/src/editor/core/cursor/Cursor.ts index c36a8b7..27d5603 100644 --- a/src/editor/core/cursor/Cursor.ts +++ b/src/editor/core/cursor/Cursor.ts @@ -144,7 +144,10 @@ export class Cursor { cursorTop + cursorHeight - defaultOffsetHeight }px` // 模拟光标显示 - if (!isShow) return + if (!isShow) { + this.recoveryCursor() + return + } const isReadonly = this.draw.isReadonly() this.cursorDom.style.width = `${width * scale}px` this.cursorDom.style.backgroundColor = color diff --git a/src/editor/core/draw/Draw.ts b/src/editor/core/draw/Draw.ts index fe0223a..54201a6 100644 --- a/src/editor/core/draw/Draw.ts +++ b/src/editor/core/draw/Draw.ts @@ -868,10 +868,19 @@ export class Draw { this.footer.recovery() this.zone.setZone(EditorZone.MAIN) } + const { startIndex } = this.range.getRange() + const isCollapsed = this.range.getIsCollapsed() this.render({ - isSubmitHistory: false, - isSetCursor: false + isSetCursor: true, + curIndex: startIndex, + isSubmitHistory: false }) + // 重新定位避免事件监听丢失 + if (!isCollapsed) { + this.cursor.drawCursor({ + isShow: false + }) + } // 回调 setTimeout(() => { if (this.listener.pageModeChange) {