Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: fix encrypted-notebook getDoc missing notebook param across frontend #18034

Danieldcaac401b626
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index 715c9470d1..73357b7776 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -62,6 +62,7 @@ import {hideTooltip} from "../dialog/tooltip";
import {base64ToURL} from "../util/image";
import {setPosition} from "../util/setPosition";
import {setFold} from "../protyle/util/blockFold";
+import {isEncryptedBox} from "../util/pathName";
const renderAssetList = (element: Element, k: string, position: IPosition, exts: string[] = []) => {
fetchPost("/api/search/searchAsset", {
@@ -981,10 +982,14 @@ export const zoomOut = (options: {
pushBack();
}
}
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: options.id,
size: options.id === options.protyle.block.rootID ? window.siyuan.config.editor.dynamicLoadBlocks : Constants.SIZE_GET_MAX,
- }, async (getResponse) => {
+ };
+ if (isEncryptedBox(options.protyle.notebookId)) {
+ getDocParam.notebook = options.protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, async (getResponse) => {
const action: TProtyleAction[] = [Constants.CB_GET_HTML];
if (!options.isPushBack) {
action.push(Constants.CB_GET_UNUNDO);
@@ -1028,10 +1033,14 @@ export const zoomOut = (options: {
}
focusBlock(showElement);
} else if (!options.focusId) {
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: options.protyle.block.rootID,
size: window.siyuan.config.editor.dynamicLoadBlocks,
- }, getFocusResponse => {
+ };
+ if (isEncryptedBox(options.protyle.notebookId)) {
+ getDocParam.notebook = options.protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getFocusResponse => {
onGet({
data: getFocusResponse,
protyle: options.protyle,
@@ -1040,11 +1049,15 @@ export const zoomOut = (options: {
});
return;
} else if (options.id === options.protyle.block.rootID) { // 聚焦返回后,该块是动态加载的,但是没加载出来
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: options.focusId,
mode: 3,
size: window.siyuan.config.editor.dynamicLoadBlocks,
- }, getFocusResponse => {
+ };
+ if (isEncryptedBox(options.protyle.notebookId)) {
+ getDocParam.notebook = options.protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getFocusResponse => {
onGet({
data: getFocusResponse,
protyle: options.protyle,
diff --git a/app/src/mobile/editor.ts b/app/src/mobile/editor.ts
index b4b314f765..624a0d0f16 100644
--- a/app/src/mobile/editor.ts
+++ b/app/src/mobile/editor.ts
@@ -15,6 +15,7 @@ import {showMessage} from "../dialog/message";
import {App} from "../index";
import {initMirror} from "../protyle/undo/globalUndo";
import {getDocByScroll, saveScroll} from "../protyle/scroll/saveScroll";
+import {isEncryptedBox} from "../util/pathName";
export const getCurrentEditor = () => {
return window.siyuan.mobile.popEditor || window.siyuan.mobile.editor;
@@ -98,11 +99,15 @@ export const openMobileFileById = (app: App, id: string, action: TProtyleAction[
}
});
} else {
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id,
size: action.includes(Constants.CB_GET_ALL) ? Constants.SIZE_GET_MAX : window.siyuan.config.editor.dynamicLoadBlocks,
mode: action.includes(Constants.CB_GET_CONTEXT) ? 3 : 0,
- }, getResponse => {
+ };
+ if (isEncryptedBox(window.siyuan.mobile.editor?.protyle?.notebookId)) {
+ getDocParam.notebook = window.siyuan.mobile.editor.protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
onGet({
data: getResponse,
protyle: window.siyuan.mobile.editor.protyle,
diff --git a/app/src/mobile/util/MobileBackFoward.ts b/app/src/mobile/util/MobileBackFoward.ts
index e6da528f80..4b99cbd1c5 100644
--- a/app/src/mobile/util/MobileBackFoward.ts
+++ b/app/src/mobile/util/MobileBackFoward.ts
@@ -13,6 +13,7 @@ import {showMessage} from "../../dialog/message";
import {getCurrentEditor} from "../editor";
import {avRender} from "../../protyle/render/av/render";
import {setTitle} from "../../util/processTitle";
+import {isEncryptedBox} from "../../util/pathName";
const forwardStack: IBackStack[] = [];
@@ -74,11 +75,15 @@ const focusStack = (backStack: IBackStack) => {
return;
}
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: backStack.id,
startID: backStack.data.startId,
endID: backStack.data.endId,
- }, getResponse => {
+ };
+ if (isEncryptedBox(protyle.notebookId)) {
+ getDocParam.notebook = protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
protyle.block.parentID = getResponse.data.parentID;
protyle.block.parent2ID = getResponse.data.parent2ID;
protyle.block.rootID = getResponse.data.rootID;
diff --git a/app/src/protyle/breadcrumb/index.ts b/app/src/protyle/breadcrumb/index.ts
index 3e8a6347e4..84690d28a7 100644
--- a/app/src/protyle/breadcrumb/index.ts
+++ b/app/src/protyle/breadcrumb/index.ts
@@ -29,6 +29,7 @@ import {getNoContainerElement} from "../wysiwyg/getBlock";
import {openTitleMenu} from "../header/openTitleMenu";
import {emitOpenMenu} from "../../plugin/EventBus";
import {isInAndroid, isInHarmony, isIPad, isMac, updateHotkeyTip} from "../util/compatibility";
+import {isEncryptedBox} from "../../util/pathName";
import {resize} from "../util/resize";
import {listIndent, listOutdent} from "../wysiwyg/list";
import {improveBreadcrumbAppearance} from "../wysiwyg/renderBacklink";
@@ -129,11 +130,15 @@ ${padHTML}
zoomOut({protyle, id: protyle.options.blockId});
target.classList.remove("block__icon--active");
} else {
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: protyle.options.blockId,
mode: 3,
size: window.siyuan.config.editor.dynamicLoadBlocks,
- }, getResponse => {
+ };
+ if (isEncryptedBox(protyle.notebookId)) {
+ getDocParam.notebook = protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
onGet({data: getResponse, protyle, action: [Constants.CB_GET_HL]});
});
target.classList.add("block__icon--active");
diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.ts
index 5050d41dab..f0c998010e 100644
--- a/app/src/protyle/index.ts
+++ b/app/src/protyle/index.ts
@@ -23,7 +23,7 @@ import {
updateTransaction
} from "./wysiwyg/transaction";
import {fetchPost} from "../util/fetch";
-import {getDocDisplayName} from "../util/pathName";
+import {getDocDisplayName, isEncryptedBox} from "../util/pathName";
import {initMirror, refreshUndoButtons, syncMirrorFromBroadcast} from "./undo/globalUndo";
/// #if !MOBILE
import {updatePanelByEditor} from "../editor/util";
@@ -177,10 +177,14 @@ export class Protyle {
case "li2doc":
if (this.protyle.block.rootID === data.data.srcRootBlockID) {
if (this.protyle.block.showAll && data.cmd === "heading2doc" && !this.protyle.options.backlinkData) {
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: this.protyle.block.rootID,
size: window.siyuan.config.editor.dynamicLoadBlocks,
- }, getResponse => {
+ };
+ if (isEncryptedBox(this.protyle.notebookId)) {
+ getDocParam.notebook = this.protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
onGet({data: getResponse, protyle: this.protyle});
});
} else {
@@ -382,14 +386,18 @@ export class Protyle {
}
private getDoc(mergedOptions: IProtyleOptions) {
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: mergedOptions.blockId,
isBacklink: mergedOptions.action.includes(Constants.CB_GET_BACKLINK),
originalRefBlockIDs: mergedOptions.originalRefBlockIDs,
// 0: 仅当前 ID(默认值),1:向上 2:向下,3:上下都加载,4:加载最后
mode: (mergedOptions.action && mergedOptions.action.includes(Constants.CB_GET_CONTEXT)) ? 3 : 0,
size: mergedOptions.action?.includes(Constants.CB_GET_ALL) ? Constants.SIZE_GET_MAX : window.siyuan.config.editor.dynamicLoadBlocks,
- }, getResponse => {
+ };
+ if (isEncryptedBox(this.protyle.notebookId)) {
+ getDocParam.notebook = this.protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
onGet({
data: getResponse,
protyle: this.protyle,
diff --git a/app/src/protyle/scroll/event.ts b/app/src/protyle/scroll/event.ts
index 8700fe4f49..44bf01a6c3 100644
--- a/app/src/protyle/scroll/event.ts
+++ b/app/src/protyle/scroll/event.ts
@@ -6,6 +6,7 @@ import {isMobile} from "../../util/functions";
import {hasClosestBlock, hasClosestByClassName} from "../util/hasClosest";
import {stickyRow} from "../render/av/row";
import {trimAVRowsSync} from "../render/av/virtualScroll";
+import {isEncryptedBox} from "../../util/pathName";
let getIndexTimeout: number;
const avScrollPending = new WeakSet<HTMLElement>();
@@ -91,11 +92,15 @@ export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
protyle.contentElement.style.width = (protyle.contentElement.offsetWidth) + "px";
protyle.contentElement.style.overflow = "hidden";
protyle.wysiwyg.element.setAttribute("data-top", element.scrollTop.toString());
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: protyle.wysiwyg.element.firstElementChild.getAttribute("data-node-id"),
mode: 1,
size: window.siyuan.config.editor.dynamicLoadBlocks,
- }, getResponse => {
+ };
+ if (isEncryptedBox(protyle.notebookId)) {
+ getDocParam.notebook = protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
protyle.contentElement.style.overflow = "";
protyle.contentElement.style.width = "";
onGet({
@@ -114,11 +119,15 @@ export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
return;
}
protyle.wysiwyg.element.setAttribute("data-top", element.scrollTop.toString());
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: protyle.wysiwyg.element.lastElementChild.getAttribute("data-node-id"),
mode: 2,
size: window.siyuan.config.editor.dynamicLoadBlocks,
- }, getResponse => {
+ };
+ if (isEncryptedBox(protyle.notebookId)) {
+ getDocParam.notebook = protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
onGet({
data: getResponse,
protyle,
diff --git a/app/src/protyle/scroll/index.ts b/app/src/protyle/scroll/index.ts
index 79f4ba5c9b..ced30af69b 100644
--- a/app/src/protyle/scroll/index.ts
+++ b/app/src/protyle/scroll/index.ts
@@ -5,6 +5,7 @@ import {updateHotkeyTip} from "../util/compatibility";
import {hasClosestByClassName} from "../util/hasClosest";
import {goEnd, goHome} from "../wysiwyg/commonHotkey";
import {showTooltip} from "../../dialog/tooltip";
+import {isEncryptedBox} from "../../util/pathName";
export class Scroll {
public element: HTMLElement;
@@ -68,12 +69,16 @@ export class Scroll {
}
protyle.wysiwyg.element.setAttribute("data-top", protyle.wysiwyg.element.scrollTop.toString());
protyle.contentElement.style.overflow = "hidden";
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
index: parseInt(this.inputElement.value),
id: protyle.block.parentID,
mode: 0,
size: window.siyuan.config.editor.dynamicLoadBlocks,
- }, getResponse => {
+ };
+ if (isEncryptedBox(protyle.notebookId)) {
+ getDocParam.notebook = protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
onGet({
data: getResponse,
protyle,
diff --git a/app/src/protyle/scroll/saveScroll.ts b/app/src/protyle/scroll/saveScroll.ts
index e1e55be208..f14717c672 100644
--- a/app/src/protyle/scroll/saveScroll.ts
+++ b/app/src/protyle/scroll/saveScroll.ts
@@ -5,6 +5,7 @@ import {onGet} from "../util/onGet";
import {Constants} from "../../constants";
import {setStorageVal} from "../util/compatibility";
import {isSupportCSSHL} from "../render/searchMarkRender";
+import {isEncryptedBox} from "../../util/pathName";
export const saveScroll = (protyle: IProtyle, getObject = false) => {
if (!protyle.wysiwyg.element.firstElementChild || window.siyuan.config.readonly) {
@@ -76,7 +77,7 @@ export const getDocByScroll = (options: {
}
}
if (options.scrollAttr?.zoomInId && options.scrollAttr?.rootId && options.scrollAttr.zoomInId !== options.scrollAttr.rootId) {
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: options.scrollAttr.zoomInId,
size: Constants.SIZE_GET_MAX,
query: options.protyle.query?.key,
@@ -84,16 +85,24 @@ export const getDocByScroll = (options: {
queryTypes: options.protyle.query?.types,
querySubTypes: options.protyle.query?.subTypes,
highlight: !isSupportCSSHL(),
- }, response => {
+ };
+ if (isEncryptedBox(options.protyle.notebookId)) {
+ getDocParam.notebook = options.protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, response => {
if (response.code === 1) {
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: options.scrollAttr.rootId || options.mergedOptions?.blockId || options.protyle.block?.rootID || options.scrollAttr.startId,
query: options.protyle.query?.key,
queryMethod: options.protyle.query?.method,
queryTypes: options.protyle.query?.types,
querySubTypes: options.protyle.query?.subTypes,
highlight: !isSupportCSSHL(),
- }, response => {
+ };
+ if (isEncryptedBox(options.protyle.notebookId)) {
+ getDocParam.notebook = options.protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, response => {
onGet({
scrollPosition: options.mergedOptions?.scrollPosition,
data: response,
@@ -123,7 +132,7 @@ export const getDocByScroll = (options: {
});
return;
}
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: options.scrollAttr?.rootId || options.mergedOptions?.blockId || options.protyle.block?.rootID || options.scrollAttr?.startId,
startID: options.scrollAttr?.startId,
endID: options.scrollAttr?.endId,
@@ -132,7 +141,11 @@ export const getDocByScroll = (options: {
queryTypes: options.protyle.query?.types,
querySubTypes: options.protyle.query?.subTypes,
highlight: !isSupportCSSHL(),
- }, response => {
+ };
+ if (isEncryptedBox(options.protyle.notebookId)) {
+ getDocParam.notebook = options.protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, response => {
onGet({
scrollPosition: options.mergedOptions?.scrollPosition,
data: response,
diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts
index 74d05d4b1a..19b4dd3171 100644
--- a/app/src/protyle/util/editorCommonEvent.ts
+++ b/app/src/protyle/util/editorCommonEvent.ts
@@ -52,6 +52,7 @@ import {insertGalleryItemAnimation} from "../render/av/gallery/item";
import {clearSelect} from "./clear";
import {dragoverTab} from "../render/av/view";
import {setFold} from "./blockFold";
+import {isEncryptedBox} from "../util/pathName";
// position: afterbegin 为拖拽成超级块; "afterend", "beforebegin" 一般拖拽
const moveTo = async (protyle: IProtyle, sourceElements: Element[], targetElement: Element,
@@ -1376,10 +1377,14 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
}
}
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: protyle.block.id,
size: window.siyuan.config.editor.dynamicLoadBlocks,
- }, getResponse => {
+ };
+ if (isEncryptedBox(protyle.notebookId)) {
+ getDocParam.notebook = protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
onGet({data: getResponse, protyle});
/// #if !MOBILE
// 文档标题互转后,需更新大纲
diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.ts
index 1d153cc6d6..fc39237727 100644
--- a/app/src/protyle/util/onGet.ts
+++ b/app/src/protyle/util/onGet.ts
@@ -20,6 +20,7 @@ import {hideTooltip} from "../../dialog/tooltip";
import {stickyRow} from "../render/av/row";
import {getContenteditableElement} from "../wysiwyg/getBlock";
import {activeBlur} from "../../mobile/util/keyboardToolbar";
+import {isEncryptedBox} from "../../util/pathName";
export const onGet = (options: {
data: IWebSocketData,
@@ -314,22 +315,30 @@ const setHTML = (options: {
protyle.contentElement.scrollHeight > 0 && // 没有激活的页签 https://github.com/siyuan-note/siyuan/issues/5255
!options.action.includes(Constants.CB_GET_FOCUSFIRST) && // 防止 eof 为true https://github.com/siyuan-note/siyuan/issues/5291
protyle.contentElement.scrollHeight <= protyle.contentElement.clientHeight) {
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: protyle.wysiwyg.element.lastElementChild.getAttribute("data-node-id"),
mode: 2,
size: window.siyuan.config.editor.dynamicLoadBlocks,
- }, getResponse => {
+ };
+ if (isEncryptedBox(protyle.notebookId)) {
+ getDocParam.notebook = protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
onGet({data: getResponse, protyle, action: [Constants.CB_GET_APPEND, Constants.CB_GET_UNCHANGEID]});
});
}
// 动态滚动条拖拽到最后几个块时需多加载一点块 https://github.com/siyuan-note/siyuan/issues/16906
if (options.action.includes(Constants.CB_GET_FOCUSFIRST) &&
protyle.wysiwyg.element.getBoundingClientRect().top > protyle.breadcrumb.element.getBoundingClientRect().bottom) {
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: protyle.wysiwyg.element.firstElementChild.getAttribute("data-node-id"),
mode: 1,
size: window.siyuan.config.editor.dynamicLoadBlocks,
- }, getResponse => {
+ };
+ if (isEncryptedBox(protyle.notebookId)) {
+ getDocParam.notebook = protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
onGet({
data: getResponse,
protyle,
diff --git a/app/src/protyle/wysiwyg/commonHotkey.ts b/app/src/protyle/wysiwyg/commonHotkey.ts
index c6a9123232..0b3430fa8e 100644
--- a/app/src/protyle/wysiwyg/commonHotkey.ts
+++ b/app/src/protyle/wysiwyg/commonHotkey.ts
@@ -16,6 +16,7 @@ import {copyTextByType} from "../toolbar/util";
import {hasClosestByTag, hasTopClosestByClassName} from "../util/hasClosest";
import {removeEmbed} from "./removeEmbed";
import {clearBlockElement} from "../util/clear";
+import {isEncryptedBox} from "../../util/pathName";
export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent, nodeElement?: HTMLElement) => {
if (matchHotKey(window.siyuan.config.keymap.editor.general.netImg2LocalAsset.custom, event)) {
@@ -413,11 +414,15 @@ export const goHome = (protyle: IProtyle) => {
protyle.contentElement.scrollTop = 0;
protyle.scroll.lastScrollTop = 1;
} else {
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: protyle.block.rootID,
mode: 0,
size: window.siyuan.config.editor.dynamicLoadBlocks,
- }, getResponse => {
+ };
+ if (isEncryptedBox(protyle.notebookId)) {
+ getDocParam.notebook = protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
onGet({data: getResponse, protyle, action: [Constants.CB_GET_FOCUS]});
});
}
@@ -426,11 +431,15 @@ export const goHome = (protyle: IProtyle) => {
export const goEnd = (protyle: IProtyle) => {
if (!protyle.scroll.element.classList.contains("fn__none") &&
protyle.wysiwyg.element.lastElementChild.getAttribute("data-eof") !== "2") {
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: protyle.block.rootID,
mode: 4,
size: window.siyuan.config.editor.dynamicLoadBlocks,
- }, getResponse => {
+ };
+ if (isEncryptedBox(protyle.notebookId)) {
+ getDocParam.notebook = protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
onGet({
data: getResponse,
protyle,
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index b0de9b3d81..099972d51b 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -107,6 +107,7 @@ import {updateCalloutType} from "./callout";
import {nbsp2space, removeZWJ} from "../util/normalizeText";
import {setFold} from "../util/blockFold";
import {BlockPanel} from "../../block/Panel";
+import {isEncryptedBox} from "../../util/pathName";
export class WYSIWYG {
public lastHTMLs: { [key: string]: string } = {};
@@ -2638,11 +2639,15 @@ export class WYSIWYG {
if (!preventGetTopHTML && !protyle.scroll.element.classList.contains("fn__none")) {
if (event.deltaY < 0 && protyle.wysiwyg.element.firstElementChild.getAttribute("data-eof") !== "1" &&
(protyle.contentElement.clientHeight === protyle.contentElement.scrollHeight || protyle.contentElement.scrollTop === 0)) {
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: protyle.wysiwyg.element.firstElementChild.getAttribute("data-node-id"),
mode: 1,
size: window.siyuan.config.editor.dynamicLoadBlocks,
- }, getResponse => {
+ };
+ if (isEncryptedBox(protyle.notebookId)) {
+ getDocParam.notebook = protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
preventGetTopHTML = false;
onGet({
data: getResponse,
@@ -2654,11 +2659,15 @@ export class WYSIWYG {
} else if (event.deltaY > 0 && protyle.wysiwyg.element.lastElementChild.getAttribute("data-eof") !== "2" &&
(protyle.contentElement.clientHeight === protyle.contentElement.scrollHeight ||
protyle.contentElement.clientHeight + Math.ceil(protyle.contentElement.scrollTop) >= protyle.contentElement.scrollHeight)) {
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: protyle.wysiwyg.element.lastElementChild.getAttribute("data-node-id"),
mode: 2,
size: window.siyuan.config.editor.dynamicLoadBlocks,
- }, getResponse => {
+ };
+ if (isEncryptedBox(protyle.notebookId)) {
+ getDocParam.notebook = protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
preventGetTopHTML = false;
onGet({
data: getResponse,
diff --git a/app/src/protyle/wysiwyg/remove.ts b/app/src/protyle/wysiwyg/remove.ts
index 8b0e8d2dce..cd8ded3464 100644
--- a/app/src/protyle/wysiwyg/remove.ts
+++ b/app/src/protyle/wysiwyg/remove.ts
@@ -31,6 +31,7 @@ import {Backlink} from "../../layout/dock/Backlink";
import {fetchPost, fetchSyncPost} from "../../util/fetch";
import {onGet} from "../util/onGet";
import {setFold} from "../util/blockFold";
+import {isEncryptedBox} from "../../util/pathName";
export const removeBlock = async (protyle: IProtyle, blockElement: Element, range: Range, type: "Delete" | "Backspace" | "remove") => {
protyle.observerLoad?.disconnect();
@@ -301,11 +302,15 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang
!protyle.scroll.element.classList.contains("fn__none") &&
protyle.contentElement.scrollHeight - protyle.contentElement.scrollTop < protyle.contentElement.clientHeight * 2
) {
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: protyle.wysiwyg.element.lastElementChild.getAttribute("data-node-id"),
mode: 2,
size: window.siyuan.config.editor.dynamicLoadBlocks,
- }, getResponse => {
+ };
+ if (isEncryptedBox(protyle.notebookId)) {
+ getDocParam.notebook = protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
onGet({
data: getResponse,
protyle,
diff --git a/app/src/protyle/wysiwyg/renderBacklink.ts b/app/src/protyle/wysiwyg/renderBacklink.ts
index fe4920df97..3c9af9561f 100644
--- a/app/src/protyle/wysiwyg/renderBacklink.ts
+++ b/app/src/protyle/wysiwyg/renderBacklink.ts
@@ -8,6 +8,7 @@ import {blockRender} from "../render/blockRender";
import {disabledForeverProtyle, disabledProtyle} from "../util/onGet";
import {avRender} from "../render/av/render";
import {hasClosestByAttribute} from "../util/hasClosest";
+import {isEncryptedBox} from "../../util/pathName";
export const renderBacklink = (protyle: IProtyle, backlinkData: {
blockPaths: IBreadcrumb[],
@@ -63,10 +64,14 @@ const setBacklinkFold = (html: string, expand: boolean) => {
};
export const loadBreadcrumb = (protyle: IProtyle, element: HTMLElement) => {
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: element.getAttribute("data-id"),
size: Constants.SIZE_GET_MAX,
- }, getResponse => {
+ };
+ if (isEncryptedBox(protyle.notebookId)) {
+ getDocParam.notebook = protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
element.parentElement.querySelector(".protyle-breadcrumb__item--active").classList.remove("protyle-breadcrumb__item--active");
element.classList.add("protyle-breadcrumb__item--active");
let nextElement = element.parentElement.nextElementSibling;
diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts
index d85f41aa19..500504426e 100644
--- a/app/src/protyle/wysiwyg/transaction.ts
+++ b/app/src/protyle/wysiwyg/transaction.ts
@@ -22,6 +22,7 @@ import {resize} from "../util/resize";
import {processClonePHElement} from "../render/util";
import {scrollCenter} from "../../util/highlightById";
import {setFold} from "../util/blockFold";
+import {isEncryptedBox} from "../../util/pathName";
const removeTopElement = (updateElement: Element, protyle: IProtyle) => {
// 移动到其他文档中,该块需移除
@@ -1556,11 +1557,15 @@ const processFold = (operation: IOperation, protyle: IProtyle) => {
!protyle.scroll.element.classList.contains("fn__none") &&
protyle.contentElement.scrollHeight - protyle.contentElement.scrollTop < protyle.contentElement.clientHeight * 2 // https://github.com/siyuan-note/siyuan/issues/7785
) {
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: protyle.wysiwyg.element.lastElementChild.getAttribute("data-node-id"),
mode: 2,
size: window.siyuan.config.editor.dynamicLoadBlocks,
- }, getResponse => {
+ };
+ if (isEncryptedBox(protyle.notebookId)) {
+ getDocParam.notebook = protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
onGet({
data: getResponse,
protyle,
diff --git a/app/src/search/util.ts b/app/src/search/util.ts
index 58e9aa8802..3632748988 100644
--- a/app/src/search/util.ts
+++ b/app/src/search/util.ts
@@ -1157,7 +1157,7 @@ export const getArticle = (options: {
if (articleId !== options.id) {
return;
}
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: options.id,
query: options.value || null,
queryMethod: options.config?.method || null,
@@ -1167,7 +1167,11 @@ export const getArticle = (options: {
size: zoomIn ? Constants.SIZE_GET_MAX : window.siyuan.config.editor.dynamicLoadBlocks,
zoom: zoomIn,
highlight: !isSupportCSSHL(),
- }, getResponse => {
+ };
+ if (isEncryptedBox(options.edit.protyle.notebookId)) {
+ getDocParam.notebook = options.edit.protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
if (articleId !== options.id) {
return;
}
diff --git a/app/src/util/backForward.ts b/app/src/util/backForward.ts
index bb4966c3de..0d070f8f02 100644
--- a/app/src/util/backForward.ts
+++ b/app/src/util/backForward.ts
@@ -15,6 +15,7 @@ import {saveScroll} from "../protyle/scroll/saveScroll";
import {getAllModels} from "../layout/getAll";
import {App} from "../index";
import {onGet} from "../protyle/util/onGet";
+import {isEncryptedBox} from "./pathName";
let forwardStack: IBackStack[] = [];
let previousIsBack = false;
@@ -155,11 +156,15 @@ const focusStack = async (app: App, stack: IBackStack) => {
}
// 动态加载导致内容移除 https://github.com/siyuan-note/siyuan/issues/10692
if (!blockElement && !stack.zoomId && !stack.protyle.scroll.element.classList.contains("fn__none")) {
- fetchPost("/api/filetree/getDoc", {
+ const getDocParam: IObject = {
id: stack.id,
mode: 3,
size: window.siyuan.config.editor.dynamicLoadBlocks,
- }, getResponse => {
+ };
+ if (isEncryptedBox(stack.protyle.notebookId)) {
+ getDocParam.notebook = stack.protyle.notebookId;
+ }
+ fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
onGet({
data: getResponse,
protyle: stack.protyle,