Skip to content

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

:bug: fix https://github.com/siyuan-note/siyuan/issues/6581

Vanessad2145ec91637
diff --git a/app/src/index.ts b/app/src/index.ts
index f68939debd..4c6e35d5bf 100644
--- a/app/src/index.ts
+++ b/app/src/index.ts
@@ -22,6 +22,7 @@ import {promiseTransactions} from "./protyle/wysiwyg/transaction";
import {initMessage} from "./dialog/message";
import {resizeDrag} from "./layout/util";
import {setLocalStorage} from "./protyle/util/compatibility";
+import {getAllTabs} from "./layout/getAll";
class App {
constructor() {
@@ -46,6 +47,45 @@ class App {
case"progress":
progressLoading(data);
break;
+ case "rename":
+ getAllTabs().forEach((tab) => {
+ if (tab.headElement) {
+ const initTab = tab.headElement.getAttribute("data-initdata")
+ if (initTab) {
+ const initTabData = JSON.parse(initTab)
+ if (initTabData.rootId === data.data.id) {
+ tab.updateTitle(data.data.title);
+ }
+ }
+ }
+ });
+ break;
+ case "unmount":
+ getAllTabs().forEach((tab) => {
+ if (tab.headElement) {
+ const initTab = tab.headElement.getAttribute("data-initdata")
+ if (initTab) {
+ const initTabData = JSON.parse(initTab)
+ if (data.data.box === initTabData.notebookId) {
+ tab.parent.removeTab(tab.id);
+ }
+ }
+ }
+ });
+ break;
+ case "removeDoc":
+ getAllTabs().forEach((tab) => {
+ if (tab.headElement) {
+ const initTab = tab.headElement.getAttribute("data-initdata")
+ if (initTab) {
+ const initTabData = JSON.parse(initTab)
+ if (data.data.ids.includes(initTabData.rootId)) {
+ tab.parent.removeTab(tab.id);
+ }
+ }
+ }
+ });
+ break;
case"statusbar":
progressStatus(data);
break;
diff --git a/app/src/layout/util.ts b/app/src/layout/util.ts
index 11d389107e..d234002992 100644
--- a/app/src/layout/util.ts
+++ b/app/src/layout/util.ts
@@ -345,6 +345,7 @@ export const layoutToJSON = (layout: Layout | Wnd | Tab | Model, json: any) => {
}
json.instance = "Tab";
} else if (layout instanceof Editor) {
+ json.notebookId = layout.editor.protyle.notebookId;
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";