Skip to content

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

:sparkles: https://github.com/siyuan-note/siyuan/issues/9032

Vanessadc3889b5b339
diff --git a/app/src/plugin/API.ts b/app/src/plugin/API.ts
index 5c45bd229b..5579ec2752 100644
--- a/app/src/plugin/API.ts
+++ b/app/src/plugin/API.ts
@@ -6,6 +6,8 @@ import {fetchGet, fetchPost, fetchSyncPost} from "../util/fetch";
import {getBackend, getFrontend} from "../util/functions";
/// #if !MOBILE
import {openFile, openFileById} from "../editor/util";
+import {openNewWindow, openNewWindowById} from "../window/openNewWindow";
+import {Tab} from "../layout/Tab";
/// #endif
import {updateHotkeyTip} from "../protyle/util/compatibility";
import {App} from "../index";
@@ -15,11 +17,31 @@ import {Menu} from "./Menu";
import {Protyle} from "../protyle";
let openTab;
+let openWindow;
/// #if MOBILE
openTab = () => {
// TODO: Mobile
};
+openWindow = () => {
+ // TODO: Mobile
+};
/// #else
+openWindow = (options: {
+ tab?: Tab,
+ doc?: {
+ id: string, // 块 id
+ },
+}) => {
+ if (options.doc.id) {
+ openNewWindowById(options.doc.id);
+ return;
+ }
+ if (options.tab) {
+ openNewWindow(options.tab)
+ return;
+ }
+};
+
openTab = (options: {
app: App,
doc?: {
@@ -147,6 +169,7 @@ export const API = {
getFrontend,
getBackend,
openTab,
+ openWindow,
Protyle,
Plugin,
Dialog,
diff --git a/app/src/plugin/commandPanel.ts b/app/src/plugin/commandPanel.ts
index a6b5b20f5b..81d037b333 100644
--- a/app/src/plugin/commandPanel.ts
+++ b/app/src/plugin/commandPanel.ts
@@ -26,7 +26,11 @@ export const commandPanel = (app: App) => {
liElement.innerHTML = `<span class="b3-list-item__text">${plugin.displayName}: ${command.langText || plugin.i18n[command.langKey]}</span>
<span class="b3-list-item__meta">${updateHotkeyTip(command.customHotkey)}</span>`;
liElement.addEventListener("click", () => {
- command.callback();
+ if (command.callback) {
+ command.callback();
+ } else if (command.globalCallback) {
+ command.globalCallback();
+ }
dialog.destroy();
});
listElement.insertAdjacentElement("beforeend", liElement);