An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Pass notebookId through Editor/Protyle chain for encrypted box context, skip closed encrypted notebook tabs on layout restore, add cycle detection in Files path traversal https://github.com/siyuan-note/siyuan/issues/18034
Daniel4e88c1dd3082
diff --git a/app/src/editor/index.ts b/app/src/editor/index.tsindex ffc82cd716..b241df1acf 100644--- a/app/src/editor/index.ts+++ b/app/src/editor/index.ts@@ -20,6 +20,7 @@ export class Editor extends Model {tab: Tab,blockId: string,rootId: string,+ notebookId?: string,mode?: TEditorMode,action?: TProtyleAction[],afterInitProtyle?: (editor: Protyle) => void,@@ -42,6 +43,7 @@ export class Editor extends Model {blockId: string,action?: TProtyleAction[]rootId: string,+ notebookId?: string,mode?: TEditorMode,scrollPosition?: ScrollLogicalPosition,afterInitProtyle?: (editor: Protyle) => void,@@ -50,6 +52,7 @@ export class Editor extends Model {action: options.action || [],blockId: options.blockId,rootId: options.rootId,+ notebookId: options.notebookId,mode: options.mode,render: {title: true,diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.tsindex 45c3180679..3c59fba02c 100644--- a/app/src/layout/dock/Files.ts+++ b/app/src/layout/dock/Files.ts@@ -1327,7 +1327,12 @@ data-type="navigation-root" data-path="/">}let currentPath = filePath;let liElement: HTMLElement;+ const visitedPaths = new Set<string>();while (!liElement) {+ if (visitedPaths.has(currentPath)) {+ return;+ }+ visitedPaths.add(currentPath);liElement = treeElement.querySelector(`[data-path="${currentPath}"]`);if (!liElement) {const dirname = pathPosix().dirname(currentPath);diff --git a/app/src/layout/util.ts b/app/src/layout/util.tsindex f7bd403637..ee06ddf8df 100644--- a/app/src/layout/util.ts+++ b/app/src/layout/util.ts@@ -22,7 +22,7 @@ import {Backlink} from "./dock/Backlink";import {openFileById} from "../editor/util";import {isWindow} from "../util/functions";import {showMessage} from "../dialog/message";-import {parseUriInfo} from "../util/pathName";+import {isEncryptedBox, parseUriInfo} from "../util/pathName";import {Custom} from "./dock/Custom";import {newCardModel} from "../card/newCardTab";import {App} from "../index";@@ -377,6 +377,12 @@ export const JSONToCenter = (}(layout as Wnd).addTab(child, false, false, json.activeTime);} else if (json.instance === "Editor" && json.blockId) {+ const notebook = window.siyuan.notebooks.find((item) => item.id === json.notebookId);+ if (notebook?.closed && isEncryptedBox(json.notebookId)) {+ (layout as Tab).headElement.removeAttribute("data-init-active");+ removedTabs.push(layout as Tab);+ return;+ }if (window.siyuan.config.fileTree.openFilesUseCurrentTab) {(layout as Tab).headElement.classList.add("item--unupdate");}@@ -791,6 +797,7 @@ export const newModelByInitData = (app: App, tab: Tab, json: any) => {tab,rootId: json.rootId,blockId: json.blockId,+ notebookId: json.notebookId,mode: json.mode,scrollPosition: json.scrollPosition,action: Array.isArray(json.action) ? json.action.concat(Constants.CB_GET_FOCUS) :diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.tsindex e6c1445a35..e8b8bbdc42 100644--- a/app/src/protyle/index.ts+++ b/app/src/protyle/index.ts@@ -79,6 +79,7 @@ export class Protyle {lite: !!options.lite,updated: false,element: id,+ notebookId: mergedOptions.notebookId,options: mergedOptions,block: {},highlight: {diff --git a/app/src/types/protyle.d.ts b/app/src/types/protyle.d.tsindex f7c9d6470d..8a9b5bc95f 100644--- a/app/src/types/protyle.d.ts+++ b/app/src/types/protyle.d.ts@@ -472,6 +472,7 @@ interface IProtyleOptions {mode?: TEditorMode,blockId?: stringrootId?: string+ notebookId?: stringoriginalRefBlockIDs?: IObjectkey?: stringdefIds?: string[]