@univerjs/action-recorder 1.0.0-alpha.2 → 1.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +180 -193
- package/lib/cjs/locale/ar-SA.js +18 -7
- package/lib/cjs/locale/ca-ES.js +18 -7
- package/lib/cjs/locale/de-DE.js +18 -7
- package/lib/cjs/locale/en-US.js +18 -7
- package/lib/cjs/locale/es-ES.js +18 -7
- package/lib/cjs/locale/fa-IR.js +18 -7
- package/lib/cjs/locale/fr-FR.js +18 -7
- package/lib/cjs/locale/id-ID.js +18 -7
- package/lib/cjs/locale/it-IT.js +18 -7
- package/lib/cjs/locale/ja-JP.js +18 -7
- package/lib/cjs/locale/ko-KR.js +18 -7
- package/lib/cjs/locale/pl-PL.js +18 -7
- package/lib/cjs/locale/pt-BR.js +18 -7
- package/lib/cjs/locale/ru-RU.js +18 -7
- package/lib/cjs/locale/sk-SK.js +18 -7
- package/lib/cjs/locale/vi-VN.js +18 -7
- package/lib/cjs/locale/zh-CN.js +18 -7
- package/lib/cjs/locale/zh-HK.js +18 -7
- package/lib/cjs/locale/zh-TW.js +18 -7
- package/lib/es/index.js +181 -195
- package/lib/es/locale/ar-SA.js +18 -7
- package/lib/es/locale/ca-ES.js +18 -7
- package/lib/es/locale/de-DE.js +18 -7
- package/lib/es/locale/en-US.js +18 -7
- package/lib/es/locale/es-ES.js +18 -7
- package/lib/es/locale/fa-IR.js +18 -7
- package/lib/es/locale/fr-FR.js +18 -7
- package/lib/es/locale/id-ID.js +18 -7
- package/lib/es/locale/it-IT.js +18 -7
- package/lib/es/locale/ja-JP.js +18 -7
- package/lib/es/locale/ko-KR.js +18 -7
- package/lib/es/locale/pl-PL.js +18 -7
- package/lib/es/locale/pt-BR.js +18 -7
- package/lib/es/locale/ru-RU.js +18 -7
- package/lib/es/locale/sk-SK.js +18 -7
- package/lib/es/locale/vi-VN.js +18 -7
- package/lib/es/locale/zh-CN.js +18 -7
- package/lib/es/locale/zh-HK.js +18 -7
- package/lib/es/locale/zh-TW.js +18 -7
- package/lib/index.js +181 -195
- package/lib/locale/ar-SA.js +18 -7
- package/lib/locale/ca-ES.js +18 -7
- package/lib/locale/de-DE.js +18 -7
- package/lib/locale/en-US.js +18 -7
- package/lib/locale/es-ES.js +18 -7
- package/lib/locale/fa-IR.js +18 -7
- package/lib/locale/fr-FR.js +18 -7
- package/lib/locale/id-ID.js +18 -7
- package/lib/locale/it-IT.js +18 -7
- package/lib/locale/ja-JP.js +18 -7
- package/lib/locale/ko-KR.js +18 -7
- package/lib/locale/pl-PL.js +18 -7
- package/lib/locale/pt-BR.js +18 -7
- package/lib/locale/ru-RU.js +18 -7
- package/lib/locale/sk-SK.js +18 -7
- package/lib/locale/vi-VN.js +18 -7
- package/lib/locale/zh-CN.js +18 -7
- package/lib/locale/zh-HK.js +18 -7
- package/lib/locale/zh-TW.js +18 -7
- package/lib/types/index.d.ts +1 -0
- package/lib/types/locale/en-US.d.ts +9 -0
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +10 -10
package/lib/cjs/index.js
CHANGED
|
@@ -1,68 +1,15 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _univerjs_ui = require("@univerjs/ui");
|
|
2
3
|
let _univerjs_core = require("@univerjs/core");
|
|
4
|
+
let _univerjs_design = require("@univerjs/design");
|
|
3
5
|
let _univerjs_sheets = require("@univerjs/sheets");
|
|
6
|
+
let rxjs = require("rxjs");
|
|
4
7
|
let _univerjs_sheets_filter = require("@univerjs/sheets-filter");
|
|
5
8
|
let _univerjs_sheets_ui = require("@univerjs/sheets-ui");
|
|
6
|
-
let _univerjs_ui = require("@univerjs/ui");
|
|
7
|
-
let rxjs = require("rxjs");
|
|
8
|
-
let _univerjs_design = require("@univerjs/design");
|
|
9
9
|
let _univerjs_icons = require("@univerjs/icons");
|
|
10
10
|
let react = require("react");
|
|
11
11
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
12
|
|
|
13
|
-
//#region package.json
|
|
14
|
-
var name = "@univerjs/action-recorder";
|
|
15
|
-
var version = "1.0.0-alpha.2";
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/config/config.ts
|
|
19
|
-
const ACTION_RECORDER_PLUGIN_CONFIG_KEY = "action-recorder.config";
|
|
20
|
-
const configSymbol = Symbol(ACTION_RECORDER_PLUGIN_CONFIG_KEY);
|
|
21
|
-
const defaultPluginConfig = {};
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
25
|
-
function _typeof(o) {
|
|
26
|
-
"@babel/helpers - typeof";
|
|
27
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
28
|
-
return typeof o;
|
|
29
|
-
} : function(o) {
|
|
30
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
31
|
-
}, _typeof(o);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
36
|
-
function toPrimitive(t, r) {
|
|
37
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
38
|
-
var e = t[Symbol.toPrimitive];
|
|
39
|
-
if (void 0 !== e) {
|
|
40
|
-
var i = e.call(t, r || "default");
|
|
41
|
-
if ("object" != _typeof(i)) return i;
|
|
42
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
43
|
-
}
|
|
44
|
-
return ("string" === r ? String : Number)(t);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
49
|
-
function toPropertyKey(t) {
|
|
50
|
-
var i = toPrimitive(t, "string");
|
|
51
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
56
|
-
function _defineProperty(e, r, t) {
|
|
57
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
58
|
-
value: t,
|
|
59
|
-
enumerable: !0,
|
|
60
|
-
configurable: !0,
|
|
61
|
-
writable: !0
|
|
62
|
-
}) : e[r] = t, e;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
//#endregion
|
|
66
13
|
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
|
|
67
14
|
function __decorateParam(paramIndex, decorator) {
|
|
68
15
|
return function(target, key) {
|
|
@@ -79,124 +26,6 @@ function __decorate(decorators, target, key, desc) {
|
|
|
79
26
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
80
27
|
}
|
|
81
28
|
|
|
82
|
-
//#endregion
|
|
83
|
-
//#region src/services/action-recorder.service.ts
|
|
84
|
-
let ActionRecorderService = class ActionRecorderService extends _univerjs_core.Disposable {
|
|
85
|
-
get recording() {
|
|
86
|
-
return this._recording$.getValue();
|
|
87
|
-
}
|
|
88
|
-
get _recorded() {
|
|
89
|
-
return this._recorded$.getValue();
|
|
90
|
-
}
|
|
91
|
-
get _recordedCommands() {
|
|
92
|
-
return this._recordedCommands$.getValue();
|
|
93
|
-
}
|
|
94
|
-
constructor(_commandSrv, _logService, _localFileService, _instanceService) {
|
|
95
|
-
super();
|
|
96
|
-
this._commandSrv = _commandSrv;
|
|
97
|
-
this._logService = _logService;
|
|
98
|
-
this._localFileService = _localFileService;
|
|
99
|
-
this._instanceService = _instanceService;
|
|
100
|
-
_defineProperty(this, "_shouldRecordCommands", /* @__PURE__ */ new Set());
|
|
101
|
-
_defineProperty(this, "_panelOpened$", new rxjs.BehaviorSubject(false));
|
|
102
|
-
_defineProperty(this, "panelOpened$", this._panelOpened$.asObservable());
|
|
103
|
-
_defineProperty(this, "_recorder", null);
|
|
104
|
-
_defineProperty(this, "_recording$", new rxjs.BehaviorSubject(false));
|
|
105
|
-
_defineProperty(this, "recording$", this._recording$.asObservable());
|
|
106
|
-
_defineProperty(this, "_recorded$", new rxjs.BehaviorSubject([]));
|
|
107
|
-
_defineProperty(this, "_recordedCommands$", new rxjs.BehaviorSubject([]));
|
|
108
|
-
_defineProperty(this, "recordedCommands$", this._recordedCommands$.asObservable());
|
|
109
|
-
}
|
|
110
|
-
registerRecordedCommand(command) {
|
|
111
|
-
if (command.type === _univerjs_core.CommandType.MUTATION) throw new Error("[CommandRecorderService] Cannot record mutation commands.");
|
|
112
|
-
this._shouldRecordCommands.add(command.id);
|
|
113
|
-
}
|
|
114
|
-
togglePanel(visible) {
|
|
115
|
-
this._panelOpened$.next(visible);
|
|
116
|
-
if (visible === false) this.stopRecording();
|
|
117
|
-
}
|
|
118
|
-
startRecording(replaceId = false) {
|
|
119
|
-
this._recorder = this._commandSrv.onCommandExecuted((rawCommandInfo) => {
|
|
120
|
-
if (this._shouldRecordCommands.has(rawCommandInfo.id)) {
|
|
121
|
-
var _this$_instanceServic;
|
|
122
|
-
const recorded = this._recorded;
|
|
123
|
-
const commands = this._recordedCommands;
|
|
124
|
-
let commandInfo = { ...rawCommandInfo };
|
|
125
|
-
const focusUnitId = (_this$_instanceServic = this._instanceService.getFocusedUnit()) === null || _this$_instanceServic === void 0 ? void 0 : _this$_instanceServic.getUnitId();
|
|
126
|
-
const { unitId = focusUnitId, subUnitId } = commandInfo === null || commandInfo === void 0 ? void 0 : commandInfo.params;
|
|
127
|
-
if (replaceId && unitId && subUnitId) {
|
|
128
|
-
var _getSheetBySheetId;
|
|
129
|
-
const subUnitName = (_getSheetBySheetId = this._instanceService.getUnit(unitId).getSheetBySheetId(subUnitId)) === null || _getSheetBySheetId === void 0 ? void 0 : _getSheetBySheetId.getName();
|
|
130
|
-
commandInfo = {
|
|
131
|
-
...commandInfo,
|
|
132
|
-
params: {
|
|
133
|
-
...commandInfo.params,
|
|
134
|
-
subUnitId: subUnitName
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
if (commandInfo.id === _univerjs_sheets.SetSelectionsOperation.id && recorded.length > 0 && recorded[recorded.length - 1].id === _univerjs_sheets.SetSelectionsOperation.id) recorded[recorded.length - 1] = commandInfo;
|
|
139
|
-
else {
|
|
140
|
-
recorded.push(commandInfo);
|
|
141
|
-
this._recorded$.next(recorded);
|
|
142
|
-
if (commandInfo.type === _univerjs_core.CommandType.COMMAND) {
|
|
143
|
-
commands.push(commandInfo);
|
|
144
|
-
this._recordedCommands$.next(commands);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
this._recording$.next(true);
|
|
150
|
-
}
|
|
151
|
-
stopRecording() {
|
|
152
|
-
var _this$_recorder;
|
|
153
|
-
(_this$_recorder = this._recorder) === null || _this$_recorder === void 0 || _this$_recorder.dispose();
|
|
154
|
-
this._recorder = null;
|
|
155
|
-
this._recorded$.next([]);
|
|
156
|
-
this._recordedCommands$.next([]);
|
|
157
|
-
this._recording$.next(false);
|
|
158
|
-
}
|
|
159
|
-
completeRecording() {
|
|
160
|
-
const commands = this._recorded.slice();
|
|
161
|
-
this._localFileService.downloadFile(new Blob([JSON.stringify(commands, null, 2)]), "recorded-commands.json");
|
|
162
|
-
this._logService.error("Recorded commands:", commands);
|
|
163
|
-
this.stopRecording();
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
ActionRecorderService = __decorate([
|
|
167
|
-
__decorateParam(0, _univerjs_core.ICommandService),
|
|
168
|
-
__decorateParam(1, _univerjs_core.ILogService),
|
|
169
|
-
__decorateParam(2, _univerjs_ui.ILocalFileService),
|
|
170
|
-
__decorateParam(3, _univerjs_core.IUniverInstanceService)
|
|
171
|
-
], ActionRecorderService);
|
|
172
|
-
|
|
173
|
-
//#endregion
|
|
174
|
-
//#region src/commands/commands/record.command.ts
|
|
175
|
-
const StartRecordingActionCommand = {
|
|
176
|
-
id: "action-recorder.command.start-recording",
|
|
177
|
-
type: _univerjs_core.CommandType.COMMAND,
|
|
178
|
-
handler: (accessor, params) => {
|
|
179
|
-
accessor.get(ActionRecorderService).startRecording(!!(params === null || params === void 0 ? void 0 : params.replaceId));
|
|
180
|
-
return true;
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
const CompleteRecordingActionCommand = {
|
|
184
|
-
id: "action-recorder.command.complete-recording",
|
|
185
|
-
type: _univerjs_core.CommandType.COMMAND,
|
|
186
|
-
handler: (accessor) => {
|
|
187
|
-
accessor.get(ActionRecorderService).completeRecording();
|
|
188
|
-
return true;
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
const StopRecordingActionCommand = {
|
|
192
|
-
id: "action-recorder.command.stop-recording",
|
|
193
|
-
type: _univerjs_core.CommandType.COMMAND,
|
|
194
|
-
handler: (accessor) => {
|
|
195
|
-
accessor.get(ActionRecorderService).completeRecording();
|
|
196
|
-
return true;
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
|
|
200
29
|
//#endregion
|
|
201
30
|
//#region src/services/replay.service.ts
|
|
202
31
|
let ActionReplayService = class ActionReplayService extends _univerjs_core.Disposable {
|
|
@@ -329,6 +158,139 @@ const ReplayLocalRecordOnActiveCommand = {
|
|
|
329
158
|
}
|
|
330
159
|
};
|
|
331
160
|
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
163
|
+
function _typeof(o) {
|
|
164
|
+
"@babel/helpers - typeof";
|
|
165
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
166
|
+
return typeof o;
|
|
167
|
+
} : function(o) {
|
|
168
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
169
|
+
}, _typeof(o);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
174
|
+
function toPrimitive(t, r) {
|
|
175
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
176
|
+
var e = t[Symbol.toPrimitive];
|
|
177
|
+
if (void 0 !== e) {
|
|
178
|
+
var i = e.call(t, r || "default");
|
|
179
|
+
if ("object" != _typeof(i)) return i;
|
|
180
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
181
|
+
}
|
|
182
|
+
return ("string" === r ? String : Number)(t);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
187
|
+
function toPropertyKey(t) {
|
|
188
|
+
var i = toPrimitive(t, "string");
|
|
189
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
194
|
+
function _defineProperty(e, r, t) {
|
|
195
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
196
|
+
value: t,
|
|
197
|
+
enumerable: !0,
|
|
198
|
+
configurable: !0,
|
|
199
|
+
writable: !0
|
|
200
|
+
}) : e[r] = t, e;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/services/action-recorder.service.ts
|
|
205
|
+
let ActionRecorderService = class ActionRecorderService extends _univerjs_core.Disposable {
|
|
206
|
+
get recording() {
|
|
207
|
+
return this._recording$.getValue();
|
|
208
|
+
}
|
|
209
|
+
get _recorded() {
|
|
210
|
+
return this._recorded$.getValue();
|
|
211
|
+
}
|
|
212
|
+
get _recordedCommands() {
|
|
213
|
+
return this._recordedCommands$.getValue();
|
|
214
|
+
}
|
|
215
|
+
constructor(_commandSrv, _logService, _localFileService, _instanceService) {
|
|
216
|
+
super();
|
|
217
|
+
this._commandSrv = _commandSrv;
|
|
218
|
+
this._logService = _logService;
|
|
219
|
+
this._localFileService = _localFileService;
|
|
220
|
+
this._instanceService = _instanceService;
|
|
221
|
+
_defineProperty(this, "_shouldRecordCommands", /* @__PURE__ */ new Set());
|
|
222
|
+
_defineProperty(this, "_panelOpened$", new rxjs.BehaviorSubject(false));
|
|
223
|
+
_defineProperty(this, "panelOpened$", this._panelOpened$.asObservable());
|
|
224
|
+
_defineProperty(this, "_recorder", null);
|
|
225
|
+
_defineProperty(this, "_recording$", new rxjs.BehaviorSubject(false));
|
|
226
|
+
_defineProperty(this, "recording$", this._recording$.asObservable());
|
|
227
|
+
_defineProperty(this, "_recorded$", new rxjs.BehaviorSubject([]));
|
|
228
|
+
_defineProperty(this, "_recordedCommands$", new rxjs.BehaviorSubject([]));
|
|
229
|
+
_defineProperty(this, "recordedCommands$", this._recordedCommands$.asObservable());
|
|
230
|
+
}
|
|
231
|
+
registerRecordedCommand(command) {
|
|
232
|
+
if (command.type === _univerjs_core.CommandType.MUTATION) throw new Error("[CommandRecorderService] Cannot record mutation commands.");
|
|
233
|
+
this._shouldRecordCommands.add(command.id);
|
|
234
|
+
}
|
|
235
|
+
togglePanel(visible) {
|
|
236
|
+
this._panelOpened$.next(visible);
|
|
237
|
+
if (visible === false) this.stopRecording();
|
|
238
|
+
}
|
|
239
|
+
startRecording(replaceId = false) {
|
|
240
|
+
this._recorder = this._commandSrv.onCommandExecuted((rawCommandInfo) => {
|
|
241
|
+
if (this._shouldRecordCommands.has(rawCommandInfo.id)) {
|
|
242
|
+
var _this$_instanceServic;
|
|
243
|
+
const recorded = this._recorded;
|
|
244
|
+
const commands = this._recordedCommands;
|
|
245
|
+
let commandInfo = { ...rawCommandInfo };
|
|
246
|
+
const focusUnitId = (_this$_instanceServic = this._instanceService.getFocusedUnit()) === null || _this$_instanceServic === void 0 ? void 0 : _this$_instanceServic.getUnitId();
|
|
247
|
+
const { unitId = focusUnitId, subUnitId } = commandInfo === null || commandInfo === void 0 ? void 0 : commandInfo.params;
|
|
248
|
+
if (replaceId && unitId && subUnitId) {
|
|
249
|
+
var _getSheetBySheetId;
|
|
250
|
+
const subUnitName = (_getSheetBySheetId = this._instanceService.getUnit(unitId).getSheetBySheetId(subUnitId)) === null || _getSheetBySheetId === void 0 ? void 0 : _getSheetBySheetId.getName();
|
|
251
|
+
commandInfo = {
|
|
252
|
+
...commandInfo,
|
|
253
|
+
params: {
|
|
254
|
+
...commandInfo.params,
|
|
255
|
+
subUnitId: subUnitName
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
if (commandInfo.id === _univerjs_sheets.SetSelectionsOperation.id && recorded.length > 0 && recorded[recorded.length - 1].id === _univerjs_sheets.SetSelectionsOperation.id) recorded[recorded.length - 1] = commandInfo;
|
|
260
|
+
else {
|
|
261
|
+
recorded.push(commandInfo);
|
|
262
|
+
this._recorded$.next(recorded);
|
|
263
|
+
if (commandInfo.type === _univerjs_core.CommandType.COMMAND) {
|
|
264
|
+
commands.push(commandInfo);
|
|
265
|
+
this._recordedCommands$.next(commands);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
this._recording$.next(true);
|
|
271
|
+
}
|
|
272
|
+
stopRecording() {
|
|
273
|
+
var _this$_recorder;
|
|
274
|
+
(_this$_recorder = this._recorder) === null || _this$_recorder === void 0 || _this$_recorder.dispose();
|
|
275
|
+
this._recorder = null;
|
|
276
|
+
this._recorded$.next([]);
|
|
277
|
+
this._recordedCommands$.next([]);
|
|
278
|
+
this._recording$.next(false);
|
|
279
|
+
}
|
|
280
|
+
completeRecording() {
|
|
281
|
+
const commands = this._recorded.slice();
|
|
282
|
+
this._localFileService.downloadFile(new Blob([JSON.stringify(commands, null, 2)]), "recorded-commands.json");
|
|
283
|
+
this._logService.error("Recorded commands:", commands);
|
|
284
|
+
this.stopRecording();
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
ActionRecorderService = __decorate([
|
|
288
|
+
__decorateParam(0, _univerjs_core.ICommandService),
|
|
289
|
+
__decorateParam(1, _univerjs_core.ILogService),
|
|
290
|
+
__decorateParam(2, _univerjs_ui.ILocalFileService),
|
|
291
|
+
__decorateParam(3, _univerjs_core.IUniverInstanceService)
|
|
292
|
+
], ActionRecorderService);
|
|
293
|
+
|
|
332
294
|
//#endregion
|
|
333
295
|
//#region src/commands/operations/operation.ts
|
|
334
296
|
const OpenRecordPanelOperation = {
|
|
@@ -410,23 +372,46 @@ const menuSchema = { [_univerjs_ui.RibbonOthersGroup.OTHERS]: { [RECORD_MENU_ITE
|
|
|
410
372
|
}
|
|
411
373
|
} } };
|
|
412
374
|
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region package.json
|
|
377
|
+
var name = "@univerjs/action-recorder";
|
|
378
|
+
var version = "1.0.0-alpha.4";
|
|
379
|
+
|
|
380
|
+
//#endregion
|
|
381
|
+
//#region src/config/config.ts
|
|
382
|
+
const ACTION_RECORDER_PLUGIN_CONFIG_KEY = "action-recorder.config";
|
|
383
|
+
const configSymbol = Symbol(ACTION_RECORDER_PLUGIN_CONFIG_KEY);
|
|
384
|
+
const defaultPluginConfig = {};
|
|
385
|
+
|
|
386
|
+
//#endregion
|
|
387
|
+
//#region src/commands/commands/record.command.ts
|
|
388
|
+
const StartRecordingActionCommand = {
|
|
389
|
+
id: "action-recorder.command.start-recording",
|
|
390
|
+
type: _univerjs_core.CommandType.COMMAND,
|
|
391
|
+
handler: (accessor, params) => {
|
|
392
|
+
accessor.get(ActionRecorderService).startRecording(!!(params === null || params === void 0 ? void 0 : params.replaceId));
|
|
393
|
+
return true;
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
const CompleteRecordingActionCommand = {
|
|
397
|
+
id: "action-recorder.command.complete-recording",
|
|
398
|
+
type: _univerjs_core.CommandType.COMMAND,
|
|
399
|
+
handler: (accessor) => {
|
|
400
|
+
accessor.get(ActionRecorderService).completeRecording();
|
|
401
|
+
return true;
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
const StopRecordingActionCommand = {
|
|
405
|
+
id: "action-recorder.command.stop-recording",
|
|
406
|
+
type: _univerjs_core.CommandType.COMMAND,
|
|
407
|
+
handler: (accessor) => {
|
|
408
|
+
accessor.get(ActionRecorderService).completeRecording();
|
|
409
|
+
return true;
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
|
|
413
413
|
//#endregion
|
|
414
414
|
//#region src/views/components/RecorderPanel.tsx
|
|
415
|
-
/**
|
|
416
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
417
|
-
*
|
|
418
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
419
|
-
* you may not use this file except in compliance with the License.
|
|
420
|
-
* You may obtain a copy of the License at
|
|
421
|
-
*
|
|
422
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
423
|
-
*
|
|
424
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
425
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
426
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
427
|
-
* See the License for the specific language governing permissions and
|
|
428
|
-
* limitations under the License.
|
|
429
|
-
*/
|
|
430
415
|
function RecorderPanel() {
|
|
431
416
|
if (!(0, _univerjs_ui.useObservable)((0, _univerjs_ui.useDependency)(ActionRecorderService).panelOpened$)) return null;
|
|
432
417
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RecordPanelImpl, {});
|
|
@@ -434,6 +419,7 @@ function RecorderPanel() {
|
|
|
434
419
|
function RecordPanelImpl() {
|
|
435
420
|
var _recordedCommands$len;
|
|
436
421
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
422
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
437
423
|
const actionRecorderService = (0, _univerjs_ui.useDependency)(ActionRecorderService);
|
|
438
424
|
const recording = (0, _univerjs_ui.useObservable)(actionRecorderService.recording$);
|
|
439
425
|
const recordedCommands = (0, _univerjs_ui.useObservable)(actionRecorderService.recordedCommands$);
|
|
@@ -450,7 +436,7 @@ function RecordPanelImpl() {
|
|
|
450
436
|
const stopRecording = (0, react.useCallback)(() => {
|
|
451
437
|
if (recording) commandService.executeCommand(StopRecordingActionCommand.id);
|
|
452
438
|
}, [commandService, recording]);
|
|
453
|
-
const titleText = recording ? len === 0 ? "
|
|
439
|
+
const titleText = recording ? len === 0 ? localeService.t("action-recorder.panel.recording") : `${len}: ${recordedCommands[len - 1].id}` : localeService.t("action-recorder.panel.startRecording");
|
|
454
440
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
455
441
|
className: "univer-fixed univer-bottom-20 univer-left-1/2 univer-z-[1000] univer-flex univer-h-16 univer-w-[512px] -univer-translate-x-1/2 univer-items-center univer-rounded-lg univer-bg-white univer-px-5 univer-shadow-lg",
|
|
456
442
|
children: [
|
|
@@ -468,18 +454,18 @@ function RecordPanelImpl() {
|
|
|
468
454
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
469
455
|
className: "univer-w-20",
|
|
470
456
|
onClick: recording ? stopRecording : closePanel,
|
|
471
|
-
children: recording ? "
|
|
457
|
+
children: localeService.t(recording ? "action-recorder.panel.cancel" : "action-recorder.panel.close")
|
|
472
458
|
}),
|
|
473
459
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
474
460
|
className: "univer-w-20",
|
|
475
461
|
variant: "primary",
|
|
476
462
|
onClick: recording ? completeRecording : () => startRecording(),
|
|
477
|
-
children: recording ? "
|
|
463
|
+
children: localeService.t(recording ? "action-recorder.panel.save" : "action-recorder.panel.start")
|
|
478
464
|
}),
|
|
479
465
|
!recording && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
480
466
|
variant: "primary",
|
|
481
467
|
onClick: () => startRecording(true),
|
|
482
|
-
children: "
|
|
468
|
+
children: localeService.t("action-recorder.panel.startWithId")
|
|
483
469
|
})
|
|
484
470
|
]
|
|
485
471
|
})
|
|
@@ -660,6 +646,7 @@ _defineProperty(UniverActionRecorderPlugin, "version", version);
|
|
|
660
646
|
UniverActionRecorderPlugin = __decorate([__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(2, _univerjs_core.IConfigService)], UniverActionRecorderPlugin);
|
|
661
647
|
|
|
662
648
|
//#endregion
|
|
649
|
+
exports.ActionRecorderMenuSchema = menuSchema;
|
|
663
650
|
Object.defineProperty(exports, 'ActionRecorderService', {
|
|
664
651
|
enumerable: true,
|
|
665
652
|
get: function () {
|
package/lib/cjs/locale/ar-SA.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/locale/ar-SA.ts
|
|
3
|
-
const locale = { "action-recorder": {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
const locale = { "action-recorder": {
|
|
4
|
+
panel: {
|
|
5
|
+
recording: "جارٍ التسجيل...",
|
|
6
|
+
startRecording: "بدء التسجيل",
|
|
7
|
+
cancel: "إلغاء",
|
|
8
|
+
close: "إغلاق",
|
|
9
|
+
save: "حفظ",
|
|
10
|
+
start: "بدء",
|
|
11
|
+
startWithId: "بدء (N)"
|
|
12
|
+
},
|
|
13
|
+
menu: {
|
|
14
|
+
title: "تسجيل الإجراءات",
|
|
15
|
+
record: "تسجيل الإجراءات...",
|
|
16
|
+
"replay-local": "استبدال السجل المحلي...",
|
|
17
|
+
"replay-local-name": "استبدال السجل المحلي بوحدة فرعية...",
|
|
18
|
+
"replay-local-active": "استبدال السجل المحلي بالوحدة الفرعية الحالية..."
|
|
19
|
+
}
|
|
20
|
+
} };
|
|
10
21
|
|
|
11
22
|
//#endregion
|
|
12
23
|
module.exports = locale;
|
package/lib/cjs/locale/ca-ES.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/locale/ca-ES.ts
|
|
3
|
-
const locale = { "action-recorder": {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
const locale = { "action-recorder": {
|
|
4
|
+
panel: {
|
|
5
|
+
recording: "S'està enregistrant...",
|
|
6
|
+
startRecording: "Inicia l’enregistrament",
|
|
7
|
+
cancel: "Cancel·la",
|
|
8
|
+
close: "Tanca",
|
|
9
|
+
save: "Desa",
|
|
10
|
+
start: "Inicia",
|
|
11
|
+
startWithId: "Inicia (N)"
|
|
12
|
+
},
|
|
13
|
+
menu: {
|
|
14
|
+
title: "Grava accions",
|
|
15
|
+
record: "Grava accions...",
|
|
16
|
+
"replay-local": "Reemplaça gravació local...",
|
|
17
|
+
"replay-local-name": "Reemplaça gravació local per subunitat...",
|
|
18
|
+
"replay-local-active": "Reemplaça gravació local per subunitat actual..."
|
|
19
|
+
}
|
|
20
|
+
} };
|
|
10
21
|
|
|
11
22
|
//#endregion
|
|
12
23
|
module.exports = locale;
|
package/lib/cjs/locale/de-DE.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/locale/de-DE.ts
|
|
3
|
-
const locale = { "action-recorder": {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
const locale = { "action-recorder": {
|
|
4
|
+
panel: {
|
|
5
|
+
recording: "Aufnahme läuft...",
|
|
6
|
+
startRecording: "Aufnahme starten",
|
|
7
|
+
cancel: "Abbrechen",
|
|
8
|
+
close: "Schließen",
|
|
9
|
+
save: "Speichern",
|
|
10
|
+
start: "Starten",
|
|
11
|
+
startWithId: "Starten (N)"
|
|
12
|
+
},
|
|
13
|
+
menu: {
|
|
14
|
+
title: "Aktionen aufzeichnen",
|
|
15
|
+
record: "Aktionen aufzeichnen...",
|
|
16
|
+
"replay-local": "Lokale Aufzeichnung ersetzen...",
|
|
17
|
+
"replay-local-name": "Lokale Aufzeichnung nach Untereinheit ersetzen...",
|
|
18
|
+
"replay-local-active": "Lokale Aufzeichnung nach aktueller Untereinheit ersetzen..."
|
|
19
|
+
}
|
|
20
|
+
} };
|
|
10
21
|
|
|
11
22
|
//#endregion
|
|
12
23
|
module.exports = locale;
|
package/lib/cjs/locale/en-US.js
CHANGED
|
@@ -15,13 +15,24 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
const locale = { "action-recorder": {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
const locale = { "action-recorder": {
|
|
19
|
+
panel: {
|
|
20
|
+
recording: "Recording...",
|
|
21
|
+
startRecording: "Start Recording",
|
|
22
|
+
cancel: "Cancel",
|
|
23
|
+
close: "Close",
|
|
24
|
+
save: "Save",
|
|
25
|
+
start: "Start",
|
|
26
|
+
startWithId: "Start(N)"
|
|
27
|
+
},
|
|
28
|
+
menu: {
|
|
29
|
+
title: "Record Actions",
|
|
30
|
+
record: "Record Actions...",
|
|
31
|
+
"replay-local": "Replace Local Record...",
|
|
32
|
+
"replay-local-name": "Replace Local Record by Subunit...",
|
|
33
|
+
"replay-local-active": "Replace Local Record by Current Subunit..."
|
|
34
|
+
}
|
|
35
|
+
} };
|
|
25
36
|
|
|
26
37
|
//#endregion
|
|
27
38
|
module.exports = locale;
|
package/lib/cjs/locale/es-ES.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/locale/es-ES.ts
|
|
3
|
-
const locale = { "action-recorder": {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
const locale = { "action-recorder": {
|
|
4
|
+
panel: {
|
|
5
|
+
recording: "Grabando...",
|
|
6
|
+
startRecording: "Iniciar grabación",
|
|
7
|
+
cancel: "Cancelar",
|
|
8
|
+
close: "Cerrar",
|
|
9
|
+
save: "Guardar",
|
|
10
|
+
start: "Iniciar",
|
|
11
|
+
startWithId: "Iniciar (N)"
|
|
12
|
+
},
|
|
13
|
+
menu: {
|
|
14
|
+
title: "Grabar acciones",
|
|
15
|
+
record: "Grabar acciones...",
|
|
16
|
+
"replay-local": "Reemplazar grabación local...",
|
|
17
|
+
"replay-local-name": "Reemplazar grabación local por subunidad...",
|
|
18
|
+
"replay-local-active": "Reemplazar grabación local por subunidad actual..."
|
|
19
|
+
}
|
|
20
|
+
} };
|
|
10
21
|
|
|
11
22
|
//#endregion
|
|
12
23
|
module.exports = locale;
|
package/lib/cjs/locale/fa-IR.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/locale/fa-IR.ts
|
|
3
|
-
const locale = { "action-recorder": {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
const locale = { "action-recorder": {
|
|
4
|
+
panel: {
|
|
5
|
+
recording: "در حال ضبط...",
|
|
6
|
+
startRecording: "شروع ضبط",
|
|
7
|
+
cancel: "لغو",
|
|
8
|
+
close: "بستن",
|
|
9
|
+
save: "ذخیره",
|
|
10
|
+
start: "شروع",
|
|
11
|
+
startWithId: "شروع (N)"
|
|
12
|
+
},
|
|
13
|
+
menu: {
|
|
14
|
+
title: "ثبت اقدامات",
|
|
15
|
+
record: "ثبت اقدامات...",
|
|
16
|
+
"replay-local": "بازپخش محلی ثبت...",
|
|
17
|
+
"replay-local-name": "بازپخش محلی ثبت بر اساس نام زیر واحد...",
|
|
18
|
+
"replay-local-active": "بازپخش محلی ثبت بر اساس زیر واحد فعلی..."
|
|
19
|
+
}
|
|
20
|
+
} };
|
|
10
21
|
|
|
11
22
|
//#endregion
|
|
12
23
|
module.exports = locale;
|
package/lib/cjs/locale/fr-FR.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/locale/fr-FR.ts
|
|
3
|
-
const locale = { "action-recorder": {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
const locale = { "action-recorder": {
|
|
4
|
+
panel: {
|
|
5
|
+
recording: "Enregistrement...",
|
|
6
|
+
startRecording: "Démarrer l’enregistrement",
|
|
7
|
+
cancel: "Annuler",
|
|
8
|
+
close: "Fermer",
|
|
9
|
+
save: "Enregistrer",
|
|
10
|
+
start: "Démarrer",
|
|
11
|
+
startWithId: "Démarrer (N)"
|
|
12
|
+
},
|
|
13
|
+
menu: {
|
|
14
|
+
title: "Enregistrer les actions",
|
|
15
|
+
record: "Enregistrer les actions...",
|
|
16
|
+
"replay-local": "Lecture de l'enregistrement local...",
|
|
17
|
+
"replay-local-name": "Remplacer l'enregistrement local par le sous-unité...",
|
|
18
|
+
"replay-local-active": "Remplacer l'enregistrement local par le sous-unité actuel..."
|
|
19
|
+
}
|
|
20
|
+
} };
|
|
10
21
|
|
|
11
22
|
//#endregion
|
|
12
23
|
module.exports = locale;
|