From acfa766027bfa2c1482f9ecd646307502a69c57a Mon Sep 17 00:00:00 2001 From: Vanessa Date: Tue, 12 Dec 2023 20:40:39 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E6=89=93=E5=BC=80=E5=AE=9A=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/protyle/util/onGet.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.ts index 2a8476143..d9bb785b2 100644 --- a/app/src/protyle/util/onGet.ts +++ b/app/src/protyle/util/onGet.ts @@ -251,10 +251,7 @@ const setHTML = (options: { // 使用动态滚动条定位到最后一个块,重启后无法触发滚动事件,需要再次更新 index protyle.scroll.updateIndex(protyle, options.scrollAttr.startId); // https://github.com/siyuan-note/siyuan/issues/8224 - const contentRect = protyle.contentElement.getBoundingClientRect(); - if (protyle.wysiwyg.element.clientHeight - parseInt(protyle.wysiwyg.element.style.paddingBottom) < protyle.contentElement.clientHeight && - protyle.wysiwyg.element.lastElementChild.getBoundingClientRect().bottom < contentRect.bottom && - protyle.wysiwyg.element.firstElementChild.getBoundingClientRect().top > contentRect.top) { + if (protyle.contentElement.scrollHeight <= protyle.contentElement.clientHeight) { showMessage(window.siyuan.languages.scrollGetMore); } } @@ -361,12 +358,8 @@ export const enableProtyle = (protyle: IProtyle) => { const focusElementById = (protyle: IProtyle, action: string[], scrollAttr?: IScrollAttr) => { let focusElement: Element; - let range: Range; if (scrollAttr && scrollAttr.focusId) { focusElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${scrollAttr.focusId}"]`) - if (action.includes(Constants.CB_GET_FOCUS)) { - range = focusByOffset(focusElement, scrollAttr.focusStart, scrollAttr.focusEnd) as Range; - } } else { Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${protyle.block.id}"]`)).find((item: HTMLElement) => { if (!hasClosestByAttribute(item, "data-type", "block-render", true)) { @@ -386,7 +379,12 @@ const focusElementById = (protyle: IProtyle, action: string[], scrollAttr?: IScr bgFade(focusElement); } if (action.includes(Constants.CB_GET_FOCUS) || action.includes(Constants.CB_GET_FOCUSFIRST)) { - focusBlock(focusElement); + let range: Range; + if (scrollAttr && scrollAttr.focusId) { + range = focusByOffset(focusElement, scrollAttr.focusStart, scrollAttr.focusEnd) as Range; + } else { + focusBlock(focusElement); + } /// #if !MOBILE if (!action.includes(Constants.CB_GET_UNUNDO)) { pushBack(protyle, range, focusElement);