diff --git a/apps/desktop/src/components/editor/EditorSettingsDialog.vue b/apps/desktop/src/components/editor/EditorSettingsDialog.vue index 5d98645e7..2f0fbaeea 100644 --- a/apps/desktop/src/components/editor/EditorSettingsDialog.vue +++ b/apps/desktop/src/components/editor/EditorSettingsDialog.vue @@ -14,6 +14,7 @@ import { PackageSearch, Pencil, RefreshCw, + RotateCcw, Settings, Terminal, Trash2, @@ -71,7 +72,6 @@ import { eventToShortcut } from "@/lib/keyboardShortcuts"; import { SHORTCUT_DEFINITIONS, findShortcutConflict, - formatShortcut, normalizeShortcutSettings, type ShortcutActionId, } from "@/lib/shortcutRegistry"; @@ -119,6 +119,7 @@ const editShowColumnCommentsInHeader = ref(settingsStore.editorSettings.showColu const editCompactColumnHeaderActions = ref(settingsStore.editorSettings.compactColumnHeaderActions); const editRedisScanPageSize = ref(settingsStore.editorSettings.redisScanPageSize); const editShortcuts = ref(normalizeShortcutSettings(settingsStore.editorSettings.shortcuts)); +const editingShortcutId = ref(null); const editSidebarActivation = ref(settingsStore.editorSettings.sidebarActivation); const editSidebarObjectDisplay = ref(settingsStore.editorSettings.sidebarObjectDisplay); const sidebarObjectDisplayHelp = ref<"grouped" | "simple" | null>(null); @@ -496,9 +497,56 @@ function onShortcutChange(actionId: ShortcutActionId, value: any) { function onShortcutKeydown(actionId: ShortcutActionId, event: KeyboardEvent) { event.preventDefault(); event.stopPropagation(); + if (editingShortcutId.value !== actionId) return; + if (event.key === "Escape") { + editingShortcutId.value = null; + return; + } const shortcut = eventToShortcut(event); if (!shortcut) return; onShortcutChange(actionId, shortcut); + editingShortcutId.value = null; +} + +function formatShortcutPill(shortcut: string): string { + const isMac = globalThis.navigator?.platform?.toLowerCase().includes("mac") ?? false; + return shortcut + .split("+") + .filter(Boolean) + .map((part) => { + if (part === "Mod") return isMac ? "⌘" : "Ctrl"; + if (part === "Meta") return isMac ? "⌘" : "Meta"; + if (part === "Shift") return isMac ? "⇧" : "Shift"; + if (part === "Alt") return isMac ? "⌥" : "Alt"; + if (part === "Control" || part === "Ctrl") return isMac ? "⌃" : "Ctrl"; + if (part === "Enter") return "↵"; + if (part === "Backspace") return "⌫"; + if (part === "Delete") return isMac ? "⌦" : "Del"; + if (part === "Escape") return "Esc"; + if (part === "ArrowUp") return "↑"; + if (part === "ArrowDown") return "↓"; + if (part === "ArrowLeft") return "←"; + if (part === "ArrowRight") return "→"; + if (part === " ") return "Space"; + return part.length === 1 ? part.toUpperCase() : part; + }) + .join(isMac ? " " : " + "); +} + +const shortcutPressShortcutLabel = computed(() => t("settings.shortcutPressShortcut")); +const shortcutPressShortcutInputWidth = computed(() => `${shortcutPressShortcutLabel.value.length + 2}em`); + +function focusShortcutInput(actionId: ShortcutActionId) { + editingShortcutId.value = actionId; + const input = document.querySelector(`[data-shortcut-input="${actionId}"]`); + requestAnimationFrame(() => { + input?.focus(); + input?.select(); + }); +} + +function cancelShortcutEdit() { + editingShortcutId.value = null; } function resetShortcut(actionId: ShortcutActionId) { @@ -1794,40 +1842,80 @@ watch(
-
+
- + {{ t(`settings.shortcutScope${definition.scope[0].toUpperCase()}${definition.scope.slice(1)}`) }}
-
-
- +
+ + +