@univerjs/docs-drawing 0.2.4-alpha.0 → 0.2.4

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 P=Object.defineProperty;var b=(r,i,e)=>i in r?P(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var D=(r,i,e)=>b(r,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),f=require("@univerjs/drawing"),I=require("rxjs/operators");class S extends f.UnitDrawingService{}const l=a.createIdentifier("univer.doc.plugin.doc-drawing.service");var h=(r=>(r[r.INSERT=0]="INSERT",r[r.REMOVE=1]="REMOVE",r[r.UPDATE=2]="UPDATE",r[r.ARRANGE=3]="ARRANGE",r[r.GROUP=4]="GROUP",r[r.UNGROUP=5]="UNGROUP",r))(h||{});const w={id:"doc.mutation.set-drawing-apply",type:a.CommandType.MUTATION,handler:(r,i)=>{const e=r.get(f.IDrawingManagerService),t=r.get(l),n=r.get(a.IUniverInstanceService),{op:s,unitId:c,subUnitId:g,type:O,objects:o}=i;switch(e.applyJson1(c,g,s),t.applyJson1(c,g,s),O){case 0:e.addNotification(o),t.addNotification(o);break;case 1:e.removeNotification(o),t.removeNotification(o);break;case 2:e.updateNotification(o),t.updateNotification(o);break;case 3:e.orderNotification(o),t.orderNotification(o);break;case 4:e.groupUpdateNotification(o);break;case 5:e.ungroupUpdateNotification(o);break}return n.getUnit(c),!0}};var p=Object.defineProperty,R=Object.getOwnPropertyDescriptor,N=(r,i,e,t)=>{for(var n=t>1?void 0:t?R(i,e):i,s=r.length-1,c;s>=0;s--)(c=r[s])&&(n=(t?c(i,e,n):c(n))||n);return t&&n&&p(i,e,n),n},d=(r,i)=>(e,t)=>i(e,t,r);const U="DOC_DRAWING_PLUGIN";let v=class extends a.Disposable{constructor(r){super(),this._commandService=r,this.disposeWithMe(this._commandService.registerCommand(w))}};v=N([a.OnLifecycle(a.LifecycleStages.Starting,v),d(0,a.ICommandService)],v);let _=class extends a.Disposable{constructor(r,i,e,t,n){super(),this._docDrawingService=r,this._drawingManagerService=i,this._resourceManagerService=e,this._univerInstanceService=t,this._lifecycleService=n,this._init()}_init(){this._initSnapshot(),this._drawingInitializeListener()}_initSnapshot(){const r=e=>{const t=this._docDrawingService.getDrawingDataForUnit(e);return t!=null&&t[e]?JSON.stringify(t==null?void 0:t[e]):""},i=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:U,businesses:[a.UniverInstanceType.UNIVER_DOC],toJson:e=>r(e),parseJson:e=>i(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{var n,s;this._setDrawingDataForUnit(e,{data:(n=t.data)!=null?n:{},order:(s=t.order)!=null?s:[]})}}))}_setDrawingDataForUnit(r,i){const e=this._univerInstanceService.getUnit(r);e!=null&&(e.resetDrawing(i.data,i.order),this._initDataLoader())}_initDataLoader(){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_DOC);if(!r)return!1;const i=r.getUnitId(),e=i,t=r.getDrawings(),n=r.getDrawingsOrder();if(!t||!n)return!1;Object.keys(t).forEach(c=>{const g=t[c];t[c]={...g}});const s={[e]:{unitId:i,subUnitId:e,data:t,order:n}};return this._docDrawingService.registerDrawingData(i,s),this._drawingManagerService.registerDrawingData(i,s),!0}_drawingInitializeListener(){this._lifecycleService.lifecycle$.pipe(I.filter(r=>r===a.LifecycleStages.Rendered),I.first()).subscribe(r=>{var e;const i=(e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_DOC))==null?void 0:e.getUnitId();i&&(this._docDrawingService.initializeNotification(i),this._drawingManagerService.initializeNotification(i))})}};_=N([a.OnLifecycle(a.LifecycleStages.Starting,_),d(0,l),d(1,f.IDrawingManagerService),d(2,a.IResourceManagerService),d(3,a.IUniverInstanceService),d(4,a.Inject(a.LifecycleService))],_);var M=Object.defineProperty,C=Object.getOwnPropertyDescriptor,E=(r,i,e,t)=>{for(var n=t>1?void 0:t?C(i,e):i,s=r.length-1,c;s>=0;s--)(c=r[s])&&(n=(t?c(i,e,n):c(n))||n);return t&&n&&M(i,e,n),n},L=(r,i)=>(e,t)=>i(e,t,r),u;exports.UniverDocsDrawingPlugin=(u=class extends a.Plugin{constructor(i,e){super(),this._injector=e}onStarting(i){[[v],[_],[S],[l,{useClass:S}]].forEach(e=>i.add(e))}},D(u,"pluginName",U),D(u,"type",a.UniverInstanceType.UNIVER_DOC),u);exports.UniverDocsDrawingPlugin=E([L(1,a.Inject(a.Injector))],exports.UniverDocsDrawingPlugin);exports.DOCS_DRAWING_PLUGIN=U;exports.DocDrawingApplyType=h;exports.DocDrawingService=S;exports.IDocDrawingService=l;exports.SetDocDrawingApplyMutation=w;
1
+ "use strict";var p=Object.defineProperty;var U=(i,r,e)=>r in i?p(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e;var v=(i,r,e)=>U(i,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),l=require("@wendellhu/redi"),f=require("@univerjs/drawing"),w=require("rxjs/operators");class _ extends f.UnitDrawingService{}const u=l.createIdentifier("univer.doc.plugin.doc-drawing.service");var O=Object.defineProperty,y=Object.getOwnPropertyDescriptor,h=(i,r,e,t)=>{for(var n=t>1?void 0:t?y(r,e):r,s=i.length-1,c;s>=0;s--)(c=i[s])&&(n=(t?c(r,e,n):c(n))||n);return t&&n&&O(r,e,n),n},o=(i,r)=>(e,t)=>r(e,t,i);const S="DOC_DRAWING_PLUGIN";let D=class extends a.Disposable{constructor(i){super(),this._commandService=i}};D=h([a.OnLifecycle(a.LifecycleStages.Starting,D),o(0,a.ICommandService)],D);let d=class extends a.Disposable{constructor(i,r,e,t,n){super(),this._docDrawingService=i,this._drawingManagerService=r,this._resourceManagerService=e,this._univerInstanceService=t,this._lifecycleService=n,this._init()}_init(){this._initSnapshot(),this._drawingInitializeListener()}_initSnapshot(){const i=e=>{const t=this._docDrawingService.getDrawingDataForUnit(e);return t!=null&&t[e]?JSON.stringify(t==null?void 0:t[e]):""},r=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:S,businesses:[a.UniverInstanceType.UNIVER_DOC],toJson:e=>i(e),parseJson:e=>r(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{var n,s;this._setDrawingDataForUnit(e,{data:(n=t.data)!=null?n:{},order:(s=t.order)!=null?s:[]})}}))}_setDrawingDataForUnit(i,r){const e=this._univerInstanceService.getUnit(i);e!=null&&(e.resetDrawing(r.data,r.order),this._initDataLoader())}_initDataLoader(){const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_DOC);if(!i)return!1;const r=i.getUnitId(),e=r,t=i.getDrawings(),n=i.getDrawingsOrder();if(!t||!n)return!1;Object.keys(t).forEach(c=>{const I=t[c];t[c]={...I}});const s={[e]:{unitId:r,subUnitId:e,data:t,order:n}};return this._docDrawingService.registerDrawingData(r,s),this._drawingManagerService.registerDrawingData(r,s),!0}_drawingInitializeListener(){this._lifecycleService.lifecycle$.pipe(w.filter(i=>i===a.LifecycleStages.Rendered),w.first()).subscribe(i=>{var e;const r=(e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_DOC))==null?void 0:e.getUnitId();r&&(this._docDrawingService.initializeNotification(r),this._drawingManagerService.initializeNotification(r))})}};d=h([a.OnLifecycle(a.LifecycleStages.Starting,d),o(0,u),o(1,f.IDrawingManagerService),o(2,a.IResourceManagerService),o(3,a.IUniverInstanceService),o(4,l.Inject(a.LifecycleService))],d);var P=Object.defineProperty,L=Object.getOwnPropertyDescriptor,N=(i,r,e,t)=>{for(var n=t>1?void 0:t?L(r,e):r,s=i.length-1,c;s>=0;s--)(c=i[s])&&(n=(t?c(r,e,n):c(n))||n);return t&&n&&P(r,e,n),n},C=(i,r)=>(e,t)=>r(e,t,i),g;exports.UniverDocsDrawingPlugin=(g=class extends a.Plugin{constructor(r,e){super(),this._injector=e}onStarting(r){[[D],[d],[_],[u,{useClass:_}]].forEach(e=>r.add(e))}},v(g,"pluginName",S),v(g,"type",a.UniverInstanceType.UNIVER_DOC),g);exports.UniverDocsDrawingPlugin=N([C(1,l.Inject(l.Injector))],exports.UniverDocsDrawingPlugin);exports.DOCS_DRAWING_PLUGIN=S;exports.DocDrawingService=_;exports.IDocDrawingService=u;
package/lib/es/index.js CHANGED
@@ -1,159 +1,129 @@
1
- var b = Object.defineProperty;
2
- var M = (e, r, t) => r in e ? b(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
3
- var f = (e, r, t) => M(e, typeof r != "symbol" ? r + "" : r, t);
4
- import { createIdentifier as C, CommandType as E, IUniverInstanceService as D, OnLifecycle as I, LifecycleStages as l, Inject as N, LifecycleService as p, Disposable as O, ICommandService as L, UniverInstanceType as u, IResourceManagerService as G, Plugin as j, Injector as J } from "@univerjs/core";
5
- import { UnitDrawingService as F, IDrawingManagerService as w } from "@univerjs/drawing";
6
- import { filter as V, first as x } from "rxjs/operators";
7
- class h extends F {
1
+ var O = Object.defineProperty;
2
+ var P = (i, r, e) => r in i ? O(i, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[r] = e;
3
+ var D = (i, r, e) => P(i, typeof r != "symbol" ? r + "" : r, e);
4
+ import { OnLifecycle as f, LifecycleStages as l, LifecycleService as C, Disposable as S, ICommandService as N, UniverInstanceType as g, IResourceManagerService as m, IUniverInstanceService as y, Plugin as L } from "@univerjs/core";
5
+ import { createIdentifier as M, Inject as h, Injector as b } from "@wendellhu/redi";
6
+ import { UnitDrawingService as R, IDrawingManagerService as j } from "@univerjs/drawing";
7
+ import { filter as E, first as F } from "rxjs/operators";
8
+ class v extends R {
8
9
  }
9
- const S = C("univer.doc.plugin.doc-drawing.service");
10
- var $ = /* @__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))($ || {});
11
- const z = {
12
- id: "doc.mutation.set-drawing-apply",
13
- type: E.MUTATION,
14
- handler: (e, r) => {
15
- const t = e.get(w), i = e.get(S), n = e.get(D), { op: a, unitId: s, subUnitId: d, type: m, objects: o } = r;
16
- switch (t.applyJson1(s, d, a), i.applyJson1(s, d, a), m) {
17
- case 0:
18
- t.addNotification(o), i.addNotification(o);
19
- break;
20
- case 1:
21
- t.removeNotification(o), i.removeNotification(o);
22
- break;
23
- case 2:
24
- t.updateNotification(o), i.updateNotification(o);
25
- break;
26
- case 3:
27
- t.orderNotification(o), i.orderNotification(o);
28
- break;
29
- case 4:
30
- t.groupUpdateNotification(o);
31
- break;
32
- case 5:
33
- t.ungroupUpdateNotification(o);
34
- break;
35
- }
36
- return n.getUnit(s), !0;
10
+ const w = M("univer.doc.plugin.doc-drawing.service");
11
+ var J = Object.defineProperty, x = Object.getOwnPropertyDescriptor, p = (i, r, e, t) => {
12
+ for (var n = t > 1 ? void 0 : t ? x(r, e) : r, a = i.length - 1, s; a >= 0; a--)
13
+ (s = i[a]) && (n = (t ? s(r, e, n) : s(n)) || n);
14
+ return t && n && J(r, e, n), n;
15
+ }, c = (i, r) => (e, t) => r(e, t, i);
16
+ const I = "DOC_DRAWING_PLUGIN";
17
+ let d = class extends S {
18
+ constructor(i) {
19
+ super(), this._commandService = i;
37
20
  }
38
21
  };
39
- var W = Object.defineProperty, q = Object.getOwnPropertyDescriptor, P = (e, r, t, i) => {
40
- for (var n = i > 1 ? void 0 : i ? q(r, t) : r, a = e.length - 1, s; a >= 0; a--)
41
- (s = e[a]) && (n = (i ? s(r, t, n) : s(n)) || n);
42
- return i && n && W(r, t, n), n;
43
- }, c = (e, r) => (t, i) => r(t, i, e);
44
- const R = "DOC_DRAWING_PLUGIN";
45
- let v = class extends O {
46
- constructor(e) {
47
- super(), this._commandService = e, this.disposeWithMe(this._commandService.registerCommand(z));
48
- }
49
- };
50
- v = P([
51
- I(l.Starting, v),
52
- c(0, L)
53
- ], v);
54
- let _ = class extends O {
55
- constructor(e, r, t, i, n) {
56
- super(), this._docDrawingService = e, this._drawingManagerService = r, this._resourceManagerService = t, this._univerInstanceService = i, this._lifecycleService = n, this._init();
22
+ d = p([
23
+ f(l.Starting, d),
24
+ c(0, N)
25
+ ], d);
26
+ let _ = class extends S {
27
+ constructor(i, r, e, t, n) {
28
+ super(), this._docDrawingService = i, this._drawingManagerService = r, this._resourceManagerService = e, this._univerInstanceService = t, this._lifecycleService = n, this._init();
57
29
  }
58
30
  _init() {
59
31
  this._initSnapshot(), this._drawingInitializeListener();
60
32
  }
61
33
  _initSnapshot() {
62
- const e = (t) => {
63
- const i = this._docDrawingService.getDrawingDataForUnit(t);
64
- return i != null && i[t] ? JSON.stringify(i == null ? void 0 : i[t]) : "";
65
- }, r = (t) => {
66
- if (!t)
34
+ const i = (e) => {
35
+ const t = this._docDrawingService.getDrawingDataForUnit(e);
36
+ return t != null && t[e] ? JSON.stringify(t == null ? void 0 : t[e]) : "";
37
+ }, r = (e) => {
38
+ if (!e)
67
39
  return { data: {}, order: [] };
68
40
  try {
69
- return JSON.parse(t);
41
+ return JSON.parse(e);
70
42
  } catch {
71
43
  return { data: {}, order: [] };
72
44
  }
73
45
  };
74
46
  this.disposeWithMe(
75
47
  this._resourceManagerService.registerPluginResource({
76
- pluginName: R,
77
- businesses: [u.UNIVER_DOC],
78
- toJson: (t) => e(t),
79
- parseJson: (t) => r(t),
80
- onUnLoad: (t) => {
81
- this._setDrawingDataForUnit(t, { data: {}, order: [] });
48
+ pluginName: I,
49
+ businesses: [g.UNIVER_DOC],
50
+ toJson: (e) => i(e),
51
+ parseJson: (e) => r(e),
52
+ onUnLoad: (e) => {
53
+ this._setDrawingDataForUnit(e, { data: {}, order: [] });
82
54
  },
83
- onLoad: (t, i) => {
55
+ onLoad: (e, t) => {
84
56
  var n, a;
85
- this._setDrawingDataForUnit(t, { data: (n = i.data) != null ? n : {}, order: (a = i.order) != null ? a : [] });
57
+ this._setDrawingDataForUnit(e, { data: (n = t.data) != null ? n : {}, order: (a = t.order) != null ? a : [] });
86
58
  }
87
59
  })
88
60
  );
89
61
  }
90
- _setDrawingDataForUnit(e, r) {
91
- const t = this._univerInstanceService.getUnit(e);
92
- t != null && (t.resetDrawing(r.data, r.order), this._initDataLoader());
62
+ _setDrawingDataForUnit(i, r) {
63
+ const e = this._univerInstanceService.getUnit(i);
64
+ e != null && (e.resetDrawing(r.data, r.order), this._initDataLoader());
93
65
  }
94
66
  _initDataLoader() {
95
- const e = this._univerInstanceService.getCurrentUnitForType(u.UNIVER_DOC);
96
- if (!e)
67
+ const i = this._univerInstanceService.getCurrentUnitForType(g.UNIVER_DOC);
68
+ if (!i)
97
69
  return !1;
98
- const r = e.getUnitId(), t = r, i = e.getDrawings(), n = e.getDrawingsOrder();
99
- if (!i || !n)
70
+ const r = i.getUnitId(), e = r, t = i.getDrawings(), n = i.getDrawingsOrder();
71
+ if (!t || !n)
100
72
  return !1;
101
- Object.keys(i).forEach((s) => {
102
- const d = i[s];
103
- i[s] = { ...d };
73
+ Object.keys(t).forEach((s) => {
74
+ const U = t[s];
75
+ t[s] = { ...U };
104
76
  });
105
77
  const a = {
106
- [t]: {
78
+ [e]: {
107
79
  unitId: r,
108
- subUnitId: t,
109
- data: i,
80
+ subUnitId: e,
81
+ data: t,
110
82
  order: n
111
83
  }
112
84
  };
113
85
  return this._docDrawingService.registerDrawingData(r, a), this._drawingManagerService.registerDrawingData(r, a), !0;
114
86
  }
115
87
  _drawingInitializeListener() {
116
- this._lifecycleService.lifecycle$.pipe(V((e) => e === l.Rendered), x()).subscribe((e) => {
117
- var t;
118
- const r = (t = this._univerInstanceService.getCurrentUnitForType(u.UNIVER_DOC)) == null ? void 0 : t.getUnitId();
88
+ this._lifecycleService.lifecycle$.pipe(E((i) => i === l.Rendered), F()).subscribe((i) => {
89
+ var e;
90
+ const r = (e = this._univerInstanceService.getCurrentUnitForType(g.UNIVER_DOC)) == null ? void 0 : e.getUnitId();
119
91
  r && (this._docDrawingService.initializeNotification(r), this._drawingManagerService.initializeNotification(r));
120
92
  });
121
93
  }
122
94
  };
123
- _ = P([
124
- I(l.Starting, _),
125
- c(0, S),
126
- c(1, w),
127
- c(2, G),
128
- c(3, D),
129
- c(4, N(p))
95
+ _ = p([
96
+ f(l.Starting, _),
97
+ c(0, w),
98
+ c(1, j),
99
+ c(2, m),
100
+ c(3, y),
101
+ c(4, h(C))
130
102
  ], _);
131
- var B = Object.defineProperty, H = Object.getOwnPropertyDescriptor, K = (e, r, t, i) => {
132
- for (var n = i > 1 ? void 0 : i ? H(r, t) : r, a = e.length - 1, s; a >= 0; a--)
133
- (s = e[a]) && (n = (i ? s(r, t, n) : s(n)) || n);
134
- return i && n && B(r, t, n), n;
135
- }, Q = (e, r) => (t, i) => r(t, i, e), g;
136
- let U = (g = class extends j {
137
- constructor(e, r) {
103
+ var $ = Object.defineProperty, z = Object.getOwnPropertyDescriptor, G = (i, r, e, t) => {
104
+ for (var n = t > 1 ? void 0 : t ? z(r, e) : r, a = i.length - 1, s; a >= 0; a--)
105
+ (s = i[a]) && (n = (t ? s(r, e, n) : s(n)) || n);
106
+ return t && n && $(r, e, n), n;
107
+ }, V = (i, r) => (e, t) => r(e, t, i), o;
108
+ let u = (o = class extends L {
109
+ constructor(i, r) {
138
110
  super(), this._injector = r;
139
111
  }
140
- onStarting(e) {
112
+ onStarting(i) {
141
113
  [
142
- [v],
114
+ [d],
143
115
  [_],
144
- [h],
145
- [S, { useClass: h }]
146
- ].forEach((r) => e.add(r));
116
+ [v],
117
+ [w, { useClass: v }]
118
+ ].forEach((r) => i.add(r));
147
119
  }
148
- }, f(g, "pluginName", R), f(g, "type", u.UNIVER_DOC), g);
149
- U = K([
150
- Q(1, N(J))
151
- ], U);
120
+ }, D(o, "pluginName", I), D(o, "type", g.UNIVER_DOC), o);
121
+ u = G([
122
+ V(1, h(b))
123
+ ], u);
152
124
  export {
153
- R as DOCS_DRAWING_PLUGIN,
154
- $ as DocDrawingApplyType,
155
- h as DocDrawingService,
156
- S as IDocDrawingService,
157
- z as SetDocDrawingApplyMutation,
158
- U as UniverDocsDrawingPlugin
125
+ I as DOCS_DRAWING_PLUGIN,
126
+ v as DocDrawingService,
127
+ w as IDocDrawingService,
128
+ u as UniverDocsDrawingPlugin
159
129
  };
@@ -16,4 +16,3 @@
16
16
  export { UniverDocsDrawingPlugin } from './plugin';
17
17
  export { type IDocDrawing, IDocDrawingService, DocDrawingService } from './services/doc-drawing.service';
18
18
  export { DOCS_DRAWING_PLUGIN, type IDocDrawingModel } from './controllers/doc-drawing.controller';
19
- export { SetDocDrawingApplyMutation, DocDrawingApplyType, type ISetDrawingApplyMutationParams } from './commands/mutations/set-drawing-apply.mutation';
@@ -1,4 +1,5 @@
1
- import { Injector, Plugin, UniverInstanceType } from '@univerjs/core';
1
+ import { Plugin, UniverInstanceType } from '@univerjs/core';
2
+ import { Injector } from '@wendellhu/redi';
2
3
 
3
4
  export declare class UniverDocsDrawingPlugin extends Plugin {
4
5
  _injector: Injector;
@@ -15,5 +15,5 @@ export declare class DocDrawingService extends UnitDrawingService<IDocDrawing> {
15
15
  }
16
16
  export interface IDocDrawingService extends IUnitDrawingService<IDocDrawing> {
17
17
  }
18
- export declare const IDocDrawingService: import('@univerjs/core').IdentifierDecorator<IDocDrawingService>;
18
+ export declare const IDocDrawingService: import('@wendellhu/redi').IdentifierDecorator<IDocDrawingService>;
19
19
  export {};
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(s,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("rxjs/operators")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing","rxjs/operators"],r):(s=typeof globalThis<"u"?globalThis:s||self,r(s.UniverDocsDrawing={},s.UniverCore,s.UniverDrawing,s.rxjs.operators))})(this,function(s,r,u,h){"use strict";var m=Object.defineProperty;var E=(s,r,u)=>r in s?m(s,r,{enumerable:!0,configurable:!0,writable:!0,value:u}):s[r]=u;var I=(s,r,u)=>E(s,typeof r!="symbol"?r+"":r,u);var D;class l extends u.UnitDrawingService{}const v=r.createIdentifier("univer.doc.plugin.doc-drawing.service");var w=(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))(w||{});const N={id:"doc.mutation.set-drawing-apply",type:r.CommandType.MUTATION,handler:(i,n)=>{const e=i.get(u.IDrawingManagerService),t=i.get(v),a=i.get(r.IUniverInstanceService),{op:c,unitId:o,subUnitId:S,type:C,objects:d}=n;switch(e.applyJson1(o,S,c),t.applyJson1(o,S,c),C){case 0:e.addNotification(d),t.addNotification(d);break;case 1:e.removeNotification(d),t.removeNotification(d);break;case 2:e.updateNotification(d),t.updateNotification(d);break;case 3:e.orderNotification(d),t.orderNotification(d);break;case 4:e.groupUpdateNotification(d);break;case 5:e.ungroupUpdateNotification(d);break}return a.getUnit(o),!0}};var P=Object.defineProperty,p=Object.getOwnPropertyDescriptor,O=(i,n,e,t)=>{for(var a=t>1?void 0:t?p(n,e):n,c=i.length-1,o;c>=0;c--)(o=i[c])&&(a=(t?o(n,e,a):o(a))||a);return t&&a&&P(n,e,a),a},g=(i,n)=>(e,t)=>n(e,t,i);const U="DOC_DRAWING_PLUGIN";let f=class extends r.Disposable{constructor(i){super(),this._commandService=i,this.disposeWithMe(this._commandService.registerCommand(N))}};f=O([r.OnLifecycle(r.LifecycleStages.Starting,f),g(0,r.ICommandService)],f);let _=class extends r.Disposable{constructor(i,n,e,t,a){super(),this._docDrawingService=i,this._drawingManagerService=n,this._resourceManagerService=e,this._univerInstanceService=t,this._lifecycleService=a,this._init()}_init(){this._initSnapshot(),this._drawingInitializeListener()}_initSnapshot(){const i=e=>{const t=this._docDrawingService.getDrawingDataForUnit(e);return t!=null&&t[e]?JSON.stringify(t==null?void 0:t[e]):""},n=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:U,businesses:[r.UniverInstanceType.UNIVER_DOC],toJson:e=>i(e),parseJson:e=>n(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{var a,c;this._setDrawingDataForUnit(e,{data:(a=t.data)!=null?a:{},order:(c=t.order)!=null?c:[]})}}))}_setDrawingDataForUnit(i,n){const e=this._univerInstanceService.getUnit(i);e!=null&&(e.resetDrawing(n.data,n.order),this._initDataLoader())}_initDataLoader(){const i=this._univerInstanceService.getCurrentUnitForType(r.UniverInstanceType.UNIVER_DOC);if(!i)return!1;const n=i.getUnitId(),e=n,t=i.getDrawings(),a=i.getDrawingsOrder();if(!t||!a)return!1;Object.keys(t).forEach(o=>{const S=t[o];t[o]={...S}});const c={[e]:{unitId:n,subUnitId:e,data:t,order:a}};return this._docDrawingService.registerDrawingData(n,c),this._drawingManagerService.registerDrawingData(n,c),!0}_drawingInitializeListener(){this._lifecycleService.lifecycle$.pipe(h.filter(i=>i===r.LifecycleStages.Rendered),h.first()).subscribe(i=>{var e;const n=(e=this._univerInstanceService.getCurrentUnitForType(r.UniverInstanceType.UNIVER_DOC))==null?void 0:e.getUnitId();n&&(this._docDrawingService.initializeNotification(n),this._drawingManagerService.initializeNotification(n))})}};_=O([r.OnLifecycle(r.LifecycleStages.Starting,_),g(0,v),g(1,u.IDrawingManagerService),g(2,r.IResourceManagerService),g(3,r.IUniverInstanceService),g(4,r.Inject(r.LifecycleService))],_);var R=Object.defineProperty,M=Object.getOwnPropertyDescriptor,b=(i,n,e,t)=>{for(var a=t>1?void 0:t?M(n,e):n,c=i.length-1,o;c>=0;c--)(o=i[c])&&(a=(t?o(n,e,a):o(a))||a);return t&&a&&R(n,e,a),a},j=(i,n)=>(e,t)=>n(e,t,i);s.UniverDocsDrawingPlugin=(D=class extends r.Plugin{constructor(n,e){super(),this._injector=e}onStarting(n){[[f],[_],[l],[v,{useClass:l}]].forEach(e=>n.add(e))}},I(D,"pluginName",U),I(D,"type",r.UniverInstanceType.UNIVER_DOC),D),s.UniverDocsDrawingPlugin=b([j(1,r.Inject(r.Injector))],s.UniverDocsDrawingPlugin),s.DOCS_DRAWING_PLUGIN=U,s.DocDrawingApplyType=w,s.DocDrawingService=l,s.IDocDrawingService=v,s.SetDocDrawingApplyMutation=N,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
1
+ (function(s,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/drawing"),require("rxjs/operators")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/drawing","rxjs/operators"],n):(s=typeof globalThis<"u"?globalThis:s||self,n(s.UniverDocsDrawing={},s.UniverCore,s["@wendellhu/redi"],s.UniverDrawing,s.rxjs.operators))})(this,function(s,n,g,S,h){"use strict";var L=Object.defineProperty;var N=(s,n,g)=>n in s?L(s,n,{enumerable:!0,configurable:!0,writable:!0,value:g}):s[n]=g;var w=(s,n,g)=>N(s,typeof n!="symbol"?n+"":n,g);var v;class l extends S.UnitDrawingService{}const _=g.createIdentifier("univer.doc.plugin.doc-drawing.service");var I=Object.defineProperty,U=Object.getOwnPropertyDescriptor,p=(t,i,e,r)=>{for(var a=r>1?void 0:r?U(i,e):i,c=t.length-1,o;c>=0;c--)(o=t[c])&&(a=(r?o(i,e,a):o(a))||a);return r&&a&&I(i,e,a),a},d=(t,i)=>(e,r)=>i(e,r,t);const f="DOC_DRAWING_PLUGIN";let u=class extends n.Disposable{constructor(t){super(),this._commandService=t}};u=p([n.OnLifecycle(n.LifecycleStages.Starting,u),d(0,n.ICommandService)],u);let D=class extends n.Disposable{constructor(t,i,e,r,a){super(),this._docDrawingService=t,this._drawingManagerService=i,this._resourceManagerService=e,this._univerInstanceService=r,this._lifecycleService=a,this._init()}_init(){this._initSnapshot(),this._drawingInitializeListener()}_initSnapshot(){const t=e=>{const r=this._docDrawingService.getDrawingDataForUnit(e);return r!=null&&r[e]?JSON.stringify(r==null?void 0:r[e]):""},i=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:f,businesses:[n.UniverInstanceType.UNIVER_DOC],toJson:e=>t(e),parseJson:e=>i(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,r)=>{var a,c;this._setDrawingDataForUnit(e,{data:(a=r.data)!=null?a:{},order:(c=r.order)!=null?c:[]})}}))}_setDrawingDataForUnit(t,i){const e=this._univerInstanceService.getUnit(t);e!=null&&(e.resetDrawing(i.data,i.order),this._initDataLoader())}_initDataLoader(){const t=this._univerInstanceService.getCurrentUnitForType(n.UniverInstanceType.UNIVER_DOC);if(!t)return!1;const i=t.getUnitId(),e=i,r=t.getDrawings(),a=t.getDrawingsOrder();if(!r||!a)return!1;Object.keys(r).forEach(o=>{const C=r[o];r[o]={...C}});const c={[e]:{unitId:i,subUnitId:e,data:r,order:a}};return this._docDrawingService.registerDrawingData(i,c),this._drawingManagerService.registerDrawingData(i,c),!0}_drawingInitializeListener(){this._lifecycleService.lifecycle$.pipe(h.filter(t=>t===n.LifecycleStages.Rendered),h.first()).subscribe(t=>{var e;const i=(e=this._univerInstanceService.getCurrentUnitForType(n.UniverInstanceType.UNIVER_DOC))==null?void 0:e.getUnitId();i&&(this._docDrawingService.initializeNotification(i),this._drawingManagerService.initializeNotification(i))})}};D=p([n.OnLifecycle(n.LifecycleStages.Starting,D),d(0,_),d(1,S.IDrawingManagerService),d(2,n.IResourceManagerService),d(3,n.IUniverInstanceService),d(4,g.Inject(n.LifecycleService))],D);var y=Object.defineProperty,O=Object.getOwnPropertyDescriptor,P=(t,i,e,r)=>{for(var a=r>1?void 0:r?O(i,e):i,c=t.length-1,o;c>=0;c--)(o=t[c])&&(a=(r?o(i,e,a):o(a))||a);return r&&a&&y(i,e,a),a},j=(t,i)=>(e,r)=>i(e,r,t);s.UniverDocsDrawingPlugin=(v=class extends n.Plugin{constructor(i,e){super(),this._injector=e}onStarting(i){[[u],[D],[l],[_,{useClass:l}]].forEach(e=>i.add(e))}},w(v,"pluginName",f),w(v,"type",n.UniverInstanceType.UNIVER_DOC),v),s.UniverDocsDrawingPlugin=P([j(1,g.Inject(g.Injector))],s.UniverDocsDrawingPlugin),s.DOCS_DRAWING_PLUGIN=f,s.DocDrawingService=l,s.IDocDrawingService=_,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/docs-drawing",
3
- "version": "0.2.4-alpha.0",
3
+ "version": "0.2.4",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -44,19 +44,21 @@
44
44
  "lib"
45
45
  ],
46
46
  "peerDependencies": {
47
+ "@wendellhu/redi": "0.16.0",
47
48
  "rxjs": ">=7.0.0",
48
- "@univerjs/core": "0.2.4-alpha.0",
49
- "@univerjs/drawing": "0.2.4-alpha.0"
49
+ "@univerjs/core": "0.2.4",
50
+ "@univerjs/drawing": "0.2.4"
50
51
  },
51
52
  "devDependencies": {
53
+ "@wendellhu/redi": "0.16.0",
52
54
  "typescript": "^5.5.3",
53
55
  "vite": "^5.3.4",
54
56
  "vitest": "^2.0.3",
55
- "@univerjs/core": "0.2.4-alpha.0",
56
- "@univerjs/docs": "0.2.4-alpha.0",
57
- "@univerjs/engine-render": "0.2.4-alpha.0",
58
- "@univerjs/drawing": "0.2.4-alpha.0",
59
- "@univerjs/shared": "0.2.4-alpha.0"
57
+ "@univerjs/core": "0.2.4",
58
+ "@univerjs/docs": "0.2.4",
59
+ "@univerjs/drawing": "0.2.4",
60
+ "@univerjs/engine-render": "0.2.4",
61
+ "@univerjs/shared": "0.2.4"
60
62
  },
61
63
  "univerSpace": {
62
64
  ".": {
@@ -1,15 +0,0 @@
1
- import { IMutation } from '@univerjs/core';
2
- import { IDrawingJson1Type } from '@univerjs/drawing';
3
-
4
- export declare enum DocDrawingApplyType {
5
- INSERT = 0,
6
- REMOVE = 1,
7
- UPDATE = 2,
8
- ARRANGE = 3,
9
- GROUP = 4,
10
- UNGROUP = 5
11
- }
12
- export interface ISetDrawingApplyMutationParams extends IDrawingJson1Type {
13
- type: DocDrawingApplyType;
14
- }
15
- export declare const SetDocDrawingApplyMutation: IMutation<ISetDrawingApplyMutationParams>;