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(shape): the editor should not get focus when shap editor is focus (#6516)

VicKun9f9855c87fb5
diff --git a/packages/docs-ui/src/services/editor/editor-manager.service.ts b/packages/docs-ui/src/services/editor/editor-manager.service.ts
index 284751d39c..98ff31c53f 100644
--- a/packages/docs-ui/src/services/editor/editor-manager.service.ts
+++ b/packages/docs-ui/src/services/editor/editor-manager.service.ts
@@ -168,6 +168,7 @@ export class EditorService extends Disposable implements IEditorService, IDispos
this._univerInstanceService.setCurrentUnitForType(editorUnitId);
const valueCount = editor.getValue().length;
+
this._contextService.setContextValue(EDITOR_ACTIVATED, true);
if (!isInternalEditorID(editorUnitId)) {
diff --git a/packages/sheets-drawing-ui/src/controllers/shortcuts/drawing.shortcut.ts b/packages/sheets-drawing-ui/src/controllers/shortcuts/drawing.shortcut.ts
index ef16e02e07..d2fe645c2c 100644
--- a/packages/sheets-drawing-ui/src/controllers/shortcuts/drawing.shortcut.ts
+++ b/packages/sheets-drawing-ui/src/controllers/shortcuts/drawing.shortcut.ts
@@ -17,7 +17,7 @@
import type { IContextService } from '@univerjs/core';
import type { IShortcutItem } from '@univerjs/ui';
import type { IMoveDrawingsCommandParams } from '../../commands/commands/move-drawings.command';
-import { Direction, EDITOR_ACTIVATED, FOCUSING_COMMON_DRAWINGS, FOCUSING_FX_BAR_EDITOR, FOCUSING_PANEL_EDITOR, FOCUSING_SHEET } from '@univerjs/core';
+import { Direction, FOCUSING_COMMON_DRAWINGS, FOCUSING_FX_BAR_EDITOR, FOCUSING_PANEL_EDITOR, FOCUSING_SHAPE_TEXT_EDITOR, FOCUSING_SHEET } from '@univerjs/core';
import { KeyCode } from '@univerjs/ui';
import { DeleteDrawingsCommand } from '../../commands/commands/delete-drawings.command';
import { MoveDrawingsCommand } from '../../commands/commands/move-drawings.command';
@@ -26,9 +26,9 @@ export function whenSheetDrawingFocused(contextService: IContextService): boolea
return (
contextService.getContextValue(FOCUSING_SHEET) &&
!contextService.getContextValue(FOCUSING_FX_BAR_EDITOR) &&
- !contextService.getContextValue(EDITOR_ACTIVATED) &&
!contextService.getContextValue(FOCUSING_PANEL_EDITOR) &&
- contextService.getContextValue(FOCUSING_COMMON_DRAWINGS)
+ contextService.getContextValue(FOCUSING_COMMON_DRAWINGS) &&
+ !contextService.getContextValue(FOCUSING_SHAPE_TEXT_EDITOR)
);
}
@@ -83,6 +83,7 @@ export const DeleteDrawingsShortcutItem: IShortcutItem = {
id: DeleteDrawingsCommand.id,
description: 'shortcut.drawing-delete',
group: '4_drawing-view',
+ priority: 100,
// when focusing on any other input tag do not trigger this shortcut
preconditions: whenSheetDrawingFocused,
binding: KeyCode.DELETE,