feat(editor): add SQL editor context menu shortcuts

* feat(editor): add SQL editor context menu shortcuts

* chore(i18n): autofill new translations

---------

Co-authored-by: faithererer <faithererer@users.noreply.github.com>
Co-authored-by: dbx-i18n-bot <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-07-05 19:38:51 +08:00
1 parent d502b4ce6c
commit 8b035d0989
17 files changed
+207 -108

No files matched your search

@@ -0,0 +1,37 @@
export function isMacShortcutPlatform(platform = globalThis.navigator?.platform || ""): boolean {
return platform.toLowerCase().includes("mac");
}
export function shortcutKeyLabel(part: string, platform = globalThis.navigator?.platform || ""): string {
const isMac = isMacShortcutPlatform(platform);
if (part === "Mod") return isMac ? "⌘" : "Ctrl";
if (part === "Cmd") return isMac ? "⌘" : "Cmd";
if (part === "Meta") return isMac ? "⌘" : "Meta";
if (part === "Alt") return isMac ? "⌥" : "Alt";
if (part === "Shift") return isMac ? "⇧" : "Shift";
if (part === "Control" || part === "Ctrl") return isMac ? "⌃" : "Ctrl";
if (part === "Delete") return isMac ? "⌦" : "Del";
if (part === "Backspace") return "⌫";
if (part === "Enter") return "↵";
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;
}
export function shortcutDisplayKeys(shortcut?: string, platform = globalThis.navigator?.platform || ""): string[] {
return (
shortcut
?.split("+")
.filter(Boolean)
.map((part) => shortcutKeyLabel(part, platform)) || []
);
}
export function formatShortcutDisplay(shortcut: string, platform = globalThis.navigator?.platform || ""): string {
if (!shortcut) return "—";
return shortcutDisplayKeys(shortcut, platform).join(isMacShortcutPlatform(platform) ? " " : " + ");
}
@@ -14,6 +14,8 @@ export type ShortcutActionId =
| "undo"
| "redo"
| "selectAll"
| "uppercaseSelection"
| "lowercaseSelection"
| "copyCurrentRow"
| "deleteCurrentRow"
| "newQuery"
@@ -147,6 +149,18 @@ export const SHORTCUT_DEFINITIONS: ShortcutDefinition[] = [
scope: "editor",
defaultShortcut: "Mod+A",
},
{
id: "uppercaseSelection",
labelKey: "settings.shortcutUppercaseSelection",
scope: "editor",
defaultShortcut: "Shift+Alt+U",
},
{
id: "lowercaseSelection",
labelKey: "settings.shortcutLowercaseSelection",
scope: "editor",
defaultShortcut: "Shift+Alt+L",
},
{
id: "copyCurrentRow",
labelKey: "settings.shortcutCopyCurrentRow",