From 284d78bc27e6309d793ade2d132e652977bfa6b9 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 28 Sep 2022 23:48:59 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/6004 --- app/src/menus/protyle.ts | 4 ++-- app/src/util/backForward.ts | 14 ++++---------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts index f8e162c92..99df66078 100644 --- a/app/src/menus/protyle.ts +++ b/app/src/menus/protyle.ts @@ -409,9 +409,9 @@ export const zoomOut = (protyle: IProtyle, id: string, focusId?: string, isPushB size: id === protyle.block.rootID ? Constants.SIZE_GET : Constants.SIZE_GET_MAX, }, getResponse => { if (isPushBack) { - onGet(getResponse, protyle, id === protyle.block.rootID ? [Constants.CB_GET_FOCUS] : [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS]); + onGet(getResponse, protyle, id === protyle.block.rootID ? [Constants.CB_GET_FOCUS, Constants.CB_GET_HTML] : [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS, Constants.CB_GET_HTML]); } else { - onGet(getResponse, protyle, id === protyle.block.rootID ? [Constants.CB_GET_FOCUS, Constants.CB_GET_UNUNDO] : [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS, Constants.CB_GET_UNUNDO]); + onGet(getResponse, protyle, id === protyle.block.rootID ? [Constants.CB_GET_FOCUS, Constants.CB_GET_HTML, Constants.CB_GET_UNUNDO] : [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS, Constants.CB_GET_UNUNDO, Constants.CB_GET_HTML]); } // https://github.com/siyuan-note/siyuan/issues/4874 if (focusId) { diff --git a/app/src/util/backForward.ts b/app/src/util/backForward.ts index 2d64dbd5c..055794319 100644 --- a/app/src/util/backForward.ts +++ b/app/src/util/backForward.ts @@ -48,7 +48,7 @@ const focusStack = async (stack: IBackStack) => { callback(tab) { const editor = new Editor({ tab, - blockId: info.data.rootChildID, + blockId: stack.id, // 忘记为什么要用 rootChildID 了,但用了会产生 https://github.com/siyuan-note/siyuan/issues/6004 问题 }); tab.addModel(editor); } @@ -159,18 +159,12 @@ const focusStack = async (stack: IBackStack) => { } return false; } - const info = await fetchSyncPost("/api/block/getBlockInfo", {id: stack.id}); - if (info.code === 2) { - // 文件被锁定 - lockFile(info.data); - return false; - } fetchPost("/api/filetree/getDoc", { - id: info.data.rootChildID, + id: stack.id, // 忘记为什么要用 rootChildID 了,但用了会产生 https://github.com/siyuan-note/siyuan/issues/6004 问题 mode: stack.isZoom ? 0 : 3, size: stack.isZoom ? Constants.SIZE_GET_MAX : Constants.SIZE_GET, }, getResponse => { - onGet(getResponse, stack.protyle, [Constants.CB_GET_HTML]); + onGet(getResponse, stack.protyle, stack.isZoom ? [Constants.CB_GET_HTML, Constants.CB_GET_ALL] : [Constants.CB_GET_HTML]); Array.from(stack.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${stack.id}"]`)).find(item => { if (!hasClosestByAttribute(item, "data-type", "NodeBlockQueryEmbed")) { blockElement = item; @@ -270,7 +264,7 @@ export const pushBack = (protyle: IProtyle, range?: Range, blockElement?: Elemen const position = getSelectionOffset(editElement, undefined, range); const id = blockElement.getAttribute("data-node-id") || protyle.block.rootID; const lastStack = window.siyuan.backStack[window.siyuan.backStack.length - 1]; - const isZoom = protyle.block.id !== protyle.block.rootID; + const isZoom = protyle.block.showAll; if (lastStack && lastStack.id === id && lastStack.isZoom === isZoom) { lastStack.position = position; } else {