@univerjs/action-recorder 0.5.0 → 0.5.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 +2 -2
- package/lib/cjs/locale/fr-FR.js +1 -0
- package/lib/es/index.js +235 -229
- package/lib/es/locale/fr-FR.js +12 -0
- package/lib/types/controllers/config.schema.d.ts +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/locale/fr-FR.d.ts +3 -0
- package/lib/umd/index.js +2 -2
- package/lib/umd/locale/fr-FR.js +1 -0
- package/package.json +13 -13
package/lib/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Z=Object.defineProperty;var K=(e,n,r)=>n in e?Z(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r;var v=(e,n,r)=>K(e,typeof n!="symbol"?n+"":n,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),s=require("@univerjs/sheets"),T=require("@univerjs/sheets-filter"),m=require("@univerjs/sheets-ui"),d=require("@univerjs/ui"),A=require("rxjs"),C=require("@univerjs/design"),S=require("react");var p=function(){return p=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},p.apply(this,arguments)},Y=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=S.forwardRef(function(e,n){var r=e.icon,t=e.id,o=e.className,c=e.extend,i=Y(e,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(t," ").concat(o||"").trim(),l=S.useRef("_".concat(ee()));return B(r,"".concat(t),{defIds:r.defIds,idSuffix:l.current},p({ref:n,className:u},i),c)});function B(e,n,r,t,o){return S.createElement(e.tag,p(p({key:n},Q(e,r,o)),t),(X(e,r).children||[]).map(function(c,i){return B(c,"".concat(n,"-").concat(e.tag,"-").concat(i),r,void 0,o)}))}function Q(e,n,r){var t=p({},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 X(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)?p(p({},e),{children:e.children.map(function(o){return typeof o.attrs.id=="string"&&t&&t.indexOf(o.attrs.id)>-1?p(p({},o),{attrs:p(p({},o.attrs),{id:o.attrs.id+n.idSuffix})}):o})}):e}function ee(){return Math.random().toString(36).substring(2,8)}L.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"]},U=S.forwardRef(function(e,n){return S.createElement(L,Object.assign({},e,{id:"record-single",ref:n,icon:re}))});U.displayName="RecordSingle";var te=Object.defineProperty,ne=Object.getOwnPropertyDescriptor,oe=(e,n,r,t)=>{for(var o=t>1?void 0:t?ne(n,r):n,c=e.length-1,i;c>=0;c--)(i=e[c])&&(o=(t?i(n,r,o):i(o))||o);return t&&o&&te(n,r,o),o},P=(e,n)=>(r,t)=>n(r,t,e);exports.ActionRecorderService=class extends a.Disposable{constructor(r,t,o,c){super();v(this,"_shouldRecordCommands",new Set);v(this,"_panelOpened$",new A.BehaviorSubject(!1));v(this,"panelOpened$",this._panelOpened$.asObservable());v(this,"_recorder",null);v(this,"_recording$",new A.BehaviorSubject(!1));v(this,"recording$",this._recording$.asObservable());v(this,"_recorded$",new A.BehaviorSubject([]));v(this,"_recordedCommands$",new A.BehaviorSubject([]));v(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===a.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 l={...t};const _=(o=this._instanceService.getFocusedUnit())==null?void 0:o.getUnitId(),{unitId:h=_,subUnitId:f}=l==null?void 0:l.params;if(r&&h&&f){const x=(c=this._instanceService.getUnit(h).getSheetBySheetId(f))==null?void 0:c.getName();l={...l,params:{...l.params,subUnitId:x}}}l.id===s.SetSelectionsOperation.id&&i.length>0&&i[i.length-1].id===s.SetSelectionsOperation.id?i[i.length-1]=l:(i.push(l),this._recorded$.next(i),l.type===a.CommandType.COMMAND&&(u.push(l),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=oe([P(0,a.ICommandService),P(1,a.ILogService),P(2,d.ILocalFileService),P(3,a.IUniverInstanceService)],exports.ActionRecorderService);const V={id:"action-recorder.command.start-recording",type:a.CommandType.COMMAND,handler:(e,n)=>(e.get(exports.ActionRecorderService).startRecording(!!(n!=null&&n.replaceId)),!0)},W={id:"action-recorder.command.complete-recording",type:a.CommandType.COMMAND,handler:e=>(e.get(exports.ActionRecorderService).completeRecording(),!0)},q={id:"action-recorder.command.stop-recording",type:a.CommandType.COMMAND,handler:e=>(e.get(exports.ActionRecorderService).completeRecording(),!0)};var ce=Object.defineProperty,ie=Object.getOwnPropertyDescriptor,ae=(e,n,r,t)=>{for(var o=t>1?void 0:t?ie(n,r):n,c=e.length-1,i;c>=0;c--)(i=e[c])&&(o=(t?i(n,r,o):i(o))||o);return t&&o&&ce(n,r,o),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 a.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 l of n){const{id:_,params:h}=l,f=h;if(f){if(typeof f.unitId<"u"&&(f.unitId=t),o==="name"&&f.subUnitId!=="undefined"){const R=(i=this._instanceService.getFocusedUnit().getSheetBySheetName(f.subUnitId))==null?void 0:i.getSheetId();R?f.subUnitId=R:this._logService.error("[ReplayService]",`failed to find subunit by subUnitName = ${f.subUnitId}`)}if(o==="active"&&f.subUnitId!=="undefined"){const R=(u=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:u.getSheetId();R?f.subUnitId=R:this._logService.error("[ReplayService]","failed to find active subunit")}if(!await this._commandService.executeCommand(_,h))return!1}else if(!await this._commandService.executeCommand(_))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 a.awaitTime(se());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=ae([I(0,d.IMessageService),I(1,a.IUniverInstanceService),I(2,d.ILocalFileService),I(3,a.ILogService),I(4,a.ICommandService)],exports.ActionReplayService);function se(){return Math.floor(Math.random()*800)+200}const w={id:"action-recorder.command.replay-local-records",type:a.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}},$={id:"action-recorder.command.replay-local-records-name",type:a.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}},F={id:"action-recorder.command.replay-local-records-active",type:a.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}},E={id:"action-recorder.operation.open-panel",type:a.CommandType.OPERATION,handler(e){return e.get(exports.ActionRecorderService).togglePanel(!0),!0}},z={id:"action-recorder.operation.close-panel",type:a.CommandType.OPERATION,handler(e){return e.get(exports.ActionRecorderService).togglePanel(!1),!0}};var k={exports:{}},M={};/**
|
|
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={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var L;function le(){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 f,m={},y=null,C=null;h!==void 0&&(y=""+h),d.key!==void 0&&(y=""+d.key),d.ref!==void 0&&(C=d.ref);for(f in d)t.call(d,f)&&!i.hasOwnProperty(f)&&(m[f]=d[f]);if(l&&l.defaultProps)for(f in d=l.defaultProps,d)m[f]===void 0&&(m[f]=d[f]);return{$$typeof:n,type:l,key:y,ref:C,props:m,_owner:o.current}}return A.Fragment=e,A.jsx=c,A.jsxs=c,A}var B;function me(){return B||(B=1,j.exports=le()),j.exports}var _=me();function G(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=G(r[n]))&&(t&&(t+=" "),t+=e)}else for(e in r)r[e]&&(t&&(t+=" "),t+=e);return t}function ue(){for(var r,n,e=0,t="",o=arguments.length;e<o;e++)(r=arguments[e])&&(n=G(r))&&(t&&(t+=" "),t+=n);return t}const fe="univer-action-recorder-panel",pe="univer-action-recorder-panel-icon",ve="univer-action-recorder-panel-icon-recording",Se="univer-recording",ge="univer-action-recorder-panel-title",he="univer-action-recorder-panel-actions",P={actionRecorderPanel:fe,actionRecorderPanelIcon:pe,actionRecorderPanelIconRecording:ve,recording:Se,actionRecorderPanelTitle:ge,actionRecorderPanelActions:he};function _e(){const r=a.useDependency(exports.ActionRecorderService);return u.useObservable(r.panelOpened$)?_.jsx(Ce,{}):null}function Ce(){var f;const r=a.useDependency(a.ICommandService),n=a.useDependency(exports.ActionRecorderService),e=u.useObservable(n.recording$),t=u.useObservable(n.recordedCommands$),o=(f=t==null?void 0:t.length)!=null?f:0,i=g.useCallback(()=>{e||r.executeCommand(H.id)},[r,e]),c=g.useCallback(m=>{e||r.executeCommand(W.id,{replaceId:m})},[r,e]),l=g.useCallback(()=>{e&&r.executeCommand(z.id)},[r,e]),d=g.useCallback(()=>{e&&r.executeCommand(k.id)},[r,e]),h=e?o===0?"Recording...":`${o}: ${t[o-1].id}`:"Start Recording";return _.jsxs("div",{className:P.actionRecorderPanel,children:[_.jsx("div",{className:ue(P.actionRecorderPanelIcon,e?P.actionRecorderPanelIconRecording:!1),children:_.jsx(N,{})}),_.jsx("div",{className:P.actionRecorderPanelTitle,children:h}),_.jsxs("div",{className:P.actionRecorderPanelActions,children:[_.jsx(R.Button,{type:"default",size:"small",onClick:e?d:i,children:e?"Cancel":"Close"}),_.jsx(R.Button,{type:"primary",size:"small",onClick:e?l:()=>c(),children:e?"Save":"Start"}),!e&&_.jsx(R.Button,{type:"primary",size:"small",onClick:()=>c(!0),children:"Start(N)"})]})]})}const Z="RECORD_MENU_ITEM";function ye(){return{id:Z,type:u.MenuItemType.SUBITEMS,icon:"RecordSingle",tooltip:"action-recorder.menu.title"}}function Re(r){const n=r.get(exports.ActionRecorderService);return{id:D.id,title:"action-recorder.menu.record",type:u.MenuItemType.BUTTON,disabled$:n.panelOpened$}}function Ie(){return{id:$.id,title:"action-recorder.menu.replay-local",type:u.MenuItemType.BUTTON}}function Oe(){return{id:E.id,title:"action-recorder.menu.replay-local-name",type:u.MenuItemType.BUTTON}}function Ae(){return{id:F.id,title:"action-recorder.menu.replay-local-active",type:u.MenuItemType.BUTTON}}const Pe={[u.RibbonStartGroup.OTHERS]:{[Z]:{order:10,menuItemFactory:ye,[D.id]:{order:1,menuItemFactory:Re},[$.id]:{order:2,menuItemFactory:Ie},[E.id]:{order:3,menuItemFactory:Oe},[F.id]:{order:4,menuItemFactory:Ae}}}};var be=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,Me=(r,n,e,t)=>{for(var o=t>1?void 0:t?xe(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&&be(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(){[W,k,z,D,H,$,E,F].forEach(r=>this._commandSrv.registerCommand(r))}_initUI(){this._uiPartsSrv.registerComponent(u.BuiltInUIPart.GLOBAL,()=>a.connectInjector(_e,this._injector)),this._componentManager.register("RecordSingle",N),this._menuManagerService.mergeMenu(Pe)}_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,p.SetRangeBoldCommand,p.SetRangeFontFamilyCommand,p.SetRangeFontSizeCommand,p.SetRangeItalicCommand,p.SetRangeStrickThroughCommand,p.SetRangeSubscriptCommand,p.SetRangeSuperscriptCommand,p.SetRangeTextColorCommand,p.SetRangeUnderlineCommand,s.SetRangeValuesCommand,s.SetStrikeThroughCommand,s.SetTextColorCommand,s.SetTextRotationCommand,s.SetTextWrapCommand,s.SetVerticalTextAlignCommand,p.SheetCopyCommand,p.SheetCutCommand,p.SheetPasteBesidesBorderCommand,p.SheetPasteColWidthCommand,p.SheetPasteCommand,p.SheetPasteFormatCommand,p.SheetPasteShortKeyCommand,p.SheetPasteValueCommand,s.SetWorksheetActivateCommand,s.SetWorksheetActiveOperation,s.SetSelectionsOperation,T.SetSheetFilterRangeCommand,T.SetSheetsFilterCriteriaCommand,T.RemoveSheetFilterCommand].forEach(r=>this._actionRecorderService.registerRecordedCommand(r))}_initDocsCommands(){}};M=Me([I(0,a.ICommandService),I(1,u.IUIPartsService),I(2,u.IMenuManagerService),I(3,a.Inject(u.ComponentManager)),I(4,a.Inject(exports.ActionRecorderService)),I(5,a.Inject(a.Injector))],M);const Te="action-recorder.config",je={};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},V=(r,n)=>(e,t)=>n(e,t,r),U;exports.UniverActionRecorderPlugin=(U=class extends a.Plugin{constructor(n=je,e,t){super(),this._config=n,this._injector=e,this._configService=t;const{menu:o,...i}=this._config;o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Te,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([V(1,a.Inject(a.Injector)),V(2,a.IConfigService)],exports.UniverActionRecorderPlugin);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e={"action-recorder":{menu:{title:"Enregistrer les actions",record:"Enregistrer les actions...","replay-local":"Lecture de l'enregistrement local..."}}};module.exports=e;
|
package/lib/es/index.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Disposable as
|
|
5
|
-
import { SetSelectionsOperation as
|
|
6
|
-
import { SetSheetFilterRangeCommand as
|
|
7
|
-
import { SetRangeBoldCommand as
|
|
8
|
-
import { ILocalFileService as
|
|
9
|
-
import { BehaviorSubject as
|
|
1
|
+
var le = Object.defineProperty;
|
|
2
|
+
var me = (e, r, t) => r in e ? le(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
3
|
+
var u = (e, r, t) => me(e, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
+
import { Disposable as D, CommandType as g, ICommandService as M, ILogService as K, IUniverInstanceService as Y, awaitTime as ue, useDependency as T, Inject as b, Injector as Q, connectInjector as fe, Plugin as pe, IConfigService as ge } from "@univerjs/core";
|
|
5
|
+
import { SetSelectionsOperation as E, CopySheetCommand as he, DeleteRangeMoveLeftCommand as ve, DeleteRangeMoveUpCommand as Se, DeltaColumnWidthCommand as _e, DeltaRowHeightCommand as Ce, InsertSheetCommand as ye, InsertColAfterCommand as Re, InsertColBeforeCommand as Ie, InsertRowAfterCommand as Oe, InsertRowBeforeCommand as Pe, RemoveSheetCommand as xe, SetStyleCommand as be, AddWorksheetMergeCommand as Ne, AddWorksheetMergeAllCommand as Me, AddWorksheetMergeVerticalCommand as Ae, AddWorksheetMergeHorizontalCommand as Ue, SetFrozenCommand as we, CancelFrozenCommand as $e, SetHorizontalTextAlignCommand as je, SetOverlineCommand as Te, SetRangeValuesCommand as Ee, SetStrikeThroughCommand as Fe, SetTextColorCommand as De, SetTextRotationCommand as Le, SetTextWrapCommand as Be, SetVerticalTextAlignCommand as Ve, SetWorksheetActivateCommand as Je, SetWorksheetActiveOperation as We } from "@univerjs/sheets";
|
|
6
|
+
import { SetSheetFilterRangeCommand as ze, SetSheetsFilterCriteriaCommand as He, RemoveSheetFilterCommand as qe } from "@univerjs/sheets-filter";
|
|
7
|
+
import { SetRangeBoldCommand as ke, SetRangeFontFamilyCommand as Ge, SetRangeFontSizeCommand as Ze, SetRangeItalicCommand as Ke, SetRangeStrickThroughCommand as Ye, SetRangeSubscriptCommand as Qe, SetRangeSuperscriptCommand as Xe, SetRangeTextColorCommand as er, SetRangeUnderlineCommand as rr, SheetCopyCommand as tr, SheetCutCommand as nr, SheetPasteBesidesBorderCommand as or, SheetPasteColWidthCommand as ir, SheetPasteCommand as cr, SheetPasteFormatCommand as ar, SheetPasteShortKeyCommand as sr, SheetPasteValueCommand as dr } from "@univerjs/sheets-ui";
|
|
8
|
+
import { ILocalFileService as X, IMessageService as A, useObservable as F, RibbonStartGroup as lr, MenuItemType as I, ComponentManager as mr, IUIPartsService as ur, IMenuManagerService as fr, BuiltInUIPart as pr } from "@univerjs/ui";
|
|
9
|
+
import { BehaviorSubject as O } from "rxjs";
|
|
10
10
|
import { MessageType as U, Button as w } from "@univerjs/design";
|
|
11
|
-
import
|
|
12
|
-
var
|
|
13
|
-
return
|
|
11
|
+
import gr, { forwardRef as ee, useRef as hr, createElement as re, useCallback as P } from "react";
|
|
12
|
+
var l = function() {
|
|
13
|
+
return l = Object.assign || function(e) {
|
|
14
14
|
for (var r, t = 1, n = arguments.length; t < n; t++) {
|
|
15
15
|
r = arguments[t];
|
|
16
16
|
for (var o in r) Object.prototype.hasOwnProperty.call(r, o) && (e[o] = r[o]);
|
|
17
17
|
}
|
|
18
18
|
return e;
|
|
19
|
-
},
|
|
20
|
-
},
|
|
19
|
+
}, l.apply(this, arguments);
|
|
20
|
+
}, vr = 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
|
+
}, te = ee(function(e, r) {
|
|
28
|
+
var t = e.icon, n = e.id, o = e.className, i = e.extend, c = vr(e, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(n, " ").concat(o || "").trim(), d = hr("_".concat(Cr()));
|
|
29
|
+
return ne(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 ne(e, r, t, n, o) {
|
|
32
|
+
return re(e.tag, l(l({ key: r }, Sr(e, t, o)), n), (_r(e, t).children || []).map(function(i, c) {
|
|
33
|
+
return ne(i, "".concat(r, "-").concat(e.tag, "-").concat(c), t, void 0, o);
|
|
34
34
|
}));
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
var n =
|
|
36
|
+
function Sr(e, r, t) {
|
|
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;
|
|
40
40
|
return !o || o.length === 0 || (e.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + r.idSuffix), Object.entries(n).forEach(function(i) {
|
|
@@ -42,41 +42,41 @@ function hr(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 _r(e, r) {
|
|
46
46
|
var t, n = r.defIds;
|
|
47
|
-
return !n || n.length === 0 ? e : e.tag === "defs" && (!((t = e.children) === null || t === void 0) && t.length) ?
|
|
48
|
-
return typeof o.attrs.id == "string" && n && n.indexOf(o.attrs.id) > -1 ?
|
|
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
|
+
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 Cr() {
|
|
52
52
|
return Math.random().toString(36).substring(2, 8);
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
var
|
|
56
|
-
return
|
|
54
|
+
te.displayName = "UniverIcon";
|
|
55
|
+
var yr = { 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 = ee(function(e, r) {
|
|
56
|
+
return re(te, Object.assign({}, e, {
|
|
57
57
|
id: "record-single",
|
|
58
58
|
ref: r,
|
|
59
|
-
icon:
|
|
59
|
+
icon: yr
|
|
60
60
|
}));
|
|
61
61
|
});
|
|
62
|
-
|
|
63
|
-
var
|
|
64
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
62
|
+
L.displayName = "RecordSingle";
|
|
63
|
+
var Rr = Object.defineProperty, Ir = Object.getOwnPropertyDescriptor, Or = (e, r, t, n) => {
|
|
64
|
+
for (var o = n > 1 ? void 0 : n ? Ir(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 &&
|
|
67
|
-
},
|
|
68
|
-
let
|
|
66
|
+
return n && o && Rr(r, t, o), o;
|
|
67
|
+
}, x = (e, r) => (t, n) => r(t, n, e);
|
|
68
|
+
let m = class extends D {
|
|
69
69
|
constructor(r, t, n, o) {
|
|
70
70
|
super();
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
u(this, "_shouldRecordCommands", /* @__PURE__ */ new Set());
|
|
72
|
+
u(this, "_panelOpened$", new O(!1));
|
|
73
|
+
u(this, "panelOpened$", this._panelOpened$.asObservable());
|
|
74
|
+
u(this, "_recorder", null);
|
|
75
|
+
u(this, "_recording$", new O(!1));
|
|
76
|
+
u(this, "recording$", this._recording$.asObservable());
|
|
77
|
+
u(this, "_recorded$", new O([]));
|
|
78
|
+
u(this, "_recordedCommands$", new O([]));
|
|
79
|
+
u(this, "recordedCommands$", this._recordedCommands$.asObservable());
|
|
80
80
|
this._commandSrv = r, this._logService = t, this._localFileService = n, this._instanceService = o;
|
|
81
81
|
}
|
|
82
82
|
get recording() {
|
|
@@ -89,7 +89,7 @@ let l = class extends F {
|
|
|
89
89
|
return this._recordedCommands$.getValue();
|
|
90
90
|
}
|
|
91
91
|
registerRecordedCommand(r) {
|
|
92
|
-
if (r.type ===
|
|
92
|
+
if (r.type === g.MUTATION) throw new Error("[CommandRecorderService] Cannot record mutation commands.");
|
|
93
93
|
this._shouldRecordCommands.add(r.id);
|
|
94
94
|
}
|
|
95
95
|
togglePanel(r) {
|
|
@@ -101,18 +101,18 @@ let l = class extends F {
|
|
|
101
101
|
if (this._shouldRecordCommands.has(t.id)) {
|
|
102
102
|
const i = this._recorded, c = this._recordedCommands;
|
|
103
103
|
let a = { ...t };
|
|
104
|
-
const
|
|
105
|
-
if (r &&
|
|
106
|
-
const
|
|
104
|
+
const d = (n = this._instanceService.getFocusedUnit()) == null ? void 0 : n.getUnitId(), { unitId: f = d, subUnitId: s } = a == null ? void 0 : a.params;
|
|
105
|
+
if (r && f && s) {
|
|
106
|
+
const p = (o = this._instanceService.getUnit(f).getSheetBySheetId(s)) == null ? void 0 : o.getName();
|
|
107
107
|
a = {
|
|
108
108
|
...a,
|
|
109
109
|
params: {
|
|
110
110
|
...a.params,
|
|
111
|
-
subUnitId:
|
|
111
|
+
subUnitId: p
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
-
a.id ===
|
|
115
|
+
a.id === E.id && i.length > 0 && i[i.length - 1].id === E.id ? i[i.length - 1] = a : (i.push(a), this._recorded$.next(i), a.type === g.COMMAND && (c.push(a), this._recordedCommands$.next(c)));
|
|
116
116
|
}
|
|
117
117
|
}), this._recording$.next(!0);
|
|
118
118
|
}
|
|
@@ -125,31 +125,31 @@ let l = class extends F {
|
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
],
|
|
134
|
-
const
|
|
128
|
+
m = Or([
|
|
129
|
+
x(0, M),
|
|
130
|
+
x(1, K),
|
|
131
|
+
x(2, X),
|
|
132
|
+
x(3, Y)
|
|
133
|
+
], m);
|
|
134
|
+
const oe = {
|
|
135
135
|
id: "action-recorder.command.start-recording",
|
|
136
|
-
type:
|
|
137
|
-
handler: (e, r) => (e.get(
|
|
138
|
-
},
|
|
136
|
+
type: g.COMMAND,
|
|
137
|
+
handler: (e, r) => (e.get(m).startRecording(!!(r != null && r.replaceId)), !0)
|
|
138
|
+
}, ie = {
|
|
139
139
|
id: "action-recorder.command.complete-recording",
|
|
140
|
-
type:
|
|
141
|
-
handler: (e) => (e.get(
|
|
142
|
-
},
|
|
140
|
+
type: g.COMMAND,
|
|
141
|
+
handler: (e) => (e.get(m).completeRecording(), !0)
|
|
142
|
+
}, ce = {
|
|
143
143
|
id: "action-recorder.command.stop-recording",
|
|
144
|
-
type:
|
|
145
|
-
handler: (e) => (e.get(
|
|
144
|
+
type: g.COMMAND,
|
|
145
|
+
handler: (e) => (e.get(m).completeRecording(), !0)
|
|
146
146
|
};
|
|
147
|
-
var
|
|
148
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
147
|
+
var Pr = Object.defineProperty, xr = Object.getOwnPropertyDescriptor, br = (e, r, t, n) => {
|
|
148
|
+
for (var o = n > 1 ? void 0 : n ? xr(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 &&
|
|
151
|
-
}, C = (e, r) => (t, n) => r(t, n, e),
|
|
152
|
-
let
|
|
150
|
+
return n && o && Pr(r, t, o), o;
|
|
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
|
+
let S = class extends D {
|
|
153
153
|
constructor(e, r, t, n, o) {
|
|
154
154
|
super(), this._messageService = e, this._instanceService = r, this._localFileService = t, this._logService = n, this._commandService = o;
|
|
155
155
|
}
|
|
@@ -180,18 +180,18 @@ let h = class extends F {
|
|
|
180
180
|
t || this._logService.error("[ReplayService]", "no focused unit to replay commands");
|
|
181
181
|
const { mode: n } = r || {};
|
|
182
182
|
for (const a of e) {
|
|
183
|
-
const { id:
|
|
183
|
+
const { id: d, params: f } = a, s = f;
|
|
184
184
|
if (s) {
|
|
185
185
|
if (typeof s.unitId < "u" && (s.unitId = t), n === "name" && s.subUnitId !== "undefined") {
|
|
186
|
-
const
|
|
187
|
-
|
|
186
|
+
const h = (i = this._instanceService.getFocusedUnit().getSheetBySheetName(s.subUnitId)) == null ? void 0 : i.getSheetId();
|
|
187
|
+
h ? s.subUnitId = h : this._logService.error("[ReplayService]", `failed to find subunit by subUnitName = ${s.subUnitId}`);
|
|
188
188
|
}
|
|
189
189
|
if (n === "active" && s.subUnitId !== "undefined") {
|
|
190
|
-
const
|
|
191
|
-
|
|
190
|
+
const h = (c = this._instanceService.getFocusedUnit().getActiveSheet()) == null ? void 0 : c.getSheetId();
|
|
191
|
+
h ? s.subUnitId = h : this._logService.error("[ReplayService]", "failed to find active subunit");
|
|
192
192
|
}
|
|
193
|
-
if (!await this._commandService.executeCommand(
|
|
194
|
-
} else if (!await this._commandService.executeCommand(
|
|
193
|
+
if (!await this._commandService.executeCommand(d, f)) return !1;
|
|
194
|
+
} else if (!await this._commandService.executeCommand(d)) return !1;
|
|
195
195
|
}
|
|
196
196
|
return !0;
|
|
197
197
|
}
|
|
@@ -204,7 +204,7 @@ let h = class extends F {
|
|
|
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 ue(Nr());
|
|
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,60 +213,60 @@ let h = class extends F {
|
|
|
213
213
|
return !0;
|
|
214
214
|
}
|
|
215
215
|
};
|
|
216
|
-
|
|
217
|
-
C(0,
|
|
218
|
-
C(1,
|
|
219
|
-
C(2,
|
|
220
|
-
C(3,
|
|
216
|
+
S = br([
|
|
217
|
+
C(0, A),
|
|
218
|
+
C(1, Y),
|
|
219
|
+
C(2, X),
|
|
220
|
+
C(3, K),
|
|
221
221
|
C(4, M)
|
|
222
|
-
],
|
|
223
|
-
function
|
|
222
|
+
], S);
|
|
223
|
+
function Nr() {
|
|
224
224
|
return Math.floor(Math.random() * 800) + 200;
|
|
225
225
|
}
|
|
226
|
-
const
|
|
226
|
+
const V = {
|
|
227
227
|
id: "action-recorder.command.replay-local-records",
|
|
228
|
-
type:
|
|
228
|
+
type: g.COMMAND,
|
|
229
229
|
handler: async (e) => {
|
|
230
|
-
const t = await e.get(
|
|
231
|
-
return t && e.get(
|
|
230
|
+
const t = await e.get(S).replayLocalJSON();
|
|
231
|
+
return t && e.get(A).show({
|
|
232
232
|
type: U.Success,
|
|
233
233
|
content: "Successfully replayed local records"
|
|
234
234
|
}), t;
|
|
235
235
|
}
|
|
236
|
-
},
|
|
236
|
+
}, J = {
|
|
237
237
|
id: "action-recorder.command.replay-local-records-name",
|
|
238
|
-
type:
|
|
238
|
+
type: g.COMMAND,
|
|
239
239
|
handler: async (e) => {
|
|
240
|
-
const t = await e.get(
|
|
241
|
-
return t && e.get(
|
|
240
|
+
const t = await e.get(S).replayLocalJSON(B.NAME);
|
|
241
|
+
return t && e.get(A).show({
|
|
242
242
|
type: U.Success,
|
|
243
243
|
content: "Successfully replayed local records"
|
|
244
244
|
}), t;
|
|
245
245
|
}
|
|
246
246
|
}, W = {
|
|
247
247
|
id: "action-recorder.command.replay-local-records-active",
|
|
248
|
-
type:
|
|
248
|
+
type: g.COMMAND,
|
|
249
249
|
handler: async (e) => {
|
|
250
|
-
const t = await e.get(
|
|
251
|
-
return t && e.get(
|
|
250
|
+
const t = await e.get(S).replayLocalJSON(B.ACTIVE);
|
|
251
|
+
return t && e.get(A).show({
|
|
252
252
|
type: U.Success,
|
|
253
253
|
content: "Successfully replayed local records"
|
|
254
254
|
}), t;
|
|
255
255
|
}
|
|
256
256
|
}, z = {
|
|
257
257
|
id: "action-recorder.operation.open-panel",
|
|
258
|
-
type:
|
|
258
|
+
type: g.OPERATION,
|
|
259
259
|
handler(e) {
|
|
260
|
-
return e.get(
|
|
260
|
+
return e.get(m).togglePanel(!0), !0;
|
|
261
261
|
}
|
|
262
|
-
},
|
|
262
|
+
}, ae = {
|
|
263
263
|
id: "action-recorder.operation.close-panel",
|
|
264
|
-
type:
|
|
264
|
+
type: g.OPERATION,
|
|
265
265
|
handler(e) {
|
|
266
|
-
return e.get(
|
|
266
|
+
return e.get(m).togglePanel(!1), !0;
|
|
267
267
|
}
|
|
268
268
|
};
|
|
269
|
-
var
|
|
269
|
+
var $ = { exports: {} }, y = {};
|
|
270
270
|
/**
|
|
271
271
|
* @license React
|
|
272
272
|
* react-jsx-runtime.production.min.js
|
|
@@ -276,159 +276,163 @@ var oe = { exports: {} }, A = {};
|
|
|
276
276
|
* This source code is licensed under the MIT license found in the
|
|
277
277
|
* LICENSE file in the root directory of this source tree.
|
|
278
278
|
*/
|
|
279
|
-
var
|
|
280
|
-
function
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
279
|
+
var q;
|
|
280
|
+
function Mr() {
|
|
281
|
+
if (q) return y;
|
|
282
|
+
q = 1;
|
|
283
|
+
var e = gr, r = Symbol.for("react.element"), t = Symbol.for("react.fragment"), n = Object.prototype.hasOwnProperty, o = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
284
|
+
function c(a, d, f) {
|
|
285
|
+
var s, p = {}, h = null, H = null;
|
|
286
|
+
f !== void 0 && (h = "" + f), d.key !== void 0 && (h = "" + d.key), d.ref !== void 0 && (H = d.ref);
|
|
287
|
+
for (s in d) n.call(d, s) && !i.hasOwnProperty(s) && (p[s] = d[s]);
|
|
288
|
+
if (a && a.defaultProps) for (s in d = a.defaultProps, d) p[s] === void 0 && (p[s] = d[s]);
|
|
289
|
+
return { $$typeof: r, type: a, key: h, ref: H, props: p, _owner: o.current };
|
|
290
|
+
}
|
|
291
|
+
return y.Fragment = t, y.jsx = c, y.jsxs = c, y;
|
|
292
|
+
}
|
|
293
|
+
var k;
|
|
294
|
+
function Ar() {
|
|
295
|
+
return k || (k = 1, $.exports = Mr()), $.exports;
|
|
286
296
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
A.jsxs = ie;
|
|
290
|
-
oe.exports = A;
|
|
291
|
-
var f = oe.exports;
|
|
292
|
-
function ce(e) {
|
|
297
|
+
var v = Ar();
|
|
298
|
+
function se(e) {
|
|
293
299
|
var r, t, n = "";
|
|
294
300
|
if (typeof e == "string" || typeof e == "number") n += e;
|
|
295
301
|
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
296
302
|
var o = e.length;
|
|
297
|
-
for (r = 0; r < o; r++) e[r] && (t =
|
|
303
|
+
for (r = 0; r < o; r++) e[r] && (t = se(e[r])) && (n && (n += " "), n += t);
|
|
298
304
|
} else for (t in e) e[t] && (n && (n += " "), n += t);
|
|
299
305
|
return n;
|
|
300
306
|
}
|
|
301
|
-
function
|
|
302
|
-
for (var e, r, t = 0, n = "", o = arguments.length; t < o; t++) (e = arguments[t]) && (r =
|
|
307
|
+
function Ur() {
|
|
308
|
+
for (var e, r, t = 0, n = "", o = arguments.length; t < o; t++) (e = arguments[t]) && (r = se(e)) && (n && (n += " "), n += r);
|
|
303
309
|
return n;
|
|
304
310
|
}
|
|
305
|
-
const
|
|
306
|
-
actionRecorderPanel:
|
|
307
|
-
actionRecorderPanelIcon:
|
|
308
|
-
actionRecorderPanelIconRecording:
|
|
309
|
-
recording:
|
|
310
|
-
actionRecorderPanelTitle:
|
|
311
|
-
actionRecorderPanelActions:
|
|
311
|
+
const wr = "univer-action-recorder-panel", $r = "univer-action-recorder-panel-icon", jr = "univer-action-recorder-panel-icon-recording", Tr = "univer-recording", Er = "univer-action-recorder-panel-title", Fr = "univer-action-recorder-panel-actions", R = {
|
|
312
|
+
actionRecorderPanel: wr,
|
|
313
|
+
actionRecorderPanelIcon: $r,
|
|
314
|
+
actionRecorderPanelIconRecording: jr,
|
|
315
|
+
recording: Tr,
|
|
316
|
+
actionRecorderPanelTitle: Er,
|
|
317
|
+
actionRecorderPanelActions: Fr
|
|
312
318
|
};
|
|
313
|
-
function
|
|
314
|
-
const e =
|
|
315
|
-
return
|
|
319
|
+
function Dr() {
|
|
320
|
+
const e = T(m);
|
|
321
|
+
return F(e.panelOpened$) ? /* @__PURE__ */ v.jsx(Lr, {}) : null;
|
|
316
322
|
}
|
|
317
|
-
function
|
|
323
|
+
function Lr() {
|
|
318
324
|
var s;
|
|
319
|
-
const e =
|
|
320
|
-
t || e.executeCommand(
|
|
321
|
-
}, [e, t]), c =
|
|
322
|
-
t || e.executeCommand(
|
|
323
|
-
}, [e, t]), a =
|
|
324
|
-
t && e.executeCommand(
|
|
325
|
-
}, [e, t]),
|
|
326
|
-
t && e.executeCommand(
|
|
327
|
-
}, [e, t]),
|
|
328
|
-
return /* @__PURE__ */
|
|
329
|
-
/* @__PURE__ */
|
|
330
|
-
/* @__PURE__ */
|
|
331
|
-
/* @__PURE__ */
|
|
332
|
-
/* @__PURE__ */
|
|
333
|
-
/* @__PURE__ */
|
|
334
|
-
!t && /* @__PURE__ */
|
|
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(ae.id);
|
|
327
|
+
}, [e, t]), c = P((p) => {
|
|
328
|
+
t || e.executeCommand(oe.id, { replaceId: p });
|
|
329
|
+
}, [e, t]), a = P(() => {
|
|
330
|
+
t && e.executeCommand(ie.id);
|
|
331
|
+
}, [e, t]), d = P(() => {
|
|
332
|
+
t && e.executeCommand(ce.id);
|
|
333
|
+
}, [e, t]), f = t ? o === 0 ? "Recording..." : `${o}: ${n[o - 1].id}` : "Start Recording";
|
|
334
|
+
return /* @__PURE__ */ v.jsxs("div", { className: R.actionRecorderPanel, children: [
|
|
335
|
+
/* @__PURE__ */ v.jsx("div", { className: Ur(R.actionRecorderPanelIcon, t ? R.actionRecorderPanelIconRecording : !1), children: /* @__PURE__ */ v.jsx(L, {}) }),
|
|
336
|
+
/* @__PURE__ */ v.jsx("div", { className: R.actionRecorderPanelTitle, children: f }),
|
|
337
|
+
/* @__PURE__ */ v.jsxs("div", { className: R.actionRecorderPanelActions, children: [
|
|
338
|
+
/* @__PURE__ */ v.jsx(w, { type: "default", size: "small", onClick: t ? d : i, children: t ? "Cancel" : "Close" }),
|
|
339
|
+
/* @__PURE__ */ v.jsx(w, { type: "primary", size: "small", onClick: t ? a : () => c(), children: t ? "Save" : "Start" }),
|
|
340
|
+
!t && /* @__PURE__ */ v.jsx(w, { type: "primary", size: "small", onClick: () => c(!0), children: "Start(N)" })
|
|
335
341
|
] })
|
|
336
342
|
] });
|
|
337
343
|
}
|
|
338
|
-
const
|
|
339
|
-
function
|
|
344
|
+
const de = "RECORD_MENU_ITEM";
|
|
345
|
+
function Br() {
|
|
340
346
|
return {
|
|
341
|
-
id:
|
|
342
|
-
type:
|
|
347
|
+
id: de,
|
|
348
|
+
type: I.SUBITEMS,
|
|
343
349
|
icon: "RecordSingle",
|
|
344
350
|
tooltip: "action-recorder.menu.title"
|
|
345
351
|
};
|
|
346
352
|
}
|
|
347
|
-
function
|
|
348
|
-
const r = e.get(
|
|
353
|
+
function Vr(e) {
|
|
354
|
+
const r = e.get(m);
|
|
349
355
|
return {
|
|
350
356
|
id: z.id,
|
|
351
357
|
title: "action-recorder.menu.record",
|
|
352
|
-
type:
|
|
358
|
+
type: I.BUTTON,
|
|
353
359
|
disabled$: r.panelOpened$
|
|
354
360
|
};
|
|
355
361
|
}
|
|
356
|
-
function
|
|
362
|
+
function Jr() {
|
|
357
363
|
return {
|
|
358
|
-
id:
|
|
364
|
+
id: V.id,
|
|
359
365
|
title: "action-recorder.menu.replay-local",
|
|
360
|
-
type:
|
|
366
|
+
type: I.BUTTON
|
|
361
367
|
};
|
|
362
368
|
}
|
|
363
|
-
function
|
|
369
|
+
function Wr() {
|
|
364
370
|
return {
|
|
365
|
-
id:
|
|
371
|
+
id: J.id,
|
|
366
372
|
title: "action-recorder.menu.replay-local-name",
|
|
367
|
-
type:
|
|
373
|
+
type: I.BUTTON
|
|
368
374
|
};
|
|
369
375
|
}
|
|
370
|
-
function
|
|
376
|
+
function zr() {
|
|
371
377
|
return {
|
|
372
378
|
id: W.id,
|
|
373
379
|
title: "action-recorder.menu.replay-local-active",
|
|
374
|
-
type:
|
|
380
|
+
type: I.BUTTON
|
|
375
381
|
};
|
|
376
382
|
}
|
|
377
|
-
const
|
|
378
|
-
[
|
|
379
|
-
[
|
|
383
|
+
const Hr = {
|
|
384
|
+
[lr.OTHERS]: {
|
|
385
|
+
[de]: {
|
|
380
386
|
order: 10,
|
|
381
|
-
menuItemFactory:
|
|
387
|
+
menuItemFactory: Br,
|
|
382
388
|
[z.id]: {
|
|
383
389
|
order: 1,
|
|
384
|
-
menuItemFactory:
|
|
390
|
+
menuItemFactory: Vr
|
|
385
391
|
},
|
|
386
|
-
[
|
|
392
|
+
[V.id]: {
|
|
387
393
|
order: 2,
|
|
388
|
-
menuItemFactory:
|
|
394
|
+
menuItemFactory: Jr
|
|
389
395
|
},
|
|
390
|
-
[
|
|
396
|
+
[J.id]: {
|
|
391
397
|
order: 3,
|
|
392
|
-
menuItemFactory:
|
|
398
|
+
menuItemFactory: Wr
|
|
393
399
|
},
|
|
394
400
|
[W.id]: {
|
|
395
401
|
order: 4,
|
|
396
|
-
menuItemFactory:
|
|
402
|
+
menuItemFactory: zr
|
|
397
403
|
}
|
|
398
404
|
}
|
|
399
405
|
}
|
|
400
406
|
};
|
|
401
|
-
var
|
|
402
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
407
|
+
var qr = Object.defineProperty, kr = Object.getOwnPropertyDescriptor, Gr = (e, r, t, n) => {
|
|
408
|
+
for (var o = n > 1 ? void 0 : n ? kr(r, t) : r, i = e.length - 1, c; i >= 0; i--)
|
|
403
409
|
(c = e[i]) && (o = (n ? c(r, t, o) : c(o)) || o);
|
|
404
|
-
return n && o &&
|
|
405
|
-
},
|
|
406
|
-
let
|
|
410
|
+
return n && o && qr(r, t, o), o;
|
|
411
|
+
}, _ = (e, r) => (t, n) => r(t, n, e);
|
|
412
|
+
let N = class extends D {
|
|
407
413
|
constructor(e, r, t, n, o, i) {
|
|
408
414
|
super(), this._commandSrv = e, this._uiPartsSrv = r, this._menuManagerService = t, this._componentManager = n, this._actionRecorderService = o, this._injector = i, this._initCommands(), this._initUI(), this._initSheetsCommands(), this._initDocsCommands();
|
|
409
415
|
}
|
|
410
416
|
_initCommands() {
|
|
411
417
|
[
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
418
|
+
oe,
|
|
419
|
+
ce,
|
|
420
|
+
ie,
|
|
415
421
|
z,
|
|
416
|
-
|
|
417
|
-
B,
|
|
422
|
+
ae,
|
|
418
423
|
V,
|
|
424
|
+
J,
|
|
419
425
|
W
|
|
420
426
|
].forEach((e) => this._commandSrv.registerCommand(e));
|
|
421
427
|
}
|
|
422
428
|
_initUI() {
|
|
423
|
-
this._uiPartsSrv.registerComponent(
|
|
429
|
+
this._uiPartsSrv.registerComponent(pr.GLOBAL, () => fe(Dr, this._injector)), this._componentManager.register("RecordSingle", L), this._menuManagerService.mergeMenu(Hr);
|
|
424
430
|
}
|
|
425
431
|
_initSheetsCommands() {
|
|
426
432
|
[
|
|
427
433
|
// InsertColCommand,
|
|
428
434
|
// InsertRowCommand,
|
|
429
435
|
// #region basic commands
|
|
430
|
-
pe,
|
|
431
|
-
ge,
|
|
432
436
|
he,
|
|
433
437
|
ve,
|
|
434
438
|
Se,
|
|
@@ -441,98 +445,100 @@ let b = class extends F {
|
|
|
441
445
|
Pe,
|
|
442
446
|
xe,
|
|
443
447
|
be,
|
|
444
|
-
Me,
|
|
445
448
|
Ne,
|
|
449
|
+
Me,
|
|
450
|
+
Ae,
|
|
451
|
+
Ue,
|
|
446
452
|
// ResetBackgroundColorCommand,
|
|
447
453
|
// ResetTextColorCommand,
|
|
448
454
|
// SetBackgroundColorCommand,
|
|
449
455
|
// SetBoldCommand,
|
|
450
456
|
// SetFontFamilyCommand,
|
|
451
457
|
// SetFontSizeCommand,
|
|
452
|
-
Ue,
|
|
453
|
-
Ae,
|
|
454
458
|
we,
|
|
455
|
-
// SetItalicCommand,
|
|
456
459
|
$e,
|
|
457
|
-
|
|
460
|
+
je,
|
|
461
|
+
// SetItalicCommand,
|
|
462
|
+
Te,
|
|
458
463
|
ke,
|
|
459
464
|
Ge,
|
|
460
465
|
Ze,
|
|
461
|
-
qe,
|
|
462
466
|
Ke,
|
|
463
467
|
Ye,
|
|
464
468
|
Qe,
|
|
465
469
|
Xe,
|
|
466
|
-
|
|
467
|
-
|
|
470
|
+
er,
|
|
471
|
+
rr,
|
|
468
472
|
Ee,
|
|
469
473
|
Fe,
|
|
470
474
|
De,
|
|
471
|
-
// SetUnderlineCommand,
|
|
472
475
|
Le,
|
|
473
|
-
|
|
474
|
-
|
|
476
|
+
Be,
|
|
477
|
+
// SetUnderlineCommand,
|
|
478
|
+
Ve,
|
|
475
479
|
tr,
|
|
476
480
|
nr,
|
|
477
481
|
or,
|
|
478
482
|
ir,
|
|
479
483
|
cr,
|
|
480
484
|
ar,
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
485
|
+
sr,
|
|
486
|
+
dr,
|
|
487
|
+
Je,
|
|
488
|
+
We,
|
|
489
|
+
E,
|
|
484
490
|
// #endregion
|
|
485
491
|
// #region data validation command
|
|
486
492
|
// #endregion
|
|
487
493
|
// #region conditional formatting command
|
|
488
494
|
// #endregion
|
|
489
495
|
// #region filter command
|
|
490
|
-
We,
|
|
491
496
|
ze,
|
|
492
|
-
He
|
|
497
|
+
He,
|
|
498
|
+
qe
|
|
493
499
|
// #endregion
|
|
494
500
|
].forEach((e) => this._actionRecorderService.registerRecordedCommand(e));
|
|
495
501
|
}
|
|
496
502
|
_initDocsCommands() {
|
|
497
503
|
}
|
|
498
504
|
};
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
],
|
|
507
|
-
const
|
|
508
|
-
var
|
|
509
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
505
|
+
N = Gr([
|
|
506
|
+
_(0, M),
|
|
507
|
+
_(1, ur),
|
|
508
|
+
_(2, fr),
|
|
509
|
+
_(3, b(mr)),
|
|
510
|
+
_(4, b(m)),
|
|
511
|
+
_(5, b(Q))
|
|
512
|
+
], N);
|
|
513
|
+
const Zr = "action-recorder.config", Kr = {};
|
|
514
|
+
var Yr = Object.defineProperty, Qr = Object.getOwnPropertyDescriptor, Xr = (e, r, t, n) => {
|
|
515
|
+
for (var o = n > 1 ? void 0 : n ? Qr(r, t) : r, i = e.length - 1, c; i >= 0; i--)
|
|
510
516
|
(c = e[i]) && (o = (n ? c(r, t, o) : c(o)) || o);
|
|
511
|
-
return n && o &&
|
|
512
|
-
},
|
|
513
|
-
let
|
|
514
|
-
constructor(e =
|
|
517
|
+
return n && o && Yr(r, t, o), o;
|
|
518
|
+
}, G = (e, r) => (t, n) => r(t, n, e), j;
|
|
519
|
+
let Z = (j = class extends pe {
|
|
520
|
+
constructor(e = Kr, r, t) {
|
|
515
521
|
super(), this._config = e, this._injector = r, this._configService = t;
|
|
516
522
|
const { menu: n, ...o } = this._config;
|
|
517
|
-
n && this._configService.setConfig("menu", n, { merge: !0 }), this._configService.setConfig(
|
|
523
|
+
n && this._configService.setConfig("menu", n, { merge: !0 }), this._configService.setConfig(Zr, o);
|
|
518
524
|
}
|
|
519
525
|
onStarting() {
|
|
520
|
-
(this._config.replayOnly ? [[
|
|
521
|
-
[
|
|
522
|
-
[
|
|
523
|
-
[
|
|
526
|
+
(this._config.replayOnly ? [[S]] : [
|
|
527
|
+
[m],
|
|
528
|
+
[S],
|
|
529
|
+
[N]
|
|
524
530
|
]).forEach((r) => this._injector.add(r));
|
|
525
531
|
}
|
|
526
532
|
onSteady() {
|
|
527
|
-
this._config.replayOnly || this._injector.get(
|
|
533
|
+
this._config.replayOnly || this._injector.get(N);
|
|
528
534
|
}
|
|
529
|
-
},
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
],
|
|
535
|
+
}, u(j, "pluginName", "UNIVER_ACTION_RECORDER_PLUGIN"), j);
|
|
536
|
+
Z = Xr([
|
|
537
|
+
G(1, b(Q)),
|
|
538
|
+
G(2, ge)
|
|
539
|
+
], Z);
|
|
534
540
|
export {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
541
|
+
m as ActionRecorderService,
|
|
542
|
+
S as ActionReplayService,
|
|
543
|
+
Z as UniverActionRecorderPlugin
|
|
538
544
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MenuConfig } from '@univerjs/ui';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const ACTION_RECORDER_PLUGIN_CONFIG_KEY = "action-recorder.config";
|
|
3
3
|
export declare const configSymbol: unique symbol;
|
|
4
4
|
export interface IUniverActionRecorderConfig {
|
|
5
5
|
menu?: MenuConfig;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import './global.css';
|
|
16
17
|
export { UniverActionRecorderPlugin } from './plugin';
|
|
17
18
|
export { ActionRecorderService } from './services/action-recorder.service';
|
|
18
19
|
export { ActionReplayService } from './services/replay.service';
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(a,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):(a=typeof globalThis<"u"?globalThis:a||self,i(a.UniverActionRecorder={},a.UniverCore,a.UniverSheets,a.UniverSheetsFilter,a.UniverSheetsUi,a.UniverUi,a.rxjs,a.UniverDesign,a.React))})(this,function(a,i,s,T,m,l,A,_,g){"use strict";var Ne=Object.defineProperty;var we=(a,i,s)=>i in a?Ne(a,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[i]=s;var p=(a,i,s)=>we(a,typeof i!="symbol"?i+"":i,s);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)},Y=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},B=g.forwardRef(function(e,t){var n=e.icon,r=e.id,o=e.className,c=e.extend,d=Y(e,["icon","id","className","extend"]),f="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),u=g.useRef("_".concat(X()));return $(n,"".concat(r),{defIds:n.defIds,idSuffix:u.current},S({ref:t,className:f},d),c)});function $(e,t,n,r,o){return g.createElement(e.tag,S(S({key:t},q(e,n,o)),r),(Q(e,n).children||[]).map(function(c,d){return $(c,"".concat(t,"-").concat(e.tag,"-").concat(d),n,void 0,o)}))}function q(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(c){var d=c[0],f=c[1];typeof f=="string"&&(r[d]=f.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),r}function Q(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 X(){return Math.random().toString(36).substring(2,8)}B.displayName="UniverIcon";var ee={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(e,t){return g.createElement(B,Object.assign({},e,{id:"record-single",ref:t,icon:ee}))});N.displayName="RecordSingle";var ne=Object.defineProperty,re=Object.getOwnPropertyDescriptor,te=(e,t,n,r)=>{for(var o=r>1?void 0:r?re(t,n):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(o=(r?d(t,n,o):d(o))||o);return r&&o&&ne(t,n,o),o},j=(e,t)=>(n,r)=>t(n,r,e);a.ActionRecorderService=class extends i.Disposable{constructor(n,r,o,c){super();p(this,"_shouldRecordCommands",new Set);p(this,"_panelOpened$",new A.BehaviorSubject(!1));p(this,"panelOpened$",this._panelOpened$.asObservable());p(this,"_recorder",null);p(this,"_recording$",new A.BehaviorSubject(!1));p(this,"recording$",this._recording$.asObservable());p(this,"_recorded$",new A.BehaviorSubject([]));p(this,"_recordedCommands$",new A.BehaviorSubject([]));p(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===i.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,f=this._recordedCommands;let u={...r};const R=(o=this._instanceService.getFocusedUnit())==null?void 0:o.getUnitId(),{unitId:y=R,subUnitId:v}=u==null?void 0:u.params;if(n&&y&&v){const L=(c=this._instanceService.getUnit(y).getSheetBySheetId(v))==null?void 0:c.getName();u={...u,params:{...u.params,subUnitId:L}}}u.id===s.SetSelectionsOperation.id&&d.length>0&&d[d.length-1].id===s.SetSelectionsOperation.id?d[d.length-1]=u:(d.push(u),this._recorded$.next(d),u.type===i.CommandType.COMMAND&&(f.push(u),this._recordedCommands$.next(f)))}}),this._recording$.next(!0)}stopRecording(){var 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()}},a.ActionRecorderService=te([j(0,i.ICommandService),j(1,i.ILogService),j(2,l.ILocalFileService),j(3,i.IUniverInstanceService)],a.ActionRecorderService);const V={id:"action-recorder.command.start-recording",type:i.CommandType.COMMAND,handler:(e,t)=>(e.get(a.ActionRecorderService).startRecording(!!(t!=null&&t.replaceId)),!0)},W={id:"action-recorder.command.complete-recording",type:i.CommandType.COMMAND,handler:e=>(e.get(a.ActionRecorderService).completeRecording(),!0)},z={id:"action-recorder.command.stop-recording",type:i.CommandType.COMMAND,handler:e=>(e.get(a.ActionRecorderService).completeRecording(),!0)};var oe=Object.defineProperty,ie=Object.getOwnPropertyDescriptor,ce=(e,t,n,r)=>{for(var o=r>1?void 0:r?ie(t,n):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(o=(r?d(t,n,o):d(o))||o);return r&&o&&oe(t,n,o),o},I=(e,t)=>(n,r)=>t(n,r,e),w=(e=>(e.DEFAULT="default",e.NAME="name",e.ACTIVE="active",e))(w||{});a.ActionReplayService=class extends i.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:_.MessageType.Error,content:`Failed to replay commands from local file ${r.name}.`}),!1}}async replayCommands(t,n){var c,d,f;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 u of t){const{id:R,params:y}=u,v=y;if(v){if(typeof v.unitId<"u"&&(v.unitId=r),o==="name"&&v.subUnitId!=="undefined"){const P=(d=this._instanceService.getFocusedUnit().getSheetBySheetName(v.subUnitId))==null?void 0:d.getSheetId();P?v.subUnitId=P:this._logService.error("[ReplayService]",`failed to find subunit by subUnitName = ${v.subUnitId}`)}if(o==="active"&&v.subUnitId!=="undefined"){const P=(f=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:f.getSheetId();P?v.subUnitId=P:this._logService.error("[ReplayService]","failed to find active subunit")}if(!await this._commandService.executeCommand(R,y))return!1}else if(!await this._commandService.executeCommand(R))return!1}return!0}async replayCommandsWithDelay(t){var r;const 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 i.awaitTime(ae());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}},a.ActionReplayService=ce([I(0,l.IMessageService),I(1,i.IUniverInstanceService),I(2,l.ILocalFileService),I(3,i.ILogService),I(4,i.ICommandService)],a.ActionReplayService);function ae(){return Math.floor(Math.random()*800)+200}const U={id:"action-recorder.command.replay-local-records",type:i.CommandType.COMMAND,handler:async e=>{const n=await e.get(a.ActionReplayService).replayLocalJSON();return n&&e.get(l.IMessageService).show({type:_.MessageType.Success,content:"Successfully replayed local records"}),n}},x={id:"action-recorder.command.replay-local-records-name",type:i.CommandType.COMMAND,handler:async e=>{const n=await e.get(a.ActionReplayService).replayLocalJSON(w.NAME);return n&&e.get(l.IMessageService).show({type:_.MessageType.Success,content:"Successfully replayed local records"}),n}},D={id:"action-recorder.command.replay-local-records-active",type:i.CommandType.COMMAND,handler:async e=>{const n=await e.get(a.ActionReplayService).replayLocalJSON(w.ACTIVE);return n&&e.get(l.IMessageService).show({type:_.MessageType.Success,content:"Successfully replayed local records"}),n}},E={id:"action-recorder.operation.open-panel",type:i.CommandType.OPERATION,handler(e){return e.get(a.ActionRecorderService).togglePanel(!0),!0}},k={id:"action-recorder.operation.close-panel",type:i.CommandType.OPERATION,handler(e){return e.get(a.ActionRecorderService).togglePanel(!1),!0}};var H={exports:{}},b={};/**
|
|
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={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var H;function se(){if(H)return A;H=1;var n=_,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(u,l,R){var v,f={},I=null,y=null;R!==void 0&&(I=""+R),l.key!==void 0&&(I=""+l.key),l.ref!==void 0&&(y=l.ref);for(v in l)r.call(l,v)&&!a.hasOwnProperty(v)&&(f[v]=l[v]);if(u&&u.defaultProps)for(v in l=u.defaultProps,l)f[v]===void 0&&(f[v]=l[v]);return{$$typeof:t,type:u,key:I,ref:y,props:f,_owner:o.current}}return A.Fragment=e,A.jsx=d,A.jsxs=d,A}var G;function le(){return G||(G=1,L.exports=se()),L.exports}var C=le();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 me(){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 ue(){const n=i.useDependency(c.ActionRecorderService);return m.useObservable(n.panelOpened$)?C.jsx(fe,{}):null}function fe(){var v;const n=i.useDependency(i.ICommandService),t=i.useDependency(c.ActionRecorderService),e=m.useObservable(t.recording$),r=m.useObservable(t.recordedCommands$),o=(v=r==null?void 0:r.length)!=null?v:0,a=_.useCallback(()=>{e||n.executeCommand(k.id)},[n,e]),d=_.useCallback(f=>{e||n.executeCommand(J.id,{replaceId:f})},[n,e]),u=_.useCallback(()=>{e&&n.executeCommand(W.id)},[n,e]),l=_.useCallback(()=>{e&&n.executeCommand(z.id)},[n,e]),R=e?o===0?"Recording...":`${o}: ${r[o-1].id}`:"Start Recording";return C.jsxs("div",{className:j.actionRecorderPanel,children:[C.jsx("div",{className:me(j.actionRecorderPanelIcon,e?j.actionRecorderPanelIconRecording:!1),children:C.jsx(w,{})}),C.jsx("div",{className:j.actionRecorderPanelTitle,children:R}),C.jsxs("div",{className:j.actionRecorderPanelActions,children:[C.jsx(h.Button,{type:"default",size:"small",onClick:e?l:a,children:e?"Cancel":"Close"}),C.jsx(h.Button,{type:"primary",size:"small",onClick:e?u:()=>d(),children:e?"Save":"Start"}),!e&&C.jsx(h.Button,{type:"primary",size:"small",onClick:()=>d(!0),children:"Start(N)"})]})]})}const Z="RECORD_MENU_ITEM";function ve(){return{id:Z,type:m.MenuItemType.SUBITEMS,icon:"RecordSingle",tooltip:"action-recorder.menu.title"}}function Se(n){const t=n.get(c.ActionRecorderService);return{id:F.id,title:"action-recorder.menu.record",type:m.MenuItemType.BUTTON,disabled$:t.panelOpened$}}function pe(){return{id:x.id,title:"action-recorder.menu.replay-local",type:m.MenuItemType.BUTTON}}function ge(){return{id:E.id,title:"action-recorder.menu.replay-local-name",type:m.MenuItemType.BUTTON}}function _e(){return{id:D.id,title:"action-recorder.menu.replay-local-active",type:m.MenuItemType.BUTTON}}const Ce={[m.RibbonStartGroup.OTHERS]:{[Z]:{order:10,menuItemFactory:ve,[F.id]:{order:1,menuItemFactory:Se},[x.id]:{order:2,menuItemFactory:pe},[E.id]:{order:3,menuItemFactory:ge},[D.id]:{order:4,menuItemFactory:_e}}}};var Re=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,he=(n,t,e,r)=>{for(var o=r>1?void 0:r?ye(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},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,x,E,D].forEach(n=>this._commandSrv.registerCommand(n))}_initUI(){this._uiPartsSrv.registerComponent(m.BuiltInUIPart.GLOBAL,()=>i.connectInjector(ue,this._injector)),this._componentManager.register("RecordSingle",w),this._menuManagerService.mergeMenu(Ce)}_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,S.SetRangeBoldCommand,S.SetRangeFontFamilyCommand,S.SetRangeFontSizeCommand,S.SetRangeItalicCommand,S.SetRangeStrickThroughCommand,S.SetRangeSubscriptCommand,S.SetRangeSuperscriptCommand,S.SetRangeTextColorCommand,S.SetRangeUnderlineCommand,s.SetRangeValuesCommand,s.SetStrikeThroughCommand,s.SetTextColorCommand,s.SetTextRotationCommand,s.SetTextWrapCommand,s.SetVerticalTextAlignCommand,S.SheetCopyCommand,S.SheetCutCommand,S.SheetPasteBesidesBorderCommand,S.SheetPasteColWidthCommand,S.SheetPasteCommand,S.SheetPasteFormatCommand,S.SheetPasteShortKeyCommand,S.SheetPasteValueCommand,s.SetWorksheetActivateCommand,s.SetWorksheetActiveOperation,s.SetSelectionsOperation,N.SetSheetFilterRangeCommand,N.SetSheetsFilterCriteriaCommand,N.RemoveSheetFilterCommand].forEach(n=>this._actionRecorderService.registerRecordedCommand(n))}_initDocsCommands(){}};T=he([O(0,i.ICommandService),O(1,m.IUIPartsService),O(2,m.IMenuManagerService),O(3,i.Inject(m.ComponentManager)),O(4,i.Inject(c.ActionRecorderService)),O(5,i.Inject(i.Injector))],T);const Ie="action-recorder.config",Oe={};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},K=(n,t)=>(e,r)=>t(e,r,n);c.UniverActionRecorderPlugin=(B=class extends i.Plugin{constructor(t=Oe,e,r){super(),this._config=t,this._injector=e,this._configService=r;const{menu:o,...a}=this._config;o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Ie,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([K(1,i.Inject(i.Injector)),K(2,i.IConfigService)],c.UniverActionRecorderPlugin),Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverActionRecorderFrFR=n())})(this,function(){"use strict";return{"action-recorder":{menu:{title:"Enregistrer les actions",record:"Enregistrer les actions...","replay-local":"Lecture de l'enregistrement local..."}}}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/action-recorder",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -52,23 +52,23 @@
|
|
|
52
52
|
"rxjs": ">=7.0.0"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@univerjs/icons": "^0.2.
|
|
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
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/sheets": "0.5.
|
|
62
|
-
"@univerjs/
|
|
57
|
+
"@univerjs/core": "0.5.1",
|
|
58
|
+
"@univerjs/design": "0.5.1",
|
|
59
|
+
"@univerjs/sheets": "0.5.1",
|
|
60
|
+
"@univerjs/sheets-filter": "0.5.1",
|
|
61
|
+
"@univerjs/sheets-ui": "0.5.1",
|
|
62
|
+
"@univerjs/ui": "0.5.1"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"less": "^4.2.
|
|
65
|
+
"less": "^4.2.1",
|
|
66
66
|
"react": "18.3.1",
|
|
67
67
|
"rxjs": "^7.8.1",
|
|
68
|
-
"typescript": "^5.
|
|
69
|
-
"vite": "^
|
|
70
|
-
"vitest": "^2.1.
|
|
71
|
-
"@univerjs-infra/shared": "0.5.
|
|
68
|
+
"typescript": "^5.7.2",
|
|
69
|
+
"vite": "^6.0.1",
|
|
70
|
+
"vitest": "^2.1.6",
|
|
71
|
+
"@univerjs-infra/shared": "0.5.1"
|
|
72
72
|
},
|
|
73
73
|
"space": {
|
|
74
74
|
".": {
|