@univerjs/action-recorder 0.8.0-beta.0 → 0.8.0-beta.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 +1 -1
- package/lib/es/index.js +49 -49
- package/lib/index.js +49 -49
- package/lib/umd/index.js +1 -1
- package/package.json +9 -9
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var z=Object.defineProperty;var H=(e,n,r)=>n in e?z(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r;var S=(e,n,r)=>H(e,typeof n!="symbol"?n+"":n,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),a=require("@univerjs/sheets"),M=require("@univerjs/sheets-filter"),l=require("@univerjs/sheets-ui"),d=require("@univerjs/ui"),O=require("rxjs"),C=require("@univerjs/design"),f=require("react/jsx-runtime"),h=require("react");var g=function(){return g=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},g.apply(this,arguments)},J=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 i=0,t=Object.getOwnPropertySymbols(e);i<t.length;i++)n.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(e,t[i])&&(r[t[i]]=e[t[i]]);return r},E=h.forwardRef(function(e,n){var r=e.icon,t=e.id,i=e.className,o=e.extend,c=J(e,["icon","id","className","extend"]),m="univerjs-icon univerjs-icon-".concat(t," ").concat(i||"").trim(),u=h.useRef("_".concat(K()));return L(r,"".concat(t),{defIds:r.defIds,idSuffix:u.current},g({ref:n,className:m},c),o)});function L(e,n,r,t,i){return h.createElement(e.tag,g(g({key:n},G(e,r,i)),t),(Z(e,r).children||[]).map(function(o,c){return L(o,"".concat(n,"-").concat(e.tag,"-").concat(c),r,void 0,i)}))}function G(e,n,r){var t=g({},e.attrs);r!=null&&r.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=r.colorChannel1),e.tag==="mask"&&t.id&&(t.id=t.id+n.idSuffix),Object.entries(t).forEach(function(o){var c=o[0],m=o[1];c==="mask"&&typeof m=="string"&&(t[c]=m.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))});var i=n.defIds;return!i||i.length===0||(e.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+n.idSuffix),Object.entries(t).forEach(function(o){var c=o[0],m=o[1];typeof m=="string"&&(t[c]=m.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),t}function Z(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)?g(g({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&t&&t.indexOf(i.attrs.id)>-1?g(g({},i),{attrs:g(g({},i.attrs),{id:i.attrs.id+n.idSuffix})}):i})}):e}function K(){return Math.random().toString(36).substring(2,8)}E.displayName="UniverIcon";var Y={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"]},T=h.forwardRef(function(e,n){return h.createElement(E,Object.assign({},e,{id:"record-single",ref:n,icon:Y}))});T.displayName="RecordSingle";var Q=Object.getOwnPropertyDescriptor,X=(e,n,r,t)=>{for(var i=t>1?void 0:t?Q(n,r):n,o=e.length-1,c;o>=0;o--)(c=e[o])&&(i=c(i)||i);return i},A=(e,n)=>(r,t)=>n(r,t,e);exports.ActionRecorderService=class extends s.Disposable{constructor(r,t,i,o){super();S(this,"_shouldRecordCommands",new Set);S(this,"_panelOpened$",new O.BehaviorSubject(!1));S(this,"panelOpened$",this._panelOpened$.asObservable());S(this,"_recorder",null);S(this,"_recording$",new O.BehaviorSubject(!1));S(this,"recording$",this._recording$.asObservable());S(this,"_recorded$",new O.BehaviorSubject([]));S(this,"_recordedCommands$",new O.BehaviorSubject([]));S(this,"recordedCommands$",this._recordedCommands$.asObservable());this._commandSrv=r,this._logService=t,this._localFileService=i,this._instanceService=o}get recording(){return this._recording$.getValue()}get _recorded(){return this._recorded$.getValue()}get _recordedCommands(){return this._recordedCommands$.getValue()}registerRecordedCommand(r){if(r.type===s.CommandType.MUTATION)throw new Error("[CommandRecorderService] Cannot record mutation commands.");this._shouldRecordCommands.add(r.id)}togglePanel(r){this._panelOpened$.next(r),r===!1&&this.stopRecording()}startRecording(r=!1){this._recorder=this._commandSrv.onCommandExecuted(t=>{var i,o;if(this._shouldRecordCommands.has(t.id)){const c=this._recorded,m=this._recordedCommands;let u={...t};const y=(i=this._instanceService.getFocusedUnit())==null?void 0:i.getUnitId(),{unitId:p=y,subUnitId:v}=u==null?void 0:u.params;if(r&&p&&v){const x=(o=this._instanceService.getUnit(p).getSheetBySheetId(v))==null?void 0:o.getName();u={...u,params:{...u.params,subUnitId:x}}}u.id===a.SetSelectionsOperation.id&&c.length>0&&c[c.length-1].id===a.SetSelectionsOperation.id?c[c.length-1]=u:(c.push(u),this._recorded$.next(c),u.type===s.CommandType.COMMAND&&(m.push(u),this._recordedCommands$.next(m)))}}),this._recording$.next(!0)}stopRecording(){var r;(r=this._recorder)==null||r.dispose(),this._recorder=null,this._recorded$.next([]),this._recordedCommands$.next([]),this._recording$.next(!1)}completeRecording(){const r=this._recorded.slice();this._localFileService.downloadFile(new Blob([JSON.stringify(r,null,2)]),"recorded-commands.json"),this._logService.error("Recorded commands:",r),this.stopRecording()}};exports.ActionRecorderService=X([A(0,s.ICommandService),A(1,s.ILogService),A(2,d.ILocalFileService),A(3,s.IUniverInstanceService)],exports.ActionRecorderService);const B={id:"action-recorder.command.start-recording",type:s.CommandType.COMMAND,handler:(e,n)=>(e.get(exports.ActionRecorderService).startRecording(!!(n!=null&&n.replaceId)),!0)},k={id:"action-recorder.command.complete-recording",type:s.CommandType.COMMAND,handler:e=>(e.get(exports.ActionRecorderService).completeRecording(),!0)},V={id:"action-recorder.command.stop-recording",type:s.CommandType.COMMAND,handler:e=>(e.get(exports.ActionRecorderService).completeRecording(),!0)};var ee=Object.getOwnPropertyDescriptor,re=(e,n,r,t)=>{for(var i=t>1?void 0:t?ee(n,r):n,o=e.length-1,c;o>=0;o--)(c=e[o])&&(i=c(i)||i);return i},I=(e,n)=>(r,t)=>n(r,t,e),U=(e=>(e.DEFAULT="default",e.NAME="name",e.ACTIVE="active",e))(U||{});exports.ActionReplayService=class extends s.Disposable{constructor(n,r,t,i,o){super(),this._messageService=n,this._instanceService=r,this._localFileService=t,this._logService=i,this._commandService=o}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 o,c,m;const t=(o=this._instanceService.getFocusedUnit())==null?void 0:o.getUnitId();t||this._logService.error("[ReplayService]","no focused unit to replay commands");const{mode:i}=r||{};for(const u of n){const{id:y,params:p}=u,v=p;if(v){if(typeof v.unitId<"u"&&(v.unitId=t),i==="name"&&v.subUnitId!=="undefined"){const R=(c=this._instanceService.getFocusedUnit().getSheetBySheetName(v.subUnitId))==null?void 0:c.getSheetId();R?v.subUnitId=R:this._logService.error("[ReplayService]",`failed to find subunit by subUnitName = ${v.subUnitId}`)}if(i==="active"&&v.subUnitId!=="undefined"){const R=(m=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:m.getSheetId();R?v.subUnitId=R:this._logService.error("[ReplayService]","failed to find active subunit")}if(!await this._commandService.executeCommand(y,p))return!1}else if(!await this._commandService.executeCommand(y))return!1}return!0}async replayCommandsWithDelay(n){var t;const r=(t=this._instanceService.getFocusedUnit())==null?void 0:t.getUnitId();r||this._logService.error("[ReplayService]","no focused unit to replay commands");for(const i of n){await s.awaitTime(te());const{id:o,params:c}=i;if(c){if(typeof c.unitId<"u"&&(c.unitId=r),!await this._commandService.executeCommand(o,c))return!1}else if(!await this._commandService.executeCommand(o))return!1}return!0}};exports.ActionReplayService=re([I(0,d.IMessageService),I(1,s.IUniverInstanceService),I(2,d.ILocalFileService),I(3,s.ILogService),I(4,s.ICommandService)],exports.ActionReplayService);function te(){return Math.floor(Math.random()*800)+200}const N={id:"action-recorder.command.replay-local-records",type:s.CommandType.COMMAND,handler:async e=>{const r=await e.get(exports.ActionReplayService).replayLocalJSON();return r&&e.get(d.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),r}},j={id:"action-recorder.command.replay-local-records-name",type:s.CommandType.COMMAND,handler:async e=>{const r=await e.get(exports.ActionReplayService).replayLocalJSON(U.NAME);return r&&e.get(d.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),r}},P={id:"action-recorder.command.replay-local-records-active",type:s.CommandType.COMMAND,handler:async e=>{const r=await e.get(exports.ActionReplayService).replayLocalJSON(U.ACTIVE);return r&&e.get(d.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),r}},$={id:"action-recorder.operation.open-panel",type:s.CommandType.OPERATION,handler(e){return e.get(exports.ActionRecorderService).togglePanel(!0),!0}},W={id:"action-recorder.operation.close-panel",type:s.CommandType.OPERATION,handler(e){return e.get(exports.ActionRecorderService).togglePanel(!1),!0}};function ne(){const e=d.useDependency(exports.ActionRecorderService);return d.useObservable(e.panelOpened$)?f.jsx(ie,{}):null}function ie(){var p;const e=d.useDependency(s.ICommandService),n=d.useDependency(exports.ActionRecorderService),r=d.useObservable(n.recording$),t=d.useObservable(n.recordedCommands$),i=(p=t==null?void 0:t.length)!=null?p:0,o=h.useCallback(()=>{r||e.executeCommand(W.id)},[e,r]),c=h.useCallback(v=>{r||e.executeCommand(B.id,{replaceId:v})},[e,r]),m=h.useCallback(()=>{r&&e.executeCommand(k.id)},[e,r]),u=h.useCallback(()=>{r&&e.executeCommand(V.id)},[e,r]),y=r?i===0?"Recording...":`${i}: ${t[i-1].id}`:"Start Recording";return f.jsxs("div",{className:"univer-fixed univer-bottom-20 univer-left-1/2 univer-z-[1000] univer-flex univer-h-16 univer-w-[512px] -univer-translate-x-1/2 univer-items-center univer-rounded-lg univer-bg-white univer-px-5 univer-shadow-lg",children:[f.jsx("div",{className:"univer-mr-2 univer-size-5 univer-shrink-0 univer-grow-0 univer-text-xl",children:f.jsx(T,{})}),f.jsx("div",{className:"univer-flex-1 univer-text-sm",children:y}),f.jsxs("div",{className:"univer-flex univer-w-64 univer-shrink-0 univer-grow-0 univer-justify-between",children:[f.jsx(C.Button,{className:"univer-w-20",onClick:r?u:o,children:r?"Cancel":"Close"}),f.jsx(C.Button,{className:"univer-w-20",variant:"primary",onClick:r?m:()=>c(),children:r?"Save":"Start"}),!r&&f.jsx(C.Button,{variant:"primary",onClick:()=>c(!0),children:"Start(N)"})]})]})}const q="RECORD_MENU_ITEM";function oe(){return{id:q,type:d.MenuItemType.SUBITEMS,icon:"RecordSingle",tooltip:"action-recorder.menu.title"}}function ce(e){const n=e.get(exports.ActionRecorderService);return{id:$.id,title:"action-recorder.menu.record",type:d.MenuItemType.BUTTON,disabled$:n.panelOpened$}}function ae(){return{id:N.id,title:"action-recorder.menu.replay-local",type:d.MenuItemType.BUTTON}}function se(){return{id:j.id,title:"action-recorder.menu.replay-local-name",type:d.MenuItemType.BUTTON}}function de(){return{id:P.id,title:"action-recorder.menu.replay-local-active",type:d.MenuItemType.BUTTON}}const le={[d.RibbonStartGroup.OTHERS]:{[q]:{order:2,menuItemFactory:oe,[$.id]:{order:1,menuItemFactory:ce},[N.id]:{order:2,menuItemFactory:ae},[j.id]:{order:3,menuItemFactory:se},[P.id]:{order:4,menuItemFactory:de}}}};var me=Object.getOwnPropertyDescriptor,ue=(e,n,r,t)=>{for(var i=t>1?void 0:t?me(n,r):n,o=e.length-1,c;o>=0;o--)(c=e[o])&&(i=c(i)||i);return i},_=(e,n)=>(r,t)=>n(r,t,e);let b=class extends s.Disposable{constructor(e,n,r,t,i,o){super(),this._commandSrv=e,this._uiPartsSrv=n,this._menuManagerService=r,this._componentManager=t,this._actionRecorderService=i,this._injector=o,this._initCommands(),this._initUI(),this._initSheetsCommands(),this._initDocsCommands()}_initCommands(){[B,V,k,$,W,N,j,P].forEach(e=>this._commandSrv.registerCommand(e))}_initUI(){this._uiPartsSrv.registerComponent(d.BuiltInUIPart.GLOBAL,()=>d.connectInjector(ne,this._injector)),this.disposeWithMe(this._componentManager.register("RecordSingle",T)),this._menuManagerService.mergeMenu(le)}_initSheetsCommands(){[a.CopySheetCommand,a.DeleteRangeMoveLeftCommand,a.DeleteRangeMoveUpCommand,a.DeltaColumnWidthCommand,a.DeltaRowHeightCommand,a.InsertSheetCommand,a.InsertColAfterCommand,a.InsertColBeforeCommand,a.InsertRowAfterCommand,a.InsertRowBeforeCommand,a.RemoveSheetCommand,a.SetStyleCommand,a.AddWorksheetMergeCommand,a.AddWorksheetMergeAllCommand,a.AddWorksheetMergeVerticalCommand,a.AddWorksheetMergeHorizontalCommand,a.SetFrozenCommand,a.CancelFrozenCommand,a.SetHorizontalTextAlignCommand,a.SetOverlineCommand,l.SetRangeBoldCommand,l.SetRangeFontFamilyCommand,l.SetRangeFontSizeCommand,l.SetRangeItalicCommand,l.SetRangeStrickThroughCommand,l.SetRangeSubscriptCommand,l.SetRangeSuperscriptCommand,l.SetRangeTextColorCommand,l.SetRangeUnderlineCommand,a.SetRangeValuesCommand,a.SetStrikeThroughCommand,a.SetTextColorCommand,a.SetTextRotationCommand,a.SetTextWrapCommand,a.SetVerticalTextAlignCommand,l.SheetCopyCommand,l.SheetCutCommand,l.SheetPasteBesidesBorderCommand,l.SheetPasteColWidthCommand,l.SheetPasteCommand,l.SheetPasteFormatCommand,l.SheetPasteShortKeyCommand,l.SheetPasteValueCommand,l.AutoFillCommand,l.RefillCommand,a.SetWorksheetActivateCommand,a.SetWorksheetActiveOperation,a.SetSelectionsOperation,M.SetSheetFilterRangeCommand,M.SetSheetsFilterCriteriaCommand,M.RemoveSheetFilterCommand].forEach(e=>this._actionRecorderService.registerRecordedCommand(e))}_initDocsCommands(){}};b=ue([_(0,s.ICommandService),_(1,d.IUIPartsService),_(2,d.IMenuManagerService),_(3,s.Inject(d.ComponentManager)),_(4,s.Inject(exports.ActionRecorderService)),_(5,s.Inject(s.Injector))],b);const ve="action-recorder.config",F={};var ge=Object.getOwnPropertyDescriptor,Se=(e,n,r,t)=>{for(var i=t>1?void 0:t?ge(n,r):n,o=e.length-1,c;o>=0;o--)(c=e[o])&&(i=c(i)||i);return i},D=(e,n)=>(r,t)=>n(r,t,e),w;exports.UniverActionRecorderPlugin=(w=class extends s.Plugin{constructor(n=F,r,t){super(),this._config=n,this._injector=r,this._configService=t;const{menu:i,...o}=s.merge({},F,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ve,o)}onStarting(){(this._config.replayOnly?[[exports.ActionReplayService]]:[[exports.ActionRecorderService],[exports.ActionReplayService],[b]]).forEach(r=>this._injector.add(r))}onSteady(){this._config.replayOnly||this._injector.get(b)}},S(w,"pluginName","UNIVER_ACTION_RECORDER_PLUGIN"),w);exports.UniverActionRecorderPlugin=Se([D(1,s.Inject(s.Injector)),D(2,s.IConfigService)],exports.UniverActionRecorderPlugin);
|
|
1
|
+
"use strict";var z=Object.defineProperty;var H=(e,n,r)=>n in e?z(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r;var g=(e,n,r)=>H(e,typeof n!="symbol"?n+"":n,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),a=require("@univerjs/sheets"),M=require("@univerjs/sheets-filter"),l=require("@univerjs/sheets-ui"),d=require("@univerjs/ui"),O=require("rxjs"),C=require("@univerjs/design"),f=require("react/jsx-runtime"),h=require("react");var S=function(){return S=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},S.apply(this,arguments)},J=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},E=h.forwardRef(function(e,n){var r=e.icon,t=e.id,o=e.className,i=e.extend,c=J(e,["icon","id","className","extend"]),m="univerjs-icon univerjs-icon-".concat(t," ").concat(o||"").trim(),u=h.useRef("_".concat(K()));return L(r,"".concat(t),{defIds:r.defIds,idSuffix:u.current},S({ref:n,className:m},c),i)});function L(e,n,r,t,o){return h.createElement(e.tag,S(S({key:n},G(e,r,o)),t),(Z(e,r).children||[]).map(function(i,c){return L(i,"".concat(n,"-").concat(e.tag,"-").concat(c),r,void 0,o)}))}function G(e,n,r){var t=S({},e.attrs);r!=null&&r.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=r.colorChannel1),e.tag==="mask"&&t.id&&(t.id=t.id+n.idSuffix),Object.entries(t).forEach(function(i){var c=i[0],m=i[1];c==="mask"&&typeof m=="string"&&(t[c]=m.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))});var o=n.defIds;return!o||o.length===0||(e.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+n.idSuffix),Object.entries(t).forEach(function(i){var c=i[0],m=i[1];typeof m=="string"&&(t[c]=m.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),t}function Z(e,n){var r,t=n.defIds;return!t||t.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?S(S({},e),{children:e.children.map(function(o){return typeof o.attrs.id=="string"&&t&&t.includes(o.attrs.id)?S(S({},o),{attrs:S(S({},o.attrs),{id:o.attrs.id+n.idSuffix})}):o})}):e}function K(){return Math.random().toString(36).substring(2,8)}E.displayName="UniverIcon";var Y={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"g",attrs:{fill:"currentColor",clipPath:"url(#record-icon_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-icon_clip0_1559_19"},children:[{tag:"path",attrs:{fill:"white",d:"M0 0H16V16H0z",transform:"translate(.94)"}}]}]}],defIds:["record-icon_clip0_1559_19"]},T=h.forwardRef(function(e,n){return h.createElement(E,Object.assign({},e,{id:"record-icon",ref:n,icon:Y}))});T.displayName="RecordIcon";var Q=Object.getOwnPropertyDescriptor,X=(e,n,r,t)=>{for(var o=t>1?void 0:t?Q(n,r):n,i=e.length-1,c;i>=0;i--)(c=e[i])&&(o=c(o)||o);return o},A=(e,n)=>(r,t)=>n(r,t,e);exports.ActionRecorderService=class extends s.Disposable{constructor(r,t,o,i){super();g(this,"_shouldRecordCommands",new Set);g(this,"_panelOpened$",new O.BehaviorSubject(!1));g(this,"panelOpened$",this._panelOpened$.asObservable());g(this,"_recorder",null);g(this,"_recording$",new O.BehaviorSubject(!1));g(this,"recording$",this._recording$.asObservable());g(this,"_recorded$",new O.BehaviorSubject([]));g(this,"_recordedCommands$",new O.BehaviorSubject([]));g(this,"recordedCommands$",this._recordedCommands$.asObservable());this._commandSrv=r,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(r){if(r.type===s.CommandType.MUTATION)throw new Error("[CommandRecorderService] Cannot record mutation commands.");this._shouldRecordCommands.add(r.id)}togglePanel(r){this._panelOpened$.next(r),r===!1&&this.stopRecording()}startRecording(r=!1){this._recorder=this._commandSrv.onCommandExecuted(t=>{var o,i;if(this._shouldRecordCommands.has(t.id)){const c=this._recorded,m=this._recordedCommands;let u={...t};const y=(o=this._instanceService.getFocusedUnit())==null?void 0:o.getUnitId(),{unitId:p=y,subUnitId:v}=u==null?void 0:u.params;if(r&&p&&v){const x=(i=this._instanceService.getUnit(p).getSheetBySheetId(v))==null?void 0:i.getName();u={...u,params:{...u.params,subUnitId:x}}}u.id===a.SetSelectionsOperation.id&&c.length>0&&c[c.length-1].id===a.SetSelectionsOperation.id?c[c.length-1]=u:(c.push(u),this._recorded$.next(c),u.type===s.CommandType.COMMAND&&(m.push(u),this._recordedCommands$.next(m)))}}),this._recording$.next(!0)}stopRecording(){var r;(r=this._recorder)==null||r.dispose(),this._recorder=null,this._recorded$.next([]),this._recordedCommands$.next([]),this._recording$.next(!1)}completeRecording(){const r=this._recorded.slice();this._localFileService.downloadFile(new Blob([JSON.stringify(r,null,2)]),"recorded-commands.json"),this._logService.error("Recorded commands:",r),this.stopRecording()}};exports.ActionRecorderService=X([A(0,s.ICommandService),A(1,s.ILogService),A(2,d.ILocalFileService),A(3,s.IUniverInstanceService)],exports.ActionRecorderService);const B={id:"action-recorder.command.start-recording",type:s.CommandType.COMMAND,handler:(e,n)=>(e.get(exports.ActionRecorderService).startRecording(!!(n!=null&&n.replaceId)),!0)},k={id:"action-recorder.command.complete-recording",type:s.CommandType.COMMAND,handler:e=>(e.get(exports.ActionRecorderService).completeRecording(),!0)},V={id:"action-recorder.command.stop-recording",type:s.CommandType.COMMAND,handler:e=>(e.get(exports.ActionRecorderService).completeRecording(),!0)};var ee=Object.getOwnPropertyDescriptor,re=(e,n,r,t)=>{for(var o=t>1?void 0:t?ee(n,r):n,i=e.length-1,c;i>=0;i--)(c=e[i])&&(o=c(o)||o);return o},I=(e,n)=>(r,t)=>n(r,t,e),U=(e=>(e.DEFAULT="default",e.NAME="name",e.ACTIVE="active",e))(U||{});exports.ActionReplayService=class extends s.Disposable{constructor(n,r,t,o,i){super(),this._messageService=n,this._instanceService=r,this._localFileService=t,this._logService=o,this._commandService=i}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 i,c,m;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}=r||{};for(const u of n){const{id:y,params:p}=u,v=p;if(v){if(typeof v.unitId<"u"&&(v.unitId=t),o==="name"&&v.subUnitId!=="undefined"){const R=(c=this._instanceService.getFocusedUnit().getSheetBySheetName(v.subUnitId))==null?void 0:c.getSheetId();R?v.subUnitId=R:this._logService.error("[ReplayService]",`failed to find subunit by subUnitName = ${v.subUnitId}`)}if(o==="active"&&v.subUnitId!=="undefined"){const R=(m=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:m.getSheetId();R?v.subUnitId=R:this._logService.error("[ReplayService]","failed to find active subunit")}if(!await this._commandService.executeCommand(y,p))return!1}else if(!await this._commandService.executeCommand(y))return!1}return!0}async replayCommandsWithDelay(n){var t;const r=(t=this._instanceService.getFocusedUnit())==null?void 0:t.getUnitId();r||this._logService.error("[ReplayService]","no focused unit to replay commands");for(const o of n){await s.awaitTime(te());const{id:i,params:c}=o;if(c){if(typeof c.unitId<"u"&&(c.unitId=r),!await this._commandService.executeCommand(i,c))return!1}else if(!await this._commandService.executeCommand(i))return!1}return!0}};exports.ActionReplayService=re([I(0,d.IMessageService),I(1,s.IUniverInstanceService),I(2,d.ILocalFileService),I(3,s.ILogService),I(4,s.ICommandService)],exports.ActionReplayService);function te(){return Math.floor(Math.random()*800)+200}const N={id:"action-recorder.command.replay-local-records",type:s.CommandType.COMMAND,handler:async e=>{const r=await e.get(exports.ActionReplayService).replayLocalJSON();return r&&e.get(d.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),r}},j={id:"action-recorder.command.replay-local-records-name",type:s.CommandType.COMMAND,handler:async e=>{const r=await e.get(exports.ActionReplayService).replayLocalJSON(U.NAME);return r&&e.get(d.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),r}},P={id:"action-recorder.command.replay-local-records-active",type:s.CommandType.COMMAND,handler:async e=>{const r=await e.get(exports.ActionReplayService).replayLocalJSON(U.ACTIVE);return r&&e.get(d.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),r}},$={id:"action-recorder.operation.open-panel",type:s.CommandType.OPERATION,handler(e){return e.get(exports.ActionRecorderService).togglePanel(!0),!0}},W={id:"action-recorder.operation.close-panel",type:s.CommandType.OPERATION,handler(e){return e.get(exports.ActionRecorderService).togglePanel(!1),!0}};function ne(){const e=d.useDependency(exports.ActionRecorderService);return d.useObservable(e.panelOpened$)?f.jsx(oe,{}):null}function oe(){var p;const e=d.useDependency(s.ICommandService),n=d.useDependency(exports.ActionRecorderService),r=d.useObservable(n.recording$),t=d.useObservable(n.recordedCommands$),o=(p=t==null?void 0:t.length)!=null?p:0,i=h.useCallback(()=>{r||e.executeCommand(W.id)},[e,r]),c=h.useCallback(v=>{r||e.executeCommand(B.id,{replaceId:v})},[e,r]),m=h.useCallback(()=>{r&&e.executeCommand(k.id)},[e,r]),u=h.useCallback(()=>{r&&e.executeCommand(V.id)},[e,r]),y=r?o===0?"Recording...":`${o}: ${t[o-1].id}`:"Start Recording";return f.jsxs("div",{className:"univer-fixed univer-bottom-20 univer-left-1/2 univer-z-[1000] univer-flex univer-h-16 univer-w-[512px] -univer-translate-x-1/2 univer-items-center univer-rounded-lg univer-bg-white univer-px-5 univer-shadow-lg",children:[f.jsx("div",{className:"univer-mr-2 univer-size-5 univer-shrink-0 univer-grow-0 univer-text-xl",children:f.jsx(T,{})}),f.jsx("div",{className:"univer-flex-1 univer-text-sm",children:y}),f.jsxs("div",{className:"univer-flex univer-w-64 univer-shrink-0 univer-grow-0 univer-justify-between",children:[f.jsx(C.Button,{className:"univer-w-20",onClick:r?u:i,children:r?"Cancel":"Close"}),f.jsx(C.Button,{className:"univer-w-20",variant:"primary",onClick:r?m:()=>c(),children:r?"Save":"Start"}),!r&&f.jsx(C.Button,{variant:"primary",onClick:()=>c(!0),children:"Start(N)"})]})]})}const q="RECORD_MENU_ITEM";function ie(){return{id:q,type:d.MenuItemType.SUBITEMS,icon:"RecordIcon",tooltip:"action-recorder.menu.title"}}function ce(e){const n=e.get(exports.ActionRecorderService);return{id:$.id,title:"action-recorder.menu.record",type:d.MenuItemType.BUTTON,disabled$:n.panelOpened$}}function ae(){return{id:N.id,title:"action-recorder.menu.replay-local",type:d.MenuItemType.BUTTON}}function se(){return{id:j.id,title:"action-recorder.menu.replay-local-name",type:d.MenuItemType.BUTTON}}function de(){return{id:P.id,title:"action-recorder.menu.replay-local-active",type:d.MenuItemType.BUTTON}}const le={[d.RibbonStartGroup.OTHERS]:{[q]:{order:2,menuItemFactory:ie,[$.id]:{order:1,menuItemFactory:ce},[N.id]:{order:2,menuItemFactory:ae},[j.id]:{order:3,menuItemFactory:se},[P.id]:{order:4,menuItemFactory:de}}}};var me=Object.getOwnPropertyDescriptor,ue=(e,n,r,t)=>{for(var o=t>1?void 0:t?me(n,r):n,i=e.length-1,c;i>=0;i--)(c=e[i])&&(o=c(o)||o);return o},_=(e,n)=>(r,t)=>n(r,t,e);let b=class extends s.Disposable{constructor(e,n,r,t,o,i){super(),this._commandSrv=e,this._uiPartsSrv=n,this._menuManagerService=r,this._componentManager=t,this._actionRecorderService=o,this._injector=i,this._initCommands(),this._initUI(),this._initSheetsCommands(),this._initDocsCommands()}_initCommands(){[B,V,k,$,W,N,j,P].forEach(e=>this._commandSrv.registerCommand(e))}_initUI(){this._uiPartsSrv.registerComponent(d.BuiltInUIPart.GLOBAL,()=>d.connectInjector(ne,this._injector)),this.disposeWithMe(this._componentManager.register("RecordIcon",T)),this._menuManagerService.mergeMenu(le)}_initSheetsCommands(){[a.CopySheetCommand,a.DeleteRangeMoveLeftCommand,a.DeleteRangeMoveUpCommand,a.DeltaColumnWidthCommand,a.DeltaRowHeightCommand,a.InsertSheetCommand,a.InsertColAfterCommand,a.InsertColBeforeCommand,a.InsertRowAfterCommand,a.InsertRowBeforeCommand,a.RemoveSheetCommand,a.SetStyleCommand,a.AddWorksheetMergeCommand,a.AddWorksheetMergeAllCommand,a.AddWorksheetMergeVerticalCommand,a.AddWorksheetMergeHorizontalCommand,a.SetFrozenCommand,a.CancelFrozenCommand,a.SetHorizontalTextAlignCommand,a.SetOverlineCommand,l.SetRangeBoldCommand,l.SetRangeFontFamilyCommand,l.SetRangeFontSizeCommand,l.SetRangeItalicCommand,l.SetRangeStrickThroughCommand,l.SetRangeSubscriptCommand,l.SetRangeSuperscriptCommand,l.SetRangeTextColorCommand,l.SetRangeUnderlineCommand,a.SetRangeValuesCommand,a.SetStrikeThroughCommand,a.SetTextColorCommand,a.SetTextRotationCommand,a.SetTextWrapCommand,a.SetVerticalTextAlignCommand,l.SheetCopyCommand,l.SheetCutCommand,l.SheetPasteBesidesBorderCommand,l.SheetPasteColWidthCommand,l.SheetPasteCommand,l.SheetPasteFormatCommand,l.SheetPasteShortKeyCommand,l.SheetPasteValueCommand,l.AutoFillCommand,l.RefillCommand,a.SetWorksheetActivateCommand,a.SetWorksheetActiveOperation,a.SetSelectionsOperation,M.SetSheetFilterRangeCommand,M.SetSheetsFilterCriteriaCommand,M.RemoveSheetFilterCommand].forEach(e=>this._actionRecorderService.registerRecordedCommand(e))}_initDocsCommands(){}};b=ue([_(0,s.ICommandService),_(1,d.IUIPartsService),_(2,d.IMenuManagerService),_(3,s.Inject(d.ComponentManager)),_(4,s.Inject(exports.ActionRecorderService)),_(5,s.Inject(s.Injector))],b);const ve="action-recorder.config",F={};var Se=Object.getOwnPropertyDescriptor,ge=(e,n,r,t)=>{for(var o=t>1?void 0:t?Se(n,r):n,i=e.length-1,c;i>=0;i--)(c=e[i])&&(o=c(o)||o);return o},D=(e,n)=>(r,t)=>n(r,t,e),w;exports.UniverActionRecorderPlugin=(w=class extends s.Plugin{constructor(n=F,r,t){super(),this._config=n,this._injector=r,this._configService=t;const{menu:o,...i}=s.merge({},F,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(ve,i)}onStarting(){(this._config.replayOnly?[[exports.ActionReplayService]]:[[exports.ActionRecorderService],[exports.ActionReplayService],[b]]).forEach(r=>this._injector.add(r))}onSteady(){this._config.replayOnly||this._injector.get(b)}},g(w,"pluginName","UNIVER_ACTION_RECORDER_PLUGIN"),w);exports.UniverActionRecorderPlugin=ge([D(1,s.Inject(s.Injector)),D(2,s.IConfigService)],exports.UniverActionRecorderPlugin);
|
package/lib/es/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
var ie = Object.defineProperty;
|
|
2
2
|
var ae = (e, t, r) => t in e ? ie(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
3
|
var m = (e, t, r) => ae(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import { Disposable as T, CommandType as u, ICommandService as M, ILogService as J, IUniverInstanceService as G, awaitTime as ce, Inject as
|
|
5
|
-
import { SetSelectionsOperation as $, CopySheetCommand as me, DeleteRangeMoveLeftCommand as ue, DeleteRangeMoveUpCommand as fe, DeltaColumnWidthCommand as
|
|
4
|
+
import { Disposable as T, CommandType as u, ICommandService as M, ILogService as J, IUniverInstanceService as G, awaitTime as ce, Inject as w, Injector as Z, IConfigService as se, Plugin as de, merge as le } from "@univerjs/core";
|
|
5
|
+
import { SetSelectionsOperation as $, CopySheetCommand as me, DeleteRangeMoveLeftCommand as ue, DeleteRangeMoveUpCommand as fe, DeltaColumnWidthCommand as he, DeltaRowHeightCommand as ge, InsertSheetCommand as ve, InsertColAfterCommand as pe, InsertColBeforeCommand as Se, InsertRowAfterCommand as Ce, InsertRowBeforeCommand as _e, RemoveSheetCommand as ye, SetStyleCommand as Re, AddWorksheetMergeCommand as Ie, AddWorksheetMergeAllCommand as Oe, AddWorksheetMergeVerticalCommand as we, AddWorksheetMergeHorizontalCommand as xe, SetFrozenCommand as Me, CancelFrozenCommand as be, SetHorizontalTextAlignCommand as Ne, SetOverlineCommand as Ue, SetRangeValuesCommand as Ae, SetStrikeThroughCommand as $e, SetTextColorCommand as Pe, SetTextRotationCommand as Fe, SetTextWrapCommand as Te, SetVerticalTextAlignCommand as Ee, SetWorksheetActivateCommand as De, SetWorksheetActiveOperation as je } from "@univerjs/sheets";
|
|
6
6
|
import { SetSheetFilterRangeCommand as Le, SetSheetsFilterCriteriaCommand as ke, RemoveSheetFilterCommand as Be } from "@univerjs/sheets-filter";
|
|
7
7
|
import { SetRangeBoldCommand as Ve, SetRangeFontFamilyCommand as We, SetRangeFontSizeCommand as ze, SetRangeItalicCommand as He, SetRangeStrickThroughCommand as Je, SetRangeSubscriptCommand as Ge, SetRangeSuperscriptCommand as Ze, SetRangeTextColorCommand as Ke, SetRangeUnderlineCommand as Ye, SheetCopyCommand as qe, SheetCutCommand as Qe, SheetPasteBesidesBorderCommand as Xe, SheetPasteColWidthCommand as et, SheetPasteCommand as tt, SheetPasteFormatCommand as rt, SheetPasteShortKeyCommand as nt, SheetPasteValueCommand as ot, AutoFillCommand as it, RefillCommand as at } from "@univerjs/sheets-ui";
|
|
8
8
|
import { ILocalFileService as K, IMessageService as b, useDependency as P, useObservable as F, RibbonStartGroup as ct, MenuItemType as y, IUIPartsService as st, IMenuManagerService as dt, ComponentManager as lt, BuiltInUIPart as mt, connectInjector as ut } from "@univerjs/ui";
|
|
9
9
|
import { BehaviorSubject as R } from "rxjs";
|
|
10
10
|
import { MessageType as N, Button as U } from "@univerjs/design";
|
|
11
|
-
import { jsx as
|
|
11
|
+
import { jsx as g, jsxs as V } from "react/jsx-runtime";
|
|
12
12
|
import { forwardRef as Y, useRef as ft, createElement as q, useCallback as I } from "react";
|
|
13
13
|
var d = function() {
|
|
14
14
|
return d = Object.assign || function(e) {
|
|
@@ -18,7 +18,7 @@ var d = function() {
|
|
|
18
18
|
}
|
|
19
19
|
return e;
|
|
20
20
|
}, d.apply(this, arguments);
|
|
21
|
-
},
|
|
21
|
+
}, ht = function(e, t) {
|
|
22
22
|
var r = {};
|
|
23
23
|
for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
|
|
24
24
|
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -26,15 +26,15 @@ var d = function() {
|
|
|
26
26
|
t.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[o]) && (r[n[o]] = e[n[o]]);
|
|
27
27
|
return r;
|
|
28
28
|
}, Q = Y(function(e, t) {
|
|
29
|
-
var r = e.icon, n = e.id, o = e.className, i = e.extend, a =
|
|
29
|
+
var r = e.icon, n = e.id, o = e.className, i = e.extend, a = ht(e, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(n, " ").concat(o || "").trim(), f = ft("_".concat(pt()));
|
|
30
30
|
return X(r, "".concat(n), { defIds: r.defIds, idSuffix: f.current }, d({ ref: t, className: c }, a), i);
|
|
31
31
|
});
|
|
32
32
|
function X(e, t, r, n, o) {
|
|
33
|
-
return q(e.tag, d(d({ key: t },
|
|
33
|
+
return q(e.tag, d(d({ key: t }, gt(e, r, o)), n), (vt(e, r).children || []).map(function(i, a) {
|
|
34
34
|
return X(i, "".concat(t, "-").concat(e.tag, "-").concat(a), r, void 0, o);
|
|
35
35
|
}));
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function gt(e, t, r) {
|
|
38
38
|
var n = d({}, e.attrs);
|
|
39
39
|
r != null && r.colorChannel1 && n.fill === "colorChannel1" && (n.fill = r.colorChannel1), e.tag === "mask" && n.id && (n.id = n.id + t.idSuffix), Object.entries(n).forEach(function(i) {
|
|
40
40
|
var a = i[0], c = i[1];
|
|
@@ -49,21 +49,21 @@ function ht(e, t, r) {
|
|
|
49
49
|
function vt(e, t) {
|
|
50
50
|
var r, n = t.defIds;
|
|
51
51
|
return !n || n.length === 0 ? e : e.tag === "defs" && (!((r = e.children) === null || r === void 0) && r.length) ? d(d({}, e), { children: e.children.map(function(o) {
|
|
52
|
-
return typeof o.attrs.id == "string" && n && n.
|
|
52
|
+
return typeof o.attrs.id == "string" && n && n.includes(o.attrs.id) ? d(d({}, o), { attrs: d(d({}, o.attrs), { id: o.attrs.id + t.idSuffix }) }) : o;
|
|
53
53
|
}) }) : e;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function pt() {
|
|
56
56
|
return Math.random().toString(36).substring(2, 8);
|
|
57
57
|
}
|
|
58
58
|
Q.displayName = "UniverIcon";
|
|
59
|
-
var
|
|
59
|
+
var St = { tag: "svg", attrs: { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "g", attrs: { fill: "currentColor", clipPath: "url(#record-icon_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-icon_clip0_1559_19" }, children: [{ tag: "path", attrs: { fill: "white", d: "M0 0H16V16H0z", transform: "translate(.94)" } }] }] }], defIds: ["record-icon_clip0_1559_19"] }, E = Y(function(e, t) {
|
|
60
60
|
return q(Q, Object.assign({}, e, {
|
|
61
|
-
id: "record-
|
|
61
|
+
id: "record-icon",
|
|
62
62
|
ref: t,
|
|
63
|
-
icon:
|
|
63
|
+
icon: St
|
|
64
64
|
}));
|
|
65
65
|
});
|
|
66
|
-
E.displayName = "
|
|
66
|
+
E.displayName = "RecordIcon";
|
|
67
67
|
var Ct = Object.getOwnPropertyDescriptor, _t = (e, t, r, n) => {
|
|
68
68
|
for (var o = n > 1 ? void 0 : n ? Ct(t, r) : t, i = e.length - 1, a; i >= 0; i--)
|
|
69
69
|
(a = e[i]) && (o = a(o) || o);
|
|
@@ -105,14 +105,14 @@ let l = class extends T {
|
|
|
105
105
|
if (this._shouldRecordCommands.has(r.id)) {
|
|
106
106
|
const i = this._recorded, a = this._recordedCommands;
|
|
107
107
|
let c = { ...r };
|
|
108
|
-
const f = (n = this._instanceService.getFocusedUnit()) == null ? void 0 : n.getUnitId(), { unitId:
|
|
109
|
-
if (t &&
|
|
110
|
-
const
|
|
108
|
+
const f = (n = this._instanceService.getFocusedUnit()) == null ? void 0 : n.getUnitId(), { unitId: h = f, subUnitId: s } = c == null ? void 0 : c.params;
|
|
109
|
+
if (t && h && s) {
|
|
110
|
+
const S = (o = this._instanceService.getUnit(h).getSheetBySheetId(s)) == null ? void 0 : o.getName();
|
|
111
111
|
c = {
|
|
112
112
|
...c,
|
|
113
113
|
params: {
|
|
114
114
|
...c.params,
|
|
115
|
-
subUnitId:
|
|
115
|
+
subUnitId: S
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
118
|
}
|
|
@@ -184,7 +184,7 @@ let v = class extends T {
|
|
|
184
184
|
r || this._logService.error("[ReplayService]", "no focused unit to replay commands");
|
|
185
185
|
const { mode: n } = t || {};
|
|
186
186
|
for (const c of e) {
|
|
187
|
-
const { id: f, params:
|
|
187
|
+
const { id: f, params: h } = c, s = h;
|
|
188
188
|
if (s) {
|
|
189
189
|
if (typeof s.unitId < "u" && (s.unitId = r), n === "name" && s.subUnitId !== "undefined") {
|
|
190
190
|
const C = (i = this._instanceService.getFocusedUnit().getSheetBySheetName(s.subUnitId)) == null ? void 0 : i.getSheetId();
|
|
@@ -194,7 +194,7 @@ let v = class extends T {
|
|
|
194
194
|
const C = (a = this._instanceService.getFocusedUnit().getActiveSheet()) == null ? void 0 : a.getSheetId();
|
|
195
195
|
C ? s.subUnitId = C : this._logService.error("[ReplayService]", "failed to find active subunit");
|
|
196
196
|
}
|
|
197
|
-
if (!await this._commandService.executeCommand(f,
|
|
197
|
+
if (!await this._commandService.executeCommand(f, h)) return !1;
|
|
198
198
|
} else if (!await this._commandService.executeCommand(f)) return !1;
|
|
199
199
|
}
|
|
200
200
|
return !0;
|
|
@@ -272,28 +272,28 @@ const j = {
|
|
|
272
272
|
};
|
|
273
273
|
function Ot() {
|
|
274
274
|
const e = P(l);
|
|
275
|
-
return F(e.panelOpened$) ? /* @__PURE__ */
|
|
275
|
+
return F(e.panelOpened$) ? /* @__PURE__ */ g(wt, {}) : null;
|
|
276
276
|
}
|
|
277
|
-
function
|
|
277
|
+
function wt() {
|
|
278
278
|
var s;
|
|
279
279
|
const e = P(M), t = P(l), r = F(t.recording$), n = F(t.recordedCommands$), o = (s = n == null ? void 0 : n.length) != null ? s : 0, i = I(() => {
|
|
280
280
|
r || e.executeCommand(ne.id);
|
|
281
|
-
}, [e, r]), a = I((
|
|
282
|
-
r || e.executeCommand(ee.id, { replaceId:
|
|
281
|
+
}, [e, r]), a = I((S) => {
|
|
282
|
+
r || e.executeCommand(ee.id, { replaceId: S });
|
|
283
283
|
}, [e, r]), c = I(() => {
|
|
284
284
|
r && e.executeCommand(te.id);
|
|
285
285
|
}, [e, r]), f = I(() => {
|
|
286
286
|
r && e.executeCommand(re.id);
|
|
287
|
-
}, [e, r]),
|
|
287
|
+
}, [e, r]), h = r ? o === 0 ? "Recording..." : `${o}: ${n[o - 1].id}` : "Start Recording";
|
|
288
288
|
return /* @__PURE__ */ V(
|
|
289
289
|
"div",
|
|
290
290
|
{
|
|
291
291
|
className: "univer-fixed univer-bottom-20 univer-left-1/2 univer-z-[1000] univer-flex univer-h-16 univer-w-[512px] -univer-translate-x-1/2 univer-items-center univer-rounded-lg univer-bg-white univer-px-5 univer-shadow-lg",
|
|
292
292
|
children: [
|
|
293
|
-
/* @__PURE__ */
|
|
294
|
-
/* @__PURE__ */
|
|
293
|
+
/* @__PURE__ */ g("div", { className: "univer-mr-2 univer-size-5 univer-shrink-0 univer-grow-0 univer-text-xl", children: /* @__PURE__ */ g(E, {}) }),
|
|
294
|
+
/* @__PURE__ */ g("div", { className: "univer-flex-1 univer-text-sm", children: h }),
|
|
295
295
|
/* @__PURE__ */ V("div", { className: "univer-flex univer-w-64 univer-shrink-0 univer-grow-0 univer-justify-between", children: [
|
|
296
|
-
/* @__PURE__ */
|
|
296
|
+
/* @__PURE__ */ g(
|
|
297
297
|
U,
|
|
298
298
|
{
|
|
299
299
|
className: "univer-w-20",
|
|
@@ -301,7 +301,7 @@ function xt() {
|
|
|
301
301
|
children: r ? "Cancel" : "Close"
|
|
302
302
|
}
|
|
303
303
|
),
|
|
304
|
-
/* @__PURE__ */
|
|
304
|
+
/* @__PURE__ */ g(
|
|
305
305
|
U,
|
|
306
306
|
{
|
|
307
307
|
className: "univer-w-20",
|
|
@@ -310,18 +310,18 @@ function xt() {
|
|
|
310
310
|
children: r ? "Save" : "Start"
|
|
311
311
|
}
|
|
312
312
|
),
|
|
313
|
-
!r && /* @__PURE__ */
|
|
313
|
+
!r && /* @__PURE__ */ g(U, { variant: "primary", onClick: () => a(!0), children: "Start(N)" })
|
|
314
314
|
] })
|
|
315
315
|
]
|
|
316
316
|
}
|
|
317
317
|
);
|
|
318
318
|
}
|
|
319
319
|
const oe = "RECORD_MENU_ITEM";
|
|
320
|
-
function
|
|
320
|
+
function xt() {
|
|
321
321
|
return {
|
|
322
322
|
id: oe,
|
|
323
323
|
type: y.SUBITEMS,
|
|
324
|
-
icon: "
|
|
324
|
+
icon: "RecordIcon",
|
|
325
325
|
tooltip: "action-recorder.menu.title"
|
|
326
326
|
};
|
|
327
327
|
}
|
|
@@ -359,7 +359,7 @@ const At = {
|
|
|
359
359
|
[ct.OTHERS]: {
|
|
360
360
|
[oe]: {
|
|
361
361
|
order: 2,
|
|
362
|
-
menuItemFactory:
|
|
362
|
+
menuItemFactory: xt,
|
|
363
363
|
[B.id]: {
|
|
364
364
|
order: 1,
|
|
365
365
|
menuItemFactory: Mt
|
|
@@ -383,8 +383,8 @@ var $t = Object.getOwnPropertyDescriptor, Pt = (e, t, r, n) => {
|
|
|
383
383
|
for (var o = n > 1 ? void 0 : n ? $t(t, r) : t, i = e.length - 1, a; i >= 0; i--)
|
|
384
384
|
(a = e[i]) && (o = a(o) || o);
|
|
385
385
|
return o;
|
|
386
|
-
},
|
|
387
|
-
let
|
|
386
|
+
}, p = (e, t) => (r, n) => t(r, n, e);
|
|
387
|
+
let x = class extends T {
|
|
388
388
|
constructor(e, t, r, n, o, i) {
|
|
389
389
|
super(), this._commandSrv = e, this._uiPartsSrv = t, this._menuManagerService = r, this._componentManager = n, this._actionRecorderService = o, this._injector = i, this._initCommands(), this._initUI(), this._initSheetsCommands(), this._initDocsCommands();
|
|
390
390
|
}
|
|
@@ -402,7 +402,7 @@ let w = class extends T {
|
|
|
402
402
|
}
|
|
403
403
|
_initUI() {
|
|
404
404
|
this._uiPartsSrv.registerComponent(mt.GLOBAL, () => ut(Ot, this._injector)), this.disposeWithMe(
|
|
405
|
-
this._componentManager.register("
|
|
405
|
+
this._componentManager.register("RecordIcon", E)
|
|
406
406
|
), this._menuManagerService.mergeMenu(At);
|
|
407
407
|
}
|
|
408
408
|
_initSheetsCommands() {
|
|
@@ -413,19 +413,19 @@ let w = class extends T {
|
|
|
413
413
|
me,
|
|
414
414
|
ue,
|
|
415
415
|
fe,
|
|
416
|
-
ge,
|
|
417
416
|
he,
|
|
417
|
+
ge,
|
|
418
418
|
ve,
|
|
419
|
-
Se,
|
|
420
419
|
pe,
|
|
420
|
+
Se,
|
|
421
421
|
Ce,
|
|
422
422
|
_e,
|
|
423
423
|
ye,
|
|
424
424
|
Re,
|
|
425
425
|
Ie,
|
|
426
426
|
Oe,
|
|
427
|
-
xe,
|
|
428
427
|
we,
|
|
428
|
+
xe,
|
|
429
429
|
// ResetBackgroundColorCommand,
|
|
430
430
|
// ResetTextColorCommand,
|
|
431
431
|
// SetBackgroundColorCommand,
|
|
@@ -481,14 +481,14 @@ let w = class extends T {
|
|
|
481
481
|
_initDocsCommands() {
|
|
482
482
|
}
|
|
483
483
|
};
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
],
|
|
484
|
+
x = Pt([
|
|
485
|
+
p(0, M),
|
|
486
|
+
p(1, st),
|
|
487
|
+
p(2, dt),
|
|
488
|
+
p(3, w(lt)),
|
|
489
|
+
p(4, w(l)),
|
|
490
|
+
p(5, w(Z))
|
|
491
|
+
], x);
|
|
492
492
|
const Ft = "action-recorder.config", W = {};
|
|
493
493
|
var Tt = Object.getOwnPropertyDescriptor, Et = (e, t, r, n) => {
|
|
494
494
|
for (var o = n > 1 ? void 0 : n ? Tt(t, r) : t, i = e.length - 1, a; i >= 0; i--)
|
|
@@ -509,15 +509,15 @@ let H = (A = class extends de {
|
|
|
509
509
|
(this._config.replayOnly ? [[v]] : [
|
|
510
510
|
[l],
|
|
511
511
|
[v],
|
|
512
|
-
[
|
|
512
|
+
[x]
|
|
513
513
|
]).forEach((t) => this._injector.add(t));
|
|
514
514
|
}
|
|
515
515
|
onSteady() {
|
|
516
|
-
this._config.replayOnly || this._injector.get(
|
|
516
|
+
this._config.replayOnly || this._injector.get(x);
|
|
517
517
|
}
|
|
518
518
|
}, m(A, "pluginName", "UNIVER_ACTION_RECORDER_PLUGIN"), A);
|
|
519
519
|
H = Et([
|
|
520
|
-
z(1,
|
|
520
|
+
z(1, w(Z)),
|
|
521
521
|
z(2, se)
|
|
522
522
|
], H);
|
|
523
523
|
export {
|
package/lib/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
var ie = Object.defineProperty;
|
|
2
2
|
var ae = (e, t, r) => t in e ? ie(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
3
|
var m = (e, t, r) => ae(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import { Disposable as T, CommandType as u, ICommandService as M, ILogService as J, IUniverInstanceService as G, awaitTime as ce, Inject as
|
|
5
|
-
import { SetSelectionsOperation as $, CopySheetCommand as me, DeleteRangeMoveLeftCommand as ue, DeleteRangeMoveUpCommand as fe, DeltaColumnWidthCommand as
|
|
4
|
+
import { Disposable as T, CommandType as u, ICommandService as M, ILogService as J, IUniverInstanceService as G, awaitTime as ce, Inject as w, Injector as Z, IConfigService as se, Plugin as de, merge as le } from "@univerjs/core";
|
|
5
|
+
import { SetSelectionsOperation as $, CopySheetCommand as me, DeleteRangeMoveLeftCommand as ue, DeleteRangeMoveUpCommand as fe, DeltaColumnWidthCommand as he, DeltaRowHeightCommand as ge, InsertSheetCommand as ve, InsertColAfterCommand as pe, InsertColBeforeCommand as Se, InsertRowAfterCommand as Ce, InsertRowBeforeCommand as _e, RemoveSheetCommand as ye, SetStyleCommand as Re, AddWorksheetMergeCommand as Ie, AddWorksheetMergeAllCommand as Oe, AddWorksheetMergeVerticalCommand as we, AddWorksheetMergeHorizontalCommand as xe, SetFrozenCommand as Me, CancelFrozenCommand as be, SetHorizontalTextAlignCommand as Ne, SetOverlineCommand as Ue, SetRangeValuesCommand as Ae, SetStrikeThroughCommand as $e, SetTextColorCommand as Pe, SetTextRotationCommand as Fe, SetTextWrapCommand as Te, SetVerticalTextAlignCommand as Ee, SetWorksheetActivateCommand as De, SetWorksheetActiveOperation as je } from "@univerjs/sheets";
|
|
6
6
|
import { SetSheetFilterRangeCommand as Le, SetSheetsFilterCriteriaCommand as ke, RemoveSheetFilterCommand as Be } from "@univerjs/sheets-filter";
|
|
7
7
|
import { SetRangeBoldCommand as Ve, SetRangeFontFamilyCommand as We, SetRangeFontSizeCommand as ze, SetRangeItalicCommand as He, SetRangeStrickThroughCommand as Je, SetRangeSubscriptCommand as Ge, SetRangeSuperscriptCommand as Ze, SetRangeTextColorCommand as Ke, SetRangeUnderlineCommand as Ye, SheetCopyCommand as qe, SheetCutCommand as Qe, SheetPasteBesidesBorderCommand as Xe, SheetPasteColWidthCommand as et, SheetPasteCommand as tt, SheetPasteFormatCommand as rt, SheetPasteShortKeyCommand as nt, SheetPasteValueCommand as ot, AutoFillCommand as it, RefillCommand as at } from "@univerjs/sheets-ui";
|
|
8
8
|
import { ILocalFileService as K, IMessageService as b, useDependency as P, useObservable as F, RibbonStartGroup as ct, MenuItemType as y, IUIPartsService as st, IMenuManagerService as dt, ComponentManager as lt, BuiltInUIPart as mt, connectInjector as ut } from "@univerjs/ui";
|
|
9
9
|
import { BehaviorSubject as R } from "rxjs";
|
|
10
10
|
import { MessageType as N, Button as U } from "@univerjs/design";
|
|
11
|
-
import { jsx as
|
|
11
|
+
import { jsx as g, jsxs as V } from "react/jsx-runtime";
|
|
12
12
|
import { forwardRef as Y, useRef as ft, createElement as q, useCallback as I } from "react";
|
|
13
13
|
var d = function() {
|
|
14
14
|
return d = Object.assign || function(e) {
|
|
@@ -18,7 +18,7 @@ var d = function() {
|
|
|
18
18
|
}
|
|
19
19
|
return e;
|
|
20
20
|
}, d.apply(this, arguments);
|
|
21
|
-
},
|
|
21
|
+
}, ht = function(e, t) {
|
|
22
22
|
var r = {};
|
|
23
23
|
for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
|
|
24
24
|
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -26,15 +26,15 @@ var d = function() {
|
|
|
26
26
|
t.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[o]) && (r[n[o]] = e[n[o]]);
|
|
27
27
|
return r;
|
|
28
28
|
}, Q = Y(function(e, t) {
|
|
29
|
-
var r = e.icon, n = e.id, o = e.className, i = e.extend, a =
|
|
29
|
+
var r = e.icon, n = e.id, o = e.className, i = e.extend, a = ht(e, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(n, " ").concat(o || "").trim(), f = ft("_".concat(pt()));
|
|
30
30
|
return X(r, "".concat(n), { defIds: r.defIds, idSuffix: f.current }, d({ ref: t, className: c }, a), i);
|
|
31
31
|
});
|
|
32
32
|
function X(e, t, r, n, o) {
|
|
33
|
-
return q(e.tag, d(d({ key: t },
|
|
33
|
+
return q(e.tag, d(d({ key: t }, gt(e, r, o)), n), (vt(e, r).children || []).map(function(i, a) {
|
|
34
34
|
return X(i, "".concat(t, "-").concat(e.tag, "-").concat(a), r, void 0, o);
|
|
35
35
|
}));
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function gt(e, t, r) {
|
|
38
38
|
var n = d({}, e.attrs);
|
|
39
39
|
r != null && r.colorChannel1 && n.fill === "colorChannel1" && (n.fill = r.colorChannel1), e.tag === "mask" && n.id && (n.id = n.id + t.idSuffix), Object.entries(n).forEach(function(i) {
|
|
40
40
|
var a = i[0], c = i[1];
|
|
@@ -49,21 +49,21 @@ function ht(e, t, r) {
|
|
|
49
49
|
function vt(e, t) {
|
|
50
50
|
var r, n = t.defIds;
|
|
51
51
|
return !n || n.length === 0 ? e : e.tag === "defs" && (!((r = e.children) === null || r === void 0) && r.length) ? d(d({}, e), { children: e.children.map(function(o) {
|
|
52
|
-
return typeof o.attrs.id == "string" && n && n.
|
|
52
|
+
return typeof o.attrs.id == "string" && n && n.includes(o.attrs.id) ? d(d({}, o), { attrs: d(d({}, o.attrs), { id: o.attrs.id + t.idSuffix }) }) : o;
|
|
53
53
|
}) }) : e;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function pt() {
|
|
56
56
|
return Math.random().toString(36).substring(2, 8);
|
|
57
57
|
}
|
|
58
58
|
Q.displayName = "UniverIcon";
|
|
59
|
-
var
|
|
59
|
+
var St = { tag: "svg", attrs: { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "g", attrs: { fill: "currentColor", clipPath: "url(#record-icon_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-icon_clip0_1559_19" }, children: [{ tag: "path", attrs: { fill: "white", d: "M0 0H16V16H0z", transform: "translate(.94)" } }] }] }], defIds: ["record-icon_clip0_1559_19"] }, E = Y(function(e, t) {
|
|
60
60
|
return q(Q, Object.assign({}, e, {
|
|
61
|
-
id: "record-
|
|
61
|
+
id: "record-icon",
|
|
62
62
|
ref: t,
|
|
63
|
-
icon:
|
|
63
|
+
icon: St
|
|
64
64
|
}));
|
|
65
65
|
});
|
|
66
|
-
E.displayName = "
|
|
66
|
+
E.displayName = "RecordIcon";
|
|
67
67
|
var Ct = Object.getOwnPropertyDescriptor, _t = (e, t, r, n) => {
|
|
68
68
|
for (var o = n > 1 ? void 0 : n ? Ct(t, r) : t, i = e.length - 1, a; i >= 0; i--)
|
|
69
69
|
(a = e[i]) && (o = a(o) || o);
|
|
@@ -105,14 +105,14 @@ let l = class extends T {
|
|
|
105
105
|
if (this._shouldRecordCommands.has(r.id)) {
|
|
106
106
|
const i = this._recorded, a = this._recordedCommands;
|
|
107
107
|
let c = { ...r };
|
|
108
|
-
const f = (n = this._instanceService.getFocusedUnit()) == null ? void 0 : n.getUnitId(), { unitId:
|
|
109
|
-
if (t &&
|
|
110
|
-
const
|
|
108
|
+
const f = (n = this._instanceService.getFocusedUnit()) == null ? void 0 : n.getUnitId(), { unitId: h = f, subUnitId: s } = c == null ? void 0 : c.params;
|
|
109
|
+
if (t && h && s) {
|
|
110
|
+
const S = (o = this._instanceService.getUnit(h).getSheetBySheetId(s)) == null ? void 0 : o.getName();
|
|
111
111
|
c = {
|
|
112
112
|
...c,
|
|
113
113
|
params: {
|
|
114
114
|
...c.params,
|
|
115
|
-
subUnitId:
|
|
115
|
+
subUnitId: S
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
118
|
}
|
|
@@ -184,7 +184,7 @@ let v = class extends T {
|
|
|
184
184
|
r || this._logService.error("[ReplayService]", "no focused unit to replay commands");
|
|
185
185
|
const { mode: n } = t || {};
|
|
186
186
|
for (const c of e) {
|
|
187
|
-
const { id: f, params:
|
|
187
|
+
const { id: f, params: h } = c, s = h;
|
|
188
188
|
if (s) {
|
|
189
189
|
if (typeof s.unitId < "u" && (s.unitId = r), n === "name" && s.subUnitId !== "undefined") {
|
|
190
190
|
const C = (i = this._instanceService.getFocusedUnit().getSheetBySheetName(s.subUnitId)) == null ? void 0 : i.getSheetId();
|
|
@@ -194,7 +194,7 @@ let v = class extends T {
|
|
|
194
194
|
const C = (a = this._instanceService.getFocusedUnit().getActiveSheet()) == null ? void 0 : a.getSheetId();
|
|
195
195
|
C ? s.subUnitId = C : this._logService.error("[ReplayService]", "failed to find active subunit");
|
|
196
196
|
}
|
|
197
|
-
if (!await this._commandService.executeCommand(f,
|
|
197
|
+
if (!await this._commandService.executeCommand(f, h)) return !1;
|
|
198
198
|
} else if (!await this._commandService.executeCommand(f)) return !1;
|
|
199
199
|
}
|
|
200
200
|
return !0;
|
|
@@ -272,28 +272,28 @@ const j = {
|
|
|
272
272
|
};
|
|
273
273
|
function Ot() {
|
|
274
274
|
const e = P(l);
|
|
275
|
-
return F(e.panelOpened$) ? /* @__PURE__ */
|
|
275
|
+
return F(e.panelOpened$) ? /* @__PURE__ */ g(wt, {}) : null;
|
|
276
276
|
}
|
|
277
|
-
function
|
|
277
|
+
function wt() {
|
|
278
278
|
var s;
|
|
279
279
|
const e = P(M), t = P(l), r = F(t.recording$), n = F(t.recordedCommands$), o = (s = n == null ? void 0 : n.length) != null ? s : 0, i = I(() => {
|
|
280
280
|
r || e.executeCommand(ne.id);
|
|
281
|
-
}, [e, r]), a = I((
|
|
282
|
-
r || e.executeCommand(ee.id, { replaceId:
|
|
281
|
+
}, [e, r]), a = I((S) => {
|
|
282
|
+
r || e.executeCommand(ee.id, { replaceId: S });
|
|
283
283
|
}, [e, r]), c = I(() => {
|
|
284
284
|
r && e.executeCommand(te.id);
|
|
285
285
|
}, [e, r]), f = I(() => {
|
|
286
286
|
r && e.executeCommand(re.id);
|
|
287
|
-
}, [e, r]),
|
|
287
|
+
}, [e, r]), h = r ? o === 0 ? "Recording..." : `${o}: ${n[o - 1].id}` : "Start Recording";
|
|
288
288
|
return /* @__PURE__ */ V(
|
|
289
289
|
"div",
|
|
290
290
|
{
|
|
291
291
|
className: "univer-fixed univer-bottom-20 univer-left-1/2 univer-z-[1000] univer-flex univer-h-16 univer-w-[512px] -univer-translate-x-1/2 univer-items-center univer-rounded-lg univer-bg-white univer-px-5 univer-shadow-lg",
|
|
292
292
|
children: [
|
|
293
|
-
/* @__PURE__ */
|
|
294
|
-
/* @__PURE__ */
|
|
293
|
+
/* @__PURE__ */ g("div", { className: "univer-mr-2 univer-size-5 univer-shrink-0 univer-grow-0 univer-text-xl", children: /* @__PURE__ */ g(E, {}) }),
|
|
294
|
+
/* @__PURE__ */ g("div", { className: "univer-flex-1 univer-text-sm", children: h }),
|
|
295
295
|
/* @__PURE__ */ V("div", { className: "univer-flex univer-w-64 univer-shrink-0 univer-grow-0 univer-justify-between", children: [
|
|
296
|
-
/* @__PURE__ */
|
|
296
|
+
/* @__PURE__ */ g(
|
|
297
297
|
U,
|
|
298
298
|
{
|
|
299
299
|
className: "univer-w-20",
|
|
@@ -301,7 +301,7 @@ function xt() {
|
|
|
301
301
|
children: r ? "Cancel" : "Close"
|
|
302
302
|
}
|
|
303
303
|
),
|
|
304
|
-
/* @__PURE__ */
|
|
304
|
+
/* @__PURE__ */ g(
|
|
305
305
|
U,
|
|
306
306
|
{
|
|
307
307
|
className: "univer-w-20",
|
|
@@ -310,18 +310,18 @@ function xt() {
|
|
|
310
310
|
children: r ? "Save" : "Start"
|
|
311
311
|
}
|
|
312
312
|
),
|
|
313
|
-
!r && /* @__PURE__ */
|
|
313
|
+
!r && /* @__PURE__ */ g(U, { variant: "primary", onClick: () => a(!0), children: "Start(N)" })
|
|
314
314
|
] })
|
|
315
315
|
]
|
|
316
316
|
}
|
|
317
317
|
);
|
|
318
318
|
}
|
|
319
319
|
const oe = "RECORD_MENU_ITEM";
|
|
320
|
-
function
|
|
320
|
+
function xt() {
|
|
321
321
|
return {
|
|
322
322
|
id: oe,
|
|
323
323
|
type: y.SUBITEMS,
|
|
324
|
-
icon: "
|
|
324
|
+
icon: "RecordIcon",
|
|
325
325
|
tooltip: "action-recorder.menu.title"
|
|
326
326
|
};
|
|
327
327
|
}
|
|
@@ -359,7 +359,7 @@ const At = {
|
|
|
359
359
|
[ct.OTHERS]: {
|
|
360
360
|
[oe]: {
|
|
361
361
|
order: 2,
|
|
362
|
-
menuItemFactory:
|
|
362
|
+
menuItemFactory: xt,
|
|
363
363
|
[B.id]: {
|
|
364
364
|
order: 1,
|
|
365
365
|
menuItemFactory: Mt
|
|
@@ -383,8 +383,8 @@ var $t = Object.getOwnPropertyDescriptor, Pt = (e, t, r, n) => {
|
|
|
383
383
|
for (var o = n > 1 ? void 0 : n ? $t(t, r) : t, i = e.length - 1, a; i >= 0; i--)
|
|
384
384
|
(a = e[i]) && (o = a(o) || o);
|
|
385
385
|
return o;
|
|
386
|
-
},
|
|
387
|
-
let
|
|
386
|
+
}, p = (e, t) => (r, n) => t(r, n, e);
|
|
387
|
+
let x = class extends T {
|
|
388
388
|
constructor(e, t, r, n, o, i) {
|
|
389
389
|
super(), this._commandSrv = e, this._uiPartsSrv = t, this._menuManagerService = r, this._componentManager = n, this._actionRecorderService = o, this._injector = i, this._initCommands(), this._initUI(), this._initSheetsCommands(), this._initDocsCommands();
|
|
390
390
|
}
|
|
@@ -402,7 +402,7 @@ let w = class extends T {
|
|
|
402
402
|
}
|
|
403
403
|
_initUI() {
|
|
404
404
|
this._uiPartsSrv.registerComponent(mt.GLOBAL, () => ut(Ot, this._injector)), this.disposeWithMe(
|
|
405
|
-
this._componentManager.register("
|
|
405
|
+
this._componentManager.register("RecordIcon", E)
|
|
406
406
|
), this._menuManagerService.mergeMenu(At);
|
|
407
407
|
}
|
|
408
408
|
_initSheetsCommands() {
|
|
@@ -413,19 +413,19 @@ let w = class extends T {
|
|
|
413
413
|
me,
|
|
414
414
|
ue,
|
|
415
415
|
fe,
|
|
416
|
-
ge,
|
|
417
416
|
he,
|
|
417
|
+
ge,
|
|
418
418
|
ve,
|
|
419
|
-
Se,
|
|
420
419
|
pe,
|
|
420
|
+
Se,
|
|
421
421
|
Ce,
|
|
422
422
|
_e,
|
|
423
423
|
ye,
|
|
424
424
|
Re,
|
|
425
425
|
Ie,
|
|
426
426
|
Oe,
|
|
427
|
-
xe,
|
|
428
427
|
we,
|
|
428
|
+
xe,
|
|
429
429
|
// ResetBackgroundColorCommand,
|
|
430
430
|
// ResetTextColorCommand,
|
|
431
431
|
// SetBackgroundColorCommand,
|
|
@@ -481,14 +481,14 @@ let w = class extends T {
|
|
|
481
481
|
_initDocsCommands() {
|
|
482
482
|
}
|
|
483
483
|
};
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
],
|
|
484
|
+
x = Pt([
|
|
485
|
+
p(0, M),
|
|
486
|
+
p(1, st),
|
|
487
|
+
p(2, dt),
|
|
488
|
+
p(3, w(lt)),
|
|
489
|
+
p(4, w(l)),
|
|
490
|
+
p(5, w(Z))
|
|
491
|
+
], x);
|
|
492
492
|
const Ft = "action-recorder.config", W = {};
|
|
493
493
|
var Tt = Object.getOwnPropertyDescriptor, Et = (e, t, r, n) => {
|
|
494
494
|
for (var o = n > 1 ? void 0 : n ? Tt(t, r) : t, i = e.length - 1, a; i >= 0; i--)
|
|
@@ -509,15 +509,15 @@ let H = (A = class extends de {
|
|
|
509
509
|
(this._config.replayOnly ? [[v]] : [
|
|
510
510
|
[l],
|
|
511
511
|
[v],
|
|
512
|
-
[
|
|
512
|
+
[x]
|
|
513
513
|
]).forEach((t) => this._injector.add(t));
|
|
514
514
|
}
|
|
515
515
|
onSteady() {
|
|
516
|
-
this._config.replayOnly || this._injector.get(
|
|
516
|
+
this._config.replayOnly || this._injector.get(x);
|
|
517
517
|
}
|
|
518
518
|
}, m(A, "pluginName", "UNIVER_ACTION_RECORDER_PLUGIN"), A);
|
|
519
519
|
H = Et([
|
|
520
|
-
z(1,
|
|
520
|
+
z(1, w(Z)),
|
|
521
521
|
z(2, se)
|
|
522
522
|
], H);
|
|
523
523
|
export {
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(o,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-filter"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-filter","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/design","react/jsx-runtime","react"],a):(o=typeof globalThis<"u"?globalThis:o||self,a(o.UniverActionRecorder={},o.UniverCore,o.UniverSheets,o.UniverSheetsFilter,o.UniverSheetsUi,o.UniverUi,o.rxjs,o.UniverDesign,o.React,o.React))})(this,function(o,a,s,T,m,l,A,y,p,C){"use strict";var Se=Object.defineProperty;var ge=(o,a,s)=>a in o?Se(o,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[a]=s;var g=(o,a,s)=>ge(o,typeof a!="symbol"?a+"":a,s);var D;var S=function(){return S=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},S.apply(this,arguments)},H=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},x=C.forwardRef(function(e,t){var r=e.icon,n=e.id,i=e.className,c=e.extend,d=H(e,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),v=C.useRef("_".concat(Z()));return E(r,"".concat(n),{defIds:r.defIds,idSuffix:v.current},S({ref:t,className:u},d),c)});function E(e,t,r,n,i){return C.createElement(e.tag,S(S({key:t},J(e,r,i)),n),(G(e,r).children||[]).map(function(c,d){return E(c,"".concat(t,"-").concat(e.tag,"-").concat(d),r,void 0,i)}))}function J(e,t,r){var n=S({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(c){var d=c[0],u=c[1];d==="mask"&&typeof u=="string"&&(n[d]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(c){var d=c[0],u=c[1];typeof u=="string"&&(n[d]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function G(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?S(S({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?S(S({},i),{attrs:S(S({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function Z(){return Math.random().toString(36).substring(2,8)}x.displayName="UniverIcon";var K={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(e,t){return C.createElement(x,Object.assign({},e,{id:"record-single",ref:t,icon:K}))});w.displayName="RecordSingle";var Y=Object.getOwnPropertyDescriptor,Q=(e,t,r,n)=>{for(var i=n>1?void 0:n?Y(t,r):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(i=d(i)||i);return i},M=(e,t)=>(r,n)=>t(r,n,e);o.ActionRecorderService=class extends a.Disposable{constructor(r,n,i,c){super();g(this,"_shouldRecordCommands",new Set);g(this,"_panelOpened$",new A.BehaviorSubject(!1));g(this,"panelOpened$",this._panelOpened$.asObservable());g(this,"_recorder",null);g(this,"_recording$",new A.BehaviorSubject(!1));g(this,"recording$",this._recording$.asObservable());g(this,"_recorded$",new A.BehaviorSubject([]));g(this,"_recordedCommands$",new A.BehaviorSubject([]));g(this,"recordedCommands$",this._recordedCommands$.asObservable());this._commandSrv=r,this._logService=n,this._localFileService=i,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(n=>{var i,c;if(this._shouldRecordCommands.has(n.id)){const d=this._recorded,u=this._recordedCommands;let v={...n};const R=(i=this._instanceService.getFocusedUnit())==null?void 0:i.getUnitId(),{unitId:h=R,subUnitId:f}=v==null?void 0:v.params;if(r&&h&&f){const F=(c=this._instanceService.getUnit(h).getSheetBySheetId(f))==null?void 0:c.getName();v={...v,params:{...v.params,subUnitId:F}}}v.id===s.SetSelectionsOperation.id&&d.length>0&&d[d.length-1].id===s.SetSelectionsOperation.id?d[d.length-1]=v:(d.push(v),this._recorded$.next(d),v.type===a.CommandType.COMMAND&&(u.push(v),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()}},o.ActionRecorderService=Q([M(0,a.ICommandService),M(1,a.ILogService),M(2,l.ILocalFileService),M(3,a.IUniverInstanceService)],o.ActionRecorderService);const L={id:"action-recorder.command.start-recording",type:a.CommandType.COMMAND,handler:(e,t)=>(e.get(o.ActionRecorderService).startRecording(!!(t!=null&&t.replaceId)),!0)},B={id:"action-recorder.command.complete-recording",type:a.CommandType.COMMAND,handler:e=>(e.get(o.ActionRecorderService).completeRecording(),!0)},k={id:"action-recorder.command.stop-recording",type:a.CommandType.COMMAND,handler:e=>(e.get(o.ActionRecorderService).completeRecording(),!0)};var X=Object.getOwnPropertyDescriptor,ee=(e,t,r,n)=>{for(var i=n>1?void 0:n?X(t,r):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(i=d(i)||i);return i},I=(e,t)=>(r,n)=>t(r,n,e),j=(e=>(e.DEFAULT="default",e.NAME="name",e.ACTIVE="active",e))(j||{});o.ActionReplayService=class extends a.Disposable{constructor(t,r,n,i,c){super(),this._messageService=t,this._instanceService=r,this._localFileService=n,this._logService=i,this._commandService=c}async replayLocalJSON(t="default"){const r=await this._localFileService.openFile({multiple:!1,accept:".json"});if(r.length!==1)return!1;const n=r[0];try{return this.replayCommands(JSON.parse(await n.text()),{mode:t})}catch{return this._messageService.show({type:y.MessageType.Error,content:`Failed to replay commands from local file ${n.name}.`}),!1}}async replayCommands(t,r){var c,d,u;const n=(c=this._instanceService.getFocusedUnit())==null?void 0:c.getUnitId();n||this._logService.error("[ReplayService]","no focused unit to replay commands");const{mode:i}=r||{};for(const v of t){const{id:R,params:h}=v,f=h;if(f){if(typeof f.unitId<"u"&&(f.unitId=n),i==="name"&&f.subUnitId!=="undefined"){const O=(d=this._instanceService.getFocusedUnit().getSheetBySheetName(f.subUnitId))==null?void 0:d.getSheetId();O?f.subUnitId=O:this._logService.error("[ReplayService]",`failed to find subunit by subUnitName = ${f.subUnitId}`)}if(i==="active"&&f.subUnitId!=="undefined"){const O=(u=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:u.getSheetId();O?f.subUnitId=O:this._logService.error("[ReplayService]","failed to find active subunit")}if(!await this._commandService.executeCommand(R,h))return!1}else if(!await this._commandService.executeCommand(R))return!1}return!0}async replayCommandsWithDelay(t){var n;const r=(n=this._instanceService.getFocusedUnit())==null?void 0:n.getUnitId();r||this._logService.error("[ReplayService]","no focused unit to replay commands");for(const i of t){await a.awaitTime(re());const{id:c,params:d}=i;if(d){if(typeof d.unitId<"u"&&(d.unitId=r),!await this._commandService.executeCommand(c,d))return!1}else if(!await this._commandService.executeCommand(c))return!1}return!0}},o.ActionReplayService=ee([I(0,l.IMessageService),I(1,a.IUniverInstanceService),I(2,l.ILocalFileService),I(3,a.ILogService),I(4,a.ICommandService)],o.ActionReplayService);function re(){return Math.floor(Math.random()*800)+200}const N={id:"action-recorder.command.replay-local-records",type:a.CommandType.COMMAND,handler:async e=>{const r=await e.get(o.ActionReplayService).replayLocalJSON();return r&&e.get(l.IMessageService).show({type:y.MessageType.Success,content:"Successfully replayed local records"}),r}},P={id:"action-recorder.command.replay-local-records-name",type:a.CommandType.COMMAND,handler:async e=>{const r=await e.get(o.ActionReplayService).replayLocalJSON(j.NAME);return r&&e.get(l.IMessageService).show({type:y.MessageType.Success,content:"Successfully replayed local records"}),r}},U={id:"action-recorder.command.replay-local-records-active",type:a.CommandType.COMMAND,handler:async e=>{const r=await e.get(o.ActionReplayService).replayLocalJSON(j.ACTIVE);return r&&e.get(l.IMessageService).show({type:y.MessageType.Success,content:"Successfully replayed local records"}),r}},$={id:"action-recorder.operation.open-panel",type:a.CommandType.OPERATION,handler(e){return e.get(o.ActionRecorderService).togglePanel(!0),!0}},V={id:"action-recorder.operation.close-panel",type:a.CommandType.OPERATION,handler(e){return e.get(o.ActionRecorderService).togglePanel(!1),!0}};function ne(){const e=l.useDependency(o.ActionRecorderService);return l.useObservable(e.panelOpened$)?p.jsx(te,{}):null}function te(){var h;const e=l.useDependency(a.ICommandService),t=l.useDependency(o.ActionRecorderService),r=l.useObservable(t.recording$),n=l.useObservable(t.recordedCommands$),i=(h=n==null?void 0:n.length)!=null?h:0,c=C.useCallback(()=>{r||e.executeCommand(V.id)},[e,r]),d=C.useCallback(f=>{r||e.executeCommand(L.id,{replaceId:f})},[e,r]),u=C.useCallback(()=>{r&&e.executeCommand(B.id)},[e,r]),v=C.useCallback(()=>{r&&e.executeCommand(k.id)},[e,r]),R=r?i===0?"Recording...":`${i}: ${n[i-1].id}`:"Start Recording";return p.jsxs("div",{className:"univer-fixed univer-bottom-20 univer-left-1/2 univer-z-[1000] univer-flex univer-h-16 univer-w-[512px] -univer-translate-x-1/2 univer-items-center univer-rounded-lg univer-bg-white univer-px-5 univer-shadow-lg",children:[p.jsx("div",{className:"univer-mr-2 univer-size-5 univer-shrink-0 univer-grow-0 univer-text-xl",children:p.jsx(w,{})}),p.jsx("div",{className:"univer-flex-1 univer-text-sm",children:R}),p.jsxs("div",{className:"univer-flex univer-w-64 univer-shrink-0 univer-grow-0 univer-justify-between",children:[p.jsx(y.Button,{className:"univer-w-20",onClick:r?v:c,children:r?"Cancel":"Close"}),p.jsx(y.Button,{className:"univer-w-20",variant:"primary",onClick:r?u:()=>d(),children:r?"Save":"Start"}),!r&&p.jsx(y.Button,{variant:"primary",onClick:()=>d(!0),children:"Start(N)"})]})]})}const W="RECORD_MENU_ITEM";function ie(){return{id:W,type:l.MenuItemType.SUBITEMS,icon:"RecordSingle",tooltip:"action-recorder.menu.title"}}function oe(e){const t=e.get(o.ActionRecorderService);return{id:$.id,title:"action-recorder.menu.record",type:l.MenuItemType.BUTTON,disabled$:t.panelOpened$}}function ce(){return{id:N.id,title:"action-recorder.menu.replay-local",type:l.MenuItemType.BUTTON}}function ae(){return{id:P.id,title:"action-recorder.menu.replay-local-name",type:l.MenuItemType.BUTTON}}function de(){return{id:U.id,title:"action-recorder.menu.replay-local-active",type:l.MenuItemType.BUTTON}}const se={[l.RibbonStartGroup.OTHERS]:{[W]:{order:2,menuItemFactory:ie,[$.id]:{order:1,menuItemFactory:oe},[N.id]:{order:2,menuItemFactory:ce},[P.id]:{order:3,menuItemFactory:ae},[U.id]:{order:4,menuItemFactory:de}}}};var le=Object.getOwnPropertyDescriptor,me=(e,t,r,n)=>{for(var i=n>1?void 0:n?le(t,r):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(i=d(i)||i);return i},_=(e,t)=>(r,n)=>t(r,n,e);let b=class extends a.Disposable{constructor(e,t,r,n,i,c){super(),this._commandSrv=e,this._uiPartsSrv=t,this._menuManagerService=r,this._componentManager=n,this._actionRecorderService=i,this._injector=c,this._initCommands(),this._initUI(),this._initSheetsCommands(),this._initDocsCommands()}_initCommands(){[L,k,B,$,V,N,P,U].forEach(e=>this._commandSrv.registerCommand(e))}_initUI(){this._uiPartsSrv.registerComponent(l.BuiltInUIPart.GLOBAL,()=>l.connectInjector(ne,this._injector)),this.disposeWithMe(this._componentManager.register("RecordSingle",w)),this._menuManagerService.mergeMenu(se)}_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,T.SetSheetFilterRangeCommand,T.SetSheetsFilterCriteriaCommand,T.RemoveSheetFilterCommand].forEach(e=>this._actionRecorderService.registerRecordedCommand(e))}_initDocsCommands(){}};b=me([_(0,a.ICommandService),_(1,l.IUIPartsService),_(2,l.IMenuManagerService),_(3,a.Inject(l.ComponentManager)),_(4,a.Inject(o.ActionRecorderService)),_(5,a.Inject(a.Injector))],b);const ue="action-recorder.config",q={};var ve=Object.getOwnPropertyDescriptor,fe=(e,t,r,n)=>{for(var i=n>1?void 0:n?ve(t,r):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(i=d(i)||i);return i},z=(e,t)=>(r,n)=>t(r,n,e);o.UniverActionRecorderPlugin=(D=class extends a.Plugin{constructor(t=q,r,n){super(),this._config=t,this._injector=r,this._configService=n;const{menu:i,...c}=a.merge({},q,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ue,c)}onStarting(){(this._config.replayOnly?[[o.ActionReplayService]]:[[o.ActionRecorderService],[o.ActionReplayService],[b]]).forEach(r=>this._injector.add(r))}onSteady(){this._config.replayOnly||this._injector.get(b)}},g(D,"pluginName","UNIVER_ACTION_RECORDER_PLUGIN"),D),o.UniverActionRecorderPlugin=fe([z(1,a.Inject(a.Injector)),z(2,a.IConfigService)],o.UniverActionRecorderPlugin),Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(o,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-filter"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-filter","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/design","react/jsx-runtime","react"],a):(o=typeof globalThis<"u"?globalThis:o||self,a(o.UniverActionRecorder={},o.UniverCore,o.UniverSheets,o.UniverSheetsFilter,o.UniverSheetsUi,o.UniverUi,o.rxjs,o.UniverDesign,o.React,o.React))})(this,function(o,a,s,b,m,l,A,y,p,C){"use strict";var Se=Object.defineProperty;var ge=(o,a,s)=>a in o?Se(o,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[a]=s;var g=(o,a,s)=>ge(o,typeof a!="symbol"?a+"":a,s);var D;var S=function(){return S=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},S.apply(this,arguments)},H=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},x=C.forwardRef(function(e,t){var r=e.icon,n=e.id,i=e.className,c=e.extend,d=H(e,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),v=C.useRef("_".concat(Z()));return E(r,"".concat(n),{defIds:r.defIds,idSuffix:v.current},S({ref:t,className:u},d),c)});function E(e,t,r,n,i){return C.createElement(e.tag,S(S({key:t},J(e,r,i)),n),(G(e,r).children||[]).map(function(c,d){return E(c,"".concat(t,"-").concat(e.tag,"-").concat(d),r,void 0,i)}))}function J(e,t,r){var n=S({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(c){var d=c[0],u=c[1];d==="mask"&&typeof u=="string"&&(n[d]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(c){var d=c[0],u=c[1];typeof u=="string"&&(n[d]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function G(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?S(S({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.includes(i.attrs.id)?S(S({},i),{attrs:S(S({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function Z(){return Math.random().toString(36).substring(2,8)}x.displayName="UniverIcon";var K={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"g",attrs:{fill:"currentColor",clipPath:"url(#record-icon_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-icon_clip0_1559_19"},children:[{tag:"path",attrs:{fill:"white",d:"M0 0H16V16H0z",transform:"translate(.94)"}}]}]}],defIds:["record-icon_clip0_1559_19"]},T=C.forwardRef(function(e,t){return C.createElement(x,Object.assign({},e,{id:"record-icon",ref:t,icon:K}))});T.displayName="RecordIcon";var Y=Object.getOwnPropertyDescriptor,Q=(e,t,r,n)=>{for(var i=n>1?void 0:n?Y(t,r):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(i=d(i)||i);return i},M=(e,t)=>(r,n)=>t(r,n,e);o.ActionRecorderService=class extends a.Disposable{constructor(r,n,i,c){super();g(this,"_shouldRecordCommands",new Set);g(this,"_panelOpened$",new A.BehaviorSubject(!1));g(this,"panelOpened$",this._panelOpened$.asObservable());g(this,"_recorder",null);g(this,"_recording$",new A.BehaviorSubject(!1));g(this,"recording$",this._recording$.asObservable());g(this,"_recorded$",new A.BehaviorSubject([]));g(this,"_recordedCommands$",new A.BehaviorSubject([]));g(this,"recordedCommands$",this._recordedCommands$.asObservable());this._commandSrv=r,this._logService=n,this._localFileService=i,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(n=>{var i,c;if(this._shouldRecordCommands.has(n.id)){const d=this._recorded,u=this._recordedCommands;let v={...n};const R=(i=this._instanceService.getFocusedUnit())==null?void 0:i.getUnitId(),{unitId:h=R,subUnitId:f}=v==null?void 0:v.params;if(r&&h&&f){const F=(c=this._instanceService.getUnit(h).getSheetBySheetId(f))==null?void 0:c.getName();v={...v,params:{...v.params,subUnitId:F}}}v.id===s.SetSelectionsOperation.id&&d.length>0&&d[d.length-1].id===s.SetSelectionsOperation.id?d[d.length-1]=v:(d.push(v),this._recorded$.next(d),v.type===a.CommandType.COMMAND&&(u.push(v),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()}},o.ActionRecorderService=Q([M(0,a.ICommandService),M(1,a.ILogService),M(2,l.ILocalFileService),M(3,a.IUniverInstanceService)],o.ActionRecorderService);const L={id:"action-recorder.command.start-recording",type:a.CommandType.COMMAND,handler:(e,t)=>(e.get(o.ActionRecorderService).startRecording(!!(t!=null&&t.replaceId)),!0)},B={id:"action-recorder.command.complete-recording",type:a.CommandType.COMMAND,handler:e=>(e.get(o.ActionRecorderService).completeRecording(),!0)},k={id:"action-recorder.command.stop-recording",type:a.CommandType.COMMAND,handler:e=>(e.get(o.ActionRecorderService).completeRecording(),!0)};var X=Object.getOwnPropertyDescriptor,ee=(e,t,r,n)=>{for(var i=n>1?void 0:n?X(t,r):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(i=d(i)||i);return i},I=(e,t)=>(r,n)=>t(r,n,e),j=(e=>(e.DEFAULT="default",e.NAME="name",e.ACTIVE="active",e))(j||{});o.ActionReplayService=class extends a.Disposable{constructor(t,r,n,i,c){super(),this._messageService=t,this._instanceService=r,this._localFileService=n,this._logService=i,this._commandService=c}async replayLocalJSON(t="default"){const r=await this._localFileService.openFile({multiple:!1,accept:".json"});if(r.length!==1)return!1;const n=r[0];try{return this.replayCommands(JSON.parse(await n.text()),{mode:t})}catch{return this._messageService.show({type:y.MessageType.Error,content:`Failed to replay commands from local file ${n.name}.`}),!1}}async replayCommands(t,r){var c,d,u;const n=(c=this._instanceService.getFocusedUnit())==null?void 0:c.getUnitId();n||this._logService.error("[ReplayService]","no focused unit to replay commands");const{mode:i}=r||{};for(const v of t){const{id:R,params:h}=v,f=h;if(f){if(typeof f.unitId<"u"&&(f.unitId=n),i==="name"&&f.subUnitId!=="undefined"){const O=(d=this._instanceService.getFocusedUnit().getSheetBySheetName(f.subUnitId))==null?void 0:d.getSheetId();O?f.subUnitId=O:this._logService.error("[ReplayService]",`failed to find subunit by subUnitName = ${f.subUnitId}`)}if(i==="active"&&f.subUnitId!=="undefined"){const O=(u=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:u.getSheetId();O?f.subUnitId=O:this._logService.error("[ReplayService]","failed to find active subunit")}if(!await this._commandService.executeCommand(R,h))return!1}else if(!await this._commandService.executeCommand(R))return!1}return!0}async replayCommandsWithDelay(t){var n;const r=(n=this._instanceService.getFocusedUnit())==null?void 0:n.getUnitId();r||this._logService.error("[ReplayService]","no focused unit to replay commands");for(const i of t){await a.awaitTime(re());const{id:c,params:d}=i;if(d){if(typeof d.unitId<"u"&&(d.unitId=r),!await this._commandService.executeCommand(c,d))return!1}else if(!await this._commandService.executeCommand(c))return!1}return!0}},o.ActionReplayService=ee([I(0,l.IMessageService),I(1,a.IUniverInstanceService),I(2,l.ILocalFileService),I(3,a.ILogService),I(4,a.ICommandService)],o.ActionReplayService);function re(){return Math.floor(Math.random()*800)+200}const N={id:"action-recorder.command.replay-local-records",type:a.CommandType.COMMAND,handler:async e=>{const r=await e.get(o.ActionReplayService).replayLocalJSON();return r&&e.get(l.IMessageService).show({type:y.MessageType.Success,content:"Successfully replayed local records"}),r}},P={id:"action-recorder.command.replay-local-records-name",type:a.CommandType.COMMAND,handler:async e=>{const r=await e.get(o.ActionReplayService).replayLocalJSON(j.NAME);return r&&e.get(l.IMessageService).show({type:y.MessageType.Success,content:"Successfully replayed local records"}),r}},U={id:"action-recorder.command.replay-local-records-active",type:a.CommandType.COMMAND,handler:async e=>{const r=await e.get(o.ActionReplayService).replayLocalJSON(j.ACTIVE);return r&&e.get(l.IMessageService).show({type:y.MessageType.Success,content:"Successfully replayed local records"}),r}},$={id:"action-recorder.operation.open-panel",type:a.CommandType.OPERATION,handler(e){return e.get(o.ActionRecorderService).togglePanel(!0),!0}},V={id:"action-recorder.operation.close-panel",type:a.CommandType.OPERATION,handler(e){return e.get(o.ActionRecorderService).togglePanel(!1),!0}};function ne(){const e=l.useDependency(o.ActionRecorderService);return l.useObservable(e.panelOpened$)?p.jsx(te,{}):null}function te(){var h;const e=l.useDependency(a.ICommandService),t=l.useDependency(o.ActionRecorderService),r=l.useObservable(t.recording$),n=l.useObservable(t.recordedCommands$),i=(h=n==null?void 0:n.length)!=null?h:0,c=C.useCallback(()=>{r||e.executeCommand(V.id)},[e,r]),d=C.useCallback(f=>{r||e.executeCommand(L.id,{replaceId:f})},[e,r]),u=C.useCallback(()=>{r&&e.executeCommand(B.id)},[e,r]),v=C.useCallback(()=>{r&&e.executeCommand(k.id)},[e,r]),R=r?i===0?"Recording...":`${i}: ${n[i-1].id}`:"Start Recording";return p.jsxs("div",{className:"univer-fixed univer-bottom-20 univer-left-1/2 univer-z-[1000] univer-flex univer-h-16 univer-w-[512px] -univer-translate-x-1/2 univer-items-center univer-rounded-lg univer-bg-white univer-px-5 univer-shadow-lg",children:[p.jsx("div",{className:"univer-mr-2 univer-size-5 univer-shrink-0 univer-grow-0 univer-text-xl",children:p.jsx(T,{})}),p.jsx("div",{className:"univer-flex-1 univer-text-sm",children:R}),p.jsxs("div",{className:"univer-flex univer-w-64 univer-shrink-0 univer-grow-0 univer-justify-between",children:[p.jsx(y.Button,{className:"univer-w-20",onClick:r?v:c,children:r?"Cancel":"Close"}),p.jsx(y.Button,{className:"univer-w-20",variant:"primary",onClick:r?u:()=>d(),children:r?"Save":"Start"}),!r&&p.jsx(y.Button,{variant:"primary",onClick:()=>d(!0),children:"Start(N)"})]})]})}const W="RECORD_MENU_ITEM";function ie(){return{id:W,type:l.MenuItemType.SUBITEMS,icon:"RecordIcon",tooltip:"action-recorder.menu.title"}}function oe(e){const t=e.get(o.ActionRecorderService);return{id:$.id,title:"action-recorder.menu.record",type:l.MenuItemType.BUTTON,disabled$:t.panelOpened$}}function ce(){return{id:N.id,title:"action-recorder.menu.replay-local",type:l.MenuItemType.BUTTON}}function ae(){return{id:P.id,title:"action-recorder.menu.replay-local-name",type:l.MenuItemType.BUTTON}}function de(){return{id:U.id,title:"action-recorder.menu.replay-local-active",type:l.MenuItemType.BUTTON}}const se={[l.RibbonStartGroup.OTHERS]:{[W]:{order:2,menuItemFactory:ie,[$.id]:{order:1,menuItemFactory:oe},[N.id]:{order:2,menuItemFactory:ce},[P.id]:{order:3,menuItemFactory:ae},[U.id]:{order:4,menuItemFactory:de}}}};var le=Object.getOwnPropertyDescriptor,me=(e,t,r,n)=>{for(var i=n>1?void 0:n?le(t,r):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(i=d(i)||i);return i},_=(e,t)=>(r,n)=>t(r,n,e);let w=class extends a.Disposable{constructor(e,t,r,n,i,c){super(),this._commandSrv=e,this._uiPartsSrv=t,this._menuManagerService=r,this._componentManager=n,this._actionRecorderService=i,this._injector=c,this._initCommands(),this._initUI(),this._initSheetsCommands(),this._initDocsCommands()}_initCommands(){[L,k,B,$,V,N,P,U].forEach(e=>this._commandSrv.registerCommand(e))}_initUI(){this._uiPartsSrv.registerComponent(l.BuiltInUIPart.GLOBAL,()=>l.connectInjector(ne,this._injector)),this.disposeWithMe(this._componentManager.register("RecordIcon",T)),this._menuManagerService.mergeMenu(se)}_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,b.SetSheetFilterRangeCommand,b.SetSheetsFilterCriteriaCommand,b.RemoveSheetFilterCommand].forEach(e=>this._actionRecorderService.registerRecordedCommand(e))}_initDocsCommands(){}};w=me([_(0,a.ICommandService),_(1,l.IUIPartsService),_(2,l.IMenuManagerService),_(3,a.Inject(l.ComponentManager)),_(4,a.Inject(o.ActionRecorderService)),_(5,a.Inject(a.Injector))],w);const ue="action-recorder.config",q={};var ve=Object.getOwnPropertyDescriptor,fe=(e,t,r,n)=>{for(var i=n>1?void 0:n?ve(t,r):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(i=d(i)||i);return i},z=(e,t)=>(r,n)=>t(r,n,e);o.UniverActionRecorderPlugin=(D=class extends a.Plugin{constructor(t=q,r,n){super(),this._config=t,this._injector=r,this._configService=n;const{menu:i,...c}=a.merge({},q,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ue,c)}onStarting(){(this._config.replayOnly?[[o.ActionReplayService]]:[[o.ActionRecorderService],[o.ActionReplayService],[w]]).forEach(r=>this._injector.add(r))}onSteady(){this._config.replayOnly||this._injector.get(w)}},g(D,"pluginName","UNIVER_ACTION_RECORDER_PLUGIN"),D),o.UniverActionRecorderPlugin=fe([z(1,a.Inject(a.Injector)),z(2,a.IConfigService)],o.UniverActionRecorderPlugin),Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/action-recorder",
|
|
3
|
-
"version": "0.8.0-beta.
|
|
3
|
+
"version": "0.8.0-beta.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -52,13 +52,13 @@
|
|
|
52
52
|
"rxjs": ">=7.0.0"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@univerjs/icons": "^0.
|
|
56
|
-
"@univerjs/
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/
|
|
59
|
-
"@univerjs/sheets-
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/
|
|
55
|
+
"@univerjs/icons": "^0.4.4",
|
|
56
|
+
"@univerjs/design": "0.8.0-beta.1",
|
|
57
|
+
"@univerjs/sheets": "0.8.0-beta.1",
|
|
58
|
+
"@univerjs/core": "0.8.0-beta.1",
|
|
59
|
+
"@univerjs/sheets-ui": "0.8.0-beta.1",
|
|
60
|
+
"@univerjs/ui": "0.8.0-beta.1",
|
|
61
|
+
"@univerjs/sheets-filter": "0.8.0-beta.1"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"react": "18.3.1",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"typescript": "^5.8.3",
|
|
68
68
|
"vite": "^6.3.5",
|
|
69
69
|
"vitest": "^3.1.4",
|
|
70
|
-
"@univerjs-infra/shared": "0.8.0-beta.
|
|
70
|
+
"@univerjs-infra/shared": "0.8.0-beta.1"
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|
|
73
73
|
"test": "vitest run",
|