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:
17 files changed
+207
-108
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { formatShortcutDisplay, shortcutDisplayKeys } from "@/lib/editor/shortcutDisplay";
|
||||
|
||||
describe("shortcut display", () => {
|
||||
it("uses readable modifier labels on Windows", () => {
|
||||
expect(shortcutDisplayKeys("Shift+Alt+U", "Win32")).toEqual(["Shift", "Alt", "U"]);
|
||||
});
|
||||
|
||||
it("uses readable modifier labels on Linux", () => {
|
||||
expect(shortcutDisplayKeys("Ctrl+Alt+Delete", "Linux x86_64")).toEqual(["Ctrl", "Alt", "Del"]);
|
||||
});
|
||||
|
||||
it("uses Apple platform glyphs on macOS", () => {
|
||||
expect(shortcutDisplayKeys("Mod+Alt+Enter", "MacIntel")).toEqual(["⌘", "⌥", "↵"]);
|
||||
});
|
||||
|
||||
it("formats shortcut pills with platform separators", () => {
|
||||
expect(formatShortcutDisplay("Shift+Alt+ArrowUp", "Win32")).toBe("Shift + Alt + ↑");
|
||||
expect(formatShortcutDisplay("Shift+Alt+ArrowUp", "MacIntel")).toBe("⇧ ⌥ ↑");
|
||||
expect(formatShortcutDisplay("Mod+Delete", "MacIntel")).toBe("⌘ ⌦");
|
||||
});
|
||||
});
|
||||
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
import { DEFAULT_SHORTCUT_SETTINGS, SHORTCUT_DEFINITIONS, findShortcutConflict, normalizeShortcutSettings, type ShortcutActionId } from "@/lib/editor/shortcutRegistry";
|
||||
|
||||
describe("shortcutRegistry editor actions", () => {
|
||||
const formatterEditorActionIds: ShortcutActionId[] = ["formatSql", "indentMore", "indentLess", "duplicateLine", "deleteLine", "moveLineUp", "moveLineDown", "copyLineUp", "copyLineDown", "undo", "redo", "selectAll"];
|
||||
const formatterEditorActionIds: ShortcutActionId[] = ["formatSql", "indentMore", "indentLess", "duplicateLine", "deleteLine", "moveLineUp", "moveLineDown", "copyLineUp", "copyLineDown", "undo", "redo", "selectAll", "uppercaseSelection", "lowercaseSelection"];
|
||||
const sidebarShortcutActionIds: ShortcutActionId[] = ["copySidebarSelection", "pasteSidebarSelection", "editSidebarConnection"];
|
||||
|
||||
it("registers formatter editor shortcuts in the generic editor scope", () => {
|
||||
@@ -30,6 +30,8 @@ describe("shortcutRegistry editor actions", () => {
|
||||
expect(shortcuts.undo).toBe("Mod+Z");
|
||||
expect(shortcuts.redo).toBe("Shift+Mod+Z");
|
||||
expect(shortcuts.selectAll).toBe("Mod+A");
|
||||
expect(shortcuts.uppercaseSelection).toBe("Shift+Alt+U");
|
||||
expect(shortcuts.lowercaseSelection).toBe("Shift+Alt+L");
|
||||
});
|
||||
|
||||
it("detects conflicts between formatter editor shortcuts and other editor shortcuts", () => {
|
||||
@@ -38,6 +40,12 @@ describe("shortcutRegistry editor actions", () => {
|
||||
expect(findShortcutConflict("duplicateLine", shortcuts.duplicateLine, shortcuts)).toBe("find");
|
||||
});
|
||||
|
||||
it("detects conflicts for SQL selection case shortcuts", () => {
|
||||
const shortcuts = normalizeShortcutSettings({ uppercaseSelection: "Mod+A" });
|
||||
|
||||
expect(findShortcutConflict("uppercaseSelection", shortcuts.uppercaseSelection, shortcuts)).toBe("selectAll");
|
||||
});
|
||||
|
||||
it("registers sidebar shortcuts in the sidebar scope", () => {
|
||||
for (const actionId of sidebarShortcutActionIds) {
|
||||
const definition = SHORTCUT_DEFINITIONS.find((item) => item.id === actionId);
|
||||
|
||||
Reference in new issue
Block a user