diff --git a/app/src/boot/globalEvent/commandPanel.ts b/app/src/boot/globalEvent/commandPanel.ts index ee72e51a1..baf81d5a6 100644 --- a/app/src/boot/globalEvent/commandPanel.ts +++ b/app/src/boot/globalEvent/commandPanel.ts @@ -21,17 +21,29 @@ export const commandPanel = (app: App) => {
+
+ ↑/↓ ${window.siyuan.languages.searchTip1} + Enter/Click ${window.siyuan.languages.confirm} + Esc ${window.siyuan.languages.close} +
` }); dialog.element.setAttribute("data-key", Constants.DIALOG_COMMANDPANEL); const listElement = dialog.element.querySelector("#commands"); + /// #if !MOBILE + let html = "" + Object.keys(window.siyuan.config.keymap.general).forEach((key) => { + html += `
  • + ${window.siyuan.languages[key]} + ${updateHotkeyTip(window.siyuan.config.keymap.general[key].custom)} +
  • `; + }); + listElement.insertAdjacentHTML("beforeend", html); + /// #endif app.plugins.forEach(plugin => { plugin.commands.forEach(command => { const liElement = document.createElement("li"); liElement.classList.add("b3-list-item"); - if (listElement.childElementCount === 0) { - liElement.classList.add("b3-list-item--focus"); - } liElement.innerHTML = `${plugin.displayName}: ${command.langText || plugin.i18n[command.langKey]} ${updateHotkeyTip(command.customHotkey)}`; liElement.addEventListener("click", () => { @@ -49,12 +61,9 @@ export const commandPanel = (app: App) => { if (listElement.childElementCount === 0) { const liElement = document.createElement("li"); liElement.classList.add("b3-list-item", "b3-list-item--focus"); - liElement.innerHTML = `${isMobile() ? window.siyuan.languages._kernel[122] : window.siyuan.languages.commandEmpty}`; + liElement.innerHTML = `${window.siyuan.languages._kernel[122]}`; liElement.addEventListener("click", () => { dialog.destroy(); - /// #if !MOBILE - openSetting(app).element.querySelector('.b3-tab-bar [data-name="bazaar"]').dispatchEvent(new CustomEvent("click")); - /// #endif }); listElement.insertAdjacentElement("beforeend", liElement); } else { @@ -72,7 +81,12 @@ export const commandPanel = (app: App) => { if (event.key === "Enter") { const currentElement = listElement.querySelector(".b3-list-item--focus"); if (currentElement) { - currentElement.dispatchEvent(new CustomEvent("click")); + const command = currentElement.getAttribute("data-command"); + if (command) { + execByCommand(command, app); + } else { + currentElement.dispatchEvent(new CustomEvent("click")); + } } dialog.destroy(); } else if (event.key === "Escape") { @@ -108,3 +122,10 @@ const filterList = (inputElement: HTMLInputElement, listElement: Element) => { } }); }; + +const execByCommand = (command: string, app: App) => { + switch (command) { + case "openSetting": + break; + } +}; diff --git a/app/src/layout/topBar.ts b/app/src/layout/topBar.ts index a07dc26fb..c30e2a9fe 100644 --- a/app/src/layout/topBar.ts +++ b/app/src/layout/topBar.ts @@ -42,6 +42,9 @@ export const initBar = (app: App) => {
    +
    + +
    @@ -179,6 +182,10 @@ export const initBar = (app: App) => { openPlugin(app, target); event.stopPropagation(); break; + } else if (targetId === "barCommand") { + commandPanel(app); + event.stopPropagation(); + break; } else if (targetId === "barZoom") { if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && window.siyuan.menus.menu.element.getAttribute("data-name") === "barZoom") { @@ -303,14 +310,6 @@ const openPlugin = (app: App, target: Element) => { } }); } - menu.addItem({ - icon: "iconLayoutBottom", - accelerator: window.siyuan.config.keymap.general.commandPanel.custom, - label: window.siyuan.languages.commandPanel, - click() { - commandPanel(app); - } - }); menu.addSeparator(); let hasPlugin = false; app.plugins.forEach((plugin) => {