Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions webapp/packages/core-view/src/View/CaptureView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2025 DBeaver Corp and others
* Copyright (C) 2020-2026 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
Expand All @@ -18,7 +18,7 @@
import styles from './CaptureView.module.css';
import { CaptureViewContext } from './CaptureViewContext.js';
import type { IView } from './IView.js';
import { parseHotkey } from './parseHotkey.js';
import { mapShortcut, parseHotkey } from './parseHotkey.js';
import { useActiveView } from './useActiveView.js';
import { useViewContext } from './useViewContext.js';

Expand All @@ -40,7 +40,10 @@
.filter(action => action?.binding && !action.isDisabled())
.filter(Boolean) as IActionItem[];

const keys = actionItems.map(item => getCommonAndOSSpecificKeys(item.binding?.binding)).flat();
const keys = actionItems
.map(item => getCommonAndOSSpecificKeys(item.binding?.binding))
.flat()
.map(item => mapShortcut(item));

useHotkeys(
keys,
Expand All @@ -58,6 +61,8 @@
});
});

console.log(action);

Check warning on line 64 in webapp/packages/core-view/src/View/CaptureView.tsx

View workflow job for this annotation

GitHub Actions / Frontend / Lint

Unexpected console statement. Only these console methods are allowed: warn, error

action?.activate(true);
},
{
Expand Down
6 changes: 5 additions & 1 deletion webapp/packages/core-view/src/View/parseHotkey.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2025 DBeaver Corp and others
* Copyright (C) 2020-2026 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -39,6 +39,10 @@ export function mapKey(key: string): string {
.replace(/key|digit|numpad|arrow/, '');
}

export function mapShortcut(shortcut: string, combinationKey = '+'): string {
return shortcut.split(combinationKey).map(mapKey).join(combinationKey);
}

export function isHotkeyModifier(key: string): boolean {
return reservedModifierKeywords.includes(key);
}
Expand Down
1 change: 0 additions & 1 deletion webapp/packages/plugin-data-spreadsheet-new/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
*/

import './module.js';
export * from './DataGrid/DATA_GRID_BINDINGS.js';
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
* Copyright (C) 2020-2026 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'],
Expand All @@ -27,3 +26,13 @@ export const KEY_BINDING_DELETE_ROW: IKeyBinding = {
id: 'data-viewer-delete-row',
keys: ['Delete'],
};

export const KEY_BINDING_SAVE: IKeyBinding = {
id: 'data-viewer-save',
keys: ['mod+shift+s'],
};

export const KEY_BINDING_CANCEL: IKeyBinding = {
id: 'data-viewer-cancel',
keys: ['mod+.'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mod+period?

};
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,22 @@ import {
ACTION_SAVE,
ActionService,
DATA_CONTEXT_MENU,
KEY_BINDING_ADD,
KEY_BINDING_DELETE,
KEY_BINDING_DUPLICATE,
KEY_BINDING_REVERT,
KeyBindingService,
MenuService,
type IAction,
} from '@cloudbeaver/core-view';
import { LocalizationService } from '@cloudbeaver/core-localization';
import type { IDataContextProvider } from '@cloudbeaver/core-data-context';

import {
KEY_BINDING_ADD_NEW_ROW,
KEY_BINDING_CANCEL,
KEY_BINDING_DELETE_ROW,
KEY_BINDING_DUPLICATE_ROW,
KEY_BINDING_REVERT_INLINE_EDITOR_CHANGES,
KEY_BINDING_SAVE,
} from '../../../DATA_VIEWER_KEY_BINDINGS.js';

import { DatabaseEditChangeType, IDatabaseDataEditAction } from '../../../DatabaseDataModel/Actions/IDatabaseDataEditAction.js';
import { DATA_CONTEXT_DV_DDM } from '../../../DatabaseDataModel/DataContext/DATA_CONTEXT_DV_DDM.js';
import { DATA_CONTEXT_DV_DDM_RESULT_INDEX } from '../../../DatabaseDataModel/DataContext/DATA_CONTEXT_DV_DDM_RESULT_INDEX.js';
Expand All @@ -49,7 +54,7 @@ export class TableFooterMenuService {
this.registerEditingActions();
this.keyBindingService.addKeyBindingHandler({
id: 'table-footer-delete',
binding: KEY_BINDING_DELETE,
binding: KEY_BINDING_DELETE_ROW,
contexts: [DATA_CONTEXT_DV_DDM, DATA_CONTEXT_DV_DDM_RESULT_INDEX],
isBindingApplicable(context, action) {
return action === ACTION_DELETE;
Expand All @@ -59,7 +64,7 @@ export class TableFooterMenuService {

this.keyBindingService.addKeyBindingHandler({
id: 'table-footer-revert',
binding: KEY_BINDING_REVERT,
binding: KEY_BINDING_REVERT_INLINE_EDITOR_CHANGES,
contexts: [DATA_CONTEXT_DV_DDM, DATA_CONTEXT_DV_DDM_RESULT_INDEX],
isBindingApplicable(context, action) {
return action === ACTION_REVERT;
Expand All @@ -69,7 +74,7 @@ export class TableFooterMenuService {

this.keyBindingService.addKeyBindingHandler({
id: 'table-footer-add',
binding: KEY_BINDING_ADD,
binding: KEY_BINDING_ADD_NEW_ROW,
contexts: [DATA_CONTEXT_DV_DDM, DATA_CONTEXT_DV_DDM_RESULT_INDEX],
isBindingApplicable(context, action) {
return action === ACTION_ADD;
Expand All @@ -79,15 +84,35 @@ export class TableFooterMenuService {

this.keyBindingService.addKeyBindingHandler({
id: 'table-footer-duplicate',
binding: KEY_BINDING_DUPLICATE,
binding: KEY_BINDING_DUPLICATE_ROW,
contexts: [DATA_CONTEXT_DV_DDM, DATA_CONTEXT_DV_DDM_RESULT_INDEX],
isBindingApplicable(context, action) {
return action === ACTION_DUPLICATE;
},
handler: this.tableFooterMenuActionHandler.bind(this),
});

this.dataViewerViewService.registerAction(ACTION_DELETE, ACTION_REVERT, ACTION_ADD, ACTION_DUPLICATE);
this.keyBindingService.addKeyBindingHandler({
id: 'table-footer-save',
binding: KEY_BINDING_SAVE,
contexts: [DATA_CONTEXT_DV_DDM, DATA_CONTEXT_DV_DDM_RESULT_INDEX],
isBindingApplicable(context, action) {
return action === ACTION_SAVE;
},
handler: this.tableFooterMenuActionHandler.bind(this),
});

this.keyBindingService.addKeyBindingHandler({
id: 'table-footer-cancel',
binding: KEY_BINDING_CANCEL,
contexts: [DATA_CONTEXT_DV_DDM, DATA_CONTEXT_DV_DDM_RESULT_INDEX],
isBindingApplicable(context, action) {
return action === ACTION_CANCEL;
},
handler: this.tableFooterMenuActionHandler.bind(this),
});

this.dataViewerViewService.registerAction(ACTION_DELETE, ACTION_REVERT, ACTION_ADD, ACTION_DUPLICATE, ACTION_CANCEL);
}

private registerEditingActions() {
Expand Down
1 change: 1 addition & 0 deletions webapp/packages/plugin-data-viewer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,4 @@ export * from './useDataViewerCopyHandler.js';
export * from './DataViewerSettingsService.js';
export * from './DATA_EDITOR_SETTINGS_GROUP.js';
export * from './MENU_DV_CONTEXT_MENU.js';
export * from './DATA_VIEWER_KEY_BINDINGS.js';
2 changes: 1 addition & 1 deletion webapp/packages/plugin-help/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@cloudbeaver/core-routing": "workspace:*",
"@cloudbeaver/core-utils": "workspace:*",
"@cloudbeaver/core-view": "workspace:*",
"@cloudbeaver/plugin-data-spreadsheet-new": "workspace:*",
"@cloudbeaver/plugin-data-viewer": "workspace:*",
"@cloudbeaver/plugin-navigation-tabs": "workspace:*",
"@cloudbeaver/plugin-navigation-tree": "workspace:*",
"@cloudbeaver/plugin-object-viewer-nav-tree-link": "workspace:*",
Expand Down
33 changes: 24 additions & 9 deletions webapp/packages/plugin-help/src/Shortcuts/SHORTCUTS_DATA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,22 @@
* you may not use this file except in compliance with the License.
*/
import { getOS, OperatingSystem } from '@cloudbeaver/core-utils';
import { createKeyBinding, getCommonAndOSSpecificKeys, type IKeyBinding, KEY_BINDING_OPEN_IN_TAB, KEY_BINDING_REDO, KEY_BINDING_UNDO } from '@cloudbeaver/core-view';
import {
createKeyBinding,
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_CANCEL,
KEY_BINDING_DELETE_ROW,
KEY_BINDING_DUPLICATE_ROW,
KEY_BINDING_REVERT_INLINE_EDITOR_CHANGES,
} from '@cloudbeaver/plugin-data-spreadsheet-new';
KEY_BINDING_SAVE,
} from '@cloudbeaver/plugin-data-viewer';
import { KEY_BINDING_COLLAPSE_ALL, KEY_BINDING_ENABLE_FILTER } from '@cloudbeaver/plugin-navigation-tree';
import { KEY_BINDING_LINK_OBJECT } from '@cloudbeaver/plugin-object-viewer-nav-tree-link';
import {
Expand Down Expand Up @@ -53,8 +63,6 @@ const FORMAT_SHORTCUT_KEYS_MAP: Record<string, string> = {
right: '→',
pageup: 'pageup',
pagedown: 'pagedown',
del: '⌦',
delete: '⌦',
};
const SOURCE_DIVIDER_REGEXP = /\+/gi;
const APPLIED_DIVIDER = ' + ';
Expand All @@ -72,11 +80,18 @@ export const DATA_VIEWER_SHORTCUTS: IShortcut[] = [
label: 'data_viewer_shortcut_duplicate_row',
code: transformKeys(KEY_BINDING_DUPLICATE_ROW),
},
// disabled
// {
// label: 'data_viewer_shortcut_delete_row',
// code: transformKeys(KEY_BINDING_DELETE_ROW),
// },
{
label: 'data_viewer_shortcut_delete_row',
code: transformKeys(KEY_BINDING_DELETE_ROW),
},
{
label: 'ui_processing_save',
code: transformKeys(KEY_BINDING_SAVE),
},
{
label: 'ui_processing_cancel',
code: transformKeys(KEY_BINDING_CANCEL),
},
];

export const SQL_EDITOR_SHORTCUTS: IShortcut[] = [
Expand Down
2 changes: 1 addition & 1 deletion webapp/packages/plugin-help/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"path": "../core-view"
},
{
"path": "../plugin-data-spreadsheet-new"
"path": "../plugin-data-viewer"
},
{
"path": "../plugin-navigation-tabs"
Expand Down
2 changes: 1 addition & 1 deletion webapp/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3242,7 +3242,7 @@ __metadata:
"@cloudbeaver/core-routing": "workspace:*"
"@cloudbeaver/core-utils": "workspace:*"
"@cloudbeaver/core-view": "workspace:*"
"@cloudbeaver/plugin-data-spreadsheet-new": "workspace:*"
"@cloudbeaver/plugin-data-viewer": "workspace:*"
"@cloudbeaver/plugin-navigation-tabs": "workspace:*"
"@cloudbeaver/plugin-navigation-tree": "workspace:*"
"@cloudbeaver/plugin-object-viewer-nav-tree-link": "workspace:*"
Expand Down
Loading