diff --git a/apps/client/src/services/command_registry.ts b/apps/client/src/services/command_registry.ts index 3d73501e4..1402d390f 100644 --- a/apps/client/src/services/command_registry.ts +++ b/apps/client/src/services/command_registry.ts @@ -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]; diff --git a/apps/client/src/services/keyboard_actions.ts b/apps/client/src/services/keyboard_actions.ts index 35cae43fa..820de185c 100644 --- a/apps/client/src/services/keyboard_actions.ts +++ b/apps/client/src/services/keyboard_actions.ts @@ -13,6 +13,7 @@ export interface Action { friendlyName: string; description?: string; iconClass?: string; + isElectronOnly?: boolean; } const keyboardActionsLoaded = server.get("keyboard-actions").then((actions) => { diff --git a/apps/server/src/services/keyboard_actions.ts b/apps/server/src/services/keyboard_actions.ts index 87b3fd124..0365636ae 100644 --- a/apps/server/src/services/keyboard_actions.ts +++ b/apps/server/src/services/keyboard_actions.ts @@ -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" }, { diff --git a/packages/commons/src/lib/keyboard_actions_interface.ts b/packages/commons/src/lib/keyboard_actions_interface.ts index 9d57d4067..9b73e48b2 100644 --- a/packages/commons/src/lib/keyboard_actions_interface.ts +++ b/packages/commons/src/lib/keyboard_actions_interface.ts @@ -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;