@univerjs/action-recorder 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +131 -125
- package/lib/index.css +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +10 -10
package/lib/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var K=Object.defineProperty;var Y=(r,n,e)=>n in r?K(r,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[n]=e;var S=(r,n,e)=>Y(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"),p=require("@univerjs/sheets-ui"),u=require("@univerjs/ui"),b=require("rxjs"),R=require("@univerjs/design"),g=require("react");var v=function(){return v=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},v.apply(this,arguments)},Q=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},q=g.forwardRef(function(r,n){var e=r.icon,t=r.id,o=r.className,i=r.extend,c=Q(r,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(t," ").concat(o||"").trim(),d=g.useRef("_".concat(re()));return J(e,"".concat(t),{defIds:e.defIds,idSuffix:d.current},v({ref:n,className:l},c),i)});function J(r,n,e,t,o){return g.createElement(r.tag,v(v({key:n},X(r,e,o)),t),(ee(r,e).children||[]).map(function(i,c){return J(i,"".concat(n,"-").concat(r.tag,"-").concat(c),e,void 0,o)}))}function X(r,n,e){var t=v({},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 ee(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)?v(v({},r),{children:r.children.map(function(o){return typeof o.attrs.id=="string"&&t&&t.indexOf(o.attrs.id)>-1?v(v({},o),{attrs:v(v({},o.attrs),{id:o.attrs.id+n.idSuffix})}):o})}):r}function re(){return Math.random().toString(36).substring(2,8)}q.displayName="UniverIcon";var te={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=g.forwardRef(function(r,n){return g.createElement(q,Object.assign({},r,{id:"record-single",ref:n,icon:te}))});N.displayName="RecordSingle";var ne=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,ie=(r,n,e,t)=>{for(var o=t>1?void 0:t?oe(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&&ne(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();S(this,"_shouldRecordCommands",new Set);S(this,"_panelOpened$",new b.BehaviorSubject(!1));S(this,"panelOpened$",this._panelOpened$.asObservable());S(this,"_recorder",null);S(this,"_recording$",new b.BehaviorSubject(!1));S(this,"recording$",this._recording$.asObservable());S(this,"_recorded$",new b.BehaviorSubject([]));S(this,"_recordedCommands$",new b.BehaviorSubject([]));S(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:f=h,subUnitId:m}=d==null?void 0:d.params;if(e&&f&&m){const y=(i=this._instanceService.getUnit(f).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=ie([x(0,a.ICommandService),x(1,a.ILogService),x(2,u.ILocalFileService),x(3,a.IUniverInstanceService)],exports.ActionRecorderService);const W={id:"action-recorder.command.start-recording",type:a.CommandType.COMMAND,handler:(r,n)=>(r.get(exports.ActionRecorderService).startRecording(!!(n!=null&&n.replaceId)),!0)},z={id:"action-recorder.command.complete-recording",type:a.CommandType.COMMAND,handler:r=>(r.get(exports.ActionRecorderService).completeRecording(),!0)},k={id:"action-recorder.command.stop-recording",type:a.CommandType.COMMAND,handler:r=>(r.get(exports.ActionRecorderService).completeRecording(),!0)};var ce=Object.defineProperty,ae=Object.getOwnPropertyDescriptor,se=(r,n,e,t)=>{for(var o=t>1?void 0:t?ae(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&&ce(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:f}=d,m=f;if(m){if(typeof m.unitId<"u"&&(m.unitId=t),o==="name"&&m.subUnitId!=="undefined"){const C=(c=this._instanceService.getFocusedUnit().getSheetBySheetName(m.subUnitId))==null?void 0:c.getSheetId();C?m.subUnitId=C:this._logService.error("[ReplayService]",`failed to find subunit by subUnitName = ${m.subUnitId}`)}if(o==="active"&&m.subUnitId!=="undefined"){const C=(l=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:l.getSheetId();C?m.subUnitId=C:this._logService.error("[ReplayService]","failed to find active subunit")}if(!await this._commandService.executeCommand(h,f))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(de());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=se([O(0,u.IMessageService),O(1,a.IUniverInstanceService),O(2,u.ILocalFileService),O(3,a.ILogService),O(4,a.ICommandService)],exports.ActionReplayService);function de(){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(u.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(u.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(u.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}},H={id:"action-recorder.operation.close-panel",type:a.CommandType.OPERATION,handler(r){return r.get(exports.ActionRecorderService).togglePanel(!1),!0}};var j={exports:{}},A={};/**
|
|
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 S=(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"),g=require("react");var v=function(){return v=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},v.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=g.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=g.useRef("_".concat(te()));return W(e,"".concat(t),{defIds:e.defIds,idSuffix:d.current},v({ref:n,className:l},c),i)});function W(r,n,e,t,o){return g.createElement(r.tag,v(v({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=v({},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)?v(v({},r),{children:r.children.map(function(o){return typeof o.attrs.id=="string"&&t&&t.indexOf(o.attrs.id)>-1?v(v({},o),{attrs:v(v({},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=g.forwardRef(function(r,n){return g.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();S(this,"_shouldRecordCommands",new Set);S(this,"_panelOpened$",new b.BehaviorSubject(!1));S(this,"panelOpened$",this._panelOpened$.asObservable());S(this,"_recorder",null);S(this,"_recording$",new b.BehaviorSubject(!1));S(this,"recording$",this._recording$.asObservable());S(this,"_recorded$",new b.BehaviorSubject([]));S(this,"_recordedCommands$",new b.BehaviorSubject([]));S(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
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var L;function
|
|
9
|
+
*/var L;function me(){if(L)return A;L=1;var r=g,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",ve="univer-action-recorder-panel-icon",Se="univer-action-recorder-panel-icon-recording",ge="univer-recording",he="univer-action-recorder-panel-title",Ce="univer-action-recorder-panel-actions",P={actionRecorderPanel:pe,actionRecorderPanelIcon:ve,actionRecorderPanelIconRecording:Se,recording:ge,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=g.useCallback(()=>{e||r.executeCommand(G.id)},[r,e]),c=g.useCallback(m=>{e||r.executeCommand(z.id,{replaceId:m})},[r,e]),l=g.useCallback(()=>{e&&r.executeCommand(k.id)},[r,e]),d=g.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)}},S(U,"pluginName","UNIVER_ACTION_RECORDER_PLUGIN"),U);exports.UniverActionRecorderPlugin=we([q(1,a.Inject(a.Injector)),q(2,a.IConfigService)],exports.UniverActionRecorderPlugin);
|
package/lib/es/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (e, r, t) =>
|
|
4
|
-
import { Disposable as D, CommandType as g, ICommandService as M, ILogService as
|
|
5
|
-
import { SetSelectionsOperation as E, CopySheetCommand as
|
|
6
|
-
import { SetSheetFilterRangeCommand as
|
|
7
|
-
import { SetRangeBoldCommand as
|
|
8
|
-
import { ILocalFileService as
|
|
1
|
+
var me = Object.defineProperty;
|
|
2
|
+
var ue = (e, r, t) => r in e ? me(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
3
|
+
var u = (e, r, t) => ue(e, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
+
import { Disposable as D, CommandType as g, ICommandService as M, ILogService as Y, IUniverInstanceService as Q, awaitTime as fe, useDependency as T, Inject as b, Injector as X, connectInjector as pe, Plugin as ge, merge as he, IConfigService as ve } from "@univerjs/core";
|
|
5
|
+
import { SetSelectionsOperation as E, CopySheetCommand as Se, DeleteRangeMoveLeftCommand as _e, DeleteRangeMoveUpCommand as Ce, DeltaColumnWidthCommand as ye, DeltaRowHeightCommand as Re, InsertSheetCommand as Ie, InsertColAfterCommand as Oe, InsertColBeforeCommand as Pe, InsertRowAfterCommand as xe, InsertRowBeforeCommand as be, RemoveSheetCommand as Ne, SetStyleCommand as Me, AddWorksheetMergeCommand as Ae, AddWorksheetMergeAllCommand as Ue, AddWorksheetMergeVerticalCommand as we, AddWorksheetMergeHorizontalCommand as $e, SetFrozenCommand as je, CancelFrozenCommand as Te, SetHorizontalTextAlignCommand as Ee, SetOverlineCommand as Fe, SetRangeValuesCommand as De, SetStrikeThroughCommand as Le, SetTextColorCommand as Be, SetTextRotationCommand as Ve, SetTextWrapCommand as Je, SetVerticalTextAlignCommand as We, SetWorksheetActivateCommand as ze, SetWorksheetActiveOperation as He } from "@univerjs/sheets";
|
|
6
|
+
import { SetSheetFilterRangeCommand as qe, SetSheetsFilterCriteriaCommand as ke, RemoveSheetFilterCommand as Ge } from "@univerjs/sheets-filter";
|
|
7
|
+
import { SetRangeBoldCommand as Ze, SetRangeFontFamilyCommand as Ke, SetRangeFontSizeCommand as Ye, SetRangeItalicCommand as Qe, SetRangeStrickThroughCommand as Xe, SetRangeSubscriptCommand as er, SetRangeSuperscriptCommand as rr, SetRangeTextColorCommand as tr, SetRangeUnderlineCommand as nr, SheetCopyCommand as or, SheetCutCommand as ir, SheetPasteBesidesBorderCommand as cr, SheetPasteColWidthCommand as ar, SheetPasteCommand as sr, SheetPasteFormatCommand as dr, SheetPasteShortKeyCommand as lr, SheetPasteValueCommand as mr, AutoFillCommand as ur, RefillCommand as fr } from "@univerjs/sheets-ui";
|
|
8
|
+
import { ILocalFileService as ee, IMessageService as A, useObservable as F, RibbonStartGroup as pr, MenuItemType as I, ComponentManager as gr, IUIPartsService as hr, IMenuManagerService as vr, BuiltInUIPart as Sr } from "@univerjs/ui";
|
|
9
9
|
import { BehaviorSubject as O } from "rxjs";
|
|
10
10
|
import { MessageType as U, Button as w } from "@univerjs/design";
|
|
11
|
-
import
|
|
11
|
+
import _r, { forwardRef as re, useRef as Cr, createElement as te, useCallback as P } from "react";
|
|
12
12
|
var l = function() {
|
|
13
13
|
return l = Object.assign || function(e) {
|
|
14
14
|
for (var r, t = 1, n = arguments.length; t < n; t++) {
|
|
@@ -17,23 +17,23 @@ var l = function() {
|
|
|
17
17
|
}
|
|
18
18
|
return e;
|
|
19
19
|
}, l.apply(this, arguments);
|
|
20
|
-
},
|
|
20
|
+
}, yr = function(e, r) {
|
|
21
21
|
var t = {};
|
|
22
22
|
for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && r.indexOf(n) < 0 && (t[n] = e[n]);
|
|
23
23
|
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
24
24
|
for (var o = 0, n = Object.getOwnPropertySymbols(e); o < n.length; o++)
|
|
25
25
|
r.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[o]) && (t[n[o]] = e[n[o]]);
|
|
26
26
|
return t;
|
|
27
|
-
},
|
|
28
|
-
var t = e.icon, n = e.id, o = e.className, i = e.extend, c =
|
|
29
|
-
return
|
|
27
|
+
}, ne = re(function(e, r) {
|
|
28
|
+
var t = e.icon, n = e.id, o = e.className, i = e.extend, c = yr(e, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(n, " ").concat(o || "").trim(), d = Cr("_".concat(Or()));
|
|
29
|
+
return oe(t, "".concat(n), { defIds: t.defIds, idSuffix: d.current }, l({ ref: r, className: a }, c), i);
|
|
30
30
|
});
|
|
31
|
-
function
|
|
32
|
-
return
|
|
33
|
-
return
|
|
31
|
+
function oe(e, r, t, n, o) {
|
|
32
|
+
return te(e.tag, l(l({ key: r }, Rr(e, t, o)), n), (Ir(e, t).children || []).map(function(i, c) {
|
|
33
|
+
return oe(i, "".concat(r, "-").concat(e.tag, "-").concat(c), t, void 0, o);
|
|
34
34
|
}));
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function Rr(e, r, t) {
|
|
37
37
|
var n = l({}, e.attrs);
|
|
38
38
|
t != null && t.colorChannel1 && n.fill === "colorChannel1" && (n.fill = t.colorChannel1);
|
|
39
39
|
var o = r.defIds;
|
|
@@ -42,28 +42,28 @@ function Sr(e, r, t) {
|
|
|
42
42
|
typeof a == "string" && (n[c] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(r.idSuffix, ")")));
|
|
43
43
|
})), n;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function Ir(e, r) {
|
|
46
46
|
var t, n = r.defIds;
|
|
47
47
|
return !n || n.length === 0 ? e : e.tag === "defs" && (!((t = e.children) === null || t === void 0) && t.length) ? l(l({}, e), { children: e.children.map(function(o) {
|
|
48
48
|
return typeof o.attrs.id == "string" && n && n.indexOf(o.attrs.id) > -1 ? l(l({}, o), { attrs: l(l({}, o.attrs), { id: o.attrs.id + r.idSuffix }) }) : o;
|
|
49
49
|
}) }) : e;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function Or() {
|
|
52
52
|
return Math.random().toString(36).substring(2, 8);
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
var
|
|
56
|
-
return
|
|
54
|
+
ne.displayName = "UniverIcon";
|
|
55
|
+
var Pr = { 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"] }, L = re(function(e, r) {
|
|
56
|
+
return te(ne, Object.assign({}, e, {
|
|
57
57
|
id: "record-single",
|
|
58
58
|
ref: r,
|
|
59
|
-
icon:
|
|
59
|
+
icon: Pr
|
|
60
60
|
}));
|
|
61
61
|
});
|
|
62
62
|
L.displayName = "RecordSingle";
|
|
63
|
-
var
|
|
64
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
63
|
+
var xr = Object.defineProperty, br = Object.getOwnPropertyDescriptor, Nr = (e, r, t, n) => {
|
|
64
|
+
for (var o = n > 1 ? void 0 : n ? br(r, t) : r, i = e.length - 1, c; i >= 0; i--)
|
|
65
65
|
(c = e[i]) && (o = (n ? c(r, t, o) : c(o)) || o);
|
|
66
|
-
return n && o &&
|
|
66
|
+
return n && o && xr(r, t, o), o;
|
|
67
67
|
}, x = (e, r) => (t, n) => r(t, n, e);
|
|
68
68
|
let m = class extends D {
|
|
69
69
|
constructor(r, t, n, o) {
|
|
@@ -125,29 +125,29 @@ let m = class extends D {
|
|
|
125
125
|
this._localFileService.downloadFile(new Blob([JSON.stringify(r, null, 2)]), "recorded-commands.json"), this._logService.error("Recorded commands:", r), this.stopRecording();
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
|
-
m =
|
|
128
|
+
m = Nr([
|
|
129
129
|
x(0, M),
|
|
130
|
-
x(1,
|
|
131
|
-
x(2,
|
|
132
|
-
x(3,
|
|
130
|
+
x(1, Y),
|
|
131
|
+
x(2, ee),
|
|
132
|
+
x(3, Q)
|
|
133
133
|
], m);
|
|
134
|
-
const
|
|
134
|
+
const ie = {
|
|
135
135
|
id: "action-recorder.command.start-recording",
|
|
136
136
|
type: g.COMMAND,
|
|
137
137
|
handler: (e, r) => (e.get(m).startRecording(!!(r != null && r.replaceId)), !0)
|
|
138
|
-
},
|
|
138
|
+
}, ce = {
|
|
139
139
|
id: "action-recorder.command.complete-recording",
|
|
140
140
|
type: g.COMMAND,
|
|
141
141
|
handler: (e) => (e.get(m).completeRecording(), !0)
|
|
142
|
-
},
|
|
142
|
+
}, ae = {
|
|
143
143
|
id: "action-recorder.command.stop-recording",
|
|
144
144
|
type: g.COMMAND,
|
|
145
145
|
handler: (e) => (e.get(m).completeRecording(), !0)
|
|
146
146
|
};
|
|
147
|
-
var
|
|
148
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
147
|
+
var Mr = Object.defineProperty, Ar = Object.getOwnPropertyDescriptor, Ur = (e, r, t, n) => {
|
|
148
|
+
for (var o = n > 1 ? void 0 : n ? Ar(r, t) : r, i = e.length - 1, c; i >= 0; i--)
|
|
149
149
|
(c = e[i]) && (o = (n ? c(r, t, o) : c(o)) || o);
|
|
150
|
-
return n && o &&
|
|
150
|
+
return n && o && Mr(r, t, o), o;
|
|
151
151
|
}, C = (e, r) => (t, n) => r(t, n, e), B = /* @__PURE__ */ ((e) => (e.DEFAULT = "default", e.NAME = "name", e.ACTIVE = "active", e))(B || {});
|
|
152
152
|
let S = class extends D {
|
|
153
153
|
constructor(e, r, t, n, o) {
|
|
@@ -204,7 +204,7 @@ let S = class extends D {
|
|
|
204
204
|
const r = (t = this._instanceService.getFocusedUnit()) == null ? void 0 : t.getUnitId();
|
|
205
205
|
r || this._logService.error("[ReplayService]", "no focused unit to replay commands");
|
|
206
206
|
for (const n of e) {
|
|
207
|
-
await
|
|
207
|
+
await fe(wr());
|
|
208
208
|
const { id: o, params: i } = n;
|
|
209
209
|
if (i) {
|
|
210
210
|
if (typeof i.unitId < "u" && (i.unitId = r), !await this._commandService.executeCommand(o, i)) return !1;
|
|
@@ -213,14 +213,14 @@ let S = class extends D {
|
|
|
213
213
|
return !0;
|
|
214
214
|
}
|
|
215
215
|
};
|
|
216
|
-
S =
|
|
216
|
+
S = Ur([
|
|
217
217
|
C(0, A),
|
|
218
|
-
C(1,
|
|
219
|
-
C(2,
|
|
220
|
-
C(3,
|
|
218
|
+
C(1, Q),
|
|
219
|
+
C(2, ee),
|
|
220
|
+
C(3, Y),
|
|
221
221
|
C(4, M)
|
|
222
222
|
], S);
|
|
223
|
-
function
|
|
223
|
+
function wr() {
|
|
224
224
|
return Math.floor(Math.random() * 800) + 200;
|
|
225
225
|
}
|
|
226
226
|
const V = {
|
|
@@ -259,7 +259,7 @@ const V = {
|
|
|
259
259
|
handler(e) {
|
|
260
260
|
return e.get(m).togglePanel(!0), !0;
|
|
261
261
|
}
|
|
262
|
-
},
|
|
262
|
+
}, se = {
|
|
263
263
|
id: "action-recorder.operation.close-panel",
|
|
264
264
|
type: g.OPERATION,
|
|
265
265
|
handler(e) {
|
|
@@ -277,10 +277,10 @@ var $ = { exports: {} }, y = {};
|
|
|
277
277
|
* LICENSE file in the root directory of this source tree.
|
|
278
278
|
*/
|
|
279
279
|
var q;
|
|
280
|
-
function
|
|
280
|
+
function $r() {
|
|
281
281
|
if (q) return y;
|
|
282
282
|
q = 1;
|
|
283
|
-
var e =
|
|
283
|
+
var e = _r, 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
284
|
function c(a, d, f) {
|
|
285
285
|
var s, p = {}, h = null, H = null;
|
|
286
286
|
f !== void 0 && (h = "" + f), d.key !== void 0 && (h = "" + d.key), d.ref !== void 0 && (H = d.ref);
|
|
@@ -291,48 +291,48 @@ function Mr() {
|
|
|
291
291
|
return y.Fragment = t, y.jsx = c, y.jsxs = c, y;
|
|
292
292
|
}
|
|
293
293
|
var k;
|
|
294
|
-
function
|
|
295
|
-
return k || (k = 1, $.exports =
|
|
294
|
+
function jr() {
|
|
295
|
+
return k || (k = 1, $.exports = $r()), $.exports;
|
|
296
296
|
}
|
|
297
|
-
var v =
|
|
298
|
-
function
|
|
297
|
+
var v = jr();
|
|
298
|
+
function de(e) {
|
|
299
299
|
var r, t, n = "";
|
|
300
300
|
if (typeof e == "string" || typeof e == "number") n += e;
|
|
301
301
|
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
302
302
|
var o = e.length;
|
|
303
|
-
for (r = 0; r < o; r++) e[r] && (t =
|
|
303
|
+
for (r = 0; r < o; r++) e[r] && (t = de(e[r])) && (n && (n += " "), n += t);
|
|
304
304
|
} else for (t in e) e[t] && (n && (n += " "), n += t);
|
|
305
305
|
return n;
|
|
306
306
|
}
|
|
307
|
-
function
|
|
308
|
-
for (var e, r, t = 0, n = "", o = arguments.length; t < o; t++) (e = arguments[t]) && (r =
|
|
307
|
+
function Tr() {
|
|
308
|
+
for (var e, r, t = 0, n = "", o = arguments.length; t < o; t++) (e = arguments[t]) && (r = de(e)) && (n && (n += " "), n += r);
|
|
309
309
|
return n;
|
|
310
310
|
}
|
|
311
|
-
const
|
|
312
|
-
actionRecorderPanel:
|
|
313
|
-
actionRecorderPanelIcon:
|
|
314
|
-
actionRecorderPanelIconRecording:
|
|
315
|
-
recording:
|
|
316
|
-
actionRecorderPanelTitle:
|
|
317
|
-
actionRecorderPanelActions:
|
|
311
|
+
const Er = "univer-action-recorder-panel", Fr = "univer-action-recorder-panel-icon", Dr = "univer-action-recorder-panel-icon-recording", Lr = "univer-recording", Br = "univer-action-recorder-panel-title", Vr = "univer-action-recorder-panel-actions", R = {
|
|
312
|
+
actionRecorderPanel: Er,
|
|
313
|
+
actionRecorderPanelIcon: Fr,
|
|
314
|
+
actionRecorderPanelIconRecording: Dr,
|
|
315
|
+
recording: Lr,
|
|
316
|
+
actionRecorderPanelTitle: Br,
|
|
317
|
+
actionRecorderPanelActions: Vr
|
|
318
318
|
};
|
|
319
|
-
function
|
|
319
|
+
function Jr() {
|
|
320
320
|
const e = T(m);
|
|
321
|
-
return F(e.panelOpened$) ? /* @__PURE__ */ v.jsx(
|
|
321
|
+
return F(e.panelOpened$) ? /* @__PURE__ */ v.jsx(Wr, {}) : null;
|
|
322
322
|
}
|
|
323
|
-
function
|
|
323
|
+
function Wr() {
|
|
324
324
|
var s;
|
|
325
325
|
const e = T(M), r = T(m), t = F(r.recording$), n = F(r.recordedCommands$), o = (s = n == null ? void 0 : n.length) != null ? s : 0, i = P(() => {
|
|
326
|
-
t || e.executeCommand(
|
|
326
|
+
t || e.executeCommand(se.id);
|
|
327
327
|
}, [e, t]), c = P((p) => {
|
|
328
|
-
t || e.executeCommand(
|
|
328
|
+
t || e.executeCommand(ie.id, { replaceId: p });
|
|
329
329
|
}, [e, t]), a = P(() => {
|
|
330
|
-
t && e.executeCommand(ie.id);
|
|
331
|
-
}, [e, t]), d = P(() => {
|
|
332
330
|
t && e.executeCommand(ce.id);
|
|
331
|
+
}, [e, t]), d = P(() => {
|
|
332
|
+
t && e.executeCommand(ae.id);
|
|
333
333
|
}, [e, t]), f = t ? o === 0 ? "Recording..." : `${o}: ${n[o - 1].id}` : "Start Recording";
|
|
334
334
|
return /* @__PURE__ */ v.jsxs("div", { className: R.actionRecorderPanel, children: [
|
|
335
|
-
/* @__PURE__ */ v.jsx("div", { className:
|
|
335
|
+
/* @__PURE__ */ v.jsx("div", { className: Tr(R.actionRecorderPanelIcon, t ? R.actionRecorderPanelIconRecording : !1), children: /* @__PURE__ */ v.jsx(L, {}) }),
|
|
336
336
|
/* @__PURE__ */ v.jsx("div", { className: R.actionRecorderPanelTitle, children: f }),
|
|
337
337
|
/* @__PURE__ */ v.jsxs("div", { className: R.actionRecorderPanelActions, children: [
|
|
338
338
|
/* @__PURE__ */ v.jsx(w, { type: "default", size: "small", onClick: t ? d : i, children: t ? "Cancel" : "Close" }),
|
|
@@ -341,16 +341,16 @@ function Lr() {
|
|
|
341
341
|
] })
|
|
342
342
|
] });
|
|
343
343
|
}
|
|
344
|
-
const
|
|
345
|
-
function
|
|
344
|
+
const le = "RECORD_MENU_ITEM";
|
|
345
|
+
function zr() {
|
|
346
346
|
return {
|
|
347
|
-
id:
|
|
347
|
+
id: le,
|
|
348
348
|
type: I.SUBITEMS,
|
|
349
349
|
icon: "RecordSingle",
|
|
350
350
|
tooltip: "action-recorder.menu.title"
|
|
351
351
|
};
|
|
352
352
|
}
|
|
353
|
-
function
|
|
353
|
+
function Hr(e) {
|
|
354
354
|
const r = e.get(m);
|
|
355
355
|
return {
|
|
356
356
|
id: z.id,
|
|
@@ -359,55 +359,55 @@ function Vr(e) {
|
|
|
359
359
|
disabled$: r.panelOpened$
|
|
360
360
|
};
|
|
361
361
|
}
|
|
362
|
-
function
|
|
362
|
+
function qr() {
|
|
363
363
|
return {
|
|
364
364
|
id: V.id,
|
|
365
365
|
title: "action-recorder.menu.replay-local",
|
|
366
366
|
type: I.BUTTON
|
|
367
367
|
};
|
|
368
368
|
}
|
|
369
|
-
function
|
|
369
|
+
function kr() {
|
|
370
370
|
return {
|
|
371
371
|
id: J.id,
|
|
372
372
|
title: "action-recorder.menu.replay-local-name",
|
|
373
373
|
type: I.BUTTON
|
|
374
374
|
};
|
|
375
375
|
}
|
|
376
|
-
function
|
|
376
|
+
function Gr() {
|
|
377
377
|
return {
|
|
378
378
|
id: W.id,
|
|
379
379
|
title: "action-recorder.menu.replay-local-active",
|
|
380
380
|
type: I.BUTTON
|
|
381
381
|
};
|
|
382
382
|
}
|
|
383
|
-
const
|
|
384
|
-
[
|
|
385
|
-
[
|
|
383
|
+
const Zr = {
|
|
384
|
+
[pr.OTHERS]: {
|
|
385
|
+
[le]: {
|
|
386
386
|
order: 10,
|
|
387
|
-
menuItemFactory:
|
|
387
|
+
menuItemFactory: zr,
|
|
388
388
|
[z.id]: {
|
|
389
389
|
order: 1,
|
|
390
|
-
menuItemFactory:
|
|
390
|
+
menuItemFactory: Hr
|
|
391
391
|
},
|
|
392
392
|
[V.id]: {
|
|
393
393
|
order: 2,
|
|
394
|
-
menuItemFactory:
|
|
394
|
+
menuItemFactory: qr
|
|
395
395
|
},
|
|
396
396
|
[J.id]: {
|
|
397
397
|
order: 3,
|
|
398
|
-
menuItemFactory:
|
|
398
|
+
menuItemFactory: kr
|
|
399
399
|
},
|
|
400
400
|
[W.id]: {
|
|
401
401
|
order: 4,
|
|
402
|
-
menuItemFactory:
|
|
402
|
+
menuItemFactory: Gr
|
|
403
403
|
}
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
};
|
|
407
|
-
var
|
|
408
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
407
|
+
var Kr = Object.defineProperty, Yr = Object.getOwnPropertyDescriptor, Qr = (e, r, t, n) => {
|
|
408
|
+
for (var o = n > 1 ? void 0 : n ? Yr(r, t) : r, i = e.length - 1, c; i >= 0; i--)
|
|
409
409
|
(c = e[i]) && (o = (n ? c(r, t, o) : c(o)) || o);
|
|
410
|
-
return n && o &&
|
|
410
|
+
return n && o && Kr(r, t, o), o;
|
|
411
411
|
}, _ = (e, r) => (t, n) => r(t, n, e);
|
|
412
412
|
let N = class extends D {
|
|
413
413
|
constructor(e, r, t, n, o, i) {
|
|
@@ -415,26 +415,24 @@ let N = class extends D {
|
|
|
415
415
|
}
|
|
416
416
|
_initCommands() {
|
|
417
417
|
[
|
|
418
|
-
oe,
|
|
419
|
-
ce,
|
|
420
418
|
ie,
|
|
421
|
-
z,
|
|
422
419
|
ae,
|
|
420
|
+
ce,
|
|
421
|
+
z,
|
|
422
|
+
se,
|
|
423
423
|
V,
|
|
424
424
|
J,
|
|
425
425
|
W
|
|
426
426
|
].forEach((e) => this._commandSrv.registerCommand(e));
|
|
427
427
|
}
|
|
428
428
|
_initUI() {
|
|
429
|
-
this._uiPartsSrv.registerComponent(
|
|
429
|
+
this._uiPartsSrv.registerComponent(Sr.GLOBAL, () => pe(Jr, this._injector)), this._componentManager.register("RecordSingle", L), this._menuManagerService.mergeMenu(Zr);
|
|
430
430
|
}
|
|
431
431
|
_initSheetsCommands() {
|
|
432
432
|
[
|
|
433
433
|
// InsertColCommand,
|
|
434
434
|
// InsertRowCommand,
|
|
435
435
|
// #region basic commands
|
|
436
|
-
he,
|
|
437
|
-
ve,
|
|
438
436
|
Se,
|
|
439
437
|
_e,
|
|
440
438
|
Ce,
|
|
@@ -449,19 +447,19 @@ let N = class extends D {
|
|
|
449
447
|
Me,
|
|
450
448
|
Ae,
|
|
451
449
|
Ue,
|
|
450
|
+
we,
|
|
451
|
+
$e,
|
|
452
452
|
// ResetBackgroundColorCommand,
|
|
453
453
|
// ResetTextColorCommand,
|
|
454
454
|
// SetBackgroundColorCommand,
|
|
455
455
|
// SetBoldCommand,
|
|
456
456
|
// SetFontFamilyCommand,
|
|
457
457
|
// SetFontSizeCommand,
|
|
458
|
-
we,
|
|
459
|
-
$e,
|
|
460
458
|
je,
|
|
461
|
-
// SetItalicCommand,
|
|
462
459
|
Te,
|
|
463
|
-
|
|
464
|
-
|
|
460
|
+
Ee,
|
|
461
|
+
// SetItalicCommand,
|
|
462
|
+
Fe,
|
|
465
463
|
Ze,
|
|
466
464
|
Ke,
|
|
467
465
|
Ye,
|
|
@@ -469,23 +467,27 @@ let N = class extends D {
|
|
|
469
467
|
Xe,
|
|
470
468
|
er,
|
|
471
469
|
rr,
|
|
472
|
-
|
|
473
|
-
|
|
470
|
+
tr,
|
|
471
|
+
nr,
|
|
474
472
|
De,
|
|
475
473
|
Le,
|
|
476
474
|
Be,
|
|
477
|
-
// SetUnderlineCommand,
|
|
478
475
|
Ve,
|
|
479
|
-
|
|
480
|
-
|
|
476
|
+
Je,
|
|
477
|
+
// SetUnderlineCommand,
|
|
478
|
+
We,
|
|
481
479
|
or,
|
|
482
480
|
ir,
|
|
483
481
|
cr,
|
|
484
482
|
ar,
|
|
485
483
|
sr,
|
|
486
484
|
dr,
|
|
487
|
-
|
|
488
|
-
|
|
485
|
+
lr,
|
|
486
|
+
mr,
|
|
487
|
+
ur,
|
|
488
|
+
fr,
|
|
489
|
+
ze,
|
|
490
|
+
He,
|
|
489
491
|
E,
|
|
490
492
|
// #endregion
|
|
491
493
|
// #region data validation command
|
|
@@ -493,34 +495,38 @@ let N = class extends D {
|
|
|
493
495
|
// #region conditional formatting command
|
|
494
496
|
// #endregion
|
|
495
497
|
// #region filter command
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
498
|
+
qe,
|
|
499
|
+
ke,
|
|
500
|
+
Ge
|
|
499
501
|
// #endregion
|
|
500
502
|
].forEach((e) => this._actionRecorderService.registerRecordedCommand(e));
|
|
501
503
|
}
|
|
502
504
|
_initDocsCommands() {
|
|
503
505
|
}
|
|
504
506
|
};
|
|
505
|
-
N =
|
|
507
|
+
N = Qr([
|
|
506
508
|
_(0, M),
|
|
507
|
-
_(1,
|
|
508
|
-
_(2,
|
|
509
|
-
_(3, b(
|
|
509
|
+
_(1, hr),
|
|
510
|
+
_(2, vr),
|
|
511
|
+
_(3, b(gr)),
|
|
510
512
|
_(4, b(m)),
|
|
511
|
-
_(5, b(
|
|
513
|
+
_(5, b(X))
|
|
512
514
|
], N);
|
|
513
|
-
const
|
|
514
|
-
var
|
|
515
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
515
|
+
const Xr = "action-recorder.config", G = {};
|
|
516
|
+
var et = Object.defineProperty, rt = Object.getOwnPropertyDescriptor, tt = (e, r, t, n) => {
|
|
517
|
+
for (var o = n > 1 ? void 0 : n ? rt(r, t) : r, i = e.length - 1, c; i >= 0; i--)
|
|
516
518
|
(c = e[i]) && (o = (n ? c(r, t, o) : c(o)) || o);
|
|
517
|
-
return n && o &&
|
|
518
|
-
},
|
|
519
|
-
let
|
|
520
|
-
constructor(e =
|
|
519
|
+
return n && o && et(r, t, o), o;
|
|
520
|
+
}, Z = (e, r) => (t, n) => r(t, n, e), j;
|
|
521
|
+
let K = (j = class extends ge {
|
|
522
|
+
constructor(e = G, r, t) {
|
|
521
523
|
super(), this._config = e, this._injector = r, this._configService = t;
|
|
522
|
-
const { menu: n, ...o } =
|
|
523
|
-
|
|
524
|
+
const { menu: n, ...o } = he(
|
|
525
|
+
{},
|
|
526
|
+
G,
|
|
527
|
+
this._config
|
|
528
|
+
);
|
|
529
|
+
n && this._configService.setConfig("menu", n, { merge: !0 }), this._configService.setConfig(Xr, o);
|
|
524
530
|
}
|
|
525
531
|
onStarting() {
|
|
526
532
|
(this._config.replayOnly ? [[S]] : [
|
|
@@ -533,12 +539,12 @@ let Z = (j = class extends pe {
|
|
|
533
539
|
this._config.replayOnly || this._injector.get(N);
|
|
534
540
|
}
|
|
535
541
|
}, u(j, "pluginName", "UNIVER_ACTION_RECORDER_PLUGIN"), j);
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
],
|
|
542
|
+
K = tt([
|
|
543
|
+
Z(1, b(X)),
|
|
544
|
+
Z(2, ve)
|
|
545
|
+
], K);
|
|
540
546
|
export {
|
|
541
547
|
m as ActionRecorderService,
|
|
542
548
|
S as ActionReplayService,
|
|
543
|
-
|
|
549
|
+
K as UniverActionRecorderPlugin
|
|
544
550
|
};
|
package/lib/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.univer-action-recorder-panel{position:fixed;bottom:80px;width:512px;height:64px;border-radius:var(--border-radius-xl);background-color:rgb(var(--bg-color-secondary));z-index:1000;left:50%;transform:translate(-50%);box-shadow:var(--box-shadow-lg);padding-left:var(--padding-xl);padding-right:var(--padding-xl);display:flex;align-items:center}.univer-action-recorder-panel-icon{flex-grow:0;flex-shrink:0;font-size:var(--font-size-xxl);width:var(--font-size-xxl);height:var(--font-size-xxl);margin-right:var(--margin-xs)}@keyframes univer-recording{0%{color:rgb(var(--text-color))}40%{color:red}60%{color:red}to{color:rgb(var(--text-color))}}.univer-action-recorder-panel-icon-recording>svg>g>path:first-of-type{animation:univer-recording 2s infinite}.univer-action-recorder-panel-title{flex-grow:1;font-size:var(--font-size-xs)}.univer-action-recorder-panel-actions{display:flex;flex-grow:0;flex-shrink:0;width:260px;justify-content:space-between}.univer-action-recorder-panel-actions>button{width:80px}
|
|
1
|
+
*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(63 131 248 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(63 131 248 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*{scrollbar-color:initial;scrollbar-width:initial}@keyframes enter{0%{opacity:var(--tw-enter-opacity, 1);transform:translate3d(var(--tw-enter-translate-x, 0),var(--tw-enter-translate-y, 0),0) scale3d(var(--tw-enter-scale, 1),var(--tw-enter-scale, 1),var(--tw-enter-scale, 1)) rotate(var(--tw-enter-rotate, 0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity, 1);transform:translate3d(var(--tw-exit-translate-x, 0),var(--tw-exit-translate-y, 0),0) scale3d(var(--tw-exit-scale, 1),var(--tw-exit-scale, 1),var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0))}}.univer-action-recorder-panel{position:fixed;bottom:80px;width:512px;height:64px;border-radius:var(--border-radius-xl);background-color:rgb(var(--bg-color-secondary));z-index:1000;left:50%;transform:translate(-50%);box-shadow:var(--box-shadow-lg);padding-left:var(--padding-xl);padding-right:var(--padding-xl);display:flex;align-items:center}.univer-action-recorder-panel-icon{flex-grow:0;flex-shrink:0;font-size:var(--font-size-xxl);width:var(--font-size-xxl);height:var(--font-size-xxl);margin-right:var(--margin-xs)}@keyframes univer-recording{0%{color:rgb(var(--text-color))}40%{color:red}60%{color:red}to{color:rgb(var(--text-color))}}.univer-action-recorder-panel-icon-recording>svg>g>path:first-of-type{animation:univer-recording 2s infinite}.univer-action-recorder-panel-title{flex-grow:1;font-size:var(--font-size-xs)}.univer-action-recorder-panel-actions{display:flex;flex-grow:0;flex-shrink:0;width:260px;justify-content:space-between}.univer-action-recorder-panel-actions>button{width:80px}
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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,S,m,b,h,_){"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)},Y=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},$=_.forwardRef(function(n,t){var e=n.icon,r=n.id,o=n.className,a=n.extend,d=Y(n,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),l=_.useRef("_".concat(ee()));return V(e,"".concat(r),{defIds:e.defIds,idSuffix:l.current},p({ref:t,className:u},d),a)});function V(n,t,e,r,o){return _.createElement(n.tag,p(p({key:t},Q(n,e,o)),r),(X(n,e).children||[]).map(function(a,d){return V(a,"".concat(t,"-").concat(n.tag,"-").concat(d),e,void 0,o)}))}function Q(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],u=a[1];typeof u=="string"&&(r[d]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),r}function X(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 ee(){return Math.random().toString(36).substring(2,8)}$.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"]},w=_.forwardRef(function(n,t){return _.createElement($,Object.assign({},n,{id:"record-single",ref:t,icon:ne}))});w.displayName="RecordSingle";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},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,u=this._recordedCommands;let l={...r};const R=(o=this._instanceService.getFocusedUnit())==null?void 0:o.getUnitId(),{unitId:v=R,subUnitId:f}=l==null?void 0:l.params;if(e&&v&&f){const I=(a=this._instanceService.getUnit(v).getSheetBySheetId(f))==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&&(u.push(l),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()}},c.ActionRecorderService=oe([M(0,i.ICommandService),M(1,i.ILogService),M(2,m.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 ie=Object.defineProperty,ce=Object.getOwnPropertyDescriptor,ae=(n,t,e,r)=>{for(var o=r>1?void 0:r?ce(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&&ie(t,e,o),o},P=(n,t)=>(e,r)=>t(e,r,n),U=(n=>(n.DEFAULT="default",n.NAME="name",n.ACTIVE="active",n))(U||{});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,u;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:v}=l,f=v;if(f){if(typeof f.unitId<"u"&&(f.unitId=r),o==="name"&&f.subUnitId!=="undefined"){const y=(d=this._instanceService.getFocusedUnit().getSheetBySheetName(f.subUnitId))==null?void 0:d.getSheetId();y?f.subUnitId=y:this._logService.error("[ReplayService]",`failed to find subunit by subUnitName = ${f.subUnitId}`)}if(o==="active"&&f.subUnitId!=="undefined"){const y=(u=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:u.getSheetId();y?f.subUnitId=y:this._logService.error("[ReplayService]","failed to find active subunit")}if(!await this._commandService.executeCommand(R,v))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(de());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=ae([P(0,m.IMessageService),P(1,i.IUniverInstanceService),P(2,m.ILocalFileService),P(3,i.ILogService),P(4,i.ICommandService)],c.ActionReplayService);function de(){return Math.floor(Math.random()*800)+200}const x={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}},E={id:"action-recorder.command.replay-local-records-name",type:i.CommandType.COMMAND,handler:async n=>{const e=await n.get(c.ActionReplayService).replayLocalJSON(U.NAME);return e&&n.get(m.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(U.ACTIVE);return e&&n.get(m.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={};/**
|
|
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
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var H;function
|
|
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"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/action-recorder",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -54,21 +54,21 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@univerjs/icons": "^0.2.8",
|
|
56
56
|
"clsx": "^2.1.1",
|
|
57
|
-
"@univerjs/core": "0.5.
|
|
58
|
-
"@univerjs/design": "0.5.
|
|
59
|
-
"@univerjs/sheets": "0.5.
|
|
60
|
-
"@univerjs/sheets
|
|
61
|
-
"@univerjs/
|
|
62
|
-
"@univerjs/ui": "0.5.
|
|
57
|
+
"@univerjs/core": "0.5.2",
|
|
58
|
+
"@univerjs/design": "0.5.2",
|
|
59
|
+
"@univerjs/sheets-filter": "0.5.2",
|
|
60
|
+
"@univerjs/sheets": "0.5.2",
|
|
61
|
+
"@univerjs/ui": "0.5.2",
|
|
62
|
+
"@univerjs/sheets-ui": "0.5.2"
|
|
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
|
"typescript": "^5.7.2",
|
|
69
|
-
"vite": "^6.0.
|
|
70
|
-
"vitest": "^2.1.
|
|
71
|
-
"@univerjs-infra/shared": "0.5.
|
|
69
|
+
"vite": "^6.0.3",
|
|
70
|
+
"vitest": "^2.1.8",
|
|
71
|
+
"@univerjs-infra/shared": "0.5.2"
|
|
72
72
|
},
|
|
73
73
|
"space": {
|
|
74
74
|
".": {
|