@univerjs/sheets-drawing 0.10.14-nightly.202511031023 → 0.10.14-nightly.202511070640

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"),w=require("@univerjs/sheets");var l=(e=>(e.Position="0",e.Both="1",e.None="2",e))(l||{});class P extends U.UnitDrawingService{}const p=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),i=e.get(p),{op:n,unitId:a,subUnitId:c,type:d,objects:o}=r;switch(t.applyJson1(a,c,n),i.applyJson1(a,c,n),d){case 0:t.addNotification(o),i.addNotification(o);break;case 1:t.removeNotification(o),i.removeNotification(o);break;case 2:t.updateNotification(o),i.updateNotification(o);break;case 3:t.orderNotification(o),i.orderNotification(o);break;case 4:t.groupUpdateNotification(o);break;case 5:t.ungroupUpdateNotification(o);break}return!0}};var R=Object.getOwnPropertyDescriptor,M=(e,r,t,i)=>{for(var n=i>1?void 0:i?R(r,t):r,a=e.length-1,c;a>=0;a--)(c=e[a])&&(n=c(n)||n);return n},u=(e,r)=>(t,i)=>r(t,i,e);const f="SHEET_DRAWING_PLUGIN";let _=class extends s.Disposable{constructor(e,r,t,i,n,a){super(),this._sheetInterceptorService=e,this._univerInstanceService=r,this._commandService=t,this._sheetDrawingService=i,this._drawingManagerService=n,this._resourceManagerService=a,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(g))}_initSnapshot(){const e=(t,i)=>{const n=i||this._sheetDrawingService.getDrawingDataForUnit(t);return n?JSON.stringify(n):""},r=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:f,businesses:[s.UniverInstanceType.UNIVER_SHEET],toJson:(t,i)=>e(t,i),parseJson:t=>r(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 r;if(e.id===w.RemoveSheetCommand.id){const t=e.params,i=t.unitId||this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),n=t.subUnitId||((r=this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:r.getSheetId());if(!i||!n)return{redos:[],undos:[]};const a=this._sheetDrawingService.getDrawingData(i,n),c=Object.values(a);if(c.length===0)return{redos:[],undos:[]};const d=this._sheetDrawingService.getBatchRemoveOp(c),{unitId:o,subUnitId:v,undo:S,redo:D,objects:I}=d;return{redos:[{id:g.id,params:{op:D,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===w.CopySheetCommand.id){const t=e.params,{unitId:i,subUnitId:n,targetSubUnitId:a}=t;if(!i||!n||!a)return{redos:[],undos:[]};const c=this._sheetDrawingService.getDrawingData(i,n),d=Object.values(c).map(O=>({...O,subUnitId:a,drawingId:s.generateRandomId(6)}));if(d.length===0)return{redos:[],undos:[]};const o=this._sheetDrawingService.getBatchAddOp(d),{unitId:v,subUnitId:S,undo:D,redo:I,objects:E}=o;return{redos:[{id:g.id,params:{op:I,unitId:v,subUnitId:S,objects:E,type:h.INSERT}}],undos:[{id:g.id,params:{op:D,unitId:v,subUnitId:S,objects:E,type:h.REMOVE}}]}}return{redos:[],undos:[]}}}))}};_=M([u(0,s.Inject(w.SheetInterceptorService)),u(1,s.Inject(s.IUniverInstanceService)),u(2,s.ICommandService),u(3,p),u(4,U.IDrawingManagerService),u(5,s.IResourceManagerService)],_);const j="sheets-drawing.config",N={};var C=Object.defineProperty,G=Object.getOwnPropertyDescriptor,T=(e,r,t)=>r in e?C(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,H=(e,r,t,i)=>{for(var n=i>1?void 0:i?G(r,t):r,a=e.length-1,c;a>=0;a--)(c=e[a])&&(n=c(n)||n);return n},m=(e,r)=>(t,i)=>r(t,i,e),b=(e,r,t)=>T(e,typeof r!="symbol"?r+"":r,t);exports.UniverSheetsDrawingPlugin=class extends s.Plugin{constructor(r=N,t,i){super(),this._config=r,this._injector=t,this._configService=i;const{...n}=s.merge({},N,this._config);this._configService.setConfig(j,n)}onStarting(){[[_],[p,{useClass:P}]].forEach(r=>this._injector.add(r)),this._injector.get(_)}};b(exports.UniverSheetsDrawingPlugin,"pluginName",f);b(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=p;exports.SHEET_DRAWING_PLUGIN=f;exports.SetDrawingApplyMutation=g;exports.SheetDrawingAnchorType=l;
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;
package/lib/es/index.js CHANGED
@@ -1,28 +1,28 @@
1
- import { createIdentifier as l, CommandType as P, Inject as m, IUniverInstanceService as C, ICommandService as M, IResourceManagerService as j, Disposable as G, UniverInstanceType as _, generateRandomId as J, DependentOn as V, Injector as H, IConfigService as L, Plugin as T, merge as W } from "@univerjs/core";
2
- import { UnitDrawingService as F, IDrawingManagerService as O, UniverDrawingPlugin as x } from "@univerjs/drawing";
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
3
  import { SheetInterceptorService as B, RemoveSheetCommand as $, 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 F {
5
+ class k extends x {
6
6
  }
7
- const f = l("sheets-drawing.sheet-drawing.service");
7
+ const E = P("sheets-drawing.sheet-drawing.service");
8
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
9
  const g = {
10
10
  id: "sheet.mutation.set-drawing-apply",
11
- type: P.MUTATION,
12
- handler: (e, r) => {
13
- const t = e.get(O), i = e.get(f), { op: n, unitId: s, subUnitId: o, type: c, objects: a } = r;
14
- switch (t.applyJson1(s, o, n), i.applyJson1(s, o, n), c) {
11
+ type: C.MUTATION,
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;
14
+ switch (t.applyJson1(s, o, n), r.applyJson1(s, o, n), c) {
15
15
  case 0:
16
- t.addNotification(a), i.addNotification(a);
16
+ t.addNotification(a), r.addNotification(a);
17
17
  break;
18
18
  case 1:
19
- t.removeNotification(a), i.removeNotification(a);
19
+ t.removeNotification(a), r.removeNotification(a);
20
20
  break;
21
21
  case 2:
22
- t.updateNotification(a), i.updateNotification(a);
22
+ t.updateNotification(a), r.updateNotification(a);
23
23
  break;
24
24
  case 3:
25
- t.orderNotification(a), i.orderNotification(a);
25
+ t.orderNotification(a), r.orderNotification(a);
26
26
  break;
27
27
  case 4:
28
28
  t.groupUpdateNotification(a);
@@ -34,21 +34,21 @@ const g = {
34
34
  return !0;
35
35
  }
36
36
  };
37
- var q = Object.getOwnPropertyDescriptor, z = (e, r, t, i) => {
38
- for (var n = i > 1 ? void 0 : i ? q(r, t) : r, s = e.length - 1, o; s >= 0; s--)
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--)
39
39
  (o = e[s]) && (n = o(n) || n);
40
40
  return n;
41
- }, d = (e, r) => (t, i) => r(t, i, e);
42
- const D = "SHEET_DRAWING_PLUGIN";
43
- let I = class extends G {
44
- constructor(e, r, t, i, n, s) {
45
- super(), this._sheetInterceptorService = e, this._univerInstanceService = r, this._commandService = t, this._sheetDrawingService = i, this._drawingManagerService = n, this._resourceManagerService = s, this._initSnapshot(), this._initSheetChange(), this.disposeWithMe(this._commandService.registerCommand(g));
41
+ }, d = (e, i) => (t, r) => i(t, r, e);
42
+ const R = "SHEET_DRAWING_PLUGIN";
43
+ let p = class extends T {
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));
46
46
  }
47
47
  _initSnapshot() {
48
- const e = (t, i) => {
49
- const n = i || this._sheetDrawingService.getDrawingDataForUnit(t);
48
+ const e = (t, r) => {
49
+ const n = r || this._sheetDrawingService.getDrawingDataForUnit(t);
50
50
  return n ? JSON.stringify(n) : "";
51
- }, r = (t) => {
51
+ }, i = (t) => {
52
52
  if (!t)
53
53
  return {};
54
54
  try {
@@ -59,15 +59,15 @@ let I = class extends G {
59
59
  };
60
60
  this.disposeWithMe(
61
61
  this._resourceManagerService.registerPluginResource({
62
- pluginName: D,
63
- businesses: [_.UNIVER_SHEET],
64
- toJson: (t, i) => e(t, i),
65
- parseJson: (t) => r(t),
62
+ pluginName: R,
63
+ businesses: [I.UNIVER_SHEET],
64
+ toJson: (t, r) => e(t, r),
65
+ parseJson: (t) => i(t),
66
66
  onUnLoad: (t) => {
67
67
  this._sheetDrawingService.removeDrawingDataForUnit(t), this._drawingManagerService.removeDrawingDataForUnit(t);
68
68
  },
69
- onLoad: (t, i) => {
70
- this._sheetDrawingService.registerDrawingData(t, i), this._drawingManagerService.registerDrawingData(t, i);
69
+ onLoad: (t, r) => {
70
+ this._sheetDrawingService.registerDrawingData(t, r), this._drawingManagerService.registerDrawingData(t, r);
71
71
  }
72
72
  })
73
73
  );
@@ -78,12 +78,12 @@ let I = class extends G {
78
78
  this._sheetInterceptorService.interceptCommand({
79
79
  // eslint-disable-next-line max-lines-per-function
80
80
  getMutations: (e) => {
81
- var r;
81
+ var i;
82
82
  if (e.id === $.id) {
83
- const t = e.params, i = t.unitId || this._univerInstanceService.getCurrentUnitOfType(_.UNIVER_SHEET).getUnitId(), n = t.subUnitId || ((r = this._univerInstanceService.getCurrentUnitOfType(_.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : r.getSheetId());
84
- if (!i || !n)
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());
84
+ if (!r || !n)
85
85
  return { redos: [], undos: [] };
86
- const s = this._sheetDrawingService.getDrawingData(i, n), o = Object.values(s);
86
+ const s = this._sheetDrawingService.getDrawingData(r, n), o = Object.values(s).filter((_) => _.drawingType !== D.DRAWING_CHART);
87
87
  if (o.length === 0)
88
88
  return { redos: [], undos: [] };
89
89
  const c = this._sheetDrawingService.getBatchRemoveOp(o), { unitId: a, subUnitId: u, undo: v, redo: U, objects: S } = c;
@@ -114,17 +114,17 @@ let I = class extends G {
114
114
  ]
115
115
  };
116
116
  } else if (e.id === K.id) {
117
- const t = e.params, { unitId: i, subUnitId: n, targetSubUnitId: s } = t;
118
- if (!i || !n || !s)
117
+ const t = e.params, { unitId: r, subUnitId: n, targetSubUnitId: s } = t;
118
+ if (!r || !n || !s)
119
119
  return { redos: [], undos: [] };
120
- const o = this._sheetDrawingService.getDrawingData(i, n), c = Object.values(o).map((R) => ({
121
- ...R,
120
+ const o = this._sheetDrawingService.getDrawingData(r, n), c = Object.values(o).filter((m) => m.drawingType !== D.DRAWING_CHART).map((m) => ({
121
+ ...m,
122
122
  subUnitId: s,
123
- drawingId: J(6)
123
+ drawingId: H(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: E } = a;
127
+ const a = this._sheetDrawingService.getBatchAddOp(c), { unitId: u, subUnitId: v, undo: U, redo: S, objects: _ } = a;
128
128
  return {
129
129
  redos: [
130
130
  {
@@ -133,7 +133,7 @@ let I = class extends G {
133
133
  op: S,
134
134
  unitId: u,
135
135
  subUnitId: v,
136
- objects: E,
136
+ objects: _,
137
137
  type: h.INSERT
138
138
  }
139
139
  }
@@ -145,7 +145,7 @@ let I = class extends G {
145
145
  op: U,
146
146
  unitId: u,
147
147
  subUnitId: v,
148
- objects: E,
148
+ objects: _,
149
149
  type: h.REMOVE
150
150
  }
151
151
  }
@@ -158,49 +158,49 @@ let I = class extends G {
158
158
  );
159
159
  }
160
160
  };
161
- I = z([
162
- d(0, m(B)),
163
- d(1, m(C)),
164
- d(2, M),
165
- d(3, f),
161
+ p = z([
162
+ d(0, N(B)),
163
+ d(1, N(M)),
164
+ d(2, j),
165
+ d(3, E),
166
166
  d(4, O),
167
- d(5, j)
168
- ], I);
169
- const A = "sheets-drawing.config", N = {};
170
- var Q = Object.defineProperty, X = Object.getOwnPropertyDescriptor, Z = (e, r, t) => r in e ? Q(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, y = (e, r, t, i) => {
171
- for (var n = i > 1 ? void 0 : i ? X(r, t) : r, s = e.length - 1, o; s >= 0; s--)
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--)
172
172
  (o = e[s]) && (n = o(n) || n);
173
173
  return n;
174
- }, b = (e, r) => (t, i) => r(t, i, e), w = (e, r, t) => Z(e, typeof r != "symbol" ? r + "" : r, t);
175
- let p = class extends T {
176
- constructor(e = N, r, t) {
177
- super(), this._config = e, this._injector = r, this._configService = t;
178
- const { ...i } = W(
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 {
176
+ constructor(e = b, i, t) {
177
+ super(), this._config = e, this._injector = i, this._configService = t;
178
+ const { ...r } = F(
179
179
  {},
180
- N,
180
+ b,
181
181
  this._config
182
182
  );
183
- this._configService.setConfig(A, i);
183
+ this._configService.setConfig(Q, r);
184
184
  }
185
185
  onStarting() {
186
186
  [
187
- [I],
188
- [f, { useClass: k }]
189
- ].forEach((e) => this._injector.add(e)), this._injector.get(I);
187
+ [p],
188
+ [E, { useClass: k }]
189
+ ].forEach((e) => this._injector.add(e)), this._injector.get(p);
190
190
  }
191
191
  };
192
- w(p, "pluginName", D);
193
- w(p, "type", _.UNIVER_SHEET);
194
- p = y([
195
- V(x),
196
- b(1, m(H)),
197
- b(2, L)
198
- ], p);
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);
199
199
  export {
200
200
  h as DrawingApplyType,
201
- f as ISheetDrawingService,
202
- D as SHEET_DRAWING_PLUGIN,
201
+ E as ISheetDrawingService,
202
+ R as SHEET_DRAWING_PLUGIN,
203
203
  g as SetDrawingApplyMutation,
204
204
  Y as SheetDrawingAnchorType,
205
- p as UniverSheetsDrawingPlugin
205
+ f as UniverSheetsDrawingPlugin
206
206
  };
package/lib/index.js CHANGED
@@ -1,28 +1,28 @@
1
- import { createIdentifier as l, CommandType as P, Inject as m, IUniverInstanceService as C, ICommandService as M, IResourceManagerService as j, Disposable as G, UniverInstanceType as _, generateRandomId as J, DependentOn as V, Injector as H, IConfigService as L, Plugin as T, merge as W } from "@univerjs/core";
2
- import { UnitDrawingService as F, IDrawingManagerService as O, UniverDrawingPlugin as x } from "@univerjs/drawing";
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
3
  import { SheetInterceptorService as B, RemoveSheetCommand as $, 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 F {
5
+ class k extends x {
6
6
  }
7
- const f = l("sheets-drawing.sheet-drawing.service");
7
+ const E = P("sheets-drawing.sheet-drawing.service");
8
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
9
  const g = {
10
10
  id: "sheet.mutation.set-drawing-apply",
11
- type: P.MUTATION,
12
- handler: (e, r) => {
13
- const t = e.get(O), i = e.get(f), { op: n, unitId: s, subUnitId: o, type: c, objects: a } = r;
14
- switch (t.applyJson1(s, o, n), i.applyJson1(s, o, n), c) {
11
+ type: C.MUTATION,
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;
14
+ switch (t.applyJson1(s, o, n), r.applyJson1(s, o, n), c) {
15
15
  case 0:
16
- t.addNotification(a), i.addNotification(a);
16
+ t.addNotification(a), r.addNotification(a);
17
17
  break;
18
18
  case 1:
19
- t.removeNotification(a), i.removeNotification(a);
19
+ t.removeNotification(a), r.removeNotification(a);
20
20
  break;
21
21
  case 2:
22
- t.updateNotification(a), i.updateNotification(a);
22
+ t.updateNotification(a), r.updateNotification(a);
23
23
  break;
24
24
  case 3:
25
- t.orderNotification(a), i.orderNotification(a);
25
+ t.orderNotification(a), r.orderNotification(a);
26
26
  break;
27
27
  case 4:
28
28
  t.groupUpdateNotification(a);
@@ -34,21 +34,21 @@ const g = {
34
34
  return !0;
35
35
  }
36
36
  };
37
- var q = Object.getOwnPropertyDescriptor, z = (e, r, t, i) => {
38
- for (var n = i > 1 ? void 0 : i ? q(r, t) : r, s = e.length - 1, o; s >= 0; s--)
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--)
39
39
  (o = e[s]) && (n = o(n) || n);
40
40
  return n;
41
- }, d = (e, r) => (t, i) => r(t, i, e);
42
- const D = "SHEET_DRAWING_PLUGIN";
43
- let I = class extends G {
44
- constructor(e, r, t, i, n, s) {
45
- super(), this._sheetInterceptorService = e, this._univerInstanceService = r, this._commandService = t, this._sheetDrawingService = i, this._drawingManagerService = n, this._resourceManagerService = s, this._initSnapshot(), this._initSheetChange(), this.disposeWithMe(this._commandService.registerCommand(g));
41
+ }, d = (e, i) => (t, r) => i(t, r, e);
42
+ const R = "SHEET_DRAWING_PLUGIN";
43
+ let p = class extends T {
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));
46
46
  }
47
47
  _initSnapshot() {
48
- const e = (t, i) => {
49
- const n = i || this._sheetDrawingService.getDrawingDataForUnit(t);
48
+ const e = (t, r) => {
49
+ const n = r || this._sheetDrawingService.getDrawingDataForUnit(t);
50
50
  return n ? JSON.stringify(n) : "";
51
- }, r = (t) => {
51
+ }, i = (t) => {
52
52
  if (!t)
53
53
  return {};
54
54
  try {
@@ -59,15 +59,15 @@ let I = class extends G {
59
59
  };
60
60
  this.disposeWithMe(
61
61
  this._resourceManagerService.registerPluginResource({
62
- pluginName: D,
63
- businesses: [_.UNIVER_SHEET],
64
- toJson: (t, i) => e(t, i),
65
- parseJson: (t) => r(t),
62
+ pluginName: R,
63
+ businesses: [I.UNIVER_SHEET],
64
+ toJson: (t, r) => e(t, r),
65
+ parseJson: (t) => i(t),
66
66
  onUnLoad: (t) => {
67
67
  this._sheetDrawingService.removeDrawingDataForUnit(t), this._drawingManagerService.removeDrawingDataForUnit(t);
68
68
  },
69
- onLoad: (t, i) => {
70
- this._sheetDrawingService.registerDrawingData(t, i), this._drawingManagerService.registerDrawingData(t, i);
69
+ onLoad: (t, r) => {
70
+ this._sheetDrawingService.registerDrawingData(t, r), this._drawingManagerService.registerDrawingData(t, r);
71
71
  }
72
72
  })
73
73
  );
@@ -78,12 +78,12 @@ let I = class extends G {
78
78
  this._sheetInterceptorService.interceptCommand({
79
79
  // eslint-disable-next-line max-lines-per-function
80
80
  getMutations: (e) => {
81
- var r;
81
+ var i;
82
82
  if (e.id === $.id) {
83
- const t = e.params, i = t.unitId || this._univerInstanceService.getCurrentUnitOfType(_.UNIVER_SHEET).getUnitId(), n = t.subUnitId || ((r = this._univerInstanceService.getCurrentUnitOfType(_.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : r.getSheetId());
84
- if (!i || !n)
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());
84
+ if (!r || !n)
85
85
  return { redos: [], undos: [] };
86
- const s = this._sheetDrawingService.getDrawingData(i, n), o = Object.values(s);
86
+ const s = this._sheetDrawingService.getDrawingData(r, n), o = Object.values(s).filter((_) => _.drawingType !== D.DRAWING_CHART);
87
87
  if (o.length === 0)
88
88
  return { redos: [], undos: [] };
89
89
  const c = this._sheetDrawingService.getBatchRemoveOp(o), { unitId: a, subUnitId: u, undo: v, redo: U, objects: S } = c;
@@ -114,17 +114,17 @@ let I = class extends G {
114
114
  ]
115
115
  };
116
116
  } else if (e.id === K.id) {
117
- const t = e.params, { unitId: i, subUnitId: n, targetSubUnitId: s } = t;
118
- if (!i || !n || !s)
117
+ const t = e.params, { unitId: r, subUnitId: n, targetSubUnitId: s } = t;
118
+ if (!r || !n || !s)
119
119
  return { redos: [], undos: [] };
120
- const o = this._sheetDrawingService.getDrawingData(i, n), c = Object.values(o).map((R) => ({
121
- ...R,
120
+ const o = this._sheetDrawingService.getDrawingData(r, n), c = Object.values(o).filter((m) => m.drawingType !== D.DRAWING_CHART).map((m) => ({
121
+ ...m,
122
122
  subUnitId: s,
123
- drawingId: J(6)
123
+ drawingId: H(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: E } = a;
127
+ const a = this._sheetDrawingService.getBatchAddOp(c), { unitId: u, subUnitId: v, undo: U, redo: S, objects: _ } = a;
128
128
  return {
129
129
  redos: [
130
130
  {
@@ -133,7 +133,7 @@ let I = class extends G {
133
133
  op: S,
134
134
  unitId: u,
135
135
  subUnitId: v,
136
- objects: E,
136
+ objects: _,
137
137
  type: h.INSERT
138
138
  }
139
139
  }
@@ -145,7 +145,7 @@ let I = class extends G {
145
145
  op: U,
146
146
  unitId: u,
147
147
  subUnitId: v,
148
- objects: E,
148
+ objects: _,
149
149
  type: h.REMOVE
150
150
  }
151
151
  }
@@ -158,49 +158,49 @@ let I = class extends G {
158
158
  );
159
159
  }
160
160
  };
161
- I = z([
162
- d(0, m(B)),
163
- d(1, m(C)),
164
- d(2, M),
165
- d(3, f),
161
+ p = z([
162
+ d(0, N(B)),
163
+ d(1, N(M)),
164
+ d(2, j),
165
+ d(3, E),
166
166
  d(4, O),
167
- d(5, j)
168
- ], I);
169
- const A = "sheets-drawing.config", N = {};
170
- var Q = Object.defineProperty, X = Object.getOwnPropertyDescriptor, Z = (e, r, t) => r in e ? Q(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, y = (e, r, t, i) => {
171
- for (var n = i > 1 ? void 0 : i ? X(r, t) : r, s = e.length - 1, o; s >= 0; s--)
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--)
172
172
  (o = e[s]) && (n = o(n) || n);
173
173
  return n;
174
- }, b = (e, r) => (t, i) => r(t, i, e), w = (e, r, t) => Z(e, typeof r != "symbol" ? r + "" : r, t);
175
- let p = class extends T {
176
- constructor(e = N, r, t) {
177
- super(), this._config = e, this._injector = r, this._configService = t;
178
- const { ...i } = W(
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 {
176
+ constructor(e = b, i, t) {
177
+ super(), this._config = e, this._injector = i, this._configService = t;
178
+ const { ...r } = F(
179
179
  {},
180
- N,
180
+ b,
181
181
  this._config
182
182
  );
183
- this._configService.setConfig(A, i);
183
+ this._configService.setConfig(Q, r);
184
184
  }
185
185
  onStarting() {
186
186
  [
187
- [I],
188
- [f, { useClass: k }]
189
- ].forEach((e) => this._injector.add(e)), this._injector.get(I);
187
+ [p],
188
+ [E, { useClass: k }]
189
+ ].forEach((e) => this._injector.add(e)), this._injector.get(p);
190
190
  }
191
191
  };
192
- w(p, "pluginName", D);
193
- w(p, "type", _.UNIVER_SHEET);
194
- p = y([
195
- V(x),
196
- b(1, m(H)),
197
- b(2, L)
198
- ], p);
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);
199
199
  export {
200
200
  h as DrawingApplyType,
201
- f as ISheetDrawingService,
202
- D as SHEET_DRAWING_PLUGIN,
201
+ E as ISheetDrawingService,
202
+ R as SHEET_DRAWING_PLUGIN,
203
203
  g as SetDrawingApplyMutation,
204
204
  Y as SheetDrawingAnchorType,
205
- p as UniverSheetsDrawingPlugin
205
+ f as UniverSheetsDrawingPlugin
206
206
  };
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(a,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/sheets")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing","@univerjs/sheets"],s):(a=typeof globalThis<"u"?globalThis:a||self,s(a.UniverSheetsDrawing={},a.UniverCore,a.UniverDrawing,a.UniverSheets))})(this,(function(a,s,I,D){"use strict";var E=(e=>(e.Position="0",e.Both="1",e.None="2",e))(E||{});class P extends I.UnitDrawingService{}const _=s.createIdentifier("sheets-drawing.sheet-drawing.service");var u=(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))(u||{});const g={id:"sheet.mutation.set-drawing-apply",type:s.CommandType.MUTATION,handler:(e,n)=>{const t=e.get(I.IDrawingManagerService),i=e.get(_),{op:r,unitId:o,subUnitId:c,type:h,objects:d}=n;switch(t.applyJson1(o,c,r),i.applyJson1(o,c,r),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 R=Object.getOwnPropertyDescriptor,j=(e,n,t,i)=>{for(var r=i>1?void 0:i?R(n,t):n,o=e.length-1,c;o>=0;o--)(c=e[o])&&(r=c(r)||r);return r},v=(e,n)=>(t,i)=>n(t,i,e);const w="SHEET_DRAWING_PLUGIN";let U=class extends s.Disposable{constructor(e,n,t,i,r,o){super(),this._sheetInterceptorService=e,this._univerInstanceService=n,this._commandService=t,this._sheetDrawingService=i,this._drawingManagerService=r,this._resourceManagerService=o,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(g))}_initSnapshot(){const e=(t,i)=>{const r=i||this._sheetDrawingService.getDrawingDataForUnit(t);return r?JSON.stringify(r):""},n=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:w,businesses:[s.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===D.RemoveSheetCommand.id){const t=e.params,i=t.unitId||this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),r=t.subUnitId||((n=this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId());if(!i||!r)return{redos:[],undos:[]};const o=this._sheetDrawingService.getDrawingData(i,r),c=Object.values(o);if(c.length===0)return{redos:[],undos:[]};const h=this._sheetDrawingService.getBatchRemoveOp(c),{unitId:d,subUnitId:S,undo:f,redo:m,objects:p}=h;return{redos:[{id:g.id,params:{op:m,unitId:d,subUnitId:S,objects:p,type:u.REMOVE}}],undos:[{id:g.id,params:{op:f,unitId:d,subUnitId:S,objects:p,type:u.INSERT}}]}}else if(e.id===D.CopySheetCommand.id){const t=e.params,{unitId:i,subUnitId:r,targetSubUnitId:o}=t;if(!i||!r||!o)return{redos:[],undos:[]};const c=this._sheetDrawingService.getDrawingData(i,r),h=Object.values(c).map(J=>({...J,subUnitId:o,drawingId:s.generateRandomId(6)}));if(h.length===0)return{redos:[],undos:[]};const d=this._sheetDrawingService.getBatchAddOp(h),{unitId:S,subUnitId:f,undo:m,redo:p,objects:l}=d;return{redos:[{id:g.id,params:{op:p,unitId:S,subUnitId:f,objects:l,type:u.INSERT}}],undos:[{id:g.id,params:{op:m,unitId:S,subUnitId:f,objects:l,type:u.REMOVE}}]}}return{redos:[],undos:[]}}}))}};U=j([v(0,s.Inject(D.SheetInterceptorService)),v(1,s.Inject(s.IUniverInstanceService)),v(2,s.ICommandService),v(3,_),v(4,I.IDrawingManagerService),v(5,s.IResourceManagerService)],U);const M="sheets-drawing.config",N={};var C=Object.defineProperty,G=Object.getOwnPropertyDescriptor,T=(e,n,t)=>n in e?C(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,H=(e,n,t,i)=>{for(var r=i>1?void 0:i?G(n,t):n,o=e.length-1,c;o>=0;o--)(c=e[o])&&(r=c(r)||r);return r},b=(e,n)=>(t,i)=>n(t,i,e),O=(e,n,t)=>T(e,typeof n!="symbol"?n+"":n,t);a.UniverSheetsDrawingPlugin=class extends s.Plugin{constructor(n=N,t,i){super(),this._config=n,this._injector=t,this._configService=i;const{...r}=s.merge({},N,this._config);this._configService.setConfig(M,r)}onStarting(){[[U],[_,{useClass:P}]].forEach(n=>this._injector.add(n)),this._injector.get(U)}},O(a.UniverSheetsDrawingPlugin,"pluginName",w),O(a.UniverSheetsDrawingPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),a.UniverSheetsDrawingPlugin=H([s.DependentOn(I.UniverDrawingPlugin),b(1,s.Inject(s.Injector)),b(2,s.IConfigService)],a.UniverSheetsDrawingPlugin),a.DrawingApplyType=u,a.ISheetDrawingService=_,a.SHEET_DRAWING_PLUGIN=w,a.SetDrawingApplyMutation=g,a.SheetDrawingAnchorType=E,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,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"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-drawing",
3
- "version": "0.10.14-nightly.202511031023",
3
+ "version": "0.10.14-nightly.202511070640",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -43,9 +43,9 @@
43
43
  "lib"
44
44
  ],
45
45
  "dependencies": {
46
- "@univerjs/core": "0.10.14-nightly.202511031023",
47
- "@univerjs/sheets": "0.10.14-nightly.202511031023",
48
- "@univerjs/drawing": "0.10.14-nightly.202511031023"
46
+ "@univerjs/core": "0.10.14-nightly.202511070640",
47
+ "@univerjs/drawing": "0.10.14-nightly.202511070640",
48
+ "@univerjs/sheets": "0.10.14-nightly.202511070640"
49
49
  },
50
50
  "devDependencies": {
51
51
  "typescript": "^5.9.3",