Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add replay-only mode to actionRecordPlugin #3695

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const configSymbol = Symbol(PLUGIN_CONFIG_KEY);

export interface IUniverActionRecorderConfig {
menu?: MenuConfig;
replayOnly?: boolean;
}

export const defaultPluginConfig: IUniverActionRecorderConfig = {};
20 changes: 13 additions & 7 deletions packages-experimental/action-recorder/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}
}
Loading