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
feat(core): command service support get command type
Wenzhao Hu6775a7310dec
diff --git a/packages/core/src/services/command/command.service.ts b/packages/core/src/services/command/command.service.tsindex 0354789fce..ef14856ed5 100644--- a/packages/core/src/services/command/command.service.ts+++ b/packages/core/src/services/command/command.service.ts@@ -171,6 +171,7 @@ export const ICommandService = createIdentifier<ICommandService>('anywhere.comma*/export class CommandRegistry {private readonly _commands = new Map<string, ICommand>();+ private readonly _commandTypes = new Map<string, CommandType>();registerCommand(command: ICommand): IDisposable {if (this._commands.has(command.id)) {@@ -178,9 +179,11 @@ export class CommandRegistry {}this._commands.set(command.id, command);+ this._commandTypes.set(command.id, command.type);return toDisposable(() => {this._commands.delete(command.id);+ this._commandTypes.delete(command.id);command.onDispose?.();});@@ -197,6 +200,10 @@ export class CommandRegistry {return [this._commands.get(id)!];}++ getCommandType(id: string): CommandType | undefined {+ return this._commandTypes.get(id);+ }}interface ICommandExecutionStackItem extends ICommandInfo {}@@ -208,7 +215,7 @@ export const NilCommand: ICommand = {};export class CommandService implements ICommandService {- private readonly _commandRegistry: CommandRegistry;+ protected readonly _commandRegistry: CommandRegistry;private readonly _beforeCommandExecutionListeners: CommandListener[] = [];private readonly _commandExecutedListeners: CommandListener[] = [];diff --git a/packages/find-replace/src/controllers/find-replace.controller.ts b/packages/find-replace/src/controllers/find-replace.controller.tsindex 230c973f83..858b05fdef 100644--- a/packages/find-replace/src/controllers/find-replace.controller.ts+++ b/packages/find-replace/src/controllers/find-replace.controller.ts@@ -16,8 +16,6 @@import {ICommandService,- IContextService,- ILogService,IUniverInstanceService,LifecycleStages,LocaleService,@@ -67,9 +65,7 @@ export class FindReplaceController extends RxDisposable {@IShortcutService private readonly _shortcutService: IShortcutService,@ICommandService private readonly _commandService: ICommandService,@IFindReplaceService private readonly _findReplaceService: IFindReplaceService,- @ILogService private readonly _logService: ILogService,@IDialogService private readonly _dialogService: IDialogService,- @IContextService private readonly _contextService: IContextService,@ILayoutService private readonly _layoutService: ILayoutService,@Inject(LocaleService) private readonly _localeService: LocaleService,@Inject(ComponentManager) private readonly _componentManager: ComponentManager,