Skip to content

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

:rotating_light:

Vanessa580fb4007ef7
diff --git a/app/src/boot/globalShortcut.ts b/app/src/boot/globalShortcut.ts
index 8a8db0f619..80fc2b2749 100644
--- a/app/src/boot/globalShortcut.ts
+++ b/app/src/boot/globalShortcut.ts
@@ -478,7 +478,7 @@ export const globalShortcut = (app: App) => {
rootId = ` data-node-id="${item.model.editor.protyle.block.rootID}"`;
icon = unicode2Emoji(item.docIcon || Constants.SIYUAN_IMAGE_FILE, false, "b3-list-item__graphic", true);
} else if (initData) {
- const initDataObj = JSON.parse(initData)
+ const initDataObj = JSON.parse(initData);
if (initDataObj.instance === "Editor") {
rootId = ` data-node-id="${initDataObj.rootId}"`;
icon = unicode2Emoji(item.docIcon || Constants.SIYUAN_IMAGE_FILE, false, "b3-list-item__graphic", true);
diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts
index 2d35f989b0..0c3fc019a1 100644
--- a/app/src/layout/Wnd.ts
+++ b/app/src/layout/Wnd.ts
@@ -434,7 +434,7 @@ export class Wnd {
if (currentTab && currentTab.headElement) {
const initData = currentTab.headElement.getAttribute("data-initdata");
if (initData) {
- currentTab.addModel(newModelByInitData(this.app, currentTab, JSON.parse(initData)))
+ currentTab.addModel(newModelByInitData(this.app, currentTab, JSON.parse(initData)));
currentTab.headElement.removeAttribute("data-initdata");
return;
}
diff --git a/app/src/layout/dock/index.ts b/app/src/layout/dock/index.ts
index 8eed41c5a3..93a0079f33 100644
--- a/app/src/layout/dock/index.ts
+++ b/app/src/layout/dock/index.ts
@@ -65,23 +65,23 @@ export class Dock {
this.position = options.position;
this.pin = options.data.pin;
this.data = {};
- let showDock = false
+ let showDock = false;
if (options.data.data.length !== 0) {
if (!showDock) {
options.data.data[0].find(item => {
if (TYPES.includes(item.type)) {
- showDock = true
- return true
+ showDock = true;
+ return true;
}
- })
+ });
}
if (!showDock && options.data.data[1]) {
options.data.data[1].find(item => {
if (TYPES.includes(item.type)) {
- showDock = true
- return true
+ showDock = true;
+ return true;
}
- })
+ });
}
}
if (!showDock) {
diff --git a/app/src/layout/util.ts b/app/src/layout/util.ts
index 963115ee9e..6890bcd24a 100644
--- a/app/src/layout/util.ts
+++ b/app/src/layout/util.ts
@@ -408,20 +408,20 @@ export const JSONToLayout = (app: App, isStart: boolean) => {
});
// 移除没有插件的 tab
document.querySelectorAll('li[data-type="tab-header"]').forEach((item: HTMLElement) => {
- const initData = item.getAttribute("data-initdata")
+ const initData = item.getAttribute("data-initdata");
if (initData) {
const initDataObj = JSON.parse(initData);
if (initDataObj.instance === "Custom") {
let hasPlugin = false;
app.plugins.find(plugin => {
if (Object.keys(plugin.models).includes(initDataObj.customModelType)) {
- hasPlugin = true
- return true
+ hasPlugin = true;
+ return true;
}
});
if (!hasPlugin) {
- const tabId = item.getAttribute("data-id")
- const tab = getInstanceById(tabId) as Tab
+ const tabId = item.getAttribute("data-id");
+ const tab = getInstanceById(tabId) as Tab;
if (tab) {
tab.parent.removeTab(tabId, false, false, false);
}
@@ -440,7 +440,7 @@ export const JSONToLayout = (app: App, isStart: boolean) => {
} else {
document.querySelectorAll('li[data-type="tab-header"][data-init-active="true"]').forEach((item: HTMLElement) => {
item.removeAttribute("data-init-active");
- const tab = getInstanceById(item.getAttribute("data-id")) as Tab
+ const tab = getInstanceById(item.getAttribute("data-id")) as Tab;
tab.parent.switchTab(item, false, false);
});
}
@@ -719,14 +719,14 @@ export const copyTab = (app: App, tab: Tab) => {
};
export const newModelByInitData = (app: App, tab: Tab, json: any) => {
- let model: Model
+ let model: Model;
if (json.instance === "Custom") {
if (json.customModelType === "siyuan-card") {
model = newCardModel({
app,
tab: tab,
data: json.customModelData
- })
+ });
} else {
app.plugins.find(item => {
if (item.models[json.customModelType]) {
@@ -749,7 +749,7 @@ export const newModelByInitData = (app: App, tab: Tab, json: any) => {
});
}
return model;
-}
+};
export const pdfIsLoading = (element: HTMLElement) => {
const isLoading = element.querySelector('.layout-tab-container > [data-loading="true"]') ? true : false;
diff --git a/app/src/plugin/loader.ts b/app/src/plugin/loader.ts
index 3fe968eb26..b69fc332ee 100644
--- a/app/src/plugin/loader.ts
+++ b/app/src/plugin/loader.ts
@@ -80,7 +80,7 @@ export const loadPlugin = (app: App, item: IPluginData) => {
const updateDock = (dockItem: IDockTab[], index: number, plugin: Plugin, type: string) => {
- const dockKeys = Object.keys(plugin.docks)
+ const dockKeys = Object.keys(plugin.docks);
dockItem.forEach((tabItem: IDockTab, tabIndex: number) => {
if (dockKeys.includes(tabItem.type)) {
if (type === "Left") {
@@ -94,8 +94,8 @@ const updateDock = (dockItem: IDockTab[], index: number, plugin: Plugin, type: s
plugin.docks[tabItem.type].config.show = tabItem.show;
plugin.docks[tabItem.type].config.size = tabItem.size;
}
- })
-}
+ });
+};
export const afterLoadPlugin = (plugin: Plugin) => {
try {
@@ -113,14 +113,14 @@ export const afterLoadPlugin = (plugin: Plugin) => {
});
window.siyuan.config.uiLayout.left.data.forEach((dockItem: IDockTab[], index: number) => {
- updateDock(dockItem, index, plugin, "Left")
- })
+ updateDock(dockItem, index, plugin, "Left");
+ });
window.siyuan.config.uiLayout.right.data.forEach((dockItem: IDockTab[], index: number) => {
- updateDock(dockItem, index, plugin, "Right")
- })
+ updateDock(dockItem, index, plugin, "Right");
+ });
window.siyuan.config.uiLayout.bottom.data.forEach((dockItem: IDockTab[], index: number) => {
- updateDock(dockItem, index, plugin, "Bottom")
- })
+ updateDock(dockItem, index, plugin, "Bottom");
+ });
Object.keys(plugin.docks).forEach(key => {
const dock = plugin.docks[key];
if (dock.config.position.startsWith("Left")) {
@@ -153,4 +153,4 @@ export const afterLoadPlugin = (plugin: Plugin) => {
}
});
// 等待 tab 完成后再 init Tab model
-}
+};
diff --git a/app/src/plugin/uninstall.ts b/app/src/plugin/uninstall.ts
index 8b82405239..bad5d69a9b 100644
--- a/app/src/plugin/uninstall.ts
+++ b/app/src/plugin/uninstall.ts
@@ -2,6 +2,7 @@ import {App} from "../index";
import {Plugin} from "../plugin";
import {getAllModels} from "../layout/getAll";
import {exportLayout} from "../layout/util";
+import {Constants} from "../constants";
export const uninstall = (app: App, name: string) => {
app.plugins.find((plugin: Plugin, index) => {
@@ -43,11 +44,14 @@ export const uninstall = (app: App, name: string) => {
});
// rm plugin
app.plugins.splice(index, 1);
- exportLayout({
- reload: false,
- onlyData: false,
- errorExit: false
- });
+
+ setTimeout(() => {
+ exportLayout({
+ reload: false,
+ onlyData: false,
+ errorExit: false
+ });
+ }, Constants.TIMEOUT_LOAD); // 移除页签时切换到新的文档页签,需等待新页签初始化完成,才有 editor.protyle.block 等数据
return true;
}
});