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.

feat: add replay-only mode to actionRecordPlugin (#3695)

YuHonga3cb5c47aee1
diff --git a/packages-experimental/action-recorder/src/controllers/config.schema.ts b/packages-experimental/action-recorder/src/controllers/config.schema.ts
index 57500ba4d3..61e1146d4e 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 fbc7fa3a5a..8618e305fe 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);
}
}