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 Delete Right shortcut to editor shortcuts (#5068)

ZhangWei287dc52694ec
diff --git a/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-filter-row-current-worksheet-ci-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-filter-row-current-worksheet-ci-chromium-linux.png
index 9bb39fdd9a..22cdc3f390 100644
Binary files a/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-filter-row-current-worksheet-ci-chromium-linux.png and b/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-filter-row-current-worksheet-ci-chromium-linux.png differ
diff --git a/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-filter-row-other-worksheet-ci-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-filter-row-other-worksheet-ci-chromium-linux.png
index a4085d5ec2..18d58660f3 100644
Binary files a/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-filter-row-other-worksheet-ci-chromium-linux.png and b/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-filter-row-other-worksheet-ci-chromium-linux.png differ
diff --git a/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-hide-row-current-worksheet-ci-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-hide-row-current-worksheet-ci-chromium-linux.png
index ed0941fbd4..9a0bde2c35 100644
Binary files a/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-hide-row-current-worksheet-ci-chromium-linux.png and b/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-hide-row-current-worksheet-ci-chromium-linux.png differ
diff --git a/packages/sheets-ui/src/controllers/sheet-ui.controller.ts b/packages/sheets-ui/src/controllers/sheet-ui.controller.ts
index c4fd826ad5..6c308863a4 100644
--- a/packages/sheets-ui/src/controllers/sheet-ui.controller.ts
+++ b/packages/sheets-ui/src/controllers/sheet-ui.controller.ts
@@ -116,6 +116,7 @@ import {
EditorCursorTabShortcut,
EditorDeleteLeftShortcut,
EditorDeleteLeftShortcutInActive,
+ EditorDeleteRightShortcut,
generateArrowSelectionShortCutItem,
ShiftEditorDeleteLeftShortcut,
StartEditWithF2Shortcut,
@@ -338,6 +339,7 @@ export class SheetUIController extends Disposable {
EditorCursorTabShortcut,
EditorBreakLineShortcut,
EditorDeleteLeftShortcut,
+ EditorDeleteRightShortcut,
EditorDeleteLeftShortcutInActive,
EditorCursorEscShortcut,
EditorCursorCtrlEnterShortcut,
diff --git a/packages/sheets-ui/src/controllers/shortcuts/editor.shortcut.ts b/packages/sheets-ui/src/controllers/shortcuts/editor.shortcut.ts
index c6a8d31eac..45a1d5f88b 100644
--- a/packages/sheets-ui/src/controllers/shortcuts/editor.shortcut.ts
+++ b/packages/sheets-ui/src/controllers/shortcuts/editor.shortcut.ts
@@ -15,7 +15,7 @@
*/
import type { IShortcutItem } from '@univerjs/ui';
-import { BreakLineCommand, DeleteLeftCommand } from '@univerjs/docs-ui';
+import { BreakLineCommand, DeleteLeftCommand, DeleteRightCommand } from '@univerjs/docs-ui';
import { DeviceInputEventType } from '@univerjs/engine-render';
import { KeyCode, MetaKeys } from '@univerjs/ui';
@@ -150,6 +150,13 @@ export const EditorDeleteLeftShortcut: IShortcutItem = {
binding: KeyCode.BACKSPACE,
};
+export const EditorDeleteRightShortcut: IShortcutItem = {
+ id: DeleteRightCommand.id,
+ preconditions: (contextService) =>
+ whenEditorActivated(contextService) || whenFormulaEditorFocused(contextService),
+ binding: KeyCode.DELETE,
+};
+
export const ShiftEditorDeleteLeftShortcut: IShortcutItem = {
id: DeleteLeftCommand.id,
preconditions: (contextService) =>