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;