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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix: fix sheet command preconditions (#1319)
Wenzhao Hu6e92c60833ab
diff --git a/packages/sheets-ui/src/commands/commands/clipboard.command.ts b/packages/sheets-ui/src/commands/commands/clipboard.command.tsindex 36b781e3d9..5a04c4245d 100644--- a/packages/sheets-ui/src/commands/commands/clipboard.command.ts+++ b/packages/sheets-ui/src/commands/commands/clipboard.command.ts@@ -14,18 +14,14 @@* limitations under the License.*/-import type { ICommand, IContextService, IMultiCommand } from '@univerjs/core';-import { CommandType, EDITOR_ACTIVATED, ICommandService, ILogService } from '@univerjs/core';+import type { ICommand, IMultiCommand } from '@univerjs/core';+import { CommandType, ICommandService, ILogService } from '@univerjs/core';import { CopyCommand, CutCommand, IClipboardInterfaceService, PasteCommand } from '@univerjs/ui';import type { IAccessor } from '@wendellhu/redi';-import { whenSheetEditorActivated, whenSheetEditorFocused } from '../../controllers/shortcuts/utils';+import { whenSheetFocused } from '../../controllers/shortcuts/utils';import { ISheetClipboardService, PREDEFINED_HOOK_NAME } from '../../services/clipboard/clipboard.service';-function whenSheetEditorNotActivated(context: IContextService): boolean {- return whenSheetEditorFocused(context) && !context.getContextValue(EDITOR_ACTIVATED);-}-const SHEET_CLIPBOARD_PRIORITY = 998;export const SheetCopyCommand: IMultiCommand = {@@ -34,7 +30,7 @@ export const SheetCopyCommand: IMultiCommand = {type: CommandType.COMMAND,multi: true,priority: SHEET_CLIPBOARD_PRIORITY,- preconditions: whenSheetEditorNotActivated,+ preconditions: whenSheetFocused,handler: async (accessor) => {const sheetClipboardService = accessor.get(ISheetClipboardService);return sheetClipboardService.copy();@@ -47,7 +43,7 @@ export const SheetCutCommand: IMultiCommand = {type: CommandType.COMMAND,multi: true,priority: SHEET_CLIPBOARD_PRIORITY,- preconditions: whenSheetEditorActivated,+ preconditions: whenSheetFocused,handler: async (accessor) => {const sheetClipboardService = accessor.get(ISheetClipboardService);return sheetClipboardService.cut();@@ -64,7 +60,7 @@ export const SheetPasteCommand: IMultiCommand = {multi: true,name: 'sheet.command.paste',priority: SHEET_CLIPBOARD_PRIORITY,- preconditions: whenSheetEditorNotActivated,+ preconditions: whenSheetFocused,handler: async (accessor: IAccessor, params: ISheetPasteParams) => {const logService = accessor.get(ILogService);