mirror of
https://github.com/zadam/trilium.git
synced 2025-10-26 07:46:30 +01:00
feat(command_palette): hide electron-only actions on web
This commit is contained in:
@@ -2,6 +2,7 @@ import appContext, { type CommandNames } from "../components/app_context.js";
|
||||
import type NoteTreeWidget from "../widgets/note_tree.js";
|
||||
import { t, translationsInitializedPromise } from "./i18n.js";
|
||||
import keyboardActions, { Action } from "./keyboard_actions.js";
|
||||
import utils from "./utils.js";
|
||||
|
||||
export interface CommandDefinition {
|
||||
id: string;
|
||||
@@ -171,6 +172,11 @@ class CommandRegistry {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip Electron-only actions if not in Electron environment
|
||||
if (action.isElectronOnly && !utils.isElectron()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the primary shortcut (first one in the list)
|
||||
const primaryShortcut = action.effectiveShortcuts?.[0];
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ export interface Action {
|
||||
friendlyName: string;
|
||||
description?: string;
|
||||
iconClass?: string;
|
||||
isElectronOnly?: boolean;
|
||||
}
|
||||
|
||||
const keyboardActionsLoaded = server.get<Action[]>("keyboard-actions").then((actions) => {
|
||||
|
||||
@@ -275,6 +275,7 @@ function getDefaultKeyboardActions() {
|
||||
friendlyName: t("keyboard_action_names.open-new-tab"),
|
||||
iconClass: "bx bx-plus",
|
||||
defaultShortcuts: isElectron ? ["CommandOrControl+T"] : [],
|
||||
isElectronOnly: true,
|
||||
description: t("keyboard_actions.open-new-tab"),
|
||||
scope: "window"
|
||||
},
|
||||
@@ -283,6 +284,7 @@ function getDefaultKeyboardActions() {
|
||||
friendlyName: t("keyboard_action_names.close-active-tab"),
|
||||
iconClass: "bx bx-minus",
|
||||
defaultShortcuts: isElectron ? ["CommandOrControl+W"] : [],
|
||||
isElectronOnly: true,
|
||||
description: t("keyboard_actions.close-active-tab"),
|
||||
scope: "window"
|
||||
},
|
||||
@@ -291,6 +293,7 @@ function getDefaultKeyboardActions() {
|
||||
friendlyName: t("keyboard_action_names.reopen-last-tab"),
|
||||
iconClass: "bx bx-undo",
|
||||
defaultShortcuts: isElectron ? ["CommandOrControl+Shift+T"] : [],
|
||||
isElectronOnly: true,
|
||||
description: t("keyboard_actions.reopen-last-tab"),
|
||||
scope: "window"
|
||||
},
|
||||
@@ -299,6 +302,7 @@ function getDefaultKeyboardActions() {
|
||||
friendlyName: t("keyboard_action_names.activate-next-tab"),
|
||||
iconClass: "bx bx-skip-next",
|
||||
defaultShortcuts: isElectron ? ["CommandOrControl+Tab", "CommandOrControl+PageDown"] : [],
|
||||
isElectronOnly: true,
|
||||
description: t("keyboard_actions.activate-next-tab"),
|
||||
scope: "window"
|
||||
},
|
||||
@@ -307,6 +311,7 @@ function getDefaultKeyboardActions() {
|
||||
friendlyName: t("keyboard_action_names.activate-previous-tab"),
|
||||
iconClass: "bx bx-skip-previous",
|
||||
defaultShortcuts: isElectron ? ["CommandOrControl+Shift+Tab", "CommandOrControl+PageUp"] : [],
|
||||
isElectronOnly: true,
|
||||
description: t("keyboard_actions.activate-previous-tab"),
|
||||
scope: "window"
|
||||
},
|
||||
@@ -748,6 +753,7 @@ function getDefaultKeyboardActions() {
|
||||
friendlyName: t("keyboard_action_names.open-developer-tools"),
|
||||
iconClass: "bx bx-bug-alt",
|
||||
defaultShortcuts: isElectron ? ["CommandOrControl+Shift+I"] : [],
|
||||
isElectronOnly: true,
|
||||
description: t("keyboard_actions.open-dev-tools"),
|
||||
scope: "window"
|
||||
},
|
||||
@@ -756,6 +762,7 @@ function getDefaultKeyboardActions() {
|
||||
friendlyName: t("keyboard_action_names.find-in-text"),
|
||||
iconClass: "bx bx-search",
|
||||
defaultShortcuts: isElectron ? ["CommandOrControl+F"] : [],
|
||||
isElectronOnly: true,
|
||||
description: t("keyboard_actions.find-in-text"),
|
||||
scope: "window"
|
||||
},
|
||||
@@ -780,6 +787,7 @@ function getDefaultKeyboardActions() {
|
||||
friendlyName: t("keyboard_action_names.zoom-out"),
|
||||
iconClass: "bx bx-zoom-out",
|
||||
defaultShortcuts: isElectron ? ["CommandOrControl+-"] : [],
|
||||
isElectronOnly: true,
|
||||
description: t("keyboard_actions.zoom-out"),
|
||||
scope: "window"
|
||||
},
|
||||
@@ -789,6 +797,7 @@ function getDefaultKeyboardActions() {
|
||||
iconClass: "bx bx-zoom-in",
|
||||
description: t("keyboard_actions.zoom-in"),
|
||||
defaultShortcuts: isElectron ? ["CommandOrControl+="] : [],
|
||||
isElectronOnly: true,
|
||||
scope: "window"
|
||||
},
|
||||
{
|
||||
@@ -797,6 +806,7 @@ function getDefaultKeyboardActions() {
|
||||
iconClass: "bx bx-search-alt",
|
||||
description: t("keyboard_actions.reset-zoom-level"),
|
||||
defaultShortcuts: isElectron ? ["CommandOrControl+0"] : [],
|
||||
isElectronOnly: true,
|
||||
scope: "window"
|
||||
},
|
||||
{
|
||||
|
||||
@@ -122,6 +122,11 @@ export interface ActionKeyboardShortcut {
|
||||
* e.g. CTRL-C in note tree does something a bit different from CTRL-C in the text editor.
|
||||
*/
|
||||
scope?: "window" | "note-tree" | "text-detail" | "code-detail";
|
||||
/**
|
||||
* Whether the action is only available for the desktop application.
|
||||
* This is used to hide actions that are not available in the web version.
|
||||
*/
|
||||
isElectronOnly?: boolean;
|
||||
}
|
||||
|
||||
export type KeyboardShortcut = ActionKeyboardShortcut | KeyboardShortcutSeparator;
|
||||
|
||||
Reference in New Issue
Block a user