@univerjs/action-recorder 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var J=Object.defineProperty;var G=(e,n,r)=>n in e?J(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r;var f=(e,n,r)=>G(e,typeof n!="symbol"?n+"":n,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),a=require("@univerjs/sheets"),T=require("@univerjs/sheets-filter"),l=require("@univerjs/sheets-ui"),d=require("@univerjs/ui"),A=require("rxjs"),C=require("@univerjs/design"),v=require("react/jsx-runtime"),p=require("react");var S=function(){return S=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},S.apply(this,arguments)},Z=function(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,t=Object.getOwnPropertySymbols(e);o<t.length;o++)n.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o])&&(r[t[o]]=e[t[o]]);return r},L=p.forwardRef(function(e,n){var r=e.icon,t=e.id,o=e.className,c=e.extend,i=Z(e,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(t," ").concat(o||"").trim(),m=p.useRef("_".concat(Q()));return B(r,"".concat(t),{defIds:r.defIds,idSuffix:m.current},S({ref:n,className:u},i),c)});function B(e,n,r,t,o){return p.createElement(e.tag,S(S({key:n},K(e,r,o)),t),(Y(e,r).children||[]).map(function(c,i){return B(c,"".concat(n,"-").concat(e.tag,"-").concat(i),r,void 0,o)}))}function K(e,n,r){var t=S({},e.attrs);r!=null&&r.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=r.colorChannel1);var o=n.defIds;return!o||o.length===0||(e.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(e,n){var r,t=n.defIds;return!t||t.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?S(S({},e),{children:e.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})}):e}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=p.forwardRef(function(e,n){return p.createElement(L,Object.assign({},e,{id:"record-single",ref:n,icon:X}))});U.displayName="RecordSingle";var ee=Object.getOwnPropertyDescriptor,re=(e,n,r,t)=>{for(var o=t>1?void 0:t?ee(n,r):n,c=e.length-1,i;c>=0;c--)(i=e[c])&&(o=i(o)||o);return o},b=(e,n)=>(r,t)=>n(r,t,e);exports.ActionRecorderService=class extends s.Disposable{constructor(r,t,o,c){super();f(this,"_shouldRecordCommands",new Set);f(this,"_panelOpened$",new A.BehaviorSubject(!1));f(this,"panelOpened$",this._panelOpened$.asObservable());f(this,"_recorder",null);f(this,"_recording$",new A.BehaviorSubject(!1));f(this,"recording$",this._recording$.asObservable());f(this,"_recorded$",new A.BehaviorSubject([]));f(this,"_recordedCommands$",new A.BehaviorSubject([]));f(this,"recordedCommands$",this._recordedCommands$.asObservable());this._commandSrv=r,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(r){if(r.type===s.CommandType.MUTATION)throw new Error("[CommandRecorderService] Cannot record mutation commands.");this._shouldRecordCommands.add(r.id)}togglePanel(r){this._panelOpened$.next(r),r===!1&&this.stopRecording()}startRecording(r=!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:g}=m==null?void 0:m.params;if(r&&h&&g){const P=(c=this._instanceService.getUnit(h).getSheetBySheetId(g))==null?void 0:c.getName();m={...m,params:{...m.params,subUnitId:P}}}m.id===a.SetSelectionsOperation.id&&i.length>0&&i[i.length-1].id===a.SetSelectionsOperation.id?i[i.length-1]=m:(i.push(m),this._recorded$.next(i),m.type===s.CommandType.COMMAND&&(u.push(m),this._recordedCommands$.next(u)))}}),this._recording$.next(!0)}stopRecording(){var r;(r=this._recorder)==null||r.dispose(),this._recorder=null,this._recorded$.next([]),this._recordedCommands$.next([]),this._recording$.next(!1)}completeRecording(){const r=this._recorded.slice();this._localFileService.downloadFile(new Blob([JSON.stringify(r,null,2)]),"recorded-commands.json"),this._logService.error("Recorded commands:",r),this.stopRecording()}};exports.ActionRecorderService=re([b(0,s.ICommandService),b(1,s.ILogService),b(2,d.ILocalFileService),b(3,s.IUniverInstanceService)],exports.ActionRecorderService);const k={id:"action-recorder.command.start-recording",type:s.CommandType.COMMAND,handler:(e,n)=>(e.get(exports.ActionRecorderService).startRecording(!!(n!=null&&n.replaceId)),!0)},V={id:"action-recorder.command.complete-recording",type:s.CommandType.COMMAND,handler:e=>(e.get(exports.ActionRecorderService).completeRecording(),!0)},W={id:"action-recorder.command.stop-recording",type:s.CommandType.COMMAND,handler:e=>(e.get(exports.ActionRecorderService).completeRecording(),!0)};var te=Object.getOwnPropertyDescriptor,ne=(e,n,r,t)=>{for(var o=t>1?void 0:t?te(n,r):n,c=e.length-1,i;c>=0;c--)(i=e[c])&&(o=i(o)||o);return o},I=(e,n)=>(r,t)=>n(r,t,e),N=(e=>(e.DEFAULT="default",e.NAME="name",e.ACTIVE="active",e))(N||{});exports.ActionReplayService=class extends s.Disposable{constructor(n,r,t,o,c){super(),this._messageService=n,this._instanceService=r,this._localFileService=t,this._logService=o,this._commandService=c}async replayLocalJSON(n="default"){const r=await this._localFileService.openFile({multiple:!1,accept:".json"});if(r.length!==1)return!1;const t=r[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,r){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}=r||{};for(const m of n){const{id:y,params:h}=m,g=h;if(g){if(typeof g.unitId<"u"&&(g.unitId=t),o==="name"&&g.subUnitId!=="undefined"){const _=(i=this._instanceService.getFocusedUnit().getSheetBySheetName(g.subUnitId))==null?void 0:i.getSheetId();_?g.subUnitId=_:this._logService.error("[ReplayService]",`failed to find subunit by subUnitName = ${g.subUnitId}`)}if(o==="active"&&g.subUnitId!=="undefined"){const _=(u=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:u.getSheetId();_?g.subUnitId=_: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 r=(t=this._instanceService.getFocusedUnit())==null?void 0:t.getUnitId();r||this._logService.error("[ReplayService]","no focused unit to replay commands");for(const o of n){await s.awaitTime(oe());const{id:c,params:i}=o;if(i){if(typeof i.unitId<"u"&&(i.unitId=r),!await this._commandService.executeCommand(c,i))return!1}else if(!await this._commandService.executeCommand(c))return!1}return!0}};exports.ActionReplayService=ne([I(0,d.IMessageService),I(1,s.IUniverInstanceService),I(2,d.ILocalFileService),I(3,s.ILogService),I(4,s.ICommandService)],exports.ActionReplayService);function oe(){return Math.floor(Math.random()*800)+200}const j={id:"action-recorder.command.replay-local-records",type:s.CommandType.COMMAND,handler:async e=>{const r=await e.get(exports.ActionReplayService).replayLocalJSON();return r&&e.get(d.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),r}},w={id:"action-recorder.command.replay-local-records-name",type:s.CommandType.COMMAND,handler:async e=>{const r=await e.get(exports.ActionReplayService).replayLocalJSON(N.NAME);return r&&e.get(d.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),r}},$={id:"action-recorder.command.replay-local-records-active",type:s.CommandType.COMMAND,handler:async e=>{const r=await e.get(exports.ActionReplayService).replayLocalJSON(N.ACTIVE);return r&&e.get(d.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),r}},F={id:"action-recorder.operation.open-panel",type:s.CommandType.OPERATION,handler(e){return e.get(exports.ActionRecorderService).togglePanel(!0),!0}},q={id:"action-recorder.operation.close-panel",type:s.CommandType.OPERATION,handler(e){return e.get(exports.ActionRecorderService).togglePanel(!1),!0}};function z(e){var n,r,t="";if(typeof e=="string"||typeof e=="number")t+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(n=0;n<o;n++)e[n]&&(r=z(e[n]))&&(t&&(t+=" "),t+=r)}else for(r in e)e[r]&&(t&&(t+=" "),t+=r);return t}function ce(){for(var e,n,r=0,t="",o=arguments.length;r<o;r++)(e=arguments[r])&&(n=z(e))&&(t&&(t+=" "),t+=n);return t}const ie="univer-action-recorder-panel",ae="univer-action-recorder-panel-icon",se="univer-action-recorder-panel-icon-recording",de="univer-action-recorder-panel-title",le="univer-action-recorder-panel-actions",O={actionRecorderPanel:ie,actionRecorderPanelIcon:ae,actionRecorderPanelIconRecording:se,actionRecorderPanelTitle:de,actionRecorderPanelActions:le};function me(){const e=d.useDependency(exports.ActionRecorderService);return d.useObservable(e.panelOpened$)?v.jsx(ue,{}):null}function ue(){var h;const e=d.useDependency(s.ICommandService),n=d.useDependency(exports.ActionRecorderService),r=d.useObservable(n.recording$),t=d.useObservable(n.recordedCommands$),o=(h=t==null?void 0:t.length)!=null?h:0,c=p.useCallback(()=>{r||e.executeCommand(q.id)},[e,r]),i=p.useCallback(g=>{r||e.executeCommand(k.id,{replaceId:g})},[e,r]),u=p.useCallback(()=>{r&&e.executeCommand(V.id)},[e,r]),m=p.useCallback(()=>{r&&e.executeCommand(W.id)},[e,r]),y=r?o===0?"Recording...":`${o}: ${t[o-1].id}`:"Start Recording";return v.jsxs("div",{className:O.actionRecorderPanel,children:[v.jsx("div",{className:ce(O.actionRecorderPanelIcon,r?O.actionRecorderPanelIconRecording:!1),children:v.jsx(U,{})}),v.jsx("div",{className:O.actionRecorderPanelTitle,children:y}),v.jsxs("div",{className:O.actionRecorderPanelActions,children:[v.jsx(C.Button,{type:"default",size:"small",onClick:r?m:c,children:r?"Cancel":"Close"}),v.jsx(C.Button,{type:"primary",size:"small",onClick:r?u:()=>i(),children:r?"Save":"Start"}),!r&&v.jsx(C.Button,{type:"primary",size:"small",onClick:()=>i(!0),children:"Start(N)"})]})]})}const H="RECORD_MENU_ITEM";function ge(){return{id:H,type:d.MenuItemType.SUBITEMS,icon:"RecordSingle",tooltip:"action-recorder.menu.title"}}function Se(e){const n=e.get(exports.ActionRecorderService);return{id:F.id,title:"action-recorder.menu.record",type:d.MenuItemType.BUTTON,disabled$:n.panelOpened$}}function fe(){return{id:j.id,title:"action-recorder.menu.replay-local",type:d.MenuItemType.BUTTON}}function ve(){return{id:w.id,title:"action-recorder.menu.replay-local-name",type:d.MenuItemType.BUTTON}}function pe(){return{id:$.id,title:"action-recorder.menu.replay-local-active",type:d.MenuItemType.BUTTON}}const he={[d.RibbonStartGroup.OTHERS]:{[H]:{order:10,menuItemFactory:ge,[F.id]:{order:1,menuItemFactory:Se},[j.id]:{order:2,menuItemFactory:fe},[w.id]:{order:3,menuItemFactory:ve},[$.id]:{order:4,menuItemFactory:pe}}}};var Ce=Object.getOwnPropertyDescriptor,ye=(e,n,r,t)=>{for(var o=t>1?void 0:t?Ce(n,r):n,c=e.length-1,i;c>=0;c--)(i=e[c])&&(o=i(o)||o);return o},R=(e,n)=>(r,t)=>n(r,t,e);let M=class extends s.Disposable{constructor(e,n,r,t,o,c){super(),this._commandSrv=e,this._uiPartsSrv=n,this._menuManagerService=r,this._componentManager=t,this._actionRecorderService=o,this._injector=c,this._initCommands(),this._initUI(),this._initSheetsCommands(),this._initDocsCommands()}_initCommands(){[k,W,V,F,q,j,w,$].forEach(e=>this._commandSrv.registerCommand(e))}_initUI(){this._uiPartsSrv.registerComponent(d.BuiltInUIPart.GLOBAL,()=>d.connectInjector(me,this._injector)),this._componentManager.register("RecordSingle",U),this._menuManagerService.mergeMenu(he)}_initSheetsCommands(){[a.CopySheetCommand,a.DeleteRangeMoveLeftCommand,a.DeleteRangeMoveUpCommand,a.DeltaColumnWidthCommand,a.DeltaRowHeightCommand,a.InsertSheetCommand,a.InsertColAfterCommand,a.InsertColBeforeCommand,a.InsertRowAfterCommand,a.InsertRowBeforeCommand,a.RemoveSheetCommand,a.SetStyleCommand,a.AddWorksheetMergeCommand,a.AddWorksheetMergeAllCommand,a.AddWorksheetMergeVerticalCommand,a.AddWorksheetMergeHorizontalCommand,a.SetFrozenCommand,a.CancelFrozenCommand,a.SetHorizontalTextAlignCommand,a.SetOverlineCommand,l.SetRangeBoldCommand,l.SetRangeFontFamilyCommand,l.SetRangeFontSizeCommand,l.SetRangeItalicCommand,l.SetRangeStrickThroughCommand,l.SetRangeSubscriptCommand,l.SetRangeSuperscriptCommand,l.SetRangeTextColorCommand,l.SetRangeUnderlineCommand,a.SetRangeValuesCommand,a.SetStrikeThroughCommand,a.SetTextColorCommand,a.SetTextRotationCommand,a.SetTextWrapCommand,a.SetVerticalTextAlignCommand,l.SheetCopyCommand,l.SheetCutCommand,l.SheetPasteBesidesBorderCommand,l.SheetPasteColWidthCommand,l.SheetPasteCommand,l.SheetPasteFormatCommand,l.SheetPasteShortKeyCommand,l.SheetPasteValueCommand,l.AutoFillCommand,l.RefillCommand,a.SetWorksheetActivateCommand,a.SetWorksheetActiveOperation,a.SetSelectionsOperation,T.SetSheetFilterRangeCommand,T.SetSheetsFilterCriteriaCommand,T.RemoveSheetFilterCommand].forEach(e=>this._actionRecorderService.registerRecordedCommand(e))}_initDocsCommands(){}};M=ye([R(0,s.ICommandService),R(1,d.IUIPartsService),R(2,d.IMenuManagerService),R(3,s.Inject(d.ComponentManager)),R(4,s.Inject(exports.ActionRecorderService)),R(5,s.Inject(s.Injector))],M);const Re="action-recorder.config",D={};var _e=Object.getOwnPropertyDescriptor,Ie=(e,n,r,t)=>{for(var o=t>1?void 0:t?_e(n,r):n,c=e.length-1,i;c>=0;c--)(i=e[c])&&(o=i(o)||o);return o},E=(e,n)=>(r,t)=>n(r,t,e),x;exports.UniverActionRecorderPlugin=(x=class extends s.Plugin{constructor(n=D,r,t){super(),this._config=n,this._injector=r,this._configService=t;const{menu:o,...c}=s.merge({},D,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Re,c)}onStarting(){(this._config.replayOnly?[[exports.ActionReplayService]]:[[exports.ActionRecorderService],[exports.ActionReplayService],[M]]).forEach(r=>this._injector.add(r))}onSteady(){this._config.replayOnly||this._injector.get(M)}},f(x,"pluginName","UNIVER_ACTION_RECORDER_PLUGIN"),x);exports.UniverActionRecorderPlugin=Ie([E(1,s.Inject(s.Injector)),E(2,s.IConfigService)],exports.UniverActionRecorderPlugin);
1
+ "use strict";var J=Object.defineProperty;var G=(e,n,r)=>n in e?J(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r;var S=(e,n,r)=>G(e,typeof n!="symbol"?n+"":n,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),a=require("@univerjs/sheets"),x=require("@univerjs/sheets-filter"),l=require("@univerjs/sheets-ui"),d=require("@univerjs/ui"),A=require("rxjs"),C=require("@univerjs/design"),v=require("react/jsx-runtime"),p=require("react");var f=function(){return f=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},f.apply(this,arguments)},Z=function(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,t=Object.getOwnPropertySymbols(e);o<t.length;o++)n.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o])&&(r[t[o]]=e[t[o]]);return r},L=p.forwardRef(function(e,n){var r=e.icon,t=e.id,o=e.className,c=e.extend,i=Z(e,["icon","id","className","extend"]),m="univerjs-icon univerjs-icon-".concat(t," ").concat(o||"").trim(),u=p.useRef("_".concat(Q()));return B(r,"".concat(t),{defIds:r.defIds,idSuffix:u.current},f({ref:n,className:m},i),c)});function B(e,n,r,t,o){return p.createElement(e.tag,f(f({key:n},K(e,r,o)),t),(Y(e,r).children||[]).map(function(c,i){return B(c,"".concat(n,"-").concat(e.tag,"-").concat(i),r,void 0,o)}))}function K(e,n,r){var t=f({},e.attrs);r!=null&&r.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=r.colorChannel1),e.tag==="mask"&&t.id&&(t.id=t.id+n.idSuffix),Object.entries(t).forEach(function(c){var i=c[0],m=c[1];i==="mask"&&typeof m=="string"&&(t[i]=m.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))});var o=n.defIds;return!o||o.length===0||(e.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+n.idSuffix),Object.entries(t).forEach(function(c){var i=c[0],m=c[1];typeof m=="string"&&(t[i]=m.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),t}function Y(e,n){var r,t=n.defIds;return!t||t.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?f(f({},e),{children:e.children.map(function(o){return typeof o.attrs.id=="string"&&t&&t.indexOf(o.attrs.id)>-1?f(f({},o),{attrs:f(f({},o.attrs),{id:o.attrs.id+n.idSuffix})}):o})}):e}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=p.forwardRef(function(e,n){return p.createElement(L,Object.assign({},e,{id:"record-single",ref:n,icon:X}))});U.displayName="RecordSingle";var ee=Object.getOwnPropertyDescriptor,re=(e,n,r,t)=>{for(var o=t>1?void 0:t?ee(n,r):n,c=e.length-1,i;c>=0;c--)(i=e[c])&&(o=i(o)||o);return o},b=(e,n)=>(r,t)=>n(r,t,e);exports.ActionRecorderService=class extends s.Disposable{constructor(r,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=r,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(r){if(r.type===s.CommandType.MUTATION)throw new Error("[CommandRecorderService] Cannot record mutation commands.");this._shouldRecordCommands.add(r.id)}togglePanel(r){this._panelOpened$.next(r),r===!1&&this.stopRecording()}startRecording(r=!1){this._recorder=this._commandSrv.onCommandExecuted(t=>{var o,c;if(this._shouldRecordCommands.has(t.id)){const i=this._recorded,m=this._recordedCommands;let u={...t};const y=(o=this._instanceService.getFocusedUnit())==null?void 0:o.getUnitId(),{unitId:h=y,subUnitId:g}=u==null?void 0:u.params;if(r&&h&&g){const P=(c=this._instanceService.getUnit(h).getSheetBySheetId(g))==null?void 0:c.getName();u={...u,params:{...u.params,subUnitId:P}}}u.id===a.SetSelectionsOperation.id&&i.length>0&&i[i.length-1].id===a.SetSelectionsOperation.id?i[i.length-1]=u:(i.push(u),this._recorded$.next(i),u.type===s.CommandType.COMMAND&&(m.push(u),this._recordedCommands$.next(m)))}}),this._recording$.next(!0)}stopRecording(){var r;(r=this._recorder)==null||r.dispose(),this._recorder=null,this._recorded$.next([]),this._recordedCommands$.next([]),this._recording$.next(!1)}completeRecording(){const r=this._recorded.slice();this._localFileService.downloadFile(new Blob([JSON.stringify(r,null,2)]),"recorded-commands.json"),this._logService.error("Recorded commands:",r),this.stopRecording()}};exports.ActionRecorderService=re([b(0,s.ICommandService),b(1,s.ILogService),b(2,d.ILocalFileService),b(3,s.IUniverInstanceService)],exports.ActionRecorderService);const k={id:"action-recorder.command.start-recording",type:s.CommandType.COMMAND,handler:(e,n)=>(e.get(exports.ActionRecorderService).startRecording(!!(n!=null&&n.replaceId)),!0)},V={id:"action-recorder.command.complete-recording",type:s.CommandType.COMMAND,handler:e=>(e.get(exports.ActionRecorderService).completeRecording(),!0)},W={id:"action-recorder.command.stop-recording",type:s.CommandType.COMMAND,handler:e=>(e.get(exports.ActionRecorderService).completeRecording(),!0)};var te=Object.getOwnPropertyDescriptor,ne=(e,n,r,t)=>{for(var o=t>1?void 0:t?te(n,r):n,c=e.length-1,i;c>=0;c--)(i=e[c])&&(o=i(o)||o);return o},I=(e,n)=>(r,t)=>n(r,t,e),N=(e=>(e.DEFAULT="default",e.NAME="name",e.ACTIVE="active",e))(N||{});exports.ActionReplayService=class extends s.Disposable{constructor(n,r,t,o,c){super(),this._messageService=n,this._instanceService=r,this._localFileService=t,this._logService=o,this._commandService=c}async replayLocalJSON(n="default"){const r=await this._localFileService.openFile({multiple:!1,accept:".json"});if(r.length!==1)return!1;const t=r[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,r){var c,i,m;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}=r||{};for(const u of n){const{id:y,params:h}=u,g=h;if(g){if(typeof g.unitId<"u"&&(g.unitId=t),o==="name"&&g.subUnitId!=="undefined"){const _=(i=this._instanceService.getFocusedUnit().getSheetBySheetName(g.subUnitId))==null?void 0:i.getSheetId();_?g.subUnitId=_:this._logService.error("[ReplayService]",`failed to find subunit by subUnitName = ${g.subUnitId}`)}if(o==="active"&&g.subUnitId!=="undefined"){const _=(m=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:m.getSheetId();_?g.subUnitId=_: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 r=(t=this._instanceService.getFocusedUnit())==null?void 0:t.getUnitId();r||this._logService.error("[ReplayService]","no focused unit to replay commands");for(const o of n){await s.awaitTime(oe());const{id:c,params:i}=o;if(i){if(typeof i.unitId<"u"&&(i.unitId=r),!await this._commandService.executeCommand(c,i))return!1}else if(!await this._commandService.executeCommand(c))return!1}return!0}};exports.ActionReplayService=ne([I(0,d.IMessageService),I(1,s.IUniverInstanceService),I(2,d.ILocalFileService),I(3,s.ILogService),I(4,s.ICommandService)],exports.ActionReplayService);function oe(){return Math.floor(Math.random()*800)+200}const j={id:"action-recorder.command.replay-local-records",type:s.CommandType.COMMAND,handler:async e=>{const r=await e.get(exports.ActionReplayService).replayLocalJSON();return r&&e.get(d.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),r}},w={id:"action-recorder.command.replay-local-records-name",type:s.CommandType.COMMAND,handler:async e=>{const r=await e.get(exports.ActionReplayService).replayLocalJSON(N.NAME);return r&&e.get(d.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),r}},$={id:"action-recorder.command.replay-local-records-active",type:s.CommandType.COMMAND,handler:async e=>{const r=await e.get(exports.ActionReplayService).replayLocalJSON(N.ACTIVE);return r&&e.get(d.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),r}},F={id:"action-recorder.operation.open-panel",type:s.CommandType.OPERATION,handler(e){return e.get(exports.ActionRecorderService).togglePanel(!0),!0}},q={id:"action-recorder.operation.close-panel",type:s.CommandType.OPERATION,handler(e){return e.get(exports.ActionRecorderService).togglePanel(!1),!0}};function z(e){var n,r,t="";if(typeof e=="string"||typeof e=="number")t+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(n=0;n<o;n++)e[n]&&(r=z(e[n]))&&(t&&(t+=" "),t+=r)}else for(r in e)e[r]&&(t&&(t+=" "),t+=r);return t}function ce(){for(var e,n,r=0,t="",o=arguments.length;r<o;r++)(e=arguments[r])&&(n=z(e))&&(t&&(t+=" "),t+=n);return t}const ie="univer-action-recorder-panel",ae="univer-action-recorder-panel-icon",se="univer-action-recorder-panel-icon-recording",de="univer-action-recorder-panel-title",le="univer-action-recorder-panel-actions",O={actionRecorderPanel:ie,actionRecorderPanelIcon:ae,actionRecorderPanelIconRecording:se,actionRecorderPanelTitle:de,actionRecorderPanelActions:le};function me(){const e=d.useDependency(exports.ActionRecorderService);return d.useObservable(e.panelOpened$)?v.jsx(ue,{}):null}function ue(){var h;const e=d.useDependency(s.ICommandService),n=d.useDependency(exports.ActionRecorderService),r=d.useObservable(n.recording$),t=d.useObservable(n.recordedCommands$),o=(h=t==null?void 0:t.length)!=null?h:0,c=p.useCallback(()=>{r||e.executeCommand(q.id)},[e,r]),i=p.useCallback(g=>{r||e.executeCommand(k.id,{replaceId:g})},[e,r]),m=p.useCallback(()=>{r&&e.executeCommand(V.id)},[e,r]),u=p.useCallback(()=>{r&&e.executeCommand(W.id)},[e,r]),y=r?o===0?"Recording...":`${o}: ${t[o-1].id}`:"Start Recording";return v.jsxs("div",{className:O.actionRecorderPanel,children:[v.jsx("div",{className:ce(O.actionRecorderPanelIcon,r?O.actionRecorderPanelIconRecording:!1),children:v.jsx(U,{})}),v.jsx("div",{className:O.actionRecorderPanelTitle,children:y}),v.jsxs("div",{className:O.actionRecorderPanelActions,children:[v.jsx(C.Button,{type:"default",size:"small",onClick:r?u:c,children:r?"Cancel":"Close"}),v.jsx(C.Button,{type:"primary",size:"small",onClick:r?m:()=>i(),children:r?"Save":"Start"}),!r&&v.jsx(C.Button,{type:"primary",size:"small",onClick:()=>i(!0),children:"Start(N)"})]})]})}const H="RECORD_MENU_ITEM";function ge(){return{id:H,type:d.MenuItemType.SUBITEMS,icon:"RecordSingle",tooltip:"action-recorder.menu.title"}}function fe(e){const n=e.get(exports.ActionRecorderService);return{id:F.id,title:"action-recorder.menu.record",type:d.MenuItemType.BUTTON,disabled$:n.panelOpened$}}function Se(){return{id:j.id,title:"action-recorder.menu.replay-local",type:d.MenuItemType.BUTTON}}function ve(){return{id:w.id,title:"action-recorder.menu.replay-local-name",type:d.MenuItemType.BUTTON}}function pe(){return{id:$.id,title:"action-recorder.menu.replay-local-active",type:d.MenuItemType.BUTTON}}const he={[d.RibbonStartGroup.OTHERS]:{[H]:{order:10,menuItemFactory:ge,[F.id]:{order:1,menuItemFactory:fe},[j.id]:{order:2,menuItemFactory:Se},[w.id]:{order:3,menuItemFactory:ve},[$.id]:{order:4,menuItemFactory:pe}}}};var Ce=Object.getOwnPropertyDescriptor,ye=(e,n,r,t)=>{for(var o=t>1?void 0:t?Ce(n,r):n,c=e.length-1,i;c>=0;c--)(i=e[c])&&(o=i(o)||o);return o},R=(e,n)=>(r,t)=>n(r,t,e);let M=class extends s.Disposable{constructor(e,n,r,t,o,c){super(),this._commandSrv=e,this._uiPartsSrv=n,this._menuManagerService=r,this._componentManager=t,this._actionRecorderService=o,this._injector=c,this._initCommands(),this._initUI(),this._initSheetsCommands(),this._initDocsCommands()}_initCommands(){[k,W,V,F,q,j,w,$].forEach(e=>this._commandSrv.registerCommand(e))}_initUI(){this._uiPartsSrv.registerComponent(d.BuiltInUIPart.GLOBAL,()=>d.connectInjector(me,this._injector)),this._componentManager.register("RecordSingle",U),this._menuManagerService.mergeMenu(he)}_initSheetsCommands(){[a.CopySheetCommand,a.DeleteRangeMoveLeftCommand,a.DeleteRangeMoveUpCommand,a.DeltaColumnWidthCommand,a.DeltaRowHeightCommand,a.InsertSheetCommand,a.InsertColAfterCommand,a.InsertColBeforeCommand,a.InsertRowAfterCommand,a.InsertRowBeforeCommand,a.RemoveSheetCommand,a.SetStyleCommand,a.AddWorksheetMergeCommand,a.AddWorksheetMergeAllCommand,a.AddWorksheetMergeVerticalCommand,a.AddWorksheetMergeHorizontalCommand,a.SetFrozenCommand,a.CancelFrozenCommand,a.SetHorizontalTextAlignCommand,a.SetOverlineCommand,l.SetRangeBoldCommand,l.SetRangeFontFamilyCommand,l.SetRangeFontSizeCommand,l.SetRangeItalicCommand,l.SetRangeStrickThroughCommand,l.SetRangeSubscriptCommand,l.SetRangeSuperscriptCommand,l.SetRangeTextColorCommand,l.SetRangeUnderlineCommand,a.SetRangeValuesCommand,a.SetStrikeThroughCommand,a.SetTextColorCommand,a.SetTextRotationCommand,a.SetTextWrapCommand,a.SetVerticalTextAlignCommand,l.SheetCopyCommand,l.SheetCutCommand,l.SheetPasteBesidesBorderCommand,l.SheetPasteColWidthCommand,l.SheetPasteCommand,l.SheetPasteFormatCommand,l.SheetPasteShortKeyCommand,l.SheetPasteValueCommand,l.AutoFillCommand,l.RefillCommand,a.SetWorksheetActivateCommand,a.SetWorksheetActiveOperation,a.SetSelectionsOperation,x.SetSheetFilterRangeCommand,x.SetSheetsFilterCriteriaCommand,x.RemoveSheetFilterCommand].forEach(e=>this._actionRecorderService.registerRecordedCommand(e))}_initDocsCommands(){}};M=ye([R(0,s.ICommandService),R(1,d.IUIPartsService),R(2,d.IMenuManagerService),R(3,s.Inject(d.ComponentManager)),R(4,s.Inject(exports.ActionRecorderService)),R(5,s.Inject(s.Injector))],M);const Re="action-recorder.config",D={};var _e=Object.getOwnPropertyDescriptor,Ie=(e,n,r,t)=>{for(var o=t>1?void 0:t?_e(n,r):n,c=e.length-1,i;c>=0;c--)(i=e[c])&&(o=i(o)||o);return o},E=(e,n)=>(r,t)=>n(r,t,e),T;exports.UniverActionRecorderPlugin=(T=class extends s.Plugin{constructor(n=D,r,t){super(),this._config=n,this._injector=r,this._configService=t;const{menu:o,...c}=s.merge({},D,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Re,c)}onStarting(){(this._config.replayOnly?[[exports.ActionReplayService]]:[[exports.ActionRecorderService],[exports.ActionReplayService],[M]]).forEach(r=>this._injector.add(r))}onSteady(){this._config.replayOnly||this._injector.get(M)}},S(T,"pluginName","UNIVER_ACTION_RECORDER_PLUGIN"),T);exports.UniverActionRecorderPlugin=Ie([E(1,s.Inject(s.Injector)),E(2,s.IConfigService)],exports.UniverActionRecorderPlugin);
package/lib/es/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  var ae = Object.defineProperty;
2
2
  var se = (e, t, r) => t in e ? ae(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
3
  var m = (e, t, r) => se(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { Disposable as D, CommandType as u, ICommandService as A, ILogService as G, IUniverInstanceService as Z, awaitTime as de, Inject as M, Injector as K, IConfigService as le, Plugin as me, merge as ue } from "@univerjs/core";
5
- import { SetSelectionsOperation as $, CopySheetCommand as fe, DeleteRangeMoveLeftCommand as ge, DeleteRangeMoveUpCommand as he, DeltaColumnWidthCommand as pe, DeltaRowHeightCommand as Se, InsertSheetCommand as ve, InsertColAfterCommand as Ce, InsertColBeforeCommand as _e, InsertRowAfterCommand as ye, InsertRowBeforeCommand as Re, RemoveSheetCommand as Ie, SetStyleCommand as Oe, AddWorksheetMergeCommand as Pe, AddWorksheetMergeAllCommand as Me, AddWorksheetMergeVerticalCommand as be, AddWorksheetMergeHorizontalCommand as Ae, SetFrozenCommand as Ne, CancelFrozenCommand as Ue, SetHorizontalTextAlignCommand as xe, SetOverlineCommand as we, SetRangeValuesCommand as $e, SetStrikeThroughCommand as Te, SetTextColorCommand as Fe, SetTextRotationCommand as De, SetTextWrapCommand as Ee, SetVerticalTextAlignCommand as je, SetWorksheetActivateCommand as Le, SetWorksheetActiveOperation as Be } from "@univerjs/sheets";
4
+ import { Disposable as E, CommandType as u, ICommandService as A, ILogService as G, IUniverInstanceService as Z, awaitTime as de, Inject as M, Injector as K, IConfigService as le, Plugin as me, merge as ue } from "@univerjs/core";
5
+ import { SetSelectionsOperation as $, CopySheetCommand as fe, DeleteRangeMoveLeftCommand as ge, DeleteRangeMoveUpCommand as he, DeltaColumnWidthCommand as pe, DeltaRowHeightCommand as Se, InsertSheetCommand as ve, InsertColAfterCommand as Ce, InsertColBeforeCommand as _e, InsertRowAfterCommand as ye, InsertRowBeforeCommand as Re, RemoveSheetCommand as Ie, SetStyleCommand as Oe, AddWorksheetMergeCommand as Pe, AddWorksheetMergeAllCommand as Me, AddWorksheetMergeVerticalCommand as be, AddWorksheetMergeHorizontalCommand as Ae, SetFrozenCommand as Ne, CancelFrozenCommand as xe, SetHorizontalTextAlignCommand as Ue, SetOverlineCommand as we, SetRangeValuesCommand as $e, SetStrikeThroughCommand as Te, SetTextColorCommand as Fe, SetTextRotationCommand as Ee, SetTextWrapCommand as De, SetVerticalTextAlignCommand as je, SetWorksheetActivateCommand as Le, SetWorksheetActiveOperation as Be } from "@univerjs/sheets";
6
6
  import { SetSheetFilterRangeCommand as ke, SetSheetsFilterCriteriaCommand as Ve, RemoveSheetFilterCommand as We } from "@univerjs/sheets-filter";
7
7
  import { SetRangeBoldCommand as ze, SetRangeFontFamilyCommand as He, SetRangeFontSizeCommand as Je, SetRangeItalicCommand as Ge, SetRangeStrickThroughCommand as Ze, SetRangeSubscriptCommand as Ke, SetRangeSuperscriptCommand as Ye, SetRangeTextColorCommand as qe, SetRangeUnderlineCommand as Qe, SheetCopyCommand as Xe, SheetCutCommand as et, SheetPasteBesidesBorderCommand as tt, SheetPasteColWidthCommand as rt, SheetPasteCommand as nt, SheetPasteFormatCommand as ot, SheetPasteShortKeyCommand as it, SheetPasteValueCommand as ct, AutoFillCommand as at, RefillCommand as st } from "@univerjs/sheets-ui";
8
8
  import { ILocalFileService as Y, IMessageService as N, useDependency as T, useObservable as F, RibbonStartGroup as dt, MenuItemType as R, IUIPartsService as lt, IMenuManagerService as mt, ComponentManager as ut, BuiltInUIPart as ft, connectInjector as gt } from "@univerjs/ui";
9
9
  import { BehaviorSubject as I } from "rxjs";
10
- import { MessageType as U, Button as x } from "@univerjs/design";
10
+ import { MessageType as x, Button as U } from "@univerjs/design";
11
11
  import { jsx as h, jsxs as W } from "react/jsx-runtime";
12
12
  import { forwardRef as q, useRef as ht, createElement as Q, useCallback as O } from "react";
13
13
  var d = function() {
@@ -36,7 +36,10 @@ function ee(e, t, r, n, o) {
36
36
  }
37
37
  function St(e, t, r) {
38
38
  var n = d({}, e.attrs);
39
- r != null && r.colorChannel1 && n.fill === "colorChannel1" && (n.fill = r.colorChannel1);
39
+ r != null && r.colorChannel1 && n.fill === "colorChannel1" && (n.fill = r.colorChannel1), e.tag === "mask" && n.id && (n.id = n.id + t.idSuffix), Object.entries(n).forEach(function(i) {
40
+ var c = i[0], a = i[1];
41
+ c === "mask" && typeof a == "string" && (n[c] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
42
+ });
40
43
  var o = t.defIds;
41
44
  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) {
42
45
  var c = i[0], a = i[1];
@@ -53,20 +56,20 @@ function Ct() {
53
56
  return Math.random().toString(36).substring(2, 8);
54
57
  }
55
58
  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"] }, E = q(function(e, t) {
59
+ 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
60
  return Q(X, Object.assign({}, e, {
58
61
  id: "record-single",
59
62
  ref: t,
60
63
  icon: _t
61
64
  }));
62
65
  });
63
- E.displayName = "RecordSingle";
66
+ D.displayName = "RecordSingle";
64
67
  var yt = Object.getOwnPropertyDescriptor, Rt = (e, t, r, n) => {
65
68
  for (var o = n > 1 ? void 0 : n ? yt(t, r) : t, i = e.length - 1, c; i >= 0; i--)
66
69
  (c = e[i]) && (o = c(o) || o);
67
70
  return o;
68
71
  }, P = (e, t) => (r, n) => t(r, n, e);
69
- let l = class extends D {
72
+ let l = class extends E {
70
73
  constructor(t, r, n, o) {
71
74
  super();
72
75
  m(this, "_shouldRecordCommands", /* @__PURE__ */ new Set());
@@ -150,7 +153,7 @@ var It = Object.getOwnPropertyDescriptor, Ot = (e, t, r, n) => {
150
153
  (c = e[i]) && (o = c(o) || o);
151
154
  return o;
152
155
  }, _ = (e, t) => (r, n) => t(r, n, e), j = /* @__PURE__ */ ((e) => (e.DEFAULT = "default", e.NAME = "name", e.ACTIVE = "active", e))(j || {});
153
- let p = class extends D {
156
+ let p = class extends E {
154
157
  constructor(e, t, r, n, o) {
155
158
  super(), this._messageService = e, this._instanceService = t, this._localFileService = r, this._logService = n, this._commandService = o;
156
159
  }
@@ -165,7 +168,7 @@ let p = class extends D {
165
168
  return this.replayCommands(JSON.parse(await r.text()), { mode: e });
166
169
  } catch {
167
170
  return this._messageService.show({
168
- type: U.Error,
171
+ type: x.Error,
169
172
  content: `Failed to replay commands from local file ${r.name}.`
170
173
  }), !1;
171
174
  }
@@ -230,7 +233,7 @@ const L = {
230
233
  handler: async (e) => {
231
234
  const r = await e.get(p).replayLocalJSON();
232
235
  return r && e.get(N).show({
233
- type: U.Success,
236
+ type: x.Success,
234
237
  content: "Successfully replayed local records"
235
238
  }), r;
236
239
  }
@@ -240,7 +243,7 @@ const L = {
240
243
  handler: async (e) => {
241
244
  const r = await e.get(p).replayLocalJSON(j.NAME);
242
245
  return r && e.get(N).show({
243
- type: U.Success,
246
+ type: x.Success,
244
247
  content: "Successfully replayed local records"
245
248
  }), r;
246
249
  }
@@ -250,7 +253,7 @@ const L = {
250
253
  handler: async (e) => {
251
254
  const r = await e.get(p).replayLocalJSON(j.ACTIVE);
252
255
  return r && e.get(N).show({
253
- type: U.Success,
256
+ type: x.Success,
254
257
  content: "Successfully replayed local records"
255
258
  }), r;
256
259
  }
@@ -280,12 +283,12 @@ function Mt() {
280
283
  for (var e, t, r = 0, n = "", o = arguments.length; r < o; r++) (e = arguments[r]) && (t = ie(e)) && (n && (n += " "), n += t);
281
284
  return n;
282
285
  }
283
- const bt = "univer-action-recorder-panel", At = "univer-action-recorder-panel-icon", Nt = "univer-action-recorder-panel-icon-recording", Ut = "univer-action-recorder-panel-title", xt = "univer-action-recorder-panel-actions", y = {
286
+ const bt = "univer-action-recorder-panel", At = "univer-action-recorder-panel-icon", Nt = "univer-action-recorder-panel-icon-recording", xt = "univer-action-recorder-panel-title", Ut = "univer-action-recorder-panel-actions", y = {
284
287
  actionRecorderPanel: bt,
285
288
  actionRecorderPanelIcon: At,
286
289
  actionRecorderPanelIconRecording: Nt,
287
- actionRecorderPanelTitle: Ut,
288
- actionRecorderPanelActions: xt
290
+ actionRecorderPanelTitle: xt,
291
+ actionRecorderPanelActions: Ut
289
292
  };
290
293
  function wt() {
291
294
  const e = T(l);
@@ -303,12 +306,12 @@ function $t() {
303
306
  r && e.executeCommand(ne.id);
304
307
  }, [e, r]), g = r ? o === 0 ? "Recording..." : `${o}: ${n[o - 1].id}` : "Start Recording";
305
308
  return /* @__PURE__ */ W("div", { className: y.actionRecorderPanel, children: [
306
- /* @__PURE__ */ h("div", { className: Mt(y.actionRecorderPanelIcon, r ? y.actionRecorderPanelIconRecording : !1), children: /* @__PURE__ */ h(E, {}) }),
309
+ /* @__PURE__ */ h("div", { className: Mt(y.actionRecorderPanelIcon, r ? y.actionRecorderPanelIconRecording : !1), children: /* @__PURE__ */ h(D, {}) }),
307
310
  /* @__PURE__ */ h("div", { className: y.actionRecorderPanelTitle, children: g }),
308
311
  /* @__PURE__ */ W("div", { className: y.actionRecorderPanelActions, children: [
309
- /* @__PURE__ */ h(x, { type: "default", size: "small", onClick: r ? f : i, children: r ? "Cancel" : "Close" }),
310
- /* @__PURE__ */ h(x, { type: "primary", size: "small", onClick: r ? a : () => c(), children: r ? "Save" : "Start" }),
311
- !r && /* @__PURE__ */ h(x, { type: "primary", size: "small", onClick: () => c(!0), children: "Start(N)" })
312
+ /* @__PURE__ */ h(U, { type: "default", size: "small", onClick: r ? f : i, children: r ? "Cancel" : "Close" }),
313
+ /* @__PURE__ */ h(U, { type: "primary", size: "small", onClick: r ? a : () => c(), children: r ? "Save" : "Start" }),
314
+ !r && /* @__PURE__ */ h(U, { type: "primary", size: "small", onClick: () => c(!0), children: "Start(N)" })
312
315
  ] })
313
316
  ] });
314
317
  }
@@ -330,14 +333,14 @@ function Ft(e) {
330
333
  disabled$: t.panelOpened$
331
334
  };
332
335
  }
333
- function Dt() {
336
+ function Et() {
334
337
  return {
335
338
  id: L.id,
336
339
  title: "action-recorder.menu.replay-local",
337
340
  type: R.BUTTON
338
341
  };
339
342
  }
340
- function Et() {
343
+ function Dt() {
341
344
  return {
342
345
  id: B.id,
343
346
  title: "action-recorder.menu.replay-local-name",
@@ -362,11 +365,11 @@ const Lt = {
362
365
  },
363
366
  [L.id]: {
364
367
  order: 2,
365
- menuItemFactory: Dt
368
+ menuItemFactory: Et
366
369
  },
367
370
  [B.id]: {
368
371
  order: 3,
369
- menuItemFactory: Et
372
+ menuItemFactory: Dt
370
373
  },
371
374
  [k.id]: {
372
375
  order: 4,
@@ -380,7 +383,7 @@ var Bt = Object.getOwnPropertyDescriptor, kt = (e, t, r, n) => {
380
383
  (c = e[i]) && (o = c(o) || o);
381
384
  return o;
382
385
  }, S = (e, t) => (r, n) => t(r, n, e);
383
- let b = class extends D {
386
+ let b = class extends E {
384
387
  constructor(e, t, r, n, o, i) {
385
388
  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();
386
389
  }
@@ -397,7 +400,7 @@ let b = class extends D {
397
400
  ].forEach((e) => this._commandSrv.registerCommand(e));
398
401
  }
399
402
  _initUI() {
400
- this._uiPartsSrv.registerComponent(ft.GLOBAL, () => gt(wt, this._injector)), this._componentManager.register("RecordSingle", E), this._menuManagerService.mergeMenu(Lt);
403
+ this._uiPartsSrv.registerComponent(ft.GLOBAL, () => gt(wt, this._injector)), this._componentManager.register("RecordSingle", D), this._menuManagerService.mergeMenu(Lt);
401
404
  }
402
405
  _initSheetsCommands() {
403
406
  [
@@ -427,8 +430,8 @@ let b = class extends D {
427
430
  // SetFontFamilyCommand,
428
431
  // SetFontSizeCommand,
429
432
  Ne,
430
- Ue,
431
433
  xe,
434
+ Ue,
432
435
  // SetItalicCommand,
433
436
  we,
434
437
  ze,
@@ -443,8 +446,8 @@ let b = class extends D {
443
446
  $e,
444
447
  Te,
445
448
  Fe,
446
- De,
447
449
  Ee,
450
+ De,
448
451
  // SetUnderlineCommand,
449
452
  je,
450
453
  Xe,
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(i,c){typeof exports=="object"&&typeof module<"u"?c(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"],c):(i=typeof globalThis<"u"?globalThis:i||self,c(i.UniverActionRecorder={},i.UniverCore,i.UniverSheets,i.UniverSheetsFilter,i.UniverSheetsUi,i.UniverUi,i.rxjs,i.UniverDesign,i.React,i.React))})(this,function(i,c,d,b,m,l,P,h,p,C){"use strict";var Ce=Object.defineProperty;var ye=(i,c,d)=>c in i?Ce(i,c,{enumerable:!0,configurable:!0,writable:!0,value:d}):i[c]=d;var g=(i,c,d)=>ye(i,typeof c!="symbol"?c+"":c,d);var F;var S=function(){return S=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},S.apply(this,arguments)},G=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n},L=C.forwardRef(function(e,t){var n=e.icon,r=e.id,o=e.className,a=e.extend,s=G(e,["icon","id","className","extend"]),v="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),u=C.useRef("_".concat(Y()));return B(n,"".concat(r),{defIds:n.defIds,idSuffix:u.current},S({ref:t,className:v},s),a)});function B(e,t,n,r,o){return C.createElement(e.tag,S(S({key:t},Z(e,n,o)),r),(K(e,n).children||[]).map(function(a,s){return B(a,"".concat(t,"-").concat(e.tag,"-").concat(s),n,void 0,o)}))}function Z(e,t,n){var r=S({},e.attrs);n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1);var o=t.defIds;return!o||o.length===0||(e.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+t.idSuffix),Object.entries(r).forEach(function(a){var s=a[0],v=a[1];typeof v=="string"&&(r[s]=v.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),r}function K(e,t){var n,r=t.defIds;return!r||r.length===0?e:e.tag==="defs"&&(!((n=e.children)===null||n===void 0)&&n.length)?S(S({},e),{children:e.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})}):e}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(e,t){return C.createElement(L,Object.assign({},e,{id:"record-single",ref:t,icon:Q}))});j.displayName="RecordSingle";var X=Object.getOwnPropertyDescriptor,ee=(e,t,n,r)=>{for(var o=r>1?void 0:r?X(t,n):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(o=s(o)||o);return o},M=(e,t)=>(n,r)=>t(n,r,e);i.ActionRecorderService=class extends c.Disposable{constructor(n,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=n,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(n){if(n.type===c.CommandType.MUTATION)throw new Error("[CommandRecorderService] Cannot record mutation commands.");this._shouldRecordCommands.add(n.id)}togglePanel(n){this._panelOpened$.next(n),n===!1&&this.stopRecording()}startRecording(n=!1){this._recorder=this._commandSrv.onCommandExecuted(r=>{var o,a;if(this._shouldRecordCommands.has(r.id)){const s=this._recorded,v=this._recordedCommands;let u={...r};const _=(o=this._instanceService.getFocusedUnit())==null?void 0:o.getUnitId(),{unitId:y=_,subUnitId:f}=u==null?void 0:u.params;if(n&&y&&f){const E=(a=this._instanceService.getUnit(y).getSheetBySheetId(f))==null?void 0:a.getName();u={...u,params:{...u.params,subUnitId:E}}}u.id===d.SetSelectionsOperation.id&&s.length>0&&s[s.length-1].id===d.SetSelectionsOperation.id?s[s.length-1]=u:(s.push(u),this._recorded$.next(s),u.type===c.CommandType.COMMAND&&(v.push(u),this._recordedCommands$.next(v)))}}),this._recording$.next(!0)}stopRecording(){var n;(n=this._recorder)==null||n.dispose(),this._recorder=null,this._recorded$.next([]),this._recordedCommands$.next([]),this._recording$.next(!1)}completeRecording(){const n=this._recorded.slice();this._localFileService.downloadFile(new Blob([JSON.stringify(n,null,2)]),"recorded-commands.json"),this._logService.error("Recorded commands:",n),this.stopRecording()}},i.ActionRecorderService=ee([M(0,c.ICommandService),M(1,c.ILogService),M(2,l.ILocalFileService),M(3,c.IUniverInstanceService)],i.ActionRecorderService);const x={id:"action-recorder.command.start-recording",type:c.CommandType.COMMAND,handler:(e,t)=>(e.get(i.ActionRecorderService).startRecording(!!(t!=null&&t.replaceId)),!0)},k={id:"action-recorder.command.complete-recording",type:c.CommandType.COMMAND,handler:e=>(e.get(i.ActionRecorderService).completeRecording(),!0)},V={id:"action-recorder.command.stop-recording",type:c.CommandType.COMMAND,handler:e=>(e.get(i.ActionRecorderService).completeRecording(),!0)};var ne=Object.getOwnPropertyDescriptor,re=(e,t,n,r)=>{for(var o=r>1?void 0:r?ne(t,n):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(o=s(o)||o);return o},I=(e,t)=>(n,r)=>t(n,r,e),N=(e=>(e.DEFAULT="default",e.NAME="name",e.ACTIVE="active",e))(N||{});i.ActionReplayService=class extends c.Disposable{constructor(t,n,r,o,a){super(),this._messageService=t,this._instanceService=n,this._localFileService=r,this._logService=o,this._commandService=a}async replayLocalJSON(t="default"){const n=await this._localFileService.openFile({multiple:!1,accept:".json"});if(n.length!==1)return!1;const r=n[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,n){var a,s,v;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}=n||{};for(const u of t){const{id:_,params:y}=u,f=y;if(f){if(typeof f.unitId<"u"&&(f.unitId=r),o==="name"&&f.subUnitId!=="undefined"){const A=(s=this._instanceService.getFocusedUnit().getSheetBySheetName(f.subUnitId))==null?void 0:s.getSheetId();A?f.subUnitId=A:this._logService.error("[ReplayService]",`failed to find subunit by subUnitName = ${f.subUnitId}`)}if(o==="active"&&f.subUnitId!=="undefined"){const A=(v=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:v.getSheetId();A?f.subUnitId=A:this._logService.error("[ReplayService]","failed to find active subunit")}if(!await this._commandService.executeCommand(_,y))return!1}else if(!await this._commandService.executeCommand(_))return!1}return!0}async replayCommandsWithDelay(t){var r;const n=(r=this._instanceService.getFocusedUnit())==null?void 0:r.getUnitId();n||this._logService.error("[ReplayService]","no focused unit to replay commands");for(const o of t){await c.awaitTime(te());const{id:a,params:s}=o;if(s){if(typeof s.unitId<"u"&&(s.unitId=n),!await this._commandService.executeCommand(a,s))return!1}else if(!await this._commandService.executeCommand(a))return!1}return!0}},i.ActionReplayService=re([I(0,l.IMessageService),I(1,c.IUniverInstanceService),I(2,l.ILocalFileService),I(3,c.ILogService),I(4,c.ICommandService)],i.ActionReplayService);function te(){return Math.floor(Math.random()*800)+200}const w={id:"action-recorder.command.replay-local-records",type:c.CommandType.COMMAND,handler:async e=>{const n=await e.get(i.ActionReplayService).replayLocalJSON();return n&&e.get(l.IMessageService).show({type:h.MessageType.Success,content:"Successfully replayed local records"}),n}},U={id:"action-recorder.command.replay-local-records-name",type:c.CommandType.COMMAND,handler:async e=>{const n=await e.get(i.ActionReplayService).replayLocalJSON(N.NAME);return n&&e.get(l.IMessageService).show({type:h.MessageType.Success,content:"Successfully replayed local records"}),n}},$={id:"action-recorder.command.replay-local-records-active",type:c.CommandType.COMMAND,handler:async e=>{const n=await e.get(i.ActionReplayService).replayLocalJSON(N.ACTIVE);return n&&e.get(l.IMessageService).show({type:h.MessageType.Success,content:"Successfully replayed local records"}),n}},D={id:"action-recorder.operation.open-panel",type:c.CommandType.OPERATION,handler(e){return e.get(i.ActionRecorderService).togglePanel(!0),!0}},W={id:"action-recorder.operation.close-panel",type:c.CommandType.OPERATION,handler(e){return e.get(i.ActionRecorderService).togglePanel(!1),!0}};function q(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=q(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function oe(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=q(e))&&(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",actionRecorderPanelTitle:"univer-action-recorder-panel-title",actionRecorderPanelActions:"univer-action-recorder-panel-actions"};function ie(){const e=l.useDependency(i.ActionRecorderService);return l.useObservable(e.panelOpened$)?p.jsx(ce,{}):null}function ce(){var y;const e=l.useDependency(c.ICommandService),t=l.useDependency(i.ActionRecorderService),n=l.useObservable(t.recording$),r=l.useObservable(t.recordedCommands$),o=(y=r==null?void 0:r.length)!=null?y:0,a=C.useCallback(()=>{n||e.executeCommand(W.id)},[e,n]),s=C.useCallback(f=>{n||e.executeCommand(x.id,{replaceId:f})},[e,n]),v=C.useCallback(()=>{n&&e.executeCommand(k.id)},[e,n]),u=C.useCallback(()=>{n&&e.executeCommand(V.id)},[e,n]),_=n?o===0?"Recording...":`${o}: ${r[o-1].id}`:"Start Recording";return p.jsxs("div",{className:O.actionRecorderPanel,children:[p.jsx("div",{className:oe(O.actionRecorderPanelIcon,n?O.actionRecorderPanelIconRecording:!1),children:p.jsx(j,{})}),p.jsx("div",{className:O.actionRecorderPanelTitle,children:_}),p.jsxs("div",{className:O.actionRecorderPanelActions,children:[p.jsx(h.Button,{type:"default",size:"small",onClick:n?u:a,children:n?"Cancel":"Close"}),p.jsx(h.Button,{type:"primary",size:"small",onClick:n?v:()=>s(),children:n?"Save":"Start"}),!n&&p.jsx(h.Button,{type:"primary",size:"small",onClick:()=>s(!0),children:"Start(N)"})]})]})}const z="RECORD_MENU_ITEM";function ae(){return{id:z,type:l.MenuItemType.SUBITEMS,icon:"RecordSingle",tooltip:"action-recorder.menu.title"}}function de(e){const t=e.get(i.ActionRecorderService);return{id:D.id,title:"action-recorder.menu.record",type:l.MenuItemType.BUTTON,disabled$:t.panelOpened$}}function se(){return{id:w.id,title:"action-recorder.menu.replay-local",type:l.MenuItemType.BUTTON}}function le(){return{id:U.id,title:"action-recorder.menu.replay-local-name",type:l.MenuItemType.BUTTON}}function me(){return{id:$.id,title:"action-recorder.menu.replay-local-active",type:l.MenuItemType.BUTTON}}const ue={[l.RibbonStartGroup.OTHERS]:{[z]:{order:10,menuItemFactory:ae,[D.id]:{order:1,menuItemFactory:de},[w.id]:{order:2,menuItemFactory:se},[U.id]:{order:3,menuItemFactory:le},[$.id]:{order:4,menuItemFactory:me}}}};var ve=Object.getOwnPropertyDescriptor,fe=(e,t,n,r)=>{for(var o=r>1?void 0:r?ve(t,n):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(o=s(o)||o);return o},R=(e,t)=>(n,r)=>t(n,r,e);let T=class extends c.Disposable{constructor(e,t,n,r,o,a){super(),this._commandSrv=e,this._uiPartsSrv=t,this._menuManagerService=n,this._componentManager=r,this._actionRecorderService=o,this._injector=a,this._initCommands(),this._initUI(),this._initSheetsCommands(),this._initDocsCommands()}_initCommands(){[x,V,k,D,W,w,U,$].forEach(e=>this._commandSrv.registerCommand(e))}_initUI(){this._uiPartsSrv.registerComponent(l.BuiltInUIPart.GLOBAL,()=>l.connectInjector(ie,this._injector)),this._componentManager.register("RecordSingle",j),this._menuManagerService.mergeMenu(ue)}_initSheetsCommands(){[d.CopySheetCommand,d.DeleteRangeMoveLeftCommand,d.DeleteRangeMoveUpCommand,d.DeltaColumnWidthCommand,d.DeltaRowHeightCommand,d.InsertSheetCommand,d.InsertColAfterCommand,d.InsertColBeforeCommand,d.InsertRowAfterCommand,d.InsertRowBeforeCommand,d.RemoveSheetCommand,d.SetStyleCommand,d.AddWorksheetMergeCommand,d.AddWorksheetMergeAllCommand,d.AddWorksheetMergeVerticalCommand,d.AddWorksheetMergeHorizontalCommand,d.SetFrozenCommand,d.CancelFrozenCommand,d.SetHorizontalTextAlignCommand,d.SetOverlineCommand,m.SetRangeBoldCommand,m.SetRangeFontFamilyCommand,m.SetRangeFontSizeCommand,m.SetRangeItalicCommand,m.SetRangeStrickThroughCommand,m.SetRangeSubscriptCommand,m.SetRangeSuperscriptCommand,m.SetRangeTextColorCommand,m.SetRangeUnderlineCommand,d.SetRangeValuesCommand,d.SetStrikeThroughCommand,d.SetTextColorCommand,d.SetTextRotationCommand,d.SetTextWrapCommand,d.SetVerticalTextAlignCommand,m.SheetCopyCommand,m.SheetCutCommand,m.SheetPasteBesidesBorderCommand,m.SheetPasteColWidthCommand,m.SheetPasteCommand,m.SheetPasteFormatCommand,m.SheetPasteShortKeyCommand,m.SheetPasteValueCommand,m.AutoFillCommand,m.RefillCommand,d.SetWorksheetActivateCommand,d.SetWorksheetActiveOperation,d.SetSelectionsOperation,b.SetSheetFilterRangeCommand,b.SetSheetsFilterCriteriaCommand,b.RemoveSheetFilterCommand].forEach(e=>this._actionRecorderService.registerRecordedCommand(e))}_initDocsCommands(){}};T=fe([R(0,c.ICommandService),R(1,l.IUIPartsService),R(2,l.IMenuManagerService),R(3,c.Inject(l.ComponentManager)),R(4,c.Inject(i.ActionRecorderService)),R(5,c.Inject(c.Injector))],T);const Se="action-recorder.config",H={};var ge=Object.getOwnPropertyDescriptor,pe=(e,t,n,r)=>{for(var o=r>1?void 0:r?ge(t,n):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(o=s(o)||o);return o},J=(e,t)=>(n,r)=>t(n,r,e);i.UniverActionRecorderPlugin=(F=class extends c.Plugin{constructor(t=H,n,r){super(),this._config=t,this._injector=n,this._configService=r;const{menu:o,...a}=c.merge({},H,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Se,a)}onStarting(){(this._config.replayOnly?[[i.ActionReplayService]]:[[i.ActionRecorderService],[i.ActionReplayService],[T]]).forEach(n=>this._injector.add(n))}onSteady(){this._config.replayOnly||this._injector.get(T)}},g(F,"pluginName","UNIVER_ACTION_RECORDER_PLUGIN"),F),i.UniverActionRecorderPlugin=pe([J(1,c.Inject(c.Injector)),J(2,c.IConfigService)],i.UniverActionRecorderPlugin),Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
1
+ (function(i,a){typeof exports=="object"&&typeof module<"u"?a(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"],a):(i=typeof globalThis<"u"?globalThis:i||self,a(i.UniverActionRecorder={},i.UniverCore,i.UniverSheets,i.UniverSheetsFilter,i.UniverSheetsUi,i.UniverUi,i.rxjs,i.UniverDesign,i.React,i.React))})(this,function(i,a,l,b,m,s,P,h,p,C){"use strict";var Ce=Object.defineProperty;var ye=(i,a,l)=>a in i?Ce(i,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[a]=l;var g=(i,a,l)=>ye(i,typeof a!="symbol"?a+"":a,l);var F;var S=function(){return S=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},S.apply(this,arguments)},G=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n},L=C.forwardRef(function(e,t){var n=e.icon,r=e.id,o=e.className,c=e.extend,d=G(e,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),f=C.useRef("_".concat(Y()));return x(n,"".concat(r),{defIds:n.defIds,idSuffix:f.current},S({ref:t,className:u},d),c)});function x(e,t,n,r,o){return C.createElement(e.tag,S(S({key:t},Z(e,n,o)),r),(K(e,n).children||[]).map(function(c,d){return x(c,"".concat(t,"-").concat(e.tag,"-").concat(d),n,void 0,o)}))}function Z(e,t,n){var r=S({},e.attrs);n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1),e.tag==="mask"&&r.id&&(r.id=r.id+t.idSuffix),Object.entries(r).forEach(function(c){var d=c[0],u=c[1];d==="mask"&&typeof u=="string"&&(r[d]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var o=t.defIds;return!o||o.length===0||(e.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+t.idSuffix),Object.entries(r).forEach(function(c){var d=c[0],u=c[1];typeof u=="string"&&(r[d]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),r}function K(e,t){var n,r=t.defIds;return!r||r.length===0?e:e.tag==="defs"&&(!((n=e.children)===null||n===void 0)&&n.length)?S(S({},e),{children:e.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})}):e}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(e,t){return C.createElement(L,Object.assign({},e,{id:"record-single",ref:t,icon:Q}))});j.displayName="RecordSingle";var X=Object.getOwnPropertyDescriptor,ee=(e,t,n,r)=>{for(var o=r>1?void 0:r?X(t,n):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(o=d(o)||o);return o},M=(e,t)=>(n,r)=>t(n,r,e);i.ActionRecorderService=class extends a.Disposable{constructor(n,r,o,c){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=n,this._logService=r,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(n){if(n.type===a.CommandType.MUTATION)throw new Error("[CommandRecorderService] Cannot record mutation commands.");this._shouldRecordCommands.add(n.id)}togglePanel(n){this._panelOpened$.next(n),n===!1&&this.stopRecording()}startRecording(n=!1){this._recorder=this._commandSrv.onCommandExecuted(r=>{var o,c;if(this._shouldRecordCommands.has(r.id)){const d=this._recorded,u=this._recordedCommands;let f={...r};const _=(o=this._instanceService.getFocusedUnit())==null?void 0:o.getUnitId(),{unitId:y=_,subUnitId:v}=f==null?void 0:f.params;if(n&&y&&v){const E=(c=this._instanceService.getUnit(y).getSheetBySheetId(v))==null?void 0:c.getName();f={...f,params:{...f.params,subUnitId:E}}}f.id===l.SetSelectionsOperation.id&&d.length>0&&d[d.length-1].id===l.SetSelectionsOperation.id?d[d.length-1]=f:(d.push(f),this._recorded$.next(d),f.type===a.CommandType.COMMAND&&(u.push(f),this._recordedCommands$.next(u)))}}),this._recording$.next(!0)}stopRecording(){var n;(n=this._recorder)==null||n.dispose(),this._recorder=null,this._recorded$.next([]),this._recordedCommands$.next([]),this._recording$.next(!1)}completeRecording(){const n=this._recorded.slice();this._localFileService.downloadFile(new Blob([JSON.stringify(n,null,2)]),"recorded-commands.json"),this._logService.error("Recorded commands:",n),this.stopRecording()}},i.ActionRecorderService=ee([M(0,a.ICommandService),M(1,a.ILogService),M(2,s.ILocalFileService),M(3,a.IUniverInstanceService)],i.ActionRecorderService);const B={id:"action-recorder.command.start-recording",type:a.CommandType.COMMAND,handler:(e,t)=>(e.get(i.ActionRecorderService).startRecording(!!(t!=null&&t.replaceId)),!0)},k={id:"action-recorder.command.complete-recording",type:a.CommandType.COMMAND,handler:e=>(e.get(i.ActionRecorderService).completeRecording(),!0)},V={id:"action-recorder.command.stop-recording",type:a.CommandType.COMMAND,handler:e=>(e.get(i.ActionRecorderService).completeRecording(),!0)};var ne=Object.getOwnPropertyDescriptor,re=(e,t,n,r)=>{for(var o=r>1?void 0:r?ne(t,n):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(o=d(o)||o);return o},I=(e,t)=>(n,r)=>t(n,r,e),N=(e=>(e.DEFAULT="default",e.NAME="name",e.ACTIVE="active",e))(N||{});i.ActionReplayService=class extends a.Disposable{constructor(t,n,r,o,c){super(),this._messageService=t,this._instanceService=n,this._localFileService=r,this._logService=o,this._commandService=c}async replayLocalJSON(t="default"){const n=await this._localFileService.openFile({multiple:!1,accept:".json"});if(n.length!==1)return!1;const r=n[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,n){var c,d,u;const r=(c=this._instanceService.getFocusedUnit())==null?void 0:c.getUnitId();r||this._logService.error("[ReplayService]","no focused unit to replay commands");const{mode:o}=n||{};for(const f of t){const{id:_,params:y}=f,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=(u=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:u.getSheetId();A?v.subUnitId=A:this._logService.error("[ReplayService]","failed to find active subunit")}if(!await this._commandService.executeCommand(_,y))return!1}else if(!await this._commandService.executeCommand(_))return!1}return!0}async replayCommandsWithDelay(t){var r;const n=(r=this._instanceService.getFocusedUnit())==null?void 0:r.getUnitId();n||this._logService.error("[ReplayService]","no focused unit to replay commands");for(const o of t){await a.awaitTime(te());const{id:c,params:d}=o;if(d){if(typeof d.unitId<"u"&&(d.unitId=n),!await this._commandService.executeCommand(c,d))return!1}else if(!await this._commandService.executeCommand(c))return!1}return!0}},i.ActionReplayService=re([I(0,s.IMessageService),I(1,a.IUniverInstanceService),I(2,s.ILocalFileService),I(3,a.ILogService),I(4,a.ICommandService)],i.ActionReplayService);function te(){return Math.floor(Math.random()*800)+200}const w={id:"action-recorder.command.replay-local-records",type:a.CommandType.COMMAND,handler:async e=>{const n=await e.get(i.ActionReplayService).replayLocalJSON();return n&&e.get(s.IMessageService).show({type:h.MessageType.Success,content:"Successfully replayed local records"}),n}},U={id:"action-recorder.command.replay-local-records-name",type:a.CommandType.COMMAND,handler:async e=>{const n=await e.get(i.ActionReplayService).replayLocalJSON(N.NAME);return n&&e.get(s.IMessageService).show({type:h.MessageType.Success,content:"Successfully replayed local records"}),n}},$={id:"action-recorder.command.replay-local-records-active",type:a.CommandType.COMMAND,handler:async e=>{const n=await e.get(i.ActionReplayService).replayLocalJSON(N.ACTIVE);return n&&e.get(s.IMessageService).show({type:h.MessageType.Success,content:"Successfully replayed local records"}),n}},D={id:"action-recorder.operation.open-panel",type:a.CommandType.OPERATION,handler(e){return e.get(i.ActionRecorderService).togglePanel(!0),!0}},W={id:"action-recorder.operation.close-panel",type:a.CommandType.OPERATION,handler(e){return e.get(i.ActionRecorderService).togglePanel(!1),!0}};function q(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=q(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function oe(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=q(e))&&(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",actionRecorderPanelTitle:"univer-action-recorder-panel-title",actionRecorderPanelActions:"univer-action-recorder-panel-actions"};function ie(){const e=s.useDependency(i.ActionRecorderService);return s.useObservable(e.panelOpened$)?p.jsx(ce,{}):null}function ce(){var y;const e=s.useDependency(a.ICommandService),t=s.useDependency(i.ActionRecorderService),n=s.useObservable(t.recording$),r=s.useObservable(t.recordedCommands$),o=(y=r==null?void 0:r.length)!=null?y:0,c=C.useCallback(()=>{n||e.executeCommand(W.id)},[e,n]),d=C.useCallback(v=>{n||e.executeCommand(B.id,{replaceId:v})},[e,n]),u=C.useCallback(()=>{n&&e.executeCommand(k.id)},[e,n]),f=C.useCallback(()=>{n&&e.executeCommand(V.id)},[e,n]),_=n?o===0?"Recording...":`${o}: ${r[o-1].id}`:"Start Recording";return p.jsxs("div",{className:O.actionRecorderPanel,children:[p.jsx("div",{className:oe(O.actionRecorderPanelIcon,n?O.actionRecorderPanelIconRecording:!1),children:p.jsx(j,{})}),p.jsx("div",{className:O.actionRecorderPanelTitle,children:_}),p.jsxs("div",{className:O.actionRecorderPanelActions,children:[p.jsx(h.Button,{type:"default",size:"small",onClick:n?f:c,children:n?"Cancel":"Close"}),p.jsx(h.Button,{type:"primary",size:"small",onClick:n?u:()=>d(),children:n?"Save":"Start"}),!n&&p.jsx(h.Button,{type:"primary",size:"small",onClick:()=>d(!0),children:"Start(N)"})]})]})}const z="RECORD_MENU_ITEM";function ae(){return{id:z,type:s.MenuItemType.SUBITEMS,icon:"RecordSingle",tooltip:"action-recorder.menu.title"}}function de(e){const t=e.get(i.ActionRecorderService);return{id:D.id,title:"action-recorder.menu.record",type:s.MenuItemType.BUTTON,disabled$:t.panelOpened$}}function le(){return{id:w.id,title:"action-recorder.menu.replay-local",type:s.MenuItemType.BUTTON}}function se(){return{id:U.id,title:"action-recorder.menu.replay-local-name",type:s.MenuItemType.BUTTON}}function me(){return{id:$.id,title:"action-recorder.menu.replay-local-active",type:s.MenuItemType.BUTTON}}const ue={[s.RibbonStartGroup.OTHERS]:{[z]:{order:10,menuItemFactory:ae,[D.id]:{order:1,menuItemFactory:de},[w.id]:{order:2,menuItemFactory:le},[U.id]:{order:3,menuItemFactory:se},[$.id]:{order:4,menuItemFactory:me}}}};var fe=Object.getOwnPropertyDescriptor,ve=(e,t,n,r)=>{for(var o=r>1?void 0:r?fe(t,n):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(o=d(o)||o);return o},R=(e,t)=>(n,r)=>t(n,r,e);let T=class extends a.Disposable{constructor(e,t,n,r,o,c){super(),this._commandSrv=e,this._uiPartsSrv=t,this._menuManagerService=n,this._componentManager=r,this._actionRecorderService=o,this._injector=c,this._initCommands(),this._initUI(),this._initSheetsCommands(),this._initDocsCommands()}_initCommands(){[B,V,k,D,W,w,U,$].forEach(e=>this._commandSrv.registerCommand(e))}_initUI(){this._uiPartsSrv.registerComponent(s.BuiltInUIPart.GLOBAL,()=>s.connectInjector(ie,this._injector)),this._componentManager.register("RecordSingle",j),this._menuManagerService.mergeMenu(ue)}_initSheetsCommands(){[l.CopySheetCommand,l.DeleteRangeMoveLeftCommand,l.DeleteRangeMoveUpCommand,l.DeltaColumnWidthCommand,l.DeltaRowHeightCommand,l.InsertSheetCommand,l.InsertColAfterCommand,l.InsertColBeforeCommand,l.InsertRowAfterCommand,l.InsertRowBeforeCommand,l.RemoveSheetCommand,l.SetStyleCommand,l.AddWorksheetMergeCommand,l.AddWorksheetMergeAllCommand,l.AddWorksheetMergeVerticalCommand,l.AddWorksheetMergeHorizontalCommand,l.SetFrozenCommand,l.CancelFrozenCommand,l.SetHorizontalTextAlignCommand,l.SetOverlineCommand,m.SetRangeBoldCommand,m.SetRangeFontFamilyCommand,m.SetRangeFontSizeCommand,m.SetRangeItalicCommand,m.SetRangeStrickThroughCommand,m.SetRangeSubscriptCommand,m.SetRangeSuperscriptCommand,m.SetRangeTextColorCommand,m.SetRangeUnderlineCommand,l.SetRangeValuesCommand,l.SetStrikeThroughCommand,l.SetTextColorCommand,l.SetTextRotationCommand,l.SetTextWrapCommand,l.SetVerticalTextAlignCommand,m.SheetCopyCommand,m.SheetCutCommand,m.SheetPasteBesidesBorderCommand,m.SheetPasteColWidthCommand,m.SheetPasteCommand,m.SheetPasteFormatCommand,m.SheetPasteShortKeyCommand,m.SheetPasteValueCommand,m.AutoFillCommand,m.RefillCommand,l.SetWorksheetActivateCommand,l.SetWorksheetActiveOperation,l.SetSelectionsOperation,b.SetSheetFilterRangeCommand,b.SetSheetsFilterCriteriaCommand,b.RemoveSheetFilterCommand].forEach(e=>this._actionRecorderService.registerRecordedCommand(e))}_initDocsCommands(){}};T=ve([R(0,a.ICommandService),R(1,s.IUIPartsService),R(2,s.IMenuManagerService),R(3,a.Inject(s.ComponentManager)),R(4,a.Inject(i.ActionRecorderService)),R(5,a.Inject(a.Injector))],T);const Se="action-recorder.config",H={};var ge=Object.getOwnPropertyDescriptor,pe=(e,t,n,r)=>{for(var o=r>1?void 0:r?ge(t,n):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(o=d(o)||o);return o},J=(e,t)=>(n,r)=>t(n,r,e);i.UniverActionRecorderPlugin=(F=class extends a.Plugin{constructor(t=H,n,r){super(),this._config=t,this._injector=n,this._configService=r;const{menu:o,...c}=a.merge({},H,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Se,c)}onStarting(){(this._config.replayOnly?[[i.ActionReplayService]]:[[i.ActionRecorderService],[i.ActionReplayService],[T]]).forEach(n=>this._injector.add(n))}onSteady(){this._config.replayOnly||this._injector.get(T)}},g(F,"pluginName","UNIVER_ACTION_RECORDER_PLUGIN"),F),i.UniverActionRecorderPlugin=pe([J(1,a.Inject(a.Injector)),J(2,a.IConfigService)],i.UniverActionRecorderPlugin),Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/action-recorder",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -52,14 +52,14 @@
52
52
  "rxjs": ">=7.0.0"
53
53
  },
54
54
  "dependencies": {
55
- "@univerjs/icons": "^0.2.15",
55
+ "@univerjs/icons": "^0.2.20",
56
56
  "clsx": "^2.1.1",
57
- "@univerjs/core": "0.6.0",
58
- "@univerjs/sheets": "0.6.0",
59
- "@univerjs/design": "0.6.0",
60
- "@univerjs/ui": "0.6.0",
61
- "@univerjs/sheets-filter": "0.6.0",
62
- "@univerjs/sheets-ui": "0.6.0"
57
+ "@univerjs/core": "0.6.1",
58
+ "@univerjs/design": "0.6.1",
59
+ "@univerjs/sheets": "0.6.1",
60
+ "@univerjs/sheets-filter": "0.6.1",
61
+ "@univerjs/ui": "0.6.1",
62
+ "@univerjs/sheets-ui": "0.6.1"
63
63
  },
64
64
  "devDependencies": {
65
65
  "less": "^4.2.2",
@@ -67,9 +67,9 @@
67
67
  "rxjs": "^7.8.1",
68
68
  "tailwindcss": "^3.4.17",
69
69
  "typescript": "^5.7.3",
70
- "vite": "^6.1.0",
71
- "vitest": "^3.0.5",
72
- "@univerjs-infra/shared": "0.6.0"
70
+ "vite": "^6.1.1",
71
+ "vitest": "^3.0.6",
72
+ "@univerjs-infra/shared": "0.6.1"
73
73
  },
74
74
  "scripts": {
75
75
  "test": "vitest run",