@univerjs/action-recorder 0.17.0 → 0.18.0
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 +4 -1
- package/lib/cjs/locale/ca-ES.js +1 -1
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/es-ES.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/ja-JP.js +1 -1
- package/lib/cjs/locale/ko-KR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/sk-SK.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/index.js +4 -572
- package/lib/es/locale/ca-ES.js +1 -14
- package/lib/es/locale/en-US.js +1 -14
- package/lib/es/locale/es-ES.js +1 -14
- package/lib/es/locale/fa-IR.js +1 -14
- package/lib/es/locale/fr-FR.js +1 -14
- package/lib/es/locale/ja-JP.js +1 -14
- package/lib/es/locale/ko-KR.js +1 -14
- package/lib/es/locale/ru-RU.js +1 -14
- package/lib/es/locale/sk-SK.js +1 -14
- package/lib/es/locale/vi-VN.js +1 -14
- package/lib/es/locale/zh-CN.js +1 -14
- package/lib/es/locale/zh-TW.js +1 -14
- package/lib/index.css +100 -1
- package/lib/index.js +4 -572
- package/lib/locale/ca-ES.js +1 -14
- package/lib/locale/en-US.js +1 -14
- package/lib/locale/es-ES.js +1 -14
- package/lib/locale/fa-IR.js +1 -14
- package/lib/locale/fr-FR.js +1 -14
- package/lib/locale/ja-JP.js +1 -14
- package/lib/locale/ko-KR.js +1 -14
- package/lib/locale/ru-RU.js +1 -14
- package/lib/locale/sk-SK.js +1 -14
- package/lib/locale/vi-VN.js +1 -14
- package/lib/locale/zh-CN.js +1 -14
- package/lib/locale/zh-TW.js +1 -14
- package/lib/types/commands/commands/record.command.d.ts +16 -1
- package/lib/types/commands/commands/replay.command.d.ts +16 -1
- package/lib/types/commands/operations/operation.d.ts +16 -1
- package/lib/types/config/config.d.ts +16 -1
- package/lib/types/controllers/action-recorder.controller.d.ts +15 -0
- package/lib/types/locale/ca-ES.d.ts +16 -1
- package/lib/types/locale/es-ES.d.ts +16 -1
- package/lib/types/locale/fa-IR.d.ts +16 -1
- package/lib/types/locale/fr-FR.d.ts +16 -1
- package/lib/types/locale/ja-JP.d.ts +16 -1
- package/lib/types/locale/ko-KR.d.ts +16 -1
- package/lib/types/locale/ru-RU.d.ts +16 -1
- package/lib/types/locale/sk-SK.d.ts +16 -1
- package/lib/types/locale/vi-VN.d.ts +16 -1
- package/lib/types/locale/zh-CN.d.ts +16 -1
- package/lib/types/locale/zh-TW.d.ts +16 -1
- package/lib/types/menu/action-recorder.menu.d.ts +17 -2
- package/lib/types/plugin.d.ts +16 -1
- package/lib/types/services/action-recorder.service.d.ts +20 -4
- package/lib/types/services/replay.service.d.ts +17 -1
- package/lib/umd/index.js +4 -1
- package/lib/umd/locale/ca-ES.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/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.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-TW.js +1 -1
- package/package.json +12 -11
- package/lib/types/commands/commands/commands.spec.d.ts +0 -16
- package/lib/types/commands/operations/operation.spec.d.ts +0 -16
- package/lib/types/services/action-recorder.service.spec.d.ts +0 -16
- package/lib/types/services/replay.service.spec.d.ts +0 -16
package/lib/index.js
CHANGED
|
@@ -1,572 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { useRef as le, createElement as K, forwardRef as me, useCallback as R } from "react";
|
|
6
|
-
import { SetSelectionsOperation as A, CopySheetCommand as ue, DeleteRangeMoveLeftCommand as he, DeleteRangeMoveUpCommand as ge, DeltaColumnWidthCommand as fe, DeltaRowHeightCommand as pe, InsertSheetCommand as Se, InsertColAfterCommand as ve, InsertColBeforeCommand as Ce, InsertRowAfterCommand as _e, InsertRowBeforeCommand as ye, RemoveSheetCommand as Re, SetStyleCommand as Ie, AddWorksheetMergeCommand as Oe, AddWorksheetMergeAllCommand as we, AddWorksheetMergeVerticalCommand as Me, AddWorksheetMergeHorizontalCommand as $e, SetFrozenCommand as xe, CancelFrozenCommand as Ne, SetHorizontalTextAlignCommand as Ue, SetOverlineCommand as Ae, SetRangeValuesCommand as be, SetStrikeThroughCommand as Fe, SetTextColorCommand as Pe, SetTextRotationCommand as Te, SetTextWrapCommand as De, SetVerticalTextAlignCommand as Ee, AutoFillCommand as Le, RefillCommand as je, SetWorksheetActivateCommand as ke, SetWorksheetActiveOperation as Be } from "@univerjs/sheets";
|
|
7
|
-
import { SetSheetFilterRangeCommand as Ve, SetSheetsFilterCriteriaCommand as We, RemoveSheetFilterCommand as ze } from "@univerjs/sheets-filter";
|
|
8
|
-
import { SetRangeBoldCommand as He, SetRangeFontFamilyCommand as Je, SetRangeFontSizeCommand as Ge, SetRangeItalicCommand as Ze, SetRangeStrickThroughCommand as Ke, SetRangeSubscriptCommand as Ye, SetRangeSuperscriptCommand as qe, SetRangeTextColorCommand as Qe, SetRangeUnderlineCommand as Xe, SheetCopyCommand as et, SheetCutCommand as tt, SheetPasteBesidesBorderCommand as rt, SheetPasteColWidthCommand as nt, SheetPasteCommand as ot, SheetPasteFormatCommand as it, SheetPasteShortKeyCommand as ct, SheetPasteValueCommand as at } from "@univerjs/sheets-ui";
|
|
9
|
-
import { ILocalFileService as Y, IMessageService as x, RibbonOthersGroup as st, MenuItemType as y, useDependency as b, useObservable as F, IUIPartsService as dt, IMenuManagerService as lt, ComponentManager as mt, BuiltInUIPart as ut, connectInjector as ht } from "@univerjs/ui";
|
|
10
|
-
import { BehaviorSubject as I } from "rxjs";
|
|
11
|
-
import { MessageType as N, Button as U } from "@univerjs/design";
|
|
12
|
-
import { jsx as g, jsxs as B } from "react/jsx-runtime";
|
|
13
|
-
const gt = "@univerjs/action-recorder", ft = "0.17.0", V = {
|
|
14
|
-
name: gt,
|
|
15
|
-
version: ft
|
|
16
|
-
}, pt = "action-recorder.config", W = {};
|
|
17
|
-
function q({ ref: e, ...t }) {
|
|
18
|
-
const { icon: r, id: n, className: o, extend: i, ...c } = t, a = `univerjs-icon univerjs-icon-${n} ${o || ""}`.trim(), u = le(`_${Ct()}`);
|
|
19
|
-
return Q(r, `${n}`, {
|
|
20
|
-
defIds: r.defIds,
|
|
21
|
-
idSuffix: u.current
|
|
22
|
-
}, {
|
|
23
|
-
ref: e,
|
|
24
|
-
className: a,
|
|
25
|
-
...c
|
|
26
|
-
}, i);
|
|
27
|
-
}
|
|
28
|
-
function Q(e, t, r, n, o) {
|
|
29
|
-
return K(e.tag, {
|
|
30
|
-
key: t,
|
|
31
|
-
...St(e, r, o),
|
|
32
|
-
...n
|
|
33
|
-
}, (vt(e, r).children || []).map((i, c) => Q(i, `${t}-${e.tag}-${c}`, r, void 0, o)));
|
|
34
|
-
}
|
|
35
|
-
function St(e, t, r) {
|
|
36
|
-
const n = { ...e.attrs };
|
|
37
|
-
r != null && r.colorChannel1 && n.fill === "colorChannel1" && (n.fill = r.colorChannel1), e.tag === "mask" && n.id && (n.id = n.id + t.idSuffix), Object.entries(n).forEach(([i, c]) => {
|
|
38
|
-
i === "mask" && typeof c == "string" && (n[i] = c.replace(/url\(#(.*)\)/, `url(#$1${t.idSuffix})`));
|
|
39
|
-
});
|
|
40
|
-
const { defIds: o } = t;
|
|
41
|
-
return !o || o.length === 0 || (e.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + t.idSuffix), Object.entries(n).forEach(([i, c]) => {
|
|
42
|
-
typeof c == "string" && (n[i] = c.replace(/url\(#(.*)\)/, `url(#$1${t.idSuffix})`));
|
|
43
|
-
})), n;
|
|
44
|
-
}
|
|
45
|
-
function vt(e, t) {
|
|
46
|
-
var n;
|
|
47
|
-
const { defIds: r } = t;
|
|
48
|
-
return !r || r.length === 0 ? e : e.tag === "defs" && ((n = e.children) != null && n.length) ? {
|
|
49
|
-
...e,
|
|
50
|
-
children: e.children.map((o) => typeof o.attrs.id == "string" && r && r.includes(o.attrs.id) ? {
|
|
51
|
-
...o,
|
|
52
|
-
attrs: {
|
|
53
|
-
...o.attrs,
|
|
54
|
-
id: o.attrs.id + t.idSuffix
|
|
55
|
-
}
|
|
56
|
-
} : o)
|
|
57
|
-
} : e;
|
|
58
|
-
}
|
|
59
|
-
function Ct() {
|
|
60
|
-
return Math.random().toString(36).substring(2, 8);
|
|
61
|
-
}
|
|
62
|
-
q.displayName = "UniverIcon";
|
|
63
|
-
const _t = {
|
|
64
|
-
tag: "svg",
|
|
65
|
-
attrs: {
|
|
66
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
67
|
-
fill: "none",
|
|
68
|
-
viewBox: "0 0 17 16",
|
|
69
|
-
width: "1em",
|
|
70
|
-
height: "1em"
|
|
71
|
-
},
|
|
72
|
-
children: [{
|
|
73
|
-
tag: "g",
|
|
74
|
-
attrs: {
|
|
75
|
-
fill: "currentColor",
|
|
76
|
-
clipPath: "url(#record-icon_clip0_1559_19)"
|
|
77
|
-
},
|
|
78
|
-
children: [{
|
|
79
|
-
tag: "path",
|
|
80
|
-
attrs: { d: "M7.60303 10C8.7076 10 9.60303 9.10457 9.60303 8C9.60303 6.89543 8.7076 6 7.60303 6C6.49846 6 5.60303 6.89543 5.60303 8C5.60303 9.10457 6.49846 10 7.60303 10Z" }
|
|
81
|
-
}, {
|
|
82
|
-
tag: "path",
|
|
83
|
-
attrs: {
|
|
84
|
-
d: "M1.66943 5.29023C1.66941 3.85426 2.83349 2.69017 4.26946 2.69019L10.9362 2.69026C12.3192 2.69028 13.45 3.77008 13.5315 5.13259L14.5692 4.55638C15.3024 4.14929 16.2032 4.67947 16.2032 5.51809V10.4819C16.2032 11.3205 15.3024 11.8507 14.5692 11.4436L13.5315 10.8674C13.45 12.2299 12.3192 13.3097 10.9362 13.3097H4.26953C2.83361 13.3097 1.66956 12.1457 1.66953 10.7098L1.66943 5.29023ZM13.5362 9.49743L15.0032 10.312V5.68799L13.5362 6.50254V9.49743ZM4.26945 3.89019C3.49623 3.89018 2.86942 4.517 2.86943 5.29021L2.86953 10.7098C2.86955 11.483 3.49634 12.1097 4.26953 12.1097H10.9362C11.7094 12.1097 12.3362 11.4829 12.3362 10.7097V5.29026C12.3362 4.51707 11.7094 3.89027 10.9362 3.89026L4.26945 3.89019Z",
|
|
85
|
-
fillRule: "evenodd",
|
|
86
|
-
clipRule: "evenodd"
|
|
87
|
-
}
|
|
88
|
-
}]
|
|
89
|
-
}, {
|
|
90
|
-
tag: "defs",
|
|
91
|
-
attrs: {},
|
|
92
|
-
children: [{
|
|
93
|
-
tag: "clipPath",
|
|
94
|
-
attrs: { id: "record-icon_clip0_1559_19" },
|
|
95
|
-
children: [{
|
|
96
|
-
tag: "path",
|
|
97
|
-
attrs: {
|
|
98
|
-
fill: "white",
|
|
99
|
-
d: "M0 0H16V16H0z",
|
|
100
|
-
transform: "translate(.94)"
|
|
101
|
-
}
|
|
102
|
-
}]
|
|
103
|
-
}]
|
|
104
|
-
}],
|
|
105
|
-
defIds: ["record-icon_clip0_1559_19"]
|
|
106
|
-
}, T = me(function(t, r) {
|
|
107
|
-
return K(q, Object.assign({}, t, {
|
|
108
|
-
id: "record-icon",
|
|
109
|
-
ref: r,
|
|
110
|
-
icon: _t
|
|
111
|
-
}));
|
|
112
|
-
});
|
|
113
|
-
T.displayName = "RecordIcon";
|
|
114
|
-
var yt = Object.getOwnPropertyDescriptor, Rt = (e, t, r, n) => {
|
|
115
|
-
for (var o = n > 1 ? void 0 : n ? yt(t, r) : t, i = e.length - 1, c; i >= 0; i--)
|
|
116
|
-
(c = e[i]) && (o = c(o) || o);
|
|
117
|
-
return o;
|
|
118
|
-
}, O = (e, t) => (r, n) => t(r, n, e);
|
|
119
|
-
let l = class extends P {
|
|
120
|
-
constructor(t, r, n, o) {
|
|
121
|
-
super();
|
|
122
|
-
d(this, "_shouldRecordCommands", /* @__PURE__ */ new Set());
|
|
123
|
-
d(this, "_panelOpened$", new I(!1));
|
|
124
|
-
d(this, "panelOpened$", this._panelOpened$.asObservable());
|
|
125
|
-
d(this, "_recorder", null);
|
|
126
|
-
d(this, "_recording$", new I(!1));
|
|
127
|
-
d(this, "recording$", this._recording$.asObservable());
|
|
128
|
-
d(this, "_recorded$", new I([]));
|
|
129
|
-
d(this, "_recordedCommands$", new I([]));
|
|
130
|
-
d(this, "recordedCommands$", this._recordedCommands$.asObservable());
|
|
131
|
-
this._commandSrv = t, this._logService = r, this._localFileService = n, this._instanceService = o;
|
|
132
|
-
}
|
|
133
|
-
get recording() {
|
|
134
|
-
return this._recording$.getValue();
|
|
135
|
-
}
|
|
136
|
-
get _recorded() {
|
|
137
|
-
return this._recorded$.getValue();
|
|
138
|
-
}
|
|
139
|
-
get _recordedCommands() {
|
|
140
|
-
return this._recordedCommands$.getValue();
|
|
141
|
-
}
|
|
142
|
-
registerRecordedCommand(t) {
|
|
143
|
-
if (t.type === m.MUTATION) throw new Error("[CommandRecorderService] Cannot record mutation commands.");
|
|
144
|
-
this._shouldRecordCommands.add(t.id);
|
|
145
|
-
}
|
|
146
|
-
togglePanel(t) {
|
|
147
|
-
this._panelOpened$.next(t), t === !1 && this.stopRecording();
|
|
148
|
-
}
|
|
149
|
-
startRecording(t = !1) {
|
|
150
|
-
this._recorder = this._commandSrv.onCommandExecuted((r) => {
|
|
151
|
-
var n, o;
|
|
152
|
-
if (this._shouldRecordCommands.has(r.id)) {
|
|
153
|
-
const i = this._recorded, c = this._recordedCommands;
|
|
154
|
-
let a = { ...r };
|
|
155
|
-
const u = (n = this._instanceService.getFocusedUnit()) == null ? void 0 : n.getUnitId(), { unitId: h = u, subUnitId: s } = a == null ? void 0 : a.params;
|
|
156
|
-
if (t && h && s) {
|
|
157
|
-
const S = (o = this._instanceService.getUnit(h).getSheetBySheetId(s)) == null ? void 0 : o.getName();
|
|
158
|
-
a = {
|
|
159
|
-
...a,
|
|
160
|
-
params: {
|
|
161
|
-
...a.params,
|
|
162
|
-
subUnitId: S
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
a.id === A.id && i.length > 0 && i[i.length - 1].id === A.id ? i[i.length - 1] = a : (i.push(a), this._recorded$.next(i), a.type === m.COMMAND && (c.push(a), this._recordedCommands$.next(c)));
|
|
167
|
-
}
|
|
168
|
-
}), this._recording$.next(!0);
|
|
169
|
-
}
|
|
170
|
-
stopRecording() {
|
|
171
|
-
var t;
|
|
172
|
-
(t = this._recorder) == null || t.dispose(), this._recorder = null, this._recorded$.next([]), this._recordedCommands$.next([]), this._recording$.next(!1);
|
|
173
|
-
}
|
|
174
|
-
completeRecording() {
|
|
175
|
-
const t = this._recorded.slice();
|
|
176
|
-
this._localFileService.downloadFile(new Blob([JSON.stringify(t, null, 2)]), "recorded-commands.json"), this._logService.error("Recorded commands:", t), this.stopRecording();
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
l = Rt([
|
|
180
|
-
O(0, $),
|
|
181
|
-
O(1, J),
|
|
182
|
-
O(2, Y),
|
|
183
|
-
O(3, G)
|
|
184
|
-
], l);
|
|
185
|
-
const X = {
|
|
186
|
-
id: "action-recorder.command.start-recording",
|
|
187
|
-
type: m.COMMAND,
|
|
188
|
-
handler: (e, t) => (e.get(l).startRecording(!!(t != null && t.replaceId)), !0)
|
|
189
|
-
}, ee = {
|
|
190
|
-
id: "action-recorder.command.complete-recording",
|
|
191
|
-
type: m.COMMAND,
|
|
192
|
-
handler: (e) => (e.get(l).completeRecording(), !0)
|
|
193
|
-
}, te = {
|
|
194
|
-
id: "action-recorder.command.stop-recording",
|
|
195
|
-
type: m.COMMAND,
|
|
196
|
-
handler: (e) => (e.get(l).completeRecording(), !0)
|
|
197
|
-
};
|
|
198
|
-
var It = Object.getOwnPropertyDescriptor, Ot = (e, t, r, n) => {
|
|
199
|
-
for (var o = n > 1 ? void 0 : n ? It(t, r) : t, i = e.length - 1, c; i >= 0; i--)
|
|
200
|
-
(c = e[i]) && (o = c(o) || o);
|
|
201
|
-
return o;
|
|
202
|
-
}, C = (e, t) => (r, n) => t(r, n, e), D = /* @__PURE__ */ ((e) => (e.DEFAULT = "default", e.NAME = "name", e.ACTIVE = "active", e))(D || {});
|
|
203
|
-
let f = class extends P {
|
|
204
|
-
constructor(e, t, r, n, o) {
|
|
205
|
-
super(), this._messageService = e, this._instanceService = t, this._localFileService = r, this._logService = n, this._commandService = o;
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Read a local file and try to replay commands in this JSON.
|
|
209
|
-
*/
|
|
210
|
-
async replayLocalJSON(e = "default") {
|
|
211
|
-
const t = await this._localFileService.openFile({ multiple: !1, accept: ".json" });
|
|
212
|
-
if (t.length !== 1) return !1;
|
|
213
|
-
const r = t[0];
|
|
214
|
-
try {
|
|
215
|
-
return this.replayCommands(JSON.parse(await r.text()), { mode: e });
|
|
216
|
-
} catch {
|
|
217
|
-
return this._messageService.show({
|
|
218
|
-
type: N.Error,
|
|
219
|
-
content: `Failed to replay commands from local file ${r.name}.`
|
|
220
|
-
}), !1;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Replay a list of commands. Note that `unitId` of these commands would be changed to the focused unit.
|
|
225
|
-
* @param commands - The commands to replay.
|
|
226
|
-
* @returns If the replay is successful.
|
|
227
|
-
*/
|
|
228
|
-
async replayCommands(e, t) {
|
|
229
|
-
var o, i, c;
|
|
230
|
-
const r = (o = this._instanceService.getFocusedUnit()) == null ? void 0 : o.getUnitId();
|
|
231
|
-
r || this._logService.error("[ReplayService]", "no focused unit to replay commands");
|
|
232
|
-
const { mode: n } = t || {};
|
|
233
|
-
for (const a of e) {
|
|
234
|
-
const { id: u, params: h } = a, s = h;
|
|
235
|
-
if (s) {
|
|
236
|
-
if (typeof s.unitId < "u" && (s.unitId = r), n === "name" && s.subUnitId !== "undefined") {
|
|
237
|
-
const v = (i = this._instanceService.getFocusedUnit().getSheetBySheetName(s.subUnitId)) == null ? void 0 : i.getSheetId();
|
|
238
|
-
v ? s.subUnitId = v : this._logService.error("[ReplayService]", `failed to find subunit by subUnitName = ${s.subUnitId}`);
|
|
239
|
-
}
|
|
240
|
-
if (n === "active" && s.subUnitId !== "undefined") {
|
|
241
|
-
const v = (c = this._instanceService.getFocusedUnit().getActiveSheet()) == null ? void 0 : c.getSheetId();
|
|
242
|
-
v ? s.subUnitId = v : this._logService.error("[ReplayService]", "failed to find active subunit");
|
|
243
|
-
}
|
|
244
|
-
if (!await this._commandService.executeCommand(u, h)) return !1;
|
|
245
|
-
} else if (!await this._commandService.executeCommand(u)) return !1;
|
|
246
|
-
}
|
|
247
|
-
return !0;
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Replay a list of commands with a random delay between each command.
|
|
251
|
-
* @param commands - The commands to replay.
|
|
252
|
-
*/
|
|
253
|
-
async replayCommandsWithDelay(e) {
|
|
254
|
-
var r;
|
|
255
|
-
const t = (r = this._instanceService.getFocusedUnit()) == null ? void 0 : r.getUnitId();
|
|
256
|
-
t || this._logService.error("[ReplayService]", "no focused unit to replay commands");
|
|
257
|
-
for (const n of e) {
|
|
258
|
-
await ce(wt());
|
|
259
|
-
const { id: o, params: i } = n;
|
|
260
|
-
if (i) {
|
|
261
|
-
if (typeof i.unitId < "u" && (i.unitId = t), !await this._commandService.executeCommand(o, i)) return !1;
|
|
262
|
-
} else if (!await this._commandService.executeCommand(o)) return !1;
|
|
263
|
-
}
|
|
264
|
-
return !0;
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
f = Ot([
|
|
268
|
-
C(0, x),
|
|
269
|
-
C(1, G),
|
|
270
|
-
C(2, Y),
|
|
271
|
-
C(3, J),
|
|
272
|
-
C(4, $)
|
|
273
|
-
], f);
|
|
274
|
-
function wt() {
|
|
275
|
-
return Math.floor(Math.random() * 800) + 200;
|
|
276
|
-
}
|
|
277
|
-
const E = {
|
|
278
|
-
id: "action-recorder.command.replay-local-records",
|
|
279
|
-
type: m.COMMAND,
|
|
280
|
-
handler: async (e) => {
|
|
281
|
-
const r = await e.get(f).replayLocalJSON();
|
|
282
|
-
return r && e.get(x).show({
|
|
283
|
-
type: N.Success,
|
|
284
|
-
content: "Successfully replayed local records"
|
|
285
|
-
}), r;
|
|
286
|
-
}
|
|
287
|
-
}, L = {
|
|
288
|
-
id: "action-recorder.command.replay-local-records-name",
|
|
289
|
-
type: m.COMMAND,
|
|
290
|
-
handler: async (e) => {
|
|
291
|
-
const r = await e.get(f).replayLocalJSON(D.NAME);
|
|
292
|
-
return r && e.get(x).show({
|
|
293
|
-
type: N.Success,
|
|
294
|
-
content: "Successfully replayed local records"
|
|
295
|
-
}), r;
|
|
296
|
-
}
|
|
297
|
-
}, j = {
|
|
298
|
-
id: "action-recorder.command.replay-local-records-active",
|
|
299
|
-
type: m.COMMAND,
|
|
300
|
-
handler: async (e) => {
|
|
301
|
-
const r = await e.get(f).replayLocalJSON(D.ACTIVE);
|
|
302
|
-
return r && e.get(x).show({
|
|
303
|
-
type: N.Success,
|
|
304
|
-
content: "Successfully replayed local records"
|
|
305
|
-
}), r;
|
|
306
|
-
}
|
|
307
|
-
}, k = {
|
|
308
|
-
id: "action-recorder.operation.open-panel",
|
|
309
|
-
type: m.OPERATION,
|
|
310
|
-
handler(e) {
|
|
311
|
-
return e.get(l).togglePanel(!0), !0;
|
|
312
|
-
}
|
|
313
|
-
}, re = {
|
|
314
|
-
id: "action-recorder.operation.close-panel",
|
|
315
|
-
type: m.OPERATION,
|
|
316
|
-
handler(e) {
|
|
317
|
-
return e.get(l).togglePanel(!1), !0;
|
|
318
|
-
}
|
|
319
|
-
}, ne = "RECORD_MENU_ITEM";
|
|
320
|
-
function Mt() {
|
|
321
|
-
return {
|
|
322
|
-
id: ne,
|
|
323
|
-
type: y.SUBITEMS,
|
|
324
|
-
icon: "RecordIcon",
|
|
325
|
-
tooltip: "action-recorder.menu.title"
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
function $t(e) {
|
|
329
|
-
const t = e.get(l);
|
|
330
|
-
return {
|
|
331
|
-
id: k.id,
|
|
332
|
-
title: "action-recorder.menu.record",
|
|
333
|
-
type: y.BUTTON,
|
|
334
|
-
disabled$: t.panelOpened$
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
function xt() {
|
|
338
|
-
return {
|
|
339
|
-
id: E.id,
|
|
340
|
-
title: "action-recorder.menu.replay-local",
|
|
341
|
-
type: y.BUTTON
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
function Nt() {
|
|
345
|
-
return {
|
|
346
|
-
id: L.id,
|
|
347
|
-
title: "action-recorder.menu.replay-local-name",
|
|
348
|
-
type: y.BUTTON
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
|
-
function Ut() {
|
|
352
|
-
return {
|
|
353
|
-
id: j.id,
|
|
354
|
-
title: "action-recorder.menu.replay-local-active",
|
|
355
|
-
type: y.BUTTON
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
const At = {
|
|
359
|
-
[st.OTHERS]: {
|
|
360
|
-
[ne]: {
|
|
361
|
-
order: 1,
|
|
362
|
-
menuItemFactory: Mt,
|
|
363
|
-
[k.id]: {
|
|
364
|
-
order: 1,
|
|
365
|
-
menuItemFactory: $t
|
|
366
|
-
},
|
|
367
|
-
[E.id]: {
|
|
368
|
-
order: 2,
|
|
369
|
-
menuItemFactory: xt
|
|
370
|
-
},
|
|
371
|
-
[L.id]: {
|
|
372
|
-
order: 3,
|
|
373
|
-
menuItemFactory: Nt
|
|
374
|
-
},
|
|
375
|
-
[j.id]: {
|
|
376
|
-
order: 4,
|
|
377
|
-
menuItemFactory: Ut
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
};
|
|
382
|
-
function bt() {
|
|
383
|
-
const e = b(l);
|
|
384
|
-
return F(e.panelOpened$) ? /* @__PURE__ */ g(Ft, {}) : null;
|
|
385
|
-
}
|
|
386
|
-
function Ft() {
|
|
387
|
-
var s;
|
|
388
|
-
const e = b($), t = b(l), r = F(t.recording$), n = F(t.recordedCommands$), o = (s = n == null ? void 0 : n.length) != null ? s : 0, i = R(() => {
|
|
389
|
-
r || e.executeCommand(re.id);
|
|
390
|
-
}, [e, r]), c = R((S) => {
|
|
391
|
-
r || e.executeCommand(X.id, { replaceId: S });
|
|
392
|
-
}, [e, r]), a = R(() => {
|
|
393
|
-
r && e.executeCommand(ee.id);
|
|
394
|
-
}, [e, r]), u = R(() => {
|
|
395
|
-
r && e.executeCommand(te.id);
|
|
396
|
-
}, [e, r]), h = r ? o === 0 ? "Recording..." : `${o}: ${n[o - 1].id}` : "Start Recording";
|
|
397
|
-
return /* @__PURE__ */ B(
|
|
398
|
-
"div",
|
|
399
|
-
{
|
|
400
|
-
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",
|
|
401
|
-
children: [
|
|
402
|
-
/* @__PURE__ */ g("div", { className: "univer-mr-2 univer-size-5 univer-shrink-0 univer-grow-0 univer-text-xl", children: /* @__PURE__ */ g(T, {}) }),
|
|
403
|
-
/* @__PURE__ */ g("div", { className: "univer-flex-1 univer-text-sm", children: h }),
|
|
404
|
-
/* @__PURE__ */ B("div", { className: "univer-flex univer-w-64 univer-shrink-0 univer-grow-0 univer-justify-between", children: [
|
|
405
|
-
/* @__PURE__ */ g(
|
|
406
|
-
U,
|
|
407
|
-
{
|
|
408
|
-
className: "univer-w-20",
|
|
409
|
-
onClick: r ? u : i,
|
|
410
|
-
children: r ? "Cancel" : "Close"
|
|
411
|
-
}
|
|
412
|
-
),
|
|
413
|
-
/* @__PURE__ */ g(
|
|
414
|
-
U,
|
|
415
|
-
{
|
|
416
|
-
className: "univer-w-20",
|
|
417
|
-
variant: "primary",
|
|
418
|
-
onClick: r ? a : () => c(),
|
|
419
|
-
children: r ? "Save" : "Start"
|
|
420
|
-
}
|
|
421
|
-
),
|
|
422
|
-
!r && /* @__PURE__ */ g(U, { variant: "primary", onClick: () => c(!0), children: "Start(N)" })
|
|
423
|
-
] })
|
|
424
|
-
]
|
|
425
|
-
}
|
|
426
|
-
);
|
|
427
|
-
}
|
|
428
|
-
var Pt = Object.getOwnPropertyDescriptor, Tt = (e, t, r, n) => {
|
|
429
|
-
for (var o = n > 1 ? void 0 : n ? Pt(t, r) : t, i = e.length - 1, c; i >= 0; i--)
|
|
430
|
-
(c = e[i]) && (o = c(o) || o);
|
|
431
|
-
return o;
|
|
432
|
-
}, p = (e, t) => (r, n) => t(r, n, e);
|
|
433
|
-
let M = class extends P {
|
|
434
|
-
constructor(e, t, r, n, o, i) {
|
|
435
|
-
super(), this._commandSrv = e, this._uiPartsSrv = t, this._menuManagerService = r, this._componentManager = n, this._actionRecorderService = o, this._injector = i, this._initCommands(), this._initUI(), this._initSheetsCommands(), this._initDocsCommands();
|
|
436
|
-
}
|
|
437
|
-
_initCommands() {
|
|
438
|
-
[
|
|
439
|
-
X,
|
|
440
|
-
te,
|
|
441
|
-
ee,
|
|
442
|
-
k,
|
|
443
|
-
re,
|
|
444
|
-
E,
|
|
445
|
-
L,
|
|
446
|
-
j
|
|
447
|
-
].forEach((e) => this._commandSrv.registerCommand(e));
|
|
448
|
-
}
|
|
449
|
-
_initUI() {
|
|
450
|
-
this._uiPartsSrv.registerComponent(ut.GLOBAL, () => ht(bt, this._injector)), this.disposeWithMe(
|
|
451
|
-
this._componentManager.register("RecordIcon", T)
|
|
452
|
-
), this._menuManagerService.mergeMenu(At);
|
|
453
|
-
}
|
|
454
|
-
_initSheetsCommands() {
|
|
455
|
-
[
|
|
456
|
-
// InsertColCommand,
|
|
457
|
-
// InsertRowCommand,
|
|
458
|
-
// #region basic commands
|
|
459
|
-
ue,
|
|
460
|
-
he,
|
|
461
|
-
ge,
|
|
462
|
-
fe,
|
|
463
|
-
pe,
|
|
464
|
-
Se,
|
|
465
|
-
ve,
|
|
466
|
-
Ce,
|
|
467
|
-
_e,
|
|
468
|
-
ye,
|
|
469
|
-
Re,
|
|
470
|
-
Ie,
|
|
471
|
-
Oe,
|
|
472
|
-
we,
|
|
473
|
-
Me,
|
|
474
|
-
$e,
|
|
475
|
-
// ResetBackgroundColorCommand,
|
|
476
|
-
// ResetTextColorCommand,
|
|
477
|
-
// SetBackgroundColorCommand,
|
|
478
|
-
// SetBoldCommand,
|
|
479
|
-
// SetFontFamilyCommand,
|
|
480
|
-
// SetFontSizeCommand,
|
|
481
|
-
xe,
|
|
482
|
-
Ne,
|
|
483
|
-
Ue,
|
|
484
|
-
// SetItalicCommand,
|
|
485
|
-
Ae,
|
|
486
|
-
He,
|
|
487
|
-
Je,
|
|
488
|
-
Ge,
|
|
489
|
-
Ze,
|
|
490
|
-
Ke,
|
|
491
|
-
Ye,
|
|
492
|
-
qe,
|
|
493
|
-
Qe,
|
|
494
|
-
Xe,
|
|
495
|
-
be,
|
|
496
|
-
Fe,
|
|
497
|
-
Pe,
|
|
498
|
-
Te,
|
|
499
|
-
De,
|
|
500
|
-
// SetUnderlineCommand,
|
|
501
|
-
Ee,
|
|
502
|
-
et,
|
|
503
|
-
tt,
|
|
504
|
-
rt,
|
|
505
|
-
nt,
|
|
506
|
-
ot,
|
|
507
|
-
it,
|
|
508
|
-
ct,
|
|
509
|
-
at,
|
|
510
|
-
Le,
|
|
511
|
-
je,
|
|
512
|
-
ke,
|
|
513
|
-
Be,
|
|
514
|
-
A,
|
|
515
|
-
// #endregion
|
|
516
|
-
// #region data validation command
|
|
517
|
-
// #endregion
|
|
518
|
-
// #region conditional formatting command
|
|
519
|
-
// #endregion
|
|
520
|
-
// #region filter command
|
|
521
|
-
Ve,
|
|
522
|
-
We,
|
|
523
|
-
ze
|
|
524
|
-
// #endregion
|
|
525
|
-
].forEach((e) => this._actionRecorderService.registerRecordedCommand(e));
|
|
526
|
-
}
|
|
527
|
-
_initDocsCommands() {
|
|
528
|
-
}
|
|
529
|
-
};
|
|
530
|
-
M = Tt([
|
|
531
|
-
p(0, $),
|
|
532
|
-
p(1, dt),
|
|
533
|
-
p(2, lt),
|
|
534
|
-
p(3, w(mt)),
|
|
535
|
-
p(4, w(l)),
|
|
536
|
-
p(5, w(Z))
|
|
537
|
-
], M);
|
|
538
|
-
var Dt = Object.getOwnPropertyDescriptor, Et = (e, t, r, n) => {
|
|
539
|
-
for (var o = n > 1 ? void 0 : n ? Dt(t, r) : t, i = e.length - 1, c; i >= 0; i--)
|
|
540
|
-
(c = e[i]) && (o = c(o) || o);
|
|
541
|
-
return o;
|
|
542
|
-
}, z = (e, t) => (r, n) => t(r, n, e), _;
|
|
543
|
-
let H = (_ = class extends se {
|
|
544
|
-
constructor(e = W, t, r) {
|
|
545
|
-
super(), this._config = e, this._injector = t, this._configService = r;
|
|
546
|
-
const { menu: n, ...o } = de(
|
|
547
|
-
{},
|
|
548
|
-
W,
|
|
549
|
-
this._config
|
|
550
|
-
);
|
|
551
|
-
n && this._configService.setConfig("menu", n, { merge: !0 }), this._configService.setConfig(pt, o);
|
|
552
|
-
}
|
|
553
|
-
onStarting() {
|
|
554
|
-
(this._config.replayOnly ? [[f]] : [
|
|
555
|
-
[l],
|
|
556
|
-
[f],
|
|
557
|
-
[M]
|
|
558
|
-
]).forEach((t) => this._injector.add(t));
|
|
559
|
-
}
|
|
560
|
-
onSteady() {
|
|
561
|
-
this._config.replayOnly || this._injector.get(M);
|
|
562
|
-
}
|
|
563
|
-
}, d(_, "pluginName", "UNIVER_ACTION_RECORDER_PLUGIN"), d(_, "packageName", V.name), d(_, "version", V.version), _);
|
|
564
|
-
H = Et([
|
|
565
|
-
z(1, w(Z)),
|
|
566
|
-
z(2, ae)
|
|
567
|
-
], H);
|
|
568
|
-
export {
|
|
569
|
-
l as ActionRecorderService,
|
|
570
|
-
f as ActionReplayService,
|
|
571
|
-
H as UniverActionRecorderPlugin
|
|
572
|
-
};
|
|
1
|
+
import{CommandType as e,Disposable as t,ICommandService as n,IConfigService as r,ILogService as i,IUniverInstanceService as a,Inject as o,Injector as s,Plugin as c,awaitTime as l,merge as u}from"@univerjs/core";import{RecordIcon as d}from"@univerjs/icons";import{AddWorksheetMergeAllCommand as f,AddWorksheetMergeCommand as ee,AddWorksheetMergeHorizontalCommand as te,AddWorksheetMergeVerticalCommand as ne,AutoFillCommand as re,CancelFrozenCommand as p,CopySheetCommand as ie,DeleteRangeMoveLeftCommand as ae,DeleteRangeMoveUpCommand as oe,DeltaColumnWidthCommand as se,DeltaRowHeightCommand as ce,InsertColAfterCommand as le,InsertColBeforeCommand as ue,InsertRowAfterCommand as de,InsertRowBeforeCommand as fe,InsertSheetCommand as pe,RefillCommand as me,RemoveSheetCommand as he,SetFrozenCommand as ge,SetHorizontalTextAlignCommand as _e,SetOverlineCommand as ve,SetRangeValuesCommand as ye,SetSelectionsOperation as m,SetStrikeThroughCommand as be,SetStyleCommand as xe,SetTextColorCommand as Se,SetTextRotationCommand as Ce,SetTextWrapCommand as we,SetVerticalTextAlignCommand as Te,SetWorksheetActivateCommand as Ee,SetWorksheetActiveOperation as De}from"@univerjs/sheets";import{RemoveSheetFilterCommand as Oe,SetSheetFilterRangeCommand as ke,SetSheetsFilterCriteriaCommand as Ae}from"@univerjs/sheets-filter";import{SetRangeBoldCommand as je,SetRangeFontFamilyCommand as h,SetRangeFontSizeCommand as g,SetRangeItalicCommand as _,SetRangeStrickThroughCommand as v,SetRangeSubscriptCommand as y,SetRangeSuperscriptCommand as b,SetRangeTextColorCommand as x,SetRangeUnderlineCommand as S,SheetCopyCommand as Me,SheetCutCommand as Ne,SheetPasteBesidesBorderCommand as Pe,SheetPasteColWidthCommand as Fe,SheetPasteCommand as Ie,SheetPasteFormatCommand as Le,SheetPasteShortKeyCommand as Re,SheetPasteValueCommand as ze}from"@univerjs/sheets-ui";import{BuiltInUIPart as Be,ComponentManager as Ve,ILocalFileService as C,IMenuManagerService as He,IMessageService as w,IUIPartsService as Ue,MenuItemType as T,RibbonOthersGroup as We,connectInjector as Ge,useDependency as E,useObservable as D}from"@univerjs/ui";import{BehaviorSubject as O}from"rxjs";import{Button as k,MessageType as A}from"@univerjs/design";import{useCallback as j}from"react";import{jsx as M,jsxs as N}from"react/jsx-runtime";var Ke=`@univerjs/action-recorder`,qe=`0.18.0`;const P=`action-recorder.config`;Symbol(P);const F={};function I(e){"@babel/helpers - typeof";return I=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},I(e)}function Je(e,t){if(I(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(I(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ye(e){var t=Je(e,`string`);return I(t)==`symbol`?t:t+``}function L(e,t,n){return(t=Ye(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function R(e,t){return function(n,r){t(n,r,e)}}function z(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let B=class extends t{get recording(){return this._recording$.getValue()}get _recorded(){return this._recorded$.getValue()}get _recordedCommands(){return this._recordedCommands$.getValue()}constructor(e,t,n,r){super(),this._commandSrv=e,this._logService=t,this._localFileService=n,this._instanceService=r,L(this,`_shouldRecordCommands`,new Set),L(this,`_panelOpened$`,new O(!1)),L(this,`panelOpened$`,this._panelOpened$.asObservable()),L(this,`_recorder`,null),L(this,`_recording$`,new O(!1)),L(this,`recording$`,this._recording$.asObservable()),L(this,`_recorded$`,new O([])),L(this,`_recordedCommands$`,new O([])),L(this,`recordedCommands$`,this._recordedCommands$.asObservable())}registerRecordedCommand(t){if(t.type===e.MUTATION)throw Error(`[CommandRecorderService] Cannot record mutation commands.`);this._shouldRecordCommands.add(t.id)}togglePanel(e){this._panelOpened$.next(e),e===!1&&this.stopRecording()}startRecording(t=!1){this._recorder=this._commandSrv.onCommandExecuted(n=>{if(this._shouldRecordCommands.has(n.id)){var r;let a=this._recorded,o=this._recordedCommands,s={...n},c=(r=this._instanceService.getFocusedUnit())==null?void 0:r.getUnitId(),{unitId:l=c,subUnitId:u}=s==null?void 0:s.params;if(t&&l&&u){var i;let e=(i=this._instanceService.getUnit(l).getSheetBySheetId(u))==null?void 0:i.getName();s={...s,params:{...s.params,subUnitId:e}}}s.id===m.id&&a.length>0&&a[a.length-1].id===m.id?a[a.length-1]=s:(a.push(s),this._recorded$.next(a),s.type===e.COMMAND&&(o.push(s),this._recordedCommands$.next(o)))}}),this._recording$.next(!0)}stopRecording(){var e;(e=this._recorder)==null||e.dispose(),this._recorder=null,this._recorded$.next([]),this._recordedCommands$.next([]),this._recording$.next(!1)}completeRecording(){let e=this._recorded.slice();this._localFileService.downloadFile(new Blob([JSON.stringify(e,null,2)]),`recorded-commands.json`),this._logService.error(`Recorded commands:`,e),this.stopRecording()}};B=z([R(0,n),R(1,i),R(2,C),R(3,a)],B);const V={id:`action-recorder.command.start-recording`,type:e.COMMAND,handler:(e,t)=>(e.get(B).startRecording(!!(t!=null&&t.replaceId)),!0)},H={id:`action-recorder.command.complete-recording`,type:e.COMMAND,handler:e=>(e.get(B).completeRecording(),!0)},U={id:`action-recorder.command.stop-recording`,type:e.COMMAND,handler:e=>(e.get(B).completeRecording(),!0)};let W=function(e){return e.DEFAULT=`default`,e.NAME=`name`,e.ACTIVE=`active`,e}({}),G=class extends t{constructor(e,t,n,r,i){super(),this._messageService=e,this._instanceService=t,this._localFileService=n,this._logService=r,this._commandService=i}async replayLocalJSON(e=W.DEFAULT){let t=await this._localFileService.openFile({multiple:!1,accept:`.json`});if(t.length!==1)return!1;let n=t[0];try{return this.replayCommands(JSON.parse(await n.text()),{mode:e})}catch{return this._messageService.show({type:A.Error,content:`Failed to replay commands from local file ${n.name}.`}),!1}}async replayCommands(e,t){var n;let r=(n=this._instanceService.getFocusedUnit())==null?void 0:n.getUnitId();r||this._logService.error(`[ReplayService]`,`no focused unit to replay commands`);let{mode:i}=t||{};for(let t of e){let{id:e,params:n}=t,s=n;if(s){if(s.unitId!==void 0&&(s.unitId=r),i===W.NAME&&s.subUnitId!==`undefined`){var a;let e=(a=this._instanceService.getFocusedUnit().getSheetBySheetName(s.subUnitId))==null?void 0:a.getSheetId();e?s.subUnitId=e:this._logService.error(`[ReplayService]`,`failed to find subunit by subUnitName = ${s.subUnitId}`)}if(i===W.ACTIVE&&s.subUnitId!==`undefined`){var o;let e=(o=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:o.getSheetId();e?s.subUnitId=e:this._logService.error(`[ReplayService]`,`failed to find active subunit`)}if(!await this._commandService.executeCommand(e,n))return!1}else if(!await this._commandService.executeCommand(e))return!1}return!0}async replayCommandsWithDelay(e){var t;let n=(t=this._instanceService.getFocusedUnit())==null?void 0:t.getUnitId();n||this._logService.error(`[ReplayService]`,`no focused unit to replay commands`);for(let t of e){await l(Xe());let{id:e,params:r}=t;if(r){if(r.unitId!==void 0&&(r.unitId=n),!await this._commandService.executeCommand(e,r))return!1}else if(!await this._commandService.executeCommand(e))return!1}return!0}};G=z([R(0,w),R(1,a),R(2,C),R(3,i),R(4,n)],G);function Xe(){return Math.floor(Math.random()*800)+200}const K={id:`action-recorder.command.replay-local-records`,type:e.COMMAND,handler:async e=>{let t=await e.get(G).replayLocalJSON();return t&&e.get(w).show({type:A.Success,content:`Successfully replayed local records`}),t}},q={id:`action-recorder.command.replay-local-records-name`,type:e.COMMAND,handler:async e=>{let t=await e.get(G).replayLocalJSON(W.NAME);return t&&e.get(w).show({type:A.Success,content:`Successfully replayed local records`}),t}},J={id:`action-recorder.command.replay-local-records-active`,type:e.COMMAND,handler:async e=>{let t=await e.get(G).replayLocalJSON(W.ACTIVE);return t&&e.get(w).show({type:A.Success,content:`Successfully replayed local records`}),t}},Y={id:`action-recorder.operation.open-panel`,type:e.OPERATION,handler(e){return e.get(B).togglePanel(!0),!0}},X={id:`action-recorder.operation.close-panel`,type:e.OPERATION,handler(e){return e.get(B).togglePanel(!1),!0}},Z=`RECORD_MENU_ITEM`;function Ze(){return{id:Z,type:T.SUBITEMS,icon:`RecordIcon`,tooltip:`action-recorder.menu.title`}}function Qe(e){let t=e.get(B);return{id:Y.id,title:`action-recorder.menu.record`,type:T.BUTTON,disabled$:t.panelOpened$}}function $e(){return{id:K.id,title:`action-recorder.menu.replay-local`,type:T.BUTTON}}function et(){return{id:q.id,title:`action-recorder.menu.replay-local-name`,type:T.BUTTON}}function tt(){return{id:J.id,title:`action-recorder.menu.replay-local-active`,type:T.BUTTON}}const nt={[We.OTHERS]:{[Z]:{order:1,menuItemFactory:Ze,[Y.id]:{order:1,menuItemFactory:Qe},[K.id]:{order:2,menuItemFactory:$e},[q.id]:{order:3,menuItemFactory:et},[J.id]:{order:4,menuItemFactory:tt}}}};function rt(){return D(E(B).panelOpened$)?M(it,{}):null}function it(){var e;let t=E(n),r=E(B),i=D(r.recording$),a=D(r.recordedCommands$),o=(e=a==null?void 0:a.length)==null?0:e,s=j(()=>{i||t.executeCommand(X.id)},[t,i]),c=j(e=>{i||t.executeCommand(V.id,{replaceId:e})},[t,i]),l=j(()=>{i&&t.executeCommand(H.id)},[t,i]),u=j(()=>{i&&t.executeCommand(U.id)},[t,i]),f=i?o===0?`Recording...`:`${o}: ${a[o-1].id}`:`Start Recording`;return N(`div`,{className:`
|
|
2
|
+
univer-fixed univer-bottom-20 univer-left-1/2 univer-z-[1000] univer-flex univer-h-16 univer-w-[512px]
|
|
3
|
+
-univer-translate-x-1/2 univer-items-center univer-rounded-lg univer-bg-white univer-px-5 univer-shadow-lg
|
|
4
|
+
`,children:[M(`div`,{className:`univer-mr-2 univer-size-5 univer-shrink-0 univer-grow-0 univer-text-xl`,children:M(d,{})}),M(`div`,{className:`univer-flex-1 univer-text-sm`,children:f}),N(`div`,{className:`univer-flex univer-w-64 univer-shrink-0 univer-grow-0 univer-justify-between`,children:[M(k,{className:`univer-w-20`,onClick:i?u:s,children:i?`Cancel`:`Close`}),M(k,{className:`univer-w-20`,variant:`primary`,onClick:i?l:()=>c(),children:i?`Save`:`Start`}),!i&&M(k,{variant:`primary`,onClick:()=>c(!0),children:`Start(N)`})]})]})}let Q=class extends t{constructor(e,t,n,r,i,a){super(),this._commandSrv=e,this._uiPartsSrv=t,this._menuManagerService=n,this._componentManager=r,this._actionRecorderService=i,this._injector=a,this._initCommands(),this._initUI(),this._initSheetsCommands(),this._initDocsCommands()}_initCommands(){[V,U,H,Y,X,K,q,J].forEach(e=>this._commandSrv.registerCommand(e))}_initUI(){this._uiPartsSrv.registerComponent(Be.GLOBAL,()=>Ge(rt,this._injector)),this.disposeWithMe(this._componentManager.register(`RecordIcon`,d)),this._menuManagerService.mergeMenu(nt)}_initSheetsCommands(){[ie,ae,oe,se,ce,pe,le,ue,de,fe,he,xe,ee,f,ne,te,ge,p,_e,ve,je,h,g,_,v,y,b,x,S,ye,be,Se,Ce,we,Te,Me,Ne,Pe,Fe,Ie,Le,Re,ze,re,me,Ee,De,m,ke,Ae,Oe].forEach(e=>this._actionRecorderService.registerRecordedCommand(e))}_initDocsCommands(){}};Q=z([R(0,n),R(1,Ue),R(2,He),R(3,o(Ve)),R(4,o(B)),R(5,o(s))],Q);let $=class extends c{constructor(e=F,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{menu:r,...i}=u({},F,this._config);r&&this._configService.setConfig(`menu`,r,{merge:!0}),this._configService.setConfig(P,i)}onStarting(){(this._config.replayOnly?[[G]]:[[B],[G],[Q]]).forEach(e=>this._injector.add(e))}onSteady(){this._config.replayOnly||this._injector.get(Q)}};L($,`pluginName`,`UNIVER_ACTION_RECORDER_PLUGIN`),L($,`packageName`,Ke),L($,`version`,qe),$=z([R(1,o(s)),R(2,r)],$);export{B as ActionRecorderService,G as ActionReplayService,$ as UniverActionRecorderPlugin};
|
package/lib/locale/ca-ES.js
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
"action-recorder": {
|
|
3
|
-
menu: {
|
|
4
|
-
title: "Grava accions",
|
|
5
|
-
record: "Grava accions...",
|
|
6
|
-
"replay-local": "Reemplaça gravació local...",
|
|
7
|
-
"replay-local-name": "Reemplaça gravació local per subunitat...",
|
|
8
|
-
"replay-local-active": "Reemplaça gravació local per subunitat actual..."
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
export {
|
|
13
|
-
a as default
|
|
14
|
-
};
|
|
1
|
+
const e={"action-recorder":{menu:{title:`Grava accions`,record:`Grava accions...`,"replay-local":`Reemplaça gravació local...`,"replay-local-name":`Reemplaça gravació local per subunitat...`,"replay-local-active":`Reemplaça gravació local per subunitat actual...`}}};export{e as default};
|
package/lib/locale/en-US.js
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
const e
|
|
2
|
-
"action-recorder": {
|
|
3
|
-
menu: {
|
|
4
|
-
title: "Record Actions",
|
|
5
|
-
record: "Record Actions...",
|
|
6
|
-
"replay-local": "Replace Local Record...",
|
|
7
|
-
"replay-local-name": "Replace Local Record by Subunit...",
|
|
8
|
-
"replay-local-active": "Replace Local Record by Current Subunit..."
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
export {
|
|
13
|
-
e as default
|
|
14
|
-
};
|
|
1
|
+
const e={"action-recorder":{menu:{title:`Record Actions`,record:`Record Actions...`,"replay-local":`Replace Local Record...`,"replay-local-name":`Replace Local Record by Subunit...`,"replay-local-active":`Replace Local Record by Current Subunit...`}}};export{e as default};
|
package/lib/locale/es-ES.js
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
"action-recorder": {
|
|
3
|
-
menu: {
|
|
4
|
-
title: "Grabar acciones",
|
|
5
|
-
record: "Grabar acciones...",
|
|
6
|
-
"replay-local": "Reemplazar grabación local...",
|
|
7
|
-
"replay-local-name": "Reemplazar grabación local por subunidad...",
|
|
8
|
-
"replay-local-active": "Reemplazar grabación local por subunidad actual..."
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
export {
|
|
13
|
-
a as default
|
|
14
|
-
};
|
|
1
|
+
const e={"action-recorder":{menu:{title:`Grabar acciones`,record:`Grabar acciones...`,"replay-local":`Reemplazar grabación local...`,"replay-local-name":`Reemplazar grabación local por subunidad...`,"replay-local-active":`Reemplazar grabación local por subunidad actual...`}}};export{e as default};
|
package/lib/locale/fa-IR.js
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
const e
|
|
2
|
-
"action-recorder": {
|
|
3
|
-
menu: {
|
|
4
|
-
title: "ثبت اقدامات",
|
|
5
|
-
record: "ثبت اقدامات...",
|
|
6
|
-
"replay-local": "بازپخش محلی ثبت...",
|
|
7
|
-
"replay-local-name": "بازپخش محلی ثبت بر اساس نام زیر واحد...",
|
|
8
|
-
"replay-local-active": "بازپخش محلی ثبت بر اساس زیر واحد فعلی..."
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
export {
|
|
13
|
-
e as default
|
|
14
|
-
};
|
|
1
|
+
const e={"action-recorder":{menu:{title:`ثبت اقدامات`,record:`ثبت اقدامات...`,"replay-local":`بازپخش محلی ثبت...`,"replay-local-name":`بازپخش محلی ثبت بر اساس نام زیر واحد...`,"replay-local-active":`بازپخش محلی ثبت بر اساس زیر واحد فعلی...`}}};export{e as default};
|
package/lib/locale/fr-FR.js
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
const e
|
|
2
|
-
"action-recorder": {
|
|
3
|
-
menu: {
|
|
4
|
-
title: "Enregistrer les actions",
|
|
5
|
-
record: "Enregistrer les actions...",
|
|
6
|
-
"replay-local": "Lecture de l'enregistrement local...",
|
|
7
|
-
"replay-local-name": "Remplacer l'enregistrement local par le sous-unité...",
|
|
8
|
-
"replay-local-active": "Remplacer l'enregistrement local par le sous-unité actuel..."
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
export {
|
|
13
|
-
e as default
|
|
14
|
-
};
|
|
1
|
+
const e={"action-recorder":{menu:{title:`Enregistrer les actions`,record:`Enregistrer les actions...`,"replay-local":`Lecture de l'enregistrement local...`,"replay-local-name":`Remplacer l'enregistrement local par le sous-unité...`,"replay-local-active":`Remplacer l'enregistrement local par le sous-unité actuel...`}}};export{e as default};
|