Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

feat(sheets-ui): add Shift + Delete shortcut for cut selection (#5047)

ZhangWei450e776235d4
diff --git a/packages/sheets-ui/src/controllers/sheet-ui.controller.ts b/packages/sheets-ui/src/controllers/sheet-ui.controller.ts
index b20e15b80d..c4fd826ad5 100644
--- a/packages/sheets-ui/src/controllers/sheet-ui.controller.ts
+++ b/packages/sheets-ui/src/controllers/sheet-ui.controller.ts
@@ -151,7 +151,7 @@ import {
SetStrikeThroughShortcutItem,
SetUnderlineShortcutItem,
} from './shortcuts/style.shortcut';
-import { ClearSelectionValueShortcutItem, ClearSelectionValueShortcutItemMac, ShiftClearSelectionValueShortcutItem } from './shortcuts/value.shortcut';
+import { ClearSelectionValueShortcutItem, ClearSelectionValueShortcutItemMac, ShiftClearSelectionValueShortcutItem, ShiftDeleteSelectionValueShortcutItem } from './shortcuts/value.shortcut';
import {
PreventDefaultResetZoomShortcutItem,
PreventDefaultZoomInShortcutItem,
@@ -331,6 +331,7 @@ export class SheetUIController extends Disposable {
ClearSelectionValueShortcutItem,
ClearSelectionValueShortcutItemMac,
ShiftClearSelectionValueShortcutItem,
+ ShiftDeleteSelectionValueShortcutItem,
...generateArrowSelectionShortCutItem(),
EditorCursorEnterShortcut,
StartEditWithF2Shortcut,
diff --git a/packages/sheets-ui/src/controllers/shortcuts/value.shortcut.ts b/packages/sheets-ui/src/controllers/shortcuts/value.shortcut.ts
index 76e3e40220..178f2b20a2 100644
--- a/packages/sheets-ui/src/controllers/shortcuts/value.shortcut.ts
+++ b/packages/sheets-ui/src/controllers/shortcuts/value.shortcut.ts
@@ -18,6 +18,7 @@ import type { IShortcutItem } from '@univerjs/ui';
import { ClearSelectionContentCommand } from '@univerjs/sheets';
import { KeyCode, MetaKeys } from '@univerjs/ui';
+import { SheetCutCommand } from '../../commands/commands/clipboard.command';
import { whenSheetEditorFocused } from './utils';
export const ClearSelectionValueShortcutItem: IShortcutItem = {
@@ -39,6 +40,12 @@ export const ShiftClearSelectionValueShortcutItem: IShortcutItem = {
id: ClearSelectionContentCommand.id,
// when focusing on any other input tag do not trigger this shortcut
preconditions: (contextService) => whenSheetEditorFocused(contextService),
+ binding: MetaKeys.SHIFT + KeyCode.BACKSPACE,
+};
+
+export const ShiftDeleteSelectionValueShortcutItem: IShortcutItem = {
+ id: SheetCutCommand.id,
+ // when focusing on any other input tag do not trigger this shortcut
+ preconditions: (contextService) => whenSheetEditorFocused(contextService),
binding: MetaKeys.SHIFT + KeyCode.DELETE,
- mac: MetaKeys.SHIFT + KeyCode.BACKSPACE,
};