diff --git a/packages/core/src/services/command/command.service.ts b/packages/core/src/services/command/command.service.ts index 0354789fced..ef14856ed5f 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('anywhere.comma */ export class CommandRegistry { private readonly _commands = new Map(); + private readonly _commandTypes = new Map(); 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.ts index 230c973f837..858b05fdef1 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,