Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CB-3332 shortcuts improvements #3126

Merged
merged 9 commits into from
Dec 12, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import { createKeyBinding } from '../createKeyBinding.js';

export const KEY_BINDING_REDO = createKeyBinding({
id: 'redo',
keys: ['mod+y', 'mod+shift+z'],
keys: ['mod+y', 'shift+mod+z'],
preventDefault: true,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
import type { IKeyBinding } from '@cloudbeaver/core-view';

/* these consts are only used for the user interface in Shortcuts popup, actual bindings in DataGridTable.tsx */
export const KEY_BINDING_REVERT_INLINE_EDITOR_CHANGES: IKeyBinding = {
id: 'data-viewer-revert-inline-editor-changes',
keys: ['Escape'],
};

export const KEY_BINDING_ADD_NEW_ROW: IKeyBinding = {
id: 'data-viewer-add-new-row',
keys: ['Alt+R'],
};

export const KEY_BINDING_DUPLICATE_ROW: IKeyBinding = {
id: 'data-viewer-duplicate-row',
keys: ['Shift+Alt+R'],
};

export const KEY_BINDING_DELETE_ROW: IKeyBinding = {
id: 'data-viewer-delete-row',
keys: ['Delete'],
};
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ export const DataGridTable = observer<IDataPresentationProps>(function DataGridT
tableData.editor.revert(...activeElements);
return;
}
case 'Insert': {
case 'KeyR': {
if (event.altKey) {
if (event.ctrlKey || event.metaKey) {
if (event.shiftKey) {
tableData.editor.duplicate(...activeRows);
} else {
tableData.editor.add(cell);
Expand Down
1 change: 1 addition & 0 deletions webapp/packages/plugin-data-spreadsheet-new/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
* you may not use this file except in compliance with the License.
*/
export * from './manifest.js';
export * from './DataGrid/DATA_GRID_BINDINGS.js';
1 change: 1 addition & 0 deletions webapp/packages/plugin-help/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@cloudbeaver/core-routing": "^0",
"@cloudbeaver/core-utils": "^0",
"@cloudbeaver/core-view": "^0",
"@cloudbeaver/plugin-data-spreadsheet-new": "^0",
"@cloudbeaver/plugin-navigation-tree": "^0",
"@cloudbeaver/plugin-sql-editor": "^0",
"@cloudbeaver/plugin-top-app-bar": "^0",
Expand Down
28 changes: 11 additions & 17 deletions webapp/packages/plugin-help/src/Shortcuts/SHORTCUTS_DATA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
*/
import { getOS, OperatingSystem } from '@cloudbeaver/core-utils';
import { getCommonAndOSSpecificKeys, type IKeyBinding, KEY_BINDING_OPEN_IN_TAB, KEY_BINDING_REDO, KEY_BINDING_UNDO } from '@cloudbeaver/core-view';
import {
KEY_BINDING_ADD_NEW_ROW,
KEY_BINDING_DELETE_ROW,
KEY_BINDING_DUPLICATE_ROW,
KEY_BINDING_REVERT_INLINE_EDITOR_CHANGES,
} from '@cloudbeaver/plugin-data-spreadsheet-new';
import { KEY_BINDING_COLLAPSE_ALL, KEY_BINDING_ENABLE_FILTER, KEY_BINDING_LINK_OBJECT } from '@cloudbeaver/plugin-navigation-tree';
import {
KEY_BINDING_SQL_EDITOR_EXECUTE,
Expand All @@ -19,33 +25,21 @@ import {
import type { IShortcut } from './IShortcut.js';

export const DATA_VIEWER_SHORTCUTS: IShortcut[] = [
{
label: 'data_viewer_shortcut_start_inline_editing',
code: ['Enter', 'Backspace'],
},
{
label: 'data_viewer_shortcut_revert_inline_editor_changes',
code: ['Escape'],
code: transformKeys(KEY_BINDING_REVERT_INLINE_EDITOR_CHANGES),
},
{
label: 'data_viewer_shortcut_add_new_row',
code: ['Alt + Insert'],
code: transformKeys(KEY_BINDING_ADD_NEW_ROW),
},
{
label: 'data_viewer_shortcut_duplicate_row',
code: ['Ctrl + Alt + Insert'],
code: transformKeys(KEY_BINDING_DUPLICATE_ROW),
},
{
label: 'data_viewer_shortcut_delete_row',
code: ['Delete'],
},
{
label: 'data_viewer_shortcut_past_value',
code: ['Ctrl + V'],
},
{
label: 'data_viewer_shortcut_copy_value',
code: ['Ctrl + C'],
code: transformKeys(KEY_BINDING_DELETE_ROW),
},
];

Expand Down Expand Up @@ -112,7 +106,7 @@ function transformModToDisplayKey(key: string): string {
}

if (OS === OperatingSystem.macOS) {
return key.replace('MOD', 'CMD').replace('ALT', 'OPTION').replace('BACKSPACE', 'DELETE');
return key.replace('MOD', 'CMD').replace('ALT', 'OPTION');
}
return key;
}
3 changes: 3 additions & 0 deletions webapp/packages/plugin-help/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
{
"path": "../core-view/tsconfig.json"
},
{
"path": "../plugin-data-spreadsheet-new/tsconfig.json"
},
{
"path": "../plugin-navigation-tree/tsconfig.json"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import { createKeyBinding } from '@cloudbeaver/core-view';

export const KEY_BINDING_ENABLE_FILTER = createKeyBinding({
id: 'enable-filter',
keys: 'ctrl+f',
keys: 'mod+f',
preventDefault: true,
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import { createKeyBinding } from '@cloudbeaver/core-view';

export const KEY_BINDING_COLLAPSE_ALL = createKeyBinding({
id: 'collapse-all',
keys: 'ctrl+shift+/',
keys: 'shift+ctrl+/',
preventDefault: true,
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import { createKeyBinding } from '@cloudbeaver/core-view';

export const KEY_BINDING_LINK_OBJECT = createKeyBinding({
id: 'link-object',
keys: 'ctrl+shift+,',
keys: 'shift+ctrl+,',
preventDefault: true,
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import { createKeyBinding } from '@cloudbeaver/core-view';

export const KEY_BINDING_SQL_EDITOR_EXECUTE = createKeyBinding({
id: 'sql-editor-execute',
keys: 'ctrl+enter',
keys: 'mod+enter',
preventDefault: true,
});
Original file line number Diff line number Diff line change
Expand Up @@ -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: ['ctrl+\\', 'shift+ctrl+enter'],
keys: ['mod+\\', 'shift+mod+enter'],
preventDefault: true,
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import { createKeyBinding } from '@cloudbeaver/core-view';

export const KEY_BINDING_SQL_EDITOR_FORMAT = createKeyBinding({
id: 'sql-editor-format',
keys: 'shift+ctrl+f',
keys: 'shift+mod+f',
preventDefault: true,
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import { createKeyBinding } from '@cloudbeaver/core-view';

export const KEY_BINDING_SQL_EDITOR_SHOW_EXECUTION_PLAN = createKeyBinding({
id: 'sql-editor-show-execution-plan',
keys: 'shift+ctrl+e',
keys: 'shift+mod+e',
preventDefault: true,
});
Loading