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.

fix(sheets-ui): mac delete shortcut work error (#4765)

ZhangWeiaef6b87219cc
diff --git a/packages/sheets-ui/src/commands/operations/cell-edit.operation.ts b/packages/sheets-ui/src/commands/operations/cell-edit.operation.ts
index c9878453ed..93d69bf51a 100644
--- a/packages/sheets-ui/src/commands/operations/cell-edit.operation.ts
+++ b/packages/sheets-ui/src/commands/operations/cell-edit.operation.ts
@@ -27,9 +27,17 @@ export const SetCellEditVisibleOperation: IOperation<IEditorBridgeServiceVisible
if (!params) {
return false;
}
-
+ const { unitId } = params;
+ const univerInstanceService = accessor.get(IUniverInstanceService);
+ const workbook = univerInstanceService.getCurrentUnitForType<Workbook>(UniverInstanceType.UNIVER_SHEET);
+ if (!workbook) {
+ return false;
+ }
const editorBridgeService = accessor.get(IEditorBridgeService);
- editorBridgeService.changeVisible(params);
+ editorBridgeService.changeVisible({
+ ...params,
+ unitId: unitId ?? workbook.getUnitId(),
+ });
return true;
},
diff --git a/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts b/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts
index 1190c51828..89a9b6cb4a 100644
--- a/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts
+++ b/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts
@@ -183,7 +183,7 @@ export class EditingRenderController extends Disposable implements IRenderModule
this._editorBridgeService.visible$
.pipe(distinctUntilChanged((prev, curr) => prev.visible === curr.visible))
.subscribe((param) => {
- if ((param.unitId === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY || param.unitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY || param.unitId === this._context.unitId) && param.visible) {
+ if ((param.unitId === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY || param.unitId === this._context.unitId) && param.visible) {
this._isUnitEditing = true;
this._handleEditorVisible(param);
} else if (this._isUnitEditing) {
diff --git a/packages/sheets-ui/src/controllers/shortcuts/editor.shortcut.ts b/packages/sheets-ui/src/controllers/shortcuts/editor.shortcut.ts
index 234e514189..085dacf597 100644
--- a/packages/sheets-ui/src/controllers/shortcuts/editor.shortcut.ts
+++ b/packages/sheets-ui/src/controllers/shortcuts/editor.shortcut.ts
@@ -15,7 +15,6 @@
*/
import type { IShortcutItem } from '@univerjs/ui';
-import { DOCS_NORMAL_EDITOR_UNIT_ID_KEY } from '@univerjs/core';
import { BreakLineCommand, DeleteLeftCommand } from '@univerjs/docs-ui';
import { DeviceInputEventType } from '@univerjs/engine-render';
@@ -137,7 +136,6 @@ export const EditorDeleteLeftShortcut: IShortcutItem = {
preconditions: (contextService) =>
whenEditorActivated(contextService) || whenFormulaEditorFocused(contextService),
binding: KeyCode.BACKSPACE,
- mac: KeyCode.DELETE,
};
export const EditorDeleteLeftShortcutInActive: IShortcutItem = {
@@ -150,6 +148,5 @@ export const EditorDeleteLeftShortcutInActive: IShortcutItem = {
visible: true,
eventType: DeviceInputEventType.Keyboard,
keycode: KeyCode.BACKSPACE,
- unitId: DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
},
};