Pārlūkot izejas kodu

:art: fix https://github.com/siyuan-note/siyuan/issues/11729

Vanessa 1 gadu atpakaļ
vecāks
revīzija
61b73e2c59
1 mainītis faili ar 10 papildinājumiem un 2 dzēšanām
  1. 10 2
      app/src/protyle/wysiwyg/keydown.ts

+ 10 - 2
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;