From 929b27b7f6b88072a37f32a4ac5cbc1caba0899f Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 8 Aug 2022 11:36:51 +0800 Subject: [PATCH] :sparkles: https://github.com/siyuan-note/siyuan/issues/4042 --- app/src/protyle/util/onGet.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.ts index 8ae074f68..5606a0347 100644 --- a/app/src/protyle/util/onGet.ts +++ b/app/src/protyle/util/onGet.ts @@ -76,6 +76,20 @@ export const onGet = (data: IWebSocketData, protyle: IProtyle, action: string[] protyle.wysiwyg.element.setAttribute("data-doc-type", data.data.type); } + // 防止动态加载 + if (action.includes(Constants.CB_GET_APPEND) || action.includes(Constants.CB_GET_BEFORE)) { + setHTML({ + content: html, + action, + unScroll: false, + }, protyle); + const loadingElement = protyle.element.querySelector(".fn__loading"); + if (loadingElement) { + loadingElement.remove(); + } + return; + } + fetchPost("/api/block/getDocInfo", { id: protyle.block.rootID }, (response) => { @@ -91,7 +105,7 @@ export const onGet = (data: IWebSocketData, protyle: IProtyle, action: string[] if (!scrollObj) { if (action.includes(Constants.CB_GET_SCROLL) && response.data.ial.scroll) { try { - scrollObj = JSON.parse(response.data.ial.scroll) + scrollObj = JSON.parse(response.data.ial.scroll.replace(/"/g, '"')); } catch (e) { scrollObj = undefined; }