@univerjs/action-recorder 1.0.0-alpha.7 → 1.0.0-beta.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 +8 -9
- package/lib/cjs/locale/ru-RU.js +5 -5
- package/lib/cjs/locale/vi-VN.js +5 -5
- package/lib/es/index.js +8 -9
- package/lib/es/locale/ru-RU.js +5 -5
- package/lib/es/locale/vi-VN.js +5 -5
- package/lib/index.js +8 -9
- package/lib/locale/ru-RU.js +5 -5
- package/lib/locale/vi-VN.js +5 -5
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/package.json +9 -9
- package/lib/types/views/components/RecorderPanel.spec.d.ts +0 -16
package/lib/cjs/index.js
CHANGED
|
@@ -10,7 +10,7 @@ let _univerjs_icons = require("@univerjs/icons");
|
|
|
10
10
|
let react = require("react");
|
|
11
11
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
12
|
|
|
13
|
-
//#region \0@oxc-project+runtime@0.
|
|
13
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
|
|
14
14
|
function __decorateParam(paramIndex, decorator) {
|
|
15
15
|
return function(target, key) {
|
|
16
16
|
decorator(target, key, paramIndex);
|
|
@@ -18,7 +18,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
//#endregion
|
|
21
|
-
//#region \0@oxc-project+runtime@0.
|
|
21
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
|
|
22
22
|
function __decorate(decorators, target, key, desc) {
|
|
23
23
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24
24
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -159,7 +159,7 @@ const ReplayLocalRecordOnActiveCommand = {
|
|
|
159
159
|
};
|
|
160
160
|
|
|
161
161
|
//#endregion
|
|
162
|
-
//#region \0@oxc-project+runtime@0.
|
|
162
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
|
|
163
163
|
function _typeof(o) {
|
|
164
164
|
"@babel/helpers - typeof";
|
|
165
165
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -170,7 +170,7 @@ function _typeof(o) {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
//#endregion
|
|
173
|
-
//#region \0@oxc-project+runtime@0.
|
|
173
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
|
|
174
174
|
function toPrimitive(t, r) {
|
|
175
175
|
if ("object" != _typeof(t) || !t) return t;
|
|
176
176
|
var e = t[Symbol.toPrimitive];
|
|
@@ -183,14 +183,14 @@ function toPrimitive(t, r) {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
//#endregion
|
|
186
|
-
//#region \0@oxc-project+runtime@0.
|
|
186
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
|
|
187
187
|
function toPropertyKey(t) {
|
|
188
188
|
var i = toPrimitive(t, "string");
|
|
189
189
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
//#endregion
|
|
193
|
-
//#region \0@oxc-project+runtime@0.
|
|
193
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
|
|
194
194
|
function _defineProperty(e, r, t) {
|
|
195
195
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
196
196
|
value: t,
|
|
@@ -375,7 +375,7 @@ const menuSchema = { [_univerjs_ui.RibbonOthersGroup.OTHERS]: { [RECORD_MENU_ITE
|
|
|
375
375
|
//#endregion
|
|
376
376
|
//#region package.json
|
|
377
377
|
var name = "@univerjs/action-recorder";
|
|
378
|
-
var version = "1.0.0-
|
|
378
|
+
var version = "1.0.0-beta.0";
|
|
379
379
|
|
|
380
380
|
//#endregion
|
|
381
381
|
//#region src/config/config.ts
|
|
@@ -417,13 +417,12 @@ function RecorderPanel() {
|
|
|
417
417
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RecordPanelImpl, {});
|
|
418
418
|
}
|
|
419
419
|
function RecordPanelImpl() {
|
|
420
|
-
var _recordedCommands$len;
|
|
421
420
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
422
421
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
423
422
|
const actionRecorderService = (0, _univerjs_ui.useDependency)(ActionRecorderService);
|
|
424
423
|
const recording = (0, _univerjs_ui.useObservable)(actionRecorderService.recording$);
|
|
425
424
|
const recordedCommands = (0, _univerjs_ui.useObservable)(actionRecorderService.recordedCommands$);
|
|
426
|
-
const len = (
|
|
425
|
+
const len = (recordedCommands === null || recordedCommands === void 0 ? void 0 : recordedCommands.length) ?? 0;
|
|
427
426
|
const closePanel = (0, react.useCallback)(() => {
|
|
428
427
|
if (!recording) commandService.executeCommand(CloseRecordPanelOperation.id);
|
|
429
428
|
}, [commandService, recording]);
|
package/lib/cjs/locale/ru-RU.js
CHANGED
|
@@ -11,11 +11,11 @@ const locale = { "action-recorder": {
|
|
|
11
11
|
startWithId: "Начать (N)"
|
|
12
12
|
},
|
|
13
13
|
menu: {
|
|
14
|
-
title: "
|
|
15
|
-
record: "
|
|
16
|
-
"replay-local": "
|
|
17
|
-
"replay-local-name": "
|
|
18
|
-
"replay-local-active": "
|
|
14
|
+
title: "Запись действий",
|
|
15
|
+
record: "Записать действия...",
|
|
16
|
+
"replay-local": "Заменить локальную запись...",
|
|
17
|
+
"replay-local-name": "Заменить локальную запись по подразделению...",
|
|
18
|
+
"replay-local-active": "Заменить локальную запись по текущему подразделению..."
|
|
19
19
|
}
|
|
20
20
|
} };
|
|
21
21
|
|
package/lib/cjs/locale/vi-VN.js
CHANGED
|
@@ -11,11 +11,11 @@ const locale = { "action-recorder": {
|
|
|
11
11
|
startWithId: "Bắt đầu (N)"
|
|
12
12
|
},
|
|
13
13
|
menu: {
|
|
14
|
-
title: "
|
|
15
|
-
record: "
|
|
16
|
-
"replay-local": "
|
|
17
|
-
"replay-local-name": "
|
|
18
|
-
"replay-local-active": "
|
|
14
|
+
title: "Ghi hành động",
|
|
15
|
+
record: "Ghi hành động...",
|
|
16
|
+
"replay-local": "Thay bản ghi cục bộ...",
|
|
17
|
+
"replay-local-name": "Thay bản ghi cục bộ theo bộ phận...",
|
|
18
|
+
"replay-local-active": "Thay bản ghi cục bộ theo bộ phận hiện tại..."
|
|
19
19
|
}
|
|
20
20
|
} };
|
|
21
21
|
|
package/lib/es/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { RecordIcon } from "@univerjs/icons";
|
|
|
9
9
|
import { useCallback } from "react";
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
|
|
12
|
-
//#region \0@oxc-project+runtime@0.
|
|
12
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
|
|
13
13
|
function __decorateParam(paramIndex, decorator) {
|
|
14
14
|
return function(target, key) {
|
|
15
15
|
decorator(target, key, paramIndex);
|
|
@@ -17,7 +17,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
//#endregion
|
|
20
|
-
//#region \0@oxc-project+runtime@0.
|
|
20
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
|
|
21
21
|
function __decorate(decorators, target, key, desc) {
|
|
22
22
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
23
23
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -158,7 +158,7 @@ const ReplayLocalRecordOnActiveCommand = {
|
|
|
158
158
|
};
|
|
159
159
|
|
|
160
160
|
//#endregion
|
|
161
|
-
//#region \0@oxc-project+runtime@0.
|
|
161
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
|
|
162
162
|
function _typeof(o) {
|
|
163
163
|
"@babel/helpers - typeof";
|
|
164
164
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -169,7 +169,7 @@ function _typeof(o) {
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
//#endregion
|
|
172
|
-
//#region \0@oxc-project+runtime@0.
|
|
172
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
|
|
173
173
|
function toPrimitive(t, r) {
|
|
174
174
|
if ("object" != _typeof(t) || !t) return t;
|
|
175
175
|
var e = t[Symbol.toPrimitive];
|
|
@@ -182,14 +182,14 @@ function toPrimitive(t, r) {
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
//#endregion
|
|
185
|
-
//#region \0@oxc-project+runtime@0.
|
|
185
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
|
|
186
186
|
function toPropertyKey(t) {
|
|
187
187
|
var i = toPrimitive(t, "string");
|
|
188
188
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
//#endregion
|
|
192
|
-
//#region \0@oxc-project+runtime@0.
|
|
192
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
|
|
193
193
|
function _defineProperty(e, r, t) {
|
|
194
194
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
195
195
|
value: t,
|
|
@@ -374,7 +374,7 @@ const menuSchema = { [RibbonOthersGroup.OTHERS]: { [RECORD_MENU_ITEM_ID]: {
|
|
|
374
374
|
//#endregion
|
|
375
375
|
//#region package.json
|
|
376
376
|
var name = "@univerjs/action-recorder";
|
|
377
|
-
var version = "1.0.0-
|
|
377
|
+
var version = "1.0.0-beta.0";
|
|
378
378
|
|
|
379
379
|
//#endregion
|
|
380
380
|
//#region src/config/config.ts
|
|
@@ -416,13 +416,12 @@ function RecorderPanel() {
|
|
|
416
416
|
return /* @__PURE__ */ jsx(RecordPanelImpl, {});
|
|
417
417
|
}
|
|
418
418
|
function RecordPanelImpl() {
|
|
419
|
-
var _recordedCommands$len;
|
|
420
419
|
const commandService = useDependency(ICommandService);
|
|
421
420
|
const localeService = useDependency(LocaleService);
|
|
422
421
|
const actionRecorderService = useDependency(ActionRecorderService);
|
|
423
422
|
const recording = useObservable(actionRecorderService.recording$);
|
|
424
423
|
const recordedCommands = useObservable(actionRecorderService.recordedCommands$);
|
|
425
|
-
const len = (
|
|
424
|
+
const len = (recordedCommands === null || recordedCommands === void 0 ? void 0 : recordedCommands.length) ?? 0;
|
|
426
425
|
const closePanel = useCallback(() => {
|
|
427
426
|
if (!recording) commandService.executeCommand(CloseRecordPanelOperation.id);
|
|
428
427
|
}, [commandService, recording]);
|
package/lib/es/locale/ru-RU.js
CHANGED
|
@@ -10,11 +10,11 @@ const locale = { "action-recorder": {
|
|
|
10
10
|
startWithId: "Начать (N)"
|
|
11
11
|
},
|
|
12
12
|
menu: {
|
|
13
|
-
title: "
|
|
14
|
-
record: "
|
|
15
|
-
"replay-local": "
|
|
16
|
-
"replay-local-name": "
|
|
17
|
-
"replay-local-active": "
|
|
13
|
+
title: "Запись действий",
|
|
14
|
+
record: "Записать действия...",
|
|
15
|
+
"replay-local": "Заменить локальную запись...",
|
|
16
|
+
"replay-local-name": "Заменить локальную запись по подразделению...",
|
|
17
|
+
"replay-local-active": "Заменить локальную запись по текущему подразделению..."
|
|
18
18
|
}
|
|
19
19
|
} };
|
|
20
20
|
|
package/lib/es/locale/vi-VN.js
CHANGED
|
@@ -10,11 +10,11 @@ const locale = { "action-recorder": {
|
|
|
10
10
|
startWithId: "Bắt đầu (N)"
|
|
11
11
|
},
|
|
12
12
|
menu: {
|
|
13
|
-
title: "
|
|
14
|
-
record: "
|
|
15
|
-
"replay-local": "
|
|
16
|
-
"replay-local-name": "
|
|
17
|
-
"replay-local-active": "
|
|
13
|
+
title: "Ghi hành động",
|
|
14
|
+
record: "Ghi hành động...",
|
|
15
|
+
"replay-local": "Thay bản ghi cục bộ...",
|
|
16
|
+
"replay-local-name": "Thay bản ghi cục bộ theo bộ phận...",
|
|
17
|
+
"replay-local-active": "Thay bản ghi cục bộ theo bộ phận hiện tại..."
|
|
18
18
|
}
|
|
19
19
|
} };
|
|
20
20
|
|
package/lib/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { RecordIcon } from "@univerjs/icons";
|
|
|
9
9
|
import { useCallback } from "react";
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
|
|
12
|
-
//#region \0@oxc-project+runtime@0.
|
|
12
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
|
|
13
13
|
function __decorateParam(paramIndex, decorator) {
|
|
14
14
|
return function(target, key) {
|
|
15
15
|
decorator(target, key, paramIndex);
|
|
@@ -17,7 +17,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
//#endregion
|
|
20
|
-
//#region \0@oxc-project+runtime@0.
|
|
20
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
|
|
21
21
|
function __decorate(decorators, target, key, desc) {
|
|
22
22
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
23
23
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -158,7 +158,7 @@ const ReplayLocalRecordOnActiveCommand = {
|
|
|
158
158
|
};
|
|
159
159
|
|
|
160
160
|
//#endregion
|
|
161
|
-
//#region \0@oxc-project+runtime@0.
|
|
161
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
|
|
162
162
|
function _typeof(o) {
|
|
163
163
|
"@babel/helpers - typeof";
|
|
164
164
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -169,7 +169,7 @@ function _typeof(o) {
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
//#endregion
|
|
172
|
-
//#region \0@oxc-project+runtime@0.
|
|
172
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
|
|
173
173
|
function toPrimitive(t, r) {
|
|
174
174
|
if ("object" != _typeof(t) || !t) return t;
|
|
175
175
|
var e = t[Symbol.toPrimitive];
|
|
@@ -182,14 +182,14 @@ function toPrimitive(t, r) {
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
//#endregion
|
|
185
|
-
//#region \0@oxc-project+runtime@0.
|
|
185
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
|
|
186
186
|
function toPropertyKey(t) {
|
|
187
187
|
var i = toPrimitive(t, "string");
|
|
188
188
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
//#endregion
|
|
192
|
-
//#region \0@oxc-project+runtime@0.
|
|
192
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
|
|
193
193
|
function _defineProperty(e, r, t) {
|
|
194
194
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
195
195
|
value: t,
|
|
@@ -374,7 +374,7 @@ const menuSchema = { [RibbonOthersGroup.OTHERS]: { [RECORD_MENU_ITEM_ID]: {
|
|
|
374
374
|
//#endregion
|
|
375
375
|
//#region package.json
|
|
376
376
|
var name = "@univerjs/action-recorder";
|
|
377
|
-
var version = "1.0.0-
|
|
377
|
+
var version = "1.0.0-beta.0";
|
|
378
378
|
|
|
379
379
|
//#endregion
|
|
380
380
|
//#region src/config/config.ts
|
|
@@ -416,13 +416,12 @@ function RecorderPanel() {
|
|
|
416
416
|
return /* @__PURE__ */ jsx(RecordPanelImpl, {});
|
|
417
417
|
}
|
|
418
418
|
function RecordPanelImpl() {
|
|
419
|
-
var _recordedCommands$len;
|
|
420
419
|
const commandService = useDependency(ICommandService);
|
|
421
420
|
const localeService = useDependency(LocaleService);
|
|
422
421
|
const actionRecorderService = useDependency(ActionRecorderService);
|
|
423
422
|
const recording = useObservable(actionRecorderService.recording$);
|
|
424
423
|
const recordedCommands = useObservable(actionRecorderService.recordedCommands$);
|
|
425
|
-
const len = (
|
|
424
|
+
const len = (recordedCommands === null || recordedCommands === void 0 ? void 0 : recordedCommands.length) ?? 0;
|
|
426
425
|
const closePanel = useCallback(() => {
|
|
427
426
|
if (!recording) commandService.executeCommand(CloseRecordPanelOperation.id);
|
|
428
427
|
}, [commandService, recording]);
|
package/lib/locale/ru-RU.js
CHANGED
|
@@ -10,11 +10,11 @@ const locale = { "action-recorder": {
|
|
|
10
10
|
startWithId: "Начать (N)"
|
|
11
11
|
},
|
|
12
12
|
menu: {
|
|
13
|
-
title: "
|
|
14
|
-
record: "
|
|
15
|
-
"replay-local": "
|
|
16
|
-
"replay-local-name": "
|
|
17
|
-
"replay-local-active": "
|
|
13
|
+
title: "Запись действий",
|
|
14
|
+
record: "Записать действия...",
|
|
15
|
+
"replay-local": "Заменить локальную запись...",
|
|
16
|
+
"replay-local-name": "Заменить локальную запись по подразделению...",
|
|
17
|
+
"replay-local-active": "Заменить локальную запись по текущему подразделению..."
|
|
18
18
|
}
|
|
19
19
|
} };
|
|
20
20
|
|
package/lib/locale/vi-VN.js
CHANGED
|
@@ -10,11 +10,11 @@ const locale = { "action-recorder": {
|
|
|
10
10
|
startWithId: "Bắt đầu (N)"
|
|
11
11
|
},
|
|
12
12
|
menu: {
|
|
13
|
-
title: "
|
|
14
|
-
record: "
|
|
15
|
-
"replay-local": "
|
|
16
|
-
"replay-local-name": "
|
|
17
|
-
"replay-local-active": "
|
|
13
|
+
title: "Ghi hành động",
|
|
14
|
+
record: "Ghi hành động...",
|
|
15
|
+
"replay-local": "Thay bản ghi cục bộ...",
|
|
16
|
+
"replay-local-name": "Thay bản ghi cục bộ theo bộ phận...",
|
|
17
|
+
"replay-local-active": "Thay bản ghi cục bộ theo bộ phận hiện tại..."
|
|
18
18
|
}
|
|
19
19
|
} };
|
|
20
20
|
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/ui"),require("@univerjs/core"),require("@univerjs/design"),require("@univerjs/sheets"),require("rxjs"),require("@univerjs/sheets-filter"),require("@univerjs/sheets-ui"),require("react"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/ui`,`@univerjs/core`,`@univerjs/design`,`@univerjs/sheets`,`rxjs`,`@univerjs/sheets-filter`,`@univerjs/sheets-ui`,`react`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverActionRecorder={},e.UniverUi,e.UniverCore,e.UniverDesign,e.UniverSheets,e.rxjs,e.UniverSheetsFilter,e.UniverSheetsUi,e.React,e.React))})(this,function(e,t,n,r,i,a,o,s,c,l){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function u(e,t){return function(n,r){t(n,r,e)}}function d(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 f=class extends n.Disposable{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=`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:r.MessageType.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===`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===`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 r=(t=this._instanceService.getFocusedUnit())==null?void 0:t.getUnitId();r||this._logService.error(`[ReplayService]`,`no focused unit to replay commands`);for(let t of e){await(0,n.awaitTime)(p());let{id:e,params:i}=t;if(i){if(i.unitId!==void 0&&(i.unitId=r),!await this._commandService.executeCommand(e,i))return!1}else if(!await this._commandService.executeCommand(e))return!1}return!0}};f=d([u(0,t.IMessageService),u(1,n.IUniverInstanceService),u(2,t.ILocalFileService),u(3,n.ILogService),u(4,n.ICommandService)],f);function p(){return Math.floor(Math.random()*800)+200}let m={id:`action-recorder.command.replay-local-records`,type:n.CommandType.COMMAND,handler:async e=>{let n=await e.get(f).replayLocalJSON();return n&&e.get(t.IMessageService).show({type:r.MessageType.Success,content:`Successfully replayed local records`}),n}},h={id:`action-recorder.command.replay-local-records-name`,type:n.CommandType.COMMAND,handler:async e=>{let n=await e.get(f).replayLocalJSON(`name`);return n&&e.get(t.IMessageService).show({type:r.MessageType.Success,content:`Successfully replayed local records`}),n}},g={id:`action-recorder.command.replay-local-records-active`,type:n.CommandType.COMMAND,handler:async e=>{let n=await e.get(f).replayLocalJSON(`active`);return n&&e.get(t.IMessageService).show({type:r.MessageType.Success,content:`Successfully replayed local records`}),n}};function _(e){"@babel/helpers - typeof";return _=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},_(e)}function v(e,t){if(_(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(_(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function y(e){var t=v(e,`string`);return _(t)==`symbol`?t:t+``}function b(e,t,n){return(t=y(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let x=class extends n.Disposable{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,b(this,`_shouldRecordCommands`,new Set),b(this,`_panelOpened$`,new a.BehaviorSubject(!1)),b(this,`panelOpened$`,this._panelOpened$.asObservable()),b(this,`_recorder`,null),b(this,`_recording$`,new a.BehaviorSubject(!1)),b(this,`recording$`,this._recording$.asObservable()),b(this,`_recorded$`,new a.BehaviorSubject([])),b(this,`_recordedCommands$`,new a.BehaviorSubject([])),b(this,`recordedCommands$`,this._recordedCommands$.asObservable())}registerRecordedCommand(e){if(e.type===n.CommandType.MUTATION)throw Error(`[CommandRecorderService] Cannot record mutation commands.`);this._shouldRecordCommands.add(e.id)}togglePanel(e){this._panelOpened$.next(e),e===!1&&this.stopRecording()}startRecording(e=!1){this._recorder=this._commandSrv.onCommandExecuted(t=>{if(this._shouldRecordCommands.has(t.id)){var r;let o=this._recorded,s=this._recordedCommands,c={...t},l=(r=this._instanceService.getFocusedUnit())==null?void 0:r.getUnitId(),{unitId:u=l,subUnitId:d}=c==null?void 0:c.params;if(e&&u&&d){var a;let e=(a=this._instanceService.getUnit(u).getSheetBySheetId(d))==null?void 0:a.getName();c={...c,params:{...c.params,subUnitId:e}}}c.id===i.SetSelectionsOperation.id&&o.length>0&&o[o.length-1].id===i.SetSelectionsOperation.id?o[o.length-1]=c:(o.push(c),this._recorded$.next(o),c.type===n.CommandType.COMMAND&&(s.push(c),this._recordedCommands$.next(s)))}}),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()}};x=d([u(0,n.ICommandService),u(1,n.ILogService),u(2,t.ILocalFileService),u(3,n.IUniverInstanceService)],x);let S={id:`action-recorder.operation.open-panel`,type:n.CommandType.OPERATION,handler(e){return e.get(x).togglePanel(!0),!0}},C={id:`action-recorder.operation.close-panel`,type:n.CommandType.OPERATION,handler(e){return e.get(x).togglePanel(!1),!0}},w=`RECORD_MENU_ITEM`;function T(){return{id:w,type:t.MenuItemType.SUBITEMS,icon:`RecordIcon`,tooltip:`action-recorder.menu.title`}}function E(e){let n=e.get(x);return{id:S.id,title:`action-recorder.menu.record`,type:t.MenuItemType.BUTTON,disabled$:n.panelOpened$}}function D(){return{id:m.id,title:`action-recorder.menu.replay-local`,type:t.MenuItemType.BUTTON}}function O(){return{id:h.id,title:`action-recorder.menu.replay-local-name`,type:t.MenuItemType.BUTTON}}function k(){return{id:g.id,title:`action-recorder.menu.replay-local-active`,type:t.MenuItemType.BUTTON}}let A={[t.RibbonOthersGroup.OTHERS]:{[w]:{order:1,menuItemFactory:T,[S.id]:{order:1,menuItemFactory:E},[m.id]:{order:2,menuItemFactory:D},[h.id]:{order:3,menuItemFactory:O},[g.id]:{order:4,menuItemFactory:k}}}};var j=`@univerjs/action-recorder`,M=`1.0.0-alpha.7`;let N={},P={id:`action-recorder.command.start-recording`,type:n.CommandType.COMMAND,handler:(e,t)=>(e.get(x).startRecording(!!(t!=null&&t.replaceId)),!0)},F={id:`action-recorder.command.complete-recording`,type:n.CommandType.COMMAND,handler:e=>(e.get(x).completeRecording(),!0)},I={id:`action-recorder.command.stop-recording`,type:n.CommandType.COMMAND,handler:e=>(e.get(x).completeRecording(),!0)};function L({ref:e,...t}){let{icon:n,id:r,className:i,extend:a,...o}=t,s=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),l=(0,c.useRef)(`_${V()}`);return R(n,`${r}`,{defIds:n.defIds,idSuffix:l.current},{ref:e,className:s,...o},a)}function R(e,t,n,r,i){return(0,c.createElement)(e.tag,{key:t,...z(e,n,i),...r},(B(e,n).children||[]).map((r,a)=>R(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function z(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function B(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function V(){return Math.random().toString(36).substring(2,8)}L.displayName=`UniverIcon`;let H={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`g`,attrs:{fill:`currentColor`,clipPath:`url(#record-icon_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-icon_clip0_1559_19`},children:[{tag:`path`,attrs:{fill:`white`,d:`M0 0H16V16H0z`,transform:`translate(.94)`}}]}]}],defIds:[`record-icon_clip0_1559_19`]},U=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(L,Object.assign({},e,{id:`record-icon`,ref:t,icon:H}))});U.displayName=`RecordIcon`;function W(){return(0,t.useObservable)((0,t.useDependency)(x).panelOpened$)?(0,l.jsx)(G,{}):null}function G(){var e;let i=(0,t.useDependency)(n.ICommandService),a=(0,t.useDependency)(n.LocaleService),o=(0,t.useDependency)(x),s=(0,t.useObservable)(o.recording$),u=(0,t.useObservable)(o.recordedCommands$),d=(e=u==null?void 0:u.length)==null?0:e,f=(0,c.useCallback)(()=>{s||i.executeCommand(C.id)},[i,s]),p=(0,c.useCallback)(e=>{s||i.executeCommand(P.id,{replaceId:e})},[i,s]),m=(0,c.useCallback)(()=>{s&&i.executeCommand(F.id)},[i,s]),h=(0,c.useCallback)(()=>{s&&i.executeCommand(I.id)},[i,s]),g=s?d===0?a.t(`action-recorder.panel.recording`):`${d}: ${u[d-1].id}`:a.t(`action-recorder.panel.startRecording`);return(0,l.jsxs)(`div`,{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`,children:[(0,l.jsx)(`div`,{className:`univer-mr-2 univer-size-5 univer-shrink-0 univer-grow-0 univer-text-xl`,children:(0,l.jsx)(U,{})}),(0,l.jsx)(`div`,{className:`univer-flex-1 univer-text-sm`,children:g}),(0,l.jsxs)(`div`,{className:`univer-flex univer-w-64 univer-shrink-0 univer-grow-0 univer-justify-between`,children:[(0,l.jsx)(r.Button,{className:`univer-w-20`,onClick:s?h:f,children:a.t(s?`action-recorder.panel.cancel`:`action-recorder.panel.close`)}),(0,l.jsx)(r.Button,{className:`univer-w-20`,variant:`primary`,onClick:s?m:()=>p(),children:a.t(s?`action-recorder.panel.save`:`action-recorder.panel.start`)}),!s&&(0,l.jsx)(r.Button,{variant:`primary`,onClick:()=>p(!0),children:a.t(`action-recorder.panel.startWithId`)})]})]})}let K=class extends n.Disposable{constructor(e,t,n,r,i){super(),this._commandSrv=e,this._uiPartsSrv=t,this._menuManagerService=n,this._actionRecorderService=r,this._injector=i,this._initCommands(),this._initUI(),this._initSheetsCommands(),this._initDocsCommands()}_initCommands(){[P,I,F,S,C,m,h,g].forEach(e=>this._commandSrv.registerCommand(e))}_initUI(){this._uiPartsSrv.registerComponent(t.BuiltInUIPart.GLOBAL,()=>(0,t.connectInjector)(W,this._injector)),this._menuManagerService.mergeMenu(A)}_initSheetsCommands(){[i.CopySheetCommand,i.DeleteRangeMoveLeftCommand,i.DeleteRangeMoveUpCommand,i.DeltaColumnWidthCommand,i.DeltaRowHeightCommand,i.InsertSheetCommand,i.InsertColAfterCommand,i.InsertColBeforeCommand,i.InsertRowAfterCommand,i.InsertRowBeforeCommand,i.RemoveSheetCommand,i.SetStyleCommand,i.AddWorksheetMergeCommand,i.AddWorksheetMergeAllCommand,i.AddWorksheetMergeVerticalCommand,i.AddWorksheetMergeHorizontalCommand,i.SetFrozenCommand,i.CancelFrozenCommand,i.SetHorizontalTextAlignCommand,i.SetOverlineCommand,s.SetRangeBoldCommand,s.SetRangeFontFamilyCommand,s.SetRangeFontSizeCommand,s.SetRangeItalicCommand,s.SetRangeStrickThroughCommand,s.SetRangeSubscriptCommand,s.SetRangeSuperscriptCommand,s.SetRangeTextColorCommand,s.SetRangeUnderlineCommand,i.SetRangeValuesCommand,i.SetStrikeThroughCommand,i.SetTextColorCommand,i.SetTextRotationCommand,i.SetTextWrapCommand,i.SetVerticalTextAlignCommand,s.SheetCopyCommand,s.SheetCutCommand,s.SheetPasteBesidesBorderCommand,s.SheetPasteColWidthCommand,s.SheetPasteCommand,s.SheetPasteFormatCommand,s.SheetPasteShortKeyCommand,s.SheetPasteValueCommand,i.AutoFillCommand,i.RefillCommand,i.SetWorksheetActivateCommand,i.SetWorksheetActiveOperation,i.SetSelectionsOperation,o.SetSheetFilterRangeCommand,o.SetSheetsFilterCriteriaCommand,o.RemoveSheetFilterCommand].forEach(e=>this._actionRecorderService.registerRecordedCommand(e))}_initDocsCommands(){}};K=d([u(0,n.ICommandService),u(1,t.IUIPartsService),u(2,t.IMenuManagerService),u(3,(0,n.Inject)(x)),u(4,(0,n.Inject)(n.Injector))],K);let q=class extends n.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerIcons()}_registerIcons(){this.disposeWithMe(this._iconManager.register({RecordIcon:U}))}};q=d([u(0,(0,n.Inject)(t.ComponentManager)),u(1,(0,n.Inject)(t.IconManager))],q);let J=class extends n.Plugin{constructor(e=N,t,r){super(),this._config=e,this._injector=t,this._configService=r;let{menu:i,...a}=(0,n.merge)({},N,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(`action-recorder.config`,a)}onStarting(){this._injector.add([q]),this._injector.get(q),(this._config.replayOnly?[[f]]:[[x],[f],[K]]).forEach(e=>this._injector.add(e))}onSteady(){this._config.replayOnly||this._injector.get(K)}};b(J,`pluginName`,`UNIVER_ACTION_RECORDER_PLUGIN`),b(J,`packageName`,j),b(J,`version`,M),J=d([u(1,(0,n.Inject)(n.Injector)),u(2,n.IConfigService)],J),e.ActionRecorderMenuSchema=A,Object.defineProperty(e,"ActionRecorderService",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"ActionReplayService",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"UniverActionRecorderPlugin",{enumerable:!0,get:function(){return J}})});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/ui"),require("@univerjs/core"),require("@univerjs/design"),require("@univerjs/sheets"),require("rxjs"),require("@univerjs/sheets-filter"),require("@univerjs/sheets-ui"),require("react"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/ui`,`@univerjs/core`,`@univerjs/design`,`@univerjs/sheets`,`rxjs`,`@univerjs/sheets-filter`,`@univerjs/sheets-ui`,`react`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverActionRecorder={},e.UniverUi,e.UniverCore,e.UniverDesign,e.UniverSheets,e.rxjs,e.UniverSheetsFilter,e.UniverSheetsUi,e.React,e.React))})(this,function(e,t,n,r,i,a,o,s,c,l){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function u(e,t){return function(n,r){t(n,r,e)}}function d(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 f=class extends n.Disposable{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=`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:r.MessageType.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===`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===`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 r=(t=this._instanceService.getFocusedUnit())==null?void 0:t.getUnitId();r||this._logService.error(`[ReplayService]`,`no focused unit to replay commands`);for(let t of e){await(0,n.awaitTime)(p());let{id:e,params:i}=t;if(i){if(i.unitId!==void 0&&(i.unitId=r),!await this._commandService.executeCommand(e,i))return!1}else if(!await this._commandService.executeCommand(e))return!1}return!0}};f=d([u(0,t.IMessageService),u(1,n.IUniverInstanceService),u(2,t.ILocalFileService),u(3,n.ILogService),u(4,n.ICommandService)],f);function p(){return Math.floor(Math.random()*800)+200}let m={id:`action-recorder.command.replay-local-records`,type:n.CommandType.COMMAND,handler:async e=>{let n=await e.get(f).replayLocalJSON();return n&&e.get(t.IMessageService).show({type:r.MessageType.Success,content:`Successfully replayed local records`}),n}},h={id:`action-recorder.command.replay-local-records-name`,type:n.CommandType.COMMAND,handler:async e=>{let n=await e.get(f).replayLocalJSON(`name`);return n&&e.get(t.IMessageService).show({type:r.MessageType.Success,content:`Successfully replayed local records`}),n}},g={id:`action-recorder.command.replay-local-records-active`,type:n.CommandType.COMMAND,handler:async e=>{let n=await e.get(f).replayLocalJSON(`active`);return n&&e.get(t.IMessageService).show({type:r.MessageType.Success,content:`Successfully replayed local records`}),n}};function _(e){"@babel/helpers - typeof";return _=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},_(e)}function v(e,t){if(_(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(_(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function y(e){var t=v(e,`string`);return _(t)==`symbol`?t:t+``}function b(e,t,n){return(t=y(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let x=class extends n.Disposable{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,b(this,`_shouldRecordCommands`,new Set),b(this,`_panelOpened$`,new a.BehaviorSubject(!1)),b(this,`panelOpened$`,this._panelOpened$.asObservable()),b(this,`_recorder`,null),b(this,`_recording$`,new a.BehaviorSubject(!1)),b(this,`recording$`,this._recording$.asObservable()),b(this,`_recorded$`,new a.BehaviorSubject([])),b(this,`_recordedCommands$`,new a.BehaviorSubject([])),b(this,`recordedCommands$`,this._recordedCommands$.asObservable())}registerRecordedCommand(e){if(e.type===n.CommandType.MUTATION)throw Error(`[CommandRecorderService] Cannot record mutation commands.`);this._shouldRecordCommands.add(e.id)}togglePanel(e){this._panelOpened$.next(e),e===!1&&this.stopRecording()}startRecording(e=!1){this._recorder=this._commandSrv.onCommandExecuted(t=>{if(this._shouldRecordCommands.has(t.id)){var r;let o=this._recorded,s=this._recordedCommands,c={...t},l=(r=this._instanceService.getFocusedUnit())==null?void 0:r.getUnitId(),{unitId:u=l,subUnitId:d}=c==null?void 0:c.params;if(e&&u&&d){var a;let e=(a=this._instanceService.getUnit(u).getSheetBySheetId(d))==null?void 0:a.getName();c={...c,params:{...c.params,subUnitId:e}}}c.id===i.SetSelectionsOperation.id&&o.length>0&&o[o.length-1].id===i.SetSelectionsOperation.id?o[o.length-1]=c:(o.push(c),this._recorded$.next(o),c.type===n.CommandType.COMMAND&&(s.push(c),this._recordedCommands$.next(s)))}}),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()}};x=d([u(0,n.ICommandService),u(1,n.ILogService),u(2,t.ILocalFileService),u(3,n.IUniverInstanceService)],x);let S={id:`action-recorder.operation.open-panel`,type:n.CommandType.OPERATION,handler(e){return e.get(x).togglePanel(!0),!0}},C={id:`action-recorder.operation.close-panel`,type:n.CommandType.OPERATION,handler(e){return e.get(x).togglePanel(!1),!0}},w=`RECORD_MENU_ITEM`;function T(){return{id:w,type:t.MenuItemType.SUBITEMS,icon:`RecordIcon`,tooltip:`action-recorder.menu.title`}}function E(e){let n=e.get(x);return{id:S.id,title:`action-recorder.menu.record`,type:t.MenuItemType.BUTTON,disabled$:n.panelOpened$}}function D(){return{id:m.id,title:`action-recorder.menu.replay-local`,type:t.MenuItemType.BUTTON}}function O(){return{id:h.id,title:`action-recorder.menu.replay-local-name`,type:t.MenuItemType.BUTTON}}function k(){return{id:g.id,title:`action-recorder.menu.replay-local-active`,type:t.MenuItemType.BUTTON}}let A={[t.RibbonOthersGroup.OTHERS]:{[w]:{order:1,menuItemFactory:T,[S.id]:{order:1,menuItemFactory:E},[m.id]:{order:2,menuItemFactory:D},[h.id]:{order:3,menuItemFactory:O},[g.id]:{order:4,menuItemFactory:k}}}};var j=`@univerjs/action-recorder`,M=`1.0.0-beta.0`;let N={},P={id:`action-recorder.command.start-recording`,type:n.CommandType.COMMAND,handler:(e,t)=>(e.get(x).startRecording(!!(t!=null&&t.replaceId)),!0)},F={id:`action-recorder.command.complete-recording`,type:n.CommandType.COMMAND,handler:e=>(e.get(x).completeRecording(),!0)},I={id:`action-recorder.command.stop-recording`,type:n.CommandType.COMMAND,handler:e=>(e.get(x).completeRecording(),!0)};function L({ref:e,...t}){let{icon:n,id:r,className:i,extend:a,...o}=t,s=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),l=(0,c.useRef)(`_${V()}`);return R(n,`${r}`,{defIds:n.defIds,idSuffix:l.current},{ref:e,className:s,...o},a)}function R(e,t,n,r,i){return(0,c.createElement)(e.tag,{key:t,...z(e,n,i),...r},(B(e,n).children||[]).map((r,a)=>R(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function z(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function B(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function V(){return Math.random().toString(36).substring(2,8)}L.displayName=`UniverIcon`;let H={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`g`,attrs:{fill:`currentColor`,clipPath:`url(#record-icon_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-icon_clip0_1559_19`},children:[{tag:`path`,attrs:{fill:`white`,d:`M0 0H16V16H0z`,transform:`translate(.94)`}}]}]}],defIds:[`record-icon_clip0_1559_19`]},U=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(L,Object.assign({},e,{id:`record-icon`,ref:t,icon:H}))});U.displayName=`RecordIcon`;function W(){return(0,t.useObservable)((0,t.useDependency)(x).panelOpened$)?(0,l.jsx)(G,{}):null}function G(){let e=(0,t.useDependency)(n.ICommandService),i=(0,t.useDependency)(n.LocaleService),a=(0,t.useDependency)(x),o=(0,t.useObservable)(a.recording$),s=(0,t.useObservable)(a.recordedCommands$),u=(s==null?void 0:s.length)??0,d=(0,c.useCallback)(()=>{o||e.executeCommand(C.id)},[e,o]),f=(0,c.useCallback)(t=>{o||e.executeCommand(P.id,{replaceId:t})},[e,o]),p=(0,c.useCallback)(()=>{o&&e.executeCommand(F.id)},[e,o]),m=(0,c.useCallback)(()=>{o&&e.executeCommand(I.id)},[e,o]),h=o?u===0?i.t(`action-recorder.panel.recording`):`${u}: ${s[u-1].id}`:i.t(`action-recorder.panel.startRecording`);return(0,l.jsxs)(`div`,{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`,children:[(0,l.jsx)(`div`,{className:`univer-mr-2 univer-size-5 univer-shrink-0 univer-grow-0 univer-text-xl`,children:(0,l.jsx)(U,{})}),(0,l.jsx)(`div`,{className:`univer-flex-1 univer-text-sm`,children:h}),(0,l.jsxs)(`div`,{className:`univer-flex univer-w-64 univer-shrink-0 univer-grow-0 univer-justify-between`,children:[(0,l.jsx)(r.Button,{className:`univer-w-20`,onClick:o?m:d,children:i.t(o?`action-recorder.panel.cancel`:`action-recorder.panel.close`)}),(0,l.jsx)(r.Button,{className:`univer-w-20`,variant:`primary`,onClick:o?p:()=>f(),children:i.t(o?`action-recorder.panel.save`:`action-recorder.panel.start`)}),!o&&(0,l.jsx)(r.Button,{variant:`primary`,onClick:()=>f(!0),children:i.t(`action-recorder.panel.startWithId`)})]})]})}let K=class extends n.Disposable{constructor(e,t,n,r,i){super(),this._commandSrv=e,this._uiPartsSrv=t,this._menuManagerService=n,this._actionRecorderService=r,this._injector=i,this._initCommands(),this._initUI(),this._initSheetsCommands(),this._initDocsCommands()}_initCommands(){[P,I,F,S,C,m,h,g].forEach(e=>this._commandSrv.registerCommand(e))}_initUI(){this._uiPartsSrv.registerComponent(t.BuiltInUIPart.GLOBAL,()=>(0,t.connectInjector)(W,this._injector)),this._menuManagerService.mergeMenu(A)}_initSheetsCommands(){[i.CopySheetCommand,i.DeleteRangeMoveLeftCommand,i.DeleteRangeMoveUpCommand,i.DeltaColumnWidthCommand,i.DeltaRowHeightCommand,i.InsertSheetCommand,i.InsertColAfterCommand,i.InsertColBeforeCommand,i.InsertRowAfterCommand,i.InsertRowBeforeCommand,i.RemoveSheetCommand,i.SetStyleCommand,i.AddWorksheetMergeCommand,i.AddWorksheetMergeAllCommand,i.AddWorksheetMergeVerticalCommand,i.AddWorksheetMergeHorizontalCommand,i.SetFrozenCommand,i.CancelFrozenCommand,i.SetHorizontalTextAlignCommand,i.SetOverlineCommand,s.SetRangeBoldCommand,s.SetRangeFontFamilyCommand,s.SetRangeFontSizeCommand,s.SetRangeItalicCommand,s.SetRangeStrickThroughCommand,s.SetRangeSubscriptCommand,s.SetRangeSuperscriptCommand,s.SetRangeTextColorCommand,s.SetRangeUnderlineCommand,i.SetRangeValuesCommand,i.SetStrikeThroughCommand,i.SetTextColorCommand,i.SetTextRotationCommand,i.SetTextWrapCommand,i.SetVerticalTextAlignCommand,s.SheetCopyCommand,s.SheetCutCommand,s.SheetPasteBesidesBorderCommand,s.SheetPasteColWidthCommand,s.SheetPasteCommand,s.SheetPasteFormatCommand,s.SheetPasteShortKeyCommand,s.SheetPasteValueCommand,i.AutoFillCommand,i.RefillCommand,i.SetWorksheetActivateCommand,i.SetWorksheetActiveOperation,i.SetSelectionsOperation,o.SetSheetFilterRangeCommand,o.SetSheetsFilterCriteriaCommand,o.RemoveSheetFilterCommand].forEach(e=>this._actionRecorderService.registerRecordedCommand(e))}_initDocsCommands(){}};K=d([u(0,n.ICommandService),u(1,t.IUIPartsService),u(2,t.IMenuManagerService),u(3,(0,n.Inject)(x)),u(4,(0,n.Inject)(n.Injector))],K);let q=class extends n.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerIcons()}_registerIcons(){this.disposeWithMe(this._iconManager.register({RecordIcon:U}))}};q=d([u(0,(0,n.Inject)(t.ComponentManager)),u(1,(0,n.Inject)(t.IconManager))],q);let J=class extends n.Plugin{constructor(e=N,t,r){super(),this._config=e,this._injector=t,this._configService=r;let{menu:i,...a}=(0,n.merge)({},N,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(`action-recorder.config`,a)}onStarting(){this._injector.add([q]),this._injector.get(q),(this._config.replayOnly?[[f]]:[[x],[f],[K]]).forEach(e=>this._injector.add(e))}onSteady(){this._config.replayOnly||this._injector.get(K)}};b(J,`pluginName`,`UNIVER_ACTION_RECORDER_PLUGIN`),b(J,`packageName`,j),b(J,`version`,M),J=d([u(1,(0,n.Inject)(n.Injector)),u(2,n.IConfigService)],J),e.ActionRecorderMenuSchema=A,Object.defineProperty(e,"ActionRecorderService",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"ActionReplayService",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"UniverActionRecorderPlugin",{enumerable:!0,get:function(){return J}})});
|
package/lib/umd/locale/ru-RU.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t():typeof define==`function`&&define.amd?define([],t):(e=typeof globalThis<`u`?globalThis:e||self,e.UniverActionRecorderRuRU=t())})(this,function(){return{"action-recorder":{panel:{recording:`Запись...`,startRecording:`Начать запись`,cancel:`Отмена`,close:`Закрыть`,save:`Сохранить`,start:`Начать`,startWithId:`Начать (N)`},menu:{title
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t():typeof define==`function`&&define.amd?define([],t):(e=typeof globalThis<`u`?globalThis:e||self,e.UniverActionRecorderRuRU=t())})(this,function(){return{"action-recorder":{panel:{recording:`Запись...`,startRecording:`Начать запись`,cancel:`Отмена`,close:`Закрыть`,save:`Сохранить`,start:`Начать`,startWithId:`Начать (N)`},menu:{title:`Запись действий`,record:`Записать действия...`,"replay-local":`Заменить локальную запись...`,"replay-local-name":`Заменить локальную запись по подразделению...`,"replay-local-active":`Заменить локальную запись по текущему подразделению...`}}}});
|
package/lib/umd/locale/vi-VN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t():typeof define==`function`&&define.amd?define([],t):(e=typeof globalThis<`u`?globalThis:e||self,e.UniverActionRecorderViVN=t())})(this,function(){return{"action-recorder":{panel:{recording:`Đang ghi...`,startRecording:`Bắt đầu ghi`,cancel:`Hủy`,close:`Đóng`,save:`Lưu`,start:`Bắt đầu`,startWithId:`Bắt đầu (N)`},menu:{title:`
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t():typeof define==`function`&&define.amd?define([],t):(e=typeof globalThis<`u`?globalThis:e||self,e.UniverActionRecorderViVN=t())})(this,function(){return{"action-recorder":{panel:{recording:`Đang ghi...`,startRecording:`Bắt đầu ghi`,cancel:`Hủy`,close:`Đóng`,save:`Lưu`,start:`Bắt đầu`,startWithId:`Bắt đầu (N)`},menu:{title:`Ghi hành động`,record:`Ghi hành động...`,"replay-local":`Thay bản ghi cục bộ...`,"replay-local-name":`Thay bản ghi cục bộ theo bộ phận...`,"replay-local-active":`Thay bản ghi cục bộ theo bộ phận hiện tại...`}}}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/action-recorder",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Record and replay user actions in Univer.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -58,13 +58,13 @@
|
|
|
58
58
|
"rxjs": ">=7.0.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@univerjs/icons": "1.
|
|
62
|
-
"@univerjs/core": "1.0.0-
|
|
63
|
-
"@univerjs/design": "1.0.0-
|
|
64
|
-
"@univerjs/sheets": "1.0.0-
|
|
65
|
-
"@univerjs/sheets-
|
|
66
|
-
"@univerjs/ui": "1.0.0-
|
|
67
|
-
"@univerjs/sheets-
|
|
61
|
+
"@univerjs/icons": "1.35.0",
|
|
62
|
+
"@univerjs/core": "1.0.0-beta.0",
|
|
63
|
+
"@univerjs/design": "1.0.0-beta.0",
|
|
64
|
+
"@univerjs/sheets": "1.0.0-beta.0",
|
|
65
|
+
"@univerjs/sheets-ui": "1.0.0-beta.0",
|
|
66
|
+
"@univerjs/ui": "1.0.0-beta.0",
|
|
67
|
+
"@univerjs/sheets-filter": "1.0.0-beta.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"react": "18.3.1",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"tailwindcss": "3.4.18",
|
|
73
73
|
"typescript": "^6.0.3",
|
|
74
74
|
"vitest": "^4.1.10",
|
|
75
|
-
"@univerjs-infra/shared": "1.0.0-
|
|
75
|
+
"@univerjs-infra/shared": "1.0.0-beta.0"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|
|
78
78
|
"test": "vitest run",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
export {};
|