@univerjs/action-recorder 0.5.5 → 0.6.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -9
- package/lib/es/index.js +305 -333
- package/lib/types/views/components/RecorderPanel.d.ts +16 -2
- package/lib/umd/index.js +1 -9
- package/package.json +11 -11
package/lib/cjs/index.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
"use strict";var Y=Object.defineProperty;var Q=(r,n,e)=>n in r?Y(r,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[n]=e;var g=(r,n,e)=>Q(r,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),s=require("@univerjs/sheets"),T=require("@univerjs/sheets-filter"),u=require("@univerjs/sheets-ui"),f=require("@univerjs/ui"),b=require("rxjs"),R=require("@univerjs/design"),v=require("react");var S=function(){return S=Object.assign||function(r){for(var n,e=1,t=arguments.length;e<t;e++){n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o]=n[o])}return r},S.apply(this,arguments)},X=function(r,n){var e={};for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&n.indexOf(t)<0&&(e[t]=r[t]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,t=Object.getOwnPropertySymbols(r);o<t.length;o++)n.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(r,t[o])&&(e[t[o]]=r[t[o]]);return e},J=v.forwardRef(function(r,n){var e=r.icon,t=r.id,o=r.className,i=r.extend,c=X(r,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(t," ").concat(o||"").trim(),d=v.useRef("_".concat(te()));return W(e,"".concat(t),{defIds:e.defIds,idSuffix:d.current},S({ref:n,className:l},c),i)});function W(r,n,e,t,o){return v.createElement(r.tag,S(S({key:n},ee(r,e,o)),t),(re(r,e).children||[]).map(function(i,c){return W(i,"".concat(n,"-").concat(r.tag,"-").concat(c),e,void 0,o)}))}function ee(r,n,e){var t=S({},r.attrs);e!=null&&e.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=e.colorChannel1);var o=n.defIds;return!o||o.length===0||(r.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+n.idSuffix),Object.entries(t).forEach(function(i){var c=i[0],l=i[1];typeof l=="string"&&(t[c]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),t}function re(r,n){var e,t=n.defIds;return!t||t.length===0?r:r.tag==="defs"&&(!((e=r.children)===null||e===void 0)&&e.length)?S(S({},r),{children:r.children.map(function(o){return typeof o.attrs.id=="string"&&t&&t.indexOf(o.attrs.id)>-1?S(S({},o),{attrs:S(S({},o.attrs),{id:o.attrs.id+n.idSuffix})}):o})}):r}function te(){return Math.random().toString(36).substring(2,8)}J.displayName="UniverIcon";var ne={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"g",attrs:{fill:"currentColor",clipPath:"url(#record-single_clip0_1559_19)"},children:[{tag:"path",attrs:{d:"M7.60303 10C8.7076 10 9.60303 9.10457 9.60303 8C9.60303 6.89543 8.7076 6 7.60303 6C6.49846 6 5.60303 6.89543 5.60303 8C5.60303 9.10457 6.49846 10 7.60303 10Z"}},{tag:"path",attrs:{d:"M1.66943 5.29023C1.66941 3.85426 2.83349 2.69017 4.26946 2.69019L10.9362 2.69026C12.3192 2.69028 13.45 3.77008 13.5315 5.13259L14.5692 4.55638C15.3024 4.14929 16.2032 4.67947 16.2032 5.51809V10.4819C16.2032 11.3205 15.3024 11.8507 14.5692 11.4436L13.5315 10.8674C13.45 12.2299 12.3192 13.3097 10.9362 13.3097H4.26953C2.83361 13.3097 1.66956 12.1457 1.66953 10.7098L1.66943 5.29023ZM13.5362 9.49743L15.0032 10.312V5.68799L13.5362 6.50254V9.49743ZM4.26945 3.89019C3.49623 3.89018 2.86942 4.517 2.86943 5.29021L2.86953 10.7098C2.86955 11.483 3.49634 12.1097 4.26953 12.1097H10.9362C11.7094 12.1097 12.3362 11.4829 12.3362 10.7097V5.29026C12.3362 4.51707 11.7094 3.89027 10.9362 3.89026L4.26945 3.89019Z",fillRule:"evenodd",clipRule:"evenodd"}}]},{tag:"defs",attrs:{},children:[{tag:"clipPath",attrs:{id:"record-single_clip0_1559_19"},children:[{tag:"path",attrs:{fill:"#fff",d:"M0 0H16V16H0z",transform:"translate(.94)"}}]}]}],defIds:["record-single_clip0_1559_19"]},N=v.forwardRef(function(r,n){return v.createElement(J,Object.assign({},r,{id:"record-single",ref:n,icon:ne}))});N.displayName="RecordSingle";var oe=Object.defineProperty,ie=Object.getOwnPropertyDescriptor,ce=(r,n,e,t)=>{for(var o=t>1?void 0:t?ie(n,e):n,i=r.length-1,c;i>=0;i--)(c=r[i])&&(o=(t?c(n,e,o):c(o))||o);return t&&o&&oe(n,e,o),o},x=(r,n)=>(e,t)=>n(e,t,r);exports.ActionRecorderService=class extends a.Disposable{constructor(e,t,o,i){super();g(this,"_shouldRecordCommands",new Set);g(this,"_panelOpened$",new b.BehaviorSubject(!1));g(this,"panelOpened$",this._panelOpened$.asObservable());g(this,"_recorder",null);g(this,"_recording$",new b.BehaviorSubject(!1));g(this,"recording$",this._recording$.asObservable());g(this,"_recorded$",new b.BehaviorSubject([]));g(this,"_recordedCommands$",new b.BehaviorSubject([]));g(this,"recordedCommands$",this._recordedCommands$.asObservable());this._commandSrv=e,this._logService=t,this._localFileService=o,this._instanceService=i}get recording(){return this._recording$.getValue()}get _recorded(){return this._recorded$.getValue()}get _recordedCommands(){return this._recordedCommands$.getValue()}registerRecordedCommand(e){if(e.type===a.CommandType.MUTATION)throw new Error("[CommandRecorderService] Cannot record mutation commands.");this._shouldRecordCommands.add(e.id)}togglePanel(e){this._panelOpened$.next(e),e===!1&&this.stopRecording()}startRecording(e=!1){this._recorder=this._commandSrv.onCommandExecuted(t=>{var o,i;if(this._shouldRecordCommands.has(t.id)){const c=this._recorded,l=this._recordedCommands;let d={...t};const h=(o=this._instanceService.getFocusedUnit())==null?void 0:o.getUnitId(),{unitId:p=h,subUnitId:m}=d==null?void 0:d.params;if(e&&p&&m){const y=(i=this._instanceService.getUnit(p).getSheetBySheetId(m))==null?void 0:i.getName();d={...d,params:{...d.params,subUnitId:y}}}d.id===s.SetSelectionsOperation.id&&c.length>0&&c[c.length-1].id===s.SetSelectionsOperation.id?c[c.length-1]=d:(c.push(d),this._recorded$.next(c),d.type===a.CommandType.COMMAND&&(l.push(d),this._recordedCommands$.next(l)))}}),this._recording$.next(!0)}stopRecording(){var e;(e=this._recorder)==null||e.dispose(),this._recorder=null,this._recorded$.next([]),this._recordedCommands$.next([]),this._recording$.next(!1)}completeRecording(){const e=this._recorded.slice();this._localFileService.downloadFile(new Blob([JSON.stringify(e,null,2)]),"recorded-commands.json"),this._logService.error("Recorded commands:",e),this.stopRecording()}};exports.ActionRecorderService=ce([x(0,a.ICommandService),x(1,a.ILogService),x(2,f.ILocalFileService),x(3,a.IUniverInstanceService)],exports.ActionRecorderService);const z={id:"action-recorder.command.start-recording",type:a.CommandType.COMMAND,handler:(r,n)=>(r.get(exports.ActionRecorderService).startRecording(!!(n!=null&&n.replaceId)),!0)},k={id:"action-recorder.command.complete-recording",type:a.CommandType.COMMAND,handler:r=>(r.get(exports.ActionRecorderService).completeRecording(),!0)},H={id:"action-recorder.command.stop-recording",type:a.CommandType.COMMAND,handler:r=>(r.get(exports.ActionRecorderService).completeRecording(),!0)};var ae=Object.defineProperty,se=Object.getOwnPropertyDescriptor,de=(r,n,e,t)=>{for(var o=t>1?void 0:t?se(n,e):n,i=r.length-1,c;i>=0;i--)(c=r[i])&&(o=(t?c(n,e,o):c(o))||o);return t&&o&&ae(n,e,o),o},O=(r,n)=>(e,t)=>n(e,t,r),w=(r=>(r.DEFAULT="default",r.NAME="name",r.ACTIVE="active",r))(w||{});exports.ActionReplayService=class extends a.Disposable{constructor(n,e,t,o,i){super(),this._messageService=n,this._instanceService=e,this._localFileService=t,this._logService=o,this._commandService=i}async replayLocalJSON(n="default"){const e=await this._localFileService.openFile({multiple:!1,accept:".json"});if(e.length!==1)return!1;const t=e[0];try{return this.replayCommands(JSON.parse(await t.text()),{mode:n})}catch{return this._messageService.show({type:R.MessageType.Error,content:`Failed to replay commands from local file ${t.name}.`}),!1}}async replayCommands(n,e){var i,c,l;const t=(i=this._instanceService.getFocusedUnit())==null?void 0:i.getUnitId();t||this._logService.error("[ReplayService]","no focused unit to replay commands");const{mode:o}=e||{};for(const d of n){const{id:h,params:p}=d,m=p;if(m){if(typeof m.unitId<"u"&&(m.unitId=t),o==="name"&&m.subUnitId!=="undefined"){const _=(c=this._instanceService.getFocusedUnit().getSheetBySheetName(m.subUnitId))==null?void 0:c.getSheetId();_?m.subUnitId=_:this._logService.error("[ReplayService]",`failed to find subunit by subUnitName = ${m.subUnitId}`)}if(o==="active"&&m.subUnitId!=="undefined"){const _=(l=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:l.getSheetId();_?m.subUnitId=_:this._logService.error("[ReplayService]","failed to find active subunit")}if(!await this._commandService.executeCommand(h,p))return!1}else if(!await this._commandService.executeCommand(h))return!1}return!0}async replayCommandsWithDelay(n){var t;const e=(t=this._instanceService.getFocusedUnit())==null?void 0:t.getUnitId();e||this._logService.error("[ReplayService]","no focused unit to replay commands");for(const o of n){await a.awaitTime(le());const{id:i,params:c}=o;if(c){if(typeof c.unitId<"u"&&(c.unitId=e),!await this._commandService.executeCommand(i,c))return!1}else if(!await this._commandService.executeCommand(i))return!1}return!0}};exports.ActionReplayService=de([O(0,f.IMessageService),O(1,a.IUniverInstanceService),O(2,f.ILocalFileService),O(3,a.ILogService),O(4,a.ICommandService)],exports.ActionReplayService);function le(){return Math.floor(Math.random()*800)+200}const $={id:"action-recorder.command.replay-local-records",type:a.CommandType.COMMAND,handler:async r=>{const e=await r.get(exports.ActionReplayService).replayLocalJSON();return e&&r.get(f.IMessageService).show({type:R.MessageType.Success,content:"Successfully replayed local records"}),e}},E={id:"action-recorder.command.replay-local-records-name",type:a.CommandType.COMMAND,handler:async r=>{const e=await r.get(exports.ActionReplayService).replayLocalJSON(w.NAME);return e&&r.get(f.IMessageService).show({type:R.MessageType.Success,content:"Successfully replayed local records"}),e}},F={id:"action-recorder.command.replay-local-records-active",type:a.CommandType.COMMAND,handler:async r=>{const e=await r.get(exports.ActionReplayService).replayLocalJSON(w.ACTIVE);return e&&r.get(f.IMessageService).show({type:R.MessageType.Success,content:"Successfully replayed local records"}),e}},D={id:"action-recorder.operation.open-panel",type:a.CommandType.OPERATION,handler(r){return r.get(exports.ActionRecorderService).togglePanel(!0),!0}},G={id:"action-recorder.operation.close-panel",type:a.CommandType.OPERATION,handler(r){return r.get(exports.ActionRecorderService).togglePanel(!1),!0}};var j={exports:{}},A={};/**
|
|
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 L;function me(){if(L)return A;L=1;var r=v,n=Symbol.for("react.element"),e=Symbol.for("react.fragment"),t=Object.prototype.hasOwnProperty,o=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function c(l,d,h){var p,m={},y=null,_=null;h!==void 0&&(y=""+h),d.key!==void 0&&(y=""+d.key),d.ref!==void 0&&(_=d.ref);for(p in d)t.call(d,p)&&!i.hasOwnProperty(p)&&(m[p]=d[p]);if(l&&l.defaultProps)for(p in d=l.defaultProps,d)m[p]===void 0&&(m[p]=d[p]);return{$$typeof:n,type:l,key:y,ref:_,props:m,_owner:o.current}}return A.Fragment=e,A.jsx=c,A.jsxs=c,A}var B;function ue(){return B||(B=1,j.exports=me()),j.exports}var C=ue();function Z(r){var n,e,t="";if(typeof r=="string"||typeof r=="number")t+=r;else if(typeof r=="object")if(Array.isArray(r)){var o=r.length;for(n=0;n<o;n++)r[n]&&(e=Z(r[n]))&&(t&&(t+=" "),t+=e)}else for(e in r)r[e]&&(t&&(t+=" "),t+=e);return t}function fe(){for(var r,n,e=0,t="",o=arguments.length;e<o;e++)(r=arguments[e])&&(n=Z(r))&&(t&&(t+=" "),t+=n);return t}const pe="univer-action-recorder-panel",Se="univer-action-recorder-panel-icon",ge="univer-action-recorder-panel-icon-recording",ve="univer-recording",he="univer-action-recorder-panel-title",Ce="univer-action-recorder-panel-actions",P={actionRecorderPanel:pe,actionRecorderPanelIcon:Se,actionRecorderPanelIconRecording:ge,recording:ve,actionRecorderPanelTitle:he,actionRecorderPanelActions:Ce};function _e(){const r=a.useDependency(exports.ActionRecorderService);return f.useObservable(r.panelOpened$)?C.jsx(ye,{}):null}function ye(){var p;const r=a.useDependency(a.ICommandService),n=a.useDependency(exports.ActionRecorderService),e=f.useObservable(n.recording$),t=f.useObservable(n.recordedCommands$),o=(p=t==null?void 0:t.length)!=null?p:0,i=v.useCallback(()=>{e||r.executeCommand(G.id)},[r,e]),c=v.useCallback(m=>{e||r.executeCommand(z.id,{replaceId:m})},[r,e]),l=v.useCallback(()=>{e&&r.executeCommand(k.id)},[r,e]),d=v.useCallback(()=>{e&&r.executeCommand(H.id)},[r,e]),h=e?o===0?"Recording...":`${o}: ${t[o-1].id}`:"Start Recording";return C.jsxs("div",{className:P.actionRecorderPanel,children:[C.jsx("div",{className:fe(P.actionRecorderPanelIcon,e?P.actionRecorderPanelIconRecording:!1),children:C.jsx(N,{})}),C.jsx("div",{className:P.actionRecorderPanelTitle,children:h}),C.jsxs("div",{className:P.actionRecorderPanelActions,children:[C.jsx(R.Button,{type:"default",size:"small",onClick:e?d:i,children:e?"Cancel":"Close"}),C.jsx(R.Button,{type:"primary",size:"small",onClick:e?l:()=>c(),children:e?"Save":"Start"}),!e&&C.jsx(R.Button,{type:"primary",size:"small",onClick:()=>c(!0),children:"Start(N)"})]})]})}const K="RECORD_MENU_ITEM";function Re(){return{id:K,type:f.MenuItemType.SUBITEMS,icon:"RecordSingle",tooltip:"action-recorder.menu.title"}}function Ie(r){const n=r.get(exports.ActionRecorderService);return{id:D.id,title:"action-recorder.menu.record",type:f.MenuItemType.BUTTON,disabled$:n.panelOpened$}}function Oe(){return{id:$.id,title:"action-recorder.menu.replay-local",type:f.MenuItemType.BUTTON}}function Ae(){return{id:E.id,title:"action-recorder.menu.replay-local-name",type:f.MenuItemType.BUTTON}}function Pe(){return{id:F.id,title:"action-recorder.menu.replay-local-active",type:f.MenuItemType.BUTTON}}const be={[f.RibbonStartGroup.OTHERS]:{[K]:{order:10,menuItemFactory:Re,[D.id]:{order:1,menuItemFactory:Ie},[$.id]:{order:2,menuItemFactory:Oe},[E.id]:{order:3,menuItemFactory:Ae},[F.id]:{order:4,menuItemFactory:Pe}}}};var xe=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,Te=(r,n,e,t)=>{for(var o=t>1?void 0:t?Me(n,e):n,i=r.length-1,c;i>=0;i--)(c=r[i])&&(o=(t?c(n,e,o):c(o))||o);return t&&o&&xe(n,e,o),o},I=(r,n)=>(e,t)=>n(e,t,r);let M=class extends a.Disposable{constructor(r,n,e,t,o,i){super(),this._commandSrv=r,this._uiPartsSrv=n,this._menuManagerService=e,this._componentManager=t,this._actionRecorderService=o,this._injector=i,this._initCommands(),this._initUI(),this._initSheetsCommands(),this._initDocsCommands()}_initCommands(){[z,H,k,D,G,$,E,F].forEach(r=>this._commandSrv.registerCommand(r))}_initUI(){this._uiPartsSrv.registerComponent(f.BuiltInUIPart.GLOBAL,()=>a.connectInjector(_e,this._injector)),this._componentManager.register("RecordSingle",N),this._menuManagerService.mergeMenu(be)}_initSheetsCommands(){[s.CopySheetCommand,s.DeleteRangeMoveLeftCommand,s.DeleteRangeMoveUpCommand,s.DeltaColumnWidthCommand,s.DeltaRowHeightCommand,s.InsertSheetCommand,s.InsertColAfterCommand,s.InsertColBeforeCommand,s.InsertRowAfterCommand,s.InsertRowBeforeCommand,s.RemoveSheetCommand,s.SetStyleCommand,s.AddWorksheetMergeCommand,s.AddWorksheetMergeAllCommand,s.AddWorksheetMergeVerticalCommand,s.AddWorksheetMergeHorizontalCommand,s.SetFrozenCommand,s.CancelFrozenCommand,s.SetHorizontalTextAlignCommand,s.SetOverlineCommand,u.SetRangeBoldCommand,u.SetRangeFontFamilyCommand,u.SetRangeFontSizeCommand,u.SetRangeItalicCommand,u.SetRangeStrickThroughCommand,u.SetRangeSubscriptCommand,u.SetRangeSuperscriptCommand,u.SetRangeTextColorCommand,u.SetRangeUnderlineCommand,s.SetRangeValuesCommand,s.SetStrikeThroughCommand,s.SetTextColorCommand,s.SetTextRotationCommand,s.SetTextWrapCommand,s.SetVerticalTextAlignCommand,u.SheetCopyCommand,u.SheetCutCommand,u.SheetPasteBesidesBorderCommand,u.SheetPasteColWidthCommand,u.SheetPasteCommand,u.SheetPasteFormatCommand,u.SheetPasteShortKeyCommand,u.SheetPasteValueCommand,u.AutoFillCommand,u.RefillCommand,s.SetWorksheetActivateCommand,s.SetWorksheetActiveOperation,s.SetSelectionsOperation,T.SetSheetFilterRangeCommand,T.SetSheetsFilterCriteriaCommand,T.RemoveSheetFilterCommand].forEach(r=>this._actionRecorderService.registerRecordedCommand(r))}_initDocsCommands(){}};M=Te([I(0,a.ICommandService),I(1,f.IUIPartsService),I(2,f.IMenuManagerService),I(3,a.Inject(f.ComponentManager)),I(4,a.Inject(exports.ActionRecorderService)),I(5,a.Inject(a.Injector))],M);const je="action-recorder.config",V={};var Ue=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,we=(r,n,e,t)=>{for(var o=t>1?void 0:t?Ne(n,e):n,i=r.length-1,c;i>=0;i--)(c=r[i])&&(o=(t?c(n,e,o):c(o))||o);return t&&o&&Ue(n,e,o),o},q=(r,n)=>(e,t)=>n(e,t,r),U;exports.UniverActionRecorderPlugin=(U=class extends a.Plugin{constructor(n=V,e,t){super(),this._config=n,this._injector=e,this._configService=t;const{menu:o,...i}=a.merge({},V,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(je,i)}onStarting(){(this._config.replayOnly?[[exports.ActionReplayService]]:[[exports.ActionRecorderService],[exports.ActionReplayService],[M]]).forEach(e=>this._injector.add(e))}onSteady(){this._config.replayOnly||this._injector.get(M)}},g(U,"pluginName","UNIVER_ACTION_RECORDER_PLUGIN"),U);exports.UniverActionRecorderPlugin=we([q(1,a.Inject(a.Injector)),q(2,a.IConfigService)],exports.UniverActionRecorderPlugin);
|
|
1
|
+
"use strict";var G=Object.defineProperty;var Z=(r,n,e)=>n in r?G(r,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[n]=e;var S=(r,n,e)=>Z(r,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),s=require("@univerjs/sheets"),T=require("@univerjs/sheets-filter"),d=require("@univerjs/sheets-ui"),l=require("@univerjs/ui"),A=require("rxjs"),C=require("@univerjs/design"),p=require("react/jsx-runtime"),v=require("react");var g=function(){return g=Object.assign||function(r){for(var n,e=1,t=arguments.length;e<t;e++){n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o]=n[o])}return r},g.apply(this,arguments)},k=function(r,n){var e={};for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&n.indexOf(t)<0&&(e[t]=r[t]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,t=Object.getOwnPropertySymbols(r);o<t.length;o++)n.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(r,t[o])&&(e[t[o]]=r[t[o]]);return e},L=v.forwardRef(function(r,n){var e=r.icon,t=r.id,o=r.className,c=r.extend,i=k(r,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(t," ").concat(o||"").trim(),m=v.useRef("_".concat(Q()));return B(e,"".concat(t),{defIds:e.defIds,idSuffix:m.current},g({ref:n,className:u},i),c)});function B(r,n,e,t,o){return v.createElement(r.tag,g(g({key:n},K(r,e,o)),t),(Y(r,e).children||[]).map(function(c,i){return B(c,"".concat(n,"-").concat(r.tag,"-").concat(i),e,void 0,o)}))}function K(r,n,e){var t=g({},r.attrs);e!=null&&e.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=e.colorChannel1);var o=n.defIds;return!o||o.length===0||(r.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+n.idSuffix),Object.entries(t).forEach(function(c){var i=c[0],u=c[1];typeof u=="string"&&(t[i]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),t}function Y(r,n){var e,t=n.defIds;return!t||t.length===0?r:r.tag==="defs"&&(!((e=r.children)===null||e===void 0)&&e.length)?g(g({},r),{children:r.children.map(function(o){return typeof o.attrs.id=="string"&&t&&t.indexOf(o.attrs.id)>-1?g(g({},o),{attrs:g(g({},o.attrs),{id:o.attrs.id+n.idSuffix})}):o})}):r}function Q(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";var X={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"g",attrs:{fill:"currentColor",clipPath:"url(#record-single_clip0_1559_19)"},children:[{tag:"path",attrs:{d:"M7.60303 10C8.7076 10 9.60303 9.10457 9.60303 8C9.60303 6.89543 8.7076 6 7.60303 6C6.49846 6 5.60303 6.89543 5.60303 8C5.60303 9.10457 6.49846 10 7.60303 10Z"}},{tag:"path",attrs:{d:"M1.66943 5.29023C1.66941 3.85426 2.83349 2.69017 4.26946 2.69019L10.9362 2.69026C12.3192 2.69028 13.45 3.77008 13.5315 5.13259L14.5692 4.55638C15.3024 4.14929 16.2032 4.67947 16.2032 5.51809V10.4819C16.2032 11.3205 15.3024 11.8507 14.5692 11.4436L13.5315 10.8674C13.45 12.2299 12.3192 13.3097 10.9362 13.3097H4.26953C2.83361 13.3097 1.66956 12.1457 1.66953 10.7098L1.66943 5.29023ZM13.5362 9.49743L15.0032 10.312V5.68799L13.5362 6.50254V9.49743ZM4.26945 3.89019C3.49623 3.89018 2.86942 4.517 2.86943 5.29021L2.86953 10.7098C2.86955 11.483 3.49634 12.1097 4.26953 12.1097H10.9362C11.7094 12.1097 12.3362 11.4829 12.3362 10.7097V5.29026C12.3362 4.51707 11.7094 3.89027 10.9362 3.89026L4.26945 3.89019Z",fillRule:"evenodd",clipRule:"evenodd"}}]},{tag:"defs",attrs:{},children:[{tag:"clipPath",attrs:{id:"record-single_clip0_1559_19"},children:[{tag:"path",attrs:{fill:"#fff",d:"M0 0H16V16H0z",transform:"translate(.94)"}}]}]}],defIds:["record-single_clip0_1559_19"]},U=v.forwardRef(function(r,n){return v.createElement(L,Object.assign({},r,{id:"record-single",ref:n,icon:X}))});U.displayName="RecordSingle";var ee=Object.defineProperty,re=Object.getOwnPropertyDescriptor,te=(r,n,e,t)=>{for(var o=t>1?void 0:t?re(n,e):n,c=r.length-1,i;c>=0;c--)(i=r[c])&&(o=(t?i(n,e,o):i(o))||o);return t&&o&&ee(n,e,o),o},P=(r,n)=>(e,t)=>n(e,t,r);exports.ActionRecorderService=class extends a.Disposable{constructor(e,t,o,c){super();S(this,"_shouldRecordCommands",new Set);S(this,"_panelOpened$",new A.BehaviorSubject(!1));S(this,"panelOpened$",this._panelOpened$.asObservable());S(this,"_recorder",null);S(this,"_recording$",new A.BehaviorSubject(!1));S(this,"recording$",this._recording$.asObservable());S(this,"_recorded$",new A.BehaviorSubject([]));S(this,"_recordedCommands$",new A.BehaviorSubject([]));S(this,"recordedCommands$",this._recordedCommands$.asObservable());this._commandSrv=e,this._logService=t,this._localFileService=o,this._instanceService=c}get recording(){return this._recording$.getValue()}get _recorded(){return this._recorded$.getValue()}get _recordedCommands(){return this._recordedCommands$.getValue()}registerRecordedCommand(e){if(e.type===a.CommandType.MUTATION)throw new Error("[CommandRecorderService] Cannot record mutation commands.");this._shouldRecordCommands.add(e.id)}togglePanel(e){this._panelOpened$.next(e),e===!1&&this.stopRecording()}startRecording(e=!1){this._recorder=this._commandSrv.onCommandExecuted(t=>{var o,c;if(this._shouldRecordCommands.has(t.id)){const i=this._recorded,u=this._recordedCommands;let m={...t};const y=(o=this._instanceService.getFocusedUnit())==null?void 0:o.getUnitId(),{unitId:h=y,subUnitId:f}=m==null?void 0:m.params;if(e&&h&&f){const M=(c=this._instanceService.getUnit(h).getSheetBySheetId(f))==null?void 0:c.getName();m={...m,params:{...m.params,subUnitId:M}}}m.id===s.SetSelectionsOperation.id&&i.length>0&&i[i.length-1].id===s.SetSelectionsOperation.id?i[i.length-1]=m:(i.push(m),this._recorded$.next(i),m.type===a.CommandType.COMMAND&&(u.push(m),this._recordedCommands$.next(u)))}}),this._recording$.next(!0)}stopRecording(){var e;(e=this._recorder)==null||e.dispose(),this._recorder=null,this._recorded$.next([]),this._recordedCommands$.next([]),this._recording$.next(!1)}completeRecording(){const e=this._recorded.slice();this._localFileService.downloadFile(new Blob([JSON.stringify(e,null,2)]),"recorded-commands.json"),this._logService.error("Recorded commands:",e),this.stopRecording()}};exports.ActionRecorderService=te([P(0,a.ICommandService),P(1,a.ILogService),P(2,l.ILocalFileService),P(3,a.IUniverInstanceService)],exports.ActionRecorderService);const V={id:"action-recorder.command.start-recording",type:a.CommandType.COMMAND,handler:(r,n)=>(r.get(exports.ActionRecorderService).startRecording(!!(n!=null&&n.replaceId)),!0)},W={id:"action-recorder.command.complete-recording",type:a.CommandType.COMMAND,handler:r=>(r.get(exports.ActionRecorderService).completeRecording(),!0)},q={id:"action-recorder.command.stop-recording",type:a.CommandType.COMMAND,handler:r=>(r.get(exports.ActionRecorderService).completeRecording(),!0)};var ne=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,ce=(r,n,e,t)=>{for(var o=t>1?void 0:t?oe(n,e):n,c=r.length-1,i;c>=0;c--)(i=r[c])&&(o=(t?i(n,e,o):i(o))||o);return t&&o&&ne(n,e,o),o},I=(r,n)=>(e,t)=>n(e,t,r),j=(r=>(r.DEFAULT="default",r.NAME="name",r.ACTIVE="active",r))(j||{});exports.ActionReplayService=class extends a.Disposable{constructor(n,e,t,o,c){super(),this._messageService=n,this._instanceService=e,this._localFileService=t,this._logService=o,this._commandService=c}async replayLocalJSON(n="default"){const e=await this._localFileService.openFile({multiple:!1,accept:".json"});if(e.length!==1)return!1;const t=e[0];try{return this.replayCommands(JSON.parse(await t.text()),{mode:n})}catch{return this._messageService.show({type:C.MessageType.Error,content:`Failed to replay commands from local file ${t.name}.`}),!1}}async replayCommands(n,e){var c,i,u;const t=(c=this._instanceService.getFocusedUnit())==null?void 0:c.getUnitId();t||this._logService.error("[ReplayService]","no focused unit to replay commands");const{mode:o}=e||{};for(const m of n){const{id:y,params:h}=m,f=h;if(f){if(typeof f.unitId<"u"&&(f.unitId=t),o==="name"&&f.subUnitId!=="undefined"){const R=(i=this._instanceService.getFocusedUnit().getSheetBySheetName(f.subUnitId))==null?void 0:i.getSheetId();R?f.subUnitId=R:this._logService.error("[ReplayService]",`failed to find subunit by subUnitName = ${f.subUnitId}`)}if(o==="active"&&f.subUnitId!=="undefined"){const R=(u=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:u.getSheetId();R?f.subUnitId=R:this._logService.error("[ReplayService]","failed to find active subunit")}if(!await this._commandService.executeCommand(y,h))return!1}else if(!await this._commandService.executeCommand(y))return!1}return!0}async replayCommandsWithDelay(n){var t;const e=(t=this._instanceService.getFocusedUnit())==null?void 0:t.getUnitId();e||this._logService.error("[ReplayService]","no focused unit to replay commands");for(const o of n){await a.awaitTime(ie());const{id:c,params:i}=o;if(i){if(typeof i.unitId<"u"&&(i.unitId=e),!await this._commandService.executeCommand(c,i))return!1}else if(!await this._commandService.executeCommand(c))return!1}return!0}};exports.ActionReplayService=ce([I(0,l.IMessageService),I(1,a.IUniverInstanceService),I(2,l.ILocalFileService),I(3,a.ILogService),I(4,a.ICommandService)],exports.ActionReplayService);function ie(){return Math.floor(Math.random()*800)+200}const N={id:"action-recorder.command.replay-local-records",type:a.CommandType.COMMAND,handler:async r=>{const e=await r.get(exports.ActionReplayService).replayLocalJSON();return e&&r.get(l.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),e}},w={id:"action-recorder.command.replay-local-records-name",type:a.CommandType.COMMAND,handler:async r=>{const e=await r.get(exports.ActionReplayService).replayLocalJSON(j.NAME);return e&&r.get(l.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),e}},$={id:"action-recorder.command.replay-local-records-active",type:a.CommandType.COMMAND,handler:async r=>{const e=await r.get(exports.ActionReplayService).replayLocalJSON(j.ACTIVE);return e&&r.get(l.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),e}},F={id:"action-recorder.operation.open-panel",type:a.CommandType.OPERATION,handler(r){return r.get(exports.ActionRecorderService).togglePanel(!0),!0}},z={id:"action-recorder.operation.close-panel",type:a.CommandType.OPERATION,handler(r){return r.get(exports.ActionRecorderService).togglePanel(!1),!0}};function H(r){var n,e,t="";if(typeof r=="string"||typeof r=="number")t+=r;else if(typeof r=="object")if(Array.isArray(r)){var o=r.length;for(n=0;n<o;n++)r[n]&&(e=H(r[n]))&&(t&&(t+=" "),t+=e)}else for(e in r)r[e]&&(t&&(t+=" "),t+=e);return t}function ae(){for(var r,n,e=0,t="",o=arguments.length;e<o;e++)(r=arguments[e])&&(n=H(r))&&(t&&(t+=" "),t+=n);return t}const se="univer-action-recorder-panel",de="univer-action-recorder-panel-icon",le="univer-action-recorder-panel-icon-recording",me="univer-recording",ue="univer-action-recorder-panel-title",fe="univer-action-recorder-panel-actions",O={actionRecorderPanel:se,actionRecorderPanelIcon:de,actionRecorderPanelIconRecording:le,recording:me,actionRecorderPanelTitle:ue,actionRecorderPanelActions:fe};function ge(){const r=a.useDependency(exports.ActionRecorderService);return l.useObservable(r.panelOpened$)?p.jsx(Se,{}):null}function Se(){var h;const r=a.useDependency(a.ICommandService),n=a.useDependency(exports.ActionRecorderService),e=l.useObservable(n.recording$),t=l.useObservable(n.recordedCommands$),o=(h=t==null?void 0:t.length)!=null?h:0,c=v.useCallback(()=>{e||r.executeCommand(z.id)},[r,e]),i=v.useCallback(f=>{e||r.executeCommand(V.id,{replaceId:f})},[r,e]),u=v.useCallback(()=>{e&&r.executeCommand(W.id)},[r,e]),m=v.useCallback(()=>{e&&r.executeCommand(q.id)},[r,e]),y=e?o===0?"Recording...":`${o}: ${t[o-1].id}`:"Start Recording";return p.jsxs("div",{className:O.actionRecorderPanel,children:[p.jsx("div",{className:ae(O.actionRecorderPanelIcon,e?O.actionRecorderPanelIconRecording:!1),children:p.jsx(U,{})}),p.jsx("div",{className:O.actionRecorderPanelTitle,children:y}),p.jsxs("div",{className:O.actionRecorderPanelActions,children:[p.jsx(C.Button,{type:"default",size:"small",onClick:e?m:c,children:e?"Cancel":"Close"}),p.jsx(C.Button,{type:"primary",size:"small",onClick:e?u:()=>i(),children:e?"Save":"Start"}),!e&&p.jsx(C.Button,{type:"primary",size:"small",onClick:()=>i(!0),children:"Start(N)"})]})]})}const J="RECORD_MENU_ITEM";function pe(){return{id:J,type:l.MenuItemType.SUBITEMS,icon:"RecordSingle",tooltip:"action-recorder.menu.title"}}function ve(r){const n=r.get(exports.ActionRecorderService);return{id:F.id,title:"action-recorder.menu.record",type:l.MenuItemType.BUTTON,disabled$:n.panelOpened$}}function he(){return{id:N.id,title:"action-recorder.menu.replay-local",type:l.MenuItemType.BUTTON}}function Ce(){return{id:w.id,title:"action-recorder.menu.replay-local-name",type:l.MenuItemType.BUTTON}}function ye(){return{id:$.id,title:"action-recorder.menu.replay-local-active",type:l.MenuItemType.BUTTON}}const _e={[l.RibbonStartGroup.OTHERS]:{[J]:{order:10,menuItemFactory:pe,[F.id]:{order:1,menuItemFactory:ve},[N.id]:{order:2,menuItemFactory:he},[w.id]:{order:3,menuItemFactory:Ce},[$.id]:{order:4,menuItemFactory:ye}}}};var Re=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Oe=(r,n,e,t)=>{for(var o=t>1?void 0:t?Ie(n,e):n,c=r.length-1,i;c>=0;c--)(i=r[c])&&(o=(t?i(n,e,o):i(o))||o);return t&&o&&Re(n,e,o),o},_=(r,n)=>(e,t)=>n(e,t,r);let b=class extends a.Disposable{constructor(r,n,e,t,o,c){super(),this._commandSrv=r,this._uiPartsSrv=n,this._menuManagerService=e,this._componentManager=t,this._actionRecorderService=o,this._injector=c,this._initCommands(),this._initUI(),this._initSheetsCommands(),this._initDocsCommands()}_initCommands(){[V,q,W,F,z,N,w,$].forEach(r=>this._commandSrv.registerCommand(r))}_initUI(){this._uiPartsSrv.registerComponent(l.BuiltInUIPart.GLOBAL,()=>a.connectInjector(ge,this._injector)),this._componentManager.register("RecordSingle",U),this._menuManagerService.mergeMenu(_e)}_initSheetsCommands(){[s.CopySheetCommand,s.DeleteRangeMoveLeftCommand,s.DeleteRangeMoveUpCommand,s.DeltaColumnWidthCommand,s.DeltaRowHeightCommand,s.InsertSheetCommand,s.InsertColAfterCommand,s.InsertColBeforeCommand,s.InsertRowAfterCommand,s.InsertRowBeforeCommand,s.RemoveSheetCommand,s.SetStyleCommand,s.AddWorksheetMergeCommand,s.AddWorksheetMergeAllCommand,s.AddWorksheetMergeVerticalCommand,s.AddWorksheetMergeHorizontalCommand,s.SetFrozenCommand,s.CancelFrozenCommand,s.SetHorizontalTextAlignCommand,s.SetOverlineCommand,d.SetRangeBoldCommand,d.SetRangeFontFamilyCommand,d.SetRangeFontSizeCommand,d.SetRangeItalicCommand,d.SetRangeStrickThroughCommand,d.SetRangeSubscriptCommand,d.SetRangeSuperscriptCommand,d.SetRangeTextColorCommand,d.SetRangeUnderlineCommand,s.SetRangeValuesCommand,s.SetStrikeThroughCommand,s.SetTextColorCommand,s.SetTextRotationCommand,s.SetTextWrapCommand,s.SetVerticalTextAlignCommand,d.SheetCopyCommand,d.SheetCutCommand,d.SheetPasteBesidesBorderCommand,d.SheetPasteColWidthCommand,d.SheetPasteCommand,d.SheetPasteFormatCommand,d.SheetPasteShortKeyCommand,d.SheetPasteValueCommand,d.AutoFillCommand,d.RefillCommand,s.SetWorksheetActivateCommand,s.SetWorksheetActiveOperation,s.SetSelectionsOperation,T.SetSheetFilterRangeCommand,T.SetSheetsFilterCriteriaCommand,T.RemoveSheetFilterCommand].forEach(r=>this._actionRecorderService.registerRecordedCommand(r))}_initDocsCommands(){}};b=Oe([_(0,a.ICommandService),_(1,l.IUIPartsService),_(2,l.IMenuManagerService),_(3,a.Inject(l.ComponentManager)),_(4,a.Inject(exports.ActionRecorderService)),_(5,a.Inject(a.Injector))],b);const Ae="action-recorder.config",D={};var Pe=Object.defineProperty,be=Object.getOwnPropertyDescriptor,Me=(r,n,e,t)=>{for(var o=t>1?void 0:t?be(n,e):n,c=r.length-1,i;c>=0;c--)(i=r[c])&&(o=(t?i(n,e,o):i(o))||o);return t&&o&&Pe(n,e,o),o},E=(r,n)=>(e,t)=>n(e,t,r),x;exports.UniverActionRecorderPlugin=(x=class extends a.Plugin{constructor(n=D,e,t){super(),this._config=n,this._injector=e,this._configService=t;const{menu:o,...c}=a.merge({},D,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Ae,c)}onStarting(){(this._config.replayOnly?[[exports.ActionReplayService]]:[[exports.ActionRecorderService],[exports.ActionReplayService],[b]]).forEach(e=>this._injector.add(e))}onSteady(){this._config.replayOnly||this._injector.get(b)}},S(x,"pluginName","UNIVER_ACTION_RECORDER_PLUGIN"),x);exports.UniverActionRecorderPlugin=Me([E(1,a.Inject(a.Injector)),E(2,a.IConfigService)],exports.UniverActionRecorderPlugin);
|
package/lib/es/index.js
CHANGED
|
@@ -1,83 +1,84 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Disposable as
|
|
5
|
-
import { SetSelectionsOperation as
|
|
6
|
-
import { SetSheetFilterRangeCommand as
|
|
7
|
-
import { SetRangeBoldCommand as
|
|
8
|
-
import { ILocalFileService as
|
|
9
|
-
import { BehaviorSubject as
|
|
10
|
-
import { MessageType as U, Button as
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
var ae = Object.defineProperty;
|
|
2
|
+
var de = (e, t, r) => t in e ? ae(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var m = (e, t, r) => de(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { Disposable as j, CommandType as u, ICommandService as A, ILogService as Z, IUniverInstanceService as K, awaitTime as se, useDependency as $, Inject as b, Injector as Y, connectInjector as le, Plugin as me, merge as ue, IConfigService as fe } from "@univerjs/core";
|
|
5
|
+
import { SetSelectionsOperation as T, CopySheetCommand as ge, DeleteRangeMoveLeftCommand as he, DeleteRangeMoveUpCommand as pe, DeltaColumnWidthCommand as Se, DeltaRowHeightCommand as ve, InsertSheetCommand as Ce, InsertColAfterCommand as _e, InsertColBeforeCommand as ye, InsertRowAfterCommand as Re, InsertRowBeforeCommand as Ie, RemoveSheetCommand as Oe, SetStyleCommand as Pe, AddWorksheetMergeCommand as be, AddWorksheetMergeAllCommand as Me, AddWorksheetMergeVerticalCommand as Ae, AddWorksheetMergeHorizontalCommand as Ne, SetFrozenCommand as Ue, CancelFrozenCommand as xe, SetHorizontalTextAlignCommand as we, SetOverlineCommand as $e, SetRangeValuesCommand as Te, SetStrikeThroughCommand as Fe, SetTextColorCommand as je, SetTextRotationCommand as De, SetTextWrapCommand as Ee, SetVerticalTextAlignCommand as Le, SetWorksheetActivateCommand as Be, SetWorksheetActiveOperation as Ve } from "@univerjs/sheets";
|
|
6
|
+
import { SetSheetFilterRangeCommand as We, SetSheetsFilterCriteriaCommand as ze, RemoveSheetFilterCommand as He } from "@univerjs/sheets-filter";
|
|
7
|
+
import { SetRangeBoldCommand as Je, SetRangeFontFamilyCommand as Ge, SetRangeFontSizeCommand as Ze, SetRangeItalicCommand as Ke, SetRangeStrickThroughCommand as Ye, SetRangeSubscriptCommand as ke, SetRangeSuperscriptCommand as qe, SetRangeTextColorCommand as Qe, SetRangeUnderlineCommand as Xe, SheetCopyCommand as et, SheetCutCommand as tt, SheetPasteBesidesBorderCommand as rt, SheetPasteColWidthCommand as nt, SheetPasteCommand as ot, SheetPasteFormatCommand as it, SheetPasteShortKeyCommand as ct, SheetPasteValueCommand as at, AutoFillCommand as dt, RefillCommand as st } from "@univerjs/sheets-ui";
|
|
8
|
+
import { ILocalFileService as k, IMessageService as N, useObservable as F, RibbonStartGroup as lt, MenuItemType as R, ComponentManager as mt, IUIPartsService as ut, IMenuManagerService as ft, BuiltInUIPart as gt } from "@univerjs/ui";
|
|
9
|
+
import { BehaviorSubject as I } from "rxjs";
|
|
10
|
+
import { MessageType as U, Button as x } from "@univerjs/design";
|
|
11
|
+
import { jsx as h, jsxs as z } from "react/jsx-runtime";
|
|
12
|
+
import { forwardRef as q, useRef as ht, createElement as Q, useCallback as O } from "react";
|
|
13
|
+
var s = function() {
|
|
14
|
+
return s = Object.assign || function(e) {
|
|
15
|
+
for (var t, r = 1, n = arguments.length; r < n; r++) {
|
|
16
|
+
t = arguments[r];
|
|
17
|
+
for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
|
|
17
18
|
}
|
|
18
19
|
return e;
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
var
|
|
22
|
-
for (var n in e) Object.prototype.hasOwnProperty.call(e, n) &&
|
|
20
|
+
}, s.apply(this, arguments);
|
|
21
|
+
}, pt = function(e, t) {
|
|
22
|
+
var r = {};
|
|
23
|
+
for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
|
|
23
24
|
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
24
25
|
for (var o = 0, n = Object.getOwnPropertySymbols(e); o < n.length; o++)
|
|
25
|
-
|
|
26
|
-
return
|
|
27
|
-
},
|
|
28
|
-
var
|
|
29
|
-
return
|
|
26
|
+
t.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[o]) && (r[n[o]] = e[n[o]]);
|
|
27
|
+
return r;
|
|
28
|
+
}, X = q(function(e, t) {
|
|
29
|
+
var r = e.icon, n = e.id, o = e.className, i = e.extend, c = pt(e, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(n, " ").concat(o || "").trim(), f = ht("_".concat(Ct()));
|
|
30
|
+
return ee(r, "".concat(n), { defIds: r.defIds, idSuffix: f.current }, s({ ref: t, className: a }, c), i);
|
|
30
31
|
});
|
|
31
|
-
function
|
|
32
|
-
return
|
|
33
|
-
return
|
|
32
|
+
function ee(e, t, r, n, o) {
|
|
33
|
+
return Q(e.tag, s(s({ key: t }, St(e, r, o)), n), (vt(e, r).children || []).map(function(i, c) {
|
|
34
|
+
return ee(i, "".concat(t, "-").concat(e.tag, "-").concat(c), r, void 0, o);
|
|
34
35
|
}));
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
-
var n =
|
|
38
|
-
|
|
39
|
-
var o =
|
|
40
|
-
return !o || o.length === 0 || (e.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] +
|
|
37
|
+
function St(e, t, r) {
|
|
38
|
+
var n = s({}, e.attrs);
|
|
39
|
+
r != null && r.colorChannel1 && n.fill === "colorChannel1" && (n.fill = r.colorChannel1);
|
|
40
|
+
var o = t.defIds;
|
|
41
|
+
return !o || o.length === 0 || (e.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + t.idSuffix), Object.entries(n).forEach(function(i) {
|
|
41
42
|
var c = i[0], a = i[1];
|
|
42
|
-
typeof a == "string" && (n[c] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(
|
|
43
|
+
typeof a == "string" && (n[c] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
|
|
43
44
|
})), n;
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
-
var
|
|
47
|
-
return !n || n.length === 0 ? e : e.tag === "defs" && (!((
|
|
48
|
-
return typeof o.attrs.id == "string" && n && n.indexOf(o.attrs.id) > -1 ?
|
|
46
|
+
function vt(e, t) {
|
|
47
|
+
var r, n = t.defIds;
|
|
48
|
+
return !n || n.length === 0 ? e : e.tag === "defs" && (!((r = e.children) === null || r === void 0) && r.length) ? s(s({}, e), { children: e.children.map(function(o) {
|
|
49
|
+
return typeof o.attrs.id == "string" && n && n.indexOf(o.attrs.id) > -1 ? s(s({}, o), { attrs: s(s({}, o.attrs), { id: o.attrs.id + t.idSuffix }) }) : o;
|
|
49
50
|
}) }) : e;
|
|
50
51
|
}
|
|
51
|
-
function
|
|
52
|
+
function Ct() {
|
|
52
53
|
return Math.random().toString(36).substring(2, 8);
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
-
var
|
|
56
|
-
return
|
|
55
|
+
X.displayName = "UniverIcon";
|
|
56
|
+
var _t = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "g", attrs: { fill: "currentColor", clipPath: "url(#record-single_clip0_1559_19)" }, children: [{ tag: "path", attrs: { d: "M7.60303 10C8.7076 10 9.60303 9.10457 9.60303 8C9.60303 6.89543 8.7076 6 7.60303 6C6.49846 6 5.60303 6.89543 5.60303 8C5.60303 9.10457 6.49846 10 7.60303 10Z" } }, { tag: "path", attrs: { d: "M1.66943 5.29023C1.66941 3.85426 2.83349 2.69017 4.26946 2.69019L10.9362 2.69026C12.3192 2.69028 13.45 3.77008 13.5315 5.13259L14.5692 4.55638C15.3024 4.14929 16.2032 4.67947 16.2032 5.51809V10.4819C16.2032 11.3205 15.3024 11.8507 14.5692 11.4436L13.5315 10.8674C13.45 12.2299 12.3192 13.3097 10.9362 13.3097H4.26953C2.83361 13.3097 1.66956 12.1457 1.66953 10.7098L1.66943 5.29023ZM13.5362 9.49743L15.0032 10.312V5.68799L13.5362 6.50254V9.49743ZM4.26945 3.89019C3.49623 3.89018 2.86942 4.517 2.86943 5.29021L2.86953 10.7098C2.86955 11.483 3.49634 12.1097 4.26953 12.1097H10.9362C11.7094 12.1097 12.3362 11.4829 12.3362 10.7097V5.29026C12.3362 4.51707 11.7094 3.89027 10.9362 3.89026L4.26945 3.89019Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, { tag: "defs", attrs: {}, children: [{ tag: "clipPath", attrs: { id: "record-single_clip0_1559_19" }, children: [{ tag: "path", attrs: { fill: "#fff", d: "M0 0H16V16H0z", transform: "translate(.94)" } }] }] }], defIds: ["record-single_clip0_1559_19"] }, D = q(function(e, t) {
|
|
57
|
+
return Q(X, Object.assign({}, e, {
|
|
57
58
|
id: "record-single",
|
|
58
|
-
ref:
|
|
59
|
-
icon:
|
|
59
|
+
ref: t,
|
|
60
|
+
icon: _t
|
|
60
61
|
}));
|
|
61
62
|
});
|
|
62
|
-
|
|
63
|
-
var
|
|
64
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
65
|
-
(c = e[i]) && (o = (n ? c(
|
|
66
|
-
return n && o &&
|
|
67
|
-
},
|
|
68
|
-
let
|
|
69
|
-
constructor(
|
|
63
|
+
D.displayName = "RecordSingle";
|
|
64
|
+
var yt = Object.defineProperty, Rt = Object.getOwnPropertyDescriptor, It = (e, t, r, n) => {
|
|
65
|
+
for (var o = n > 1 ? void 0 : n ? Rt(t, r) : t, i = e.length - 1, c; i >= 0; i--)
|
|
66
|
+
(c = e[i]) && (o = (n ? c(t, r, o) : c(o)) || o);
|
|
67
|
+
return n && o && yt(t, r, o), o;
|
|
68
|
+
}, P = (e, t) => (r, n) => t(r, n, e);
|
|
69
|
+
let l = class extends j {
|
|
70
|
+
constructor(t, r, n, o) {
|
|
70
71
|
super();
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
this._commandSrv =
|
|
72
|
+
m(this, "_shouldRecordCommands", /* @__PURE__ */ new Set());
|
|
73
|
+
m(this, "_panelOpened$", new I(!1));
|
|
74
|
+
m(this, "panelOpened$", this._panelOpened$.asObservable());
|
|
75
|
+
m(this, "_recorder", null);
|
|
76
|
+
m(this, "_recording$", new I(!1));
|
|
77
|
+
m(this, "recording$", this._recording$.asObservable());
|
|
78
|
+
m(this, "_recorded$", new I([]));
|
|
79
|
+
m(this, "_recordedCommands$", new I([]));
|
|
80
|
+
m(this, "recordedCommands$", this._recordedCommands$.asObservable());
|
|
81
|
+
this._commandSrv = t, this._logService = r, this._localFileService = n, this._instanceService = o;
|
|
81
82
|
}
|
|
82
83
|
get recording() {
|
|
83
84
|
return this._recording$.getValue();
|
|
@@ -88,84 +89,84 @@ let m = class extends D {
|
|
|
88
89
|
get _recordedCommands() {
|
|
89
90
|
return this._recordedCommands$.getValue();
|
|
90
91
|
}
|
|
91
|
-
registerRecordedCommand(
|
|
92
|
-
if (
|
|
93
|
-
this._shouldRecordCommands.add(
|
|
92
|
+
registerRecordedCommand(t) {
|
|
93
|
+
if (t.type === u.MUTATION) throw new Error("[CommandRecorderService] Cannot record mutation commands.");
|
|
94
|
+
this._shouldRecordCommands.add(t.id);
|
|
94
95
|
}
|
|
95
|
-
togglePanel(
|
|
96
|
-
this._panelOpened$.next(
|
|
96
|
+
togglePanel(t) {
|
|
97
|
+
this._panelOpened$.next(t), t === !1 && this.stopRecording();
|
|
97
98
|
}
|
|
98
|
-
startRecording(
|
|
99
|
-
this._recorder = this._commandSrv.onCommandExecuted((
|
|
99
|
+
startRecording(t = !1) {
|
|
100
|
+
this._recorder = this._commandSrv.onCommandExecuted((r) => {
|
|
100
101
|
var n, o;
|
|
101
|
-
if (this._shouldRecordCommands.has(
|
|
102
|
+
if (this._shouldRecordCommands.has(r.id)) {
|
|
102
103
|
const i = this._recorded, c = this._recordedCommands;
|
|
103
|
-
let a = { ...
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
const
|
|
104
|
+
let a = { ...r };
|
|
105
|
+
const f = (n = this._instanceService.getFocusedUnit()) == null ? void 0 : n.getUnitId(), { unitId: g = f, subUnitId: d } = a == null ? void 0 : a.params;
|
|
106
|
+
if (t && g && d) {
|
|
107
|
+
const v = (o = this._instanceService.getUnit(g).getSheetBySheetId(d)) == null ? void 0 : o.getName();
|
|
107
108
|
a = {
|
|
108
109
|
...a,
|
|
109
110
|
params: {
|
|
110
111
|
...a.params,
|
|
111
|
-
subUnitId:
|
|
112
|
+
subUnitId: v
|
|
112
113
|
}
|
|
113
114
|
};
|
|
114
115
|
}
|
|
115
|
-
a.id ===
|
|
116
|
+
a.id === T.id && i.length > 0 && i[i.length - 1].id === T.id ? i[i.length - 1] = a : (i.push(a), this._recorded$.next(i), a.type === u.COMMAND && (c.push(a), this._recordedCommands$.next(c)));
|
|
116
117
|
}
|
|
117
118
|
}), this._recording$.next(!0);
|
|
118
119
|
}
|
|
119
120
|
stopRecording() {
|
|
120
|
-
var
|
|
121
|
-
(
|
|
121
|
+
var t;
|
|
122
|
+
(t = this._recorder) == null || t.dispose(), this._recorder = null, this._recorded$.next([]), this._recordedCommands$.next([]), this._recording$.next(!1);
|
|
122
123
|
}
|
|
123
124
|
completeRecording() {
|
|
124
|
-
const
|
|
125
|
-
this._localFileService.downloadFile(new Blob([JSON.stringify(
|
|
125
|
+
const t = this._recorded.slice();
|
|
126
|
+
this._localFileService.downloadFile(new Blob([JSON.stringify(t, null, 2)]), "recorded-commands.json"), this._logService.error("Recorded commands:", t), this.stopRecording();
|
|
126
127
|
}
|
|
127
128
|
};
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
],
|
|
134
|
-
const
|
|
129
|
+
l = It([
|
|
130
|
+
P(0, A),
|
|
131
|
+
P(1, Z),
|
|
132
|
+
P(2, k),
|
|
133
|
+
P(3, K)
|
|
134
|
+
], l);
|
|
135
|
+
const te = {
|
|
135
136
|
id: "action-recorder.command.start-recording",
|
|
136
|
-
type:
|
|
137
|
-
handler: (e,
|
|
138
|
-
},
|
|
137
|
+
type: u.COMMAND,
|
|
138
|
+
handler: (e, t) => (e.get(l).startRecording(!!(t != null && t.replaceId)), !0)
|
|
139
|
+
}, re = {
|
|
139
140
|
id: "action-recorder.command.complete-recording",
|
|
140
|
-
type:
|
|
141
|
-
handler: (e) => (e.get(
|
|
142
|
-
},
|
|
141
|
+
type: u.COMMAND,
|
|
142
|
+
handler: (e) => (e.get(l).completeRecording(), !0)
|
|
143
|
+
}, ne = {
|
|
143
144
|
id: "action-recorder.command.stop-recording",
|
|
144
|
-
type:
|
|
145
|
-
handler: (e) => (e.get(
|
|
145
|
+
type: u.COMMAND,
|
|
146
|
+
handler: (e) => (e.get(l).completeRecording(), !0)
|
|
146
147
|
};
|
|
147
|
-
var
|
|
148
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
149
|
-
(c = e[i]) && (o = (n ? c(
|
|
150
|
-
return n && o &&
|
|
151
|
-
},
|
|
152
|
-
let
|
|
153
|
-
constructor(e,
|
|
154
|
-
super(), this._messageService = e, this._instanceService =
|
|
148
|
+
var Ot = Object.defineProperty, Pt = Object.getOwnPropertyDescriptor, bt = (e, t, r, n) => {
|
|
149
|
+
for (var o = n > 1 ? void 0 : n ? Pt(t, r) : t, i = e.length - 1, c; i >= 0; i--)
|
|
150
|
+
(c = e[i]) && (o = (n ? c(t, r, o) : c(o)) || o);
|
|
151
|
+
return n && o && Ot(t, r, o), o;
|
|
152
|
+
}, _ = (e, t) => (r, n) => t(r, n, e), E = /* @__PURE__ */ ((e) => (e.DEFAULT = "default", e.NAME = "name", e.ACTIVE = "active", e))(E || {});
|
|
153
|
+
let p = class extends j {
|
|
154
|
+
constructor(e, t, r, n, o) {
|
|
155
|
+
super(), this._messageService = e, this._instanceService = t, this._localFileService = r, this._logService = n, this._commandService = o;
|
|
155
156
|
}
|
|
156
157
|
/**
|
|
157
158
|
* Read a local file and try to replay commands in this JSON.
|
|
158
159
|
*/
|
|
159
160
|
async replayLocalJSON(e = "default") {
|
|
160
|
-
const
|
|
161
|
-
if (
|
|
162
|
-
const
|
|
161
|
+
const t = await this._localFileService.openFile({ multiple: !1, accept: ".json" });
|
|
162
|
+
if (t.length !== 1) return !1;
|
|
163
|
+
const r = t[0];
|
|
163
164
|
try {
|
|
164
|
-
return this.replayCommands(JSON.parse(await
|
|
165
|
+
return this.replayCommands(JSON.parse(await r.text()), { mode: e });
|
|
165
166
|
} catch {
|
|
166
167
|
return this._messageService.show({
|
|
167
168
|
type: U.Error,
|
|
168
|
-
content: `Failed to replay commands from local file ${
|
|
169
|
+
content: `Failed to replay commands from local file ${r.name}.`
|
|
169
170
|
}), !1;
|
|
170
171
|
}
|
|
171
172
|
}
|
|
@@ -174,24 +175,24 @@ let _ = class extends D {
|
|
|
174
175
|
* @param commands - The commands to replay.
|
|
175
176
|
* @returns If the replay is successful.
|
|
176
177
|
*/
|
|
177
|
-
async replayCommands(e,
|
|
178
|
+
async replayCommands(e, t) {
|
|
178
179
|
var o, i, c;
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
const { mode: n } =
|
|
180
|
+
const r = (o = this._instanceService.getFocusedUnit()) == null ? void 0 : o.getUnitId();
|
|
181
|
+
r || this._logService.error("[ReplayService]", "no focused unit to replay commands");
|
|
182
|
+
const { mode: n } = t || {};
|
|
182
183
|
for (const a of e) {
|
|
183
|
-
const { id:
|
|
184
|
-
if (
|
|
185
|
-
if (typeof
|
|
186
|
-
const
|
|
187
|
-
|
|
184
|
+
const { id: f, params: g } = a, d = g;
|
|
185
|
+
if (d) {
|
|
186
|
+
if (typeof d.unitId < "u" && (d.unitId = r), n === "name" && d.subUnitId !== "undefined") {
|
|
187
|
+
const C = (i = this._instanceService.getFocusedUnit().getSheetBySheetName(d.subUnitId)) == null ? void 0 : i.getSheetId();
|
|
188
|
+
C ? d.subUnitId = C : this._logService.error("[ReplayService]", `failed to find subunit by subUnitName = ${d.subUnitId}`);
|
|
188
189
|
}
|
|
189
|
-
if (n === "active" &&
|
|
190
|
-
const
|
|
191
|
-
|
|
190
|
+
if (n === "active" && d.subUnitId !== "undefined") {
|
|
191
|
+
const C = (c = this._instanceService.getFocusedUnit().getActiveSheet()) == null ? void 0 : c.getSheetId();
|
|
192
|
+
C ? d.subUnitId = C : this._logService.error("[ReplayService]", "failed to find active subunit");
|
|
192
193
|
}
|
|
193
|
-
if (!await this._commandService.executeCommand(
|
|
194
|
-
} else if (!await this._commandService.executeCommand(
|
|
194
|
+
if (!await this._commandService.executeCommand(f, g)) return !1;
|
|
195
|
+
} else if (!await this._commandService.executeCommand(f)) return !1;
|
|
195
196
|
}
|
|
196
197
|
return !0;
|
|
197
198
|
}
|
|
@@ -200,351 +201,322 @@ let _ = class extends D {
|
|
|
200
201
|
* @param commands - The commands to replay.
|
|
201
202
|
*/
|
|
202
203
|
async replayCommandsWithDelay(e) {
|
|
203
|
-
var
|
|
204
|
-
const
|
|
205
|
-
|
|
204
|
+
var r;
|
|
205
|
+
const t = (r = this._instanceService.getFocusedUnit()) == null ? void 0 : r.getUnitId();
|
|
206
|
+
t || this._logService.error("[ReplayService]", "no focused unit to replay commands");
|
|
206
207
|
for (const n of e) {
|
|
207
|
-
await
|
|
208
|
+
await se(Mt());
|
|
208
209
|
const { id: o, params: i } = n;
|
|
209
210
|
if (i) {
|
|
210
|
-
if (typeof i.unitId < "u" && (i.unitId =
|
|
211
|
+
if (typeof i.unitId < "u" && (i.unitId = t), !await this._commandService.executeCommand(o, i)) return !1;
|
|
211
212
|
} else if (!await this._commandService.executeCommand(o)) return !1;
|
|
212
213
|
}
|
|
213
214
|
return !0;
|
|
214
215
|
}
|
|
215
216
|
};
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
],
|
|
223
|
-
function
|
|
217
|
+
p = bt([
|
|
218
|
+
_(0, N),
|
|
219
|
+
_(1, K),
|
|
220
|
+
_(2, k),
|
|
221
|
+
_(3, Z),
|
|
222
|
+
_(4, A)
|
|
223
|
+
], p);
|
|
224
|
+
function Mt() {
|
|
224
225
|
return Math.floor(Math.random() * 800) + 200;
|
|
225
226
|
}
|
|
226
|
-
const
|
|
227
|
+
const L = {
|
|
227
228
|
id: "action-recorder.command.replay-local-records",
|
|
228
|
-
type:
|
|
229
|
+
type: u.COMMAND,
|
|
229
230
|
handler: async (e) => {
|
|
230
|
-
const
|
|
231
|
-
return
|
|
231
|
+
const r = await e.get(p).replayLocalJSON();
|
|
232
|
+
return r && e.get(N).show({
|
|
232
233
|
type: U.Success,
|
|
233
234
|
content: "Successfully replayed local records"
|
|
234
|
-
}),
|
|
235
|
+
}), r;
|
|
235
236
|
}
|
|
236
|
-
},
|
|
237
|
+
}, B = {
|
|
237
238
|
id: "action-recorder.command.replay-local-records-name",
|
|
238
|
-
type:
|
|
239
|
+
type: u.COMMAND,
|
|
239
240
|
handler: async (e) => {
|
|
240
|
-
const
|
|
241
|
-
return
|
|
241
|
+
const r = await e.get(p).replayLocalJSON(E.NAME);
|
|
242
|
+
return r && e.get(N).show({
|
|
242
243
|
type: U.Success,
|
|
243
244
|
content: "Successfully replayed local records"
|
|
244
|
-
}),
|
|
245
|
+
}), r;
|
|
245
246
|
}
|
|
246
|
-
},
|
|
247
|
+
}, V = {
|
|
247
248
|
id: "action-recorder.command.replay-local-records-active",
|
|
248
|
-
type:
|
|
249
|
+
type: u.COMMAND,
|
|
249
250
|
handler: async (e) => {
|
|
250
|
-
const
|
|
251
|
-
return
|
|
251
|
+
const r = await e.get(p).replayLocalJSON(E.ACTIVE);
|
|
252
|
+
return r && e.get(N).show({
|
|
252
253
|
type: U.Success,
|
|
253
254
|
content: "Successfully replayed local records"
|
|
254
|
-
}),
|
|
255
|
+
}), r;
|
|
255
256
|
}
|
|
256
|
-
},
|
|
257
|
+
}, W = {
|
|
257
258
|
id: "action-recorder.operation.open-panel",
|
|
258
|
-
type:
|
|
259
|
+
type: u.OPERATION,
|
|
259
260
|
handler(e) {
|
|
260
|
-
return e.get(
|
|
261
|
+
return e.get(l).togglePanel(!0), !0;
|
|
261
262
|
}
|
|
262
|
-
},
|
|
263
|
+
}, oe = {
|
|
263
264
|
id: "action-recorder.operation.close-panel",
|
|
264
|
-
type:
|
|
265
|
+
type: u.OPERATION,
|
|
265
266
|
handler(e) {
|
|
266
|
-
return e.get(
|
|
267
|
+
return e.get(l).togglePanel(!1), !0;
|
|
267
268
|
}
|
|
268
269
|
};
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
* @license React
|
|
272
|
-
* react-jsx-runtime.production.min.js
|
|
273
|
-
*
|
|
274
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
275
|
-
*
|
|
276
|
-
* This source code is licensed under the MIT license found in the
|
|
277
|
-
* LICENSE file in the root directory of this source tree.
|
|
278
|
-
*/
|
|
279
|
-
var q;
|
|
280
|
-
function $r() {
|
|
281
|
-
if (q) return y;
|
|
282
|
-
q = 1;
|
|
283
|
-
var e = vr, r = Symbol.for("react.element"), t = Symbol.for("react.fragment"), n = Object.prototype.hasOwnProperty, o = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
284
|
-
function c(a, d, f) {
|
|
285
|
-
var s, p = {}, h = null, H = null;
|
|
286
|
-
f !== void 0 && (h = "" + f), d.key !== void 0 && (h = "" + d.key), d.ref !== void 0 && (H = d.ref);
|
|
287
|
-
for (s in d) n.call(d, s) && !i.hasOwnProperty(s) && (p[s] = d[s]);
|
|
288
|
-
if (a && a.defaultProps) for (s in d = a.defaultProps, d) p[s] === void 0 && (p[s] = d[s]);
|
|
289
|
-
return { $$typeof: r, type: a, key: h, ref: H, props: p, _owner: o.current };
|
|
290
|
-
}
|
|
291
|
-
return y.Fragment = t, y.jsx = c, y.jsxs = c, y;
|
|
292
|
-
}
|
|
293
|
-
var k;
|
|
294
|
-
function jr() {
|
|
295
|
-
return k || (k = 1, $.exports = $r()), $.exports;
|
|
296
|
-
}
|
|
297
|
-
var S = jr();
|
|
298
|
-
function de(e) {
|
|
299
|
-
var r, t, n = "";
|
|
270
|
+
function ie(e) {
|
|
271
|
+
var t, r, n = "";
|
|
300
272
|
if (typeof e == "string" || typeof e == "number") n += e;
|
|
301
273
|
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
302
274
|
var o = e.length;
|
|
303
|
-
for (
|
|
304
|
-
} else for (
|
|
275
|
+
for (t = 0; t < o; t++) e[t] && (r = ie(e[t])) && (n && (n += " "), n += r);
|
|
276
|
+
} else for (r in e) e[r] && (n && (n += " "), n += r);
|
|
305
277
|
return n;
|
|
306
278
|
}
|
|
307
|
-
function
|
|
308
|
-
for (var e,
|
|
279
|
+
function At() {
|
|
280
|
+
for (var e, t, r = 0, n = "", o = arguments.length; r < o; r++) (e = arguments[r]) && (t = ie(e)) && (n && (n += " "), n += t);
|
|
309
281
|
return n;
|
|
310
282
|
}
|
|
311
|
-
const
|
|
312
|
-
actionRecorderPanel:
|
|
313
|
-
actionRecorderPanelIcon:
|
|
314
|
-
actionRecorderPanelIconRecording:
|
|
315
|
-
recording:
|
|
316
|
-
actionRecorderPanelTitle:
|
|
317
|
-
actionRecorderPanelActions:
|
|
283
|
+
const Nt = "univer-action-recorder-panel", Ut = "univer-action-recorder-panel-icon", xt = "univer-action-recorder-panel-icon-recording", wt = "univer-recording", $t = "univer-action-recorder-panel-title", Tt = "univer-action-recorder-panel-actions", y = {
|
|
284
|
+
actionRecorderPanel: Nt,
|
|
285
|
+
actionRecorderPanelIcon: Ut,
|
|
286
|
+
actionRecorderPanelIconRecording: xt,
|
|
287
|
+
recording: wt,
|
|
288
|
+
actionRecorderPanelTitle: $t,
|
|
289
|
+
actionRecorderPanelActions: Tt
|
|
318
290
|
};
|
|
319
|
-
function
|
|
320
|
-
const e =
|
|
321
|
-
return F(e.panelOpened$) ? /* @__PURE__ */
|
|
291
|
+
function Ft() {
|
|
292
|
+
const e = $(l);
|
|
293
|
+
return F(e.panelOpened$) ? /* @__PURE__ */ h(jt, {}) : null;
|
|
322
294
|
}
|
|
323
|
-
function
|
|
324
|
-
var
|
|
325
|
-
const e =
|
|
326
|
-
|
|
327
|
-
}, [e,
|
|
328
|
-
|
|
329
|
-
}, [e,
|
|
330
|
-
|
|
331
|
-
}, [e,
|
|
332
|
-
|
|
333
|
-
}, [e,
|
|
334
|
-
return /* @__PURE__ */
|
|
335
|
-
/* @__PURE__ */
|
|
336
|
-
/* @__PURE__ */
|
|
337
|
-
/* @__PURE__ */
|
|
338
|
-
/* @__PURE__ */
|
|
339
|
-
/* @__PURE__ */
|
|
340
|
-
!
|
|
295
|
+
function jt() {
|
|
296
|
+
var d;
|
|
297
|
+
const e = $(A), t = $(l), r = F(t.recording$), n = F(t.recordedCommands$), o = (d = n == null ? void 0 : n.length) != null ? d : 0, i = O(() => {
|
|
298
|
+
r || e.executeCommand(oe.id);
|
|
299
|
+
}, [e, r]), c = O((v) => {
|
|
300
|
+
r || e.executeCommand(te.id, { replaceId: v });
|
|
301
|
+
}, [e, r]), a = O(() => {
|
|
302
|
+
r && e.executeCommand(re.id);
|
|
303
|
+
}, [e, r]), f = O(() => {
|
|
304
|
+
r && e.executeCommand(ne.id);
|
|
305
|
+
}, [e, r]), g = r ? o === 0 ? "Recording..." : `${o}: ${n[o - 1].id}` : "Start Recording";
|
|
306
|
+
return /* @__PURE__ */ z("div", { className: y.actionRecorderPanel, children: [
|
|
307
|
+
/* @__PURE__ */ h("div", { className: At(y.actionRecorderPanelIcon, r ? y.actionRecorderPanelIconRecording : !1), children: /* @__PURE__ */ h(D, {}) }),
|
|
308
|
+
/* @__PURE__ */ h("div", { className: y.actionRecorderPanelTitle, children: g }),
|
|
309
|
+
/* @__PURE__ */ z("div", { className: y.actionRecorderPanelActions, children: [
|
|
310
|
+
/* @__PURE__ */ h(x, { type: "default", size: "small", onClick: r ? f : i, children: r ? "Cancel" : "Close" }),
|
|
311
|
+
/* @__PURE__ */ h(x, { type: "primary", size: "small", onClick: r ? a : () => c(), children: r ? "Save" : "Start" }),
|
|
312
|
+
!r && /* @__PURE__ */ h(x, { type: "primary", size: "small", onClick: () => c(!0), children: "Start(N)" })
|
|
341
313
|
] })
|
|
342
314
|
] });
|
|
343
315
|
}
|
|
344
|
-
const
|
|
345
|
-
function
|
|
316
|
+
const ce = "RECORD_MENU_ITEM";
|
|
317
|
+
function Dt() {
|
|
346
318
|
return {
|
|
347
|
-
id:
|
|
348
|
-
type:
|
|
319
|
+
id: ce,
|
|
320
|
+
type: R.SUBITEMS,
|
|
349
321
|
icon: "RecordSingle",
|
|
350
322
|
tooltip: "action-recorder.menu.title"
|
|
351
323
|
};
|
|
352
324
|
}
|
|
353
|
-
function
|
|
354
|
-
const
|
|
325
|
+
function Et(e) {
|
|
326
|
+
const t = e.get(l);
|
|
355
327
|
return {
|
|
356
|
-
id:
|
|
328
|
+
id: W.id,
|
|
357
329
|
title: "action-recorder.menu.record",
|
|
358
|
-
type:
|
|
359
|
-
disabled$:
|
|
330
|
+
type: R.BUTTON,
|
|
331
|
+
disabled$: t.panelOpened$
|
|
360
332
|
};
|
|
361
333
|
}
|
|
362
|
-
function
|
|
334
|
+
function Lt() {
|
|
363
335
|
return {
|
|
364
|
-
id:
|
|
336
|
+
id: L.id,
|
|
365
337
|
title: "action-recorder.menu.replay-local",
|
|
366
|
-
type:
|
|
338
|
+
type: R.BUTTON
|
|
367
339
|
};
|
|
368
340
|
}
|
|
369
|
-
function
|
|
341
|
+
function Bt() {
|
|
370
342
|
return {
|
|
371
|
-
id:
|
|
343
|
+
id: B.id,
|
|
372
344
|
title: "action-recorder.menu.replay-local-name",
|
|
373
|
-
type:
|
|
345
|
+
type: R.BUTTON
|
|
374
346
|
};
|
|
375
347
|
}
|
|
376
|
-
function
|
|
348
|
+
function Vt() {
|
|
377
349
|
return {
|
|
378
|
-
id:
|
|
350
|
+
id: V.id,
|
|
379
351
|
title: "action-recorder.menu.replay-local-active",
|
|
380
|
-
type:
|
|
352
|
+
type: R.BUTTON
|
|
381
353
|
};
|
|
382
354
|
}
|
|
383
|
-
const
|
|
384
|
-
[
|
|
385
|
-
[
|
|
355
|
+
const Wt = {
|
|
356
|
+
[lt.OTHERS]: {
|
|
357
|
+
[ce]: {
|
|
386
358
|
order: 10,
|
|
387
|
-
menuItemFactory:
|
|
388
|
-
[
|
|
359
|
+
menuItemFactory: Dt,
|
|
360
|
+
[W.id]: {
|
|
389
361
|
order: 1,
|
|
390
|
-
menuItemFactory:
|
|
362
|
+
menuItemFactory: Et
|
|
391
363
|
},
|
|
392
|
-
[
|
|
364
|
+
[L.id]: {
|
|
393
365
|
order: 2,
|
|
394
|
-
menuItemFactory:
|
|
366
|
+
menuItemFactory: Lt
|
|
395
367
|
},
|
|
396
|
-
[
|
|
368
|
+
[B.id]: {
|
|
397
369
|
order: 3,
|
|
398
|
-
menuItemFactory:
|
|
370
|
+
menuItemFactory: Bt
|
|
399
371
|
},
|
|
400
|
-
[
|
|
372
|
+
[V.id]: {
|
|
401
373
|
order: 4,
|
|
402
|
-
menuItemFactory:
|
|
374
|
+
menuItemFactory: Vt
|
|
403
375
|
}
|
|
404
376
|
}
|
|
405
377
|
}
|
|
406
378
|
};
|
|
407
|
-
var
|
|
408
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
409
|
-
(c = e[i]) && (o = (n ? c(
|
|
410
|
-
return n && o &&
|
|
411
|
-
},
|
|
412
|
-
let
|
|
413
|
-
constructor(e,
|
|
414
|
-
super(), this._commandSrv = e, this._uiPartsSrv =
|
|
379
|
+
var zt = Object.defineProperty, Ht = Object.getOwnPropertyDescriptor, Jt = (e, t, r, n) => {
|
|
380
|
+
for (var o = n > 1 ? void 0 : n ? Ht(t, r) : t, i = e.length - 1, c; i >= 0; i--)
|
|
381
|
+
(c = e[i]) && (o = (n ? c(t, r, o) : c(o)) || o);
|
|
382
|
+
return n && o && zt(t, r, o), o;
|
|
383
|
+
}, S = (e, t) => (r, n) => t(r, n, e);
|
|
384
|
+
let M = class extends j {
|
|
385
|
+
constructor(e, t, r, n, o, i) {
|
|
386
|
+
super(), this._commandSrv = e, this._uiPartsSrv = t, this._menuManagerService = r, this._componentManager = n, this._actionRecorderService = o, this._injector = i, this._initCommands(), this._initUI(), this._initSheetsCommands(), this._initDocsCommands();
|
|
415
387
|
}
|
|
416
388
|
_initCommands() {
|
|
417
389
|
[
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
390
|
+
te,
|
|
391
|
+
ne,
|
|
392
|
+
re,
|
|
393
|
+
W,
|
|
394
|
+
oe,
|
|
395
|
+
L,
|
|
396
|
+
B,
|
|
397
|
+
V
|
|
426
398
|
].forEach((e) => this._commandSrv.registerCommand(e));
|
|
427
399
|
}
|
|
428
400
|
_initUI() {
|
|
429
|
-
this._uiPartsSrv.registerComponent(
|
|
401
|
+
this._uiPartsSrv.registerComponent(gt.GLOBAL, () => le(Ft, this._injector)), this._componentManager.register("RecordSingle", D), this._menuManagerService.mergeMenu(Wt);
|
|
430
402
|
}
|
|
431
403
|
_initSheetsCommands() {
|
|
432
404
|
[
|
|
433
405
|
// InsertColCommand,
|
|
434
406
|
// InsertRowCommand,
|
|
435
407
|
// #region basic commands
|
|
436
|
-
|
|
408
|
+
ge,
|
|
409
|
+
he,
|
|
410
|
+
pe,
|
|
411
|
+
Se,
|
|
437
412
|
ve,
|
|
438
413
|
Ce,
|
|
414
|
+
_e,
|
|
439
415
|
ye,
|
|
440
416
|
Re,
|
|
441
417
|
Ie,
|
|
442
418
|
Oe,
|
|
443
419
|
Pe,
|
|
444
|
-
xe,
|
|
445
420
|
be,
|
|
446
|
-
Ne,
|
|
447
421
|
Me,
|
|
448
422
|
Ae,
|
|
449
|
-
|
|
450
|
-
we,
|
|
451
|
-
$e,
|
|
423
|
+
Ne,
|
|
452
424
|
// ResetBackgroundColorCommand,
|
|
453
425
|
// ResetTextColorCommand,
|
|
454
426
|
// SetBackgroundColorCommand,
|
|
455
427
|
// SetBoldCommand,
|
|
456
428
|
// SetFontFamilyCommand,
|
|
457
429
|
// SetFontSizeCommand,
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
430
|
+
Ue,
|
|
431
|
+
xe,
|
|
432
|
+
we,
|
|
461
433
|
// SetItalicCommand,
|
|
462
|
-
|
|
434
|
+
$e,
|
|
435
|
+
Je,
|
|
436
|
+
Ge,
|
|
463
437
|
Ze,
|
|
464
438
|
Ke,
|
|
465
439
|
Ye,
|
|
440
|
+
ke,
|
|
441
|
+
qe,
|
|
466
442
|
Qe,
|
|
467
443
|
Xe,
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
nr,
|
|
444
|
+
Te,
|
|
445
|
+
Fe,
|
|
446
|
+
je,
|
|
472
447
|
De,
|
|
448
|
+
Ee,
|
|
449
|
+
// SetUnderlineCommand,
|
|
473
450
|
Le,
|
|
451
|
+
et,
|
|
452
|
+
tt,
|
|
453
|
+
rt,
|
|
454
|
+
nt,
|
|
455
|
+
ot,
|
|
456
|
+
it,
|
|
457
|
+
ct,
|
|
458
|
+
at,
|
|
459
|
+
dt,
|
|
460
|
+
st,
|
|
474
461
|
Be,
|
|
475
462
|
Ve,
|
|
476
|
-
|
|
477
|
-
// SetUnderlineCommand,
|
|
478
|
-
We,
|
|
479
|
-
or,
|
|
480
|
-
ir,
|
|
481
|
-
cr,
|
|
482
|
-
ar,
|
|
483
|
-
sr,
|
|
484
|
-
dr,
|
|
485
|
-
lr,
|
|
486
|
-
mr,
|
|
487
|
-
ur,
|
|
488
|
-
fr,
|
|
489
|
-
ze,
|
|
490
|
-
He,
|
|
491
|
-
E,
|
|
463
|
+
T,
|
|
492
464
|
// #endregion
|
|
493
465
|
// #region data validation command
|
|
494
466
|
// #endregion
|
|
495
467
|
// #region conditional formatting command
|
|
496
468
|
// #endregion
|
|
497
469
|
// #region filter command
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
470
|
+
We,
|
|
471
|
+
ze,
|
|
472
|
+
He
|
|
501
473
|
// #endregion
|
|
502
474
|
].forEach((e) => this._actionRecorderService.registerRecordedCommand(e));
|
|
503
475
|
}
|
|
504
476
|
_initDocsCommands() {
|
|
505
477
|
}
|
|
506
478
|
};
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
],
|
|
515
|
-
const
|
|
516
|
-
var
|
|
517
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
518
|
-
(c = e[i]) && (o = (n ? c(
|
|
519
|
-
return n && o &&
|
|
520
|
-
},
|
|
521
|
-
let
|
|
522
|
-
constructor(e =
|
|
523
|
-
super(), this._config = e, this._injector =
|
|
524
|
-
const { menu: n, ...o } =
|
|
479
|
+
M = Jt([
|
|
480
|
+
S(0, A),
|
|
481
|
+
S(1, ut),
|
|
482
|
+
S(2, ft),
|
|
483
|
+
S(3, b(mt)),
|
|
484
|
+
S(4, b(l)),
|
|
485
|
+
S(5, b(Y))
|
|
486
|
+
], M);
|
|
487
|
+
const Gt = "action-recorder.config", H = {};
|
|
488
|
+
var Zt = Object.defineProperty, Kt = Object.getOwnPropertyDescriptor, Yt = (e, t, r, n) => {
|
|
489
|
+
for (var o = n > 1 ? void 0 : n ? Kt(t, r) : t, i = e.length - 1, c; i >= 0; i--)
|
|
490
|
+
(c = e[i]) && (o = (n ? c(t, r, o) : c(o)) || o);
|
|
491
|
+
return n && o && Zt(t, r, o), o;
|
|
492
|
+
}, J = (e, t) => (r, n) => t(r, n, e), w;
|
|
493
|
+
let G = (w = class extends me {
|
|
494
|
+
constructor(e = H, t, r) {
|
|
495
|
+
super(), this._config = e, this._injector = t, this._configService = r;
|
|
496
|
+
const { menu: n, ...o } = ue(
|
|
525
497
|
{},
|
|
526
|
-
|
|
498
|
+
H,
|
|
527
499
|
this._config
|
|
528
500
|
);
|
|
529
|
-
n && this._configService.setConfig("menu", n, { merge: !0 }), this._configService.setConfig(
|
|
501
|
+
n && this._configService.setConfig("menu", n, { merge: !0 }), this._configService.setConfig(Gt, o);
|
|
530
502
|
}
|
|
531
503
|
onStarting() {
|
|
532
|
-
(this._config.replayOnly ? [[
|
|
533
|
-
[
|
|
534
|
-
[
|
|
535
|
-
[
|
|
536
|
-
]).forEach((
|
|
504
|
+
(this._config.replayOnly ? [[p]] : [
|
|
505
|
+
[l],
|
|
506
|
+
[p],
|
|
507
|
+
[M]
|
|
508
|
+
]).forEach((t) => this._injector.add(t));
|
|
537
509
|
}
|
|
538
510
|
onSteady() {
|
|
539
|
-
this._config.replayOnly || this._injector.get(
|
|
511
|
+
this._config.replayOnly || this._injector.get(M);
|
|
540
512
|
}
|
|
541
|
-
},
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
],
|
|
513
|
+
}, m(w, "pluginName", "UNIVER_ACTION_RECORDER_PLUGIN"), w);
|
|
514
|
+
G = Yt([
|
|
515
|
+
J(1, b(Y)),
|
|
516
|
+
J(2, fe)
|
|
517
|
+
], G);
|
|
546
518
|
export {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
519
|
+
l as ActionRecorderService,
|
|
520
|
+
p as ActionReplayService,
|
|
521
|
+
G as UniverActionRecorderPlugin
|
|
550
522
|
};
|
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export declare function RecorderPanel(): import("react/jsx-runtime").JSX.Element | null;
|
package/lib/umd/index.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
(function(c,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-filter"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-filter","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/design","react"],i):(c=typeof globalThis<"u"?globalThis:c||self,i(c.UniverActionRecorder={},c.UniverCore,c.UniverSheets,c.UniverSheetsFilter,c.UniverSheetsUi,c.UniverUi,c.rxjs,c.UniverDesign,c.React))})(this,function(c,i,s,N,m,u,b,h,C){"use strict";var be=Object.defineProperty;var Me=(c,i,s)=>i in c?be(c,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):c[i]=s;var g=(c,i,s)=>Me(c,typeof i!="symbol"?i+"":i,s);var B;var p=function(){return p=Object.assign||function(n){for(var t,e=1,r=arguments.length;e<r;e++){t=arguments[e];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o])}return n},p.apply(this,arguments)},Q=function(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(n);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(n,r[o])&&(e[r[o]]=n[r[o]]);return e},$=C.forwardRef(function(n,t){var e=n.icon,r=n.id,o=n.className,a=n.extend,d=Q(n,["icon","id","className","extend"]),f="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),l=C.useRef("_".concat(ne()));return V(e,"".concat(r),{defIds:e.defIds,idSuffix:l.current},p({ref:t,className:f},d),a)});function V(n,t,e,r,o){return C.createElement(n.tag,p(p({key:t},X(n,e,o)),r),(ee(n,e).children||[]).map(function(a,d){return V(a,"".concat(t,"-").concat(n.tag,"-").concat(d),e,void 0,o)}))}function X(n,t,e){var r=p({},n.attrs);e!=null&&e.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=e.colorChannel1);var o=t.defIds;return!o||o.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+t.idSuffix),Object.entries(r).forEach(function(a){var d=a[0],f=a[1];typeof f=="string"&&(r[d]=f.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),r}function ee(n,t){var e,r=t.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((e=n.children)===null||e===void 0)&&e.length)?p(p({},n),{children:n.children.map(function(o){return typeof o.attrs.id=="string"&&r&&r.indexOf(o.attrs.id)>-1?p(p({},o),{attrs:p(p({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):n}function ne(){return Math.random().toString(36).substring(2,8)}$.displayName="UniverIcon";var re={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"g",attrs:{fill:"currentColor",clipPath:"url(#record-single_clip0_1559_19)"},children:[{tag:"path",attrs:{d:"M7.60303 10C8.7076 10 9.60303 9.10457 9.60303 8C9.60303 6.89543 8.7076 6 7.60303 6C6.49846 6 5.60303 6.89543 5.60303 8C5.60303 9.10457 6.49846 10 7.60303 10Z"}},{tag:"path",attrs:{d:"M1.66943 5.29023C1.66941 3.85426 2.83349 2.69017 4.26946 2.69019L10.9362 2.69026C12.3192 2.69028 13.45 3.77008 13.5315 5.13259L14.5692 4.55638C15.3024 4.14929 16.2032 4.67947 16.2032 5.51809V10.4819C16.2032 11.3205 15.3024 11.8507 14.5692 11.4436L13.5315 10.8674C13.45 12.2299 12.3192 13.3097 10.9362 13.3097H4.26953C2.83361 13.3097 1.66956 12.1457 1.66953 10.7098L1.66943 5.29023ZM13.5362 9.49743L15.0032 10.312V5.68799L13.5362 6.50254V9.49743ZM4.26945 3.89019C3.49623 3.89018 2.86942 4.517 2.86943 5.29021L2.86953 10.7098C2.86955 11.483 3.49634 12.1097 4.26953 12.1097H10.9362C11.7094 12.1097 12.3362 11.4829 12.3362 10.7097V5.29026C12.3362 4.51707 11.7094 3.89027 10.9362 3.89026L4.26945 3.89019Z",fillRule:"evenodd",clipRule:"evenodd"}}]},{tag:"defs",attrs:{},children:[{tag:"clipPath",attrs:{id:"record-single_clip0_1559_19"},children:[{tag:"path",attrs:{fill:"#fff",d:"M0 0H16V16H0z",transform:"translate(.94)"}}]}]}],defIds:["record-single_clip0_1559_19"]},w=C.forwardRef(function(n,t){return C.createElement($,Object.assign({},n,{id:"record-single",ref:t,icon:re}))});w.displayName="RecordSingle";var te=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,ie=(n,t,e,r)=>{for(var o=r>1?void 0:r?oe(t,e):t,a=n.length-1,d;a>=0;a--)(d=n[a])&&(o=(r?d(t,e,o):d(o))||o);return r&&o&&te(t,e,o),o},M=(n,t)=>(e,r)=>t(e,r,n);c.ActionRecorderService=class extends i.Disposable{constructor(e,r,o,a){super();g(this,"_shouldRecordCommands",new Set);g(this,"_panelOpened$",new b.BehaviorSubject(!1));g(this,"panelOpened$",this._panelOpened$.asObservable());g(this,"_recorder",null);g(this,"_recording$",new b.BehaviorSubject(!1));g(this,"recording$",this._recording$.asObservable());g(this,"_recorded$",new b.BehaviorSubject([]));g(this,"_recordedCommands$",new b.BehaviorSubject([]));g(this,"recordedCommands$",this._recordedCommands$.asObservable());this._commandSrv=e,this._logService=r,this._localFileService=o,this._instanceService=a}get recording(){return this._recording$.getValue()}get _recorded(){return this._recorded$.getValue()}get _recordedCommands(){return this._recordedCommands$.getValue()}registerRecordedCommand(e){if(e.type===i.CommandType.MUTATION)throw new Error("[CommandRecorderService] Cannot record mutation commands.");this._shouldRecordCommands.add(e.id)}togglePanel(e){this._panelOpened$.next(e),e===!1&&this.stopRecording()}startRecording(e=!1){this._recorder=this._commandSrv.onCommandExecuted(r=>{var o,a;if(this._shouldRecordCommands.has(r.id)){const d=this._recorded,f=this._recordedCommands;let l={...r};const R=(o=this._instanceService.getFocusedUnit())==null?void 0:o.getUnitId(),{unitId:S=R,subUnitId:v}=l==null?void 0:l.params;if(e&&S&&v){const I=(a=this._instanceService.getUnit(S).getSheetBySheetId(v))==null?void 0:a.getName();l={...l,params:{...l.params,subUnitId:I}}}l.id===s.SetSelectionsOperation.id&&d.length>0&&d[d.length-1].id===s.SetSelectionsOperation.id?d[d.length-1]=l:(d.push(l),this._recorded$.next(d),l.type===i.CommandType.COMMAND&&(f.push(l),this._recordedCommands$.next(f)))}}),this._recording$.next(!0)}stopRecording(){var e;(e=this._recorder)==null||e.dispose(),this._recorder=null,this._recorded$.next([]),this._recordedCommands$.next([]),this._recording$.next(!1)}completeRecording(){const e=this._recorded.slice();this._localFileService.downloadFile(new Blob([JSON.stringify(e,null,2)]),"recorded-commands.json"),this._logService.error("Recorded commands:",e),this.stopRecording()}},c.ActionRecorderService=ie([M(0,i.ICommandService),M(1,i.ILogService),M(2,u.ILocalFileService),M(3,i.IUniverInstanceService)],c.ActionRecorderService);const J={id:"action-recorder.command.start-recording",type:i.CommandType.COMMAND,handler:(n,t)=>(n.get(c.ActionRecorderService).startRecording(!!(t!=null&&t.replaceId)),!0)},W={id:"action-recorder.command.complete-recording",type:i.CommandType.COMMAND,handler:n=>(n.get(c.ActionRecorderService).completeRecording(),!0)},z={id:"action-recorder.command.stop-recording",type:i.CommandType.COMMAND,handler:n=>(n.get(c.ActionRecorderService).completeRecording(),!0)};var ce=Object.defineProperty,ae=Object.getOwnPropertyDescriptor,de=(n,t,e,r)=>{for(var o=r>1?void 0:r?ae(t,e):t,a=n.length-1,d;a>=0;a--)(d=n[a])&&(o=(r?d(t,e,o):d(o))||o);return r&&o&&ce(t,e,o),o},P=(n,t)=>(e,r)=>t(e,r,n),x=(n=>(n.DEFAULT="default",n.NAME="name",n.ACTIVE="active",n))(x||{});c.ActionReplayService=class extends i.Disposable{constructor(t,e,r,o,a){super(),this._messageService=t,this._instanceService=e,this._localFileService=r,this._logService=o,this._commandService=a}async replayLocalJSON(t="default"){const e=await this._localFileService.openFile({multiple:!1,accept:".json"});if(e.length!==1)return!1;const r=e[0];try{return this.replayCommands(JSON.parse(await r.text()),{mode:t})}catch{return this._messageService.show({type:h.MessageType.Error,content:`Failed to replay commands from local file ${r.name}.`}),!1}}async replayCommands(t,e){var a,d,f;const r=(a=this._instanceService.getFocusedUnit())==null?void 0:a.getUnitId();r||this._logService.error("[ReplayService]","no focused unit to replay commands");const{mode:o}=e||{};for(const l of t){const{id:R,params:S}=l,v=S;if(v){if(typeof v.unitId<"u"&&(v.unitId=r),o==="name"&&v.subUnitId!=="undefined"){const y=(d=this._instanceService.getFocusedUnit().getSheetBySheetName(v.subUnitId))==null?void 0:d.getSheetId();y?v.subUnitId=y:this._logService.error("[ReplayService]",`failed to find subunit by subUnitName = ${v.subUnitId}`)}if(o==="active"&&v.subUnitId!=="undefined"){const y=(f=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:f.getSheetId();y?v.subUnitId=y:this._logService.error("[ReplayService]","failed to find active subunit")}if(!await this._commandService.executeCommand(R,S))return!1}else if(!await this._commandService.executeCommand(R))return!1}return!0}async replayCommandsWithDelay(t){var r;const e=(r=this._instanceService.getFocusedUnit())==null?void 0:r.getUnitId();e||this._logService.error("[ReplayService]","no focused unit to replay commands");for(const o of t){await i.awaitTime(se());const{id:a,params:d}=o;if(d){if(typeof d.unitId<"u"&&(d.unitId=e),!await this._commandService.executeCommand(a,d))return!1}else if(!await this._commandService.executeCommand(a))return!1}return!0}},c.ActionReplayService=de([P(0,u.IMessageService),P(1,i.IUniverInstanceService),P(2,u.ILocalFileService),P(3,i.ILogService),P(4,i.ICommandService)],c.ActionReplayService);function se(){return Math.floor(Math.random()*800)+200}const U={id:"action-recorder.command.replay-local-records",type:i.CommandType.COMMAND,handler:async n=>{const e=await n.get(c.ActionReplayService).replayLocalJSON();return e&&n.get(u.IMessageService).show({type:h.MessageType.Success,content:"Successfully replayed local records"}),e}},E={id:"action-recorder.command.replay-local-records-name",type:i.CommandType.COMMAND,handler:async n=>{const e=await n.get(c.ActionReplayService).replayLocalJSON(x.NAME);return e&&n.get(u.IMessageService).show({type:h.MessageType.Success,content:"Successfully replayed local records"}),e}},D={id:"action-recorder.command.replay-local-records-active",type:i.CommandType.COMMAND,handler:async n=>{const e=await n.get(c.ActionReplayService).replayLocalJSON(x.ACTIVE);return e&&n.get(u.IMessageService).show({type:h.MessageType.Success,content:"Successfully replayed local records"}),e}},F={id:"action-recorder.operation.open-panel",type:i.CommandType.OPERATION,handler(n){return n.get(c.ActionRecorderService).togglePanel(!0),!0}},k={id:"action-recorder.operation.close-panel",type:i.CommandType.OPERATION,handler(n){return n.get(c.ActionRecorderService).togglePanel(!1),!0}};var L={exports:{}},A={};/**
|
|
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 H;function le(){if(H)return A;H=1;var n=C,t=Symbol.for("react.element"),e=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function d(f,l,R){var S,v={},I=null,y=null;R!==void 0&&(I=""+R),l.key!==void 0&&(I=""+l.key),l.ref!==void 0&&(y=l.ref);for(S in l)r.call(l,S)&&!a.hasOwnProperty(S)&&(v[S]=l[S]);if(f&&f.defaultProps)for(S in l=f.defaultProps,l)v[S]===void 0&&(v[S]=l[S]);return{$$typeof:t,type:f,key:I,ref:y,props:v,_owner:o.current}}return A.Fragment=e,A.jsx=d,A.jsxs=d,A}var G;function me(){return G||(G=1,L.exports=le()),L.exports}var _=me();function q(n){var t,e,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var o=n.length;for(t=0;t<o;t++)n[t]&&(e=q(n[t]))&&(r&&(r+=" "),r+=e)}else for(e in n)n[e]&&(r&&(r+=" "),r+=e);return r}function ue(){for(var n,t,e=0,r="",o=arguments.length;e<o;e++)(n=arguments[e])&&(t=q(n))&&(r&&(r+=" "),r+=t);return r}const j={actionRecorderPanel:"univer-action-recorder-panel",actionRecorderPanelIcon:"univer-action-recorder-panel-icon",actionRecorderPanelIconRecording:"univer-action-recorder-panel-icon-recording",recording:"univer-recording",actionRecorderPanelTitle:"univer-action-recorder-panel-title",actionRecorderPanelActions:"univer-action-recorder-panel-actions"};function fe(){const n=i.useDependency(c.ActionRecorderService);return u.useObservable(n.panelOpened$)?_.jsx(ve,{}):null}function ve(){var S;const n=i.useDependency(i.ICommandService),t=i.useDependency(c.ActionRecorderService),e=u.useObservable(t.recording$),r=u.useObservable(t.recordedCommands$),o=(S=r==null?void 0:r.length)!=null?S:0,a=C.useCallback(()=>{e||n.executeCommand(k.id)},[n,e]),d=C.useCallback(v=>{e||n.executeCommand(J.id,{replaceId:v})},[n,e]),f=C.useCallback(()=>{e&&n.executeCommand(W.id)},[n,e]),l=C.useCallback(()=>{e&&n.executeCommand(z.id)},[n,e]),R=e?o===0?"Recording...":`${o}: ${r[o-1].id}`:"Start Recording";return _.jsxs("div",{className:j.actionRecorderPanel,children:[_.jsx("div",{className:ue(j.actionRecorderPanelIcon,e?j.actionRecorderPanelIconRecording:!1),children:_.jsx(w,{})}),_.jsx("div",{className:j.actionRecorderPanelTitle,children:R}),_.jsxs("div",{className:j.actionRecorderPanelActions,children:[_.jsx(h.Button,{type:"default",size:"small",onClick:e?l:a,children:e?"Cancel":"Close"}),_.jsx(h.Button,{type:"primary",size:"small",onClick:e?f:()=>d(),children:e?"Save":"Start"}),!e&&_.jsx(h.Button,{type:"primary",size:"small",onClick:()=>d(!0),children:"Start(N)"})]})]})}const Z="RECORD_MENU_ITEM";function Se(){return{id:Z,type:u.MenuItemType.SUBITEMS,icon:"RecordSingle",tooltip:"action-recorder.menu.title"}}function pe(n){const t=n.get(c.ActionRecorderService);return{id:F.id,title:"action-recorder.menu.record",type:u.MenuItemType.BUTTON,disabled$:t.panelOpened$}}function ge(){return{id:U.id,title:"action-recorder.menu.replay-local",type:u.MenuItemType.BUTTON}}function Ce(){return{id:E.id,title:"action-recorder.menu.replay-local-name",type:u.MenuItemType.BUTTON}}function _e(){return{id:D.id,title:"action-recorder.menu.replay-local-active",type:u.MenuItemType.BUTTON}}const Re={[u.RibbonStartGroup.OTHERS]:{[Z]:{order:10,menuItemFactory:Se,[F.id]:{order:1,menuItemFactory:pe},[U.id]:{order:2,menuItemFactory:ge},[E.id]:{order:3,menuItemFactory:Ce},[D.id]:{order:4,menuItemFactory:_e}}}};var ye=Object.defineProperty,he=Object.getOwnPropertyDescriptor,Ie=(n,t,e,r)=>{for(var o=r>1?void 0:r?he(t,e):t,a=n.length-1,d;a>=0;a--)(d=n[a])&&(o=(r?d(t,e,o):d(o))||o);return r&&o&&ye(t,e,o),o},O=(n,t)=>(e,r)=>t(e,r,n);let T=class extends i.Disposable{constructor(n,t,e,r,o,a){super(),this._commandSrv=n,this._uiPartsSrv=t,this._menuManagerService=e,this._componentManager=r,this._actionRecorderService=o,this._injector=a,this._initCommands(),this._initUI(),this._initSheetsCommands(),this._initDocsCommands()}_initCommands(){[J,z,W,F,k,U,E,D].forEach(n=>this._commandSrv.registerCommand(n))}_initUI(){this._uiPartsSrv.registerComponent(u.BuiltInUIPart.GLOBAL,()=>i.connectInjector(fe,this._injector)),this._componentManager.register("RecordSingle",w),this._menuManagerService.mergeMenu(Re)}_initSheetsCommands(){[s.CopySheetCommand,s.DeleteRangeMoveLeftCommand,s.DeleteRangeMoveUpCommand,s.DeltaColumnWidthCommand,s.DeltaRowHeightCommand,s.InsertSheetCommand,s.InsertColAfterCommand,s.InsertColBeforeCommand,s.InsertRowAfterCommand,s.InsertRowBeforeCommand,s.RemoveSheetCommand,s.SetStyleCommand,s.AddWorksheetMergeCommand,s.AddWorksheetMergeAllCommand,s.AddWorksheetMergeVerticalCommand,s.AddWorksheetMergeHorizontalCommand,s.SetFrozenCommand,s.CancelFrozenCommand,s.SetHorizontalTextAlignCommand,s.SetOverlineCommand,m.SetRangeBoldCommand,m.SetRangeFontFamilyCommand,m.SetRangeFontSizeCommand,m.SetRangeItalicCommand,m.SetRangeStrickThroughCommand,m.SetRangeSubscriptCommand,m.SetRangeSuperscriptCommand,m.SetRangeTextColorCommand,m.SetRangeUnderlineCommand,s.SetRangeValuesCommand,s.SetStrikeThroughCommand,s.SetTextColorCommand,s.SetTextRotationCommand,s.SetTextWrapCommand,s.SetVerticalTextAlignCommand,m.SheetCopyCommand,m.SheetCutCommand,m.SheetPasteBesidesBorderCommand,m.SheetPasteColWidthCommand,m.SheetPasteCommand,m.SheetPasteFormatCommand,m.SheetPasteShortKeyCommand,m.SheetPasteValueCommand,m.AutoFillCommand,m.RefillCommand,s.SetWorksheetActivateCommand,s.SetWorksheetActiveOperation,s.SetSelectionsOperation,N.SetSheetFilterRangeCommand,N.SetSheetsFilterCriteriaCommand,N.RemoveSheetFilterCommand].forEach(n=>this._actionRecorderService.registerRecordedCommand(n))}_initDocsCommands(){}};T=Ie([O(0,i.ICommandService),O(1,u.IUIPartsService),O(2,u.IMenuManagerService),O(3,i.Inject(u.ComponentManager)),O(4,i.Inject(c.ActionRecorderService)),O(5,i.Inject(i.Injector))],T);const Oe="action-recorder.config",K={};var Pe=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,je=(n,t,e,r)=>{for(var o=r>1?void 0:r?Ae(t,e):t,a=n.length-1,d;a>=0;a--)(d=n[a])&&(o=(r?d(t,e,o):d(o))||o);return r&&o&&Pe(t,e,o),o},Y=(n,t)=>(e,r)=>t(e,r,n);c.UniverActionRecorderPlugin=(B=class extends i.Plugin{constructor(t=K,e,r){super(),this._config=t,this._injector=e,this._configService=r;const{menu:o,...a}=i.merge({},K,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Oe,a)}onStarting(){(this._config.replayOnly?[[c.ActionReplayService]]:[[c.ActionRecorderService],[c.ActionReplayService],[T]]).forEach(e=>this._injector.add(e))}onSteady(){this._config.replayOnly||this._injector.get(T)}},g(B,"pluginName","UNIVER_ACTION_RECORDER_PLUGIN"),B),c.UniverActionRecorderPlugin=je([Y(1,i.Inject(i.Injector)),Y(2,i.IConfigService)],c.UniverActionRecorderPlugin),Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(c,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-filter"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-filter","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/design","react/jsx-runtime","react"],i):(c=typeof globalThis<"u"?globalThis:c||self,i(c.UniverActionRecorder={},c.UniverCore,c.UniverSheets,c.UniverSheetsFilter,c.UniverSheetsUi,c.UniverUi,c.rxjs,c.UniverDesign,c.React,c.React))})(this,function(c,i,s,T,l,m,P,h,p,C){"use strict";var Re=Object.defineProperty;var Ie=(c,i,s)=>i in c?Re(c,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):c[i]=s;var g=(c,i,s)=>Ie(c,typeof i!="symbol"?i+"":i,s);var F;var S=function(){return S=Object.assign||function(n){for(var t,e=1,r=arguments.length;e<r;e++){t=arguments[e];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o])}return n},S.apply(this,arguments)},Z=function(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(n);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(n,r[o])&&(e[r[o]]=n[r[o]]);return e},L=C.forwardRef(function(n,t){var e=n.icon,r=n.id,o=n.className,a=n.extend,d=Z(n,["icon","id","className","extend"]),f="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),u=C.useRef("_".concat(Y()));return B(e,"".concat(r),{defIds:e.defIds,idSuffix:u.current},S({ref:t,className:f},d),a)});function B(n,t,e,r,o){return C.createElement(n.tag,S(S({key:t},k(n,e,o)),r),(K(n,e).children||[]).map(function(a,d){return B(a,"".concat(t,"-").concat(n.tag,"-").concat(d),e,void 0,o)}))}function k(n,t,e){var r=S({},n.attrs);e!=null&&e.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=e.colorChannel1);var o=t.defIds;return!o||o.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+t.idSuffix),Object.entries(r).forEach(function(a){var d=a[0],f=a[1];typeof f=="string"&&(r[d]=f.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),r}function K(n,t){var e,r=t.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((e=n.children)===null||e===void 0)&&e.length)?S(S({},n),{children:n.children.map(function(o){return typeof o.attrs.id=="string"&&r&&r.indexOf(o.attrs.id)>-1?S(S({},o),{attrs:S(S({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):n}function Y(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";var Q={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"g",attrs:{fill:"currentColor",clipPath:"url(#record-single_clip0_1559_19)"},children:[{tag:"path",attrs:{d:"M7.60303 10C8.7076 10 9.60303 9.10457 9.60303 8C9.60303 6.89543 8.7076 6 7.60303 6C6.49846 6 5.60303 6.89543 5.60303 8C5.60303 9.10457 6.49846 10 7.60303 10Z"}},{tag:"path",attrs:{d:"M1.66943 5.29023C1.66941 3.85426 2.83349 2.69017 4.26946 2.69019L10.9362 2.69026C12.3192 2.69028 13.45 3.77008 13.5315 5.13259L14.5692 4.55638C15.3024 4.14929 16.2032 4.67947 16.2032 5.51809V10.4819C16.2032 11.3205 15.3024 11.8507 14.5692 11.4436L13.5315 10.8674C13.45 12.2299 12.3192 13.3097 10.9362 13.3097H4.26953C2.83361 13.3097 1.66956 12.1457 1.66953 10.7098L1.66943 5.29023ZM13.5362 9.49743L15.0032 10.312V5.68799L13.5362 6.50254V9.49743ZM4.26945 3.89019C3.49623 3.89018 2.86942 4.517 2.86943 5.29021L2.86953 10.7098C2.86955 11.483 3.49634 12.1097 4.26953 12.1097H10.9362C11.7094 12.1097 12.3362 11.4829 12.3362 10.7097V5.29026C12.3362 4.51707 11.7094 3.89027 10.9362 3.89026L4.26945 3.89019Z",fillRule:"evenodd",clipRule:"evenodd"}}]},{tag:"defs",attrs:{},children:[{tag:"clipPath",attrs:{id:"record-single_clip0_1559_19"},children:[{tag:"path",attrs:{fill:"#fff",d:"M0 0H16V16H0z",transform:"translate(.94)"}}]}]}],defIds:["record-single_clip0_1559_19"]},j=C.forwardRef(function(n,t){return C.createElement(L,Object.assign({},n,{id:"record-single",ref:t,icon:Q}))});j.displayName="RecordSingle";var X=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,ne=(n,t,e,r)=>{for(var o=r>1?void 0:r?ee(t,e):t,a=n.length-1,d;a>=0;a--)(d=n[a])&&(o=(r?d(t,e,o):d(o))||o);return r&&o&&X(t,e,o),o},M=(n,t)=>(e,r)=>t(e,r,n);c.ActionRecorderService=class extends i.Disposable{constructor(e,r,o,a){super();g(this,"_shouldRecordCommands",new Set);g(this,"_panelOpened$",new P.BehaviorSubject(!1));g(this,"panelOpened$",this._panelOpened$.asObservable());g(this,"_recorder",null);g(this,"_recording$",new P.BehaviorSubject(!1));g(this,"recording$",this._recording$.asObservable());g(this,"_recorded$",new P.BehaviorSubject([]));g(this,"_recordedCommands$",new P.BehaviorSubject([]));g(this,"recordedCommands$",this._recordedCommands$.asObservable());this._commandSrv=e,this._logService=r,this._localFileService=o,this._instanceService=a}get recording(){return this._recording$.getValue()}get _recorded(){return this._recorded$.getValue()}get _recordedCommands(){return this._recordedCommands$.getValue()}registerRecordedCommand(e){if(e.type===i.CommandType.MUTATION)throw new Error("[CommandRecorderService] Cannot record mutation commands.");this._shouldRecordCommands.add(e.id)}togglePanel(e){this._panelOpened$.next(e),e===!1&&this.stopRecording()}startRecording(e=!1){this._recorder=this._commandSrv.onCommandExecuted(r=>{var o,a;if(this._shouldRecordCommands.has(r.id)){const d=this._recorded,f=this._recordedCommands;let u={...r};const R=(o=this._instanceService.getFocusedUnit())==null?void 0:o.getUnitId(),{unitId:y=R,subUnitId:v}=u==null?void 0:u.params;if(e&&y&&v){const E=(a=this._instanceService.getUnit(y).getSheetBySheetId(v))==null?void 0:a.getName();u={...u,params:{...u.params,subUnitId:E}}}u.id===s.SetSelectionsOperation.id&&d.length>0&&d[d.length-1].id===s.SetSelectionsOperation.id?d[d.length-1]=u:(d.push(u),this._recorded$.next(d),u.type===i.CommandType.COMMAND&&(f.push(u),this._recordedCommands$.next(f)))}}),this._recording$.next(!0)}stopRecording(){var e;(e=this._recorder)==null||e.dispose(),this._recorder=null,this._recorded$.next([]),this._recordedCommands$.next([]),this._recording$.next(!1)}completeRecording(){const e=this._recorded.slice();this._localFileService.downloadFile(new Blob([JSON.stringify(e,null,2)]),"recorded-commands.json"),this._logService.error("Recorded commands:",e),this.stopRecording()}},c.ActionRecorderService=ne([M(0,i.ICommandService),M(1,i.ILogService),M(2,m.ILocalFileService),M(3,i.IUniverInstanceService)],c.ActionRecorderService);const x={id:"action-recorder.command.start-recording",type:i.CommandType.COMMAND,handler:(n,t)=>(n.get(c.ActionRecorderService).startRecording(!!(t!=null&&t.replaceId)),!0)},V={id:"action-recorder.command.complete-recording",type:i.CommandType.COMMAND,handler:n=>(n.get(c.ActionRecorderService).completeRecording(),!0)},W={id:"action-recorder.command.stop-recording",type:i.CommandType.COMMAND,handler:n=>(n.get(c.ActionRecorderService).completeRecording(),!0)};var re=Object.defineProperty,te=Object.getOwnPropertyDescriptor,oe=(n,t,e,r)=>{for(var o=r>1?void 0:r?te(t,e):t,a=n.length-1,d;a>=0;a--)(d=n[a])&&(o=(r?d(t,e,o):d(o))||o);return r&&o&&re(t,e,o),o},I=(n,t)=>(e,r)=>t(e,r,n),N=(n=>(n.DEFAULT="default",n.NAME="name",n.ACTIVE="active",n))(N||{});c.ActionReplayService=class extends i.Disposable{constructor(t,e,r,o,a){super(),this._messageService=t,this._instanceService=e,this._localFileService=r,this._logService=o,this._commandService=a}async replayLocalJSON(t="default"){const e=await this._localFileService.openFile({multiple:!1,accept:".json"});if(e.length!==1)return!1;const r=e[0];try{return this.replayCommands(JSON.parse(await r.text()),{mode:t})}catch{return this._messageService.show({type:h.MessageType.Error,content:`Failed to replay commands from local file ${r.name}.`}),!1}}async replayCommands(t,e){var a,d,f;const r=(a=this._instanceService.getFocusedUnit())==null?void 0:a.getUnitId();r||this._logService.error("[ReplayService]","no focused unit to replay commands");const{mode:o}=e||{};for(const u of t){const{id:R,params:y}=u,v=y;if(v){if(typeof v.unitId<"u"&&(v.unitId=r),o==="name"&&v.subUnitId!=="undefined"){const A=(d=this._instanceService.getFocusedUnit().getSheetBySheetName(v.subUnitId))==null?void 0:d.getSheetId();A?v.subUnitId=A:this._logService.error("[ReplayService]",`failed to find subunit by subUnitName = ${v.subUnitId}`)}if(o==="active"&&v.subUnitId!=="undefined"){const A=(f=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:f.getSheetId();A?v.subUnitId=A:this._logService.error("[ReplayService]","failed to find active subunit")}if(!await this._commandService.executeCommand(R,y))return!1}else if(!await this._commandService.executeCommand(R))return!1}return!0}async replayCommandsWithDelay(t){var r;const e=(r=this._instanceService.getFocusedUnit())==null?void 0:r.getUnitId();e||this._logService.error("[ReplayService]","no focused unit to replay commands");for(const o of t){await i.awaitTime(ie());const{id:a,params:d}=o;if(d){if(typeof d.unitId<"u"&&(d.unitId=e),!await this._commandService.executeCommand(a,d))return!1}else if(!await this._commandService.executeCommand(a))return!1}return!0}},c.ActionReplayService=oe([I(0,m.IMessageService),I(1,i.IUniverInstanceService),I(2,m.ILocalFileService),I(3,i.ILogService),I(4,i.ICommandService)],c.ActionReplayService);function ie(){return Math.floor(Math.random()*800)+200}const w={id:"action-recorder.command.replay-local-records",type:i.CommandType.COMMAND,handler:async n=>{const e=await n.get(c.ActionReplayService).replayLocalJSON();return e&&n.get(m.IMessageService).show({type:h.MessageType.Success,content:"Successfully replayed local records"}),e}},$={id:"action-recorder.command.replay-local-records-name",type:i.CommandType.COMMAND,handler:async n=>{const e=await n.get(c.ActionReplayService).replayLocalJSON(N.NAME);return e&&n.get(m.IMessageService).show({type:h.MessageType.Success,content:"Successfully replayed local records"}),e}},U={id:"action-recorder.command.replay-local-records-active",type:i.CommandType.COMMAND,handler:async n=>{const e=await n.get(c.ActionReplayService).replayLocalJSON(N.ACTIVE);return e&&n.get(m.IMessageService).show({type:h.MessageType.Success,content:"Successfully replayed local records"}),e}},D={id:"action-recorder.operation.open-panel",type:i.CommandType.OPERATION,handler(n){return n.get(c.ActionRecorderService).togglePanel(!0),!0}},q={id:"action-recorder.operation.close-panel",type:i.CommandType.OPERATION,handler(n){return n.get(c.ActionRecorderService).togglePanel(!1),!0}};function z(n){var t,e,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var o=n.length;for(t=0;t<o;t++)n[t]&&(e=z(n[t]))&&(r&&(r+=" "),r+=e)}else for(e in n)n[e]&&(r&&(r+=" "),r+=e);return r}function ce(){for(var n,t,e=0,r="",o=arguments.length;e<o;e++)(n=arguments[e])&&(t=z(n))&&(r&&(r+=" "),r+=t);return r}const O={actionRecorderPanel:"univer-action-recorder-panel",actionRecorderPanelIcon:"univer-action-recorder-panel-icon",actionRecorderPanelIconRecording:"univer-action-recorder-panel-icon-recording",recording:"univer-recording",actionRecorderPanelTitle:"univer-action-recorder-panel-title",actionRecorderPanelActions:"univer-action-recorder-panel-actions"};function ae(){const n=i.useDependency(c.ActionRecorderService);return m.useObservable(n.panelOpened$)?p.jsx(de,{}):null}function de(){var y;const n=i.useDependency(i.ICommandService),t=i.useDependency(c.ActionRecorderService),e=m.useObservable(t.recording$),r=m.useObservable(t.recordedCommands$),o=(y=r==null?void 0:r.length)!=null?y:0,a=C.useCallback(()=>{e||n.executeCommand(q.id)},[n,e]),d=C.useCallback(v=>{e||n.executeCommand(x.id,{replaceId:v})},[n,e]),f=C.useCallback(()=>{e&&n.executeCommand(V.id)},[n,e]),u=C.useCallback(()=>{e&&n.executeCommand(W.id)},[n,e]),R=e?o===0?"Recording...":`${o}: ${r[o-1].id}`:"Start Recording";return p.jsxs("div",{className:O.actionRecorderPanel,children:[p.jsx("div",{className:ce(O.actionRecorderPanelIcon,e?O.actionRecorderPanelIconRecording:!1),children:p.jsx(j,{})}),p.jsx("div",{className:O.actionRecorderPanelTitle,children:R}),p.jsxs("div",{className:O.actionRecorderPanelActions,children:[p.jsx(h.Button,{type:"default",size:"small",onClick:e?u:a,children:e?"Cancel":"Close"}),p.jsx(h.Button,{type:"primary",size:"small",onClick:e?f:()=>d(),children:e?"Save":"Start"}),!e&&p.jsx(h.Button,{type:"primary",size:"small",onClick:()=>d(!0),children:"Start(N)"})]})]})}const H="RECORD_MENU_ITEM";function se(){return{id:H,type:m.MenuItemType.SUBITEMS,icon:"RecordSingle",tooltip:"action-recorder.menu.title"}}function le(n){const t=n.get(c.ActionRecorderService);return{id:D.id,title:"action-recorder.menu.record",type:m.MenuItemType.BUTTON,disabled$:t.panelOpened$}}function me(){return{id:w.id,title:"action-recorder.menu.replay-local",type:m.MenuItemType.BUTTON}}function ue(){return{id:$.id,title:"action-recorder.menu.replay-local-name",type:m.MenuItemType.BUTTON}}function fe(){return{id:U.id,title:"action-recorder.menu.replay-local-active",type:m.MenuItemType.BUTTON}}const ve={[m.RibbonStartGroup.OTHERS]:{[H]:{order:10,menuItemFactory:se,[D.id]:{order:1,menuItemFactory:le},[w.id]:{order:2,menuItemFactory:me},[$.id]:{order:3,menuItemFactory:ue},[U.id]:{order:4,menuItemFactory:fe}}}};var Se=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,pe=(n,t,e,r)=>{for(var o=r>1?void 0:r?ge(t,e):t,a=n.length-1,d;a>=0;a--)(d=n[a])&&(o=(r?d(t,e,o):d(o))||o);return r&&o&&Se(t,e,o),o},_=(n,t)=>(e,r)=>t(e,r,n);let b=class extends i.Disposable{constructor(n,t,e,r,o,a){super(),this._commandSrv=n,this._uiPartsSrv=t,this._menuManagerService=e,this._componentManager=r,this._actionRecorderService=o,this._injector=a,this._initCommands(),this._initUI(),this._initSheetsCommands(),this._initDocsCommands()}_initCommands(){[x,W,V,D,q,w,$,U].forEach(n=>this._commandSrv.registerCommand(n))}_initUI(){this._uiPartsSrv.registerComponent(m.BuiltInUIPart.GLOBAL,()=>i.connectInjector(ae,this._injector)),this._componentManager.register("RecordSingle",j),this._menuManagerService.mergeMenu(ve)}_initSheetsCommands(){[s.CopySheetCommand,s.DeleteRangeMoveLeftCommand,s.DeleteRangeMoveUpCommand,s.DeltaColumnWidthCommand,s.DeltaRowHeightCommand,s.InsertSheetCommand,s.InsertColAfterCommand,s.InsertColBeforeCommand,s.InsertRowAfterCommand,s.InsertRowBeforeCommand,s.RemoveSheetCommand,s.SetStyleCommand,s.AddWorksheetMergeCommand,s.AddWorksheetMergeAllCommand,s.AddWorksheetMergeVerticalCommand,s.AddWorksheetMergeHorizontalCommand,s.SetFrozenCommand,s.CancelFrozenCommand,s.SetHorizontalTextAlignCommand,s.SetOverlineCommand,l.SetRangeBoldCommand,l.SetRangeFontFamilyCommand,l.SetRangeFontSizeCommand,l.SetRangeItalicCommand,l.SetRangeStrickThroughCommand,l.SetRangeSubscriptCommand,l.SetRangeSuperscriptCommand,l.SetRangeTextColorCommand,l.SetRangeUnderlineCommand,s.SetRangeValuesCommand,s.SetStrikeThroughCommand,s.SetTextColorCommand,s.SetTextRotationCommand,s.SetTextWrapCommand,s.SetVerticalTextAlignCommand,l.SheetCopyCommand,l.SheetCutCommand,l.SheetPasteBesidesBorderCommand,l.SheetPasteColWidthCommand,l.SheetPasteCommand,l.SheetPasteFormatCommand,l.SheetPasteShortKeyCommand,l.SheetPasteValueCommand,l.AutoFillCommand,l.RefillCommand,s.SetWorksheetActivateCommand,s.SetWorksheetActiveOperation,s.SetSelectionsOperation,T.SetSheetFilterRangeCommand,T.SetSheetsFilterCriteriaCommand,T.RemoveSheetFilterCommand].forEach(n=>this._actionRecorderService.registerRecordedCommand(n))}_initDocsCommands(){}};b=pe([_(0,i.ICommandService),_(1,m.IUIPartsService),_(2,m.IMenuManagerService),_(3,i.Inject(m.ComponentManager)),_(4,i.Inject(c.ActionRecorderService)),_(5,i.Inject(i.Injector))],b);const Ce="action-recorder.config",J={};var ye=Object.defineProperty,he=Object.getOwnPropertyDescriptor,_e=(n,t,e,r)=>{for(var o=r>1?void 0:r?he(t,e):t,a=n.length-1,d;a>=0;a--)(d=n[a])&&(o=(r?d(t,e,o):d(o))||o);return r&&o&&ye(t,e,o),o},G=(n,t)=>(e,r)=>t(e,r,n);c.UniverActionRecorderPlugin=(F=class extends i.Plugin{constructor(t=J,e,r){super(),this._config=t,this._injector=e,this._configService=r;const{menu:o,...a}=i.merge({},J,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Ce,a)}onStarting(){(this._config.replayOnly?[[c.ActionReplayService]]:[[c.ActionRecorderService],[c.ActionReplayService],[b]]).forEach(e=>this._injector.add(e))}onSteady(){this._config.replayOnly||this._injector.get(b)}},g(F,"pluginName","UNIVER_ACTION_RECORDER_PLUGIN"),F),c.UniverActionRecorderPlugin=_e([G(1,i.Inject(i.Injector)),G(2,i.IConfigService)],c.UniverActionRecorderPlugin),Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/action-recorder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-alpha.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -48,28 +48,28 @@
|
|
|
48
48
|
"lib"
|
|
49
49
|
],
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"react": "
|
|
51
|
+
"react": ">=16.9.0 || >=17 || >=18 || >=19",
|
|
52
52
|
"rxjs": ">=7.0.0"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@univerjs/icons": "^0.2.
|
|
55
|
+
"@univerjs/icons": "^0.2.14",
|
|
56
56
|
"clsx": "^2.1.1",
|
|
57
|
-
"@univerjs/core": "0.
|
|
58
|
-
"@univerjs/sheets": "0.
|
|
59
|
-
"@univerjs/design": "0.
|
|
60
|
-
"@univerjs/sheets-filter": "0.
|
|
61
|
-
"@univerjs/sheets-ui": "0.
|
|
62
|
-
"@univerjs/ui": "0.
|
|
57
|
+
"@univerjs/core": "0.6.0-alpha.0",
|
|
58
|
+
"@univerjs/sheets": "0.6.0-alpha.0",
|
|
59
|
+
"@univerjs/design": "0.6.0-alpha.0",
|
|
60
|
+
"@univerjs/sheets-filter": "0.6.0-alpha.0",
|
|
61
|
+
"@univerjs/sheets-ui": "0.6.0-alpha.0",
|
|
62
|
+
"@univerjs/ui": "0.6.0-alpha.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"less": "^4.2.1",
|
|
66
66
|
"react": "18.3.1",
|
|
67
67
|
"rxjs": "^7.8.1",
|
|
68
68
|
"tailwindcss": "^3.4.17",
|
|
69
|
-
"typescript": "^5.7.
|
|
69
|
+
"typescript": "^5.7.3",
|
|
70
70
|
"vite": "^6.0.7",
|
|
71
71
|
"vitest": "^2.1.8",
|
|
72
|
-
"@univerjs-infra/shared": "0.
|
|
72
|
+
"@univerjs-infra/shared": "0.6.0-alpha.0"
|
|
73
73
|
},
|
|
74
74
|
"scripts": {
|
|
75
75
|
"test": "vitest run",
|