feat(grid): add edit structure shortcut

Closes #4303
This commit is contained in:
t8y2 committed 2026-08-25 00:41:11 +00:00
1 parent 2f464e0d33
commit 44dc2a88f8
14 files changed
+334 -2

No files matched your search

@@ -203,6 +203,10 @@ export function isCopyCurrentRowShortcut(event: ShortcutLikeEvent, shortcuts?: P
return matchesShortcut(event, actionShortcut("copyCurrentRow", shortcuts));
}
export function isEditTableStructureShortcut(event: ShortcutLikeEvent, shortcuts?: Partial<ShortcutSettings>, platform = globalThis.navigator?.platform || ""): boolean {
return matchesShortcut(event, actionShortcut("editTableStructure", shortcuts, platform), platform);
}
export function isDeleteCurrentRowShortcut(event: ShortcutLikeEvent, shortcuts?: Partial<ShortcutSettings>): boolean {
return matchesShortcut(event, actionShortcut("deleteCurrentRow", shortcuts));
}
@@ -28,6 +28,7 @@ export type ShortcutActionId =
| "lowercaseSelection"
| "exPasteSqlInCondition"
| "toggleFold"
| "editTableStructure"
| "copyCurrentRow"
| "deleteCurrentRow"
| "goToColumn"
@@ -108,6 +109,7 @@ const PLATFORM_DEFAULT_SHORTCUTS: Partial<Record<ShortcutActionId, ReadonlySet<s
navigateTabHistoryForward: new Set(["Ctrl+Alt+ArrowRight", "Mod+Alt+ArrowRight"]),
};
const LEGACY_CLOSE_TAB_DEFAULT = "Meta+W";
const LEGACY_COPY_CURRENT_ROW_DEFAULT = "Mod+D";
const TAB_NAVIGATION_HISTORY_ACTIONS: ShortcutActionId[] = ["navigateTabHistoryBack", "navigateTabHistoryForward"];
export const SHORTCUT_DEFINITIONS: ShortcutDefinition[] = [
@@ -273,11 +275,17 @@ export const SHORTCUT_DEFINITIONS: ShortcutDefinition[] = [
scope: "editor",
defaultShortcut: "Mod+.",
},
{
id: "editTableStructure",
labelKey: "settings.shortcutEditTableStructure",
scope: "grid",
defaultShortcut: "Mod+D",
},
{
id: "copyCurrentRow",
labelKey: "settings.shortcutCopyCurrentRow",
scope: "grid",
defaultShortcut: "Mod+D",
defaultShortcut: "",
},
{
id: "deleteCurrentRow",
@@ -591,6 +599,11 @@ export function normalizeShortcutSettings(settings?: Partial<ShortcutSettings>,
}),
) as ShortcutSettings;
if (!hasExplicitShortcut(settings, "editTableStructure") && settings?.copyCurrentRow === LEGACY_COPY_CURRENT_ROW_DEFAULT) {
normalized.editTableStructure = LEGACY_COPY_CURRENT_ROW_DEFAULT;
normalized.copyCurrentRow = "";
}
for (const actionId of TAB_NAVIGATION_HISTORY_ACTIONS) {
if (hasExplicitShortcut(settings, actionId)) continue;
const definition = SHORTCUT_DEFINITIONS.find((item) => item.id === actionId);