From f7f875e1b3f21a7dae707682b4c454f1e10e6615 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Tue, 21 Jun 2022 09:05:18 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/5255 --- app/src/layout/Wnd.ts | 18 ++++++++++++++++++ app/src/protyle/util/onGet.ts | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts index d7ccba596..4607054c7 100644 --- a/app/src/layout/Wnd.ts +++ b/app/src/layout/Wnd.ts @@ -23,6 +23,8 @@ import {showMessage} from "../dialog/message"; import {openFileById, updatePanelByEditor} from "../editor/util"; import {scrollCenter} from "../util/highlightById"; import {getAllModels} from "./getAll"; +import {fetchPost} from "../util/fetch"; +import {onGet} from "../protyle/util/onGet"; export class Wnd { public id: string; @@ -337,6 +339,22 @@ export class Wnd { if (update) { updatePanelByEditor(currentTab.model.editor.protyle, true, pushBack); } + + // 切换到屏幕太高的页签 https://github.com/siyuan-note/siyuan/issues/5018 + const protyle = currentTab.model.editor.protyle; + if (!protyle.scroll.element.classList.contains("fn__none") && + protyle.wysiwyg.element.lastElementChild.getAttribute("data-eof") !== "true" && + protyle.contentElement.scrollHeight > 0 && + protyle.contentElement.scrollHeight <= protyle.contentElement.clientHeight) { + fetchPost("/api/filetree/getDoc", { + id: protyle.wysiwyg.element.lastElementChild.getAttribute("data-node-id"), + mode: 2, + k: protyle.options.key || "", + size: Constants.SIZE_GET, + }, getResponse => { + onGet(getResponse, protyle, [Constants.CB_GET_APPEND, Constants.CB_GET_UNCHANGEID]); + }); + } } else { updatePanelByEditor(undefined, false); } diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.ts index 680771803..d56506424 100644 --- a/app/src/protyle/util/onGet.ts +++ b/app/src/protyle/util/onGet.ts @@ -178,9 +178,10 @@ const setHTML = (options: { content: string, action?: string[] }, protyle: IProt if (protyle.element.classList.contains("block__edit") && (protyle.element.nextElementSibling || protyle.element.previousElementSibling)) { protyle.element.style.minHeight = Math.min(30 + protyle.wysiwyg.element.clientHeight, window.innerHeight / 3) + "px"; } - // https://github.com/siyuan-note/siyuan/issues/5018 + // 屏幕太高的页签 https://github.com/siyuan-note/siyuan/issues/5018 if (!protyle.scroll.element.classList.contains("fn__none") && protyle.wysiwyg.element.lastElementChild.getAttribute("data-eof") !== "true" && + protyle.contentElement.scrollHeight > 0 && // 没有激活的页签 https://github.com/siyuan-note/siyuan/issues/5255 protyle.contentElement.scrollHeight <= protyle.contentElement.clientHeight) { fetchPost("/api/filetree/getDoc", { id: protyle.wysiwyg.element.lastElementChild.getAttribute("data-node-id"),