@univerjs/action-recorder 0.25.1 → 1.0.0-alpha.1
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 +43 -14
- package/lib/es/index.js +44 -15
- package/lib/index.js +44 -15
- package/lib/types/controllers/action-recorder.controller.d.ts +2 -3
- package/lib/types/controllers/components.controller.d.ts +23 -0
- package/lib/types/{controllers/action-recorder.controller.spec.d.ts → locale/types.d.ts} +3 -1
- package/lib/types/menu/action-recorder.menu.d.ts +6 -5
- package/lib/types/views/components/RecorderPanel.d.ts +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +10 -10
package/lib/cjs/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
let _univerjs_core = require("@univerjs/core");
|
|
3
|
-
let _univerjs_icons = require("@univerjs/icons");
|
|
4
3
|
let _univerjs_sheets = require("@univerjs/sheets");
|
|
5
4
|
let _univerjs_sheets_filter = require("@univerjs/sheets-filter");
|
|
6
5
|
let _univerjs_sheets_ui = require("@univerjs/sheets-ui");
|
|
7
6
|
let _univerjs_ui = require("@univerjs/ui");
|
|
8
7
|
let rxjs = require("rxjs");
|
|
9
8
|
let _univerjs_design = require("@univerjs/design");
|
|
9
|
+
let _univerjs_icons = require("@univerjs/icons");
|
|
10
10
|
let react = require("react");
|
|
11
11
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
12
|
|
|
13
13
|
//#region package.json
|
|
14
14
|
var name = "@univerjs/action-recorder";
|
|
15
|
-
var version = "0.
|
|
15
|
+
var version = "1.0.0-alpha.1";
|
|
16
16
|
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/config/config.ts
|
|
@@ -21,7 +21,7 @@ const configSymbol = Symbol(ACTION_RECORDER_PLUGIN_CONFIG_KEY);
|
|
|
21
21
|
const defaultPluginConfig = {};
|
|
22
22
|
|
|
23
23
|
//#endregion
|
|
24
|
-
//#region \0@oxc-project+runtime@0.
|
|
24
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
25
25
|
function _typeof(o) {
|
|
26
26
|
"@babel/helpers - typeof";
|
|
27
27
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -32,7 +32,7 @@ function _typeof(o) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
//#endregion
|
|
35
|
-
//#region \0@oxc-project+runtime@0.
|
|
35
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
36
36
|
function toPrimitive(t, r) {
|
|
37
37
|
if ("object" != _typeof(t) || !t) return t;
|
|
38
38
|
var e = t[Symbol.toPrimitive];
|
|
@@ -45,14 +45,14 @@ function toPrimitive(t, r) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
//#endregion
|
|
48
|
-
//#region \0@oxc-project+runtime@0.
|
|
48
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
49
49
|
function toPropertyKey(t) {
|
|
50
50
|
var i = toPrimitive(t, "string");
|
|
51
51
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
//#endregion
|
|
55
|
-
//#region \0@oxc-project+runtime@0.
|
|
55
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
56
56
|
function _defineProperty(e, r, t) {
|
|
57
57
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
58
58
|
value: t,
|
|
@@ -63,7 +63,7 @@ function _defineProperty(e, r, t) {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
//#endregion
|
|
66
|
-
//#region \0@oxc-project+runtime@0.
|
|
66
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
|
|
67
67
|
function __decorateParam(paramIndex, decorator) {
|
|
68
68
|
return function(target, key) {
|
|
69
69
|
decorator(target, key, paramIndex);
|
|
@@ -71,7 +71,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
//#endregion
|
|
74
|
-
//#region \0@oxc-project+runtime@0.
|
|
74
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
|
|
75
75
|
function __decorate(decorators, target, key, desc) {
|
|
76
76
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
77
77
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -505,12 +505,11 @@ function RecordPanelImpl() {
|
|
|
505
505
|
* limitations under the License.
|
|
506
506
|
*/
|
|
507
507
|
let ActionRecorderController = class ActionRecorderController extends _univerjs_core.Disposable {
|
|
508
|
-
constructor(_commandSrv, _uiPartsSrv, _menuManagerService,
|
|
508
|
+
constructor(_commandSrv, _uiPartsSrv, _menuManagerService, _actionRecorderService, _injector) {
|
|
509
509
|
super();
|
|
510
510
|
this._commandSrv = _commandSrv;
|
|
511
511
|
this._uiPartsSrv = _uiPartsSrv;
|
|
512
512
|
this._menuManagerService = _menuManagerService;
|
|
513
|
-
this._componentManager = _componentManager;
|
|
514
513
|
this._actionRecorderService = _actionRecorderService;
|
|
515
514
|
this._injector = _injector;
|
|
516
515
|
this._initCommands();
|
|
@@ -532,7 +531,6 @@ let ActionRecorderController = class ActionRecorderController extends _univerjs_
|
|
|
532
531
|
}
|
|
533
532
|
_initUI() {
|
|
534
533
|
this._uiPartsSrv.registerComponent(_univerjs_ui.BuiltInUIPart.GLOBAL, () => (0, _univerjs_ui.connectInjector)(RecorderPanel, this._injector));
|
|
535
|
-
this.disposeWithMe(this._componentManager.register("RecordIcon", _univerjs_icons.RecordIcon));
|
|
536
534
|
this._menuManagerService.mergeMenu(menuSchema);
|
|
537
535
|
}
|
|
538
536
|
_initSheetsCommands() {
|
|
@@ -596,11 +594,40 @@ ActionRecorderController = __decorate([
|
|
|
596
594
|
__decorateParam(0, _univerjs_core.ICommandService),
|
|
597
595
|
__decorateParam(1, _univerjs_ui.IUIPartsService),
|
|
598
596
|
__decorateParam(2, _univerjs_ui.IMenuManagerService),
|
|
599
|
-
__decorateParam(3, (0, _univerjs_core.Inject)(
|
|
600
|
-
__decorateParam(4, (0, _univerjs_core.Inject)(
|
|
601
|
-
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_core.Injector))
|
|
597
|
+
__decorateParam(3, (0, _univerjs_core.Inject)(ActionRecorderService)),
|
|
598
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_core.Injector))
|
|
602
599
|
], ActionRecorderController);
|
|
603
600
|
|
|
601
|
+
//#endregion
|
|
602
|
+
//#region src/controllers/components.controller.ts
|
|
603
|
+
/**
|
|
604
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
605
|
+
*
|
|
606
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
607
|
+
* you may not use this file except in compliance with the License.
|
|
608
|
+
* You may obtain a copy of the License at
|
|
609
|
+
*
|
|
610
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
611
|
+
*
|
|
612
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
613
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
614
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
615
|
+
* See the License for the specific language governing permissions and
|
|
616
|
+
* limitations under the License.
|
|
617
|
+
*/
|
|
618
|
+
let ComponentsController = class ComponentsController extends _univerjs_core.Disposable {
|
|
619
|
+
constructor(_componentManager, _iconManager) {
|
|
620
|
+
super();
|
|
621
|
+
this._componentManager = _componentManager;
|
|
622
|
+
this._iconManager = _iconManager;
|
|
623
|
+
this._registerIcons();
|
|
624
|
+
}
|
|
625
|
+
_registerIcons() {
|
|
626
|
+
this.disposeWithMe(this._iconManager.register({ RecordIcon: _univerjs_icons.RecordIcon }));
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], ComponentsController);
|
|
630
|
+
|
|
604
631
|
//#endregion
|
|
605
632
|
//#region src/plugin.ts
|
|
606
633
|
let UniverActionRecorderPlugin = class UniverActionRecorderPlugin extends _univerjs_core.Plugin {
|
|
@@ -614,6 +641,8 @@ let UniverActionRecorderPlugin = class UniverActionRecorderPlugin extends _unive
|
|
|
614
641
|
this._configService.setConfig(ACTION_RECORDER_PLUGIN_CONFIG_KEY, rest);
|
|
615
642
|
}
|
|
616
643
|
onStarting() {
|
|
644
|
+
this._injector.add([ComponentsController]);
|
|
645
|
+
this._injector.get(ComponentsController);
|
|
617
646
|
(this._config.replayOnly ? [[ActionReplayService]] : [
|
|
618
647
|
[ActionRecorderService],
|
|
619
648
|
[ActionReplayService],
|
package/lib/es/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { CommandType, Disposable, ICommandService, IConfigService, ILogService, IUniverInstanceService, Inject, Injector, Plugin, awaitTime, merge } from "@univerjs/core";
|
|
2
|
-
import { RecordIcon } from "@univerjs/icons";
|
|
3
2
|
import { AddWorksheetMergeAllCommand, AddWorksheetMergeCommand, AddWorksheetMergeHorizontalCommand, AddWorksheetMergeVerticalCommand, AutoFillCommand, CancelFrozenCommand, CopySheetCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, DeltaColumnWidthCommand, DeltaRowHeightCommand, InsertColAfterCommand, InsertColBeforeCommand, InsertRowAfterCommand, InsertRowBeforeCommand, InsertSheetCommand, RefillCommand, RemoveSheetCommand, SetFrozenCommand, SetHorizontalTextAlignCommand, SetOverlineCommand, SetRangeValuesCommand, SetSelectionsOperation, SetStrikeThroughCommand, SetStyleCommand, SetTextColorCommand, SetTextRotationCommand, SetTextWrapCommand, SetVerticalTextAlignCommand, SetWorksheetActivateCommand, SetWorksheetActiveOperation } from "@univerjs/sheets";
|
|
4
3
|
import { RemoveSheetFilterCommand, SetSheetFilterRangeCommand, SetSheetsFilterCriteriaCommand } from "@univerjs/sheets-filter";
|
|
5
4
|
import { SetRangeBoldCommand, SetRangeFontFamilyCommand, SetRangeFontSizeCommand, SetRangeItalicCommand, SetRangeStrickThroughCommand, SetRangeSubscriptCommand, SetRangeSuperscriptCommand, SetRangeTextColorCommand, SetRangeUnderlineCommand, SheetCopyCommand, SheetCutCommand, SheetPasteBesidesBorderCommand, SheetPasteColWidthCommand, SheetPasteCommand, SheetPasteFormatCommand, SheetPasteShortKeyCommand, SheetPasteValueCommand } from "@univerjs/sheets-ui";
|
|
6
|
-
import { BuiltInUIPart, ComponentManager, ILocalFileService, IMenuManagerService, IMessageService, IUIPartsService, MenuItemType, RibbonOthersGroup, connectInjector, useDependency, useObservable } from "@univerjs/ui";
|
|
5
|
+
import { BuiltInUIPart, ComponentManager, ILocalFileService, IMenuManagerService, IMessageService, IUIPartsService, IconManager, MenuItemType, RibbonOthersGroup, connectInjector, useDependency, useObservable } from "@univerjs/ui";
|
|
7
6
|
import { BehaviorSubject } from "rxjs";
|
|
8
7
|
import { Button, MessageType } from "@univerjs/design";
|
|
8
|
+
import { RecordIcon } from "@univerjs/icons";
|
|
9
9
|
import { useCallback } from "react";
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
|
|
12
12
|
//#region package.json
|
|
13
13
|
var name = "@univerjs/action-recorder";
|
|
14
|
-
var version = "0.
|
|
14
|
+
var version = "1.0.0-alpha.1";
|
|
15
15
|
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region src/config/config.ts
|
|
@@ -20,7 +20,7 @@ const configSymbol = Symbol(ACTION_RECORDER_PLUGIN_CONFIG_KEY);
|
|
|
20
20
|
const defaultPluginConfig = {};
|
|
21
21
|
|
|
22
22
|
//#endregion
|
|
23
|
-
//#region \0@oxc-project+runtime@0.
|
|
23
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
24
24
|
function _typeof(o) {
|
|
25
25
|
"@babel/helpers - typeof";
|
|
26
26
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -31,7 +31,7 @@ function _typeof(o) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
//#endregion
|
|
34
|
-
//#region \0@oxc-project+runtime@0.
|
|
34
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
35
35
|
function toPrimitive(t, r) {
|
|
36
36
|
if ("object" != _typeof(t) || !t) return t;
|
|
37
37
|
var e = t[Symbol.toPrimitive];
|
|
@@ -44,14 +44,14 @@ function toPrimitive(t, r) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
//#endregion
|
|
47
|
-
//#region \0@oxc-project+runtime@0.
|
|
47
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
48
48
|
function toPropertyKey(t) {
|
|
49
49
|
var i = toPrimitive(t, "string");
|
|
50
50
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
//#endregion
|
|
54
|
-
//#region \0@oxc-project+runtime@0.
|
|
54
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
55
55
|
function _defineProperty(e, r, t) {
|
|
56
56
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
57
57
|
value: t,
|
|
@@ -62,7 +62,7 @@ function _defineProperty(e, r, t) {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
//#endregion
|
|
65
|
-
//#region \0@oxc-project+runtime@0.
|
|
65
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
|
|
66
66
|
function __decorateParam(paramIndex, decorator) {
|
|
67
67
|
return function(target, key) {
|
|
68
68
|
decorator(target, key, paramIndex);
|
|
@@ -70,7 +70,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
//#endregion
|
|
73
|
-
//#region \0@oxc-project+runtime@0.
|
|
73
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
|
|
74
74
|
function __decorate(decorators, target, key, desc) {
|
|
75
75
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
76
76
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -504,12 +504,11 @@ function RecordPanelImpl() {
|
|
|
504
504
|
* limitations under the License.
|
|
505
505
|
*/
|
|
506
506
|
let ActionRecorderController = class ActionRecorderController extends Disposable {
|
|
507
|
-
constructor(_commandSrv, _uiPartsSrv, _menuManagerService,
|
|
507
|
+
constructor(_commandSrv, _uiPartsSrv, _menuManagerService, _actionRecorderService, _injector) {
|
|
508
508
|
super();
|
|
509
509
|
this._commandSrv = _commandSrv;
|
|
510
510
|
this._uiPartsSrv = _uiPartsSrv;
|
|
511
511
|
this._menuManagerService = _menuManagerService;
|
|
512
|
-
this._componentManager = _componentManager;
|
|
513
512
|
this._actionRecorderService = _actionRecorderService;
|
|
514
513
|
this._injector = _injector;
|
|
515
514
|
this._initCommands();
|
|
@@ -531,7 +530,6 @@ let ActionRecorderController = class ActionRecorderController extends Disposable
|
|
|
531
530
|
}
|
|
532
531
|
_initUI() {
|
|
533
532
|
this._uiPartsSrv.registerComponent(BuiltInUIPart.GLOBAL, () => connectInjector(RecorderPanel, this._injector));
|
|
534
|
-
this.disposeWithMe(this._componentManager.register("RecordIcon", RecordIcon));
|
|
535
533
|
this._menuManagerService.mergeMenu(menuSchema);
|
|
536
534
|
}
|
|
537
535
|
_initSheetsCommands() {
|
|
@@ -595,11 +593,40 @@ ActionRecorderController = __decorate([
|
|
|
595
593
|
__decorateParam(0, ICommandService),
|
|
596
594
|
__decorateParam(1, IUIPartsService),
|
|
597
595
|
__decorateParam(2, IMenuManagerService),
|
|
598
|
-
__decorateParam(3, Inject(
|
|
599
|
-
__decorateParam(4, Inject(
|
|
600
|
-
__decorateParam(5, Inject(Injector))
|
|
596
|
+
__decorateParam(3, Inject(ActionRecorderService)),
|
|
597
|
+
__decorateParam(4, Inject(Injector))
|
|
601
598
|
], ActionRecorderController);
|
|
602
599
|
|
|
600
|
+
//#endregion
|
|
601
|
+
//#region src/controllers/components.controller.ts
|
|
602
|
+
/**
|
|
603
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
604
|
+
*
|
|
605
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
606
|
+
* you may not use this file except in compliance with the License.
|
|
607
|
+
* You may obtain a copy of the License at
|
|
608
|
+
*
|
|
609
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
610
|
+
*
|
|
611
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
612
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
613
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
614
|
+
* See the License for the specific language governing permissions and
|
|
615
|
+
* limitations under the License.
|
|
616
|
+
*/
|
|
617
|
+
let ComponentsController = class ComponentsController extends Disposable {
|
|
618
|
+
constructor(_componentManager, _iconManager) {
|
|
619
|
+
super();
|
|
620
|
+
this._componentManager = _componentManager;
|
|
621
|
+
this._iconManager = _iconManager;
|
|
622
|
+
this._registerIcons();
|
|
623
|
+
}
|
|
624
|
+
_registerIcons() {
|
|
625
|
+
this.disposeWithMe(this._iconManager.register({ RecordIcon }));
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
|
|
629
|
+
|
|
603
630
|
//#endregion
|
|
604
631
|
//#region src/plugin.ts
|
|
605
632
|
let UniverActionRecorderPlugin = class UniverActionRecorderPlugin extends Plugin {
|
|
@@ -613,6 +640,8 @@ let UniverActionRecorderPlugin = class UniverActionRecorderPlugin extends Plugin
|
|
|
613
640
|
this._configService.setConfig(ACTION_RECORDER_PLUGIN_CONFIG_KEY, rest);
|
|
614
641
|
}
|
|
615
642
|
onStarting() {
|
|
643
|
+
this._injector.add([ComponentsController]);
|
|
644
|
+
this._injector.get(ComponentsController);
|
|
616
645
|
(this._config.replayOnly ? [[ActionReplayService]] : [
|
|
617
646
|
[ActionRecorderService],
|
|
618
647
|
[ActionReplayService],
|
package/lib/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { CommandType, Disposable, ICommandService, IConfigService, ILogService, IUniverInstanceService, Inject, Injector, Plugin, awaitTime, merge } from "@univerjs/core";
|
|
2
|
-
import { RecordIcon } from "@univerjs/icons";
|
|
3
2
|
import { AddWorksheetMergeAllCommand, AddWorksheetMergeCommand, AddWorksheetMergeHorizontalCommand, AddWorksheetMergeVerticalCommand, AutoFillCommand, CancelFrozenCommand, CopySheetCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, DeltaColumnWidthCommand, DeltaRowHeightCommand, InsertColAfterCommand, InsertColBeforeCommand, InsertRowAfterCommand, InsertRowBeforeCommand, InsertSheetCommand, RefillCommand, RemoveSheetCommand, SetFrozenCommand, SetHorizontalTextAlignCommand, SetOverlineCommand, SetRangeValuesCommand, SetSelectionsOperation, SetStrikeThroughCommand, SetStyleCommand, SetTextColorCommand, SetTextRotationCommand, SetTextWrapCommand, SetVerticalTextAlignCommand, SetWorksheetActivateCommand, SetWorksheetActiveOperation } from "@univerjs/sheets";
|
|
4
3
|
import { RemoveSheetFilterCommand, SetSheetFilterRangeCommand, SetSheetsFilterCriteriaCommand } from "@univerjs/sheets-filter";
|
|
5
4
|
import { SetRangeBoldCommand, SetRangeFontFamilyCommand, SetRangeFontSizeCommand, SetRangeItalicCommand, SetRangeStrickThroughCommand, SetRangeSubscriptCommand, SetRangeSuperscriptCommand, SetRangeTextColorCommand, SetRangeUnderlineCommand, SheetCopyCommand, SheetCutCommand, SheetPasteBesidesBorderCommand, SheetPasteColWidthCommand, SheetPasteCommand, SheetPasteFormatCommand, SheetPasteShortKeyCommand, SheetPasteValueCommand } from "@univerjs/sheets-ui";
|
|
6
|
-
import { BuiltInUIPart, ComponentManager, ILocalFileService, IMenuManagerService, IMessageService, IUIPartsService, MenuItemType, RibbonOthersGroup, connectInjector, useDependency, useObservable } from "@univerjs/ui";
|
|
5
|
+
import { BuiltInUIPart, ComponentManager, ILocalFileService, IMenuManagerService, IMessageService, IUIPartsService, IconManager, MenuItemType, RibbonOthersGroup, connectInjector, useDependency, useObservable } from "@univerjs/ui";
|
|
7
6
|
import { BehaviorSubject } from "rxjs";
|
|
8
7
|
import { Button, MessageType } from "@univerjs/design";
|
|
8
|
+
import { RecordIcon } from "@univerjs/icons";
|
|
9
9
|
import { useCallback } from "react";
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
|
|
12
12
|
//#region package.json
|
|
13
13
|
var name = "@univerjs/action-recorder";
|
|
14
|
-
var version = "0.
|
|
14
|
+
var version = "1.0.0-alpha.1";
|
|
15
15
|
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region src/config/config.ts
|
|
@@ -20,7 +20,7 @@ const configSymbol = Symbol(ACTION_RECORDER_PLUGIN_CONFIG_KEY);
|
|
|
20
20
|
const defaultPluginConfig = {};
|
|
21
21
|
|
|
22
22
|
//#endregion
|
|
23
|
-
//#region \0@oxc-project+runtime@0.
|
|
23
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
24
24
|
function _typeof(o) {
|
|
25
25
|
"@babel/helpers - typeof";
|
|
26
26
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -31,7 +31,7 @@ function _typeof(o) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
//#endregion
|
|
34
|
-
//#region \0@oxc-project+runtime@0.
|
|
34
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
35
35
|
function toPrimitive(t, r) {
|
|
36
36
|
if ("object" != _typeof(t) || !t) return t;
|
|
37
37
|
var e = t[Symbol.toPrimitive];
|
|
@@ -44,14 +44,14 @@ function toPrimitive(t, r) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
//#endregion
|
|
47
|
-
//#region \0@oxc-project+runtime@0.
|
|
47
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
48
48
|
function toPropertyKey(t) {
|
|
49
49
|
var i = toPrimitive(t, "string");
|
|
50
50
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
//#endregion
|
|
54
|
-
//#region \0@oxc-project+runtime@0.
|
|
54
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
55
55
|
function _defineProperty(e, r, t) {
|
|
56
56
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
57
57
|
value: t,
|
|
@@ -62,7 +62,7 @@ function _defineProperty(e, r, t) {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
//#endregion
|
|
65
|
-
//#region \0@oxc-project+runtime@0.
|
|
65
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
|
|
66
66
|
function __decorateParam(paramIndex, decorator) {
|
|
67
67
|
return function(target, key) {
|
|
68
68
|
decorator(target, key, paramIndex);
|
|
@@ -70,7 +70,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
//#endregion
|
|
73
|
-
//#region \0@oxc-project+runtime@0.
|
|
73
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
|
|
74
74
|
function __decorate(decorators, target, key, desc) {
|
|
75
75
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
76
76
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -504,12 +504,11 @@ function RecordPanelImpl() {
|
|
|
504
504
|
* limitations under the License.
|
|
505
505
|
*/
|
|
506
506
|
let ActionRecorderController = class ActionRecorderController extends Disposable {
|
|
507
|
-
constructor(_commandSrv, _uiPartsSrv, _menuManagerService,
|
|
507
|
+
constructor(_commandSrv, _uiPartsSrv, _menuManagerService, _actionRecorderService, _injector) {
|
|
508
508
|
super();
|
|
509
509
|
this._commandSrv = _commandSrv;
|
|
510
510
|
this._uiPartsSrv = _uiPartsSrv;
|
|
511
511
|
this._menuManagerService = _menuManagerService;
|
|
512
|
-
this._componentManager = _componentManager;
|
|
513
512
|
this._actionRecorderService = _actionRecorderService;
|
|
514
513
|
this._injector = _injector;
|
|
515
514
|
this._initCommands();
|
|
@@ -531,7 +530,6 @@ let ActionRecorderController = class ActionRecorderController extends Disposable
|
|
|
531
530
|
}
|
|
532
531
|
_initUI() {
|
|
533
532
|
this._uiPartsSrv.registerComponent(BuiltInUIPart.GLOBAL, () => connectInjector(RecorderPanel, this._injector));
|
|
534
|
-
this.disposeWithMe(this._componentManager.register("RecordIcon", RecordIcon));
|
|
535
533
|
this._menuManagerService.mergeMenu(menuSchema);
|
|
536
534
|
}
|
|
537
535
|
_initSheetsCommands() {
|
|
@@ -595,11 +593,40 @@ ActionRecorderController = __decorate([
|
|
|
595
593
|
__decorateParam(0, ICommandService),
|
|
596
594
|
__decorateParam(1, IUIPartsService),
|
|
597
595
|
__decorateParam(2, IMenuManagerService),
|
|
598
|
-
__decorateParam(3, Inject(
|
|
599
|
-
__decorateParam(4, Inject(
|
|
600
|
-
__decorateParam(5, Inject(Injector))
|
|
596
|
+
__decorateParam(3, Inject(ActionRecorderService)),
|
|
597
|
+
__decorateParam(4, Inject(Injector))
|
|
601
598
|
], ActionRecorderController);
|
|
602
599
|
|
|
600
|
+
//#endregion
|
|
601
|
+
//#region src/controllers/components.controller.ts
|
|
602
|
+
/**
|
|
603
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
604
|
+
*
|
|
605
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
606
|
+
* you may not use this file except in compliance with the License.
|
|
607
|
+
* You may obtain a copy of the License at
|
|
608
|
+
*
|
|
609
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
610
|
+
*
|
|
611
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
612
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
613
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
614
|
+
* See the License for the specific language governing permissions and
|
|
615
|
+
* limitations under the License.
|
|
616
|
+
*/
|
|
617
|
+
let ComponentsController = class ComponentsController extends Disposable {
|
|
618
|
+
constructor(_componentManager, _iconManager) {
|
|
619
|
+
super();
|
|
620
|
+
this._componentManager = _componentManager;
|
|
621
|
+
this._iconManager = _iconManager;
|
|
622
|
+
this._registerIcons();
|
|
623
|
+
}
|
|
624
|
+
_registerIcons() {
|
|
625
|
+
this.disposeWithMe(this._iconManager.register({ RecordIcon }));
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
|
|
629
|
+
|
|
603
630
|
//#endregion
|
|
604
631
|
//#region src/plugin.ts
|
|
605
632
|
let UniverActionRecorderPlugin = class UniverActionRecorderPlugin extends Plugin {
|
|
@@ -613,6 +640,8 @@ let UniverActionRecorderPlugin = class UniverActionRecorderPlugin extends Plugin
|
|
|
613
640
|
this._configService.setConfig(ACTION_RECORDER_PLUGIN_CONFIG_KEY, rest);
|
|
614
641
|
}
|
|
615
642
|
onStarting() {
|
|
643
|
+
this._injector.add([ComponentsController]);
|
|
644
|
+
this._injector.get(ComponentsController);
|
|
616
645
|
(this._config.replayOnly ? [[ActionReplayService]] : [
|
|
617
646
|
[ActionRecorderService],
|
|
618
647
|
[ActionReplayService],
|
|
@@ -14,16 +14,15 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { Disposable, ICommandService, Injector } from '@univerjs/core';
|
|
17
|
-
import {
|
|
17
|
+
import { IMenuManagerService, IUIPartsService } from '@univerjs/ui';
|
|
18
18
|
import { ActionRecorderService } from '../services/action-recorder.service';
|
|
19
19
|
export declare class ActionRecorderController extends Disposable {
|
|
20
20
|
private readonly _commandSrv;
|
|
21
21
|
private readonly _uiPartsSrv;
|
|
22
22
|
private readonly _menuManagerService;
|
|
23
|
-
private readonly _componentManager;
|
|
24
23
|
private readonly _actionRecorderService;
|
|
25
24
|
private readonly _injector;
|
|
26
|
-
constructor(_commandSrv: ICommandService, _uiPartsSrv: IUIPartsService, _menuManagerService: IMenuManagerService,
|
|
25
|
+
constructor(_commandSrv: ICommandService, _uiPartsSrv: IUIPartsService, _menuManagerService: IMenuManagerService, _actionRecorderService: ActionRecorderService, _injector: Injector);
|
|
27
26
|
private _initCommands;
|
|
28
27
|
private _initUI;
|
|
29
28
|
private _initSheetsCommands;
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
import { Disposable } from '@univerjs/core';
|
|
17
|
+
import { ComponentManager, IconManager } from '@univerjs/ui';
|
|
18
|
+
export declare class ComponentsController extends Disposable {
|
|
19
|
+
private readonly _componentManager;
|
|
20
|
+
private readonly _iconManager;
|
|
21
|
+
constructor(_componentManager: ComponentManager, _iconManager: IconManager);
|
|
22
|
+
private _registerIcons;
|
|
23
|
+
}
|
|
@@ -13,4 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
import type { LocaleLeafKeys } from '@univerjs/core';
|
|
17
|
+
import type enUS from './en-US';
|
|
18
|
+
export type LocaleKey = LocaleLeafKeys<typeof enUS>;
|
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { IAccessor } from '@univerjs/core';
|
|
17
17
|
import type { IMenuButtonItem, IMenuSelectorItem, MenuSchemaType } from '@univerjs/ui';
|
|
18
|
+
import type { LocaleKey } from '../locale/types';
|
|
18
19
|
export declare const RECORD_MENU_ITEM_ID = "RECORD_MENU_ITEM";
|
|
19
|
-
export declare function RecordMenuItemFactory(): IMenuSelectorItem
|
|
20
|
-
export declare function OpenRecorderMenuItemFactory(accessor: IAccessor): IMenuButtonItem
|
|
21
|
-
export declare function ReplayLocalRecordMenuItemFactory(): IMenuButtonItem
|
|
22
|
-
export declare function ReplayLocalRecordOnNamesakeMenuItemFactory(): IMenuButtonItem
|
|
23
|
-
export declare function ReplayLocalRecordOnActiveMenuItemFactory(): IMenuButtonItem
|
|
20
|
+
export declare function RecordMenuItemFactory(): IMenuSelectorItem<LocaleKey>;
|
|
21
|
+
export declare function OpenRecorderMenuItemFactory(accessor: IAccessor): IMenuButtonItem<LocaleKey>;
|
|
22
|
+
export declare function ReplayLocalRecordMenuItemFactory(): IMenuButtonItem<LocaleKey>;
|
|
23
|
+
export declare function ReplayLocalRecordOnNamesakeMenuItemFactory(): IMenuButtonItem<LocaleKey>;
|
|
24
|
+
export declare function ReplayLocalRecordOnActiveMenuItemFactory(): IMenuButtonItem<LocaleKey>;
|
|
24
25
|
export declare const menuSchema: MenuSchemaType;
|
|
@@ -13,4 +13,4 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export declare function RecorderPanel(): import("react
|
|
16
|
+
export declare function RecorderPanel(): import("react").JSX.Element | null;
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("react"),require("@univerjs/sheets"),require("@univerjs/sheets-filter"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`react`,`@univerjs/sheets`,`@univerjs/sheets-filter`,`@univerjs/sheets-ui`,`@univerjs/ui`,`rxjs`,`@univerjs/design`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverActionRecorder={},e.UniverCore,e.React,e.UniverSheets,e.UniverSheetsFilter,e.UniverSheetsUi,e.UniverUi,e.rxjs,e.UniverDesign,e.React))})(this,function(e,t,n,r,i,a,o,s,c,l){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var u=`@univerjs/action-recorder`,d=`0.25.1`;let f={};function p({ref:e,...t}){let{icon:r,id:i,className:a,extend:o,...s}=t,c=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),l=(0,n.useRef)(`_${_()}`);return m(r,`${i}`,{defIds:r.defIds,idSuffix:l.current},{ref:e,className:c,...s},o)}function m(e,t,r,i,a){return(0,n.createElement)(e.tag,{key:t,...h(e,r,a),...i},(g(e,r).children||[]).map((n,i)=>m(n,`${t}-${e.tag}-${i}`,r,void 0,a)))}function h(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=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 g(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 _(){return Math.random().toString(36).substring(2,8)}p.displayName=`UniverIcon`;let v={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`]},y=(0,n.forwardRef)(function(e,t){return(0,n.createElement)(p,Object.assign({},e,{id:`record-icon`,ref:t,icon:v}))});y.displayName=`RecordIcon`;function b(e){"@babel/helpers - typeof";return b=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},b(e)}function x(e,t){if(b(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(b(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function S(e){var t=x(e,`string`);return b(t)==`symbol`?t:t+``}function C(e,t,n){return(t=S(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e,t){return function(n,r){t(n,r,e)}}function T(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 E=class extends t.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,C(this,`_shouldRecordCommands`,new Set),C(this,`_panelOpened$`,new s.BehaviorSubject(!1)),C(this,`panelOpened$`,this._panelOpened$.asObservable()),C(this,`_recorder`,null),C(this,`_recording$`,new s.BehaviorSubject(!1)),C(this,`recording$`,this._recording$.asObservable()),C(this,`_recorded$`,new s.BehaviorSubject([])),C(this,`_recordedCommands$`,new s.BehaviorSubject([])),C(this,`recordedCommands$`,this._recordedCommands$.asObservable())}registerRecordedCommand(e){if(e.type===t.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(n=>{if(this._shouldRecordCommands.has(n.id)){var i;let o=this._recorded,s=this._recordedCommands,c={...n},l=(i=this._instanceService.getFocusedUnit())==null?void 0:i.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===r.SetSelectionsOperation.id&&o.length>0&&o[o.length-1].id===r.SetSelectionsOperation.id?o[o.length-1]=c:(o.push(c),this._recorded$.next(o),c.type===t.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()}};E=T([w(0,t.ICommandService),w(1,t.ILogService),w(2,o.ILocalFileService),w(3,t.IUniverInstanceService)],E);let D={id:`action-recorder.command.start-recording`,type:t.CommandType.COMMAND,handler:(e,t)=>(e.get(E).startRecording(!!(t!=null&&t.replaceId)),!0)},O={id:`action-recorder.command.complete-recording`,type:t.CommandType.COMMAND,handler:e=>(e.get(E).completeRecording(),!0)},k={id:`action-recorder.command.stop-recording`,type:t.CommandType.COMMAND,handler:e=>(e.get(E).completeRecording(),!0)},A=class extends t.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:c.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 n;let r=(n=this._instanceService.getFocusedUnit())==null?void 0:n.getUnitId();r||this._logService.error(`[ReplayService]`,`no focused unit to replay commands`);for(let n of e){await(0,t.awaitTime)(j());let{id:e,params:i}=n;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}};A=T([w(0,o.IMessageService),w(1,t.IUniverInstanceService),w(2,o.ILocalFileService),w(3,t.ILogService),w(4,t.ICommandService)],A);function j(){return Math.floor(Math.random()*800)+200}let M={id:`action-recorder.command.replay-local-records`,type:t.CommandType.COMMAND,handler:async e=>{let t=await e.get(A).replayLocalJSON();return t&&e.get(o.IMessageService).show({type:c.MessageType.Success,content:`Successfully replayed local records`}),t}},N={id:`action-recorder.command.replay-local-records-name`,type:t.CommandType.COMMAND,handler:async e=>{let t=await e.get(A).replayLocalJSON(`name`);return t&&e.get(o.IMessageService).show({type:c.MessageType.Success,content:`Successfully replayed local records`}),t}},P={id:`action-recorder.command.replay-local-records-active`,type:t.CommandType.COMMAND,handler:async e=>{let t=await e.get(A).replayLocalJSON(`active`);return t&&e.get(o.IMessageService).show({type:c.MessageType.Success,content:`Successfully replayed local records`}),t}},F={id:`action-recorder.operation.open-panel`,type:t.CommandType.OPERATION,handler(e){return e.get(E).togglePanel(!0),!0}},I={id:`action-recorder.operation.close-panel`,type:t.CommandType.OPERATION,handler(e){return e.get(E).togglePanel(!1),!0}},L=`RECORD_MENU_ITEM`;function R(){return{id:L,type:o.MenuItemType.SUBITEMS,icon:`RecordIcon`,tooltip:`action-recorder.menu.title`}}function z(e){let t=e.get(E);return{id:F.id,title:`action-recorder.menu.record`,type:o.MenuItemType.BUTTON,disabled$:t.panelOpened$}}function B(){return{id:M.id,title:`action-recorder.menu.replay-local`,type:o.MenuItemType.BUTTON}}function V(){return{id:N.id,title:`action-recorder.menu.replay-local-name`,type:o.MenuItemType.BUTTON}}function H(){return{id:P.id,title:`action-recorder.menu.replay-local-active`,type:o.MenuItemType.BUTTON}}let U={[o.RibbonOthersGroup.OTHERS]:{[L]:{order:1,menuItemFactory:R,[F.id]:{order:1,menuItemFactory:z},[M.id]:{order:2,menuItemFactory:B},[N.id]:{order:3,menuItemFactory:V},[P.id]:{order:4,menuItemFactory:H}}}};function W(){return(0,o.useObservable)((0,o.useDependency)(E).panelOpened$)?(0,l.jsx)(G,{}):null}function G(){var e;let r=(0,o.useDependency)(t.ICommandService),i=(0,o.useDependency)(E),a=(0,o.useObservable)(i.recording$),s=(0,o.useObservable)(i.recordedCommands$),u=(e=s==null?void 0:s.length)==null?0:e,d=(0,n.useCallback)(()=>{a||r.executeCommand(I.id)},[r,a]),f=(0,n.useCallback)(e=>{a||r.executeCommand(D.id,{replaceId:e})},[r,a]),p=(0,n.useCallback)(()=>{a&&r.executeCommand(O.id)},[r,a]),m=(0,n.useCallback)(()=>{a&&r.executeCommand(k.id)},[r,a]),h=a?u===0?`Recording...`:`${u}: ${s[u-1].id}`:`Start Recording`;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)(y,{})}),(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)(c.Button,{className:`univer-w-20`,onClick:a?m:d,children:a?`Cancel`:`Close`}),(0,l.jsx)(c.Button,{className:`univer-w-20`,variant:`primary`,onClick:a?p:()=>f(),children:a?`Save`:`Start`}),!a&&(0,l.jsx)(c.Button,{variant:`primary`,onClick:()=>f(!0),children:`Start(N)`})]})]})}let K=class extends t.Disposable{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(){[D,k,O,F,I,M,N,P].forEach(e=>this._commandSrv.registerCommand(e))}_initUI(){this._uiPartsSrv.registerComponent(o.BuiltInUIPart.GLOBAL,()=>(0,o.connectInjector)(W,this._injector)),this.disposeWithMe(this._componentManager.register(`RecordIcon`,y)),this._menuManagerService.mergeMenu(U)}_initSheetsCommands(){[r.CopySheetCommand,r.DeleteRangeMoveLeftCommand,r.DeleteRangeMoveUpCommand,r.DeltaColumnWidthCommand,r.DeltaRowHeightCommand,r.InsertSheetCommand,r.InsertColAfterCommand,r.InsertColBeforeCommand,r.InsertRowAfterCommand,r.InsertRowBeforeCommand,r.RemoveSheetCommand,r.SetStyleCommand,r.AddWorksheetMergeCommand,r.AddWorksheetMergeAllCommand,r.AddWorksheetMergeVerticalCommand,r.AddWorksheetMergeHorizontalCommand,r.SetFrozenCommand,r.CancelFrozenCommand,r.SetHorizontalTextAlignCommand,r.SetOverlineCommand,a.SetRangeBoldCommand,a.SetRangeFontFamilyCommand,a.SetRangeFontSizeCommand,a.SetRangeItalicCommand,a.SetRangeStrickThroughCommand,a.SetRangeSubscriptCommand,a.SetRangeSuperscriptCommand,a.SetRangeTextColorCommand,a.SetRangeUnderlineCommand,r.SetRangeValuesCommand,r.SetStrikeThroughCommand,r.SetTextColorCommand,r.SetTextRotationCommand,r.SetTextWrapCommand,r.SetVerticalTextAlignCommand,a.SheetCopyCommand,a.SheetCutCommand,a.SheetPasteBesidesBorderCommand,a.SheetPasteColWidthCommand,a.SheetPasteCommand,a.SheetPasteFormatCommand,a.SheetPasteShortKeyCommand,a.SheetPasteValueCommand,r.AutoFillCommand,r.RefillCommand,r.SetWorksheetActivateCommand,r.SetWorksheetActiveOperation,r.SetSelectionsOperation,i.SetSheetFilterRangeCommand,i.SetSheetsFilterCriteriaCommand,i.RemoveSheetFilterCommand].forEach(e=>this._actionRecorderService.registerRecordedCommand(e))}_initDocsCommands(){}};K=T([w(0,t.ICommandService),w(1,o.IUIPartsService),w(2,o.IMenuManagerService),w(3,(0,t.Inject)(o.ComponentManager)),w(4,(0,t.Inject)(E)),w(5,(0,t.Inject)(t.Injector))],K);let q=class extends t.Plugin{constructor(e=f,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{menu:i,...a}=(0,t.merge)({},f,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(`action-recorder.config`,a)}onStarting(){(this._config.replayOnly?[[A]]:[[E],[A],[K]]).forEach(e=>this._injector.add(e))}onSteady(){this._config.replayOnly||this._injector.get(K)}};C(q,`pluginName`,`UNIVER_ACTION_RECORDER_PLUGIN`),C(q,`packageName`,u),C(q,`version`,d),q=T([w(1,(0,t.Inject)(t.Injector)),w(2,t.IConfigService)],q),Object.defineProperty(e,"ActionRecorderService",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"ActionReplayService",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"UniverActionRecorderPlugin",{enumerable:!0,get:function(){return q}})});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-filter"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("react"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets`,`@univerjs/sheets-filter`,`@univerjs/sheets-ui`,`@univerjs/ui`,`rxjs`,`@univerjs/design`,`react`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverActionRecorder={},e.UniverCore,e.UniverSheets,e.UniverSheetsFilter,e.UniverSheetsUi,e.UniverUi,e.rxjs,e.UniverDesign,e.React,e.React))})(this,function(e,t,n,r,i,a,o,s,c,l){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var u=`@univerjs/action-recorder`,d=`1.0.0-alpha.1`;let f={};function p(e){"@babel/helpers - typeof";return p=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},p(e)}function m(e,t){if(p(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(p(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function h(e){var t=m(e,`string`);return p(t)==`symbol`?t:t+``}function g(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _(e,t){return function(n,r){t(n,r,e)}}function v(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 y=class extends t.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,g(this,`_shouldRecordCommands`,new Set),g(this,`_panelOpened$`,new o.BehaviorSubject(!1)),g(this,`panelOpened$`,this._panelOpened$.asObservable()),g(this,`_recorder`,null),g(this,`_recording$`,new o.BehaviorSubject(!1)),g(this,`recording$`,this._recording$.asObservable()),g(this,`_recorded$`,new o.BehaviorSubject([])),g(this,`_recordedCommands$`,new o.BehaviorSubject([])),g(this,`recordedCommands$`,this._recordedCommands$.asObservable())}registerRecordedCommand(e){if(e.type===t.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(r=>{if(this._shouldRecordCommands.has(r.id)){var i;let o=this._recorded,s=this._recordedCommands,c={...r},l=(i=this._instanceService.getFocusedUnit())==null?void 0:i.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===n.SetSelectionsOperation.id&&o.length>0&&o[o.length-1].id===n.SetSelectionsOperation.id?o[o.length-1]=c:(o.push(c),this._recorded$.next(o),c.type===t.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()}};y=v([_(0,t.ICommandService),_(1,t.ILogService),_(2,a.ILocalFileService),_(3,t.IUniverInstanceService)],y);let b={id:`action-recorder.command.start-recording`,type:t.CommandType.COMMAND,handler:(e,t)=>(e.get(y).startRecording(!!(t!=null&&t.replaceId)),!0)},x={id:`action-recorder.command.complete-recording`,type:t.CommandType.COMMAND,handler:e=>(e.get(y).completeRecording(),!0)},S={id:`action-recorder.command.stop-recording`,type:t.CommandType.COMMAND,handler:e=>(e.get(y).completeRecording(),!0)},C=class extends t.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:s.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 n;let r=(n=this._instanceService.getFocusedUnit())==null?void 0:n.getUnitId();r||this._logService.error(`[ReplayService]`,`no focused unit to replay commands`);for(let n of e){await(0,t.awaitTime)(w());let{id:e,params:i}=n;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}};C=v([_(0,a.IMessageService),_(1,t.IUniverInstanceService),_(2,a.ILocalFileService),_(3,t.ILogService),_(4,t.ICommandService)],C);function w(){return Math.floor(Math.random()*800)+200}let T={id:`action-recorder.command.replay-local-records`,type:t.CommandType.COMMAND,handler:async e=>{let t=await e.get(C).replayLocalJSON();return t&&e.get(a.IMessageService).show({type:s.MessageType.Success,content:`Successfully replayed local records`}),t}},E={id:`action-recorder.command.replay-local-records-name`,type:t.CommandType.COMMAND,handler:async e=>{let t=await e.get(C).replayLocalJSON(`name`);return t&&e.get(a.IMessageService).show({type:s.MessageType.Success,content:`Successfully replayed local records`}),t}},D={id:`action-recorder.command.replay-local-records-active`,type:t.CommandType.COMMAND,handler:async e=>{let t=await e.get(C).replayLocalJSON(`active`);return t&&e.get(a.IMessageService).show({type:s.MessageType.Success,content:`Successfully replayed local records`}),t}},O={id:`action-recorder.operation.open-panel`,type:t.CommandType.OPERATION,handler(e){return e.get(y).togglePanel(!0),!0}},k={id:`action-recorder.operation.close-panel`,type:t.CommandType.OPERATION,handler(e){return e.get(y).togglePanel(!1),!0}},A=`RECORD_MENU_ITEM`;function j(){return{id:A,type:a.MenuItemType.SUBITEMS,icon:`RecordIcon`,tooltip:`action-recorder.menu.title`}}function M(e){let t=e.get(y);return{id:O.id,title:`action-recorder.menu.record`,type:a.MenuItemType.BUTTON,disabled$:t.panelOpened$}}function N(){return{id:T.id,title:`action-recorder.menu.replay-local`,type:a.MenuItemType.BUTTON}}function P(){return{id:E.id,title:`action-recorder.menu.replay-local-name`,type:a.MenuItemType.BUTTON}}function F(){return{id:D.id,title:`action-recorder.menu.replay-local-active`,type:a.MenuItemType.BUTTON}}let I={[a.RibbonOthersGroup.OTHERS]:{[A]:{order:1,menuItemFactory:j,[O.id]:{order:1,menuItemFactory:M},[T.id]:{order:2,menuItemFactory:N},[E.id]:{order:3,menuItemFactory:P},[D.id]:{order:4,menuItemFactory:F}}}};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,a.useObservable)((0,a.useDependency)(y).panelOpened$)?(0,l.jsx)(G,{}):null}function G(){var e;let n=(0,a.useDependency)(t.ICommandService),r=(0,a.useDependency)(y),i=(0,a.useObservable)(r.recording$),o=(0,a.useObservable)(r.recordedCommands$),u=(e=o==null?void 0:o.length)==null?0:e,d=(0,c.useCallback)(()=>{i||n.executeCommand(k.id)},[n,i]),f=(0,c.useCallback)(e=>{i||n.executeCommand(b.id,{replaceId:e})},[n,i]),p=(0,c.useCallback)(()=>{i&&n.executeCommand(x.id)},[n,i]),m=(0,c.useCallback)(()=>{i&&n.executeCommand(S.id)},[n,i]),h=i?u===0?`Recording...`:`${u}: ${o[u-1].id}`:`Start Recording`;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)(s.Button,{className:`univer-w-20`,onClick:i?m:d,children:i?`Cancel`:`Close`}),(0,l.jsx)(s.Button,{className:`univer-w-20`,variant:`primary`,onClick:i?p:()=>f(),children:i?`Save`:`Start`}),!i&&(0,l.jsx)(s.Button,{variant:`primary`,onClick:()=>f(!0),children:`Start(N)`})]})]})}let K=class extends t.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(){[b,S,x,O,k,T,E,D].forEach(e=>this._commandSrv.registerCommand(e))}_initUI(){this._uiPartsSrv.registerComponent(a.BuiltInUIPart.GLOBAL,()=>(0,a.connectInjector)(W,this._injector)),this._menuManagerService.mergeMenu(I)}_initSheetsCommands(){[n.CopySheetCommand,n.DeleteRangeMoveLeftCommand,n.DeleteRangeMoveUpCommand,n.DeltaColumnWidthCommand,n.DeltaRowHeightCommand,n.InsertSheetCommand,n.InsertColAfterCommand,n.InsertColBeforeCommand,n.InsertRowAfterCommand,n.InsertRowBeforeCommand,n.RemoveSheetCommand,n.SetStyleCommand,n.AddWorksheetMergeCommand,n.AddWorksheetMergeAllCommand,n.AddWorksheetMergeVerticalCommand,n.AddWorksheetMergeHorizontalCommand,n.SetFrozenCommand,n.CancelFrozenCommand,n.SetHorizontalTextAlignCommand,n.SetOverlineCommand,i.SetRangeBoldCommand,i.SetRangeFontFamilyCommand,i.SetRangeFontSizeCommand,i.SetRangeItalicCommand,i.SetRangeStrickThroughCommand,i.SetRangeSubscriptCommand,i.SetRangeSuperscriptCommand,i.SetRangeTextColorCommand,i.SetRangeUnderlineCommand,n.SetRangeValuesCommand,n.SetStrikeThroughCommand,n.SetTextColorCommand,n.SetTextRotationCommand,n.SetTextWrapCommand,n.SetVerticalTextAlignCommand,i.SheetCopyCommand,i.SheetCutCommand,i.SheetPasteBesidesBorderCommand,i.SheetPasteColWidthCommand,i.SheetPasteCommand,i.SheetPasteFormatCommand,i.SheetPasteShortKeyCommand,i.SheetPasteValueCommand,n.AutoFillCommand,n.RefillCommand,n.SetWorksheetActivateCommand,n.SetWorksheetActiveOperation,n.SetSelectionsOperation,r.SetSheetFilterRangeCommand,r.SetSheetsFilterCriteriaCommand,r.RemoveSheetFilterCommand].forEach(e=>this._actionRecorderService.registerRecordedCommand(e))}_initDocsCommands(){}};K=v([_(0,t.ICommandService),_(1,a.IUIPartsService),_(2,a.IMenuManagerService),_(3,(0,t.Inject)(y)),_(4,(0,t.Inject)(t.Injector))],K);let q=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerIcons()}_registerIcons(){this.disposeWithMe(this._iconManager.register({RecordIcon:U}))}};q=v([_(0,(0,t.Inject)(a.ComponentManager)),_(1,(0,t.Inject)(a.IconManager))],q);let J=class extends t.Plugin{constructor(e=f,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{menu:i,...a}=(0,t.merge)({},f,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?[[C]]:[[y],[C],[K]]).forEach(e=>this._injector.add(e))}onSteady(){this._config.replayOnly||this._injector.get(K)}};g(J,`pluginName`,`UNIVER_ACTION_RECORDER_PLUGIN`),g(J,`packageName`,u),g(J,`version`,d),J=v([_(1,(0,t.Inject)(t.Injector)),_(2,t.IConfigService)],J),Object.defineProperty(e,"ActionRecorderService",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"ActionReplayService",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"UniverActionRecorderPlugin",{enumerable:!0,get:function(){return J}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/action-recorder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Record and replay user actions in Univer.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -58,21 +58,21 @@
|
|
|
58
58
|
"rxjs": ">=7.0.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@univerjs/icons": "1.
|
|
62
|
-
"@univerjs/
|
|
63
|
-
"@univerjs/
|
|
64
|
-
"@univerjs/
|
|
65
|
-
"@univerjs/sheets-filter": "0.
|
|
66
|
-
"@univerjs/
|
|
67
|
-
"@univerjs/ui": "0.
|
|
61
|
+
"@univerjs/icons": "1.14.0",
|
|
62
|
+
"@univerjs/core": "1.0.0-alpha.1",
|
|
63
|
+
"@univerjs/design": "1.0.0-alpha.1",
|
|
64
|
+
"@univerjs/sheets": "1.0.0-alpha.1",
|
|
65
|
+
"@univerjs/sheets-filter": "1.0.0-alpha.1",
|
|
66
|
+
"@univerjs/ui": "1.0.0-alpha.1",
|
|
67
|
+
"@univerjs/sheets-ui": "1.0.0-alpha.1"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"react": "18.3.1",
|
|
71
71
|
"rxjs": "^7.8.2",
|
|
72
72
|
"tailwindcss": "3.4.18",
|
|
73
73
|
"typescript": "^6.0.3",
|
|
74
|
-
"vitest": "^4.1.
|
|
75
|
-
"@univerjs-infra/shared": "0.
|
|
74
|
+
"vitest": "^4.1.9",
|
|
75
|
+
"@univerjs-infra/shared": "1.0.0-alpha.1"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|
|
78
78
|
"test": "vitest run",
|