From 61b73e2c598440c03f7ad603ac30bca099361c66 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sun, 23 Jun 2024 22:49:43 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/11729 --- app/src/protyle/wysiwyg/keydown.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index b5374bc90..aba28d2e1 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -256,7 +256,11 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { } } else if (protyle.title && protyle.title.editElement && (protyle.wysiwyg.element.firstElementChild.getAttribute("data-eof") === "1" || protyle.contentElement.scrollTop === 0)) { - protyle.title.editElement.focus(); + const titleRange = setLastNodeRange(protyle.title.editElement, range, false); + titleRange.collapse(false); + focusByRange(titleRange); + event.stopPropagation(); + event.preventDefault(); } else if (protyle.contentElement.scrollTop !== 0) { protyle.contentElement.scrollTop = 0; protyle.scroll.lastScrollTop = 8; @@ -650,7 +654,11 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { if (protyle.title && protyle.title.editElement && (protyle.wysiwyg.element.firstElementChild.getAttribute("data-eof") === "1" || protyle.contentElement.scrollTop === 0)) { - protyle.title.editElement.focus(); + const titleRange = setLastNodeRange(protyle.title.editElement, range, false); + titleRange.collapse(false); + focusByRange(titleRange); + event.stopPropagation(); + event.preventDefault(); } else { protyle.contentElement.scrollTop = 0; protyle.scroll.lastScrollTop = 8;