@univerjs/uniscript 0.3.0-nightly.202410101606 → 0.3.0-nightly.202410111606
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 +9 -1
- package/lib/es/index.js +264 -1
- package/lib/locale/fa-IR.json +17 -0
- package/lib/types/locale/fa-IR.d.ts +3 -0
- package/lib/umd/index.js +9 -1
- package/package.json +16 -16
package/lib/cjs/index.js
CHANGED
@@ -1 +1,9 @@
|
|
1
|
-
'use strict';var _0x23b817=_0x4a2c;(function(_0x10817e,_0x2ace2e){var _0x47b45b=_0x4a2c,_0x386f38=_0x10817e();while(!![]){try{var _0x1c4321=parseInt(_0x47b45b(0x1ae))/0x1+-parseInt(_0x47b45b(0x228))/0x2+-parseInt(_0x47b45b(0x224))/0x3+parseInt(_0x47b45b(0x1f4))/0x4*(-parseInt(_0x47b45b(0x1b4))/0x5)+parseInt(_0x47b45b(0x217))/0x6*(parseInt(_0x47b45b(0x1df))/0x7)+parseInt(_0x47b45b(0x1d5))/0x8*(parseInt(_0x47b45b(0x22c))/0x9)+-parseInt(_0x47b45b(0x218))/0xa*(-parseInt(_0x47b45b(0x207))/0xb);if(_0x1c4321===_0x2ace2e)break;else _0x386f38['push'](_0x386f38['shift']());}catch(_0x44dd69){_0x386f38['push'](_0x386f38['shift']());}}}(_0x2ff6,0x6663e));var __defProp=Object[_0x23b817(0x219)],__defNormalProp=(_0x537055,_0x2a6b63,_0x5c5af2)=>_0x2a6b63 in _0x537055?__defProp(_0x537055,_0x2a6b63,{'enumerable':!0x0,'configurable':!0x0,'writable':!0x0,'value':_0x5c5af2}):_0x537055[_0x2a6b63]=_0x5c5af2,__name=(_0x428b82,_0x742b39)=>__defProp(_0x428b82,_0x23b817(0x1bf),{'value':_0x742b39,'configurable':!0x0}),__publicField=(_0x52eceb,_0x101298,_0x78957f)=>__defNormalProp(_0x52eceb,typeof _0x101298!=_0x23b817(0x236)?_0x101298+'':_0x101298,_0x78957f);Object[_0x23b817(0x219)](exports,Symbol[_0x23b817(0x21a)],{'value':_0x23b817(0x1d9)});const core=require(_0x23b817(0x1dc)),ui=require('@univerjs/ui'),rxjs=require(_0x23b817(0x21b)),require$$0=require(_0x23b817(0x1db)),design=require(_0x23b817(0x216)),monacoEditor=require(_0x23b817(0x1ca)),facade=require(_0x23b817(0x220)),sheetsUi=require(_0x23b817(0x1a4)),sheets=require(_0x23b817(0x201)),PLUGIN_CONFIG_KEY=_0x23b817(0x21d),defaultPluginConfig={},_ScriptPanelService=class _ScriptPanelService extends core[_0x23b817(0x1fb)]{constructor(){var _0x3bd620=_0x23b817;super(...arguments),__publicField(this,_0x3bd620(0x1cc),new rxjs[(_0x3bd620(0x1da))](!0x1)),__publicField(this,'open$',this[_0x3bd620(0x1cc)][_0x3bd620(0x202)](rxjs[_0x3bd620(0x212)]()));}get[_0x23b817(0x20e)](){var _0x97ee0d=_0x23b817;return this[_0x97ee0d(0x1cc)][_0x97ee0d(0x1d7)]();}[_0x23b817(0x21c)](){var _0x22bc1c=_0x23b817;super[_0x22bc1c(0x21c)](),this[_0x22bc1c(0x1cc)][_0x22bc1c(0x1c8)](!0x1),this[_0x22bc1c(0x1cc)]['complete']();}[_0x23b817(0x204)](){var _0x1bb9a4=_0x23b817;this[_0x1bb9a4(0x1cc)]['next'](!0x0);}[_0x23b817(0x1f3)](){var _0x5d7513=_0x23b817;this[_0x5d7513(0x1cc)][_0x5d7513(0x1c8)](!0x1);}};__name(_ScriptPanelService,_0x23b817(0x1ec));let ScriptPanelService=_ScriptPanelService;const ScriptPanelComponentName='ScriptPanel',ToggleScriptPanelOperation={'type':core[_0x23b817(0x1a9)][_0x23b817(0x1bd)],'id':_0x23b817(0x1fd),'handler':__name(_0x4f59f0=>{var _0x26145e=_0x23b817;const _0x464327=_0x4f59f0[_0x26145e(0x1cf)](ScriptPanelService),_0x5dd433=_0x4f59f0['get'](ui[_0x26145e(0x1a7)]);return _0x464327['isOpen']?(_0x464327[_0x26145e(0x1f3)](),_0x5dd433[_0x26145e(0x1f3)]()):(_0x464327[_0x26145e(0x204)](),_0x5dd433['open']({'header':{'title':_0x26145e(0x214)},'children':{'label':ScriptPanelComponentName},'width':0x258})),!0x0;},_0x23b817(0x1ed))};var jsxRuntime={'exports':{}},reactJsxRuntime_production_min={},f=require$$0,k=Symbol[_0x23b817(0x208)](_0x23b817(0x235)),l=Symbol[_0x23b817(0x208)](_0x23b817(0x21e)),m=Object['prototype'][_0x23b817(0x23b)],n=f[_0x23b817(0x233)][_0x23b817(0x1eb)],p={'key':!0x0,'ref':!0x0,'__self':!0x0,'__source':!0x0};function _0x2ff6(){var _0x2e3d8c=['uniscript.message.failed','MonacoEnvironment','pluginName','738249HeHPSH','add','useEffect','univer-script-editor-content','1045432iyeeTG','catch','WorksheetSetCellValuePermission','UNIVER_UNISCRIPT_PLUGIN','27oTpOgs','__decorateClass$1','univer-script-editor-actions','call','getMenuHiddenObservable','jsx','univer-script-editor-panel','__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED','_configService','react.element','symbol','forEach','setEditorInstance','execute','DisposableCollection','hasOwnProperty','jsxs','getBoundingClientRect','Success','show','@univerjs/sheets-ui','BUTTON','createIdentifier','ISidebarService','scriptEditorContent','CommandType','length','ILogService','__decorateParam$3','ToggleScriptPanelOperation','376818bmfQho','onSteady','__decorateClass$2','RangeProtectionPermissionEditPoint','registerExecution','useExecution','95hzMwru','FUniver','useCallback','_logService','menu','CodeSingle','__decorateClass$3','_menuManagerService','getModel','OPERATION','ScriptEditorService','name','onDidFocusEditorWidget','javascript','Button','getCurrentRangeDisable$','WorksheetEditPermission','useDependency','script-panel.panel.execute','scriptEditorActions','next','unobserve','monaco-editor','mergeMenu','_open$','_injector','getConfig','get','current','UNIVER_SHEET','__decorateParam$1','Fragment','key','825488whHQbw','defaultProps','getValue','toDisposable','Module','BehaviorSubject','react','@univerjs/core','IMessageService','UniverUniscriptPlugin','28YYvajo','_config','create','register','primary','getWorkerUrl','scriptEditorContainer','getEditorInstance','layout','__decorateParam','__decorateClass','Plugin','ReactCurrentOwner','ScriptPanelService','handler','log','MenuItemType','disposeWithMe','__decorateParam$2','IConfigService','close','131476VazJML','})()','forceEscape','ref','useRef','univerAPI','error','Disposable','uniscript.message.success','univer.operation.toggle-script-panel','div','observe','Injector','@univerjs/sheets','pipe','setConfig','open','editor','[UniscriptExecutionService]','10813ywKqqe','for','LocaleService','RibbonStartGroup','MessageType','_editorInstance','exports','isOpen','getOwnPropertyDescriptor','UniscriptMenuItemFactory','newAPI','distinctUntilChanged','then','script-panel.title','IUniscriptExecutionService','@univerjs/design','73434tSmXiz','10960hkPxVp','defineProperty','toStringTag','rxjs','dispose','uniscript.config','react.fragment','UniscriptController','@univerjs/facade'];_0x2ff6=function(){return _0x2e3d8c;};return _0x2ff6();}function q(_0x1e8bad,_0x254403,_0x1d26c6){var _0x29f83e=_0x23b817,_0x367e83,_0x397cf3={},_0x21bf67=null,_0x147623=null;_0x1d26c6!==void 0x0&&(_0x21bf67=''+_0x1d26c6),_0x254403['key']!==void 0x0&&(_0x21bf67=''+_0x254403[_0x29f83e(0x1d4)]),_0x254403[_0x29f83e(0x1f7)]!==void 0x0&&(_0x147623=_0x254403[_0x29f83e(0x1f7)]);for(_0x367e83 in _0x254403)m[_0x29f83e(0x22f)](_0x254403,_0x367e83)&&!p[_0x29f83e(0x23b)](_0x367e83)&&(_0x397cf3[_0x367e83]=_0x254403[_0x367e83]);if(_0x1e8bad&&_0x1e8bad[_0x29f83e(0x1d6)]){for(_0x367e83 in(_0x254403=_0x1e8bad[_0x29f83e(0x1d6)],_0x254403))_0x397cf3[_0x367e83]===void 0x0&&(_0x397cf3[_0x367e83]=_0x254403[_0x367e83]);}return{'$$typeof':k,'type':_0x1e8bad,'key':_0x21bf67,'ref':_0x147623,'props':_0x397cf3,'_owner':n[_0x29f83e(0x1d0)]};}__name(q,'q'),reactJsxRuntime_production_min[_0x23b817(0x1d3)]=l,reactJsxRuntime_production_min['jsx']=q,reactJsxRuntime_production_min[_0x23b817(0x23c)]=q,jsxRuntime[_0x23b817(0x20d)]=reactJsxRuntime_production_min;var jsxRuntimeExports=jsxRuntime['exports'],__defProp$3=Object['defineProperty'],__getOwnPropDesc$3=Object[_0x23b817(0x20f)],__decorateClass$3=__name((_0x3bb685,_0x41a3d1,_0x1593fc,_0xba9d66)=>{for(var _0xe04191=_0xba9d66>0x1?void 0x0:_0xba9d66?__getOwnPropDesc$3(_0x41a3d1,_0x1593fc):_0x41a3d1,_0x2f03df=_0x3bb685['length']-0x1,_0x13c4e0;_0x2f03df>=0x0;_0x2f03df--)(_0x13c4e0=_0x3bb685[_0x2f03df])&&(_0xe04191=(_0xba9d66?_0x13c4e0(_0x41a3d1,_0x1593fc,_0xe04191):_0x13c4e0(_0xe04191))||_0xe04191);return _0xba9d66&&_0xe04191&&__defProp$3(_0x41a3d1,_0x1593fc,_0xe04191),_0xe04191;},_0x23b817(0x1ba)),__decorateParam$3=__name((_0x17a95f,_0x4efa34)=>(_0x13f489,_0x8d0321)=>_0x4efa34(_0x13f489,_0x8d0321,_0x17a95f),_0x23b817(0x1ac)),_a;exports[_0x23b817(0x1be)]=(_a=class extends core[_0x23b817(0x1fb)]{constructor(_0x25c54a){var _0x5c48e9=_0x23b817;super(),__publicField(this,'_editorInstance',null),this[_0x5c48e9(0x234)]=_0x25c54a;}[_0x23b817(0x238)](_0x336198){var _0x174d5d=_0x23b817;return this['_editorInstance']=_0x336198,core[_0x174d5d(0x1d8)](()=>this['_editorInstance']=null);}[_0x23b817(0x1e6)](){var _0x2475f3=_0x23b817;return this[_0x2475f3(0x20c)];}['requireVscodeEditor'](){var _0x423ae2=_0x23b817;if(!window[_0x423ae2(0x222)]){const _0x41d7ad=this[_0x423ae2(0x234)][_0x423ae2(0x1ce)](PLUGIN_CONFIG_KEY);window['MonacoEnvironment']={'getWorkerUrl':_0x41d7ad==null?void 0x0:_0x41d7ad[_0x423ae2(0x1e4)]};}}},__name(_a,_0x23b817(0x1be)),_a),exports[_0x23b817(0x1be)]=__decorateClass$3([__decorateParam$3(0x0,core[_0x23b817(0x1f2)])],exports[_0x23b817(0x1be)]);function _0x4a2c(_0x288987,_0x54c290){var _0x2ff664=_0x2ff6();return _0x4a2c=function(_0x4a2c04,_0x184431){_0x4a2c04=_0x4a2c04-0x1a3;var _0x226aab=_0x2ff664[_0x4a2c04];return _0x226aab;},_0x4a2c(_0x288987,_0x54c290);}var __defProp$2=Object['defineProperty'],__getOwnPropDesc$2=Object['getOwnPropertyDescriptor'],__decorateClass$2=__name((_0x46f393,_0x4bfbaf,_0x2dae1b,_0x3a3e27)=>{var _0x4ded93=_0x23b817;for(var _0x1df702=_0x3a3e27>0x1?void 0x0:_0x3a3e27?__getOwnPropDesc$2(_0x4bfbaf,_0x2dae1b):_0x4bfbaf,_0x9fae93=_0x46f393[_0x4ded93(0x1aa)]-0x1,_0x199719;_0x9fae93>=0x0;_0x9fae93--)(_0x199719=_0x46f393[_0x9fae93])&&(_0x1df702=(_0x3a3e27?_0x199719(_0x4bfbaf,_0x2dae1b,_0x1df702):_0x199719(_0x1df702))||_0x1df702);return _0x3a3e27&&_0x1df702&&__defProp$2(_0x4bfbaf,_0x2dae1b,_0x1df702),_0x1df702;},_0x23b817(0x1b0)),__decorateParam$2=__name((_0x35b008,_0x37cc44)=>(_0xe45a19,_0x306072)=>_0x37cc44(_0xe45a19,_0x306072,_0x35b008),_0x23b817(0x1f1));const IUniscriptExecutionService=core[_0x23b817(0x1a6)]('univer.uniscript.execution-service');var _a2;let UniscriptExecutionService=(_a2=class extends core[_0x23b817(0x1fb)]{constructor(_0x38184e,_0x134772){var _0x145fec=_0x23b817;super(),this[_0x145fec(0x1b7)]=_0x38184e,this[_0x145fec(0x1cd)]=_0x134772;}async[_0x23b817(0x239)](_0x2c121a){var _0x2a0b98=_0x23b817;this['_logService'][_0x2a0b98(0x1ee)](_0x2a0b98(0x206),'executing\x20Uniscript...');const _0xd3b7c1=facade[_0x2a0b98(0x1b5)][_0x2a0b98(0x211)](this[_0x2a0b98(0x1cd)]),_0xa14407=new Function(_0x2a0b98(0x1f9),'(()\x20=>\x20{'+_0x2c121a+_0x2a0b98(0x1f5));try{return _0xa14407(_0xd3b7c1),!0x0;}catch(_0x477db2){return this['_logService'][_0x2a0b98(0x1fa)](_0x477db2),!0x1;}}},__name(_a2,'UniscriptExecutionService'),_a2);UniscriptExecutionService=__decorateClass$2([__decorateParam$2(0x0,core[_0x23b817(0x1ab)]),__decorateParam$2(0x1,core['Inject'](core['Injector']))],UniscriptExecutionService);const scriptEditorPanel=_0x23b817(0x232),scriptEditorContent=_0x23b817(0x227),scriptEditorActions=_0x23b817(0x22e),styles={'scriptEditorPanel':scriptEditorPanel,'scriptEditorContent':scriptEditorContent,'scriptEditorActions':scriptEditorActions};function ScriptEditorPanel(){var _0x3a056c=_0x23b817;const _0x5cc535=require$$0[_0x3a056c(0x1f8)](null),_0x18510b=require$$0[_0x3a056c(0x1f8)](null),_0x4dfe25=require$$0[_0x3a056c(0x1f8)](null),_0x638daa=core['useDependency'](core['LocaleService']),_0x9b49d5=core[_0x3a056c(0x1c5)](ui['IShortcutService']),_0x79dd=core[_0x3a056c(0x1c5)](exports['ScriptEditorService']);require$$0[_0x3a056c(0x226)](()=>{var _0x925723=_0x3a056c;const _0xe344da=_0x18510b['current'],_0x17a76a=_0x5cc535['current'];let _0x4ea9f3=null,_0x27a8b5=null;if(_0xe344da&&_0x17a76a){_0x79dd['requireVscodeEditor']();const _0x43e837=_0x4dfe25[_0x925723(0x1d0)]=monacoEditor[_0x925723(0x205)][_0x925723(0x1e1)](_0xe344da,{'value':'','language':_0x925723(0x1c1)});_0x27a8b5=new ResizeObserver(()=>{let _0x4d5072=requestIdleCallback(()=>{var _0x5c0465=_0x4a2c;if(!_0x4d5072)return;const {height:_0x5aa1b7,width:_0x477c41}=_0x17a76a[_0x5c0465(0x23d)]();_0x43e837[_0x5c0465(0x1e7)]({'width':_0x477c41,'height':_0x5aa1b7}),_0x4d5072=void 0x0;});}),_0x27a8b5[_0x925723(0x1ff)](_0x17a76a);let _0x24b801;_0x4ea9f3=new core[(_0x925723(0x23a))](),_0x4ea9f3[_0x925723(0x225)](_0x79dd[_0x925723(0x238)](_0x43e837)),_0x4ea9f3[_0x925723(0x225)](_0x43e837[_0x925723(0x1c0)](()=>{var _0x4da375=_0x925723;_0x24b801=_0x9b49d5[_0x4da375(0x1f6)]();})),_0x4ea9f3[_0x925723(0x225)](_0x43e837['onDidBlurEditorWidget'](()=>{var _0x244ef9=_0x925723;_0x24b801==null||_0x24b801[_0x244ef9(0x21c)](),_0x24b801=void 0x0;})),_0x4ea9f3[_0x925723(0x225)](core['toDisposable'](()=>_0x24b801==null?void 0x0:_0x24b801[_0x925723(0x21c)]()));}return()=>{var _0x2ab9d0=_0x925723;_0x27a8b5&&_0x17a76a&&_0x27a8b5[_0x2ab9d0(0x1c9)](_0x17a76a),_0x4ea9f3==null||_0x4ea9f3[_0x2ab9d0(0x21c)]();};},[_0x79dd,_0x9b49d5]);const _0x29cdac=useExecution(_0x4dfe25);return jsxRuntimeExports[_0x3a056c(0x23c)](_0x3a056c(0x1fe),{'className':styles['scriptEditorPanel'],'children':[jsxRuntimeExports['jsx'](_0x3a056c(0x1fe),{'className':styles[_0x3a056c(0x1a8)],'ref':_0x5cc535,'children':jsxRuntimeExports['jsx'](_0x3a056c(0x1fe),{'className':styles[_0x3a056c(0x1e5)],'ref':_0x18510b})}),jsxRuntimeExports[_0x3a056c(0x231)](_0x3a056c(0x1fe),{'className':styles[_0x3a056c(0x1c7)],'children':jsxRuntimeExports[_0x3a056c(0x231)](design[_0x3a056c(0x1c2)],{'type':_0x3a056c(0x1e3),'size':'small','onClick':_0x29cdac,'children':_0x638daa['t'](_0x3a056c(0x1c6))})})]});}__name(ScriptEditorPanel,'ScriptEditorPanel');function useExecution(_0x38bdb4){var _0x863d77=_0x23b817;const _0x497173=core[_0x863d77(0x1c5)](IUniscriptExecutionService),_0x5bacf0=core[_0x863d77(0x1c5)](ui[_0x863d77(0x1dd)]),_0x30e4d2=core['useDependency'](core[_0x863d77(0x209)]);return require$$0[_0x863d77(0x1b6)](()=>{var _0x4a6007=_0x863d77,_0x2573a7;const _0x2c9f65=(_0x2573a7=_0x38bdb4[_0x4a6007(0x1d0)])==null?void 0x0:_0x2573a7[_0x4a6007(0x1bc)]();_0x2c9f65&&_0x497173[_0x4a6007(0x239)](_0x2c9f65[_0x4a6007(0x1d7)]())[_0x4a6007(0x213)](()=>{var _0x58623a=_0x4a6007;_0x5bacf0[_0x58623a(0x1a3)]({'content':_0x30e4d2['t'](_0x58623a(0x1fc)),'type':design['MessageType'][_0x58623a(0x23e)]});})[_0x4a6007(0x229)](()=>{var _0x3cde81=_0x4a6007;_0x5bacf0[_0x3cde81(0x1a3)]({'content':_0x30e4d2['t'](_0x3cde81(0x221)),'type':design[_0x3cde81(0x20b)]['Error']});});},[_0x30e4d2,_0x5bacf0,_0x38bdb4,_0x497173]);}__name(useExecution,_0x23b817(0x1b3));function UniscriptMenuItemFactory(_0x6a21a3){var _0x155fcd=_0x23b817;return{'id':ToggleScriptPanelOperation['id'],'title':'toggle-script-panel','tooltip':'script-panel.tooltip.menu-button','icon':_0x155fcd(0x1b9),'type':ui[_0x155fcd(0x1ef)][_0x155fcd(0x1a5)],'hidden$':ui[_0x155fcd(0x230)](_0x6a21a3,core['UniverInstanceType'][_0x155fcd(0x1d1)]),'disabled$':sheetsUi[_0x155fcd(0x1c3)](_0x6a21a3,{'workbookTypes':[sheets['WorkbookEditablePermission']],'worksheetTypes':[sheets[_0x155fcd(0x1c4)],sheets['WorksheetSetCellStylePermission'],sheets[_0x155fcd(0x22a)]],'rangeTypes':[sheets[_0x155fcd(0x1b1)]]})};}__name(UniscriptMenuItemFactory,_0x23b817(0x210));const menuSchema={[ui[_0x23b817(0x20a)]['OTHERS']]:{[ToggleScriptPanelOperation['id']]:{'order':0x5,'menuItemFactory':UniscriptMenuItemFactory}}};var __defProp$1=Object[_0x23b817(0x219)],__getOwnPropDesc$1=Object['getOwnPropertyDescriptor'],__decorateClass$1=__name((_0x403717,_0x4cf27f,_0x39033a,_0x2e7e0e)=>{var _0x15e4ce=_0x23b817;for(var _0x44d478=_0x2e7e0e>0x1?void 0x0:_0x2e7e0e?__getOwnPropDesc$1(_0x4cf27f,_0x39033a):_0x4cf27f,_0x2e679b=_0x403717[_0x15e4ce(0x1aa)]-0x1,_0x26fe25;_0x2e679b>=0x0;_0x2e679b--)(_0x26fe25=_0x403717[_0x2e679b])&&(_0x44d478=(_0x2e7e0e?_0x26fe25(_0x4cf27f,_0x39033a,_0x44d478):_0x26fe25(_0x44d478))||_0x44d478);return _0x2e7e0e&&_0x44d478&&__defProp$1(_0x4cf27f,_0x39033a,_0x44d478),_0x44d478;},_0x23b817(0x22d)),__decorateParam$1=__name((_0x2d2a7c,_0x44b10f)=>(_0x48b535,_0x2bc4f7)=>_0x44b10f(_0x48b535,_0x2bc4f7,_0x2d2a7c),_0x23b817(0x1d2)),_a3;let UniscriptController=(_a3=class extends core[_0x23b817(0x1fb)]{constructor(_0x44b6be,_0xf4c271,_0x19bda5){var _0x1bcf71=_0x23b817;super(),this[_0x1bcf71(0x1bb)]=_0x44b6be,this[_0x1bcf71(0x1bb)][_0x1bcf71(0x1cb)](menuSchema),this[_0x1bcf71(0x1f0)](_0x19bda5[_0x1bcf71(0x1e2)](ScriptPanelComponentName,ScriptEditorPanel)),this[_0x1bcf71(0x1f0)](_0xf4c271['registerCommand'](ToggleScriptPanelOperation));}},__name(_a3,_0x23b817(0x21f)),_a3);UniscriptController=__decorateClass$1([__decorateParam$1(0x0,ui['IMenuManagerService']),__decorateParam$1(0x1,core['ICommandService']),__decorateParam$1(0x2,core['Inject'](ui['ComponentManager']))],UniscriptController);var __defProp2=Object[_0x23b817(0x219)],__getOwnPropDesc=Object[_0x23b817(0x20f)],__decorateClass=__name((_0x40584b,_0xee1fbd,_0x2ae5af,_0x3f380f)=>{var _0x5e691d=_0x23b817;for(var _0xb40845=_0x3f380f>0x1?void 0x0:_0x3f380f?__getOwnPropDesc(_0xee1fbd,_0x2ae5af):_0xee1fbd,_0x4aa0e8=_0x40584b[_0x5e691d(0x1aa)]-0x1,_0x5d9cb2;_0x4aa0e8>=0x0;_0x4aa0e8--)(_0x5d9cb2=_0x40584b[_0x4aa0e8])&&(_0xb40845=(_0x3f380f?_0x5d9cb2(_0xee1fbd,_0x2ae5af,_0xb40845):_0x5d9cb2(_0xb40845))||_0xb40845);return _0x3f380f&&_0xb40845&&__defProp2(_0xee1fbd,_0x2ae5af,_0xb40845),_0xb40845;},_0x23b817(0x1e9)),__decorateParam=__name((_0x1684ec,_0x29ec9b)=>(_0x522001,_0x2581e8)=>_0x29ec9b(_0x522001,_0x2581e8,_0x1684ec),_0x23b817(0x1e8));const PLUGIN_NAME=_0x23b817(0x22b);var _a4;exports[_0x23b817(0x1de)]=(_a4=class extends core[_0x23b817(0x1ea)]{constructor(_0x2a186b=defaultPluginConfig,_0x30e075,_0x2eae00){var _0x501734=_0x23b817;super(),this['_config']=_0x2a186b,this[_0x501734(0x1cd)]=_0x30e075,this[_0x501734(0x234)]=_0x2eae00;const {menu:_0x2fb90b,..._0x201455}=this[_0x501734(0x1e0)];_0x2fb90b&&this[_0x501734(0x234)][_0x501734(0x203)](_0x501734(0x1b8),_0x2fb90b,{'merge':!0x0}),this[_0x501734(0x234)][_0x501734(0x203)](PLUGIN_CONFIG_KEY,_0x201455);}['onStarting'](){var _0x43e851=_0x23b817;const _0x25990b=this[_0x43e851(0x1cd)];[[UniscriptController],[exports[_0x43e851(0x1be)]],[ScriptPanelService]][_0x43e851(0x237)](_0x2e03b1=>_0x25990b['add'](_0x2e03b1)),this[_0x43e851(0x1b2)]();}[_0x23b817(0x1af)](){var _0x4a0b8d=_0x23b817;this[_0x4a0b8d(0x1cd)][_0x4a0b8d(0x1cf)](UniscriptController);}[_0x23b817(0x1b2)](){var _0xcbfc28=_0x23b817;this[_0xcbfc28(0x1cd)][_0xcbfc28(0x225)]([IUniscriptExecutionService,{'useClass':UniscriptExecutionService}]);}},__name(_a4,'UniverUniscriptPlugin'),__publicField(_a4,_0x23b817(0x223),PLUGIN_NAME),_a4),exports['UniverUniscriptPlugin']=__decorateClass([__decorateParam(0x1,core['Inject'](core[_0x23b817(0x200)])),__decorateParam(0x2,core[_0x23b817(0x1f2)])],exports['UniverUniscriptPlugin']),exports[_0x23b817(0x215)]=IUniscriptExecutionService,exports[_0x23b817(0x1ad)]=ToggleScriptPanelOperation;
|
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"),PLUGIN_CONFIG_KEY="uniscript.config",defaultPluginConfig={},_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
|
+
* @license React
|
3
|
+
* react-jsx-runtime.production.min.js
|
4
|
+
*
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
6
|
+
*
|
7
|
+
* This source code is licensed under the MIT license found in the
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
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,__defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(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$3(target,key,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$3"),_a;exports.ScriptEditorService=(_a=class extends core.Disposable{constructor(_configService){super();__publicField(this,"_editorInstance",null);this._configService=_configService}setEditorInstance(editor){return this._editorInstance=editor,core.toDisposable(()=>this._editorInstance=null)}getEditorInstance(){return this._editorInstance}requireVscodeEditor(){if(!window.MonacoEnvironment){const config=this._configService.getConfig(PLUGIN_CONFIG_KEY);window.MonacoEnvironment={getWorkerUrl:config==null?void 0:config.getWorkerUrl}}}},__name(_a,"ScriptEditorService"),_a);exports.ScriptEditorService=__decorateClass$3([__decorateParam$3(0,core.IConfigService)],exports.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 _a2;let UniscriptExecutionService=(_a2=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(_a2,"UniscriptExecutionService"),_a2);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(exports.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 _a5;const model=(_a5=monacoEditorRef.current)==null?void 0:_a5.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,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");const menuSchema={[ui.RibbonStartGroup.OTHERS]:{[ToggleScriptPanelOperation.id]:{order:5,menuItemFactory: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"),_a3;let UniscriptController=(_a3=class extends core.Disposable{constructor(_menuManagerService,commandService,componentManager){super(),this._menuManagerService=_menuManagerService,this._menuManagerService.mergeMenu(menuSchema),this.disposeWithMe(componentManager.register(ScriptPanelComponentName,ScriptEditorPanel)),this.disposeWithMe(commandService.registerCommand(ToggleScriptPanelOperation))}},__name(_a3,"UniscriptController"),_a3);UniscriptController=__decorateClass$1([__decorateParam$1(0,ui.IMenuManagerService),__decorateParam$1(1,core.ICommandService),__decorateParam$1(2,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="UNIVER_UNISCRIPT_PLUGIN";var _a4;exports.UniverUniscriptPlugin=(_a4=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_configService){super(),this._config=_config,this._injector=_injector,this._configService=_configService;const{menu,...rest}=this._config;menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){const injector=this._injector;[[UniscriptController],[exports.ScriptEditorService],[ScriptPanelService]].forEach(d=>injector.add(d)),this.registerExecution()}onSteady(){this._injector.get(UniscriptController)}registerExecution(){this._injector.add([IUniscriptExecutionService,{useClass:UniscriptExecutionService}])}},__name(_a4,"UniverUniscriptPlugin"),__publicField(_a4,"pluginName",PLUGIN_NAME),_a4);exports.UniverUniscriptPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService)],exports.UniverUniscriptPlugin);exports.IUniscriptExecutionService=IUniscriptExecutionService;exports.ToggleScriptPanelOperation=ToggleScriptPanelOperation;
|
package/lib/es/index.js
CHANGED
@@ -1 +1,264 @@
|
|
1
|
-
var _0x2ee67a=_0x1fd6;(function(_0xd2440a,_0x3fa3b4){var _0x33089f=_0x1fd6,_0x3bfb7b=_0xd2440a();while(!![]){try{var _0x337733=parseInt(_0x33089f(0x1fe))/0x1*(parseInt(_0x33089f(0x237))/0x2)+parseInt(_0x33089f(0x20c))/0x3*(-parseInt(_0x33089f(0x221))/0x4)+-parseInt(_0x33089f(0x20f))/0x5+-parseInt(_0x33089f(0x1e3))/0x6+parseInt(_0x33089f(0x236))/0x7+parseInt(_0x33089f(0x1f2))/0x8+parseInt(_0x33089f(0x22f))/0x9;if(_0x337733===_0x3fa3b4)break;else _0x3bfb7b['push'](_0x3bfb7b['shift']());}catch(_0x236cda){_0x3bfb7b['push'](_0x3bfb7b['shift']());}}}(_0x294f,0x6dcc3));var __defProp=Object[_0x2ee67a(0x1dc)],__defNormalProp=(_0x161a51,_0x1feb55,_0x6490ea)=>_0x1feb55 in _0x161a51?__defProp(_0x161a51,_0x1feb55,{'enumerable':!0x0,'configurable':!0x0,'writable':!0x0,'value':_0x6490ea}):_0x161a51[_0x1feb55]=_0x6490ea,__name=(_0x26da9b,_0x371837)=>__defProp(_0x26da9b,_0x2ee67a(0x1eb),{'value':_0x371837,'configurable':!0x0}),__publicField=(_0x29cbb1,_0x18a011,_0x25a376)=>__defNormalProp(_0x29cbb1,typeof _0x18a011!=_0x2ee67a(0x222)?_0x18a011+'':_0x18a011,_0x25a376);import{Disposable,CommandType,toDisposable,IConfigService,createIdentifier,Inject,Injector,ILogService,useDependency,LocaleService,DisposableCollection,UniverInstanceType,ICommandService,Plugin}from'@univerjs/core';import{ISidebarService,IShortcutService,IMessageService,MenuItemType,getMenuHiddenObservable,RibbonStartGroup,ComponentManager,IMenuManagerService}from'@univerjs/ui';import{BehaviorSubject,distinctUntilChanged}from'rxjs';import _0xee23e0,{useRef,useEffect,useCallback}from'react';import{Button,MessageType}from'@univerjs/design';import{editor}from'monaco-editor';import{FUniver}from'@univerjs/facade';import{getCurrentRangeDisable$}from'@univerjs/sheets-ui';import{WorkbookEditablePermission,WorksheetEditPermission,WorksheetSetCellStylePermission,WorksheetSetCellValuePermission,RangeProtectionPermissionEditPoint}from'@univerjs/sheets';const PLUGIN_CONFIG_KEY=_0x2ee67a(0x1ce),defaultPluginConfig={},_ScriptPanelService=class _ScriptPanelService extends Disposable{constructor(){var _0x2c62b3=_0x2ee67a;super(...arguments),__publicField(this,'_open$',new BehaviorSubject(!0x1)),__publicField(this,_0x2c62b3(0x230),this['_open$'][_0x2c62b3(0x22d)](distinctUntilChanged()));}get[_0x2ee67a(0x1cc)](){var _0x593c07=_0x2ee67a;return this[_0x593c07(0x211)][_0x593c07(0x22e)]();}['dispose'](){var _0x513d12=_0x2ee67a;super['dispose'](),this[_0x513d12(0x211)][_0x513d12(0x20b)](!0x1),this[_0x513d12(0x211)][_0x513d12(0x1f9)]();}[_0x2ee67a(0x202)](){var _0x44e950=_0x2ee67a;this[_0x44e950(0x211)][_0x44e950(0x20b)](!0x0);}[_0x2ee67a(0x1d2)](){var _0x295d07=_0x2ee67a;this[_0x295d07(0x211)][_0x295d07(0x20b)](!0x1);}};__name(_ScriptPanelService,_0x2ee67a(0x1ec));let ScriptPanelService=_ScriptPanelService;const ScriptPanelComponentName=_0x2ee67a(0x227),ToggleScriptPanelOperation={'type':CommandType['OPERATION'],'id':_0x2ee67a(0x1ff),'handler':__name(_0x27f462=>{var _0x3d5c6a=_0x2ee67a;const _0x5c9b06=_0x27f462[_0x3d5c6a(0x1e7)](ScriptPanelService),_0x6ec66d=_0x27f462[_0x3d5c6a(0x1e7)](ISidebarService);return _0x5c9b06[_0x3d5c6a(0x1cc)]?(_0x5c9b06[_0x3d5c6a(0x1d2)](),_0x6ec66d[_0x3d5c6a(0x1d2)]()):(_0x5c9b06[_0x3d5c6a(0x202)](),_0x6ec66d[_0x3d5c6a(0x202)]({'header':{'title':_0x3d5c6a(0x235)},'children':{'label':ScriptPanelComponentName},'width':0x258})),!0x0;},'handler')};function _0x294f(){var _0x39f0a7=['small','2277078ovarwQ','})()','script-panel.tooltip.menu-button','show','get','uniscript.message.failed','onSteady','__decorateClass$1','name','ScriptPanelService','then','current','registerCommand','dispose','key','5658000fBePYY','UniscriptExecutionService','forEach','univer-script-editor-content','hasOwnProperty','menu','observe','complete','_configService','onDidFocusEditorWidget','useExecution','Success','3RZGbNb','univer.operation.toggle-script-panel','_config','onStarting','open','scriptEditorContent','layout','toggle-script-panel','script-panel.panel.execute','scriptEditorPanel','scriptEditorContainer','UNIVER_UNISCRIPT_PLUGIN','getBoundingClientRect','next','12GPoQwP','setEditorInstance','executing\x20Uniscript...','3977660ZhWjUt','BUTTON','_open$','prototype','ScriptEditorService','div','react.fragment','catch','__decorateParam','(()\x20=>\x20{','scriptEditorActions','getModel','mergeMenu','getWorkerUrl','length','getConfig','_editorInstance','_logService','165404mUoPjT','symbol','Fragment','jsx','ref','add','ScriptPanel','call','requireVscodeEditor','OTHERS','getOwnPropertyDescriptor','CodeSingle','pipe','getValue','2306691XBMKEh','open$','ReactCurrentOwner','for','[UniscriptExecutionService]','react.element','script-panel.title','1029686RgkOUj','453022upjmve','__decorateParam$3','registerExecution','MonacoEnvironment','__decorateClass','univer-script-editor-actions','jsxs','univerAPI','isOpen','pluginName','uniscript.config','_menuManagerService','_injector','create','close','uniscript.message.success','__decorateClass$3','setConfig','defaultProps','forceEscape','__decorateParam$2','onDidBlurEditorWidget','exports','execute','defineProperty','univer-script-editor-panel','log','error','newAPI','getEditorInstance'];_0x294f=function(){return _0x39f0a7;};return _0x294f();}var jsxRuntime={'exports':{}},reactJsxRuntime_production_min={},f=_0xee23e0,k=Symbol[_0x2ee67a(0x232)](_0x2ee67a(0x234)),l=Symbol[_0x2ee67a(0x232)](_0x2ee67a(0x215)),m=Object[_0x2ee67a(0x212)]['hasOwnProperty'],n=f['__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED'][_0x2ee67a(0x231)],p={'key':!0x0,'ref':!0x0,'__self':!0x0,'__source':!0x0};function q(_0x23c34,_0x5b6eff,_0x17c8fa){var _0x2b1411=_0x2ee67a,_0x11acf2,_0x42a7b2={},_0x302ced=null,_0x35ac41=null;_0x17c8fa!==void 0x0&&(_0x302ced=''+_0x17c8fa),_0x5b6eff[_0x2b1411(0x1f1)]!==void 0x0&&(_0x302ced=''+_0x5b6eff['key']),_0x5b6eff[_0x2b1411(0x225)]!==void 0x0&&(_0x35ac41=_0x5b6eff[_0x2b1411(0x225)]);for(_0x11acf2 in _0x5b6eff)m[_0x2b1411(0x228)](_0x5b6eff,_0x11acf2)&&!p[_0x2b1411(0x1f6)](_0x11acf2)&&(_0x42a7b2[_0x11acf2]=_0x5b6eff[_0x11acf2]);if(_0x23c34&&_0x23c34['defaultProps']){for(_0x11acf2 in(_0x5b6eff=_0x23c34[_0x2b1411(0x1d6)],_0x5b6eff))_0x42a7b2[_0x11acf2]===void 0x0&&(_0x42a7b2[_0x11acf2]=_0x5b6eff[_0x11acf2]);}return{'$$typeof':k,'type':_0x23c34,'key':_0x302ced,'ref':_0x35ac41,'props':_0x42a7b2,'_owner':n['current']};}__name(q,'q'),reactJsxRuntime_production_min[_0x2ee67a(0x223)]=l,reactJsxRuntime_production_min[_0x2ee67a(0x224)]=q,reactJsxRuntime_production_min[_0x2ee67a(0x1ca)]=q,jsxRuntime['exports']=reactJsxRuntime_production_min;var jsxRuntimeExports=jsxRuntime[_0x2ee67a(0x1da)],__defProp$3=Object[_0x2ee67a(0x1dc)],__getOwnPropDesc$3=Object[_0x2ee67a(0x22b)],__decorateClass$3=__name((_0x2f55a0,_0x273787,_0x514e2a,_0x240280)=>{var _0x4ccc16=_0x2ee67a;for(var _0x550923=_0x240280>0x1?void 0x0:_0x240280?__getOwnPropDesc$3(_0x273787,_0x514e2a):_0x273787,_0x558bc3=_0x2f55a0[_0x4ccc16(0x21d)]-0x1,_0x401441;_0x558bc3>=0x0;_0x558bc3--)(_0x401441=_0x2f55a0[_0x558bc3])&&(_0x550923=(_0x240280?_0x401441(_0x273787,_0x514e2a,_0x550923):_0x401441(_0x550923))||_0x550923);return _0x240280&&_0x550923&&__defProp$3(_0x273787,_0x514e2a,_0x550923),_0x550923;},_0x2ee67a(0x1d4)),__decorateParam$3=__name((_0x159836,_0xbcc6fe)=>(_0xbd1ae8,_0x9007b4)=>_0xbcc6fe(_0xbd1ae8,_0x9007b4,_0x159836),_0x2ee67a(0x238)),_a;let ScriptEditorService=(_a=class extends Disposable{constructor(_0x3b836e){var _0x51c9ef=_0x2ee67a;super(),__publicField(this,_0x51c9ef(0x21f),null),this[_0x51c9ef(0x1fa)]=_0x3b836e;}[_0x2ee67a(0x20d)](_0x1fdedc){var _0x3a377c=_0x2ee67a;return this[_0x3a377c(0x21f)]=_0x1fdedc,toDisposable(()=>this[_0x3a377c(0x21f)]=null);}[_0x2ee67a(0x1e1)](){var _0x3935cf=_0x2ee67a;return this[_0x3935cf(0x21f)];}[_0x2ee67a(0x229)](){var _0x3aa4b8=_0x2ee67a;if(!window[_0x3aa4b8(0x1c7)]){const _0x50cfdd=this[_0x3aa4b8(0x1fa)][_0x3aa4b8(0x21e)](PLUGIN_CONFIG_KEY);window[_0x3aa4b8(0x1c7)]={'getWorkerUrl':_0x50cfdd==null?void 0x0:_0x50cfdd[_0x3aa4b8(0x21c)]};}}},__name(_a,_0x2ee67a(0x213)),_a);ScriptEditorService=__decorateClass$3([__decorateParam$3(0x0,IConfigService)],ScriptEditorService);var __defProp$2=Object[_0x2ee67a(0x1dc)],__getOwnPropDesc$2=Object[_0x2ee67a(0x22b)],__decorateClass$2=__name((_0x5ac951,_0x190269,_0x2d7948,_0x6ffb7)=>{var _0x413be2=_0x2ee67a;for(var _0x3d7132=_0x6ffb7>0x1?void 0x0:_0x6ffb7?__getOwnPropDesc$2(_0x190269,_0x2d7948):_0x190269,_0x1ac2a5=_0x5ac951[_0x413be2(0x21d)]-0x1,_0x2b1c26;_0x1ac2a5>=0x0;_0x1ac2a5--)(_0x2b1c26=_0x5ac951[_0x1ac2a5])&&(_0x3d7132=(_0x6ffb7?_0x2b1c26(_0x190269,_0x2d7948,_0x3d7132):_0x2b1c26(_0x3d7132))||_0x3d7132);return _0x6ffb7&&_0x3d7132&&__defProp$2(_0x190269,_0x2d7948,_0x3d7132),_0x3d7132;},'__decorateClass$2'),__decorateParam$2=__name((_0x5c9921,_0x4b6f9d)=>(_0x228a8b,_0x400045)=>_0x4b6f9d(_0x228a8b,_0x400045,_0x5c9921),_0x2ee67a(0x1d8));const IUniscriptExecutionService=createIdentifier('univer.uniscript.execution-service');function _0x1fd6(_0x18fe99,_0x1df39f){var _0x294f13=_0x294f();return _0x1fd6=function(_0x1fd6c9,_0x1b0d8a){_0x1fd6c9=_0x1fd6c9-0x1c7;var _0x4c21e6=_0x294f13[_0x1fd6c9];return _0x4c21e6;},_0x1fd6(_0x18fe99,_0x1df39f);}var _a2;let UniscriptExecutionService=(_a2=class extends Disposable{constructor(_0x3fbc3b,_0x490391){var _0x4b656e=_0x2ee67a;super(),this[_0x4b656e(0x220)]=_0x3fbc3b,this['_injector']=_0x490391;}async[_0x2ee67a(0x1db)](_0x2cdb6b){var _0x249c4d=_0x2ee67a;this['_logService'][_0x249c4d(0x1de)](_0x249c4d(0x233),_0x249c4d(0x20e));const _0x583355=FUniver[_0x249c4d(0x1e0)](this[_0x249c4d(0x1d0)]),_0x132c2f=new Function(_0x249c4d(0x1cb),_0x249c4d(0x218)+_0x2cdb6b+_0x249c4d(0x1e4));try{return _0x132c2f(_0x583355),!0x0;}catch(_0x1e0a8d){return this[_0x249c4d(0x220)][_0x249c4d(0x1df)](_0x1e0a8d),!0x1;}}},__name(_a2,_0x2ee67a(0x1f3)),_a2);UniscriptExecutionService=__decorateClass$2([__decorateParam$2(0x0,ILogService),__decorateParam$2(0x1,Inject(Injector))],UniscriptExecutionService);const scriptEditorPanel=_0x2ee67a(0x1dd),scriptEditorContent=_0x2ee67a(0x1f5),scriptEditorActions=_0x2ee67a(0x1c9),styles={'scriptEditorPanel':scriptEditorPanel,'scriptEditorContent':scriptEditorContent,'scriptEditorActions':scriptEditorActions};function ScriptEditorPanel(){var _0x4fca5d=_0x2ee67a;const _0x13b86f=useRef(null),_0x452759=useRef(null),_0x2e5eaa=useRef(null),_0x3606cd=useDependency(LocaleService),_0x3e6ec5=useDependency(IShortcutService),_0x12de32=useDependency(ScriptEditorService);useEffect(()=>{var _0x1a5737=_0x1fd6;const _0x56692d=_0x452759[_0x1a5737(0x1ee)],_0x2b3f19=_0x13b86f[_0x1a5737(0x1ee)];let _0x5c0002=null,_0x3554a0=null;if(_0x56692d&&_0x2b3f19){_0x12de32[_0x1a5737(0x229)]();const _0x251461=_0x2e5eaa[_0x1a5737(0x1ee)]=editor[_0x1a5737(0x1d1)](_0x56692d,{'value':'','language':'javascript'});_0x3554a0=new ResizeObserver(()=>{let _0x3aeeba=requestIdleCallback(()=>{var _0x1741ce=_0x1fd6;if(!_0x3aeeba)return;const {height:_0x448a55,width:_0xd98de7}=_0x2b3f19[_0x1741ce(0x20a)]();_0x251461[_0x1741ce(0x204)]({'width':_0xd98de7,'height':_0x448a55}),_0x3aeeba=void 0x0;});}),_0x3554a0[_0x1a5737(0x1f8)](_0x2b3f19);let _0x29df80;_0x5c0002=new DisposableCollection(),_0x5c0002[_0x1a5737(0x226)](_0x12de32['setEditorInstance'](_0x251461)),_0x5c0002[_0x1a5737(0x226)](_0x251461[_0x1a5737(0x1fb)](()=>{var _0x2773cf=_0x1a5737;_0x29df80=_0x3e6ec5[_0x2773cf(0x1d7)]();})),_0x5c0002['add'](_0x251461[_0x1a5737(0x1d9)](()=>{var _0x241e53=_0x1a5737;_0x29df80==null||_0x29df80[_0x241e53(0x1f0)](),_0x29df80=void 0x0;})),_0x5c0002[_0x1a5737(0x226)](toDisposable(()=>_0x29df80==null?void 0x0:_0x29df80[_0x1a5737(0x1f0)]()));}return()=>{_0x3554a0&&_0x2b3f19&&_0x3554a0['unobserve'](_0x2b3f19),_0x5c0002==null||_0x5c0002['dispose']();};},[_0x12de32,_0x3e6ec5]);const _0x31281c=useExecution(_0x2e5eaa);return jsxRuntimeExports['jsxs'](_0x4fca5d(0x214),{'className':styles[_0x4fca5d(0x207)],'children':[jsxRuntimeExports[_0x4fca5d(0x224)]('div',{'className':styles[_0x4fca5d(0x203)],'ref':_0x13b86f,'children':jsxRuntimeExports['jsx']('div',{'className':styles[_0x4fca5d(0x208)],'ref':_0x452759})}),jsxRuntimeExports[_0x4fca5d(0x224)](_0x4fca5d(0x214),{'className':styles[_0x4fca5d(0x219)],'children':jsxRuntimeExports['jsx'](Button,{'type':'primary','size':_0x4fca5d(0x1e2),'onClick':_0x31281c,'children':_0x3606cd['t'](_0x4fca5d(0x206))})})]});}__name(ScriptEditorPanel,'ScriptEditorPanel');function useExecution(_0x2ba407){const _0x19814c=useDependency(IUniscriptExecutionService),_0x4f2122=useDependency(IMessageService),_0x246398=useDependency(LocaleService);return useCallback(()=>{var _0x553d2a=_0x1fd6,_0x456a44;const _0x39aae3=(_0x456a44=_0x2ba407[_0x553d2a(0x1ee)])==null?void 0x0:_0x456a44[_0x553d2a(0x21a)]();_0x39aae3&&_0x19814c[_0x553d2a(0x1db)](_0x39aae3[_0x553d2a(0x22e)]())[_0x553d2a(0x1ed)](()=>{var _0x23b77d=_0x553d2a;_0x4f2122[_0x23b77d(0x1e6)]({'content':_0x246398['t'](_0x23b77d(0x1d3)),'type':MessageType[_0x23b77d(0x1fd)]});})[_0x553d2a(0x216)](()=>{var _0x12f273=_0x553d2a;_0x4f2122['show']({'content':_0x246398['t'](_0x12f273(0x1e8)),'type':MessageType['Error']});});},[_0x246398,_0x4f2122,_0x2ba407,_0x19814c]);}__name(useExecution,_0x2ee67a(0x1fc));function UniscriptMenuItemFactory(_0x45e97a){var _0x218537=_0x2ee67a;return{'id':ToggleScriptPanelOperation['id'],'title':_0x218537(0x205),'tooltip':_0x218537(0x1e5),'icon':_0x218537(0x22c),'type':MenuItemType[_0x218537(0x210)],'hidden$':getMenuHiddenObservable(_0x45e97a,UniverInstanceType['UNIVER_SHEET']),'disabled$':getCurrentRangeDisable$(_0x45e97a,{'workbookTypes':[WorkbookEditablePermission],'worksheetTypes':[WorksheetEditPermission,WorksheetSetCellStylePermission,WorksheetSetCellValuePermission],'rangeTypes':[RangeProtectionPermissionEditPoint]})};}__name(UniscriptMenuItemFactory,'UniscriptMenuItemFactory');const menuSchema={[RibbonStartGroup[_0x2ee67a(0x22a)]]:{[ToggleScriptPanelOperation['id']]:{'order':0x5,'menuItemFactory':UniscriptMenuItemFactory}}};var __defProp$1=Object[_0x2ee67a(0x1dc)],__getOwnPropDesc$1=Object['getOwnPropertyDescriptor'],__decorateClass$1=__name((_0x9169dc,_0xee75b5,_0x5985ae,_0x5c4539)=>{var _0x2e3ccb=_0x2ee67a;for(var _0x5ee198=_0x5c4539>0x1?void 0x0:_0x5c4539?__getOwnPropDesc$1(_0xee75b5,_0x5985ae):_0xee75b5,_0xa9b252=_0x9169dc[_0x2e3ccb(0x21d)]-0x1,_0x267c3b;_0xa9b252>=0x0;_0xa9b252--)(_0x267c3b=_0x9169dc[_0xa9b252])&&(_0x5ee198=(_0x5c4539?_0x267c3b(_0xee75b5,_0x5985ae,_0x5ee198):_0x267c3b(_0x5ee198))||_0x5ee198);return _0x5c4539&&_0x5ee198&&__defProp$1(_0xee75b5,_0x5985ae,_0x5ee198),_0x5ee198;},_0x2ee67a(0x1ea)),__decorateParam$1=__name((_0x681b96,_0x32c8a5)=>(_0x35b90d,_0x46ae74)=>_0x32c8a5(_0x35b90d,_0x46ae74,_0x681b96),'__decorateParam$1'),_a3;let UniscriptController=(_a3=class extends Disposable{constructor(_0x1448ec,_0x586152,_0x2b6368){var _0x746eb6=_0x2ee67a;super(),this[_0x746eb6(0x1cf)]=_0x1448ec,this['_menuManagerService'][_0x746eb6(0x21b)](menuSchema),this['disposeWithMe'](_0x2b6368['register'](ScriptPanelComponentName,ScriptEditorPanel)),this['disposeWithMe'](_0x586152[_0x746eb6(0x1ef)](ToggleScriptPanelOperation));}},__name(_a3,'UniscriptController'),_a3);UniscriptController=__decorateClass$1([__decorateParam$1(0x0,IMenuManagerService),__decorateParam$1(0x1,ICommandService),__decorateParam$1(0x2,Inject(ComponentManager))],UniscriptController);var __defProp2=Object[_0x2ee67a(0x1dc)],__getOwnPropDesc=Object[_0x2ee67a(0x22b)],__decorateClass=__name((_0x46c6cc,_0x382226,_0x50eb2,_0x4e2492)=>{var _0x2638fd=_0x2ee67a;for(var _0x55637b=_0x4e2492>0x1?void 0x0:_0x4e2492?__getOwnPropDesc(_0x382226,_0x50eb2):_0x382226,_0x51a684=_0x46c6cc[_0x2638fd(0x21d)]-0x1,_0x37d7c9;_0x51a684>=0x0;_0x51a684--)(_0x37d7c9=_0x46c6cc[_0x51a684])&&(_0x55637b=(_0x4e2492?_0x37d7c9(_0x382226,_0x50eb2,_0x55637b):_0x37d7c9(_0x55637b))||_0x55637b);return _0x4e2492&&_0x55637b&&__defProp2(_0x382226,_0x50eb2,_0x55637b),_0x55637b;},_0x2ee67a(0x1c8)),__decorateParam=__name((_0x535755,_0x73a549)=>(_0x2b1162,_0x124cdd)=>_0x73a549(_0x2b1162,_0x124cdd,_0x535755),_0x2ee67a(0x217));const PLUGIN_NAME=_0x2ee67a(0x209);var _a4;let UniverUniscriptPlugin=(_a4=class extends Plugin{constructor(_0x3571db=defaultPluginConfig,_0x3f4d70,_0x4c4243){var _0x52d060=_0x2ee67a;super(),this[_0x52d060(0x200)]=_0x3571db,this[_0x52d060(0x1d0)]=_0x3f4d70,this[_0x52d060(0x1fa)]=_0x4c4243;const {menu:_0x2a3021,..._0x54aab0}=this[_0x52d060(0x200)];_0x2a3021&&this[_0x52d060(0x1fa)][_0x52d060(0x1d5)](_0x52d060(0x1f7),_0x2a3021,{'merge':!0x0}),this[_0x52d060(0x1fa)][_0x52d060(0x1d5)](PLUGIN_CONFIG_KEY,_0x54aab0);}[_0x2ee67a(0x201)](){var _0xe45d6f=_0x2ee67a;const _0x4139c0=this['_injector'];[[UniscriptController],[ScriptEditorService],[ScriptPanelService]][_0xe45d6f(0x1f4)](_0x492680=>_0x4139c0[_0xe45d6f(0x226)](_0x492680)),this[_0xe45d6f(0x239)]();}[_0x2ee67a(0x1e9)](){var _0x35d668=_0x2ee67a;this[_0x35d668(0x1d0)]['get'](UniscriptController);}[_0x2ee67a(0x239)](){var _0x7132b7=_0x2ee67a;this['_injector'][_0x7132b7(0x226)]([IUniscriptExecutionService,{'useClass':UniscriptExecutionService}]);}},__name(_a4,'UniverUniscriptPlugin'),__publicField(_a4,_0x2ee67a(0x1cd),PLUGIN_NAME),_a4);UniverUniscriptPlugin=__decorateClass([__decorateParam(0x1,Inject(Injector)),__decorateParam(0x2,IConfigService)],UniverUniscriptPlugin);export{IUniscriptExecutionService,ScriptEditorService,ToggleScriptPanelOperation,UniverUniscriptPlugin};
|
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, IConfigService, createIdentifier, Inject, Injector, ILogService, useDependency, LocaleService, DisposableCollection, UniverInstanceType, ICommandService, Plugin } from "@univerjs/core";
|
6
|
+
import { ISidebarService, IShortcutService, IMessageService, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, ComponentManager, IMenuManagerService } 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 PLUGIN_CONFIG_KEY = "uniscript.config", defaultPluginConfig = {}, _ScriptPanelService = class _ScriptPanelService extends Disposable {
|
15
|
+
constructor() {
|
16
|
+
super(...arguments);
|
17
|
+
__publicField(this, "_open$", new BehaviorSubject(!1));
|
18
|
+
__publicField(this, "open$", this._open$.pipe(distinctUntilChanged()));
|
19
|
+
}
|
20
|
+
get isOpen() {
|
21
|
+
return this._open$.getValue();
|
22
|
+
}
|
23
|
+
dispose() {
|
24
|
+
super.dispose(), this._open$.next(!1), this._open$.complete();
|
25
|
+
}
|
26
|
+
open() {
|
27
|
+
this._open$.next(!0);
|
28
|
+
}
|
29
|
+
close() {
|
30
|
+
this._open$.next(!1);
|
31
|
+
}
|
32
|
+
};
|
33
|
+
__name(_ScriptPanelService, "ScriptPanelService");
|
34
|
+
let ScriptPanelService = _ScriptPanelService;
|
35
|
+
const ScriptPanelComponentName = "ScriptPanel", ToggleScriptPanelOperation = {
|
36
|
+
type: CommandType.OPERATION,
|
37
|
+
id: "univer.operation.toggle-script-panel",
|
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({
|
41
|
+
header: { title: "script-panel.title" },
|
42
|
+
children: { label: ScriptPanelComponentName },
|
43
|
+
width: 600
|
44
|
+
})), !0;
|
45
|
+
}, "handler")
|
46
|
+
};
|
47
|
+
var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
|
48
|
+
/**
|
49
|
+
* @license React
|
50
|
+
* react-jsx-runtime.production.min.js
|
51
|
+
*
|
52
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
53
|
+
*
|
54
|
+
* This source code is licensed under the MIT license found in the
|
55
|
+
* LICENSE file in the root directory of this source tree.
|
56
|
+
*/
|
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 };
|
64
|
+
}
|
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, __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
71
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
72
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
73
|
+
return kind && result && __defProp$3(target, key, result), result;
|
74
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a;
|
75
|
+
let ScriptEditorService = (_a = class extends Disposable {
|
76
|
+
constructor(_configService) {
|
77
|
+
super();
|
78
|
+
__publicField(this, "_editorInstance", null);
|
79
|
+
this._configService = _configService;
|
80
|
+
}
|
81
|
+
setEditorInstance(editor2) {
|
82
|
+
return this._editorInstance = editor2, toDisposable(() => this._editorInstance = null);
|
83
|
+
}
|
84
|
+
getEditorInstance() {
|
85
|
+
return this._editorInstance;
|
86
|
+
}
|
87
|
+
requireVscodeEditor() {
|
88
|
+
if (!window.MonacoEnvironment) {
|
89
|
+
const config = this._configService.getConfig(PLUGIN_CONFIG_KEY);
|
90
|
+
window.MonacoEnvironment = {
|
91
|
+
getWorkerUrl: config == null ? void 0 : config.getWorkerUrl
|
92
|
+
};
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}, __name(_a, "ScriptEditorService"), _a);
|
96
|
+
ScriptEditorService = __decorateClass$3([
|
97
|
+
__decorateParam$3(0, IConfigService)
|
98
|
+
], ScriptEditorService);
|
99
|
+
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
100
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
101
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
102
|
+
return kind && result && __defProp$2(target, key, result), result;
|
103
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2");
|
104
|
+
const IUniscriptExecutionService = createIdentifier("univer.uniscript.execution-service");
|
105
|
+
var _a2;
|
106
|
+
let UniscriptExecutionService = (_a2 = class extends Disposable {
|
107
|
+
constructor(_logService, _injector) {
|
108
|
+
super(), this._logService = _logService, this._injector = _injector;
|
109
|
+
}
|
110
|
+
async execute(code) {
|
111
|
+
this._logService.log("[UniscriptExecutionService]", "executing Uniscript...");
|
112
|
+
const apiInstance = FUniver.newAPI(this._injector), scriptFunction = new Function("univerAPI", `(() => {${code}})()`);
|
113
|
+
try {
|
114
|
+
return scriptFunction(apiInstance), !0;
|
115
|
+
} catch (e) {
|
116
|
+
return this._logService.error(e), !1;
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}, __name(_a2, "UniscriptExecutionService"), _a2);
|
120
|
+
UniscriptExecutionService = __decorateClass$2([
|
121
|
+
__decorateParam$2(0, ILogService),
|
122
|
+
__decorateParam$2(1, Inject(Injector))
|
123
|
+
], UniscriptExecutionService);
|
124
|
+
const scriptEditorPanel = "univer-script-editor-panel", scriptEditorContent = "univer-script-editor-content", scriptEditorActions = "univer-script-editor-actions", styles = {
|
125
|
+
scriptEditorPanel,
|
126
|
+
scriptEditorContent,
|
127
|
+
scriptEditorActions
|
128
|
+
};
|
129
|
+
function ScriptEditorPanel() {
|
130
|
+
const editorContentRef = useRef(null), editorContainerRef = useRef(null), monacoEditorRef = useRef(null), localeService = useDependency(LocaleService), shortcutService = useDependency(IShortcutService), editorService = useDependency(ScriptEditorService);
|
131
|
+
useEffect(() => {
|
132
|
+
const containerElement = editorContainerRef.current, contentElement = editorContentRef.current;
|
133
|
+
let disposableCollection = null, resizeObserver = null;
|
134
|
+
if (containerElement && contentElement) {
|
135
|
+
editorService.requireVscodeEditor();
|
136
|
+
const monacoEditor = monacoEditorRef.current = editor.create(containerElement, {
|
137
|
+
value: "",
|
138
|
+
language: "javascript"
|
139
|
+
});
|
140
|
+
resizeObserver = new ResizeObserver(() => {
|
141
|
+
let timer = requestIdleCallback(() => {
|
142
|
+
if (!timer) return;
|
143
|
+
const { height, width } = contentElement.getBoundingClientRect();
|
144
|
+
monacoEditor.layout({ width, height }), timer = void 0;
|
145
|
+
});
|
146
|
+
}), resizeObserver.observe(contentElement);
|
147
|
+
let terminateEscaping;
|
148
|
+
disposableCollection = new DisposableCollection(), disposableCollection.add(editorService.setEditorInstance(monacoEditor)), disposableCollection.add(
|
149
|
+
monacoEditor.onDidFocusEditorWidget(() => {
|
150
|
+
terminateEscaping = shortcutService.forceEscape();
|
151
|
+
})
|
152
|
+
), disposableCollection.add(
|
153
|
+
monacoEditor.onDidBlurEditorWidget(() => {
|
154
|
+
terminateEscaping == null || terminateEscaping.dispose(), terminateEscaping = void 0;
|
155
|
+
})
|
156
|
+
), disposableCollection.add(toDisposable(() => terminateEscaping == null ? void 0 : terminateEscaping.dispose()));
|
157
|
+
}
|
158
|
+
return () => {
|
159
|
+
resizeObserver && contentElement && resizeObserver.unobserve(contentElement), disposableCollection == null || disposableCollection.dispose();
|
160
|
+
};
|
161
|
+
}, [editorService, shortcutService]);
|
162
|
+
const startExecution = useExecution(monacoEditorRef);
|
163
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.scriptEditorPanel, children: [
|
164
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.scriptEditorContent, ref: editorContentRef, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.scriptEditorContainer, ref: editorContainerRef }) }),
|
165
|
+
/* @__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") }) })
|
166
|
+
] });
|
167
|
+
}
|
168
|
+
__name(ScriptEditorPanel, "ScriptEditorPanel");
|
169
|
+
function useExecution(monacoEditorRef) {
|
170
|
+
const scriptService = useDependency(IUniscriptExecutionService), messageService = useDependency(IMessageService), localeService = useDependency(LocaleService);
|
171
|
+
return useCallback(() => {
|
172
|
+
var _a5;
|
173
|
+
const model = (_a5 = monacoEditorRef.current) == null ? void 0 : _a5.getModel();
|
174
|
+
model && scriptService.execute(model.getValue()).then(() => {
|
175
|
+
messageService.show({
|
176
|
+
content: localeService.t("uniscript.message.success"),
|
177
|
+
type: MessageType.Success
|
178
|
+
});
|
179
|
+
}).catch(() => {
|
180
|
+
messageService.show({
|
181
|
+
content: localeService.t("uniscript.message.failed"),
|
182
|
+
type: MessageType.Error
|
183
|
+
});
|
184
|
+
});
|
185
|
+
}, [localeService, messageService, monacoEditorRef, scriptService]);
|
186
|
+
}
|
187
|
+
__name(useExecution, "useExecution");
|
188
|
+
function UniscriptMenuItemFactory(accessor) {
|
189
|
+
return {
|
190
|
+
id: ToggleScriptPanelOperation.id,
|
191
|
+
title: "toggle-script-panel",
|
192
|
+
tooltip: "script-panel.tooltip.menu-button",
|
193
|
+
icon: "CodeSingle",
|
194
|
+
type: MenuItemType.BUTTON,
|
195
|
+
// FIXME hidden$ and disabled$ are not correctly in doc
|
196
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
197
|
+
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
198
|
+
};
|
199
|
+
}
|
200
|
+
__name(UniscriptMenuItemFactory, "UniscriptMenuItemFactory");
|
201
|
+
const menuSchema = {
|
202
|
+
[RibbonStartGroup.OTHERS]: {
|
203
|
+
[ToggleScriptPanelOperation.id]: {
|
204
|
+
order: 5,
|
205
|
+
menuItemFactory: UniscriptMenuItemFactory
|
206
|
+
}
|
207
|
+
}
|
208
|
+
};
|
209
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
210
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
211
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
212
|
+
return kind && result && __defProp$1(target, key, result), result;
|
213
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a3;
|
214
|
+
let UniscriptController = (_a3 = class extends Disposable {
|
215
|
+
constructor(_menuManagerService, commandService, componentManager) {
|
216
|
+
super(), this._menuManagerService = _menuManagerService, this._menuManagerService.mergeMenu(menuSchema), this.disposeWithMe(componentManager.register(ScriptPanelComponentName, ScriptEditorPanel)), this.disposeWithMe(commandService.registerCommand(ToggleScriptPanelOperation));
|
217
|
+
}
|
218
|
+
}, __name(_a3, "UniscriptController"), _a3);
|
219
|
+
UniscriptController = __decorateClass$1([
|
220
|
+
__decorateParam$1(0, IMenuManagerService),
|
221
|
+
__decorateParam$1(1, ICommandService),
|
222
|
+
__decorateParam$1(2, Inject(ComponentManager))
|
223
|
+
], UniscriptController);
|
224
|
+
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
225
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
226
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
227
|
+
return kind && result && __defProp2(target, key, result), result;
|
228
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam");
|
229
|
+
const PLUGIN_NAME = "UNIVER_UNISCRIPT_PLUGIN";
|
230
|
+
var _a4;
|
231
|
+
let UniverUniscriptPlugin = (_a4 = class extends Plugin {
|
232
|
+
constructor(_config = defaultPluginConfig, _injector, _configService) {
|
233
|
+
super(), this._config = _config, this._injector = _injector, this._configService = _configService;
|
234
|
+
const { menu, ...rest } = this._config;
|
235
|
+
menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
|
236
|
+
}
|
237
|
+
onStarting() {
|
238
|
+
const injector = this._injector;
|
239
|
+
[
|
240
|
+
[UniscriptController],
|
241
|
+
[ScriptEditorService],
|
242
|
+
[ScriptPanelService]
|
243
|
+
].forEach((d) => injector.add(d)), this.registerExecution();
|
244
|
+
}
|
245
|
+
onSteady() {
|
246
|
+
this._injector.get(UniscriptController);
|
247
|
+
}
|
248
|
+
/**
|
249
|
+
* Allows being overridden, replacing with a new UniscriptExecutionService.
|
250
|
+
*/
|
251
|
+
registerExecution() {
|
252
|
+
this._injector.add([IUniscriptExecutionService, { useClass: UniscriptExecutionService }]);
|
253
|
+
}
|
254
|
+
}, __name(_a4, "UniverUniscriptPlugin"), __publicField(_a4, "pluginName", PLUGIN_NAME), _a4);
|
255
|
+
UniverUniscriptPlugin = __decorateClass([
|
256
|
+
__decorateParam(1, Inject(Injector)),
|
257
|
+
__decorateParam(2, IConfigService)
|
258
|
+
], UniverUniscriptPlugin);
|
259
|
+
export {
|
260
|
+
IUniscriptExecutionService,
|
261
|
+
ScriptEditorService,
|
262
|
+
ToggleScriptPanelOperation,
|
263
|
+
UniverUniscriptPlugin
|
264
|
+
};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"script-panel": {
|
3
|
+
"title": "Uniscript",
|
4
|
+
"tooltip": {
|
5
|
+
"menu-button": "نمایش/مخفی کردن پنل Uniscript"
|
6
|
+
},
|
7
|
+
"panel": {
|
8
|
+
"execute": "اجرای اسکریپت"
|
9
|
+
}
|
10
|
+
},
|
11
|
+
"uniscript": {
|
12
|
+
"message": {
|
13
|
+
"success": "اجرای موفق",
|
14
|
+
"failed": "اجرای ناموفق"
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
package/lib/umd/index.js
CHANGED
@@ -1 +1,9 @@
|
|
1
|
-
(function(_0x56d301,_0x471be8){const _0x4d3774=_0x5e4c,_0xf7039c=_0x56d301();while(!![]){try{const _0x1b396b=parseInt(_0x4d3774(0x233))/0x1*(parseInt(_0x4d3774(0x214))/0x2)+-parseInt(_0x4d3774(0x1eb))/0x3+-parseInt(_0x4d3774(0x19a))/0x4+-parseInt(_0x4d3774(0x1b1))/0x5+parseInt(_0x4d3774(0x205))/0x6+parseInt(_0x4d3774(0x1d0))/0x7*(-parseInt(_0x4d3774(0x1d8))/0x8)+parseInt(_0x4d3774(0x1a8))/0x9;if(_0x1b396b===_0x471be8)break;else _0xf7039c['push'](_0xf7039c['shift']());}catch(_0x43ee89){_0xf7039c['push'](_0xf7039c['shift']());}}}(_0x5b17,0x60a4f),function(_0xc2b863,_0x3d14bb){const _0x227c8d=_0x5e4c;typeof exports=='object'&&typeof module<'u'?_0x3d14bb(exports,require('@univerjs/core'),require('@univerjs/ui'),require(_0x227c8d(0x20f)),require(_0x227c8d(0x19f)),require('@univerjs/design'),require(_0x227c8d(0x210)),require(_0x227c8d(0x1af)),require('@univerjs/sheets-ui'),require(_0x227c8d(0x1e3))):typeof define==_0x227c8d(0x207)&&define[_0x227c8d(0x1bd)]?define([_0x227c8d(0x219),_0x227c8d(0x1e6),_0x227c8d(0x20d),'rxjs','react','@univerjs/design','monaco-editor','@univerjs/facade',_0x227c8d(0x1c2),_0x227c8d(0x1e3)],_0x3d14bb):(_0xc2b863=typeof globalThis<'u'?globalThis:_0xc2b863||self,_0x3d14bb(_0xc2b863['UniverUniscript']={},_0xc2b863[_0x227c8d(0x1d6)],_0xc2b863[_0x227c8d(0x1cd)],_0xc2b863[_0x227c8d(0x20f)],_0xc2b863[_0x227c8d(0x202)],_0xc2b863['UniverDesign'],_0xc2b863['monaco'],_0xc2b863['UniverFacade'],_0xc2b863['UniverSheetsUi'],_0xc2b863[_0x227c8d(0x21a)]));}(this,function(_0x32fb74,_0x288b35,_0x53a6ca,_0x456227,_0x15da96,_0x2ad5b9,_0x3cd4a1,_0x171b0f,_0x2cb2f8,_0x179404){'use strict';const _0x1ed292=_0x5e4c;var _0xceb5eb=Object[_0x1ed292(0x1dc)],_0x387ca5=(_0x31b6a6,_0x2b055f,_0x427e77)=>_0x2b055f in _0x31b6a6?_0xceb5eb(_0x31b6a6,_0x2b055f,{'enumerable':!0x0,'configurable':!0x0,'writable':!0x0,'value':_0x427e77}):_0x31b6a6[_0x2b055f]=_0x427e77,_0x1cfc48=(_0x2adcbe,_0x874e8)=>_0xceb5eb(_0x2adcbe,_0x1ed292(0x1f6),{'value':_0x874e8,'configurable':!0x0}),_0x309dad=(_0x28a30d,_0x4363f9,_0x47ed73)=>_0x387ca5(_0x28a30d,typeof _0x4363f9!=_0x1ed292(0x1ec)?_0x4363f9+'':_0x4363f9,_0x47ed73),_0x34d79c,_0x582c29,_0x4a8d27,_0x1435af;const _0x2e7145='uniscript.config',_0x285069={},_0x428ecd=class _0x21bcd7 extends _0x288b35[_0x1ed292(0x1d4)]{constructor(){const _0x1e5e68=_0x1ed292;super(...arguments),_0x309dad(this,'_open$',new _0x456227[(_0x1e5e68(0x1dd))](!0x1)),_0x309dad(this,'open$',this[_0x1e5e68(0x1b4)]['pipe'](_0x456227[_0x1e5e68(0x224)]()));}get[_0x1ed292(0x1a9)](){const _0x400256=_0x1ed292;return this['_open$'][_0x400256(0x22a)]();}[_0x1ed292(0x203)](){const _0x88fce8=_0x1ed292;super[_0x88fce8(0x203)](),this[_0x88fce8(0x1b4)][_0x88fce8(0x1e1)](!0x1),this['_open$']['complete']();}[_0x1ed292(0x1cb)](){const _0x13b146=_0x1ed292;this[_0x13b146(0x1b4)]['next'](!0x0);}[_0x1ed292(0x1e4)](){const _0x4ae9c6=_0x1ed292;this[_0x4ae9c6(0x1b4)][_0x4ae9c6(0x1e1)](!0x1);}};_0x1cfc48(_0x428ecd,_0x1ed292(0x1fe));let _0x2c6f97=_0x428ecd;const _0x193efa=_0x1ed292(0x1d9),_0x238e5f={'type':_0x288b35['CommandType'][_0x1ed292(0x1c8)],'id':'univer.operation.toggle-script-panel','handler':_0x1cfc48(_0x1ae32d=>{const _0x483dc8=_0x1ed292,_0x1af920=_0x1ae32d[_0x483dc8(0x1ea)](_0x2c6f97),_0x55fbaf=_0x1ae32d['get'](_0x53a6ca['ISidebarService']);return _0x1af920['isOpen']?(_0x1af920[_0x483dc8(0x1e4)](),_0x55fbaf[_0x483dc8(0x1e4)]()):(_0x1af920[_0x483dc8(0x1cb)](),_0x55fbaf[_0x483dc8(0x1cb)]({'header':{'title':_0x483dc8(0x217)},'children':{'label':_0x193efa},'width':0x258})),!0x0;},'handler')};var _0x3a702e={'exports':{}},_0xe5545e={},_0x50e5ca=_0x15da96,_0x3f2d93=Symbol[_0x1ed292(0x218)]('react.element'),_0x4514c9=Symbol[_0x1ed292(0x218)](_0x1ed292(0x1a0)),_0x104db4=Object[_0x1ed292(0x1c0)][_0x1ed292(0x20a)],_0x3f5c22=_0x50e5ca[_0x1ed292(0x1e2)][_0x1ed292(0x20e)],_0x4cc2c0={'key':!0x0,'ref':!0x0,'__self':!0x0,'__source':!0x0};function _0x167c4f(_0x58fbf1,_0x11facb,_0x26f015){const _0x1ea923=_0x1ed292;var _0x4dd5cd,_0x43e25f={},_0x14a5c1=null,_0x3f218d=null;_0x26f015!==void 0x0&&(_0x14a5c1=''+_0x26f015),_0x11facb[_0x1ea923(0x1de)]!==void 0x0&&(_0x14a5c1=''+_0x11facb[_0x1ea923(0x1de)]),_0x11facb['ref']!==void 0x0&&(_0x3f218d=_0x11facb['ref']);for(_0x4dd5cd in _0x11facb)_0x104db4[_0x1ea923(0x1ff)](_0x11facb,_0x4dd5cd)&&!_0x4cc2c0[_0x1ea923(0x20a)](_0x4dd5cd)&&(_0x43e25f[_0x4dd5cd]=_0x11facb[_0x4dd5cd]);if(_0x58fbf1&&_0x58fbf1[_0x1ea923(0x1a1)]){for(_0x4dd5cd in(_0x11facb=_0x58fbf1[_0x1ea923(0x1a1)],_0x11facb))_0x43e25f[_0x4dd5cd]===void 0x0&&(_0x43e25f[_0x4dd5cd]=_0x11facb[_0x4dd5cd]);}return{'$$typeof':_0x3f2d93,'type':_0x58fbf1,'key':_0x14a5c1,'ref':_0x3f218d,'props':_0x43e25f,'_owner':_0x3f5c22[_0x1ea923(0x1ee)]};}_0x1cfc48(_0x167c4f,'q'),_0xe5545e[_0x1ed292(0x1b5)]=_0x4514c9,_0xe5545e[_0x1ed292(0x200)]=_0x167c4f,_0xe5545e[_0x1ed292(0x1fd)]=_0x167c4f,_0x3a702e[_0x1ed292(0x219)]=_0xe5545e;var _0x41a340=_0x3a702e[_0x1ed292(0x219)],_0x4e3c94=Object[_0x1ed292(0x1dc)],_0xdfd1db=Object[_0x1ed292(0x1d3)],_0x18abfa=_0x1cfc48((_0x548e05,_0x213ee5,_0x3757a7,_0x35922f)=>{const _0x4aab86=_0x1ed292;for(var _0x4914fc=_0x35922f>0x1?void 0x0:_0x35922f?_0xdfd1db(_0x213ee5,_0x3757a7):_0x213ee5,_0x2717a4=_0x548e05[_0x4aab86(0x1db)]-0x1,_0x550deb;_0x2717a4>=0x0;_0x2717a4--)(_0x550deb=_0x548e05[_0x2717a4])&&(_0x4914fc=(_0x35922f?_0x550deb(_0x213ee5,_0x3757a7,_0x4914fc):_0x550deb(_0x4914fc))||_0x4914fc);return _0x35922f&&_0x4914fc&&_0x4e3c94(_0x213ee5,_0x3757a7,_0x4914fc),_0x4914fc;},_0x1ed292(0x1ae)),_0x39523d=_0x1cfc48((_0x9d22ee,_0x1844e6)=>(_0x5e56b7,_0x3bcb93)=>_0x1844e6(_0x5e56b7,_0x3bcb93,_0x9d22ee),_0x1ed292(0x216));_0x32fb74[_0x1ed292(0x1b8)]=(_0x34d79c=class extends _0x288b35[_0x1ed292(0x1d4)]{constructor(_0x222afd){const _0xb8b90=_0x1ed292;super(),_0x309dad(this,_0xb8b90(0x225),null),this[_0xb8b90(0x226)]=_0x222afd;}['setEditorInstance'](_0xf52bd1){const _0x222cfc=_0x1ed292;return this[_0x222cfc(0x225)]=_0xf52bd1,_0x288b35[_0x222cfc(0x229)](()=>this[_0x222cfc(0x225)]=null);}[_0x1ed292(0x1a6)](){const _0x1b17be=_0x1ed292;return this[_0x1b17be(0x225)];}[_0x1ed292(0x1e9)](){const _0x17f3d6=_0x1ed292;if(!window['MonacoEnvironment']){const _0xf30ab5=this['_configService'][_0x17f3d6(0x1a3)](_0x2e7145);window[_0x17f3d6(0x1fc)]={'getWorkerUrl':_0xf30ab5==null?void 0x0:_0xf30ab5[_0x17f3d6(0x21e)]};}}},_0x1cfc48(_0x34d79c,_0x1ed292(0x1b8)),_0x34d79c),_0x32fb74['ScriptEditorService']=_0x18abfa([_0x39523d(0x0,_0x288b35[_0x1ed292(0x1ce)])],_0x32fb74[_0x1ed292(0x1b8)]);var _0x4080db=Object[_0x1ed292(0x1dc)],_0x53e014=Object[_0x1ed292(0x1d3)],_0x5efcd2=_0x1cfc48((_0x127596,_0x571105,_0x4e3cc7,_0x493d5d)=>{const _0x281255=_0x1ed292;for(var _0x346365=_0x493d5d>0x1?void 0x0:_0x493d5d?_0x53e014(_0x571105,_0x4e3cc7):_0x571105,_0xde5cbc=_0x127596[_0x281255(0x1db)]-0x1,_0x2210be;_0xde5cbc>=0x0;_0xde5cbc--)(_0x2210be=_0x127596[_0xde5cbc])&&(_0x346365=(_0x493d5d?_0x2210be(_0x571105,_0x4e3cc7,_0x346365):_0x2210be(_0x346365))||_0x346365);return _0x493d5d&&_0x346365&&_0x4080db(_0x571105,_0x4e3cc7,_0x346365),_0x346365;},'__decorateClass$2'),_0x433fe8=_0x1cfc48((_0x268d84,_0x1e216b)=>(_0x22a879,_0x58ee5a)=>_0x1e216b(_0x22a879,_0x58ee5a,_0x268d84),_0x1ed292(0x215));const _0x357e09=_0x288b35['createIdentifier'](_0x1ed292(0x1f7));let _0xeb602e=(_0x582c29=class extends _0x288b35[_0x1ed292(0x1d4)]{constructor(_0xee8803,_0x3f9f42){const _0x15f0bc=_0x1ed292;super(),this[_0x15f0bc(0x1f9)]=_0xee8803,this[_0x15f0bc(0x1b6)]=_0x3f9f42;}async[_0x1ed292(0x21f)](_0x1372e7){const _0x2de0ae=_0x1ed292;this[_0x2de0ae(0x1f9)][_0x2de0ae(0x201)](_0x2de0ae(0x19c),_0x2de0ae(0x1e7));const _0x9de2da=_0x171b0f['FUniver'][_0x2de0ae(0x1ca)](this['_injector']),_0x20915b=new Function(_0x2de0ae(0x211),_0x2de0ae(0x1f8)+_0x1372e7+_0x2de0ae(0x1c9));try{return _0x20915b(_0x9de2da),!0x0;}catch(_0x2feaf9){return this[_0x2de0ae(0x1f9)][_0x2de0ae(0x230)](_0x2feaf9),!0x1;}}},_0x1cfc48(_0x582c29,_0x1ed292(0x208)),_0x582c29);_0xeb602e=_0x5efcd2([_0x433fe8(0x0,_0x288b35[_0x1ed292(0x1d2)]),_0x433fe8(0x1,_0x288b35[_0x1ed292(0x1b9)](_0x288b35['Injector']))],_0xeb602e);const _0x37d588={'scriptEditorPanel':_0x1ed292(0x199),'scriptEditorContent':_0x1ed292(0x1b0),'scriptEditorActions':_0x1ed292(0x1ac)};function _0x1a4686(){const _0x1a6b16=_0x1ed292,_0x2502a9=_0x15da96['useRef'](null),_0x134597=_0x15da96['useRef'](null),_0x171e7e=_0x15da96[_0x1a6b16(0x1a2)](null),_0x33ba92=_0x288b35[_0x1a6b16(0x1b2)](_0x288b35['LocaleService']),_0x4f5294=_0x288b35[_0x1a6b16(0x1b2)](_0x53a6ca[_0x1a6b16(0x213)]),_0x33df86=_0x288b35[_0x1a6b16(0x1b2)](_0x32fb74[_0x1a6b16(0x1b8)]);_0x15da96[_0x1a6b16(0x22e)](()=>{const _0x3a4dab=_0x1a6b16,_0x4932cb=_0x134597[_0x3a4dab(0x1ee)],_0x95263e=_0x2502a9['current'];let _0x272c36=null,_0x16fb1a=null;if(_0x4932cb&&_0x95263e){_0x33df86[_0x3a4dab(0x1e9)]();const _0x526e5f=_0x171e7e[_0x3a4dab(0x1ee)]=_0x3cd4a1[_0x3a4dab(0x1ed)][_0x3a4dab(0x22c)](_0x4932cb,{'value':'','language':_0x3a4dab(0x227)});_0x16fb1a=new ResizeObserver(()=>{let _0x3b19d1=requestIdleCallback(()=>{const _0x363b7c=_0x5e4c;if(!_0x3b19d1)return;const {height:_0x55c0e1,width:_0x48359c}=_0x95263e[_0x363b7c(0x1bf)]();_0x526e5f['layout']({'width':_0x48359c,'height':_0x55c0e1}),_0x3b19d1=void 0x0;});}),_0x16fb1a['observe'](_0x95263e);let _0x442452;_0x272c36=new _0x288b35[(_0x3a4dab(0x1ad))](),_0x272c36[_0x3a4dab(0x1c5)](_0x33df86[_0x3a4dab(0x1d7)](_0x526e5f)),_0x272c36[_0x3a4dab(0x1c5)](_0x526e5f[_0x3a4dab(0x21d)](()=>{_0x442452=_0x4f5294['forceEscape']();})),_0x272c36['add'](_0x526e5f[_0x3a4dab(0x232)](()=>{const _0x5eaa55=_0x3a4dab;_0x442452==null||_0x442452[_0x5eaa55(0x203)](),_0x442452=void 0x0;})),_0x272c36[_0x3a4dab(0x1c5)](_0x288b35[_0x3a4dab(0x229)](()=>_0x442452==null?void 0x0:_0x442452[_0x3a4dab(0x203)]()));}return()=>{const _0x2bda41=_0x3a4dab;_0x16fb1a&&_0x95263e&&_0x16fb1a[_0x2bda41(0x231)](_0x95263e),_0x272c36==null||_0x272c36[_0x2bda41(0x203)]();};},[_0x33df86,_0x4f5294]);const _0x4b307e=_0x58f7b5(_0x171e7e);return _0x41a340['jsxs'](_0x1a6b16(0x1b7),{'className':_0x37d588[_0x1a6b16(0x1c4)],'children':[_0x41a340[_0x1a6b16(0x200)](_0x1a6b16(0x1b7),{'className':_0x37d588[_0x1a6b16(0x1e5)],'ref':_0x2502a9,'children':_0x41a340[_0x1a6b16(0x200)](_0x1a6b16(0x1b7),{'className':_0x37d588[_0x1a6b16(0x1c1)],'ref':_0x134597})}),_0x41a340['jsx']('div',{'className':_0x37d588[_0x1a6b16(0x1f0)],'children':_0x41a340[_0x1a6b16(0x200)](_0x2ad5b9[_0x1a6b16(0x1a7)],{'type':'primary','size':_0x1a6b16(0x1f2),'onClick':_0x4b307e,'children':_0x33ba92['t'](_0x1a6b16(0x1c6))})})]});}_0x1cfc48(_0x1a4686,_0x1ed292(0x212));function _0x58f7b5(_0x7eccb8){const _0x549cbe=_0x1ed292,_0x3c0519=_0x288b35[_0x549cbe(0x1b2)](_0x357e09),_0x251f8a=_0x288b35[_0x549cbe(0x1b2)](_0x53a6ca[_0x549cbe(0x20c)]),_0x991b0f=_0x288b35[_0x549cbe(0x1b2)](_0x288b35['LocaleService']);return _0x15da96['useCallback'](()=>{const _0x44b94f=_0x549cbe;var _0x2f40b5;const _0x5e8574=(_0x2f40b5=_0x7eccb8[_0x44b94f(0x1ee)])==null?void 0x0:_0x2f40b5['getModel']();_0x5e8574&&_0x3c0519[_0x44b94f(0x21f)](_0x5e8574[_0x44b94f(0x22a)]())[_0x44b94f(0x1a4)](()=>{const _0x1c9827=_0x44b94f;_0x251f8a[_0x1c9827(0x1be)]({'content':_0x991b0f['t'](_0x1c9827(0x19e)),'type':_0x2ad5b9[_0x1c9827(0x1b3)][_0x1c9827(0x206)]});})['catch'](()=>{const _0x548fd5=_0x44b94f;_0x251f8a[_0x548fd5(0x1be)]({'content':_0x991b0f['t'](_0x548fd5(0x1f3)),'type':_0x2ad5b9[_0x548fd5(0x1b3)][_0x548fd5(0x1df)]});});},[_0x991b0f,_0x251f8a,_0x7eccb8,_0x3c0519]);}_0x1cfc48(_0x58f7b5,'useExecution');function _0x3bb483(_0x35c9a8){const _0x19d277=_0x1ed292;return{'id':_0x238e5f['id'],'title':_0x19d277(0x1cc),'tooltip':_0x19d277(0x220),'icon':_0x19d277(0x1a5),'type':_0x53a6ca[_0x19d277(0x1aa)][_0x19d277(0x1ab)],'hidden$':_0x53a6ca[_0x19d277(0x1f5)](_0x35c9a8,_0x288b35['UniverInstanceType'][_0x19d277(0x22d)]),'disabled$':_0x2cb2f8['getCurrentRangeDisable$'](_0x35c9a8,{'workbookTypes':[_0x179404['WorkbookEditablePermission']],'worksheetTypes':[_0x179404[_0x19d277(0x209)],_0x179404[_0x19d277(0x221)],_0x179404['WorksheetSetCellValuePermission']],'rangeTypes':[_0x179404[_0x19d277(0x1ba)]]})};}_0x1cfc48(_0x3bb483,_0x1ed292(0x1d1));const _0x2c020c={[_0x53a6ca[_0x1ed292(0x1bb)][_0x1ed292(0x228)]]:{[_0x238e5f['id']]:{'order':0x5,'menuItemFactory':_0x3bb483}}};var _0x3217b5=Object[_0x1ed292(0x1dc)],_0x4178b6=Object[_0x1ed292(0x1d3)],_0x57444b=_0x1cfc48((_0x90d0b2,_0x387d27,_0x2e1fef,_0x13bfbc)=>{for(var _0x456927=_0x13bfbc>0x1?void 0x0:_0x13bfbc?_0x4178b6(_0x387d27,_0x2e1fef):_0x387d27,_0x525759=_0x90d0b2['length']-0x1,_0x5ccad4;_0x525759>=0x0;_0x525759--)(_0x5ccad4=_0x90d0b2[_0x525759])&&(_0x456927=(_0x13bfbc?_0x5ccad4(_0x387d27,_0x2e1fef,_0x456927):_0x5ccad4(_0x456927))||_0x456927);return _0x13bfbc&&_0x456927&&_0x3217b5(_0x387d27,_0x2e1fef,_0x456927),_0x456927;},_0x1ed292(0x21c)),_0x21df81=_0x1cfc48((_0x477db0,_0x170a76)=>(_0x9c35bc,_0x2a8e24)=>_0x170a76(_0x9c35bc,_0x2a8e24,_0x477db0),'__decorateParam$1');let _0x2e1b7e=(_0x4a8d27=class extends _0x288b35[_0x1ed292(0x1d4)]{constructor(_0x5cb6bc,_0x52f2f5,_0xc90db){const _0x2000c0=_0x1ed292;super(),this['_menuManagerService']=_0x5cb6bc,this[_0x2000c0(0x1ef)]['mergeMenu'](_0x2c020c),this[_0x2000c0(0x1c3)](_0xc90db[_0x2000c0(0x20b)](_0x193efa,_0x1a4686)),this[_0x2000c0(0x1c3)](_0x52f2f5['registerCommand'](_0x238e5f));}},_0x1cfc48(_0x4a8d27,'UniscriptController'),_0x4a8d27);_0x2e1b7e=_0x57444b([_0x21df81(0x0,_0x53a6ca[_0x1ed292(0x1fb)]),_0x21df81(0x1,_0x288b35[_0x1ed292(0x19d)]),_0x21df81(0x2,_0x288b35['Inject'](_0x53a6ca[_0x1ed292(0x1f4)]))],_0x2e1b7e);var _0x3783d4=Object[_0x1ed292(0x1dc)],_0x5b31a8=Object[_0x1ed292(0x1d3)],_0x25faaa=_0x1cfc48((_0x4d16f8,_0x5907f5,_0x475f89,_0x3c3c94)=>{for(var _0x5a63a5=_0x3c3c94>0x1?void 0x0:_0x3c3c94?_0x5b31a8(_0x5907f5,_0x475f89):_0x5907f5,_0x5b22ab=_0x4d16f8['length']-0x1,_0x21f38c;_0x5b22ab>=0x0;_0x5b22ab--)(_0x21f38c=_0x4d16f8[_0x5b22ab])&&(_0x5a63a5=(_0x3c3c94?_0x21f38c(_0x5907f5,_0x475f89,_0x5a63a5):_0x21f38c(_0x5a63a5))||_0x5a63a5);return _0x3c3c94&&_0x5a63a5&&_0x3783d4(_0x5907f5,_0x475f89,_0x5a63a5),_0x5a63a5;},_0x1ed292(0x1c7)),_0x301d8b=_0x1cfc48((_0x1da5ed,_0x248c17)=>(_0x2bc597,_0x1c6478)=>_0x248c17(_0x2bc597,_0x1c6478,_0x1da5ed),_0x1ed292(0x19b));const _0x7a5ab3=_0x1ed292(0x1fa);_0x32fb74['UniverUniscriptPlugin']=(_0x1435af=class extends _0x288b35[_0x1ed292(0x1e0)]{constructor(_0x1fc5f7=_0x285069,_0x3ceb3e,_0x56c166){const _0x379503=_0x1ed292;super(),this['_config']=_0x1fc5f7,this['_injector']=_0x3ceb3e,this[_0x379503(0x226)]=_0x56c166;const {menu:_0x5c2ef,..._0x4eeade}=this[_0x379503(0x1da)];_0x5c2ef&&this[_0x379503(0x226)][_0x379503(0x204)](_0x379503(0x223),_0x5c2ef,{'merge':!0x0}),this[_0x379503(0x226)][_0x379503(0x204)](_0x2e7145,_0x4eeade);}[_0x1ed292(0x22f)](){const _0x5e4d07=_0x1ed292,_0x595fd2=this['_injector'];[[_0x2e1b7e],[_0x32fb74[_0x5e4d07(0x1b8)]],[_0x2c6f97]][_0x5e4d07(0x1f1)](_0x3f2a38=>_0x595fd2[_0x5e4d07(0x1c5)](_0x3f2a38)),this[_0x5e4d07(0x1d5)]();}[_0x1ed292(0x1bc)](){const _0x122a44=_0x1ed292;this['_injector'][_0x122a44(0x1ea)](_0x2e1b7e);}[_0x1ed292(0x1d5)](){const _0x570a1b=_0x1ed292;this[_0x570a1b(0x1b6)][_0x570a1b(0x1c5)]([_0x357e09,{'useClass':_0xeb602e}]);}},_0x1cfc48(_0x1435af,_0x1ed292(0x1cf)),_0x309dad(_0x1435af,'pluginName',_0x7a5ab3),_0x1435af),_0x32fb74[_0x1ed292(0x1cf)]=_0x25faaa([_0x301d8b(0x1,_0x288b35[_0x1ed292(0x1b9)](_0x288b35[_0x1ed292(0x222)])),_0x301d8b(0x2,_0x288b35[_0x1ed292(0x1ce)])],_0x32fb74['UniverUniscriptPlugin']),_0x32fb74['IUniscriptExecutionService']=_0x357e09,_0x32fb74[_0x1ed292(0x21b)]=_0x238e5f,Object[_0x1ed292(0x1dc)](_0x32fb74,Symbol[_0x1ed292(0x1e8)],{'value':_0x1ed292(0x22b)});}));function _0x5e4c(_0x107bbc,_0x279415){const _0x5b176b=_0x5b17();return _0x5e4c=function(_0x5e4c63,_0x3ed919){_0x5e4c63=_0x5e4c63-0x199;let _0x3330d1=_0x5b176b[_0x5e4c63];return _0x3330d1;},_0x5e4c(_0x107bbc,_0x279415);}function _0x5b17(){const _0x372dc1=['26uoDviz','__decorateParam$2','__decorateParam$3','script-panel.title','for','exports','UniverSheets','ToggleScriptPanelOperation','__decorateClass$1','onDidFocusEditorWidget','getWorkerUrl','execute','script-panel.tooltip.menu-button','WorksheetSetCellStylePermission','Injector','menu','distinctUntilChanged','_editorInstance','_configService','javascript','OTHERS','toDisposable','getValue','Module','create','UNIVER_SHEET','useEffect','onStarting','error','unobserve','onDidBlurEditorWidget','37749OnfOhH','univer-script-editor-panel','1452952NYhQNn','__decorateParam','[UniscriptExecutionService]','ICommandService','uniscript.message.success','react','react.fragment','defaultProps','useRef','getConfig','then','CodeSingle','getEditorInstance','Button','14860692VAyEki','isOpen','MenuItemType','BUTTON','univer-script-editor-actions','DisposableCollection','__decorateClass$3','@univerjs/facade','univer-script-editor-content','2509730vTxyJw','useDependency','MessageType','_open$','Fragment','_injector','div','ScriptEditorService','Inject','RangeProtectionPermissionEditPoint','RibbonStartGroup','onSteady','amd','show','getBoundingClientRect','prototype','scriptEditorContainer','@univerjs/sheets-ui','disposeWithMe','scriptEditorPanel','add','script-panel.panel.execute','__decorateClass','OPERATION','})()','newAPI','open','toggle-script-panel','UniverUi','IConfigService','UniverUniscriptPlugin','12607SmLDwN','UniscriptMenuItemFactory','ILogService','getOwnPropertyDescriptor','Disposable','registerExecution','UniverCore','setEditorInstance','2704OOOIrt','ScriptPanel','_config','length','defineProperty','BehaviorSubject','key','Error','Plugin','next','__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED','@univerjs/sheets','close','scriptEditorContent','@univerjs/core','executing\x20Uniscript...','toStringTag','requireVscodeEditor','get','1539987YUNbpL','symbol','editor','current','_menuManagerService','scriptEditorActions','forEach','small','uniscript.message.failed','ComponentManager','getMenuHiddenObservable','name','univer.uniscript.execution-service','(()\x20=>\x20{','_logService','UNIVER_UNISCRIPT_PLUGIN','IMenuManagerService','MonacoEnvironment','jsxs','ScriptPanelService','call','jsx','log','React','dispose','setConfig','1447086sHXxOn','Success','function','UniscriptExecutionService','WorksheetEditPermission','hasOwnProperty','register','IMessageService','@univerjs/ui','ReactCurrentOwner','rxjs','monaco-editor','univerAPI','ScriptEditorPanel','IShortcutService'];_0x5b17=function(){return _0x372dc1;};return _0x5b17();}
|
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,_d;const PLUGIN_CONFIG_KEY="uniscript.config",defaultPluginConfig={},_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
|
+
* @license React
|
3
|
+
* react-jsx-runtime.production.min.js
|
4
|
+
*
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
6
|
+
*
|
7
|
+
* This source code is licensed under the MIT license found in the
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
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,__defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(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$3(target,key,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$3");exports2.ScriptEditorService=(_a=class extends core.Disposable{constructor(_configService){super();__publicField(this,"_editorInstance",null);this._configService=_configService}setEditorInstance(editor){return this._editorInstance=editor,core.toDisposable(()=>this._editorInstance=null)}getEditorInstance(){return this._editorInstance}requireVscodeEditor(){if(!window.MonacoEnvironment){const config=this._configService.getConfig(PLUGIN_CONFIG_KEY);window.MonacoEnvironment={getWorkerUrl:config==null?void 0:config.getWorkerUrl}}}},__name(_a,"ScriptEditorService"),_a),exports2.ScriptEditorService=__decorateClass$3([__decorateParam$3(0,core.IConfigService)],exports2.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=(_b=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(_b,"UniscriptExecutionService"),_b);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(exports2.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,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");const menuSchema={[ui.RibbonStartGroup.OTHERS]:{[ToggleScriptPanelOperation.id]:{order:5,menuItemFactory: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");let UniscriptController=(_c=class extends core.Disposable{constructor(_menuManagerService,commandService,componentManager){super(),this._menuManagerService=_menuManagerService,this._menuManagerService.mergeMenu(menuSchema),this.disposeWithMe(componentManager.register(ScriptPanelComponentName,ScriptEditorPanel)),this.disposeWithMe(commandService.registerCommand(ToggleScriptPanelOperation))}},__name(_c,"UniscriptController"),_c);UniscriptController=__decorateClass$1([__decorateParam$1(0,ui.IMenuManagerService),__decorateParam$1(1,core.ICommandService),__decorateParam$1(2,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="UNIVER_UNISCRIPT_PLUGIN";exports2.UniverUniscriptPlugin=(_d=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_configService){super(),this._config=_config,this._injector=_injector,this._configService=_configService;const{menu,...rest}=this._config;menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){const injector=this._injector;[[UniscriptController],[exports2.ScriptEditorService],[ScriptPanelService]].forEach(d=>injector.add(d)),this.registerExecution()}onSteady(){this._injector.get(UniscriptController)}registerExecution(){this._injector.add([IUniscriptExecutionService,{useClass:UniscriptExecutionService}])}},__name(_d,"UniverUniscriptPlugin"),__publicField(_d,"pluginName",PLUGIN_NAME),_d),exports2.UniverUniscriptPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService)],exports2.UniverUniscriptPlugin),exports2.IUniscriptExecutionService=IUniscriptExecutionService,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.3.0-nightly.
|
3
|
+
"version": "0.3.0-nightly.202410111606",
|
4
4
|
"private": false,
|
5
5
|
"description": "UI component library for building exceptional Univer.",
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
@@ -50,30 +50,30 @@
|
|
50
50
|
"monaco-editor": ">=0.44.0",
|
51
51
|
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
|
52
52
|
"rxjs": ">=7.0.0",
|
53
|
-
"@univerjs/
|
54
|
-
"@univerjs/
|
55
|
-
"@univerjs/
|
56
|
-
"@univerjs/
|
57
|
-
"@univerjs/sheets": "0.3.0-nightly.
|
58
|
-
"@univerjs/ui": "0.3.0-nightly.
|
53
|
+
"@univerjs/design": "0.3.0-nightly.202410111606",
|
54
|
+
"@univerjs/sheets": "0.3.0-nightly.202410111606",
|
55
|
+
"@univerjs/core": "0.3.0-nightly.202410111606",
|
56
|
+
"@univerjs/facade": "0.3.0-nightly.202410111606",
|
57
|
+
"@univerjs/sheets-ui": "0.3.0-nightly.202410111606",
|
58
|
+
"@univerjs/ui": "0.3.0-nightly.202410111606"
|
59
59
|
},
|
60
60
|
"dependencies": {
|
61
61
|
"@univerjs/protocol": "0.1.39-alpha.15",
|
62
62
|
"monaco-editor": "0.52.0",
|
63
|
-
"@univerjs/core": "0.3.0-nightly.
|
64
|
-
"@univerjs/design": "0.3.0-nightly.
|
65
|
-
"@univerjs/facade": "0.3.0-nightly.
|
66
|
-
"@univerjs/
|
67
|
-
"@univerjs/
|
68
|
-
"@univerjs/sheets-ui": "0.3.0-nightly.
|
63
|
+
"@univerjs/core": "0.3.0-nightly.202410111606",
|
64
|
+
"@univerjs/design": "0.3.0-nightly.202410111606",
|
65
|
+
"@univerjs/facade": "0.3.0-nightly.202410111606",
|
66
|
+
"@univerjs/sheets": "0.3.0-nightly.202410111606",
|
67
|
+
"@univerjs/ui": "0.3.0-nightly.202410111606",
|
68
|
+
"@univerjs/sheets-ui": "0.3.0-nightly.202410111606"
|
69
69
|
},
|
70
70
|
"devDependencies": {
|
71
|
-
"@types/react": "^18.3.
|
71
|
+
"@types/react": "^18.3.11",
|
72
72
|
"less": "^4.2.0",
|
73
73
|
"rxjs": "^7.8.1",
|
74
|
-
"typescript": "^5.6.
|
74
|
+
"typescript": "^5.6.3",
|
75
75
|
"vite": "^5.4.8",
|
76
|
-
"vitest": "^2.1.
|
76
|
+
"vitest": "^2.1.2",
|
77
77
|
"@univerjs-infra/shared": "0.3.0"
|
78
78
|
},
|
79
79
|
"univerSpace": {
|