@univerjs/uniscript 0.2.5 → 0.2.6
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 +2 -2
- package/lib/es/index.js +172 -162
- package/lib/types/plugin.d.ts +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +17 -17
package/lib/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@univerjs/core"),ui=require("@univerjs/ui"),rxjs=require("rxjs"),require$$0=require("react"),design=require("@univerjs/design"),monacoEditor=require("monaco-editor"),facade=require("@univerjs/facade"),sheetsUi=require("@univerjs/sheets-ui"),sheets=require("@univerjs/sheets"),_ScriptPanelService=class _ScriptPanelService extends core.Disposable{constructor(){super(...arguments);__publicField(this,"_open$",new rxjs.BehaviorSubject(!1));__publicField(this,"open$",this._open$.pipe(rxjs.distinctUntilChanged()))}get isOpen(){return this._open$.getValue()}dispose(){super.dispose(),this._open$.next(!1),this._open$.complete()}open(){this._open$.next(!0)}close(){this._open$.next(!1)}};__name(_ScriptPanelService,"ScriptPanelService");let ScriptPanelService=_ScriptPanelService;const ScriptPanelComponentName="ScriptPanel",ToggleScriptPanelOperation={type:core.CommandType.OPERATION,id:"univer.operation.toggle-script-panel",handler:__name(accessor=>{const scriptPanelService=accessor.get(ScriptPanelService),sidebarService=accessor.get(ui.ISidebarService);return scriptPanelService.isOpen?(scriptPanelService.close(),sidebarService.close()):(scriptPanelService.open(),sidebarService.open({header:{title:"script-panel.title"},children:{label:ScriptPanelComponentName},width:600})),!0},"handler")};var jsxRuntime={exports:{}},reactJsxRuntime_production_min={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var f=require$$0,k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};function q(c,a,g){var b,d={},e=null,h=null;g!==void 0&&(e=""+g),a.key!==void 0&&(e=""+a.key),a.ref!==void 0&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)d[b]===void 0&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}__name(q,"q");reactJsxRuntime_production_min.Fragment=l;reactJsxRuntime_production_min.jsx=q;reactJsxRuntime_production_min.jsxs=q;jsxRuntime.exports=reactJsxRuntime_production_min;var jsxRuntimeExports=jsxRuntime.exports;const _ScriptEditorService=class _ScriptEditorService extends core.Disposable{constructor(_config){super();__publicField(this,"_editorInstance",null);this._config=_config}setEditorInstance(editor){return this._editorInstance=editor,core.toDisposable(()=>this._editorInstance=null)}getEditorInstance(){return this._editorInstance}requireVscodeEditor(){window.MonacoEnvironment||(window.MonacoEnvironment={getWorkerUrl:this._config.getWorkerUrl})}};__name(_ScriptEditorService,"ScriptEditorService");let ScriptEditorService=_ScriptEditorService;var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2");const IUniscriptExecutionService=core.createIdentifier("univer.uniscript.execution-service");var _a;let UniscriptExecutionService=(_a=class extends core.Disposable{constructor(_logService,_injector){super(),this._logService=_logService,this._injector=_injector}async execute(code){this._logService.log("[UniscriptExecutionService]","executing Uniscript...");const apiInstance=facade.FUniver.newAPI(this._injector),scriptFunction=new Function("univerAPI",`(() => {${code}})()`);try{return scriptFunction(apiInstance),!0}catch(e){return this._logService.error(e),!1}}},__name(_a,"UniscriptExecutionService"),_a);UniscriptExecutionService=__decorateClass$2([__decorateParam$2(0,core.ILogService),__decorateParam$2(1,core.Inject(core.Injector))],UniscriptExecutionService);const scriptEditorPanel="univer-script-editor-panel",scriptEditorContent="univer-script-editor-content",scriptEditorActions="univer-script-editor-actions",styles={scriptEditorPanel,scriptEditorContent,scriptEditorActions};function ScriptEditorPanel(){const editorContentRef=require$$0.useRef(null),editorContainerRef=require$$0.useRef(null),monacoEditorRef=require$$0.useRef(null),localeService=core.useDependency(core.LocaleService),shortcutService=core.useDependency(ui.IShortcutService),editorService=core.useDependency(ScriptEditorService);require$$0.useEffect(()=>{const containerElement=editorContainerRef.current,contentElement=editorContentRef.current;let disposableCollection=null,resizeObserver=null;if(containerElement&&contentElement){editorService.requireVscodeEditor();const monacoEditor$1=monacoEditorRef.current=monacoEditor.editor.create(containerElement,{value:"",language:"javascript"});resizeObserver=new ResizeObserver(()=>{let timer=requestIdleCallback(()=>{if(!timer)return;const{height,width}=contentElement.getBoundingClientRect();monacoEditor$1.layout({width,height}),timer=void 0})}),resizeObserver.observe(contentElement);let terminateEscaping;disposableCollection=new core.DisposableCollection,disposableCollection.add(editorService.setEditorInstance(monacoEditor$1)),disposableCollection.add(monacoEditor$1.onDidFocusEditorWidget(()=>{terminateEscaping=shortcutService.forceEscape()})),disposableCollection.add(monacoEditor$1.onDidBlurEditorWidget(()=>{terminateEscaping==null||terminateEscaping.dispose(),terminateEscaping=void 0})),disposableCollection.add(core.toDisposable(()=>terminateEscaping==null?void 0:terminateEscaping.dispose()))}return()=>{resizeObserver&&contentElement&&resizeObserver.unobserve(contentElement),disposableCollection==null||disposableCollection.dispose()}},[editorService,shortcutService]);const startExecution=useExecution(monacoEditorRef);return jsxRuntimeExports.jsxs("div",{className:styles.scriptEditorPanel,children:[jsxRuntimeExports.jsx("div",{className:styles.scriptEditorContent,ref:editorContentRef,children:jsxRuntimeExports.jsx("div",{className:styles.scriptEditorContainer,ref:editorContainerRef})}),jsxRuntimeExports.jsx("div",{className:styles.scriptEditorActions,children:jsxRuntimeExports.jsx(design.Button,{type:"primary",size:"small",onClick:startExecution,children:localeService.t("script-panel.panel.execute")})})]})}__name(ScriptEditorPanel,"ScriptEditorPanel");function useExecution(monacoEditorRef){const scriptService=core.useDependency(IUniscriptExecutionService),messageService=core.useDependency(ui.IMessageService),localeService=core.useDependency(core.LocaleService);return require$$0.useCallback(()=>{var _a4;const model=(_a4=monacoEditorRef.current)==null?void 0:_a4.getModel();model&&scriptService.execute(model.getValue()).then(()=>{messageService.show({content:localeService.t("uniscript.message.success"),type:design.MessageType.Success})}).catch(()=>{messageService.show({content:localeService.t("uniscript.message.failed"),type:design.MessageType.Error})})},[localeService,messageService,monacoEditorRef,scriptService])}__name(useExecution,"useExecution");function UniscriptMenuItemFactory(accessor){return{id:ToggleScriptPanelOperation.id,title:"toggle-script-panel",tooltip:"script-panel.tooltip.menu-button",icon:"CodeSingle",type:ui.MenuItemType.BUTTON,positions:[ui.MenuPosition.TOOLBAR_START],hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET),disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookEditablePermission],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetSetCellStylePermission,sheets.WorksheetSetCellValuePermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint]})}}__name(UniscriptMenuItemFactory,"UniscriptMenuItemFactory");var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");const DefaultUniscriptConfig={};var _a2;let UniscriptController=(_a2=class extends core.Disposable{constructor(_config,_injector,_menuService,commandService,componentManager){super(),this._config=_config,this._injector=_injector,this._menuService=_menuService;const{menu={}}=this._config;this.disposeWithMe(_menuService.addMenuItem(this._injector.invoke(UniscriptMenuItemFactory),menu)),this.disposeWithMe(componentManager.register(ScriptPanelComponentName,ScriptEditorPanel)),this.disposeWithMe(commandService.registerCommand(ToggleScriptPanelOperation))}},__name(_a2,"UniscriptController"),_a2);UniscriptController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Steady,UniscriptController),__decorateParam$1(1,core.Inject(core.Injector)),__decorateParam$1(2,ui.IMenuService),__decorateParam$1(3,core.ICommandService),__decorateParam$1(4,core.Inject(ui.ComponentManager))],UniscriptController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam");const PLUGIN_NAME="uniscript";var _a3;exports.UniverUniscriptPlugin=(_a3=class extends core.Plugin{constructor(_config={},_injector,_localeService){super(),this._config=_config,this._injector=_injector,this._localeService=_localeService,this._config=core.Tools.deepMerge({},DefaultUniscriptConfig,this._config)}onStarting(){const injector=this._injector;[[UniscriptController,{useFactory:__name(()=>injector.createInstance(UniscriptController,this._config),"useFactory")}],[ScriptEditorService,{useFactory:__name(()=>injector.createInstance(ScriptEditorService,this._config),"useFactory")}],[ScriptPanelService]].forEach(d=>injector.add(d)),this.registerExecution()}registerExecution(){this._injector.add([IUniscriptExecutionService,{useClass:UniscriptExecutionService}])}},__name(_a3,"UniverUniscriptPlugin"),__publicField(_a3,"pluginName",PLUGIN_NAME),_a3);exports.UniverUniscriptPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.Inject(core.LocaleService))],exports.UniverUniscriptPlugin);exports.IUniscriptExecutionService=IUniscriptExecutionService;exports.ScriptEditorService=ScriptEditorService;exports.ToggleScriptPanelOperation=ToggleScriptPanelOperation;
|
package/lib/es/index.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
+
import { Disposable, CommandType, toDisposable, createIdentifier, Inject, Injector, ILogService, useDependency, LocaleService, DisposableCollection, UniverInstanceType, OnLifecycle, LifecycleStages, ICommandService, Plugin, Tools } from "@univerjs/core";
|
|
6
|
+
import { ISidebarService, IShortcutService, IMessageService, MenuItemType, MenuPosition, getMenuHiddenObservable, ComponentManager, IMenuService } from "@univerjs/ui";
|
|
7
|
+
import { BehaviorSubject, distinctUntilChanged } from "rxjs";
|
|
8
|
+
import require$$0, { useRef, useEffect, useCallback } from "react";
|
|
9
|
+
import { Button, MessageType } from "@univerjs/design";
|
|
10
|
+
import { editor } from "monaco-editor";
|
|
11
|
+
import { FUniver } from "@univerjs/facade";
|
|
12
|
+
import { getCurrentRangeDisable$ } from "@univerjs/sheets-ui";
|
|
13
|
+
import { WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission, RangeProtectionPermissionEditPoint } from "@univerjs/sheets";
|
|
14
|
+
const _ScriptPanelService = class _ScriptPanelService extends Disposable {
|
|
14
15
|
constructor() {
|
|
15
16
|
super(...arguments);
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
__publicField(this, "_open$", new BehaviorSubject(!1));
|
|
18
|
+
__publicField(this, "open$", this._open$.pipe(distinctUntilChanged()));
|
|
18
19
|
}
|
|
19
20
|
get isOpen() {
|
|
20
21
|
return this._open$.getValue();
|
|
@@ -28,20 +29,22 @@ class M extends S {
|
|
|
28
29
|
close() {
|
|
29
30
|
this._open$.next(!1);
|
|
30
31
|
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
};
|
|
33
|
+
__name(_ScriptPanelService, "ScriptPanelService");
|
|
34
|
+
let ScriptPanelService = _ScriptPanelService;
|
|
35
|
+
const ScriptPanelComponentName = "ScriptPanel", ToggleScriptPanelOperation = {
|
|
36
|
+
type: CommandType.OPERATION,
|
|
34
37
|
id: "univer.operation.toggle-script-panel",
|
|
35
|
-
handler: (
|
|
36
|
-
const
|
|
37
|
-
return
|
|
38
|
+
handler: /* @__PURE__ */ __name((accessor) => {
|
|
39
|
+
const scriptPanelService = accessor.get(ScriptPanelService), sidebarService = accessor.get(ISidebarService);
|
|
40
|
+
return scriptPanelService.isOpen ? (scriptPanelService.close(), sidebarService.close()) : (scriptPanelService.open(), sidebarService.open({
|
|
38
41
|
header: { title: "script-panel.title" },
|
|
39
|
-
children: { label:
|
|
42
|
+
children: { label: ScriptPanelComponentName },
|
|
40
43
|
width: 600
|
|
41
44
|
})), !0;
|
|
42
|
-
}
|
|
45
|
+
}, "handler")
|
|
43
46
|
};
|
|
44
|
-
var
|
|
47
|
+
var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
|
|
45
48
|
/**
|
|
46
49
|
* @license React
|
|
47
50
|
* react-jsx-runtime.production.min.js
|
|
@@ -51,27 +54,28 @@ var W = { exports: {} }, E = {};
|
|
|
51
54
|
* This source code is licensed under the MIT license found in the
|
|
52
55
|
* LICENSE file in the root directory of this source tree.
|
|
53
56
|
*/
|
|
54
|
-
var
|
|
55
|
-
function
|
|
56
|
-
var
|
|
57
|
-
|
|
58
|
-
for (
|
|
59
|
-
if (
|
|
60
|
-
return { $$typeof:
|
|
57
|
+
var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
58
|
+
function q(c, a, g) {
|
|
59
|
+
var b, d = {}, e = null, h = null;
|
|
60
|
+
g !== void 0 && (e = "" + g), a.key !== void 0 && (e = "" + a.key), a.ref !== void 0 && (h = a.ref);
|
|
61
|
+
for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
62
|
+
if (c && c.defaultProps) for (b in a = c.defaultProps, a) d[b] === void 0 && (d[b] = a[b]);
|
|
63
|
+
return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
|
|
61
64
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
__name(q, "q");
|
|
66
|
+
reactJsxRuntime_production_min.Fragment = l;
|
|
67
|
+
reactJsxRuntime_production_min.jsx = q;
|
|
68
|
+
reactJsxRuntime_production_min.jsxs = q;
|
|
69
|
+
jsxRuntime.exports = reactJsxRuntime_production_min;
|
|
70
|
+
var jsxRuntimeExports = jsxRuntime.exports;
|
|
71
|
+
const _ScriptEditorService = class _ScriptEditorService extends Disposable {
|
|
72
|
+
constructor(_config) {
|
|
69
73
|
super();
|
|
70
|
-
|
|
71
|
-
this._config =
|
|
74
|
+
__publicField(this, "_editorInstance", null);
|
|
75
|
+
this._config = _config;
|
|
72
76
|
}
|
|
73
|
-
setEditorInstance(
|
|
74
|
-
return this._editorInstance =
|
|
77
|
+
setEditorInstance(editor2) {
|
|
78
|
+
return this._editorInstance = editor2, toDisposable(() => this._editorInstance = null);
|
|
75
79
|
}
|
|
76
80
|
getEditorInstance() {
|
|
77
81
|
return this._editorInstance;
|
|
@@ -81,160 +85,166 @@ class x extends S {
|
|
|
81
85
|
getWorkerUrl: this._config.getWorkerUrl
|
|
82
86
|
});
|
|
83
87
|
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
88
|
+
};
|
|
89
|
+
__name(_ScriptEditorService, "ScriptEditorService");
|
|
90
|
+
let ScriptEditorService = _ScriptEditorService;
|
|
91
|
+
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
92
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
93
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
94
|
+
return kind && result && __defProp$2(target, key, result), result;
|
|
95
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2");
|
|
96
|
+
const IUniscriptExecutionService = createIdentifier("univer.uniscript.execution-service");
|
|
97
|
+
var _a;
|
|
98
|
+
let UniscriptExecutionService = (_a = class extends Disposable {
|
|
99
|
+
constructor(_logService, _injector) {
|
|
100
|
+
super(), this._logService = _logService, this._injector = _injector;
|
|
101
|
+
}
|
|
102
|
+
async execute(code) {
|
|
96
103
|
this._logService.log("[UniscriptExecutionService]", "executing Uniscript...");
|
|
97
|
-
const
|
|
104
|
+
const apiInstance = FUniver.newAPI(this._injector), scriptFunction = new Function("univerAPI", `(() => {${code}})()`);
|
|
98
105
|
try {
|
|
99
|
-
return
|
|
100
|
-
} catch (
|
|
101
|
-
return this._logService.error(
|
|
106
|
+
return scriptFunction(apiInstance), !0;
|
|
107
|
+
} catch (e) {
|
|
108
|
+
return this._logService.error(e), !1;
|
|
102
109
|
}
|
|
103
110
|
}
|
|
111
|
+
}, __name(_a, "UniscriptExecutionService"), _a);
|
|
112
|
+
UniscriptExecutionService = __decorateClass$2([
|
|
113
|
+
__decorateParam$2(0, ILogService),
|
|
114
|
+
__decorateParam$2(1, Inject(Injector))
|
|
115
|
+
], UniscriptExecutionService);
|
|
116
|
+
const scriptEditorPanel = "univer-script-editor-panel", scriptEditorContent = "univer-script-editor-content", scriptEditorActions = "univer-script-editor-actions", styles = {
|
|
117
|
+
scriptEditorPanel,
|
|
118
|
+
scriptEditorContent,
|
|
119
|
+
scriptEditorActions
|
|
104
120
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
};
|
|
114
|
-
function Me() {
|
|
115
|
-
const t = P(null), e = P(null), r = P(null), i = p(b), n = p(te), o = p(x);
|
|
116
|
-
ue(() => {
|
|
117
|
-
const C = e.current, a = t.current;
|
|
118
|
-
let c = null, _ = null;
|
|
119
|
-
if (C && a) {
|
|
120
|
-
o.requireVscodeEditor();
|
|
121
|
-
const h = r.current = fe.create(C, {
|
|
121
|
+
function ScriptEditorPanel() {
|
|
122
|
+
const editorContentRef = useRef(null), editorContainerRef = useRef(null), monacoEditorRef = useRef(null), localeService = useDependency(LocaleService), shortcutService = useDependency(IShortcutService), editorService = useDependency(ScriptEditorService);
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
const containerElement = editorContainerRef.current, contentElement = editorContentRef.current;
|
|
125
|
+
let disposableCollection = null, resizeObserver = null;
|
|
126
|
+
if (containerElement && contentElement) {
|
|
127
|
+
editorService.requireVscodeEditor();
|
|
128
|
+
const monacoEditor = monacoEditorRef.current = editor.create(containerElement, {
|
|
122
129
|
value: "",
|
|
123
130
|
language: "javascript"
|
|
124
131
|
});
|
|
125
|
-
|
|
126
|
-
let
|
|
127
|
-
if (!
|
|
128
|
-
const { height
|
|
129
|
-
|
|
132
|
+
resizeObserver = new ResizeObserver(() => {
|
|
133
|
+
let timer = requestIdleCallback(() => {
|
|
134
|
+
if (!timer) return;
|
|
135
|
+
const { height, width } = contentElement.getBoundingClientRect();
|
|
136
|
+
monacoEditor.layout({ width, height }), timer = void 0;
|
|
130
137
|
});
|
|
131
|
-
}),
|
|
132
|
-
let
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
138
|
+
}), resizeObserver.observe(contentElement);
|
|
139
|
+
let terminateEscaping;
|
|
140
|
+
disposableCollection = new DisposableCollection(), disposableCollection.add(editorService.setEditorInstance(monacoEditor)), disposableCollection.add(
|
|
141
|
+
monacoEditor.onDidFocusEditorWidget(() => {
|
|
142
|
+
terminateEscaping = shortcutService.forceEscape();
|
|
136
143
|
})
|
|
137
|
-
),
|
|
138
|
-
|
|
139
|
-
|
|
144
|
+
), disposableCollection.add(
|
|
145
|
+
monacoEditor.onDidBlurEditorWidget(() => {
|
|
146
|
+
terminateEscaping == null || terminateEscaping.dispose(), terminateEscaping = void 0;
|
|
140
147
|
})
|
|
141
|
-
),
|
|
148
|
+
), disposableCollection.add(toDisposable(() => terminateEscaping == null ? void 0 : terminateEscaping.dispose()));
|
|
142
149
|
}
|
|
143
150
|
return () => {
|
|
144
|
-
|
|
151
|
+
resizeObserver && contentElement && resizeObserver.unobserve(contentElement), disposableCollection == null || disposableCollection.dispose();
|
|
145
152
|
};
|
|
146
|
-
}, [
|
|
147
|
-
const
|
|
148
|
-
return /* @__PURE__ */
|
|
149
|
-
/* @__PURE__ */
|
|
150
|
-
/* @__PURE__ */
|
|
153
|
+
}, [editorService, shortcutService]);
|
|
154
|
+
const startExecution = useExecution(monacoEditorRef);
|
|
155
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.scriptEditorPanel, children: [
|
|
156
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.scriptEditorContent, ref: editorContentRef, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.scriptEditorContainer, ref: editorContainerRef }) }),
|
|
157
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.scriptEditorActions, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "primary", size: "small", onClick: startExecution, children: localeService.t("script-panel.panel.execute") }) })
|
|
151
158
|
] });
|
|
152
159
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
__name(ScriptEditorPanel, "ScriptEditorPanel");
|
|
161
|
+
function useExecution(monacoEditorRef) {
|
|
162
|
+
const scriptService = useDependency(IUniscriptExecutionService), messageService = useDependency(IMessageService), localeService = useDependency(LocaleService);
|
|
163
|
+
return useCallback(() => {
|
|
164
|
+
var _a4;
|
|
165
|
+
const model = (_a4 = monacoEditorRef.current) == null ? void 0 : _a4.getModel();
|
|
166
|
+
model && scriptService.execute(model.getValue()).then(() => {
|
|
167
|
+
messageService.show({
|
|
168
|
+
content: localeService.t("uniscript.message.success"),
|
|
169
|
+
type: MessageType.Success
|
|
162
170
|
});
|
|
163
171
|
}).catch(() => {
|
|
164
|
-
|
|
165
|
-
content:
|
|
166
|
-
type:
|
|
172
|
+
messageService.show({
|
|
173
|
+
content: localeService.t("uniscript.message.failed"),
|
|
174
|
+
type: MessageType.Error
|
|
167
175
|
});
|
|
168
176
|
});
|
|
169
|
-
}, [
|
|
177
|
+
}, [localeService, messageService, monacoEditorRef, scriptService]);
|
|
170
178
|
}
|
|
171
|
-
|
|
179
|
+
__name(useExecution, "useExecution");
|
|
180
|
+
function UniscriptMenuItemFactory(accessor) {
|
|
172
181
|
return {
|
|
173
|
-
id:
|
|
182
|
+
id: ToggleScriptPanelOperation.id,
|
|
174
183
|
title: "toggle-script-panel",
|
|
175
184
|
tooltip: "script-panel.tooltip.menu-button",
|
|
176
185
|
icon: "CodeSingle",
|
|
177
|
-
type:
|
|
178
|
-
positions: [
|
|
186
|
+
type: MenuItemType.BUTTON,
|
|
187
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
179
188
|
// FIXME hidden$ and disabled$ are not correctly in doc
|
|
180
|
-
hidden$:
|
|
181
|
-
disabled$:
|
|
189
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
190
|
+
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
182
191
|
};
|
|
183
192
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
193
|
+
__name(UniscriptMenuItemFactory, "UniscriptMenuItemFactory");
|
|
194
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
195
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
196
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
197
|
+
return kind && result && __defProp$1(target, key, result), result;
|
|
198
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
|
|
199
|
+
const DefaultUniscriptConfig = {};
|
|
200
|
+
var _a2;
|
|
201
|
+
let UniscriptController = (_a2 = class extends Disposable {
|
|
202
|
+
constructor(_config, _injector, _menuService, commandService, componentManager) {
|
|
203
|
+
super(), this._config = _config, this._injector = _injector, this._menuService = _menuService;
|
|
204
|
+
const { menu = {} } = this._config;
|
|
205
|
+
this.disposeWithMe(_menuService.addMenuItem(this._injector.invoke(UniscriptMenuItemFactory), menu)), this.disposeWithMe(componentManager.register(ScriptPanelComponentName, ScriptEditorPanel)), this.disposeWithMe(commandService.registerCommand(ToggleScriptPanelOperation));
|
|
206
|
+
}
|
|
207
|
+
}, __name(_a2, "UniscriptController"), _a2);
|
|
208
|
+
UniscriptController = __decorateClass$1([
|
|
209
|
+
OnLifecycle(LifecycleStages.Steady, UniscriptController),
|
|
210
|
+
__decorateParam$1(1, Inject(Injector)),
|
|
211
|
+
__decorateParam$1(2, IMenuService),
|
|
212
|
+
__decorateParam$1(3, ICommandService),
|
|
213
|
+
__decorateParam$1(4, Inject(ComponentManager))
|
|
214
|
+
], UniscriptController);
|
|
215
|
+
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
216
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
217
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
218
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
219
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam");
|
|
220
|
+
const PLUGIN_NAME = "uniscript";
|
|
221
|
+
var _a3;
|
|
222
|
+
let UniverUniscriptPlugin = (_a3 = class extends Plugin {
|
|
223
|
+
constructor(_config = {}, _injector, _localeService) {
|
|
224
|
+
super(), this._config = _config, this._injector = _injector, this._localeService = _localeService, this._config = Tools.deepMerge({}, DefaultUniscriptConfig, this._config);
|
|
225
|
+
}
|
|
226
|
+
onStarting() {
|
|
227
|
+
const injector = this._injector;
|
|
216
228
|
[
|
|
217
|
-
|
|
218
|
-
[
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
[M]
|
|
222
|
-
].forEach((r) => t.add(r)), this.registerExecution();
|
|
229
|
+
[UniscriptController, { useFactory: /* @__PURE__ */ __name(() => injector.createInstance(UniscriptController, this._config), "useFactory") }],
|
|
230
|
+
[ScriptEditorService, { useFactory: /* @__PURE__ */ __name(() => injector.createInstance(ScriptEditorService, this._config), "useFactory") }],
|
|
231
|
+
[ScriptPanelService]
|
|
232
|
+
].forEach((d) => injector.add(d)), this.registerExecution();
|
|
223
233
|
}
|
|
224
234
|
/**
|
|
225
235
|
* Allows being overridden, replacing with a new UniscriptExecutionService.
|
|
226
236
|
*/
|
|
227
237
|
registerExecution() {
|
|
228
|
-
this._injector.add([
|
|
238
|
+
this._injector.add([IUniscriptExecutionService, { useClass: UniscriptExecutionService }]);
|
|
229
239
|
}
|
|
230
|
-
},
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
],
|
|
240
|
+
}, __name(_a3, "UniverUniscriptPlugin"), __publicField(_a3, "pluginName", PLUGIN_NAME), _a3);
|
|
241
|
+
UniverUniscriptPlugin = __decorateClass([
|
|
242
|
+
__decorateParam(1, Inject(Injector)),
|
|
243
|
+
__decorateParam(2, Inject(LocaleService))
|
|
244
|
+
], UniverUniscriptPlugin);
|
|
235
245
|
export {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
246
|
+
IUniscriptExecutionService,
|
|
247
|
+
ScriptEditorService,
|
|
248
|
+
ToggleScriptPanelOperation,
|
|
249
|
+
UniverUniscriptPlugin
|
|
240
250
|
};
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare class UniverUniscriptPlugin extends Plugin {
|
|
|
7
7
|
private readonly _localeService;
|
|
8
8
|
static pluginName: string;
|
|
9
9
|
constructor(_config: Partial<IUniverUniscriptConfig>, _injector: Injector, _localeService: LocaleService);
|
|
10
|
-
onStarting(
|
|
10
|
+
onStarting(): void;
|
|
11
11
|
/**
|
|
12
12
|
* Allows being overridden, replacing with a new UniscriptExecutionService.
|
|
13
13
|
*/
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("react"),require("@univerjs/design"),require("monaco-editor"),require("@univerjs/facade"),require("@univerjs/sheets-ui"),require("@univerjs/sheets")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/ui","rxjs","react","@univerjs/design","monaco-editor","@univerjs/facade","@univerjs/sheets-ui","@univerjs/sheets"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverUniscript={},global.UniverCore,global.UniverUi,global.rxjs,global.React,global.UniverDesign,global.monaco,global.UniverFacade,global.UniverSheetsUi,global.UniverSheets))})(this,function(exports2,core,ui,rxjs,require$$0,design,monacoEditor,facade,sheetsUi,sheets){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c;const _ScriptPanelService=class _ScriptPanelService extends core.Disposable{constructor(){super(...arguments);__publicField(this,"_open$",new rxjs.BehaviorSubject(!1));__publicField(this,"open$",this._open$.pipe(rxjs.distinctUntilChanged()))}get isOpen(){return this._open$.getValue()}dispose(){super.dispose(),this._open$.next(!1),this._open$.complete()}open(){this._open$.next(!0)}close(){this._open$.next(!1)}};__name(_ScriptPanelService,"ScriptPanelService");let ScriptPanelService=_ScriptPanelService;const ScriptPanelComponentName="ScriptPanel",ToggleScriptPanelOperation={type:core.CommandType.OPERATION,id:"univer.operation.toggle-script-panel",handler:__name(accessor=>{const scriptPanelService=accessor.get(ScriptPanelService),sidebarService=accessor.get(ui.ISidebarService);return scriptPanelService.isOpen?(scriptPanelService.close(),sidebarService.close()):(scriptPanelService.open(),sidebarService.open({header:{title:"script-panel.title"},children:{label:ScriptPanelComponentName},width:600})),!0},"handler")};var jsxRuntime={exports:{}},reactJsxRuntime_production_min={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var f=require$$0,k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};function q(c,a,g){var b,d={},e=null,h=null;g!==void 0&&(e=""+g),a.key!==void 0&&(e=""+a.key),a.ref!==void 0&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)d[b]===void 0&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}__name(q,"q"),reactJsxRuntime_production_min.Fragment=l,reactJsxRuntime_production_min.jsx=q,reactJsxRuntime_production_min.jsxs=q,jsxRuntime.exports=reactJsxRuntime_production_min;var jsxRuntimeExports=jsxRuntime.exports;const _ScriptEditorService=class _ScriptEditorService extends core.Disposable{constructor(_config){super();__publicField(this,"_editorInstance",null);this._config=_config}setEditorInstance(editor){return this._editorInstance=editor,core.toDisposable(()=>this._editorInstance=null)}getEditorInstance(){return this._editorInstance}requireVscodeEditor(){window.MonacoEnvironment||(window.MonacoEnvironment={getWorkerUrl:this._config.getWorkerUrl})}};__name(_ScriptEditorService,"ScriptEditorService");let ScriptEditorService=_ScriptEditorService;var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2");const IUniscriptExecutionService=core.createIdentifier("univer.uniscript.execution-service");let UniscriptExecutionService=(_a=class extends core.Disposable{constructor(_logService,_injector){super(),this._logService=_logService,this._injector=_injector}async execute(code){this._logService.log("[UniscriptExecutionService]","executing Uniscript...");const apiInstance=facade.FUniver.newAPI(this._injector),scriptFunction=new Function("univerAPI",`(() => {${code}})()`);try{return scriptFunction(apiInstance),!0}catch(e){return this._logService.error(e),!1}}},__name(_a,"UniscriptExecutionService"),_a);UniscriptExecutionService=__decorateClass$2([__decorateParam$2(0,core.ILogService),__decorateParam$2(1,core.Inject(core.Injector))],UniscriptExecutionService);const styles={scriptEditorPanel:"univer-script-editor-panel",scriptEditorContent:"univer-script-editor-content",scriptEditorActions:"univer-script-editor-actions"};function ScriptEditorPanel(){const editorContentRef=require$$0.useRef(null),editorContainerRef=require$$0.useRef(null),monacoEditorRef=require$$0.useRef(null),localeService=core.useDependency(core.LocaleService),shortcutService=core.useDependency(ui.IShortcutService),editorService=core.useDependency(ScriptEditorService);require$$0.useEffect(()=>{const containerElement=editorContainerRef.current,contentElement=editorContentRef.current;let disposableCollection=null,resizeObserver=null;if(containerElement&&contentElement){editorService.requireVscodeEditor();const monacoEditor$1=monacoEditorRef.current=monacoEditor.editor.create(containerElement,{value:"",language:"javascript"});resizeObserver=new ResizeObserver(()=>{let timer=requestIdleCallback(()=>{if(!timer)return;const{height,width}=contentElement.getBoundingClientRect();monacoEditor$1.layout({width,height}),timer=void 0})}),resizeObserver.observe(contentElement);let terminateEscaping;disposableCollection=new core.DisposableCollection,disposableCollection.add(editorService.setEditorInstance(monacoEditor$1)),disposableCollection.add(monacoEditor$1.onDidFocusEditorWidget(()=>{terminateEscaping=shortcutService.forceEscape()})),disposableCollection.add(monacoEditor$1.onDidBlurEditorWidget(()=>{terminateEscaping==null||terminateEscaping.dispose(),terminateEscaping=void 0})),disposableCollection.add(core.toDisposable(()=>terminateEscaping==null?void 0:terminateEscaping.dispose()))}return()=>{resizeObserver&&contentElement&&resizeObserver.unobserve(contentElement),disposableCollection==null||disposableCollection.dispose()}},[editorService,shortcutService]);const startExecution=useExecution(monacoEditorRef);return jsxRuntimeExports.jsxs("div",{className:styles.scriptEditorPanel,children:[jsxRuntimeExports.jsx("div",{className:styles.scriptEditorContent,ref:editorContentRef,children:jsxRuntimeExports.jsx("div",{className:styles.scriptEditorContainer,ref:editorContainerRef})}),jsxRuntimeExports.jsx("div",{className:styles.scriptEditorActions,children:jsxRuntimeExports.jsx(design.Button,{type:"primary",size:"small",onClick:startExecution,children:localeService.t("script-panel.panel.execute")})})]})}__name(ScriptEditorPanel,"ScriptEditorPanel");function useExecution(monacoEditorRef){const scriptService=core.useDependency(IUniscriptExecutionService),messageService=core.useDependency(ui.IMessageService),localeService=core.useDependency(core.LocaleService);return require$$0.useCallback(()=>{var _a2;const model=(_a2=monacoEditorRef.current)==null?void 0:_a2.getModel();model&&scriptService.execute(model.getValue()).then(()=>{messageService.show({content:localeService.t("uniscript.message.success"),type:design.MessageType.Success})}).catch(()=>{messageService.show({content:localeService.t("uniscript.message.failed"),type:design.MessageType.Error})})},[localeService,messageService,monacoEditorRef,scriptService])}__name(useExecution,"useExecution");function UniscriptMenuItemFactory(accessor){return{id:ToggleScriptPanelOperation.id,title:"toggle-script-panel",tooltip:"script-panel.tooltip.menu-button",icon:"CodeSingle",type:ui.MenuItemType.BUTTON,positions:[ui.MenuPosition.TOOLBAR_START],hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET),disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookEditablePermission],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetSetCellStylePermission,sheets.WorksheetSetCellValuePermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint]})}}__name(UniscriptMenuItemFactory,"UniscriptMenuItemFactory");var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");const DefaultUniscriptConfig={};let UniscriptController=(_b=class extends core.Disposable{constructor(_config,_injector,_menuService,commandService,componentManager){super(),this._config=_config,this._injector=_injector,this._menuService=_menuService;const{menu={}}=this._config;this.disposeWithMe(_menuService.addMenuItem(this._injector.invoke(UniscriptMenuItemFactory),menu)),this.disposeWithMe(componentManager.register(ScriptPanelComponentName,ScriptEditorPanel)),this.disposeWithMe(commandService.registerCommand(ToggleScriptPanelOperation))}},__name(_b,"UniscriptController"),_b);UniscriptController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Steady,UniscriptController),__decorateParam$1(1,core.Inject(core.Injector)),__decorateParam$1(2,ui.IMenuService),__decorateParam$1(3,core.ICommandService),__decorateParam$1(4,core.Inject(ui.ComponentManager))],UniscriptController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam");const PLUGIN_NAME="uniscript";exports2.UniverUniscriptPlugin=(_c=class extends core.Plugin{constructor(_config={},_injector,_localeService){super(),this._config=_config,this._injector=_injector,this._localeService=_localeService,this._config=core.Tools.deepMerge({},DefaultUniscriptConfig,this._config)}onStarting(){const injector=this._injector;[[UniscriptController,{useFactory:__name(()=>injector.createInstance(UniscriptController,this._config),"useFactory")}],[ScriptEditorService,{useFactory:__name(()=>injector.createInstance(ScriptEditorService,this._config),"useFactory")}],[ScriptPanelService]].forEach(d=>injector.add(d)),this.registerExecution()}registerExecution(){this._injector.add([IUniscriptExecutionService,{useClass:UniscriptExecutionService}])}},__name(_c,"UniverUniscriptPlugin"),__publicField(_c,"pluginName",PLUGIN_NAME),_c),exports2.UniverUniscriptPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.Inject(core.LocaleService))],exports2.UniverUniscriptPlugin),exports2.IUniscriptExecutionService=IUniscriptExecutionService,exports2.ScriptEditorService=ScriptEditorService,exports2.ToggleScriptPanelOperation=ToggleScriptPanelOperation,Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/uniscript",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "UI component library for building exceptional Univer.",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
"monaco-editor": ">=0.44.0",
|
|
54
54
|
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
|
|
55
55
|
"rxjs": ">=7.0.0",
|
|
56
|
-
"@univerjs/core": "0.2.
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/sheets": "0.2.
|
|
59
|
-
"@univerjs/
|
|
60
|
-
"@univerjs/sheets-ui": "0.2.
|
|
61
|
-
"@univerjs/ui": "0.2.
|
|
56
|
+
"@univerjs/core": "0.2.6",
|
|
57
|
+
"@univerjs/design": "0.2.6",
|
|
58
|
+
"@univerjs/sheets": "0.2.6",
|
|
59
|
+
"@univerjs/facade": "0.2.6",
|
|
60
|
+
"@univerjs/sheets-ui": "0.2.6",
|
|
61
|
+
"@univerjs/ui": "0.2.6"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@univerjs/protocol": "0.1.38-alpha.23"
|
|
@@ -68,16 +68,16 @@
|
|
|
68
68
|
"less": "^4.2.0",
|
|
69
69
|
"monaco-editor": "0.50.0",
|
|
70
70
|
"rxjs": "^7.8.1",
|
|
71
|
-
"typescript": "^5.5.
|
|
72
|
-
"vite": "^5.3.
|
|
73
|
-
"vitest": "^2.0.
|
|
74
|
-
"@univerjs/
|
|
75
|
-
"@univerjs/
|
|
76
|
-
"@univerjs/shared": "0.2.
|
|
77
|
-
"@univerjs/
|
|
78
|
-
"@univerjs/
|
|
79
|
-
"@univerjs/sheets": "0.2.
|
|
80
|
-
"@univerjs/
|
|
71
|
+
"typescript": "^5.5.4",
|
|
72
|
+
"vite": "^5.3.5",
|
|
73
|
+
"vitest": "^2.0.4",
|
|
74
|
+
"@univerjs/core": "0.2.6",
|
|
75
|
+
"@univerjs/design": "0.2.6",
|
|
76
|
+
"@univerjs/shared": "0.2.6",
|
|
77
|
+
"@univerjs/facade": "0.2.6",
|
|
78
|
+
"@univerjs/sheets": "0.2.6",
|
|
79
|
+
"@univerjs/sheets-ui": "0.2.6",
|
|
80
|
+
"@univerjs/ui": "0.2.6"
|
|
81
81
|
},
|
|
82
82
|
"univerSpace": {
|
|
83
83
|
".": {
|