diff --git a/webapp/packages/plugin-help/src/Shortcuts/SHORTCUTS_DATA.ts b/webapp/packages/plugin-help/src/Shortcuts/SHORTCUTS_DATA.ts index 719202cf04..b9b45ee107 100644 --- a/webapp/packages/plugin-help/src/Shortcuts/SHORTCUTS_DATA.ts +++ b/webapp/packages/plugin-help/src/Shortcuts/SHORTCUTS_DATA.ts @@ -1,6 +1,6 @@ /* * CloudBeaver - Cloud Database Manager - * Copyright (C) 2020-2024 DBeaver Corp and others + * Copyright (C) 2020-2025 DBeaver Corp and others * * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. @@ -25,6 +25,30 @@ import { KEY_BINDING_SQL_EDITOR_SAVE_AS_SCRIPT } from '@cloudbeaver/plugin-sql-e import type { IShortcut } from './IShortcut.js'; +const FORMAT_SHORTCUT_KEYS_MAP: Record = { + comma: ',', + slash: '/', + backslash: '\\', + backspace: '⌫', + tab: 'tab', + clear: 'clear', + enter: '↵', + return: '↵', + escape: 'escape', + esc: 'escape', + space: '␣', + up: '↑', + down: '↓', + left: '←', + right: '→', + pageup: 'pageup', + pagedown: 'pagedown', + del: '⌦', + delete: '⌦', +}; +const SOURCE_DIVIDER_REGEXP = /\+/gi; +const APPLIED_DIVIDER = ' + '; + export const DATA_VIEWER_SHORTCUTS: IShortcut[] = [ { label: 'data_viewer_shortcut_revert_inline_editor_changes', @@ -100,19 +124,30 @@ export const NAVIGATION_TREE_SHORTCUTS: IShortcut[] = [ ]; function transformKeys(keyBinding: IKeyBinding): string[] { - const keys = getCommonAndOSSpecificKeys(keyBinding); - - return keys.map(key => transformModToDisplayKey(key.toLocaleUpperCase().replace(/\+/gi, ' + '))); + return getCommonAndOSSpecificKeys(keyBinding).map(shortcut => + shortcut.split(SOURCE_DIVIDER_REGEXP).map(formatKeyToDisplayKey).join(APPLIED_DIVIDER).toLocaleUpperCase(), + ); } -function transformModToDisplayKey(key: string): string { +function formatKeyToDisplayKey(code: string): string { + const lowerCaseCode = code.toLowerCase(); const OS = getOS(); - if (OS === OperatingSystem.windowsOS || OS === OperatingSystem.linuxOS) { - return key.replace('MOD', 'CTRL'); - } - if (OS === OperatingSystem.macOS) { - return key.replace('MOD', 'CMD').replace('ALT', 'OPTION'); + switch (lowerCaseCode) { + case 'mod': + if (OS === OperatingSystem.windowsOS || OS === OperatingSystem.linuxOS) { + return 'CTRL'; + } + if (OS === OperatingSystem.macOS) { + return 'CMD'; + } + return code; + case 'alt': + if (OS === OperatingSystem.macOS) { + return 'OPTION'; + } + return 'ALT'; + default: + return FORMAT_SHORTCUT_KEYS_MAP[lowerCaseCode] ?? code; } - return key; } diff --git a/webapp/packages/plugin-help/src/Shortcuts/Shortcut.tsx b/webapp/packages/plugin-help/src/Shortcuts/Shortcut.tsx index 294480fcc7..b13f79df8f 100644 --- a/webapp/packages/plugin-help/src/Shortcuts/Shortcut.tsx +++ b/webapp/packages/plugin-help/src/Shortcuts/Shortcut.tsx @@ -1,6 +1,6 @@ /* * CloudBeaver - Cloud Database Manager - * Copyright (C) 2020-2024 DBeaver Corp and others + * Copyright (C) 2020-2025 DBeaver Corp and others * * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. diff --git a/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/KEY_BINDING_COLLAPSE_ALL.ts b/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/KEY_BINDING_COLLAPSE_ALL.ts index f13032e36e..504ce50060 100644 --- a/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/KEY_BINDING_COLLAPSE_ALL.ts +++ b/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/KEY_BINDING_COLLAPSE_ALL.ts @@ -1,6 +1,6 @@ /* * CloudBeaver - Cloud Database Manager - * Copyright (C) 2020-2024 DBeaver Corp and others + * Copyright (C) 2020-2025 DBeaver Corp and others * * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. @@ -9,6 +9,6 @@ import { createKeyBinding } from '@cloudbeaver/core-view'; export const KEY_BINDING_COLLAPSE_ALL = createKeyBinding({ id: 'collapse-all', - keys: 'shift+ctrl+/', + keys: 'shift+ctrl+slash', preventDefault: true, }); diff --git a/webapp/packages/plugin-sql-editor/src/actions/bindings/KEY_BINDING_SQL_EDITOR_EXECUTE_NEW.ts b/webapp/packages/plugin-sql-editor/src/actions/bindings/KEY_BINDING_SQL_EDITOR_EXECUTE_NEW.ts index e756300584..b5f212b1a8 100644 --- a/webapp/packages/plugin-sql-editor/src/actions/bindings/KEY_BINDING_SQL_EDITOR_EXECUTE_NEW.ts +++ b/webapp/packages/plugin-sql-editor/src/actions/bindings/KEY_BINDING_SQL_EDITOR_EXECUTE_NEW.ts @@ -1,6 +1,6 @@ /* * CloudBeaver - Cloud Database Manager - * Copyright (C) 2020-2024 DBeaver Corp and others + * Copyright (C) 2020-2025 DBeaver Corp and others * * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. @@ -9,6 +9,6 @@ import { createKeyBinding } from '@cloudbeaver/core-view'; export const KEY_BINDING_SQL_EDITOR_EXECUTE_NEW = createKeyBinding({ id: 'sql-editor-execute-new', - keys: ['mod+\\', 'shift+mod+enter'], + keys: ['mod+backslash', 'shift+mod+enter'], preventDefault: true, });