@univerjs/docs-drawing 0.4.2 → 0.5.0-beta.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 +88 -91
- package/lib/umd/index.js +1 -1
- package/package.json +11 -15
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var S=Object.defineProperty;var f=(t,r,e)=>r in t?S(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e;var _=(t,r,e)=>f(t,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),h=require("@univerjs/drawing"),p="docs-drawing.config",U={};class v extends h.UnitDrawingService{}const d=c.createIdentifier("univer.doc.plugin.doc-drawing.service");var I=Object.defineProperty,O=Object.getOwnPropertyDescriptor,P=(t,r,e,n)=>{for(var i=n>1?void 0:n?O(r,e):r,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(r,e,i):s(i))||i);return n&&i&&I(r,e,i),i},o=(t,r)=>(e,n)=>r(e,n,t);const u="DOC_DRAWING_PLUGIN";let D=class extends c.Disposable{constructor(t,r,e,n){super(),this._docDrawingService=t,this._drawingManagerService=r,this._resourceManagerService=e,this._univerInstanceService=n,this._init()}_init(){this._initSnapshot()}_initSnapshot(){const t=e=>{const n=this._univerInstanceService.getUnit(e,c.UniverInstanceType.UNIVER_DOC);if(n){const i=n.getSnapshot().drawings,a=n.getSnapshot().drawingsOrder,s={data:i!=null?i:{},order:a!=null?a:[]};return JSON.stringify(s)}return""},r=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:u,businesses:[c.UniverInstanceType.UNIVER_DOC],toJson:e=>t(e),parseJson:e=>r(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,n)=>{var i,a;this._setDrawingDataForUnit(e,{data:(i=n.data)!=null?i:{},order:(a=n.order)!=null?a:[]})}}))}_setDrawingDataForUnit(t,r){const e=this._univerInstanceService.getUnit(t);e!=null&&(e.resetDrawing(r.data,r.order),this._initDataLoader(t))}_initDataLoader(t){const r=this._univerInstanceService.getUnit(t,c.UniverInstanceType.UNIVER_DOC);if(!r)return!1;const e=t,n=r.getDrawings(),i=r.getDrawingsOrder();if(!n||!i)return!1;Object.keys(n).forEach(s=>{const w=n[s];n[s]={...w}});const a={[e]:{unitId:t,subUnitId:e,data:n,order:i}};return this._docDrawingService.registerDrawingData(t,a),this._drawingManagerService.registerDrawingData(t,a),!0}};D=P([o(0,d),o(1,h.IDrawingManagerService),o(2,c.IResourceManagerService),o(3,c.IUniverInstanceService)],D);var N=Object.defineProperty,C=Object.getOwnPropertyDescriptor,M=(t,r,e,n)=>{for(var i=n>1?void 0:n?C(r,e):r,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(r,e,i):s(i))||i);return n&&i&&N(r,e,i),i},l=(t,r)=>(e,n)=>r(e,n,t),g;exports.UniverDocsDrawingPlugin=(g=class extends c.Plugin{constructor(r=U,e,n){super(),this._config=r,this._injector=e,this._configService=n;const{...i}=this._config;this._configService.setConfig(p,i)}onStarting(){[[D],[v],[d,{useClass:v}]].forEach(r=>this._injector.add(r)),this._injector.get(D)}},_(g,"pluginName",u),_(g,"type",c.UniverInstanceType.UNIVER_DOC),g);exports.UniverDocsDrawingPlugin=M([l(1,c.Inject(c.Injector)),l(2,c.IConfigService)],exports.UniverDocsDrawingPlugin);exports.DOCS_DRAWING_PLUGIN=u;exports.DocDrawingService=v;exports.IDocDrawingService=d;
|
package/lib/es/index.js
CHANGED
|
@@ -1,122 +1,119 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
let DocDrawingController = (_a = class extends Disposable {
|
|
20
|
-
constructor(_docDrawingService, _drawingManagerService, _resourceManagerService, _univerInstanceService) {
|
|
21
|
-
super(), this._docDrawingService = _docDrawingService, this._drawingManagerService = _drawingManagerService, this._resourceManagerService = _resourceManagerService, this._univerInstanceService = _univerInstanceService, this._init();
|
|
1
|
+
var p = Object.defineProperty;
|
|
2
|
+
var S = (t, r, e) => r in t ? p(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
|
|
3
|
+
var D = (t, r, e) => S(t, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
+
import { createIdentifier as w, Disposable as O, UniverInstanceType as g, IResourceManagerService as U, IUniverInstanceService as I, Plugin as P, Inject as C, Injector as N, IConfigService as M } from "@univerjs/core";
|
|
5
|
+
import { UnitDrawingService as b, IDrawingManagerService as j } from "@univerjs/drawing";
|
|
6
|
+
const m = "docs-drawing.config", R = {};
|
|
7
|
+
class d extends b {
|
|
8
|
+
}
|
|
9
|
+
const h = w("univer.doc.plugin.doc-drawing.service");
|
|
10
|
+
var E = Object.defineProperty, L = Object.getOwnPropertyDescriptor, G = (t, r, e, n) => {
|
|
11
|
+
for (var i = n > 1 ? void 0 : n ? L(r, e) : r, s = t.length - 1, a; s >= 0; s--)
|
|
12
|
+
(a = t[s]) && (i = (n ? a(r, e, i) : a(i)) || i);
|
|
13
|
+
return n && i && E(r, e, i), i;
|
|
14
|
+
}, o = (t, r) => (e, n) => r(e, n, t);
|
|
15
|
+
const f = "DOC_DRAWING_PLUGIN";
|
|
16
|
+
let _ = class extends O {
|
|
17
|
+
constructor(t, r, e, n) {
|
|
18
|
+
super(), this._docDrawingService = t, this._drawingManagerService = r, this._resourceManagerService = e, this._univerInstanceService = n, this._init();
|
|
22
19
|
}
|
|
23
20
|
_init() {
|
|
24
21
|
this._initSnapshot();
|
|
25
22
|
}
|
|
26
23
|
_initSnapshot() {
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
const
|
|
31
|
-
data:
|
|
32
|
-
order:
|
|
24
|
+
const t = (e) => {
|
|
25
|
+
const n = this._univerInstanceService.getUnit(e, g.UNIVER_DOC);
|
|
26
|
+
if (n) {
|
|
27
|
+
const i = n.getSnapshot().drawings, s = n.getSnapshot().drawingsOrder, a = {
|
|
28
|
+
data: i != null ? i : {},
|
|
29
|
+
order: s != null ? s : []
|
|
33
30
|
};
|
|
34
|
-
return JSON.stringify(
|
|
31
|
+
return JSON.stringify(a);
|
|
35
32
|
}
|
|
36
33
|
return "";
|
|
37
|
-
},
|
|
38
|
-
if (!
|
|
34
|
+
}, r = (e) => {
|
|
35
|
+
if (!e)
|
|
39
36
|
return { data: {}, order: [] };
|
|
40
37
|
try {
|
|
41
|
-
return JSON.parse(
|
|
38
|
+
return JSON.parse(e);
|
|
42
39
|
} catch {
|
|
43
40
|
return { data: {}, order: [] };
|
|
44
41
|
}
|
|
45
|
-
}
|
|
42
|
+
};
|
|
46
43
|
this.disposeWithMe(
|
|
47
44
|
this._resourceManagerService.registerPluginResource({
|
|
48
|
-
pluginName:
|
|
49
|
-
businesses: [
|
|
50
|
-
toJson:
|
|
51
|
-
parseJson:
|
|
52
|
-
onUnLoad:
|
|
53
|
-
this._setDrawingDataForUnit(
|
|
54
|
-
},
|
|
55
|
-
onLoad:
|
|
56
|
-
var
|
|
57
|
-
this._setDrawingDataForUnit(
|
|
58
|
-
}
|
|
45
|
+
pluginName: f,
|
|
46
|
+
businesses: [g.UNIVER_DOC],
|
|
47
|
+
toJson: (e) => t(e),
|
|
48
|
+
parseJson: (e) => r(e),
|
|
49
|
+
onUnLoad: (e) => {
|
|
50
|
+
this._setDrawingDataForUnit(e, { data: {}, order: [] });
|
|
51
|
+
},
|
|
52
|
+
onLoad: (e, n) => {
|
|
53
|
+
var i, s;
|
|
54
|
+
this._setDrawingDataForUnit(e, { data: (i = n.data) != null ? i : {}, order: (s = n.order) != null ? s : [] });
|
|
55
|
+
}
|
|
59
56
|
})
|
|
60
57
|
);
|
|
61
58
|
}
|
|
62
|
-
_setDrawingDataForUnit(
|
|
63
|
-
const
|
|
64
|
-
|
|
59
|
+
_setDrawingDataForUnit(t, r) {
|
|
60
|
+
const e = this._univerInstanceService.getUnit(t);
|
|
61
|
+
e != null && (e.resetDrawing(r.data, r.order), this._initDataLoader(t));
|
|
65
62
|
}
|
|
66
|
-
_initDataLoader(
|
|
67
|
-
const
|
|
68
|
-
if (!
|
|
63
|
+
_initDataLoader(t) {
|
|
64
|
+
const r = this._univerInstanceService.getUnit(t, g.UNIVER_DOC);
|
|
65
|
+
if (!r)
|
|
69
66
|
return !1;
|
|
70
|
-
const
|
|
71
|
-
if (!
|
|
67
|
+
const e = t, n = r.getDrawings(), i = r.getDrawingsOrder();
|
|
68
|
+
if (!n || !i)
|
|
72
69
|
return !1;
|
|
73
|
-
Object.keys(
|
|
74
|
-
const
|
|
75
|
-
|
|
70
|
+
Object.keys(n).forEach((a) => {
|
|
71
|
+
const l = n[a];
|
|
72
|
+
n[a] = { ...l };
|
|
76
73
|
});
|
|
77
|
-
const
|
|
78
|
-
[
|
|
79
|
-
unitId,
|
|
80
|
-
subUnitId,
|
|
81
|
-
data:
|
|
82
|
-
order:
|
|
74
|
+
const s = {
|
|
75
|
+
[e]: {
|
|
76
|
+
unitId: t,
|
|
77
|
+
subUnitId: e,
|
|
78
|
+
data: n,
|
|
79
|
+
order: i
|
|
83
80
|
}
|
|
84
81
|
};
|
|
85
|
-
return this._docDrawingService.registerDrawingData(
|
|
82
|
+
return this._docDrawingService.registerDrawingData(t, s), this._drawingManagerService.registerDrawingData(t, s), !0;
|
|
86
83
|
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
],
|
|
94
|
-
var
|
|
95
|
-
for (var
|
|
96
|
-
(
|
|
97
|
-
return
|
|
98
|
-
},
|
|
99
|
-
let
|
|
100
|
-
constructor(
|
|
101
|
-
super(), this._config =
|
|
102
|
-
const { ...
|
|
103
|
-
this._configService.setConfig(
|
|
84
|
+
};
|
|
85
|
+
_ = G([
|
|
86
|
+
o(0, h),
|
|
87
|
+
o(1, j),
|
|
88
|
+
o(2, U),
|
|
89
|
+
o(3, I)
|
|
90
|
+
], _);
|
|
91
|
+
var J = Object.defineProperty, y = Object.getOwnPropertyDescriptor, x = (t, r, e, n) => {
|
|
92
|
+
for (var i = n > 1 ? void 0 : n ? y(r, e) : r, s = t.length - 1, a; s >= 0; s--)
|
|
93
|
+
(a = t[s]) && (i = (n ? a(r, e, i) : a(i)) || i);
|
|
94
|
+
return n && i && J(r, e, i), i;
|
|
95
|
+
}, v = (t, r) => (e, n) => r(e, n, t), c;
|
|
96
|
+
let u = (c = class extends P {
|
|
97
|
+
constructor(t = R, r, e) {
|
|
98
|
+
super(), this._config = t, this._injector = r, this._configService = e;
|
|
99
|
+
const { ...n } = this._config;
|
|
100
|
+
this._configService.setConfig(m, n);
|
|
104
101
|
}
|
|
105
102
|
onStarting() {
|
|
106
103
|
[
|
|
107
|
-
[
|
|
108
|
-
[
|
|
109
|
-
[
|
|
110
|
-
].forEach((
|
|
104
|
+
[_],
|
|
105
|
+
[d],
|
|
106
|
+
[h, { useClass: d }]
|
|
107
|
+
].forEach((t) => this._injector.add(t)), this._injector.get(_);
|
|
111
108
|
}
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
],
|
|
109
|
+
}, D(c, "pluginName", f), D(c, "type", g.UNIVER_DOC), c);
|
|
110
|
+
u = x([
|
|
111
|
+
v(1, C(N)),
|
|
112
|
+
v(2, M)
|
|
113
|
+
], u);
|
|
117
114
|
export {
|
|
118
|
-
DOCS_DRAWING_PLUGIN,
|
|
119
|
-
DocDrawingService,
|
|
120
|
-
IDocDrawingService,
|
|
121
|
-
UniverDocsDrawingPlugin
|
|
115
|
+
f as DOCS_DRAWING_PLUGIN,
|
|
116
|
+
d as DocDrawingService,
|
|
117
|
+
h as IDocDrawingService,
|
|
118
|
+
u as UniverDocsDrawingPlugin
|
|
122
119
|
};
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(a,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("@univerjs/core"),require("@univerjs/drawing")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing"],t):(a=typeof globalThis<"u"?globalThis:a||self,t(a.UniverDocsDrawing={},a.UniverCore,a.UniverDrawing))})(this,function(a,t,g){"use strict";var j=Object.defineProperty;var y=(a,t,g)=>t in a?j(a,t,{enumerable:!0,configurable:!0,writable:!0,value:g}):a[t]=g;var h=(a,t,g)=>y(a,typeof t!="symbol"?t+"":t,g);var d;const w="docs-drawing.config",S={};class _ extends g.UnitDrawingService{}const u=t.createIdentifier("univer.doc.plugin.doc-drawing.service");var p=Object.defineProperty,U=Object.getOwnPropertyDescriptor,I=(s,n,e,r)=>{for(var i=r>1?void 0:r?U(n,e):n,o=s.length-1,c;o>=0;o--)(c=s[o])&&(i=(r?c(n,e,i):c(i))||i);return r&&i&&p(n,e,i),i},D=(s,n)=>(e,r)=>n(e,r,s);const f="DOC_DRAWING_PLUGIN";let v=class extends t.Disposable{constructor(s,n,e,r){super(),this._docDrawingService=s,this._drawingManagerService=n,this._resourceManagerService=e,this._univerInstanceService=r,this._init()}_init(){this._initSnapshot()}_initSnapshot(){const s=e=>{const r=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC);if(r){const i=r.getSnapshot().drawings,o=r.getSnapshot().drawingsOrder,c={data:i!=null?i:{},order:o!=null?o:[]};return JSON.stringify(c)}return""},n=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:f,businesses:[t.UniverInstanceType.UNIVER_DOC],toJson:e=>s(e),parseJson:e=>n(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,r)=>{var i,o;this._setDrawingDataForUnit(e,{data:(i=r.data)!=null?i:{},order:(o=r.order)!=null?o:[]})}}))}_setDrawingDataForUnit(s,n){const e=this._univerInstanceService.getUnit(s);e!=null&&(e.resetDrawing(n.data,n.order),this._initDataLoader(s))}_initDataLoader(s){const n=this._univerInstanceService.getUnit(s,t.UniverInstanceType.UNIVER_DOC);if(!n)return!1;const e=s,r=n.getDrawings(),i=n.getDrawingsOrder();if(!r||!i)return!1;Object.keys(r).forEach(c=>{const N=r[c];r[c]={...N}});const o={[e]:{unitId:s,subUnitId:e,data:r,order:i}};return this._docDrawingService.registerDrawingData(s,o),this._drawingManagerService.registerDrawingData(s,o),!0}};v=I([D(0,u),D(1,g.IDrawingManagerService),D(2,t.IResourceManagerService),D(3,t.IUniverInstanceService)],v);var O=Object.defineProperty,P=Object.getOwnPropertyDescriptor,C=(s,n,e,r)=>{for(var i=r>1?void 0:r?P(n,e):n,o=s.length-1,c;o>=0;o--)(c=s[o])&&(i=(r?c(n,e,i):c(i))||i);return r&&i&&O(n,e,i),i},l=(s,n)=>(e,r)=>n(e,r,s);a.UniverDocsDrawingPlugin=(d=class extends t.Plugin{constructor(n=S,e,r){super(),this._config=n,this._injector=e,this._configService=r;const{...i}=this._config;this._configService.setConfig(w,i)}onStarting(){[[v],[_],[u,{useClass:_}]].forEach(n=>this._injector.add(n)),this._injector.get(v)}},h(d,"pluginName",f),h(d,"type",t.UniverInstanceType.UNIVER_DOC),d),a.UniverDocsDrawingPlugin=C([l(1,t.Inject(t.Injector)),l(2,t.IConfigService)],a.UniverDocsDrawingPlugin),a.DOCS_DRAWING_PLUGIN=f,a.DocDrawingService=_,a.IDocDrawingService=u,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs-drawing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-beta.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -31,8 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"./lib/*": "./lib/*"
|
|
33
33
|
},
|
|
34
|
-
"main": "./lib/
|
|
35
|
-
"module": "./lib/es/index.js",
|
|
34
|
+
"main": "./lib/es/index.js",
|
|
36
35
|
"types": "./lib/types/index.d.ts",
|
|
37
36
|
"publishConfig": {
|
|
38
37
|
"access": "public"
|
|
@@ -43,21 +42,17 @@
|
|
|
43
42
|
"files": [
|
|
44
43
|
"lib"
|
|
45
44
|
],
|
|
46
|
-
"peerDependencies": {
|
|
47
|
-
"@univerjs/core": "0.4.2",
|
|
48
|
-
"@univerjs/drawing": "0.4.2"
|
|
49
|
-
},
|
|
50
45
|
"dependencies": {
|
|
51
|
-
"@univerjs/core": "0.
|
|
52
|
-
"@univerjs/drawing": "0.
|
|
46
|
+
"@univerjs/core": "0.5.0-beta.0",
|
|
47
|
+
"@univerjs/drawing": "0.5.0-beta.0"
|
|
53
48
|
},
|
|
54
49
|
"devDependencies": {
|
|
55
50
|
"typescript": "^5.6.3",
|
|
56
|
-
"vite": "^5.4.
|
|
57
|
-
"vitest": "^2.1.
|
|
58
|
-
"@univerjs-infra/shared": "0.
|
|
51
|
+
"vite": "^5.4.11",
|
|
52
|
+
"vitest": "^2.1.5",
|
|
53
|
+
"@univerjs-infra/shared": "0.5.0-beta.0"
|
|
59
54
|
},
|
|
60
|
-
"
|
|
55
|
+
"space": {
|
|
61
56
|
".": {
|
|
62
57
|
"import": "./lib/es/index.js",
|
|
63
58
|
"require": "./lib/cjs/index.js",
|
|
@@ -75,6 +70,7 @@
|
|
|
75
70
|
"test:watch": "vitest",
|
|
76
71
|
"coverage": "vitest run --coverage",
|
|
77
72
|
"lint:types": "tsc --noEmit",
|
|
78
|
-
"build": "
|
|
79
|
-
}
|
|
73
|
+
"build": "univer-cli build"
|
|
74
|
+
},
|
|
75
|
+
"module": "./lib/es/index.js"
|
|
80
76
|
}
|