@univerjs/sheets-drawing 0.1.17 → 0.2.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";var m=Object.defineProperty;var E=(e,t,r)=>t in e?m(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var d=(e,t,r)=>E(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),_=require("@wendellhu/redi"),f=require("@univerjs/drawing");var l=(e=>(e.Position="0",e.Both="1",e.None="2",e))(l||{});class I extends f.UnitDrawingService{}const h=_.createIdentifier("sheets-drawing.sheet-drawing.service");var D=(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))(D||{});const N={id:"sheet.mutation.set-drawing-apply",type:a.CommandType.MUTATION,handler:(e,t)=>{const r=e.get(f.IDrawingManagerService),i=e.get(h),{op:n,unitId:s,subUnitId:o,type:P,objects:c}=t;switch(r.applyJson1(s,o,n),i.applyJson1(s,o,n),P){case 0:r.addNotification(c),i.addNotification(c);break;case 1:r.removeNotification(c),i.removeNotification(c);break;case 2:r.updateNotification(c),i.updateNotification(c);break;case 3:r.orderNotification(c),i.orderNotification(c);break;case 4:r.groupUpdateNotification(c);break;case 5:r.ungroupUpdateNotification(c);break}return!0}};var O=Object.defineProperty,R=Object.getOwnPropertyDescriptor,U=(e,t,r,i)=>{for(var n=i>1?void 0:i?R(t,r):t,s=e.length-1,o;s>=0;s--)(o=e[s])&&(n=(i?o(t,r,n):o(n))||n);return i&&n&&O(t,r,n),n},v=(e,t)=>(r,i)=>t(r,i,e);const w="SHEET_DRAWING_PLUGIN";let S=class extends a.Disposable{constructor(e){super(),this._commandService=e,this.disposeWithMe(this._commandService.registerCommand(N))}};S=U([a.OnLifecycle(a.LifecycleStages.Starting,S),v(0,a.ICommandService)],S);let u=class extends a.Disposable{constructor(e,t,r){super(),this._sheetDrawingService=e,this._drawingManagerService=t,this._resourceManagerService=r,this._init()}_init(){this._initSnapshot()}_initSnapshot(){const e=r=>{const i=this._sheetDrawingService.getDrawingDataForUnit(r);return i?JSON.stringify(i):""},t=r=>{if(!r)return{};try{return JSON.parse(r)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:w,businesses:[a.UniverInstanceType.UNIVER_SHEET],toJson:r=>e(r),parseJson:r=>t(r),onUnLoad:r=>{this._sheetDrawingService.removeDrawingDataForUnit(r),this._drawingManagerService.removeDrawingDataForUnit(r)},onLoad:(r,i)=>{this._sheetDrawingService.registerDrawingData(r,i),this._drawingManagerService.registerDrawingData(r,i)}}))}};u=U([a.OnLifecycle(a.LifecycleStages.Ready,u),v(0,h),v(1,f.IDrawingManagerService),v(2,a.IResourceManagerService)],u);var p=Object.defineProperty,b=Object.getOwnPropertyDescriptor,M=(e,t,r,i)=>{for(var n=i>1?void 0:i?b(t,r):t,s=e.length-1,o;s>=0;s--)(o=e[s])&&(n=(i?o(t,r,n):o(n))||n);return i&&n&&p(t,r,n),n},G=(e,t)=>(r,i)=>t(r,i,e),g;exports.UniverSheetsDrawingPlugin=(g=class extends a.Plugin{constructor(t,r){super(),this._config=t,this._injector=r}onStarting(t){[[S],[u],[h,{useClass:I}]].forEach(r=>t.add(r))}},d(g,"pluginName",w),d(g,"type",a.UniverInstanceType.UNIVER_SHEET),g);exports.UniverSheetsDrawingPlugin=M([G(1,_.Inject(_.Injector))],exports.UniverSheetsDrawingPlugin);exports.DrawingApplyType=D;exports.ISheetDrawingService=h;exports.SetDrawingApplyMutation=N;exports.SheetDrawingAnchorType=l;
1
+ "use strict";var P=Object.defineProperty;var E=(e,t,i)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var d=(e,t,i)=>E(e,typeof t!="symbol"?t+"":t,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),h=require("@wendellhu/redi"),l=require("@univerjs/drawing");var f=(e=>(e.Position="0",e.Both="1",e.None="2",e))(f||{});class m extends l.UnitDrawingService{}const _=h.createIdentifier("sheets-drawing.sheet-drawing.service");var I=(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))(I||{});const U={id:"sheet.mutation.set-drawing-apply",type:a.CommandType.MUTATION,handler:(e,t)=>{const i=e.get(l.IDrawingManagerService),r=e.get(_),{op:n,unitId:s,subUnitId:c,type:D,objects:o}=t;switch(i.applyJson1(s,c,n),r.applyJson1(s,c,n),D){case 0:i.addNotification(o),r.addNotification(o);break;case 1:i.removeNotification(o),r.removeNotification(o);break;case 2:i.updateNotification(o),r.updateNotification(o);break;case 3:i.orderNotification(o),r.orderNotification(o);break;case 4:i.groupUpdateNotification(o);break;case 5:i.ungroupUpdateNotification(o);break}return!0}};var p=Object.defineProperty,O=Object.getOwnPropertyDescriptor,N=(e,t,i,r)=>{for(var n=r>1?void 0:r?O(t,i):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(n=(r?c(t,i,n):c(n))||n);return r&&n&&p(t,i,n),n},v=(e,t)=>(i,r)=>t(i,r,e);const w="SHEET_DRAWING_PLUGIN";let S=class extends a.Disposable{constructor(e){super(),this._commandService=e,this.disposeWithMe(this._commandService.registerCommand(U))}};S=N([a.OnLifecycle(a.LifecycleStages.Starting,S),v(0,a.ICommandService)],S);let u=class extends a.Disposable{constructor(e,t,i,r,n){super(),this._sheetDrawingService=e,this._drawingManagerService=t,this._resourceManagerService=i,this._lifecycleService=r,this._univerInstanceService=n,this._init()}_init(){this._initSnapshot(),this._drawingInitializeListener()}_initSnapshot(){const e=i=>{const r=this._sheetDrawingService.getDrawingDataForUnit(i);return r?JSON.stringify(r):""},t=i=>{if(!i)return{};try{return JSON.parse(i)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:w,businesses:[a.UniverInstanceType.UNIVER_SHEET],toJson:i=>e(i),parseJson:i=>t(i),onUnLoad:i=>{this._sheetDrawingService.removeDrawingDataForUnit(i),this._drawingManagerService.removeDrawingDataForUnit(i)},onLoad:(i,r)=>{this._sheetDrawingService.registerDrawingData(i,r)}}))}_drawingInitializeListener(){this.disposeWithMe(this._lifecycleService.lifecycle$.subscribe(e=>{var t;if(e===a.LifecycleStages.Steady){const i=(t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:t.getUnitId();if(!i)return;this._sheetDrawingService.initializeNotification(i)}}))}};u=N([a.OnLifecycle(a.LifecycleStages.Ready,u),v(0,_),v(1,l.IDrawingManagerService),v(2,a.IResourceManagerService),v(3,h.Inject(a.LifecycleService)),v(4,a.IUniverInstanceService)],u);var R=Object.defineProperty,b=Object.getOwnPropertyDescriptor,M=(e,t,i,r)=>{for(var n=r>1?void 0:r?b(t,i):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(n=(r?c(t,i,n):c(n))||n);return r&&n&&R(t,i,n),n},L=(e,t)=>(i,r)=>t(i,r,e),g;exports.UniverSheetsDrawingPlugin=(g=class extends a.Plugin{constructor(t,i){super(),this._config=t,this._injector=i}onStarting(t){[[S],[u],[_,{useClass:m}]].forEach(i=>t.add(i))}},d(g,"pluginName",w),d(g,"type",a.UniverInstanceType.UNIVER_SHEET),g);exports.UniverSheetsDrawingPlugin=M([L(1,h.Inject(h.Injector))],exports.UniverSheetsDrawingPlugin);exports.DrawingApplyType=I;exports.ISheetDrawingService=_;exports.SetDrawingApplyMutation=U;exports.SheetDrawingAnchorType=f;
package/lib/es/index.js CHANGED
@@ -1,31 +1,31 @@
1
- var D = Object.defineProperty;
2
- var R = (e, r, t) => r in e ? D(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
3
- var h = (e, r, t) => R(e, typeof r != "symbol" ? r + "" : r, t);
4
- import { CommandType as O, OnLifecycle as d, LifecycleStages as f, Disposable as N, ICommandService as w, UniverInstanceType as m, IResourceManagerService as I, Plugin as b } from "@univerjs/core";
5
- import { createIdentifier as M, Inject as p, Injector as G } from "@wendellhu/redi";
6
- import { UnitDrawingService as C, IDrawingManagerService as U } from "@univerjs/drawing";
7
- var J = /* @__PURE__ */ ((e) => (e.Position = "0", e.Both = "1", e.None = "2", e))(J || {});
8
- class j extends C {
1
+ var R = Object.defineProperty;
2
+ var w = (e, i, t) => i in e ? R(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t;
3
+ var u = (e, i, t) => w(e, typeof i != "symbol" ? i + "" : i, t);
4
+ import { CommandType as D, OnLifecycle as l, LifecycleStages as d, LifecycleService as O, Disposable as N, ICommandService as b, UniverInstanceType as S, IResourceManagerService as p, IUniverInstanceService as M, Plugin as G } from "@univerjs/core";
5
+ import { createIdentifier as L, Inject as I, Injector as C } from "@wendellhu/redi";
6
+ import { UnitDrawingService as J, IDrawingManagerService as U } from "@univerjs/drawing";
7
+ var j = /* @__PURE__ */ ((e) => (e.Position = "0", e.Both = "1", e.None = "2", e))(j || {});
8
+ class x extends J {
9
9
  }
10
- const u = M("sheets-drawing.sheet-drawing.service");
11
- var L = /* @__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))(L || {});
12
- const x = {
10
+ const g = L("sheets-drawing.sheet-drawing.service");
11
+ 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 || {});
12
+ const V = {
13
13
  id: "sheet.mutation.set-drawing-apply",
14
- type: O.MUTATION,
15
- handler: (e, r) => {
16
- const t = e.get(U), i = e.get(u), { op: a, unitId: s, subUnitId: n, type: l, objects: o } = r;
17
- switch (t.applyJson1(s, n, a), i.applyJson1(s, n, a), l) {
14
+ type: D.MUTATION,
15
+ handler: (e, i) => {
16
+ const t = e.get(U), r = e.get(g), { op: n, unitId: s, subUnitId: a, type: P, objects: o } = i;
17
+ switch (t.applyJson1(s, a, n), r.applyJson1(s, a, n), P) {
18
18
  case 0:
19
- t.addNotification(o), i.addNotification(o);
19
+ t.addNotification(o), r.addNotification(o);
20
20
  break;
21
21
  case 1:
22
- t.removeNotification(o), i.removeNotification(o);
22
+ t.removeNotification(o), r.removeNotification(o);
23
23
  break;
24
24
  case 2:
25
- t.updateNotification(o), i.updateNotification(o);
25
+ t.updateNotification(o), r.updateNotification(o);
26
26
  break;
27
27
  case 3:
28
- t.orderNotification(o), i.orderNotification(o);
28
+ t.orderNotification(o), r.orderNotification(o);
29
29
  break;
30
30
  case 4:
31
31
  t.groupUpdateNotification(o);
@@ -37,33 +37,33 @@ const x = {
37
37
  return !0;
38
38
  }
39
39
  };
40
- var H = Object.defineProperty, V = Object.getOwnPropertyDescriptor, P = (e, r, t, i) => {
41
- for (var a = i > 1 ? void 0 : i ? V(r, t) : r, s = e.length - 1, n; s >= 0; s--)
42
- (n = e[s]) && (a = (i ? n(r, t, a) : n(a)) || a);
43
- return i && a && H(r, t, a), a;
44
- }, v = (e, r) => (t, i) => r(t, i, e);
40
+ var W = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, m = (e, i, t, r) => {
41
+ for (var n = r > 1 ? void 0 : r ? $(i, t) : i, s = e.length - 1, a; s >= 0; s--)
42
+ (a = e[s]) && (n = (r ? a(i, t, n) : a(n)) || n);
43
+ return r && n && W(i, t, n), n;
44
+ }, c = (e, i) => (t, r) => i(t, r, e);
45
45
  const E = "SHEET_DRAWING_PLUGIN";
46
- let g = class extends N {
46
+ let _ = class extends N {
47
47
  constructor(e) {
48
- super(), this._commandService = e, this.disposeWithMe(this._commandService.registerCommand(x));
48
+ super(), this._commandService = e, this.disposeWithMe(this._commandService.registerCommand(V));
49
49
  }
50
50
  };
51
- g = P([
52
- d(f.Starting, g),
53
- v(0, w)
54
- ], g);
55
- let _ = class extends N {
56
- constructor(e, r, t) {
57
- super(), this._sheetDrawingService = e, this._drawingManagerService = r, this._resourceManagerService = t, this._init();
51
+ _ = m([
52
+ l(d.Starting, _),
53
+ c(0, b)
54
+ ], _);
55
+ let h = class extends N {
56
+ constructor(e, i, t, r, n) {
57
+ super(), this._sheetDrawingService = e, this._drawingManagerService = i, this._resourceManagerService = t, this._lifecycleService = r, this._univerInstanceService = n, this._init();
58
58
  }
59
59
  _init() {
60
- this._initSnapshot();
60
+ this._initSnapshot(), this._drawingInitializeListener();
61
61
  }
62
62
  _initSnapshot() {
63
63
  const e = (t) => {
64
- const i = this._sheetDrawingService.getDrawingDataForUnit(t);
65
- return i ? JSON.stringify(i) : "";
66
- }, r = (t) => {
64
+ const r = this._sheetDrawingService.getDrawingDataForUnit(t);
65
+ return r ? JSON.stringify(r) : "";
66
+ }, i = (t) => {
67
67
  if (!t)
68
68
  return {};
69
69
  try {
@@ -75,49 +75,64 @@ let _ = class extends N {
75
75
  this.disposeWithMe(
76
76
  this._resourceManagerService.registerPluginResource({
77
77
  pluginName: E,
78
- businesses: [m.UNIVER_SHEET],
78
+ businesses: [S.UNIVER_SHEET],
79
79
  toJson: (t) => e(t),
80
- parseJson: (t) => r(t),
80
+ parseJson: (t) => i(t),
81
81
  onUnLoad: (t) => {
82
82
  this._sheetDrawingService.removeDrawingDataForUnit(t), this._drawingManagerService.removeDrawingDataForUnit(t);
83
83
  },
84
- onLoad: (t, i) => {
85
- this._sheetDrawingService.registerDrawingData(t, i), this._drawingManagerService.registerDrawingData(t, i);
84
+ onLoad: (t, r) => {
85
+ this._sheetDrawingService.registerDrawingData(t, r);
86
+ }
87
+ })
88
+ );
89
+ }
90
+ _drawingInitializeListener() {
91
+ this.disposeWithMe(
92
+ this._lifecycleService.lifecycle$.subscribe((e) => {
93
+ var i;
94
+ if (e === d.Steady) {
95
+ const t = (i = this._univerInstanceService.getCurrentUnitForType(S.UNIVER_SHEET)) == null ? void 0 : i.getUnitId();
96
+ if (!t)
97
+ return;
98
+ this._sheetDrawingService.initializeNotification(t);
86
99
  }
87
100
  })
88
101
  );
89
102
  }
90
103
  };
91
- _ = P([
92
- d(f.Ready, _),
93
- v(0, u),
94
- v(1, U),
95
- v(2, I)
96
- ], _);
97
- var W = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, F = (e, r, t, i) => {
98
- for (var a = i > 1 ? void 0 : i ? $(r, t) : r, s = e.length - 1, n; s >= 0; s--)
99
- (n = e[s]) && (a = (i ? n(r, t, a) : n(a)) || a);
100
- return i && a && W(r, t, a), a;
101
- }, B = (e, r) => (t, i) => r(t, i, e), c;
102
- let S = (c = class extends b {
103
- constructor(e, r) {
104
- super(), this._config = e, this._injector = r;
104
+ h = m([
105
+ l(d.Ready, h),
106
+ c(0, g),
107
+ c(1, U),
108
+ c(2, p),
109
+ c(3, I(O)),
110
+ c(4, M)
111
+ ], h);
112
+ var F = Object.defineProperty, z = Object.getOwnPropertyDescriptor, B = (e, i, t, r) => {
113
+ for (var n = r > 1 ? void 0 : r ? z(i, t) : i, s = e.length - 1, a; s >= 0; s--)
114
+ (a = e[s]) && (n = (r ? a(i, t, n) : a(n)) || n);
115
+ return r && n && F(i, t, n), n;
116
+ }, T = (e, i) => (t, r) => i(t, r, e), v;
117
+ let f = (v = class extends G {
118
+ constructor(e, i) {
119
+ super(), this._config = e, this._injector = i;
105
120
  }
106
121
  onStarting(e) {
107
122
  [
108
- [g],
109
123
  [_],
110
- [u, { useClass: j }]
111
- ].forEach((r) => e.add(r));
124
+ [h],
125
+ [g, { useClass: x }]
126
+ ].forEach((i) => e.add(i));
112
127
  }
113
- }, h(c, "pluginName", E), h(c, "type", m.UNIVER_SHEET), c);
114
- S = F([
115
- B(1, p(G))
116
- ], S);
128
+ }, u(v, "pluginName", E), u(v, "type", S.UNIVER_SHEET), v);
129
+ f = B([
130
+ T(1, I(C))
131
+ ], f);
117
132
  export {
118
- L as DrawingApplyType,
119
- u as ISheetDrawingService,
120
- x as SetDrawingApplyMutation,
121
- J as SheetDrawingAnchorType,
122
- S as UniverSheetsDrawingPlugin
133
+ H as DrawingApplyType,
134
+ g as ISheetDrawingService,
135
+ V as SetDrawingApplyMutation,
136
+ j as SheetDrawingAnchorType,
137
+ f as UniverSheetsDrawingPlugin
123
138
  };
@@ -1,4 +1,4 @@
1
- import { Disposable, ICommandService, IResourceManagerService } from '@univerjs/core';
1
+ import { Disposable, ICommandService, IResourceManagerService, IUniverInstanceService, LifecycleService } from '@univerjs/core';
2
2
  import { IDrawingManagerService } from '@univerjs/drawing';
3
3
  import { ISheetDrawingService } from '../services/sheet-drawing.service';
4
4
 
@@ -11,7 +11,10 @@ export declare class SheetsDrawingController extends Disposable {
11
11
  private readonly _sheetDrawingService;
12
12
  private readonly _drawingManagerService;
13
13
  private _resourceManagerService;
14
- constructor(_sheetDrawingService: ISheetDrawingService, _drawingManagerService: IDrawingManagerService, _resourceManagerService: IResourceManagerService);
14
+ private _lifecycleService;
15
+ private _univerInstanceService;
16
+ constructor(_sheetDrawingService: ISheetDrawingService, _drawingManagerService: IDrawingManagerService, _resourceManagerService: IResourceManagerService, _lifecycleService: LifecycleService, _univerInstanceService: IUniverInstanceService);
15
17
  private _init;
16
18
  private _initSnapshot;
19
+ private _drawingInitializeListener;
17
20
  }
@@ -14,6 +14,6 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export { UniverSheetsDrawingPlugin } from './plugin';
17
- export { DrawingApplyType, SetDrawingApplyMutation, type ISetDrawingApplyMutationParams } from './commands/mutations/set-drawing-apply.mutation';
18
17
  export { ISheetDrawingService, SheetDrawingAnchorType } from './services/sheet-drawing.service';
19
18
  export type { IFloatDomData, ISheetDrawing, ISheetDrawingPosition, ISheetFloatDom } from './services/sheet-drawing.service';
19
+ export { SetDrawingApplyMutation, DrawingApplyType, type ISetDrawingApplyMutationParams } from './commands/mutations/set-drawing-apply.mutation';
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(a,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/drawing")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/drawing"],r):(a=typeof globalThis<"u"?globalThis:a||self,r(a.UniverSheetsDrawing={},a.UniverCore,a["@wendellhu/redi"],a.UniverDrawing))})(this,function(a,r,v,_){"use strict";var j=Object.defineProperty;var G=(a,r,v)=>r in a?j(a,r,{enumerable:!0,configurable:!0,writable:!0,value:v}):a[r]=v;var l=(a,r,v)=>G(a,typeof r!="symbol"?r+"":r,v);var f;var w=(i=>(i.Position="0",i.Both="1",i.None="2",i))(w||{});class m extends _.UnitDrawingService{}const g=v.createIdentifier("sheets-drawing.sheet-drawing.service");var D=(i=>(i[i.INSERT=0]="INSERT",i[i.REMOVE=1]="REMOVE",i[i.UPDATE=2]="UPDATE",i[i.ARRANGE=3]="ARRANGE",i[i.GROUP=4]="GROUP",i[i.UNGROUP=5]="UNGROUP",i))(D||{});const U={id:"sheet.mutation.set-drawing-apply",type:r.CommandType.MUTATION,handler:(i,n)=>{const e=i.get(_.IDrawingManagerService),t=i.get(g),{op:s,unitId:o,subUnitId:c,type:b,objects:u}=n;switch(e.applyJson1(o,c,s),t.applyJson1(o,c,s),b){case 0:e.addNotification(u),t.addNotification(u);break;case 1:e.removeNotification(u),t.removeNotification(u);break;case 2:e.updateNotification(u),t.updateNotification(u);break;case 3:e.orderNotification(u),t.orderNotification(u);break;case 4:e.groupUpdateNotification(u);break;case 5:e.ungroupUpdateNotification(u);break}return!0}};var E=Object.defineProperty,I=Object.getOwnPropertyDescriptor,N=(i,n,e,t)=>{for(var s=t>1?void 0:t?I(n,e):n,o=i.length-1,c;o>=0;o--)(c=i[o])&&(s=(t?c(n,e,s):c(s))||s);return t&&s&&E(n,e,s),s},d=(i,n)=>(e,t)=>n(e,t,i);const P="SHEET_DRAWING_PLUGIN";let h=class extends r.Disposable{constructor(i){super(),this._commandService=i,this.disposeWithMe(this._commandService.registerCommand(U))}};h=N([r.OnLifecycle(r.LifecycleStages.Starting,h),d(0,r.ICommandService)],h);let S=class extends r.Disposable{constructor(i,n,e){super(),this._sheetDrawingService=i,this._drawingManagerService=n,this._resourceManagerService=e,this._init()}_init(){this._initSnapshot()}_initSnapshot(){const i=e=>{const t=this._sheetDrawingService.getDrawingDataForUnit(e);return t?JSON.stringify(t):""},n=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:P,businesses:[r.UniverInstanceType.UNIVER_SHEET],toJson:e=>i(e),parseJson:e=>n(e),onUnLoad:e=>{this._sheetDrawingService.removeDrawingDataForUnit(e),this._drawingManagerService.removeDrawingDataForUnit(e)},onLoad:(e,t)=>{this._sheetDrawingService.registerDrawingData(e,t),this._drawingManagerService.registerDrawingData(e,t)}}))}};S=N([r.OnLifecycle(r.LifecycleStages.Ready,S),d(0,g),d(1,_.IDrawingManagerService),d(2,r.IResourceManagerService)],S);var O=Object.defineProperty,R=Object.getOwnPropertyDescriptor,p=(i,n,e,t)=>{for(var s=t>1?void 0:t?R(n,e):n,o=i.length-1,c;o>=0;o--)(c=i[o])&&(s=(t?c(n,e,s):c(s))||s);return t&&s&&O(n,e,s),s},M=(i,n)=>(e,t)=>n(e,t,i);a.UniverSheetsDrawingPlugin=(f=class extends r.Plugin{constructor(n,e){super(),this._config=n,this._injector=e}onStarting(n){[[h],[S],[g,{useClass:m}]].forEach(e=>n.add(e))}},l(f,"pluginName",P),l(f,"type",r.UniverInstanceType.UNIVER_SHEET),f),a.UniverSheetsDrawingPlugin=p([M(1,v.Inject(v.Injector))],a.UniverSheetsDrawingPlugin),a.DrawingApplyType=D,a.ISheetDrawingService=g,a.SetDrawingApplyMutation=U,a.SheetDrawingAnchorType=w,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
1
+ (function(s,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/drawing")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/drawing"],t):(s=typeof globalThis<"u"?globalThis:s||self,t(s.UniverSheetsDrawing={},s.UniverCore,s["@wendellhu/redi"],s.UniverDrawing))})(this,function(s,t,v,_){"use strict";var j=Object.defineProperty;var L=(s,t,v)=>t in s?j(s,t,{enumerable:!0,configurable:!0,writable:!0,value:v}):s[t]=v;var l=(s,t,v)=>L(s,typeof t!="symbol"?t+"":t,v);var f;var U=(i=>(i.Position="0",i.Both="1",i.None="2",i))(U||{});class P extends _.UnitDrawingService{}const S=v.createIdentifier("sheets-drawing.sheet-drawing.service");var I=(i=>(i[i.INSERT=0]="INSERT",i[i.REMOVE=1]="REMOVE",i[i.UPDATE=2]="UPDATE",i[i.ARRANGE=3]="ARRANGE",i[i.GROUP=4]="GROUP",i[i.UNGROUP=5]="UNGROUP",i))(I||{});const w={id:"sheet.mutation.set-drawing-apply",type:t.CommandType.MUTATION,handler:(i,r)=>{const e=i.get(_.IDrawingManagerService),n=i.get(S),{op:a,unitId:c,subUnitId:o,type:M,objects:u}=r;switch(e.applyJson1(c,o,a),n.applyJson1(c,o,a),M){case 0:e.addNotification(u),n.addNotification(u);break;case 1:e.removeNotification(u),n.removeNotification(u);break;case 2:e.updateNotification(u),n.updateNotification(u);break;case 3:e.orderNotification(u),n.orderNotification(u);break;case 4:e.groupUpdateNotification(u);break;case 5:e.ungroupUpdateNotification(u);break}return!0}};var E=Object.defineProperty,m=Object.getOwnPropertyDescriptor,N=(i,r,e,n)=>{for(var a=n>1?void 0:n?m(r,e):r,c=i.length-1,o;c>=0;c--)(o=i[c])&&(a=(n?o(r,e,a):o(a))||a);return n&&a&&E(r,e,a),a},h=(i,r)=>(e,n)=>r(e,n,i);const D="SHEET_DRAWING_PLUGIN";let d=class extends t.Disposable{constructor(i){super(),this._commandService=i,this.disposeWithMe(this._commandService.registerCommand(w))}};d=N([t.OnLifecycle(t.LifecycleStages.Starting,d),h(0,t.ICommandService)],d);let g=class extends t.Disposable{constructor(i,r,e,n,a){super(),this._sheetDrawingService=i,this._drawingManagerService=r,this._resourceManagerService=e,this._lifecycleService=n,this._univerInstanceService=a,this._init()}_init(){this._initSnapshot(),this._drawingInitializeListener()}_initSnapshot(){const i=e=>{const n=this._sheetDrawingService.getDrawingDataForUnit(e);return n?JSON.stringify(n):""},r=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:D,businesses:[t.UniverInstanceType.UNIVER_SHEET],toJson:e=>i(e),parseJson:e=>r(e),onUnLoad:e=>{this._sheetDrawingService.removeDrawingDataForUnit(e),this._drawingManagerService.removeDrawingDataForUnit(e)},onLoad:(e,n)=>{this._sheetDrawingService.registerDrawingData(e,n)}}))}_drawingInitializeListener(){this.disposeWithMe(this._lifecycleService.lifecycle$.subscribe(i=>{var r;if(i===t.LifecycleStages.Steady){const e=(r=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getUnitId();if(!e)return;this._sheetDrawingService.initializeNotification(e)}}))}};g=N([t.OnLifecycle(t.LifecycleStages.Ready,g),h(0,S),h(1,_.IDrawingManagerService),h(2,t.IResourceManagerService),h(3,v.Inject(t.LifecycleService)),h(4,t.IUniverInstanceService)],g);var p=Object.defineProperty,O=Object.getOwnPropertyDescriptor,R=(i,r,e,n)=>{for(var a=n>1?void 0:n?O(r,e):r,c=i.length-1,o;c>=0;c--)(o=i[c])&&(a=(n?o(r,e,a):o(a))||a);return n&&a&&p(r,e,a),a},b=(i,r)=>(e,n)=>r(e,n,i);s.UniverSheetsDrawingPlugin=(f=class extends t.Plugin{constructor(r,e){super(),this._config=r,this._injector=e}onStarting(r){[[d],[g],[S,{useClass:P}]].forEach(e=>r.add(e))}},l(f,"pluginName",D),l(f,"type",t.UniverInstanceType.UNIVER_SHEET),f),s.UniverSheetsDrawingPlugin=R([b(1,v.Inject(v.Injector))],s.UniverSheetsDrawingPlugin),s.DrawingApplyType=I,s.ISheetDrawingService=S,s.SetDrawingApplyMutation=w,s.SheetDrawingAnchorType=U,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-drawing",
3
- "version": "0.1.17",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -44,19 +44,19 @@
44
44
  "lib"
45
45
  ],
46
46
  "peerDependencies": {
47
- "@wendellhu/redi": "0.15.4",
48
- "@univerjs/core": "0.1.17",
49
- "@univerjs/drawing": "0.1.17"
47
+ "@wendellhu/redi": "0.15.5",
48
+ "@univerjs/drawing": "0.2.0",
49
+ "@univerjs/core": "0.2.0"
50
50
  },
51
51
  "devDependencies": {
52
- "@wendellhu/redi": "^0.15.4",
53
- "typescript": "^5.4.5",
54
- "vite": "^5.3.1",
52
+ "@wendellhu/redi": "0.15.5",
53
+ "typescript": "^5.5.3",
54
+ "vite": "^5.3.3",
55
55
  "vitest": "^1.6.0",
56
- "@univerjs/core": "0.1.17",
57
- "@univerjs/sheets": "0.1.17",
58
- "@univerjs/shared": "0.1.17",
59
- "@univerjs/drawing": "0.1.17"
56
+ "@univerjs/core": "0.2.0",
57
+ "@univerjs/sheets": "0.2.0",
58
+ "@univerjs/drawing": "0.2.0",
59
+ "@univerjs/shared": "0.2.0"
60
60
  },
61
61
  "univerSpace": {
62
62
  ".": {