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