index.js 3.3 KB

1
  1. "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),v=require("@univerjs/drawing"),w="sheets-drawing.config",h={};var f=(e=>(e.Position="0",e.Both="1",e.None="2",e))(f||{});class E extends v.UnitDrawingService{}const _=a.createIdentifier("sheets-drawing.sheet-drawing.service");var N=(e=>(e[e.INSERT=0]="INSERT",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE",e[e.ARRANGE=3]="ARRANGE",e[e.GROUP=4]="GROUP",e[e.UNGROUP=5]="UNGROUP",e))(N||{});const P={id:"sheet.mutation.set-drawing-apply",type:a.CommandType.MUTATION,handler:(e,i)=>{const r=e.get(v.IDrawingManagerService),t=e.get(_),{op:n,unitId:s,subUnitId:o,type:l,objects:c}=i;switch(r.applyJson1(s,o,n),t.applyJson1(s,o,n),l){case 0:r.addNotification(c),t.addNotification(c);break;case 1:r.removeNotification(c),t.removeNotification(c);break;case 2:r.updateNotification(c),t.updateNotification(c);break;case 3:r.orderNotification(c),t.orderNotification(c);break;case 4:r.groupUpdateNotification(c);break;case 5:r.ungroupUpdateNotification(c);break}return!0}};var I=Object.defineProperty,m=Object.getOwnPropertyDescriptor,p=(e,i,r,t)=>{for(var n=t>1?void 0:t?m(i,r):i,s=e.length-1,o;s>=0;s--)(o=e[s])&&(n=(t?o(i,r,n):o(n))||n);return t&&n&&I(i,r,n),n},g=(e,i)=>(r,t)=>i(r,t,e);const S="SHEET_DRAWING_PLUGIN";let u=class extends a.Disposable{constructor(e,i,r,t){super(),this._commandService=e,this._sheetDrawingService=i,this._drawingManagerService=r,this._resourceManagerService=t,this._initSnapshot(),this.disposeWithMe(this._commandService.registerCommand(P))}_initSnapshot(){const e=(r,t)=>{const n=t||this._sheetDrawingService.getDrawingDataForUnit(r);return n?JSON.stringify(n):""},i=r=>{if(!r)return{};try{return JSON.parse(r)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:S,businesses:[a.UniverInstanceType.UNIVER_SHEET],toJson:(r,t)=>e(r,t),parseJson:r=>i(r),onUnLoad:r=>{this._sheetDrawingService.removeDrawingDataForUnit(r),this._drawingManagerService.removeDrawingDataForUnit(r)},onLoad:(r,t)=>{this._sheetDrawingService.registerDrawingData(r,t),this._drawingManagerService.registerDrawingData(r,t)}}))}};u=p([g(0,a.ICommandService),g(1,_),g(2,v.IDrawingManagerService),g(3,a.IResourceManagerService)],u);var D=Object.defineProperty,O=Object.getOwnPropertyDescriptor,R=(e,i,r)=>i in e?D(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r,b=(e,i,r,t)=>{for(var n=t>1?void 0:t?O(i,r):i,s=e.length-1,o;s>=0;s--)(o=e[s])&&(n=(t?o(i,r,n):o(n))||n);return t&&n&&D(i,r,n),n},d=(e,i)=>(r,t)=>i(r,t,e),U=(e,i,r)=>R(e,typeof i!="symbol"?i+"":i,r);exports.UniverSheetsDrawingPlugin=class extends a.Plugin{constructor(i=h,r,t){super(),this._config=i,this._injector=r,this._configService=t;const{...n}=a.merge({},h,this._config);this._configService.setConfig(w,n)}onStarting(){[[u],[_,{useClass:E}]].forEach(i=>this._injector.add(i)),this._injector.get(u)}};U(exports.UniverSheetsDrawingPlugin,"pluginName",S);U(exports.UniverSheetsDrawingPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsDrawingPlugin=b([a.DependentOn(v.UniverDrawingPlugin),d(1,a.Inject(a.Injector)),d(2,a.IConfigService)],exports.UniverSheetsDrawingPlugin);exports.DrawingApplyType=N;exports.ISheetDrawingService=_;exports.SHEET_DRAWING_PLUGIN=S;exports.SetDrawingApplyMutation=P;exports.SheetDrawingAnchorType=f;