@univerjs/docs-drawing 0.2.3 → 0.2.4-alpha.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 +1 -1
- package/lib/es/index.js +19 -20
- package/lib/types/plugin.d.ts +1 -2
- package/lib/types/services/doc-drawing.service.d.ts +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +10 -12
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
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;
|
package/lib/es/index.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
var b = Object.defineProperty;
|
|
2
2
|
var M = (e, r, t) => r in e ? b(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
3
3
|
var f = (e, r, t) => M(e, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
-
import { CommandType as
|
|
5
|
-
import { createIdentifier as j, Inject as O, Injector as J } from "@wendellhu/redi";
|
|
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";
|
|
6
5
|
import { UnitDrawingService as F, IDrawingManagerService as w } from "@univerjs/drawing";
|
|
7
6
|
import { filter as V, first as x } from "rxjs/operators";
|
|
8
7
|
class h extends F {
|
|
9
8
|
}
|
|
10
|
-
const S =
|
|
9
|
+
const S = C("univer.doc.plugin.doc-drawing.service");
|
|
11
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))($ || {});
|
|
12
11
|
const z = {
|
|
13
12
|
id: "doc.mutation.set-drawing-apply",
|
|
14
|
-
type:
|
|
13
|
+
type: E.MUTATION,
|
|
15
14
|
handler: (e, r) => {
|
|
16
|
-
const t = e.get(w), i = e.get(S), n = e.get(D), { op: a, unitId: s, subUnitId: d, type:
|
|
17
|
-
switch (t.applyJson1(s, d, a), i.applyJson1(s, d, a),
|
|
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) {
|
|
18
17
|
case 0:
|
|
19
18
|
t.addNotification(o), i.addNotification(o);
|
|
20
19
|
break;
|
|
@@ -37,22 +36,22 @@ const z = {
|
|
|
37
36
|
return n.getUnit(s), !0;
|
|
38
37
|
}
|
|
39
38
|
};
|
|
40
|
-
var W = Object.defineProperty, q = Object.getOwnPropertyDescriptor,
|
|
39
|
+
var W = Object.defineProperty, q = Object.getOwnPropertyDescriptor, P = (e, r, t, i) => {
|
|
41
40
|
for (var n = i > 1 ? void 0 : i ? q(r, t) : r, a = e.length - 1, s; a >= 0; a--)
|
|
42
41
|
(s = e[a]) && (n = (i ? s(r, t, n) : s(n)) || n);
|
|
43
42
|
return i && n && W(r, t, n), n;
|
|
44
43
|
}, c = (e, r) => (t, i) => r(t, i, e);
|
|
45
|
-
const
|
|
46
|
-
let v = class extends
|
|
44
|
+
const R = "DOC_DRAWING_PLUGIN";
|
|
45
|
+
let v = class extends O {
|
|
47
46
|
constructor(e) {
|
|
48
47
|
super(), this._commandService = e, this.disposeWithMe(this._commandService.registerCommand(z));
|
|
49
48
|
}
|
|
50
49
|
};
|
|
51
|
-
v =
|
|
50
|
+
v = P([
|
|
52
51
|
I(l.Starting, v),
|
|
53
|
-
c(0,
|
|
52
|
+
c(0, L)
|
|
54
53
|
], v);
|
|
55
|
-
let _ = class extends
|
|
54
|
+
let _ = class extends O {
|
|
56
55
|
constructor(e, r, t, i, n) {
|
|
57
56
|
super(), this._docDrawingService = e, this._drawingManagerService = r, this._resourceManagerService = t, this._univerInstanceService = i, this._lifecycleService = n, this._init();
|
|
58
57
|
}
|
|
@@ -74,7 +73,7 @@ let _ = class extends N {
|
|
|
74
73
|
};
|
|
75
74
|
this.disposeWithMe(
|
|
76
75
|
this._resourceManagerService.registerPluginResource({
|
|
77
|
-
pluginName:
|
|
76
|
+
pluginName: R,
|
|
78
77
|
businesses: [u.UNIVER_DOC],
|
|
79
78
|
toJson: (t) => e(t),
|
|
80
79
|
parseJson: (t) => r(t),
|
|
@@ -121,20 +120,20 @@ let _ = class extends N {
|
|
|
121
120
|
});
|
|
122
121
|
}
|
|
123
122
|
};
|
|
124
|
-
_ =
|
|
123
|
+
_ = P([
|
|
125
124
|
I(l.Starting, _),
|
|
126
125
|
c(0, S),
|
|
127
126
|
c(1, w),
|
|
128
|
-
c(2,
|
|
127
|
+
c(2, G),
|
|
129
128
|
c(3, D),
|
|
130
|
-
c(4,
|
|
129
|
+
c(4, N(p))
|
|
131
130
|
], _);
|
|
132
131
|
var B = Object.defineProperty, H = Object.getOwnPropertyDescriptor, K = (e, r, t, i) => {
|
|
133
132
|
for (var n = i > 1 ? void 0 : i ? H(r, t) : r, a = e.length - 1, s; a >= 0; a--)
|
|
134
133
|
(s = e[a]) && (n = (i ? s(r, t, n) : s(n)) || n);
|
|
135
134
|
return i && n && B(r, t, n), n;
|
|
136
135
|
}, Q = (e, r) => (t, i) => r(t, i, e), g;
|
|
137
|
-
let U = (g = class extends
|
|
136
|
+
let U = (g = class extends j {
|
|
138
137
|
constructor(e, r) {
|
|
139
138
|
super(), this._injector = r;
|
|
140
139
|
}
|
|
@@ -146,12 +145,12 @@ let U = (g = class extends G {
|
|
|
146
145
|
[S, { useClass: h }]
|
|
147
146
|
].forEach((r) => e.add(r));
|
|
148
147
|
}
|
|
149
|
-
}, f(g, "pluginName",
|
|
148
|
+
}, f(g, "pluginName", R), f(g, "type", u.UNIVER_DOC), g);
|
|
150
149
|
U = K([
|
|
151
|
-
Q(1,
|
|
150
|
+
Q(1, N(J))
|
|
152
151
|
], U);
|
|
153
152
|
export {
|
|
154
|
-
|
|
153
|
+
R as DOCS_DRAWING_PLUGIN,
|
|
155
154
|
$ as DocDrawingApplyType,
|
|
156
155
|
h as DocDrawingService,
|
|
157
156
|
S as IDocDrawingService,
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -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('@
|
|
18
|
+
export declare const IDocDrawingService: import('@univerjs/core').IdentifierDecorator<IDocDrawingService>;
|
|
19
19
|
export {};
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(s,
|
|
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"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs-drawing",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4-alpha.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -44,21 +44,19 @@
|
|
|
44
44
|
"lib"
|
|
45
45
|
],
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@wendellhu/redi": "0.15.5",
|
|
48
47
|
"rxjs": ">=7.0.0",
|
|
49
|
-
"@univerjs/core": "0.2.
|
|
50
|
-
"@univerjs/drawing": "0.2.
|
|
48
|
+
"@univerjs/core": "0.2.4-alpha.0",
|
|
49
|
+
"@univerjs/drawing": "0.2.4-alpha.0"
|
|
51
50
|
},
|
|
52
51
|
"devDependencies": {
|
|
53
|
-
"@wendellhu/redi": "0.15.5",
|
|
54
52
|
"typescript": "^5.5.3",
|
|
55
|
-
"vite": "^5.3.
|
|
56
|
-
"vitest": "^
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/
|
|
59
|
-
"@univerjs/
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/
|
|
53
|
+
"vite": "^5.3.4",
|
|
54
|
+
"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"
|
|
62
60
|
},
|
|
63
61
|
"univerSpace": {
|
|
64
62
|
".": {
|