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) {