From 47b66562a698e992421063d91b793a2d2211299e Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 9 Dec 2023 17:52:10 +0800 Subject: [PATCH] :recycle: https://github.com/siyuan-note/siyuan/issues/9846 --- app/src/layout/util.ts | 2 +- app/src/protyle/index.ts | 9 +++++++-- app/src/window/openNewWindow.ts | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/layout/util.ts b/app/src/layout/util.ts index 7a9a3e13b..39c620cc7 100644 --- a/app/src/layout/util.ts +++ b/app/src/layout/util.ts @@ -473,7 +473,7 @@ export const layoutToJSON = (layout: Layout | Wnd | Tab | Model, json: any) => { json.blockId = layout.editor.protyle.block.id; json.rootId = layout.editor.protyle.block.rootID; json.mode = layout.editor.protyle.preview.element.classList.contains("fn__none") ? "wysiwyg" : "preview"; - json.action = layout.editor.protyle.block.showAll ? Constants.CB_GET_ALL : ""; + json.action = layout.editor.protyle.block.showAll ? Constants.CB_GET_ALL : Constants.CB_GET_SCROLL; json.instance = "Editor"; saveScroll(layout.editor.protyle); } else if (layout instanceof Asset) { diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.ts index fe2c4f7cb..552490811 100644 --- a/app/src/protyle/index.ts +++ b/app/src/protyle/index.ts @@ -228,10 +228,15 @@ export class Protyle { removeLoading(this.protyle); return; } - if (options.rootId) { + const filePosition = window.siyuan.storage[Constants.LOCAL_FILEPOSITION][options.blockId] || + window.siyuan.storage[Constants.LOCAL_FILEPOSITION][options.rootId]; + if (this.protyle.options.mode !== "preview" && + !mergedOptions.action.includes(Constants.CB_GET_ALL) && + (mergedOptions.action.includes(Constants.CB_GET_SCROLL) || mergedOptions.action.includes(Constants.CB_GET_ROOTSCROLL)) && + filePosition) { getDocByScroll({ protyle: this.protyle, - scrollAttr: window.siyuan.storage[Constants.LOCAL_FILEPOSITION][options.rootId], + scrollAttr: filePosition, mergedOptions, cb: () => { this.afterOnGet(mergedOptions); diff --git a/app/src/window/openNewWindow.ts b/app/src/window/openNewWindow.ts index 98bb7df19..f03a3452f 100644 --- a/app/src/window/openNewWindow.ts +++ b/app/src/window/openNewWindow.ts @@ -53,6 +53,7 @@ export const openNewWindowById = (id: string, options: windowOptions = {}) => { } }; if (response.data.rootID === id) { + json.children.action = Constants.CB_GET_SCROLL; /// #if !BROWSER ipcRenderer.send(Constants.SIYUAN_OPEN_WINDOW, { position: options.position,