Skip to content

Commit dc3889b

Browse files
committed
#9032
1 parent a6f80df commit dc3889b

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

app/src/plugin/API.ts

+23
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {fetchGet, fetchPost, fetchSyncPost} from "../util/fetch";
66
import {getBackend, getFrontend} from "../util/functions";
77
/// #if !MOBILE
88
import {openFile, openFileById} from "../editor/util";
9+
import {openNewWindow, openNewWindowById} from "../window/openNewWindow";
10+
import {Tab} from "../layout/Tab";
911
/// #endif
1012
import {updateHotkeyTip} from "../protyle/util/compatibility";
1113
import {App} from "../index";
@@ -15,11 +17,31 @@ import {Menu} from "./Menu";
1517
import {Protyle} from "../protyle";
1618

1719
let openTab;
20+
let openWindow;
1821
/// #if MOBILE
1922
openTab = () => {
2023
// TODO: Mobile
2124
};
25+
openWindow = () => {
26+
// TODO: Mobile
27+
};
2228
/// #else
29+
openWindow = (options: {
30+
tab?: Tab,
31+
doc?: {
32+
id: string, // 块 id
33+
},
34+
}) => {
35+
if (options.doc.id) {
36+
openNewWindowById(options.doc.id);
37+
return;
38+
}
39+
if (options.tab) {
40+
openNewWindow(options.tab)
41+
return;
42+
}
43+
};
44+
2345
openTab = (options: {
2446
app: App,
2547
doc?: {
@@ -147,6 +169,7 @@ export const API = {
147169
getFrontend,
148170
getBackend,
149171
openTab,
172+
openWindow,
150173
Protyle,
151174
Plugin,
152175
Dialog,

app/src/plugin/commandPanel.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ export const commandPanel = (app: App) => {
2626
liElement.innerHTML = `<span class="b3-list-item__text">${plugin.displayName}: ${command.langText || plugin.i18n[command.langKey]}</span>
2727
<span class="b3-list-item__meta">${updateHotkeyTip(command.customHotkey)}</span>`;
2828
liElement.addEventListener("click", () => {
29-
command.callback();
29+
if (command.callback) {
30+
command.callback();
31+
} else if (command.globalCallback) {
32+
command.globalCallback();
33+
}
3034
dialog.destroy();
3135
});
3236
listElement.insertAdjacentElement("beforeend", liElement);

0 commit comments

Comments
 (0)