diff --git a/packages-experimental/action-recorder/src/controllers/config.schema.ts b/packages-experimental/action-recorder/src/controllers/config.schema.ts index 57500ba4d340..61e1146d4e05 100644 --- a/packages-experimental/action-recorder/src/controllers/config.schema.ts +++ b/packages-experimental/action-recorder/src/controllers/config.schema.ts @@ -22,6 +22,7 @@ export const configSymbol = Symbol(PLUGIN_CONFIG_KEY); export interface IUniverActionRecorderConfig { menu?: MenuConfig; + replayOnly?: boolean; } export const defaultPluginConfig: IUniverActionRecorderConfig = {}; diff --git a/packages-experimental/action-recorder/src/plugin.ts b/packages-experimental/action-recorder/src/plugin.ts index fbc7fa3a5abf..8618e305fe0f 100644 --- a/packages-experimental/action-recorder/src/plugin.ts +++ b/packages-experimental/action-recorder/src/plugin.ts @@ -14,13 +14,13 @@ * limitations under the License. */ -import { IConfigService, Inject, Injector, Plugin } from '@univerjs/core'; import type { Dependency } from '@univerjs/core'; +import type { IUniverActionRecorderConfig } from './controllers/config.schema'; +import { IConfigService, Inject, Injector, Plugin } from '@univerjs/core'; import { ActionRecorderController } from './controllers/action-recorder.controller'; import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema'; import { ActionRecorderService } from './services/action-recorder.service'; import { ActionReplayService } from './services/replay.service'; -import type { IUniverActionRecorderConfig } from './controllers/config.schema'; /** * This plugin provides a recorder for user's interactions with Univer, @@ -45,14 +45,20 @@ export class UniverActionRecorderPlugin extends Plugin { } override onStarting(): void { - ([ - [ActionRecorderService], - [ActionReplayService], - [ActionRecorderController], - ] as Dependency[]).forEach((d) => this._injector.add(d)); + const dependency = this._config.replayOnly + ? [[ActionReplayService]] + : [ + [ActionRecorderService], + [ActionReplayService], + [ActionRecorderController], + ]; + (dependency as Dependency[]).forEach((d) => this._injector.add(d)); } override onSteady(): void { + if (this._config.replayOnly) { + return; + } this._injector.get(ActionRecorderController); } }