@univerjs/action-recorder 0.6.7 → 0.6.8
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/index.js +510 -0
- package/lib/locale/en-US.js +12 -0
- package/lib/locale/fa-IR.js +12 -0
- package/lib/locale/fr-FR.js +12 -0
- package/lib/locale/ru-RU.js +12 -0
- package/lib/locale/vi-VN.js +12 -0
- package/lib/locale/zh-CN.js +12 -0
- package/lib/locale/zh-TW.js +12 -0
- package/package.json +10 -10
package/lib/index.js
ADDED
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
var ce = Object.defineProperty;
|
|
2
|
+
var ae = (e, t, r) => t in e ? ce(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var m = (e, t, r) => ae(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { Disposable as E, CommandType as u, ICommandService as b, ILogService as G, IUniverInstanceService as Z, awaitTime as de, Inject as M, Injector as K, IConfigService as se, Plugin as le, merge as me } from "@univerjs/core";
|
|
5
|
+
import { SetSelectionsOperation as $, CopySheetCommand as ue, DeleteRangeMoveLeftCommand as fe, DeleteRangeMoveUpCommand as ge, DeltaColumnWidthCommand as he, 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 Pe, AddWorksheetMergeVerticalCommand as Me, AddWorksheetMergeHorizontalCommand as Ne, SetFrozenCommand as be, CancelFrozenCommand as xe, SetHorizontalTextAlignCommand as Ae, SetOverlineCommand as Ue, SetRangeValuesCommand as we, SetStrikeThroughCommand as $e, SetTextColorCommand as Te, SetTextRotationCommand as Fe, SetTextWrapCommand as Ee, SetVerticalTextAlignCommand as De, SetWorksheetActivateCommand as je, SetWorksheetActiveOperation as Le } from "@univerjs/sheets";
|
|
6
|
+
import { SetSheetFilterRangeCommand as Be, SetSheetsFilterCriteriaCommand as ke, RemoveSheetFilterCommand as Ve } from "@univerjs/sheets-filter";
|
|
7
|
+
import { SetRangeBoldCommand as We, SetRangeFontFamilyCommand as ze, SetRangeFontSizeCommand as He, SetRangeItalicCommand as Je, SetRangeStrickThroughCommand as Ge, SetRangeSubscriptCommand as Ze, SetRangeSuperscriptCommand as Ke, SetRangeTextColorCommand as Ye, SetRangeUnderlineCommand as qe, SheetCopyCommand as Qe, SheetCutCommand as Xe, SheetPasteBesidesBorderCommand as et, SheetPasteColWidthCommand as tt, SheetPasteCommand as rt, SheetPasteFormatCommand as nt, SheetPasteShortKeyCommand as ot, SheetPasteValueCommand as it, AutoFillCommand as ct, RefillCommand as at } from "@univerjs/sheets-ui";
|
|
8
|
+
import { ILocalFileService as Y, IMessageService as x, useDependency as T, useObservable as F, RibbonStartGroup as dt, MenuItemType as R, IUIPartsService as st, IMenuManagerService as lt, ComponentManager as mt, BuiltInUIPart as ut, connectInjector as ft } from "@univerjs/ui";
|
|
9
|
+
import { BehaviorSubject as I } from "rxjs";
|
|
10
|
+
import { MessageType as A, clsx as gt, Button as U } from "@univerjs/design";
|
|
11
|
+
import { jsx as h, jsxs as W } from "react/jsx-runtime";
|
|
12
|
+
import { forwardRef as q, useRef as ht, createElement as Q, useCallback as O } from "react";
|
|
13
|
+
var s = function() {
|
|
14
|
+
return s = Object.assign || function(e) {
|
|
15
|
+
for (var t, r = 1, n = arguments.length; r < n; r++) {
|
|
16
|
+
t = arguments[r];
|
|
17
|
+
for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
|
|
18
|
+
}
|
|
19
|
+
return e;
|
|
20
|
+
}, s.apply(this, arguments);
|
|
21
|
+
}, pt = function(e, t) {
|
|
22
|
+
var r = {};
|
|
23
|
+
for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
|
|
24
|
+
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
25
|
+
for (var o = 0, n = Object.getOwnPropertySymbols(e); o < n.length; o++)
|
|
26
|
+
t.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[o]) && (r[n[o]] = e[n[o]]);
|
|
27
|
+
return r;
|
|
28
|
+
}, X = q(function(e, t) {
|
|
29
|
+
var r = e.icon, n = e.id, o = e.className, i = e.extend, c = pt(e, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(n, " ").concat(o || "").trim(), f = ht("_".concat(Ct()));
|
|
30
|
+
return ee(r, "".concat(n), { defIds: r.defIds, idSuffix: f.current }, s({ ref: t, className: a }, c), i);
|
|
31
|
+
});
|
|
32
|
+
function ee(e, t, r, n, o) {
|
|
33
|
+
return Q(e.tag, s(s({ key: t }, St(e, r, o)), n), (vt(e, r).children || []).map(function(i, c) {
|
|
34
|
+
return ee(i, "".concat(t, "-").concat(e.tag, "-").concat(c), r, void 0, o);
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
function St(e, t, r) {
|
|
38
|
+
var n = s({}, e.attrs);
|
|
39
|
+
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(function(i) {
|
|
40
|
+
var c = i[0], a = i[1];
|
|
41
|
+
c === "mask" && typeof a == "string" && (n[c] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
|
|
42
|
+
});
|
|
43
|
+
var o = t.defIds;
|
|
44
|
+
return !o || o.length === 0 || (e.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + t.idSuffix), Object.entries(n).forEach(function(i) {
|
|
45
|
+
var c = i[0], a = i[1];
|
|
46
|
+
typeof a == "string" && (n[c] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
|
|
47
|
+
})), n;
|
|
48
|
+
}
|
|
49
|
+
function vt(e, t) {
|
|
50
|
+
var r, n = t.defIds;
|
|
51
|
+
return !n || n.length === 0 ? e : e.tag === "defs" && (!((r = e.children) === null || r === void 0) && r.length) ? s(s({}, e), { children: e.children.map(function(o) {
|
|
52
|
+
return typeof o.attrs.id == "string" && n && n.indexOf(o.attrs.id) > -1 ? s(s({}, o), { attrs: s(s({}, o.attrs), { id: o.attrs.id + t.idSuffix }) }) : o;
|
|
53
|
+
}) }) : e;
|
|
54
|
+
}
|
|
55
|
+
function Ct() {
|
|
56
|
+
return Math.random().toString(36).substring(2, 8);
|
|
57
|
+
}
|
|
58
|
+
X.displayName = "UniverIcon";
|
|
59
|
+
var _t = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "g", attrs: { fill: "currentColor", clipPath: "url(#record-single_clip0_1559_19)" }, children: [{ tag: "path", 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" } }, { tag: "path", attrs: { 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", fillRule: "evenodd", clipRule: "evenodd" } }] }, { tag: "defs", attrs: {}, children: [{ tag: "clipPath", attrs: { id: "record-single_clip0_1559_19" }, children: [{ tag: "path", attrs: { fill: "#fff", d: "M0 0H16V16H0z", transform: "translate(.94)" } }] }] }], defIds: ["record-single_clip0_1559_19"] }, D = q(function(e, t) {
|
|
60
|
+
return Q(X, Object.assign({}, e, {
|
|
61
|
+
id: "record-single",
|
|
62
|
+
ref: t,
|
|
63
|
+
icon: _t
|
|
64
|
+
}));
|
|
65
|
+
});
|
|
66
|
+
D.displayName = "RecordSingle";
|
|
67
|
+
var yt = Object.getOwnPropertyDescriptor, Rt = (e, t, r, n) => {
|
|
68
|
+
for (var o = n > 1 ? void 0 : n ? yt(t, r) : t, i = e.length - 1, c; i >= 0; i--)
|
|
69
|
+
(c = e[i]) && (o = c(o) || o);
|
|
70
|
+
return o;
|
|
71
|
+
}, P = (e, t) => (r, n) => t(r, n, e);
|
|
72
|
+
let l = class extends E {
|
|
73
|
+
constructor(t, r, n, o) {
|
|
74
|
+
super();
|
|
75
|
+
m(this, "_shouldRecordCommands", /* @__PURE__ */ new Set());
|
|
76
|
+
m(this, "_panelOpened$", new I(!1));
|
|
77
|
+
m(this, "panelOpened$", this._panelOpened$.asObservable());
|
|
78
|
+
m(this, "_recorder", null);
|
|
79
|
+
m(this, "_recording$", new I(!1));
|
|
80
|
+
m(this, "recording$", this._recording$.asObservable());
|
|
81
|
+
m(this, "_recorded$", new I([]));
|
|
82
|
+
m(this, "_recordedCommands$", new I([]));
|
|
83
|
+
m(this, "recordedCommands$", this._recordedCommands$.asObservable());
|
|
84
|
+
this._commandSrv = t, this._logService = r, this._localFileService = n, this._instanceService = o;
|
|
85
|
+
}
|
|
86
|
+
get recording() {
|
|
87
|
+
return this._recording$.getValue();
|
|
88
|
+
}
|
|
89
|
+
get _recorded() {
|
|
90
|
+
return this._recorded$.getValue();
|
|
91
|
+
}
|
|
92
|
+
get _recordedCommands() {
|
|
93
|
+
return this._recordedCommands$.getValue();
|
|
94
|
+
}
|
|
95
|
+
registerRecordedCommand(t) {
|
|
96
|
+
if (t.type === u.MUTATION) throw new Error("[CommandRecorderService] Cannot record mutation commands.");
|
|
97
|
+
this._shouldRecordCommands.add(t.id);
|
|
98
|
+
}
|
|
99
|
+
togglePanel(t) {
|
|
100
|
+
this._panelOpened$.next(t), t === !1 && this.stopRecording();
|
|
101
|
+
}
|
|
102
|
+
startRecording(t = !1) {
|
|
103
|
+
this._recorder = this._commandSrv.onCommandExecuted((r) => {
|
|
104
|
+
var n, o;
|
|
105
|
+
if (this._shouldRecordCommands.has(r.id)) {
|
|
106
|
+
const i = this._recorded, c = this._recordedCommands;
|
|
107
|
+
let a = { ...r };
|
|
108
|
+
const f = (n = this._instanceService.getFocusedUnit()) == null ? void 0 : n.getUnitId(), { unitId: g = f, subUnitId: d } = a == null ? void 0 : a.params;
|
|
109
|
+
if (t && g && d) {
|
|
110
|
+
const v = (o = this._instanceService.getUnit(g).getSheetBySheetId(d)) == null ? void 0 : o.getName();
|
|
111
|
+
a = {
|
|
112
|
+
...a,
|
|
113
|
+
params: {
|
|
114
|
+
...a.params,
|
|
115
|
+
subUnitId: v
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
a.id === $.id && i.length > 0 && i[i.length - 1].id === $.id ? i[i.length - 1] = a : (i.push(a), this._recorded$.next(i), a.type === u.COMMAND && (c.push(a), this._recordedCommands$.next(c)));
|
|
120
|
+
}
|
|
121
|
+
}), this._recording$.next(!0);
|
|
122
|
+
}
|
|
123
|
+
stopRecording() {
|
|
124
|
+
var t;
|
|
125
|
+
(t = this._recorder) == null || t.dispose(), this._recorder = null, this._recorded$.next([]), this._recordedCommands$.next([]), this._recording$.next(!1);
|
|
126
|
+
}
|
|
127
|
+
completeRecording() {
|
|
128
|
+
const t = this._recorded.slice();
|
|
129
|
+
this._localFileService.downloadFile(new Blob([JSON.stringify(t, null, 2)]), "recorded-commands.json"), this._logService.error("Recorded commands:", t), this.stopRecording();
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
l = Rt([
|
|
133
|
+
P(0, b),
|
|
134
|
+
P(1, G),
|
|
135
|
+
P(2, Y),
|
|
136
|
+
P(3, Z)
|
|
137
|
+
], l);
|
|
138
|
+
const te = {
|
|
139
|
+
id: "action-recorder.command.start-recording",
|
|
140
|
+
type: u.COMMAND,
|
|
141
|
+
handler: (e, t) => (e.get(l).startRecording(!!(t != null && t.replaceId)), !0)
|
|
142
|
+
}, re = {
|
|
143
|
+
id: "action-recorder.command.complete-recording",
|
|
144
|
+
type: u.COMMAND,
|
|
145
|
+
handler: (e) => (e.get(l).completeRecording(), !0)
|
|
146
|
+
}, ne = {
|
|
147
|
+
id: "action-recorder.command.stop-recording",
|
|
148
|
+
type: u.COMMAND,
|
|
149
|
+
handler: (e) => (e.get(l).completeRecording(), !0)
|
|
150
|
+
};
|
|
151
|
+
var It = Object.getOwnPropertyDescriptor, Ot = (e, t, r, n) => {
|
|
152
|
+
for (var o = n > 1 ? void 0 : n ? It(t, r) : t, i = e.length - 1, c; i >= 0; i--)
|
|
153
|
+
(c = e[i]) && (o = c(o) || o);
|
|
154
|
+
return o;
|
|
155
|
+
}, _ = (e, t) => (r, n) => t(r, n, e), j = /* @__PURE__ */ ((e) => (e.DEFAULT = "default", e.NAME = "name", e.ACTIVE = "active", e))(j || {});
|
|
156
|
+
let p = class extends E {
|
|
157
|
+
constructor(e, t, r, n, o) {
|
|
158
|
+
super(), this._messageService = e, this._instanceService = t, this._localFileService = r, this._logService = n, this._commandService = o;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Read a local file and try to replay commands in this JSON.
|
|
162
|
+
*/
|
|
163
|
+
async replayLocalJSON(e = "default") {
|
|
164
|
+
const t = await this._localFileService.openFile({ multiple: !1, accept: ".json" });
|
|
165
|
+
if (t.length !== 1) return !1;
|
|
166
|
+
const r = t[0];
|
|
167
|
+
try {
|
|
168
|
+
return this.replayCommands(JSON.parse(await r.text()), { mode: e });
|
|
169
|
+
} catch {
|
|
170
|
+
return this._messageService.show({
|
|
171
|
+
type: A.Error,
|
|
172
|
+
content: `Failed to replay commands from local file ${r.name}.`
|
|
173
|
+
}), !1;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Replay a list of commands. Note that `unitId` of these commands would be changed to the focused unit.
|
|
178
|
+
* @param commands - The commands to replay.
|
|
179
|
+
* @returns If the replay is successful.
|
|
180
|
+
*/
|
|
181
|
+
async replayCommands(e, t) {
|
|
182
|
+
var o, i, c;
|
|
183
|
+
const r = (o = this._instanceService.getFocusedUnit()) == null ? void 0 : o.getUnitId();
|
|
184
|
+
r || this._logService.error("[ReplayService]", "no focused unit to replay commands");
|
|
185
|
+
const { mode: n } = t || {};
|
|
186
|
+
for (const a of e) {
|
|
187
|
+
const { id: f, params: g } = a, d = g;
|
|
188
|
+
if (d) {
|
|
189
|
+
if (typeof d.unitId < "u" && (d.unitId = r), n === "name" && d.subUnitId !== "undefined") {
|
|
190
|
+
const C = (i = this._instanceService.getFocusedUnit().getSheetBySheetName(d.subUnitId)) == null ? void 0 : i.getSheetId();
|
|
191
|
+
C ? d.subUnitId = C : this._logService.error("[ReplayService]", `failed to find subunit by subUnitName = ${d.subUnitId}`);
|
|
192
|
+
}
|
|
193
|
+
if (n === "active" && d.subUnitId !== "undefined") {
|
|
194
|
+
const C = (c = this._instanceService.getFocusedUnit().getActiveSheet()) == null ? void 0 : c.getSheetId();
|
|
195
|
+
C ? d.subUnitId = C : this._logService.error("[ReplayService]", "failed to find active subunit");
|
|
196
|
+
}
|
|
197
|
+
if (!await this._commandService.executeCommand(f, g)) return !1;
|
|
198
|
+
} else if (!await this._commandService.executeCommand(f)) return !1;
|
|
199
|
+
}
|
|
200
|
+
return !0;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Replay a list of commands with a random delay between each command.
|
|
204
|
+
* @param commands - The commands to replay.
|
|
205
|
+
*/
|
|
206
|
+
async replayCommandsWithDelay(e) {
|
|
207
|
+
var r;
|
|
208
|
+
const t = (r = this._instanceService.getFocusedUnit()) == null ? void 0 : r.getUnitId();
|
|
209
|
+
t || this._logService.error("[ReplayService]", "no focused unit to replay commands");
|
|
210
|
+
for (const n of e) {
|
|
211
|
+
await de(Pt());
|
|
212
|
+
const { id: o, params: i } = n;
|
|
213
|
+
if (i) {
|
|
214
|
+
if (typeof i.unitId < "u" && (i.unitId = t), !await this._commandService.executeCommand(o, i)) return !1;
|
|
215
|
+
} else if (!await this._commandService.executeCommand(o)) return !1;
|
|
216
|
+
}
|
|
217
|
+
return !0;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
p = Ot([
|
|
221
|
+
_(0, x),
|
|
222
|
+
_(1, Z),
|
|
223
|
+
_(2, Y),
|
|
224
|
+
_(3, G),
|
|
225
|
+
_(4, b)
|
|
226
|
+
], p);
|
|
227
|
+
function Pt() {
|
|
228
|
+
return Math.floor(Math.random() * 800) + 200;
|
|
229
|
+
}
|
|
230
|
+
const L = {
|
|
231
|
+
id: "action-recorder.command.replay-local-records",
|
|
232
|
+
type: u.COMMAND,
|
|
233
|
+
handler: async (e) => {
|
|
234
|
+
const r = await e.get(p).replayLocalJSON();
|
|
235
|
+
return r && e.get(x).show({
|
|
236
|
+
type: A.Success,
|
|
237
|
+
content: "Successfully replayed local records"
|
|
238
|
+
}), r;
|
|
239
|
+
}
|
|
240
|
+
}, B = {
|
|
241
|
+
id: "action-recorder.command.replay-local-records-name",
|
|
242
|
+
type: u.COMMAND,
|
|
243
|
+
handler: async (e) => {
|
|
244
|
+
const r = await e.get(p).replayLocalJSON(j.NAME);
|
|
245
|
+
return r && e.get(x).show({
|
|
246
|
+
type: A.Success,
|
|
247
|
+
content: "Successfully replayed local records"
|
|
248
|
+
}), r;
|
|
249
|
+
}
|
|
250
|
+
}, k = {
|
|
251
|
+
id: "action-recorder.command.replay-local-records-active",
|
|
252
|
+
type: u.COMMAND,
|
|
253
|
+
handler: async (e) => {
|
|
254
|
+
const r = await e.get(p).replayLocalJSON(j.ACTIVE);
|
|
255
|
+
return r && e.get(x).show({
|
|
256
|
+
type: A.Success,
|
|
257
|
+
content: "Successfully replayed local records"
|
|
258
|
+
}), r;
|
|
259
|
+
}
|
|
260
|
+
}, V = {
|
|
261
|
+
id: "action-recorder.operation.open-panel",
|
|
262
|
+
type: u.OPERATION,
|
|
263
|
+
handler(e) {
|
|
264
|
+
return e.get(l).togglePanel(!0), !0;
|
|
265
|
+
}
|
|
266
|
+
}, oe = {
|
|
267
|
+
id: "action-recorder.operation.close-panel",
|
|
268
|
+
type: u.OPERATION,
|
|
269
|
+
handler(e) {
|
|
270
|
+
return e.get(l).togglePanel(!1), !0;
|
|
271
|
+
}
|
|
272
|
+
}, Mt = "univer-action-recorder-panel", Nt = "univer-action-recorder-panel-icon", bt = "univer-action-recorder-panel-icon-recording", xt = "univer-action-recorder-panel-title", At = "univer-action-recorder-panel-actions", y = {
|
|
273
|
+
actionRecorderPanel: Mt,
|
|
274
|
+
actionRecorderPanelIcon: Nt,
|
|
275
|
+
actionRecorderPanelIconRecording: bt,
|
|
276
|
+
actionRecorderPanelTitle: xt,
|
|
277
|
+
actionRecorderPanelActions: At
|
|
278
|
+
};
|
|
279
|
+
function Ut() {
|
|
280
|
+
const e = T(l);
|
|
281
|
+
return F(e.panelOpened$) ? /* @__PURE__ */ h(wt, {}) : null;
|
|
282
|
+
}
|
|
283
|
+
function wt() {
|
|
284
|
+
var d;
|
|
285
|
+
const e = T(b), t = T(l), r = F(t.recording$), n = F(t.recordedCommands$), o = (d = n == null ? void 0 : n.length) != null ? d : 0, i = O(() => {
|
|
286
|
+
r || e.executeCommand(oe.id);
|
|
287
|
+
}, [e, r]), c = O((v) => {
|
|
288
|
+
r || e.executeCommand(te.id, { replaceId: v });
|
|
289
|
+
}, [e, r]), a = O(() => {
|
|
290
|
+
r && e.executeCommand(re.id);
|
|
291
|
+
}, [e, r]), f = O(() => {
|
|
292
|
+
r && e.executeCommand(ne.id);
|
|
293
|
+
}, [e, r]), g = r ? o === 0 ? "Recording..." : `${o}: ${n[o - 1].id}` : "Start Recording";
|
|
294
|
+
return /* @__PURE__ */ W("div", { className: y.actionRecorderPanel, children: [
|
|
295
|
+
/* @__PURE__ */ h("div", { className: gt(y.actionRecorderPanelIcon, r ? y.actionRecorderPanelIconRecording : !1), children: /* @__PURE__ */ h(D, {}) }),
|
|
296
|
+
/* @__PURE__ */ h("div", { className: y.actionRecorderPanelTitle, children: g }),
|
|
297
|
+
/* @__PURE__ */ W("div", { className: y.actionRecorderPanelActions, children: [
|
|
298
|
+
/* @__PURE__ */ h(U, { type: "default", size: "small", onClick: r ? f : i, children: r ? "Cancel" : "Close" }),
|
|
299
|
+
/* @__PURE__ */ h(U, { type: "primary", size: "small", onClick: r ? a : () => c(), children: r ? "Save" : "Start" }),
|
|
300
|
+
!r && /* @__PURE__ */ h(U, { type: "primary", size: "small", onClick: () => c(!0), children: "Start(N)" })
|
|
301
|
+
] })
|
|
302
|
+
] });
|
|
303
|
+
}
|
|
304
|
+
const ie = "RECORD_MENU_ITEM";
|
|
305
|
+
function $t() {
|
|
306
|
+
return {
|
|
307
|
+
id: ie,
|
|
308
|
+
type: R.SUBITEMS,
|
|
309
|
+
icon: "RecordSingle",
|
|
310
|
+
tooltip: "action-recorder.menu.title"
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
function Tt(e) {
|
|
314
|
+
const t = e.get(l);
|
|
315
|
+
return {
|
|
316
|
+
id: V.id,
|
|
317
|
+
title: "action-recorder.menu.record",
|
|
318
|
+
type: R.BUTTON,
|
|
319
|
+
disabled$: t.panelOpened$
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
function Ft() {
|
|
323
|
+
return {
|
|
324
|
+
id: L.id,
|
|
325
|
+
title: "action-recorder.menu.replay-local",
|
|
326
|
+
type: R.BUTTON
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
function Et() {
|
|
330
|
+
return {
|
|
331
|
+
id: B.id,
|
|
332
|
+
title: "action-recorder.menu.replay-local-name",
|
|
333
|
+
type: R.BUTTON
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
function Dt() {
|
|
337
|
+
return {
|
|
338
|
+
id: k.id,
|
|
339
|
+
title: "action-recorder.menu.replay-local-active",
|
|
340
|
+
type: R.BUTTON
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
const jt = {
|
|
344
|
+
[dt.OTHERS]: {
|
|
345
|
+
[ie]: {
|
|
346
|
+
order: 10,
|
|
347
|
+
menuItemFactory: $t,
|
|
348
|
+
[V.id]: {
|
|
349
|
+
order: 1,
|
|
350
|
+
menuItemFactory: Tt
|
|
351
|
+
},
|
|
352
|
+
[L.id]: {
|
|
353
|
+
order: 2,
|
|
354
|
+
menuItemFactory: Ft
|
|
355
|
+
},
|
|
356
|
+
[B.id]: {
|
|
357
|
+
order: 3,
|
|
358
|
+
menuItemFactory: Et
|
|
359
|
+
},
|
|
360
|
+
[k.id]: {
|
|
361
|
+
order: 4,
|
|
362
|
+
menuItemFactory: Dt
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
var Lt = Object.getOwnPropertyDescriptor, Bt = (e, t, r, n) => {
|
|
368
|
+
for (var o = n > 1 ? void 0 : n ? Lt(t, r) : t, i = e.length - 1, c; i >= 0; i--)
|
|
369
|
+
(c = e[i]) && (o = c(o) || o);
|
|
370
|
+
return o;
|
|
371
|
+
}, S = (e, t) => (r, n) => t(r, n, e);
|
|
372
|
+
let N = class extends E {
|
|
373
|
+
constructor(e, t, r, n, o, i) {
|
|
374
|
+
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();
|
|
375
|
+
}
|
|
376
|
+
_initCommands() {
|
|
377
|
+
[
|
|
378
|
+
te,
|
|
379
|
+
ne,
|
|
380
|
+
re,
|
|
381
|
+
V,
|
|
382
|
+
oe,
|
|
383
|
+
L,
|
|
384
|
+
B,
|
|
385
|
+
k
|
|
386
|
+
].forEach((e) => this._commandSrv.registerCommand(e));
|
|
387
|
+
}
|
|
388
|
+
_initUI() {
|
|
389
|
+
this._uiPartsSrv.registerComponent(ut.GLOBAL, () => ft(Ut, this._injector)), this._componentManager.register("RecordSingle", D), this._menuManagerService.mergeMenu(jt);
|
|
390
|
+
}
|
|
391
|
+
_initSheetsCommands() {
|
|
392
|
+
[
|
|
393
|
+
// InsertColCommand,
|
|
394
|
+
// InsertRowCommand,
|
|
395
|
+
// #region basic commands
|
|
396
|
+
ue,
|
|
397
|
+
fe,
|
|
398
|
+
ge,
|
|
399
|
+
he,
|
|
400
|
+
pe,
|
|
401
|
+
Se,
|
|
402
|
+
ve,
|
|
403
|
+
Ce,
|
|
404
|
+
_e,
|
|
405
|
+
ye,
|
|
406
|
+
Re,
|
|
407
|
+
Ie,
|
|
408
|
+
Oe,
|
|
409
|
+
Pe,
|
|
410
|
+
Me,
|
|
411
|
+
Ne,
|
|
412
|
+
// ResetBackgroundColorCommand,
|
|
413
|
+
// ResetTextColorCommand,
|
|
414
|
+
// SetBackgroundColorCommand,
|
|
415
|
+
// SetBoldCommand,
|
|
416
|
+
// SetFontFamilyCommand,
|
|
417
|
+
// SetFontSizeCommand,
|
|
418
|
+
be,
|
|
419
|
+
xe,
|
|
420
|
+
Ae,
|
|
421
|
+
// SetItalicCommand,
|
|
422
|
+
Ue,
|
|
423
|
+
We,
|
|
424
|
+
ze,
|
|
425
|
+
He,
|
|
426
|
+
Je,
|
|
427
|
+
Ge,
|
|
428
|
+
Ze,
|
|
429
|
+
Ke,
|
|
430
|
+
Ye,
|
|
431
|
+
qe,
|
|
432
|
+
we,
|
|
433
|
+
$e,
|
|
434
|
+
Te,
|
|
435
|
+
Fe,
|
|
436
|
+
Ee,
|
|
437
|
+
// SetUnderlineCommand,
|
|
438
|
+
De,
|
|
439
|
+
Qe,
|
|
440
|
+
Xe,
|
|
441
|
+
et,
|
|
442
|
+
tt,
|
|
443
|
+
rt,
|
|
444
|
+
nt,
|
|
445
|
+
ot,
|
|
446
|
+
it,
|
|
447
|
+
ct,
|
|
448
|
+
at,
|
|
449
|
+
je,
|
|
450
|
+
Le,
|
|
451
|
+
$,
|
|
452
|
+
// #endregion
|
|
453
|
+
// #region data validation command
|
|
454
|
+
// #endregion
|
|
455
|
+
// #region conditional formatting command
|
|
456
|
+
// #endregion
|
|
457
|
+
// #region filter command
|
|
458
|
+
Be,
|
|
459
|
+
ke,
|
|
460
|
+
Ve
|
|
461
|
+
// #endregion
|
|
462
|
+
].forEach((e) => this._actionRecorderService.registerRecordedCommand(e));
|
|
463
|
+
}
|
|
464
|
+
_initDocsCommands() {
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
N = Bt([
|
|
468
|
+
S(0, b),
|
|
469
|
+
S(1, st),
|
|
470
|
+
S(2, lt),
|
|
471
|
+
S(3, M(mt)),
|
|
472
|
+
S(4, M(l)),
|
|
473
|
+
S(5, M(K))
|
|
474
|
+
], N);
|
|
475
|
+
const kt = "action-recorder.config", z = {};
|
|
476
|
+
var Vt = Object.getOwnPropertyDescriptor, Wt = (e, t, r, n) => {
|
|
477
|
+
for (var o = n > 1 ? void 0 : n ? Vt(t, r) : t, i = e.length - 1, c; i >= 0; i--)
|
|
478
|
+
(c = e[i]) && (o = c(o) || o);
|
|
479
|
+
return o;
|
|
480
|
+
}, H = (e, t) => (r, n) => t(r, n, e), w;
|
|
481
|
+
let J = (w = class extends le {
|
|
482
|
+
constructor(e = z, t, r) {
|
|
483
|
+
super(), this._config = e, this._injector = t, this._configService = r;
|
|
484
|
+
const { menu: n, ...o } = me(
|
|
485
|
+
{},
|
|
486
|
+
z,
|
|
487
|
+
this._config
|
|
488
|
+
);
|
|
489
|
+
n && this._configService.setConfig("menu", n, { merge: !0 }), this._configService.setConfig(kt, o);
|
|
490
|
+
}
|
|
491
|
+
onStarting() {
|
|
492
|
+
(this._config.replayOnly ? [[p]] : [
|
|
493
|
+
[l],
|
|
494
|
+
[p],
|
|
495
|
+
[N]
|
|
496
|
+
]).forEach((t) => this._injector.add(t));
|
|
497
|
+
}
|
|
498
|
+
onSteady() {
|
|
499
|
+
this._config.replayOnly || this._injector.get(N);
|
|
500
|
+
}
|
|
501
|
+
}, m(w, "pluginName", "UNIVER_ACTION_RECORDER_PLUGIN"), w);
|
|
502
|
+
J = Wt([
|
|
503
|
+
H(1, M(K)),
|
|
504
|
+
H(2, se)
|
|
505
|
+
], J);
|
|
506
|
+
export {
|
|
507
|
+
l as ActionRecorderService,
|
|
508
|
+
p as ActionReplayService,
|
|
509
|
+
J as UniverActionRecorderPlugin
|
|
510
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/action-recorder",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -48,17 +48,17 @@
|
|
|
48
48
|
"lib"
|
|
49
49
|
],
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"react": "
|
|
51
|
+
"react": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc",
|
|
52
52
|
"rxjs": ">=7.0.0"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@univerjs/icons": "^0.2.
|
|
56
|
-
"@univerjs/
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/sheets": "0.6.
|
|
59
|
-
"@univerjs/sheets
|
|
60
|
-
"@univerjs/ui": "0.6.
|
|
61
|
-
"@univerjs/
|
|
55
|
+
"@univerjs/icons": "^0.2.31",
|
|
56
|
+
"@univerjs/core": "0.6.8",
|
|
57
|
+
"@univerjs/design": "0.6.8",
|
|
58
|
+
"@univerjs/sheets-filter": "0.6.8",
|
|
59
|
+
"@univerjs/sheets": "0.6.8",
|
|
60
|
+
"@univerjs/sheets-ui": "0.6.8",
|
|
61
|
+
"@univerjs/ui": "0.6.8"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"less": "^4.2.2",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"typescript": "^5.8.2",
|
|
69
69
|
"vite": "^6.2.3",
|
|
70
70
|
"vitest": "^3.0.9",
|
|
71
|
-
"@univerjs-infra/shared": "0.6.
|
|
71
|
+
"@univerjs-infra/shared": "0.6.8"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"test": "vitest run",
|