mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-02 18:51:25 +08:00
This commit is contained in:
parent
a6f80dfcbd
commit
dc3889b5b3
@ -6,6 +6,8 @@ import {fetchGet, fetchPost, fetchSyncPost} from "../util/fetch";
|
|||||||
import {getBackend, getFrontend} from "../util/functions";
|
import {getBackend, getFrontend} from "../util/functions";
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
import {openFile, openFileById} from "../editor/util";
|
import {openFile, openFileById} from "../editor/util";
|
||||||
|
import {openNewWindow, openNewWindowById} from "../window/openNewWindow";
|
||||||
|
import {Tab} from "../layout/Tab";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {updateHotkeyTip} from "../protyle/util/compatibility";
|
import {updateHotkeyTip} from "../protyle/util/compatibility";
|
||||||
import {App} from "../index";
|
import {App} from "../index";
|
||||||
@ -15,11 +17,31 @@ import {Menu} from "./Menu";
|
|||||||
import {Protyle} from "../protyle";
|
import {Protyle} from "../protyle";
|
||||||
|
|
||||||
let openTab;
|
let openTab;
|
||||||
|
let openWindow;
|
||||||
/// #if MOBILE
|
/// #if MOBILE
|
||||||
openTab = () => {
|
openTab = () => {
|
||||||
// TODO: Mobile
|
// TODO: Mobile
|
||||||
};
|
};
|
||||||
|
openWindow = () => {
|
||||||
|
// TODO: Mobile
|
||||||
|
};
|
||||||
/// #else
|
/// #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: {
|
openTab = (options: {
|
||||||
app: App,
|
app: App,
|
||||||
doc?: {
|
doc?: {
|
||||||
@ -147,6 +169,7 @@ export const API = {
|
|||||||
getFrontend,
|
getFrontend,
|
||||||
getBackend,
|
getBackend,
|
||||||
openTab,
|
openTab,
|
||||||
|
openWindow,
|
||||||
Protyle,
|
Protyle,
|
||||||
Plugin,
|
Plugin,
|
||||||
Dialog,
|
Dialog,
|
||||||
|
@ -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>
|
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>`;
|
<span class="b3-list-item__meta">${updateHotkeyTip(command.customHotkey)}</span>`;
|
||||||
liElement.addEventListener("click", () => {
|
liElement.addEventListener("click", () => {
|
||||||
command.callback();
|
if (command.callback) {
|
||||||
|
command.callback();
|
||||||
|
} else if (command.globalCallback) {
|
||||||
|
command.globalCallback();
|
||||||
|
}
|
||||||
dialog.destroy();
|
dialog.destroy();
|
||||||
});
|
});
|
||||||
listElement.insertAdjacentElement("beforeend", liElement);
|
listElement.insertAdjacentElement("beforeend", liElement);
|
||||||
|
Loading…
Reference in New Issue
Block a user