@univerjs/sheets-drawing 0.16.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),U=require("@univerjs/drawing"),l=require("@univerjs/sheets");var b=(e=>(e.Position="0",e.Both="1",e.None="2",e))(b||{});class R extends U.UnitDrawingService{}const D=s.createIdentifier("sheets-drawing.sheet-drawing.service");var h=(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))(h||{});const g={id:"sheet.mutation.set-drawing-apply",type:s.CommandType.MUTATION,handler:(e,i)=>{const t=e.get(U.IDrawingManagerService),r=e.get(D),{op:n,unitId:a,subUnitId:c,type:d,objects:o}=i;switch(t.applyJson1(a,c,n),r.applyJson1(a,c,n),d){case 0:t.addNotification(o),r.addNotification(o);break;case 1:t.removeNotification(o),r.removeNotification(o);break;case 2:t.updateNotification(o),r.updateNotification(o);break;case 3:t.orderNotification(o),r.orderNotification(o);break;case 4:t.groupUpdateNotification(o);break;case 5:t.ungroupUpdateNotification(o);break}return!0}};var P=Object.getOwnPropertyDescriptor,C=(e,i,t,r)=>{for(var n=r>1?void 0:r?P(i,t):i,a=e.length-1,c;a>=0;a--)(c=e[a])&&(n=c(n)||n);return n},u=(e,i)=>(t,r)=>i(t,r,e);const E="SHEET_DRAWING_PLUGIN";let p=class extends s.Disposable{constructor(e,i,t,r,n,a){super(),this._sheetInterceptorService=e,this._univerInstanceService=i,this._commandService=t,this._sheetDrawingService=r,this._drawingManagerService=n,this._resourceManagerService=a,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(g))}_initSnapshot(){const e=(t,r)=>{const n=r||this._sheetDrawingService.getDrawingDataForUnit(t);return n?JSON.stringify(n):""},i=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:E,businesses:[s.UniverInstanceType.UNIVER_SHEET],toJson:(t,r)=>e(t,r),parseJson:t=>i(t),onUnLoad:t=>{this._sheetDrawingService.removeDrawingDataForUnit(t),this._drawingManagerService.removeDrawingDataForUnit(t)},onLoad:(t,r)=>{this._sheetDrawingService.registerDrawingData(t,r),this._drawingManagerService.registerDrawingData(t,r)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var i;if(e.id===l.RemoveSheetCommand.id){const t=e.params,r=t.unitId||this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),n=t.subUnitId||((i=this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:i.getSheetId());if(!r||!n)return{redos:[],undos:[]};const a=this._sheetDrawingService.getDrawingData(r,n),c=Object.values(a).filter(_=>_.drawingType!==s.DrawingTypeEnum.DRAWING_CHART);if(c.length===0)return{redos:[],undos:[]};const d=this._sheetDrawingService.getBatchRemoveOp(c),{unitId:o,subUnitId:v,undo:S,redo:f,objects:I}=d;return{redos:[{id:g.id,params:{op:f,unitId:o,subUnitId:v,objects:I,type:h.REMOVE}}],undos:[{id:g.id,params:{op:S,unitId:o,subUnitId:v,objects:I,type:h.INSERT}}]}}else if(e.id===l.CopySheetCommand.id){const t=e.params,{unitId:r,subUnitId:n,targetSubUnitId:a}=t;if(!r||!n||!a)return{redos:[],undos:[]};const c=this._sheetDrawingService.getDrawingData(r,n),d=Object.values(c).filter(w=>w.drawingType!==s.DrawingTypeEnum.DRAWING_CHART).map(w=>({...w,subUnitId:a,drawingId:s.generateRandomId(6)}));if(d.length===0)return{redos:[],undos:[]};const o=this._sheetDrawingService.getBatchAddOp(d),{unitId:v,subUnitId:S,undo:f,redo:I,objects:_}=o;return{redos:[{id:g.id,params:{op:I,unitId:v,subUnitId:S,objects:_,type:h.INSERT}}],undos:[{id:g.id,params:{op:f,unitId:v,subUnitId:S,objects:_,type:h.REMOVE}}]}}return{redos:[],undos:[]}}}))}};p=C([u(0,s.Inject(l.SheetInterceptorService)),u(1,s.Inject(s.IUniverInstanceService)),u(2,s.ICommandService),u(3,D),u(4,U.IDrawingManagerService),u(5,s.IResourceManagerService)],p);const M="sheets-drawing.config",N={};var j=Object.defineProperty,T=Object.getOwnPropertyDescriptor,G=(e,i,t)=>i in e?j(e,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[i]=t,H=(e,i,t,r)=>{for(var n=r>1?void 0:r?T(i,t):i,a=e.length-1,c;a>=0;a--)(c=e[a])&&(n=c(n)||n);return n},m=(e,i)=>(t,r)=>i(t,r,e),O=(e,i,t)=>G(e,typeof i!="symbol"?i+"":i,t);exports.UniverSheetsDrawingPlugin=class extends s.Plugin{constructor(i=N,t,r){super(),this._config=i,this._injector=t,this._configService=r;const{...n}=s.merge({},N,this._config);this._configService.setConfig(M,n)}onStarting(){[[p],[D,{useClass:R}]].forEach(i=>this._injector.add(i)),this._injector.get(p)}};O(exports.UniverSheetsDrawingPlugin,"pluginName",E);O(exports.UniverSheetsDrawingPlugin,"type",s.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsDrawingPlugin=H([s.DependentOn(U.UniverDrawingPlugin),m(1,s.Inject(s.Injector)),m(2,s.IConfigService)],exports.UniverSheetsDrawingPlugin);exports.DrawingApplyType=h;exports.ISheetDrawingService=D;exports.SHEET_DRAWING_PLUGIN=E;exports.SetDrawingApplyMutation=g;exports.SheetDrawingAnchorType=b;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),U=require("@univerjs/drawing"),m=require("@univerjs/sheets");var O=(e=>(e.Position="0",e.Both="1",e.None="2",e))(O||{});class R extends U.UnitDrawingService{}const w=s.createIdentifier("sheets-drawing.sheet-drawing.service");var h=(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))(h||{});const g={id:"sheet.mutation.set-drawing-apply",type:s.CommandType.MUTATION,handler:(e,r)=>{const t=e.get(U.IDrawingManagerService),n=e.get(w),{op:i,unitId:a,subUnitId:c,type:d,objects:o}=r;switch(t.applyJson1(a,c,i),n.applyJson1(a,c,i),d){case 0:t.addNotification(o),n.addNotification(o);break;case 1:t.removeNotification(o),n.removeNotification(o);break;case 2:t.updateNotification(o),n.updateNotification(o);break;case 3:t.orderNotification(o),n.orderNotification(o);break;case 4:t.groupUpdateNotification(o);break;case 5:t.ungroupUpdateNotification(o);break}return!0}};var C=Object.getOwnPropertyDescriptor,M=(e,r,t,n)=>{for(var i=n>1?void 0:n?C(r,t):r,a=e.length-1,c;a>=0;a--)(c=e[a])&&(i=c(i)||i);return i},u=(e,r)=>(t,n)=>r(t,n,e);const N="SHEET_DRAWING_PLUGIN";let p=class extends s.Disposable{constructor(e,r,t,n,i,a){super(),this._sheetInterceptorService=e,this._univerInstanceService=r,this._commandService=t,this._sheetDrawingService=n,this._drawingManagerService=i,this._resourceManagerService=a,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(g))}_initSnapshot(){const e=(t,n)=>{const i=n||this._sheetDrawingService.getDrawingDataForUnit(t);return i?JSON.stringify(i):""},r=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:N,businesses:[s.UniverInstanceType.UNIVER_SHEET],toJson:(t,n)=>e(t,n),parseJson:t=>r(t),onUnLoad:t=>{this._sheetDrawingService.removeDrawingDataForUnit(t),this._drawingManagerService.removeDrawingDataForUnit(t)},onLoad:(t,n)=>{this._sheetDrawingService.registerDrawingData(t,n),this._drawingManagerService.registerDrawingData(t,n)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var r;if(e.id===m.RemoveSheetCommand.id){const t=e.params,n=t.unitId||this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),i=t.subUnitId||((r=this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:r.getSheetId());if(!n||!i)return{redos:[],undos:[]};const a=this._sheetDrawingService.getDrawingData(n,i),c=Object.values(a).filter(_=>_.drawingType!==s.DrawingTypeEnum.DRAWING_CHART);if(c.length===0)return{redos:[],undos:[]};const d=this._sheetDrawingService.getBatchRemoveOp(c),{unitId:o,subUnitId:v,undo:S,redo:f,objects:I}=d;return{redos:[{id:g.id,params:{op:f,unitId:o,subUnitId:v,objects:I,type:h.REMOVE}}],undos:[{id:g.id,params:{op:S,unitId:o,subUnitId:v,objects:I,type:h.INSERT}}]}}else if(e.id===m.CopySheetCommand.id){const t=e.params,{unitId:n,subUnitId:i,targetSubUnitId:a}=t;if(!n||!i||!a)return{redos:[],undos:[]};const c=this._sheetDrawingService.getDrawingData(n,i),d=Object.values(c).filter(l=>l.drawingType!==s.DrawingTypeEnum.DRAWING_CHART).map(l=>({...l,subUnitId:a,drawingId:s.generateRandomId(6)}));if(d.length===0)return{redos:[],undos:[]};const o=this._sheetDrawingService.getBatchAddOp(d),{unitId:v,subUnitId:S,undo:f,redo:I,objects:_}=o;return{redos:[{id:g.id,params:{op:I,unitId:v,subUnitId:S,objects:_,type:h.INSERT}}],undos:[{id:g.id,params:{op:f,unitId:v,subUnitId:S,objects:_,type:h.REMOVE}}]}}return{redos:[],undos:[]}}}))}};p=M([u(0,s.Inject(m.SheetInterceptorService)),u(1,s.Inject(s.IUniverInstanceService)),u(2,s.ICommandService),u(3,w),u(4,U.IDrawingManagerService),u(5,s.IResourceManagerService)],p);const j="@univerjs/sheets-drawing",T="0.17.0",P={name:j,version:T},G="sheets-drawing.config",E={};var H=Object.defineProperty,W=Object.getOwnPropertyDescriptor,y=(e,r,t)=>r in e?H(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,A=(e,r,t,n)=>{for(var i=n>1?void 0:n?W(r,t):r,a=e.length-1,c;a>=0;a--)(c=e[a])&&(i=c(i)||i);return i},b=(e,r)=>(t,n)=>r(t,n,e),D=(e,r,t)=>y(e,typeof r!="symbol"?r+"":r,t);exports.UniverSheetsDrawingPlugin=class extends s.Plugin{constructor(r=E,t,n){super(),this._config=r,this._injector=t,this._configService=n;const{...i}=s.merge({},E,this._config);this._configService.setConfig(G,i)}onStarting(){[[p],[w,{useClass:R}]].forEach(r=>this._injector.add(r)),this._injector.get(p)}};D(exports.UniverSheetsDrawingPlugin,"pluginName",N);D(exports.UniverSheetsDrawingPlugin,"packageName",P.name);D(exports.UniverSheetsDrawingPlugin,"version",P.version);D(exports.UniverSheetsDrawingPlugin,"type",s.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsDrawingPlugin=A([s.DependentOn(U.UniverDrawingPlugin),b(1,s.Inject(s.Injector)),b(2,s.IConfigService)],exports.UniverSheetsDrawingPlugin);exports.DrawingApplyType=h;exports.ISheetDrawingService=w;exports.SHEET_DRAWING_PLUGIN=N;exports.SetDrawingApplyMutation=g;exports.SheetDrawingAnchorType=O;
package/lib/es/index.js CHANGED
@@ -1,16 +1,16 @@
1
- import { createIdentifier as P, CommandType as C, Inject as N, IUniverInstanceService as M, ICommandService as j, IResourceManagerService as G, Disposable as T, UniverInstanceType as I, DrawingTypeEnum as D, generateRandomId as H, DependentOn as J, Injector as V, IConfigService as W, Plugin as L, merge as F } from "@univerjs/core";
2
- import { UnitDrawingService as x, IDrawingManagerService as O, UniverDrawingPlugin as A } from "@univerjs/drawing";
3
- import { SheetInterceptorService as B, RemoveSheetCommand as $, CopySheetCommand as K } from "@univerjs/sheets";
1
+ import { createIdentifier as C, CommandType as M, Inject as E, IUniverInstanceService as j, ICommandService as G, IResourceManagerService as T, Disposable as H, UniverInstanceType as p, DrawingTypeEnum as D, generateRandomId as J, DependentOn as V, Injector as W, IConfigService as L, Plugin as F, merge as x } from "@univerjs/core";
2
+ import { UnitDrawingService as A, IDrawingManagerService as R, UniverDrawingPlugin as B } from "@univerjs/drawing";
3
+ import { SheetInterceptorService as $, RemoveSheetCommand as k, CopySheetCommand as K } from "@univerjs/sheets";
4
4
  var Y = /* @__PURE__ */ ((e) => (e.Position = "0", e.Both = "1", e.None = "2", e))(Y || {});
5
- class k extends x {
5
+ class q extends A {
6
6
  }
7
- const E = P("sheets-drawing.sheet-drawing.service");
8
- var h = /* @__PURE__ */ ((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))(h || {});
9
- const g = {
7
+ const w = C("sheets-drawing.sheet-drawing.service");
8
+ var v = /* @__PURE__ */ ((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))(v || {});
9
+ const h = {
10
10
  id: "sheet.mutation.set-drawing-apply",
11
- type: C.MUTATION,
11
+ type: M.MUTATION,
12
12
  handler: (e, i) => {
13
- const t = e.get(O), r = e.get(E), { op: n, unitId: s, subUnitId: o, type: c, objects: a } = i;
13
+ const t = e.get(R), r = e.get(w), { op: n, unitId: s, subUnitId: o, type: c, objects: a } = i;
14
14
  switch (t.applyJson1(s, o, n), r.applyJson1(s, o, n), c) {
15
15
  case 0:
16
16
  t.addNotification(a), r.addNotification(a);
@@ -34,15 +34,15 @@ const g = {
34
34
  return !0;
35
35
  }
36
36
  };
37
- var q = Object.getOwnPropertyDescriptor, z = (e, i, t, r) => {
38
- for (var n = r > 1 ? void 0 : r ? q(i, t) : i, s = e.length - 1, o; s >= 0; s--)
37
+ var z = Object.getOwnPropertyDescriptor, Q = (e, i, t, r) => {
38
+ for (var n = r > 1 ? void 0 : r ? z(i, t) : i, s = e.length - 1, o; s >= 0; s--)
39
39
  (o = e[s]) && (n = o(n) || n);
40
40
  return n;
41
41
  }, d = (e, i) => (t, r) => i(t, r, e);
42
- const R = "SHEET_DRAWING_PLUGIN";
43
- let p = class extends T {
42
+ const l = "SHEET_DRAWING_PLUGIN";
43
+ let f = class extends H {
44
44
  constructor(e, i, t, r, n, s) {
45
- super(), this._sheetInterceptorService = e, this._univerInstanceService = i, this._commandService = t, this._sheetDrawingService = r, this._drawingManagerService = n, this._resourceManagerService = s, this._initSnapshot(), this._initSheetChange(), this.disposeWithMe(this._commandService.registerCommand(g));
45
+ super(), this._sheetInterceptorService = e, this._univerInstanceService = i, this._commandService = t, this._sheetDrawingService = r, this._drawingManagerService = n, this._resourceManagerService = s, this._initSnapshot(), this._initSheetChange(), this.disposeWithMe(this._commandService.registerCommand(h));
46
46
  }
47
47
  _initSnapshot() {
48
48
  const e = (t, r) => {
@@ -59,8 +59,8 @@ let p = class extends T {
59
59
  };
60
60
  this.disposeWithMe(
61
61
  this._resourceManagerService.registerPluginResource({
62
- pluginName: R,
63
- businesses: [I.UNIVER_SHEET],
62
+ pluginName: l,
63
+ businesses: [p.UNIVER_SHEET],
64
64
  toJson: (t, r) => e(t, r),
65
65
  parseJson: (t) => i(t),
66
66
  onUnLoad: (t) => {
@@ -79,36 +79,36 @@ let p = class extends T {
79
79
  // eslint-disable-next-line max-lines-per-function
80
80
  getMutations: (e) => {
81
81
  var i;
82
- if (e.id === $.id) {
83
- const t = e.params, r = t.unitId || this._univerInstanceService.getCurrentUnitOfType(I.UNIVER_SHEET).getUnitId(), n = t.subUnitId || ((i = this._univerInstanceService.getCurrentUnitOfType(I.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : i.getSheetId());
82
+ if (e.id === k.id) {
83
+ const t = e.params, r = t.unitId || this._univerInstanceService.getCurrentUnitOfType(p.UNIVER_SHEET).getUnitId(), n = t.subUnitId || ((i = this._univerInstanceService.getCurrentUnitOfType(p.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : i.getSheetId());
84
84
  if (!r || !n)
85
85
  return { redos: [], undos: [] };
86
- const s = this._sheetDrawingService.getDrawingData(r, n), o = Object.values(s).filter((_) => _.drawingType !== D.DRAWING_CHART);
86
+ const s = this._sheetDrawingService.getDrawingData(r, n), o = Object.values(s).filter((I) => I.drawingType !== D.DRAWING_CHART);
87
87
  if (o.length === 0)
88
88
  return { redos: [], undos: [] };
89
- const c = this._sheetDrawingService.getBatchRemoveOp(o), { unitId: a, subUnitId: u, undo: v, redo: U, objects: S } = c;
89
+ const c = this._sheetDrawingService.getBatchRemoveOp(o), { unitId: a, subUnitId: g, undo: S, redo: U, objects: _ } = c;
90
90
  return {
91
91
  redos: [
92
92
  {
93
- id: g.id,
93
+ id: h.id,
94
94
  params: {
95
95
  op: U,
96
96
  unitId: a,
97
- subUnitId: u,
98
- objects: S,
99
- type: h.REMOVE
97
+ subUnitId: g,
98
+ objects: _,
99
+ type: v.REMOVE
100
100
  }
101
101
  }
102
102
  ],
103
103
  undos: [
104
104
  {
105
- id: g.id,
105
+ id: h.id,
106
106
  params: {
107
- op: v,
107
+ op: S,
108
108
  unitId: a,
109
- subUnitId: u,
110
- objects: S,
111
- type: h.INSERT
109
+ subUnitId: g,
110
+ objects: _,
111
+ type: v.INSERT
112
112
  }
113
113
  }
114
114
  ]
@@ -117,36 +117,36 @@ let p = class extends T {
117
117
  const t = e.params, { unitId: r, subUnitId: n, targetSubUnitId: s } = t;
118
118
  if (!r || !n || !s)
119
119
  return { redos: [], undos: [] };
120
- const o = this._sheetDrawingService.getDrawingData(r, n), c = Object.values(o).filter((m) => m.drawingType !== D.DRAWING_CHART).map((m) => ({
121
- ...m,
120
+ const o = this._sheetDrawingService.getDrawingData(r, n), c = Object.values(o).filter((N) => N.drawingType !== D.DRAWING_CHART).map((N) => ({
121
+ ...N,
122
122
  subUnitId: s,
123
- drawingId: H(6)
123
+ drawingId: J(6)
124
124
  }));
125
125
  if (c.length === 0)
126
126
  return { redos: [], undos: [] };
127
- const a = this._sheetDrawingService.getBatchAddOp(c), { unitId: u, subUnitId: v, undo: U, redo: S, objects: _ } = a;
127
+ const a = this._sheetDrawingService.getBatchAddOp(c), { unitId: g, subUnitId: S, undo: U, redo: _, objects: I } = a;
128
128
  return {
129
129
  redos: [
130
130
  {
131
- id: g.id,
131
+ id: h.id,
132
132
  params: {
133
- op: S,
134
- unitId: u,
135
- subUnitId: v,
136
- objects: _,
137
- type: h.INSERT
133
+ op: _,
134
+ unitId: g,
135
+ subUnitId: S,
136
+ objects: I,
137
+ type: v.INSERT
138
138
  }
139
139
  }
140
140
  ],
141
141
  undos: [
142
142
  {
143
- id: g.id,
143
+ id: h.id,
144
144
  params: {
145
145
  op: U,
146
- unitId: u,
147
- subUnitId: v,
148
- objects: _,
149
- type: h.REMOVE
146
+ unitId: g,
147
+ subUnitId: S,
148
+ objects: I,
149
+ type: v.REMOVE
150
150
  }
151
151
  }
152
152
  ]
@@ -158,49 +158,54 @@ let p = class extends T {
158
158
  );
159
159
  }
160
160
  };
161
- p = z([
162
- d(0, N(B)),
163
- d(1, N(M)),
164
- d(2, j),
165
- d(3, E),
166
- d(4, O),
167
- d(5, G)
168
- ], p);
169
- const Q = "sheets-drawing.config", b = {};
170
- var X = Object.defineProperty, Z = Object.getOwnPropertyDescriptor, y = (e, i, t) => i in e ? X(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t, ee = (e, i, t, r) => {
171
- for (var n = r > 1 ? void 0 : r ? Z(i, t) : i, s = e.length - 1, o; s >= 0; s--)
161
+ f = Q([
162
+ d(0, E($)),
163
+ d(1, E(j)),
164
+ d(2, G),
165
+ d(3, w),
166
+ d(4, R),
167
+ d(5, T)
168
+ ], f);
169
+ const X = "@univerjs/sheets-drawing", Z = "0.17.0", P = {
170
+ name: X,
171
+ version: Z
172
+ }, y = "sheets-drawing.config", b = {};
173
+ var ee = Object.defineProperty, te = Object.getOwnPropertyDescriptor, re = (e, i, t) => i in e ? ee(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t, ie = (e, i, t, r) => {
174
+ for (var n = r > 1 ? void 0 : r ? te(i, t) : i, s = e.length - 1, o; s >= 0; s--)
172
175
  (o = e[s]) && (n = o(n) || n);
173
176
  return n;
174
- }, w = (e, i) => (t, r) => i(t, r, e), l = (e, i, t) => y(e, typeof i != "symbol" ? i + "" : i, t);
175
- let f = class extends L {
177
+ }, O = (e, i) => (t, r) => i(t, r, e), m = (e, i, t) => re(e, typeof i != "symbol" ? i + "" : i, t);
178
+ let u = class extends F {
176
179
  constructor(e = b, i, t) {
177
180
  super(), this._config = e, this._injector = i, this._configService = t;
178
- const { ...r } = F(
181
+ const { ...r } = x(
179
182
  {},
180
183
  b,
181
184
  this._config
182
185
  );
183
- this._configService.setConfig(Q, r);
186
+ this._configService.setConfig(y, r);
184
187
  }
185
188
  onStarting() {
186
189
  [
187
- [p],
188
- [E, { useClass: k }]
189
- ].forEach((e) => this._injector.add(e)), this._injector.get(p);
190
+ [f],
191
+ [w, { useClass: q }]
192
+ ].forEach((e) => this._injector.add(e)), this._injector.get(f);
190
193
  }
191
194
  };
192
- l(f, "pluginName", R);
193
- l(f, "type", I.UNIVER_SHEET);
194
- f = ee([
195
- J(A),
196
- w(1, N(V)),
197
- w(2, W)
198
- ], f);
195
+ m(u, "pluginName", l);
196
+ m(u, "packageName", P.name);
197
+ m(u, "version", P.version);
198
+ m(u, "type", p.UNIVER_SHEET);
199
+ u = ie([
200
+ V(B),
201
+ O(1, E(W)),
202
+ O(2, L)
203
+ ], u);
199
204
  export {
200
- h as DrawingApplyType,
201
- E as ISheetDrawingService,
202
- R as SHEET_DRAWING_PLUGIN,
203
- g as SetDrawingApplyMutation,
205
+ v as DrawingApplyType,
206
+ w as ISheetDrawingService,
207
+ l as SHEET_DRAWING_PLUGIN,
208
+ h as SetDrawingApplyMutation,
204
209
  Y as SheetDrawingAnchorType,
205
- f as UniverSheetsDrawingPlugin
210
+ u as UniverSheetsDrawingPlugin
206
211
  };
package/lib/index.js CHANGED
@@ -1,16 +1,16 @@
1
- import { createIdentifier as P, CommandType as C, Inject as N, IUniverInstanceService as M, ICommandService as j, IResourceManagerService as G, Disposable as T, UniverInstanceType as I, DrawingTypeEnum as D, generateRandomId as H, DependentOn as J, Injector as V, IConfigService as W, Plugin as L, merge as F } from "@univerjs/core";
2
- import { UnitDrawingService as x, IDrawingManagerService as O, UniverDrawingPlugin as A } from "@univerjs/drawing";
3
- import { SheetInterceptorService as B, RemoveSheetCommand as $, CopySheetCommand as K } from "@univerjs/sheets";
1
+ import { createIdentifier as C, CommandType as M, Inject as E, IUniverInstanceService as j, ICommandService as G, IResourceManagerService as T, Disposable as H, UniverInstanceType as p, DrawingTypeEnum as D, generateRandomId as J, DependentOn as V, Injector as W, IConfigService as L, Plugin as F, merge as x } from "@univerjs/core";
2
+ import { UnitDrawingService as A, IDrawingManagerService as R, UniverDrawingPlugin as B } from "@univerjs/drawing";
3
+ import { SheetInterceptorService as $, RemoveSheetCommand as k, CopySheetCommand as K } from "@univerjs/sheets";
4
4
  var Y = /* @__PURE__ */ ((e) => (e.Position = "0", e.Both = "1", e.None = "2", e))(Y || {});
5
- class k extends x {
5
+ class q extends A {
6
6
  }
7
- const E = P("sheets-drawing.sheet-drawing.service");
8
- var h = /* @__PURE__ */ ((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))(h || {});
9
- const g = {
7
+ const w = C("sheets-drawing.sheet-drawing.service");
8
+ var v = /* @__PURE__ */ ((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))(v || {});
9
+ const h = {
10
10
  id: "sheet.mutation.set-drawing-apply",
11
- type: C.MUTATION,
11
+ type: M.MUTATION,
12
12
  handler: (e, i) => {
13
- const t = e.get(O), r = e.get(E), { op: n, unitId: s, subUnitId: o, type: c, objects: a } = i;
13
+ const t = e.get(R), r = e.get(w), { op: n, unitId: s, subUnitId: o, type: c, objects: a } = i;
14
14
  switch (t.applyJson1(s, o, n), r.applyJson1(s, o, n), c) {
15
15
  case 0:
16
16
  t.addNotification(a), r.addNotification(a);
@@ -34,15 +34,15 @@ const g = {
34
34
  return !0;
35
35
  }
36
36
  };
37
- var q = Object.getOwnPropertyDescriptor, z = (e, i, t, r) => {
38
- for (var n = r > 1 ? void 0 : r ? q(i, t) : i, s = e.length - 1, o; s >= 0; s--)
37
+ var z = Object.getOwnPropertyDescriptor, Q = (e, i, t, r) => {
38
+ for (var n = r > 1 ? void 0 : r ? z(i, t) : i, s = e.length - 1, o; s >= 0; s--)
39
39
  (o = e[s]) && (n = o(n) || n);
40
40
  return n;
41
41
  }, d = (e, i) => (t, r) => i(t, r, e);
42
- const R = "SHEET_DRAWING_PLUGIN";
43
- let p = class extends T {
42
+ const l = "SHEET_DRAWING_PLUGIN";
43
+ let f = class extends H {
44
44
  constructor(e, i, t, r, n, s) {
45
- super(), this._sheetInterceptorService = e, this._univerInstanceService = i, this._commandService = t, this._sheetDrawingService = r, this._drawingManagerService = n, this._resourceManagerService = s, this._initSnapshot(), this._initSheetChange(), this.disposeWithMe(this._commandService.registerCommand(g));
45
+ super(), this._sheetInterceptorService = e, this._univerInstanceService = i, this._commandService = t, this._sheetDrawingService = r, this._drawingManagerService = n, this._resourceManagerService = s, this._initSnapshot(), this._initSheetChange(), this.disposeWithMe(this._commandService.registerCommand(h));
46
46
  }
47
47
  _initSnapshot() {
48
48
  const e = (t, r) => {
@@ -59,8 +59,8 @@ let p = class extends T {
59
59
  };
60
60
  this.disposeWithMe(
61
61
  this._resourceManagerService.registerPluginResource({
62
- pluginName: R,
63
- businesses: [I.UNIVER_SHEET],
62
+ pluginName: l,
63
+ businesses: [p.UNIVER_SHEET],
64
64
  toJson: (t, r) => e(t, r),
65
65
  parseJson: (t) => i(t),
66
66
  onUnLoad: (t) => {
@@ -79,36 +79,36 @@ let p = class extends T {
79
79
  // eslint-disable-next-line max-lines-per-function
80
80
  getMutations: (e) => {
81
81
  var i;
82
- if (e.id === $.id) {
83
- const t = e.params, r = t.unitId || this._univerInstanceService.getCurrentUnitOfType(I.UNIVER_SHEET).getUnitId(), n = t.subUnitId || ((i = this._univerInstanceService.getCurrentUnitOfType(I.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : i.getSheetId());
82
+ if (e.id === k.id) {
83
+ const t = e.params, r = t.unitId || this._univerInstanceService.getCurrentUnitOfType(p.UNIVER_SHEET).getUnitId(), n = t.subUnitId || ((i = this._univerInstanceService.getCurrentUnitOfType(p.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : i.getSheetId());
84
84
  if (!r || !n)
85
85
  return { redos: [], undos: [] };
86
- const s = this._sheetDrawingService.getDrawingData(r, n), o = Object.values(s).filter((_) => _.drawingType !== D.DRAWING_CHART);
86
+ const s = this._sheetDrawingService.getDrawingData(r, n), o = Object.values(s).filter((I) => I.drawingType !== D.DRAWING_CHART);
87
87
  if (o.length === 0)
88
88
  return { redos: [], undos: [] };
89
- const c = this._sheetDrawingService.getBatchRemoveOp(o), { unitId: a, subUnitId: u, undo: v, redo: U, objects: S } = c;
89
+ const c = this._sheetDrawingService.getBatchRemoveOp(o), { unitId: a, subUnitId: g, undo: S, redo: U, objects: _ } = c;
90
90
  return {
91
91
  redos: [
92
92
  {
93
- id: g.id,
93
+ id: h.id,
94
94
  params: {
95
95
  op: U,
96
96
  unitId: a,
97
- subUnitId: u,
98
- objects: S,
99
- type: h.REMOVE
97
+ subUnitId: g,
98
+ objects: _,
99
+ type: v.REMOVE
100
100
  }
101
101
  }
102
102
  ],
103
103
  undos: [
104
104
  {
105
- id: g.id,
105
+ id: h.id,
106
106
  params: {
107
- op: v,
107
+ op: S,
108
108
  unitId: a,
109
- subUnitId: u,
110
- objects: S,
111
- type: h.INSERT
109
+ subUnitId: g,
110
+ objects: _,
111
+ type: v.INSERT
112
112
  }
113
113
  }
114
114
  ]
@@ -117,36 +117,36 @@ let p = class extends T {
117
117
  const t = e.params, { unitId: r, subUnitId: n, targetSubUnitId: s } = t;
118
118
  if (!r || !n || !s)
119
119
  return { redos: [], undos: [] };
120
- const o = this._sheetDrawingService.getDrawingData(r, n), c = Object.values(o).filter((m) => m.drawingType !== D.DRAWING_CHART).map((m) => ({
121
- ...m,
120
+ const o = this._sheetDrawingService.getDrawingData(r, n), c = Object.values(o).filter((N) => N.drawingType !== D.DRAWING_CHART).map((N) => ({
121
+ ...N,
122
122
  subUnitId: s,
123
- drawingId: H(6)
123
+ drawingId: J(6)
124
124
  }));
125
125
  if (c.length === 0)
126
126
  return { redos: [], undos: [] };
127
- const a = this._sheetDrawingService.getBatchAddOp(c), { unitId: u, subUnitId: v, undo: U, redo: S, objects: _ } = a;
127
+ const a = this._sheetDrawingService.getBatchAddOp(c), { unitId: g, subUnitId: S, undo: U, redo: _, objects: I } = a;
128
128
  return {
129
129
  redos: [
130
130
  {
131
- id: g.id,
131
+ id: h.id,
132
132
  params: {
133
- op: S,
134
- unitId: u,
135
- subUnitId: v,
136
- objects: _,
137
- type: h.INSERT
133
+ op: _,
134
+ unitId: g,
135
+ subUnitId: S,
136
+ objects: I,
137
+ type: v.INSERT
138
138
  }
139
139
  }
140
140
  ],
141
141
  undos: [
142
142
  {
143
- id: g.id,
143
+ id: h.id,
144
144
  params: {
145
145
  op: U,
146
- unitId: u,
147
- subUnitId: v,
148
- objects: _,
149
- type: h.REMOVE
146
+ unitId: g,
147
+ subUnitId: S,
148
+ objects: I,
149
+ type: v.REMOVE
150
150
  }
151
151
  }
152
152
  ]
@@ -158,49 +158,54 @@ let p = class extends T {
158
158
  );
159
159
  }
160
160
  };
161
- p = z([
162
- d(0, N(B)),
163
- d(1, N(M)),
164
- d(2, j),
165
- d(3, E),
166
- d(4, O),
167
- d(5, G)
168
- ], p);
169
- const Q = "sheets-drawing.config", b = {};
170
- var X = Object.defineProperty, Z = Object.getOwnPropertyDescriptor, y = (e, i, t) => i in e ? X(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t, ee = (e, i, t, r) => {
171
- for (var n = r > 1 ? void 0 : r ? Z(i, t) : i, s = e.length - 1, o; s >= 0; s--)
161
+ f = Q([
162
+ d(0, E($)),
163
+ d(1, E(j)),
164
+ d(2, G),
165
+ d(3, w),
166
+ d(4, R),
167
+ d(5, T)
168
+ ], f);
169
+ const X = "@univerjs/sheets-drawing", Z = "0.17.0", P = {
170
+ name: X,
171
+ version: Z
172
+ }, y = "sheets-drawing.config", b = {};
173
+ var ee = Object.defineProperty, te = Object.getOwnPropertyDescriptor, re = (e, i, t) => i in e ? ee(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t, ie = (e, i, t, r) => {
174
+ for (var n = r > 1 ? void 0 : r ? te(i, t) : i, s = e.length - 1, o; s >= 0; s--)
172
175
  (o = e[s]) && (n = o(n) || n);
173
176
  return n;
174
- }, w = (e, i) => (t, r) => i(t, r, e), l = (e, i, t) => y(e, typeof i != "symbol" ? i + "" : i, t);
175
- let f = class extends L {
177
+ }, O = (e, i) => (t, r) => i(t, r, e), m = (e, i, t) => re(e, typeof i != "symbol" ? i + "" : i, t);
178
+ let u = class extends F {
176
179
  constructor(e = b, i, t) {
177
180
  super(), this._config = e, this._injector = i, this._configService = t;
178
- const { ...r } = F(
181
+ const { ...r } = x(
179
182
  {},
180
183
  b,
181
184
  this._config
182
185
  );
183
- this._configService.setConfig(Q, r);
186
+ this._configService.setConfig(y, r);
184
187
  }
185
188
  onStarting() {
186
189
  [
187
- [p],
188
- [E, { useClass: k }]
189
- ].forEach((e) => this._injector.add(e)), this._injector.get(p);
190
+ [f],
191
+ [w, { useClass: q }]
192
+ ].forEach((e) => this._injector.add(e)), this._injector.get(f);
190
193
  }
191
194
  };
192
- l(f, "pluginName", R);
193
- l(f, "type", I.UNIVER_SHEET);
194
- f = ee([
195
- J(A),
196
- w(1, N(V)),
197
- w(2, W)
198
- ], f);
195
+ m(u, "pluginName", l);
196
+ m(u, "packageName", P.name);
197
+ m(u, "version", P.version);
198
+ m(u, "type", p.UNIVER_SHEET);
199
+ u = ie([
200
+ V(B),
201
+ O(1, E(W)),
202
+ O(2, L)
203
+ ], u);
199
204
  export {
200
- h as DrawingApplyType,
201
- E as ISheetDrawingService,
202
- R as SHEET_DRAWING_PLUGIN,
203
- g as SetDrawingApplyMutation,
205
+ v as DrawingApplyType,
206
+ w as ISheetDrawingService,
207
+ l as SHEET_DRAWING_PLUGIN,
208
+ h as SetDrawingApplyMutation,
204
209
  Y as SheetDrawingAnchorType,
205
- f as UniverSheetsDrawingPlugin
210
+ u as UniverSheetsDrawingPlugin
206
211
  };
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export { DrawingApplyType, type ISetDrawingApplyMutationParams, SetDrawingApplyMutation } from './commands/mutations/set-drawing-apply.mutation';
17
- export type { IUniverSheetsDrawingConfig } from './controllers/config.schema';
17
+ export type { IUniverSheetsDrawingConfig } from './config/config';
18
18
  export { SHEET_DRAWING_PLUGIN } from './controllers/sheet-drawing.controller';
19
19
  export { UniverSheetsDrawingPlugin } from './plugin';
20
20
  export { ISheetDrawingService, SheetDrawingAnchorType } from './services/sheet-drawing.service';
@@ -1,10 +1,12 @@
1
- import { IUniverSheetsDrawingConfig } from './controllers/config.schema';
1
+ import { IUniverSheetsDrawingConfig } from './config/config';
2
2
  import { IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
3
3
  export declare class UniverSheetsDrawingPlugin extends Plugin {
4
4
  private readonly _config;
5
5
  readonly _injector: Injector;
6
6
  private readonly _configService;
7
7
  static pluginName: string;
8
+ static packageName: string;
9
+ static version: string;
8
10
  static type: UniverInstanceType;
9
11
  constructor(_config: Partial<IUniverSheetsDrawingConfig> | undefined, _injector: Injector, _configService: IConfigService);
10
12
  onStarting(): void;
@@ -37,8 +37,8 @@ export interface IFloatDomData extends IDrawingParam {
37
37
  data?: Serializable;
38
38
  allowTransform?: boolean;
39
39
  /**
40
- * this property is used to store the excel drawing axis alignment position, which is not always the same as the sheetTransform.
41
- */
40
+ * this property is used to store the excel drawing axis alignment position, which is not always the same as the sheetTransform.
41
+ */
42
42
  axisAlignSheetTransform: ISheetDrawingPosition;
43
43
  }
44
44
  export interface ISheetFloatDom extends IFloatDomData, ISheetDrawingBase {
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(a,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/sheets")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing","@univerjs/sheets"],r):(a=typeof globalThis<"u"?globalThis:a||self,r(a.UniverSheetsDrawing={},a.UniverCore,a.UniverDrawing,a.UniverSheets))})(this,(function(a,r,I,w){"use strict";var l=(e=>(e.Position="0",e.Both="1",e.None="2",e))(l||{});class P extends I.UnitDrawingService{}const _=r.createIdentifier("sheets-drawing.sheet-drawing.service");var c=(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))(c||{});const g={id:"sheet.mutation.set-drawing-apply",type:r.CommandType.MUTATION,handler:(e,n)=>{const t=e.get(I.IDrawingManagerService),i=e.get(_),{op:s,unitId:o,subUnitId:u,type:h,objects:d}=n;switch(t.applyJson1(o,u,s),i.applyJson1(o,u,s),h){case 0:t.addNotification(d),i.addNotification(d);break;case 1:t.removeNotification(d),i.removeNotification(d);break;case 2:t.updateNotification(d),i.updateNotification(d);break;case 3:t.orderNotification(d),i.orderNotification(d);break;case 4:t.groupUpdateNotification(d);break;case 5:t.ungroupUpdateNotification(d);break}return!0}};var j=Object.getOwnPropertyDescriptor,C=(e,n,t,i)=>{for(var s=i>1?void 0:i?j(n,t):n,o=e.length-1,u;o>=0;o--)(u=e[o])&&(s=u(s)||s);return s},v=(e,n)=>(t,i)=>n(t,i,e);const m="SHEET_DRAWING_PLUGIN";let U=class extends r.Disposable{constructor(e,n,t,i,s,o){super(),this._sheetInterceptorService=e,this._univerInstanceService=n,this._commandService=t,this._sheetDrawingService=i,this._drawingManagerService=s,this._resourceManagerService=o,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(g))}_initSnapshot(){const e=(t,i)=>{const s=i||this._sheetDrawingService.getDrawingDataForUnit(t);return s?JSON.stringify(s):""},n=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:m,businesses:[r.UniverInstanceType.UNIVER_SHEET],toJson:(t,i)=>e(t,i),parseJson:t=>n(t),onUnLoad:t=>{this._sheetDrawingService.removeDrawingDataForUnit(t),this._drawingManagerService.removeDrawingDataForUnit(t)},onLoad:(t,i)=>{this._sheetDrawingService.registerDrawingData(t,i),this._drawingManagerService.registerDrawingData(t,i)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var n;if(e.id===w.RemoveSheetCommand.id){const t=e.params,i=t.unitId||this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET).getUnitId(),s=t.subUnitId||((n=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId());if(!i||!s)return{redos:[],undos:[]};const o=this._sheetDrawingService.getDrawingData(i,s),u=Object.values(o).filter(D=>D.drawingType!==r.DrawingTypeEnum.DRAWING_CHART);if(u.length===0)return{redos:[],undos:[]};const h=this._sheetDrawingService.getBatchRemoveOp(u),{unitId:d,subUnitId:S,undo:f,redo:E,objects:p}=h;return{redos:[{id:g.id,params:{op:E,unitId:d,subUnitId:S,objects:p,type:c.REMOVE}}],undos:[{id:g.id,params:{op:f,unitId:d,subUnitId:S,objects:p,type:c.INSERT}}]}}else if(e.id===w.CopySheetCommand.id){const t=e.params,{unitId:i,subUnitId:s,targetSubUnitId:o}=t;if(!i||!s||!o)return{redos:[],undos:[]};const u=this._sheetDrawingService.getDrawingData(i,s),h=Object.values(u).filter(N=>N.drawingType!==r.DrawingTypeEnum.DRAWING_CHART).map(N=>({...N,subUnitId:o,drawingId:r.generateRandomId(6)}));if(h.length===0)return{redos:[],undos:[]};const d=this._sheetDrawingService.getBatchAddOp(h),{unitId:S,subUnitId:f,undo:E,redo:p,objects:D}=d;return{redos:[{id:g.id,params:{op:p,unitId:S,subUnitId:f,objects:D,type:c.INSERT}}],undos:[{id:g.id,params:{op:E,unitId:S,subUnitId:f,objects:D,type:c.REMOVE}}]}}return{redos:[],undos:[]}}}))}};U=C([v(0,r.Inject(w.SheetInterceptorService)),v(1,r.Inject(r.IUniverInstanceService)),v(2,r.ICommandService),v(3,_),v(4,I.IDrawingManagerService),v(5,r.IResourceManagerService)],U);const M="sheets-drawing.config",b={};var T=Object.defineProperty,G=Object.getOwnPropertyDescriptor,y=(e,n,t)=>n in e?T(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,H=(e,n,t,i)=>{for(var s=i>1?void 0:i?G(n,t):n,o=e.length-1,u;o>=0;o--)(u=e[o])&&(s=u(s)||s);return s},O=(e,n)=>(t,i)=>n(t,i,e),R=(e,n,t)=>y(e,typeof n!="symbol"?n+"":n,t);a.UniverSheetsDrawingPlugin=class extends r.Plugin{constructor(n=b,t,i){super(),this._config=n,this._injector=t,this._configService=i;const{...s}=r.merge({},b,this._config);this._configService.setConfig(M,s)}onStarting(){[[U],[_,{useClass:P}]].forEach(n=>this._injector.add(n)),this._injector.get(U)}},R(a.UniverSheetsDrawingPlugin,"pluginName",m),R(a.UniverSheetsDrawingPlugin,"type",r.UniverInstanceType.UNIVER_SHEET),a.UniverSheetsDrawingPlugin=H([r.DependentOn(I.UniverDrawingPlugin),O(1,r.Inject(r.Injector)),O(2,r.IConfigService)],a.UniverSheetsDrawingPlugin),a.DrawingApplyType=c,a.ISheetDrawingService=_,a.SHEET_DRAWING_PLUGIN=m,a.SetDrawingApplyMutation=g,a.SheetDrawingAnchorType=l,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(a,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/sheets")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing","@univerjs/sheets"],r):(a=typeof globalThis<"u"?globalThis:a||self,r(a.UniverSheetsDrawing={},a.UniverCore,a.UniverDrawing,a.UniverSheets))})(this,(function(a,r,I,m){"use strict";var b=(e=>(e.Position="0",e.Both="1",e.None="2",e))(b||{});class j extends I.UnitDrawingService{}const _=r.createIdentifier("sheets-drawing.sheet-drawing.service");var c=(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))(c||{});const g={id:"sheet.mutation.set-drawing-apply",type:r.CommandType.MUTATION,handler:(e,i)=>{const t=e.get(I.IDrawingManagerService),n=e.get(_),{op:s,unitId:o,subUnitId:d,type:h,objects:u}=i;switch(t.applyJson1(o,d,s),n.applyJson1(o,d,s),h){case 0:t.addNotification(u),n.addNotification(u);break;case 1:t.removeNotification(u),n.removeNotification(u);break;case 2:t.updateNotification(u),n.updateNotification(u);break;case 3:t.orderNotification(u),n.orderNotification(u);break;case 4:t.groupUpdateNotification(u);break;case 5:t.ungroupUpdateNotification(u);break}return!0}};var C=Object.getOwnPropertyDescriptor,M=(e,i,t,n)=>{for(var s=n>1?void 0:n?C(i,t):i,o=e.length-1,d;o>=0;o--)(d=e[o])&&(s=d(s)||s);return s},v=(e,i)=>(t,n)=>i(t,n,e);const N="SHEET_DRAWING_PLUGIN";let U=class extends r.Disposable{constructor(e,i,t,n,s,o){super(),this._sheetInterceptorService=e,this._univerInstanceService=i,this._commandService=t,this._sheetDrawingService=n,this._drawingManagerService=s,this._resourceManagerService=o,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(g))}_initSnapshot(){const e=(t,n)=>{const s=n||this._sheetDrawingService.getDrawingDataForUnit(t);return s?JSON.stringify(s):""},i=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:N,businesses:[r.UniverInstanceType.UNIVER_SHEET],toJson:(t,n)=>e(t,n),parseJson:t=>i(t),onUnLoad:t=>{this._sheetDrawingService.removeDrawingDataForUnit(t),this._drawingManagerService.removeDrawingDataForUnit(t)},onLoad:(t,n)=>{this._sheetDrawingService.registerDrawingData(t,n),this._drawingManagerService.registerDrawingData(t,n)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var i;if(e.id===m.RemoveSheetCommand.id){const t=e.params,n=t.unitId||this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET).getUnitId(),s=t.subUnitId||((i=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:i.getSheetId());if(!n||!s)return{redos:[],undos:[]};const o=this._sheetDrawingService.getDrawingData(n,s),d=Object.values(o).filter(w=>w.drawingType!==r.DrawingTypeEnum.DRAWING_CHART);if(d.length===0)return{redos:[],undos:[]};const h=this._sheetDrawingService.getBatchRemoveOp(d),{unitId:u,subUnitId:S,undo:p,redo:E,objects:D}=h;return{redos:[{id:g.id,params:{op:E,unitId:u,subUnitId:S,objects:D,type:c.REMOVE}}],undos:[{id:g.id,params:{op:p,unitId:u,subUnitId:S,objects:D,type:c.INSERT}}]}}else if(e.id===m.CopySheetCommand.id){const t=e.params,{unitId:n,subUnitId:s,targetSubUnitId:o}=t;if(!n||!s||!o)return{redos:[],undos:[]};const d=this._sheetDrawingService.getDrawingData(n,s),h=Object.values(d).filter(l=>l.drawingType!==r.DrawingTypeEnum.DRAWING_CHART).map(l=>({...l,subUnitId:o,drawingId:r.generateRandomId(6)}));if(h.length===0)return{redos:[],undos:[]};const u=this._sheetDrawingService.getBatchAddOp(h),{unitId:S,subUnitId:p,undo:E,redo:D,objects:w}=u;return{redos:[{id:g.id,params:{op:D,unitId:S,subUnitId:p,objects:w,type:c.INSERT}}],undos:[{id:g.id,params:{op:E,unitId:S,subUnitId:p,objects:w,type:c.REMOVE}}]}}return{redos:[],undos:[]}}}))}};U=M([v(0,r.Inject(m.SheetInterceptorService)),v(1,r.Inject(r.IUniverInstanceService)),v(2,r.ICommandService),v(3,_),v(4,I.IDrawingManagerService),v(5,r.IResourceManagerService)],U);const O={name:"@univerjs/sheets-drawing",version:"0.17.0"},T="sheets-drawing.config",P={};var G=Object.defineProperty,y=Object.getOwnPropertyDescriptor,H=(e,i,t)=>i in e?G(e,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[i]=t,W=(e,i,t,n)=>{for(var s=n>1?void 0:n?y(i,t):i,o=e.length-1,d;o>=0;o--)(d=e[o])&&(s=d(s)||s);return s},R=(e,i)=>(t,n)=>i(t,n,e),f=(e,i,t)=>H(e,typeof i!="symbol"?i+"":i,t);a.UniverSheetsDrawingPlugin=class extends r.Plugin{constructor(i=P,t,n){super(),this._config=i,this._injector=t,this._configService=n;const{...s}=r.merge({},P,this._config);this._configService.setConfig(T,s)}onStarting(){[[U],[_,{useClass:j}]].forEach(i=>this._injector.add(i)),this._injector.get(U)}},f(a.UniverSheetsDrawingPlugin,"pluginName",N),f(a.UniverSheetsDrawingPlugin,"packageName",O.name),f(a.UniverSheetsDrawingPlugin,"version",O.version),f(a.UniverSheetsDrawingPlugin,"type",r.UniverInstanceType.UNIVER_SHEET),a.UniverSheetsDrawingPlugin=W([r.DependentOn(I.UniverDrawingPlugin),R(1,r.Inject(r.Injector)),R(2,r.IConfigService)],a.UniverSheetsDrawingPlugin),a.DrawingApplyType=c,a.ISheetDrawingService=_,a.SHEET_DRAWING_PLUGIN=N,a.SetDrawingApplyMutation=g,a.SheetDrawingAnchorType=b,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-drawing",
3
- "version": "0.16.1",
3
+ "version": "0.17.0",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -43,15 +43,15 @@
43
43
  "lib"
44
44
  ],
45
45
  "dependencies": {
46
- "@univerjs/core": "0.16.1",
47
- "@univerjs/sheets": "0.16.1",
48
- "@univerjs/drawing": "0.16.1"
46
+ "@univerjs/core": "0.17.0",
47
+ "@univerjs/sheets": "0.17.0",
48
+ "@univerjs/drawing": "0.17.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "typescript": "^5.9.3",
52
52
  "vite": "^7.3.1",
53
53
  "vitest": "^4.0.18",
54
- "@univerjs-infra/shared": "0.16.1"
54
+ "@univerjs-infra/shared": "0.17.0"
55
55
  },
56
56
  "scripts": {
57
57
  "test": "vitest run",