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