From 0ac8ae7c4b0b47ee84a9c0f8c37ffde612849957 Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Tue, 9 Jul 2024 23:02:43 +0800 Subject: [PATCH] fix: refocus when cursor is not focused #685 --- src/editor/core/cursor/Cursor.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/editor/core/cursor/Cursor.ts b/src/editor/core/cursor/Cursor.ts index 27d5603..b01d5fe 100644 --- a/src/editor/core/cursor/Cursor.ts +++ b/src/editor/core/cursor/Cursor.ts @@ -129,8 +129,11 @@ export class Cursor { const agentCursorDom = this.cursorAgent.getAgentCursorDom() if (isFocus) { setTimeout(() => { - agentCursorDom.focus() - agentCursorDom.setSelectionRange(0, 0) + // 光标不聚焦时重新定位 + if (document.activeElement !== agentCursorDom) { + agentCursorDom.focus() + agentCursorDom.setSelectionRange(0, 0) + } }) } // fillText位置 + 文字基线到底部距离 - 模拟光标偏移量