@univerjs/docs-drawing 0.17.0 → 0.18.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 +1 -129
- package/lib/index.js +1 -129
- package/lib/types/controllers/doc-drawing.controller.d.ts +17 -1
- package/lib/types/plugin.d.ts +16 -1
- package/lib/types/services/doc-drawing.service.d.ts +19 -3
- package/lib/umd/index.js +1 -1
- package/package.json +8 -7
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@univerjs/core`),t=require(`@univerjs/drawing`);var n=class extends t.UnitDrawingService{};const r=(0,e.createIdentifier)(`univer.doc.plugin.doc-drawing.service`);function i(e,t){return function(n,r){t(n,r,e)}}function a(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}const o=`DOC_DRAWING_PLUGIN`;let s=class extends e.Disposable{constructor(e,t,n,r){super(),this._docDrawingService=e,this._drawingManagerService=t,this._resourceManagerService=n,this._univerInstanceService=r,this._init()}_init(){this._initSnapshot()}_initSnapshot(){let t=t=>{let n=this._univerInstanceService.getUnit(t,e.UniverInstanceType.UNIVER_DOC);if(n){let e=n.getSnapshot().drawings,t=n.getSnapshot().drawingsOrder,r={data:e==null?{}:e,order:t==null?[]:t};return JSON.stringify(r)}return``},n=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:o,businesses:[e.UniverInstanceType.UNIVER_DOC],toJson:e=>t(e),parseJson:e=>n(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{var n,r;this._setDrawingDataForUnit(e,{data:(n=t.data)==null?{}:n,order:(r=t.order)==null?[]:r})}}))}_setDrawingDataForUnit(e,t){let n=this._univerInstanceService.getUnit(e);n!=null&&(n.resetDrawing(t.data,t.order),this.loadDrawingDataForUnit(e))}loadDrawingDataForUnit(t){let n=this._univerInstanceService.getUnit(t,e.UniverInstanceType.UNIVER_DOC);if(!n)return!1;let r=t,i=n.getDrawings(),a=n.getDrawingsOrder();if(!i||!a)return!1;Object.keys(i).forEach(e=>{i[e]={...i[e]}});let o={[r]:{unitId:t,subUnitId:r,data:i,order:a}};return this._docDrawingService.registerDrawingData(t,o),this._drawingManagerService.registerDrawingData(t,o),!0}};s=a([i(0,r),i(1,t.IDrawingManagerService),i(2,e.IResourceManagerService),i(3,e.IUniverInstanceService)],s);var c=`@univerjs/docs-drawing`,l=`0.18.0`;const u=`docs-drawing.config`;Symbol(u);const d={};function f(e){"@babel/helpers - typeof";return f=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},f(e)}function p(e,t){if(f(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(f(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function m(e){var t=p(e,`string`);return f(t)==`symbol`?t:t+``}function h(e,t,n){return(t=m(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let g=class extends e.Plugin{constructor(t=d,n,r){super(),this._config=t,this._injector=n,this._configService=r;let{...i}=(0,e.merge)({},d,this._config);this._configService.setConfig(u,i)}onStarting(){[[s],[n],[r,{useClass:n}]].forEach(e=>this._injector.add(e)),(0,e.touchDependencies)(this._injector,[[s]])}};h(g,`pluginName`,o),h(g,`packageName`,c),h(g,`version`,l),h(g,`type`,e.UniverInstanceType.UNIVER_DOC),g=a([i(1,(0,e.Inject)(e.Injector)),i(2,e.IConfigService)],g),exports.DOCS_DRAWING_PLUGIN=o,Object.defineProperty(exports,`DocDrawingController`,{enumerable:!0,get:function(){return s}}),exports.DocDrawingService=n,exports.IDocDrawingService=r,Object.defineProperty(exports,`UniverDocsDrawingPlugin`,{enumerable:!0,get:function(){return g}});
|
package/lib/es/index.js
CHANGED
|
@@ -1,129 +1 @@
|
|
|
1
|
-
var f = Object.defineProperty;
|
|
2
|
-
var U = (r, t, e) => t in r ? f(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
-
var c = (r, t, e) => U(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import { createIdentifier as I, Disposable as O, UniverInstanceType as D, IResourceManagerService as N, IUniverInstanceService as C, Plugin as P, merge as m, touchDependencies as M, Inject as R, Injector as j, IConfigService as b } from "@univerjs/core";
|
|
5
|
-
import { UnitDrawingService as y, IDrawingManagerService as E } from "@univerjs/drawing";
|
|
6
|
-
class d extends y {
|
|
7
|
-
}
|
|
8
|
-
const w = I("univer.doc.plugin.doc-drawing.service");
|
|
9
|
-
var G = Object.getOwnPropertyDescriptor, F = (r, t, e, n) => {
|
|
10
|
-
for (var i = n > 1 ? void 0 : n ? G(t, e) : t, a = r.length - 1, s; a >= 0; a--)
|
|
11
|
-
(s = r[a]) && (i = s(i) || i);
|
|
12
|
-
return i;
|
|
13
|
-
}, g = (r, t) => (e, n) => t(e, n, r);
|
|
14
|
-
const S = "DOC_DRAWING_PLUGIN";
|
|
15
|
-
let _ = class extends O {
|
|
16
|
-
constructor(r, t, e, n) {
|
|
17
|
-
super(), this._docDrawingService = r, this._drawingManagerService = t, this._resourceManagerService = e, this._univerInstanceService = n, this._init();
|
|
18
|
-
}
|
|
19
|
-
_init() {
|
|
20
|
-
this._initSnapshot();
|
|
21
|
-
}
|
|
22
|
-
_initSnapshot() {
|
|
23
|
-
const r = (e) => {
|
|
24
|
-
const n = this._univerInstanceService.getUnit(e, D.UNIVER_DOC);
|
|
25
|
-
if (n) {
|
|
26
|
-
const i = n.getSnapshot().drawings, a = n.getSnapshot().drawingsOrder, s = {
|
|
27
|
-
data: i != null ? i : {},
|
|
28
|
-
order: a != null ? a : []
|
|
29
|
-
};
|
|
30
|
-
return JSON.stringify(s);
|
|
31
|
-
}
|
|
32
|
-
return "";
|
|
33
|
-
}, t = (e) => {
|
|
34
|
-
if (!e)
|
|
35
|
-
return { data: {}, order: [] };
|
|
36
|
-
try {
|
|
37
|
-
return JSON.parse(e);
|
|
38
|
-
} catch {
|
|
39
|
-
return { data: {}, order: [] };
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
this.disposeWithMe(
|
|
43
|
-
this._resourceManagerService.registerPluginResource({
|
|
44
|
-
pluginName: S,
|
|
45
|
-
businesses: [D.UNIVER_DOC],
|
|
46
|
-
toJson: (e) => r(e),
|
|
47
|
-
parseJson: (e) => t(e),
|
|
48
|
-
onUnLoad: (e) => {
|
|
49
|
-
this._setDrawingDataForUnit(e, { data: {}, order: [] });
|
|
50
|
-
},
|
|
51
|
-
onLoad: (e, n) => {
|
|
52
|
-
var i, a;
|
|
53
|
-
this._setDrawingDataForUnit(e, { data: (i = n.data) != null ? i : {}, order: (a = n.order) != null ? a : [] });
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
_setDrawingDataForUnit(r, t) {
|
|
59
|
-
const e = this._univerInstanceService.getUnit(r);
|
|
60
|
-
e != null && (e.resetDrawing(t.data, t.order), this.loadDrawingDataForUnit(r));
|
|
61
|
-
}
|
|
62
|
-
loadDrawingDataForUnit(r) {
|
|
63
|
-
const t = this._univerInstanceService.getUnit(r, D.UNIVER_DOC);
|
|
64
|
-
if (!t)
|
|
65
|
-
return !1;
|
|
66
|
-
const e = r, n = t.getDrawings(), i = t.getDrawingsOrder();
|
|
67
|
-
if (!n || !i)
|
|
68
|
-
return !1;
|
|
69
|
-
Object.keys(n).forEach((s) => {
|
|
70
|
-
const p = n[s];
|
|
71
|
-
n[s] = { ...p };
|
|
72
|
-
});
|
|
73
|
-
const a = {
|
|
74
|
-
[e]: {
|
|
75
|
-
unitId: r,
|
|
76
|
-
subUnitId: e,
|
|
77
|
-
data: n,
|
|
78
|
-
order: i
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
return this._docDrawingService.registerDrawingData(r, a), this._drawingManagerService.registerDrawingData(r, a), !0;
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
_ = F([
|
|
85
|
-
g(0, w),
|
|
86
|
-
g(1, E),
|
|
87
|
-
g(2, N),
|
|
88
|
-
g(3, C)
|
|
89
|
-
], _);
|
|
90
|
-
const J = "@univerjs/docs-drawing", L = "0.17.0", v = {
|
|
91
|
-
name: J,
|
|
92
|
-
version: L
|
|
93
|
-
}, x = "docs-drawing.config", u = {};
|
|
94
|
-
var V = Object.getOwnPropertyDescriptor, W = (r, t, e, n) => {
|
|
95
|
-
for (var i = n > 1 ? void 0 : n ? V(t, e) : t, a = r.length - 1, s; a >= 0; a--)
|
|
96
|
-
(s = r[a]) && (i = s(i) || i);
|
|
97
|
-
return i;
|
|
98
|
-
}, h = (r, t) => (e, n) => t(e, n, r), o;
|
|
99
|
-
let l = (o = class extends P {
|
|
100
|
-
constructor(r = u, t, e) {
|
|
101
|
-
super(), this._config = r, this._injector = t, this._configService = e;
|
|
102
|
-
const { ...n } = m(
|
|
103
|
-
{},
|
|
104
|
-
u,
|
|
105
|
-
this._config
|
|
106
|
-
);
|
|
107
|
-
this._configService.setConfig(x, n);
|
|
108
|
-
}
|
|
109
|
-
onStarting() {
|
|
110
|
-
[
|
|
111
|
-
[_],
|
|
112
|
-
[d],
|
|
113
|
-
[w, { useClass: d }]
|
|
114
|
-
].forEach((r) => this._injector.add(r)), M(this._injector, [
|
|
115
|
-
[_]
|
|
116
|
-
]);
|
|
117
|
-
}
|
|
118
|
-
}, c(o, "pluginName", S), c(o, "packageName", v.name), c(o, "version", v.version), c(o, "type", D.UNIVER_DOC), o);
|
|
119
|
-
l = W([
|
|
120
|
-
h(1, R(j)),
|
|
121
|
-
h(2, b)
|
|
122
|
-
], l);
|
|
123
|
-
export {
|
|
124
|
-
S as DOCS_DRAWING_PLUGIN,
|
|
125
|
-
_ as DocDrawingController,
|
|
126
|
-
d as DocDrawingService,
|
|
127
|
-
w as IDocDrawingService,
|
|
128
|
-
l as UniverDocsDrawingPlugin
|
|
129
|
-
};
|
|
1
|
+
import{Disposable as e,IConfigService as t,IResourceManagerService as n,IUniverInstanceService as r,Inject as i,Injector as a,Plugin as o,UniverInstanceType as s,createIdentifier as c,merge as l,touchDependencies as u}from"@univerjs/core";import{IDrawingManagerService as d,UnitDrawingService as f}from"@univerjs/drawing";var p=class extends f{};const m=c(`univer.doc.plugin.doc-drawing.service`);function h(e,t){return function(n,r){t(n,r,e)}}function g(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}const _=`DOC_DRAWING_PLUGIN`;let v=class extends e{constructor(e,t,n,r){super(),this._docDrawingService=e,this._drawingManagerService=t,this._resourceManagerService=n,this._univerInstanceService=r,this._init()}_init(){this._initSnapshot()}_initSnapshot(){let e=e=>{let t=this._univerInstanceService.getUnit(e,s.UNIVER_DOC);if(t){let e=t.getSnapshot().drawings,n=t.getSnapshot().drawingsOrder,r={data:e==null?{}:e,order:n==null?[]:n};return JSON.stringify(r)}return``},t=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:_,businesses:[s.UNIVER_DOC],toJson:t=>e(t),parseJson:e=>t(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{var n,r;this._setDrawingDataForUnit(e,{data:(n=t.data)==null?{}:n,order:(r=t.order)==null?[]:r})}}))}_setDrawingDataForUnit(e,t){let n=this._univerInstanceService.getUnit(e);n!=null&&(n.resetDrawing(t.data,t.order),this.loadDrawingDataForUnit(e))}loadDrawingDataForUnit(e){let t=this._univerInstanceService.getUnit(e,s.UNIVER_DOC);if(!t)return!1;let n=e,r=t.getDrawings(),i=t.getDrawingsOrder();if(!r||!i)return!1;Object.keys(r).forEach(e=>{r[e]={...r[e]}});let a={[n]:{unitId:e,subUnitId:n,data:r,order:i}};return this._docDrawingService.registerDrawingData(e,a),this._drawingManagerService.registerDrawingData(e,a),!0}};v=g([h(0,m),h(1,d),h(2,n),h(3,r)],v);var y=`@univerjs/docs-drawing`,b=`0.18.0`;const x=`docs-drawing.config`;Symbol(x);const S={};function C(e){"@babel/helpers - typeof";return C=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},C(e)}function w(e,t){if(C(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(C(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function T(e){var t=w(e,`string`);return C(t)==`symbol`?t:t+``}function E(e,t,n){return(t=T(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let D=class extends o{constructor(e=S,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{...r}=l({},S,this._config);this._configService.setConfig(x,r)}onStarting(){[[v],[p],[m,{useClass:p}]].forEach(e=>this._injector.add(e)),u(this._injector,[[v]])}};E(D,`pluginName`,_),E(D,`packageName`,y),E(D,`version`,b),E(D,`type`,s.UNIVER_DOC),D=g([h(1,i(a)),h(2,t)],D);export{_ as DOCS_DRAWING_PLUGIN,v as DocDrawingController,p as DocDrawingService,m as IDocDrawingService,D as UniverDocsDrawingPlugin};
|
package/lib/index.js
CHANGED
|
@@ -1,129 +1 @@
|
|
|
1
|
-
var f = Object.defineProperty;
|
|
2
|
-
var U = (r, t, e) => t in r ? f(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
-
var c = (r, t, e) => U(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import { createIdentifier as I, Disposable as O, UniverInstanceType as D, IResourceManagerService as N, IUniverInstanceService as C, Plugin as P, merge as m, touchDependencies as M, Inject as R, Injector as j, IConfigService as b } from "@univerjs/core";
|
|
5
|
-
import { UnitDrawingService as y, IDrawingManagerService as E } from "@univerjs/drawing";
|
|
6
|
-
class d extends y {
|
|
7
|
-
}
|
|
8
|
-
const w = I("univer.doc.plugin.doc-drawing.service");
|
|
9
|
-
var G = Object.getOwnPropertyDescriptor, F = (r, t, e, n) => {
|
|
10
|
-
for (var i = n > 1 ? void 0 : n ? G(t, e) : t, a = r.length - 1, s; a >= 0; a--)
|
|
11
|
-
(s = r[a]) && (i = s(i) || i);
|
|
12
|
-
return i;
|
|
13
|
-
}, g = (r, t) => (e, n) => t(e, n, r);
|
|
14
|
-
const S = "DOC_DRAWING_PLUGIN";
|
|
15
|
-
let _ = class extends O {
|
|
16
|
-
constructor(r, t, e, n) {
|
|
17
|
-
super(), this._docDrawingService = r, this._drawingManagerService = t, this._resourceManagerService = e, this._univerInstanceService = n, this._init();
|
|
18
|
-
}
|
|
19
|
-
_init() {
|
|
20
|
-
this._initSnapshot();
|
|
21
|
-
}
|
|
22
|
-
_initSnapshot() {
|
|
23
|
-
const r = (e) => {
|
|
24
|
-
const n = this._univerInstanceService.getUnit(e, D.UNIVER_DOC);
|
|
25
|
-
if (n) {
|
|
26
|
-
const i = n.getSnapshot().drawings, a = n.getSnapshot().drawingsOrder, s = {
|
|
27
|
-
data: i != null ? i : {},
|
|
28
|
-
order: a != null ? a : []
|
|
29
|
-
};
|
|
30
|
-
return JSON.stringify(s);
|
|
31
|
-
}
|
|
32
|
-
return "";
|
|
33
|
-
}, t = (e) => {
|
|
34
|
-
if (!e)
|
|
35
|
-
return { data: {}, order: [] };
|
|
36
|
-
try {
|
|
37
|
-
return JSON.parse(e);
|
|
38
|
-
} catch {
|
|
39
|
-
return { data: {}, order: [] };
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
this.disposeWithMe(
|
|
43
|
-
this._resourceManagerService.registerPluginResource({
|
|
44
|
-
pluginName: S,
|
|
45
|
-
businesses: [D.UNIVER_DOC],
|
|
46
|
-
toJson: (e) => r(e),
|
|
47
|
-
parseJson: (e) => t(e),
|
|
48
|
-
onUnLoad: (e) => {
|
|
49
|
-
this._setDrawingDataForUnit(e, { data: {}, order: [] });
|
|
50
|
-
},
|
|
51
|
-
onLoad: (e, n) => {
|
|
52
|
-
var i, a;
|
|
53
|
-
this._setDrawingDataForUnit(e, { data: (i = n.data) != null ? i : {}, order: (a = n.order) != null ? a : [] });
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
_setDrawingDataForUnit(r, t) {
|
|
59
|
-
const e = this._univerInstanceService.getUnit(r);
|
|
60
|
-
e != null && (e.resetDrawing(t.data, t.order), this.loadDrawingDataForUnit(r));
|
|
61
|
-
}
|
|
62
|
-
loadDrawingDataForUnit(r) {
|
|
63
|
-
const t = this._univerInstanceService.getUnit(r, D.UNIVER_DOC);
|
|
64
|
-
if (!t)
|
|
65
|
-
return !1;
|
|
66
|
-
const e = r, n = t.getDrawings(), i = t.getDrawingsOrder();
|
|
67
|
-
if (!n || !i)
|
|
68
|
-
return !1;
|
|
69
|
-
Object.keys(n).forEach((s) => {
|
|
70
|
-
const p = n[s];
|
|
71
|
-
n[s] = { ...p };
|
|
72
|
-
});
|
|
73
|
-
const a = {
|
|
74
|
-
[e]: {
|
|
75
|
-
unitId: r,
|
|
76
|
-
subUnitId: e,
|
|
77
|
-
data: n,
|
|
78
|
-
order: i
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
return this._docDrawingService.registerDrawingData(r, a), this._drawingManagerService.registerDrawingData(r, a), !0;
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
_ = F([
|
|
85
|
-
g(0, w),
|
|
86
|
-
g(1, E),
|
|
87
|
-
g(2, N),
|
|
88
|
-
g(3, C)
|
|
89
|
-
], _);
|
|
90
|
-
const J = "@univerjs/docs-drawing", L = "0.17.0", v = {
|
|
91
|
-
name: J,
|
|
92
|
-
version: L
|
|
93
|
-
}, x = "docs-drawing.config", u = {};
|
|
94
|
-
var V = Object.getOwnPropertyDescriptor, W = (r, t, e, n) => {
|
|
95
|
-
for (var i = n > 1 ? void 0 : n ? V(t, e) : t, a = r.length - 1, s; a >= 0; a--)
|
|
96
|
-
(s = r[a]) && (i = s(i) || i);
|
|
97
|
-
return i;
|
|
98
|
-
}, h = (r, t) => (e, n) => t(e, n, r), o;
|
|
99
|
-
let l = (o = class extends P {
|
|
100
|
-
constructor(r = u, t, e) {
|
|
101
|
-
super(), this._config = r, this._injector = t, this._configService = e;
|
|
102
|
-
const { ...n } = m(
|
|
103
|
-
{},
|
|
104
|
-
u,
|
|
105
|
-
this._config
|
|
106
|
-
);
|
|
107
|
-
this._configService.setConfig(x, n);
|
|
108
|
-
}
|
|
109
|
-
onStarting() {
|
|
110
|
-
[
|
|
111
|
-
[_],
|
|
112
|
-
[d],
|
|
113
|
-
[w, { useClass: d }]
|
|
114
|
-
].forEach((r) => this._injector.add(r)), M(this._injector, [
|
|
115
|
-
[_]
|
|
116
|
-
]);
|
|
117
|
-
}
|
|
118
|
-
}, c(o, "pluginName", S), c(o, "packageName", v.name), c(o, "version", v.version), c(o, "type", D.UNIVER_DOC), o);
|
|
119
|
-
l = W([
|
|
120
|
-
h(1, R(j)),
|
|
121
|
-
h(2, b)
|
|
122
|
-
], l);
|
|
123
|
-
export {
|
|
124
|
-
S as DOCS_DRAWING_PLUGIN,
|
|
125
|
-
_ as DocDrawingController,
|
|
126
|
-
d as DocDrawingService,
|
|
127
|
-
w as IDocDrawingService,
|
|
128
|
-
l as UniverDocsDrawingPlugin
|
|
129
|
-
};
|
|
1
|
+
import{Disposable as e,IConfigService as t,IResourceManagerService as n,IUniverInstanceService as r,Inject as i,Injector as a,Plugin as o,UniverInstanceType as s,createIdentifier as c,merge as l,touchDependencies as u}from"@univerjs/core";import{IDrawingManagerService as d,UnitDrawingService as f}from"@univerjs/drawing";var p=class extends f{};const m=c(`univer.doc.plugin.doc-drawing.service`);function h(e,t){return function(n,r){t(n,r,e)}}function g(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}const _=`DOC_DRAWING_PLUGIN`;let v=class extends e{constructor(e,t,n,r){super(),this._docDrawingService=e,this._drawingManagerService=t,this._resourceManagerService=n,this._univerInstanceService=r,this._init()}_init(){this._initSnapshot()}_initSnapshot(){let e=e=>{let t=this._univerInstanceService.getUnit(e,s.UNIVER_DOC);if(t){let e=t.getSnapshot().drawings,n=t.getSnapshot().drawingsOrder,r={data:e==null?{}:e,order:n==null?[]:n};return JSON.stringify(r)}return``},t=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:_,businesses:[s.UNIVER_DOC],toJson:t=>e(t),parseJson:e=>t(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{var n,r;this._setDrawingDataForUnit(e,{data:(n=t.data)==null?{}:n,order:(r=t.order)==null?[]:r})}}))}_setDrawingDataForUnit(e,t){let n=this._univerInstanceService.getUnit(e);n!=null&&(n.resetDrawing(t.data,t.order),this.loadDrawingDataForUnit(e))}loadDrawingDataForUnit(e){let t=this._univerInstanceService.getUnit(e,s.UNIVER_DOC);if(!t)return!1;let n=e,r=t.getDrawings(),i=t.getDrawingsOrder();if(!r||!i)return!1;Object.keys(r).forEach(e=>{r[e]={...r[e]}});let a={[n]:{unitId:e,subUnitId:n,data:r,order:i}};return this._docDrawingService.registerDrawingData(e,a),this._drawingManagerService.registerDrawingData(e,a),!0}};v=g([h(0,m),h(1,d),h(2,n),h(3,r)],v);var y=`@univerjs/docs-drawing`,b=`0.18.0`;const x=`docs-drawing.config`;Symbol(x);const S={};function C(e){"@babel/helpers - typeof";return C=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},C(e)}function w(e,t){if(C(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(C(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function T(e){var t=w(e,`string`);return C(t)==`symbol`?t:t+``}function E(e,t,n){return(t=T(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let D=class extends o{constructor(e=S,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{...r}=l({},S,this._config);this._configService.setConfig(x,r)}onStarting(){[[v],[p],[m,{useClass:p}]].forEach(e=>this._injector.add(e)),u(this._injector,[[v]])}};E(D,`pluginName`,_),E(D,`packageName`,y),E(D,`version`,b),E(D,`type`,s.UNIVER_DOC),D=g([h(1,i(a)),h(2,t)],D);export{_ as DOCS_DRAWING_PLUGIN,v as DocDrawingController,p as DocDrawingService,m as IDocDrawingService,D as UniverDocsDrawingPlugin};
|
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { IDocumentData } from '@univerjs/core';
|
|
17
|
+
import { Disposable, IResourceManagerService, IUniverInstanceService } from '@univerjs/core';
|
|
2
18
|
import { IDrawingManagerService } from '@univerjs/drawing';
|
|
3
19
|
import { IDocDrawingService } from '../services/doc-drawing.service';
|
|
4
20
|
export declare const DOCS_DRAWING_PLUGIN = "DOC_DRAWING_PLUGIN";
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { IUniverDocsDrawingConfig } from './config/config';
|
|
2
17
|
import { IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
3
18
|
export declare class UniverDocsDrawingPlugin extends Plugin {
|
|
4
19
|
private readonly _config;
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { IDocDrawingBase } from '@univerjs/core';
|
|
17
|
+
import type { IDocFloatDomData, IImageData, IUnitDrawingService } from '@univerjs/drawing';
|
|
18
|
+
import { UnitDrawingService } from '@univerjs/drawing';
|
|
3
19
|
export interface IDocImage extends IImageData, IDocDrawingBase {
|
|
4
20
|
}
|
|
5
21
|
/**
|
|
@@ -16,5 +32,5 @@ export declare class DocDrawingService extends UnitDrawingService<IDocDrawing> {
|
|
|
16
32
|
}
|
|
17
33
|
export interface IDocDrawingService extends IUnitDrawingService<IDocDrawing> {
|
|
18
34
|
}
|
|
19
|
-
export declare const IDocDrawingService: import(
|
|
35
|
+
export declare const IDocDrawingService: import("@wendellhu/redi").IdentifierDecorator<IDocDrawingService>;
|
|
20
36
|
export {};
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(t
|
|
1
|
+
(function(e,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):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocsDrawing={},e.UniverCore,e.UniverDrawing))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=class extends n.UnitDrawingService{};let i=(0,t.createIdentifier)(`univer.doc.plugin.doc-drawing.service`);function a(e,t){return function(n,r){t(n,r,e)}}function o(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let s=`DOC_DRAWING_PLUGIN`,c=class extends t.Disposable{constructor(e,t,n,r){super(),this._docDrawingService=e,this._drawingManagerService=t,this._resourceManagerService=n,this._univerInstanceService=r,this._init()}_init(){this._initSnapshot()}_initSnapshot(){let e=e=>{let n=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC);if(n){let e=n.getSnapshot().drawings,t=n.getSnapshot().drawingsOrder,r={data:e==null?{}:e,order:t==null?[]:t};return JSON.stringify(r)}return``},n=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:s,businesses:[t.UniverInstanceType.UNIVER_DOC],toJson:t=>e(t),parseJson:e=>n(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{var n,r;this._setDrawingDataForUnit(e,{data:(n=t.data)==null?{}:n,order:(r=t.order)==null?[]:r})}}))}_setDrawingDataForUnit(e,t){let n=this._univerInstanceService.getUnit(e);n!=null&&(n.resetDrawing(t.data,t.order),this.loadDrawingDataForUnit(e))}loadDrawingDataForUnit(e){let n=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC);if(!n)return!1;let r=e,i=n.getDrawings(),a=n.getDrawingsOrder();if(!i||!a)return!1;Object.keys(i).forEach(e=>{i[e]={...i[e]}});let o={[r]:{unitId:e,subUnitId:r,data:i,order:a}};return this._docDrawingService.registerDrawingData(e,o),this._drawingManagerService.registerDrawingData(e,o),!0}};c=o([a(0,i),a(1,n.IDrawingManagerService),a(2,t.IResourceManagerService),a(3,t.IUniverInstanceService)],c);var l=`@univerjs/docs-drawing`,u=`0.18.0`;let d=`docs-drawing.config`;Symbol(d);let f={};function p(e){"@babel/helpers - typeof";return p=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},p(e)}function m(e,t){if(p(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(p(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function h(e){var t=m(e,`string`);return p(t)==`symbol`?t:t+``}function g(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let _=class extends t.Plugin{constructor(e=f,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},f,this._config);this._configService.setConfig(d,i)}onStarting(){[[c],[r],[i,{useClass:r}]].forEach(e=>this._injector.add(e)),(0,t.touchDependencies)(this._injector,[[c]])}};g(_,`pluginName`,s),g(_,`packageName`,l),g(_,`version`,u),g(_,`type`,t.UniverInstanceType.UNIVER_DOC),_=o([a(1,(0,t.Inject)(t.Injector)),a(2,t.IConfigService)],_),e.DOCS_DRAWING_PLUGIN=s,Object.defineProperty(e,`DocDrawingController`,{enumerable:!0,get:function(){return c}}),e.DocDrawingService=r,e.IDocDrawingService=i,Object.defineProperty(e,`UniverDocsDrawingPlugin`,{enumerable:!0,get:function(){return _}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs-drawing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -43,21 +43,22 @@
|
|
|
43
43
|
"lib"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@univerjs/core": "0.
|
|
47
|
-
"@univerjs/drawing": "0.
|
|
46
|
+
"@univerjs/core": "0.18.0",
|
|
47
|
+
"@univerjs/drawing": "0.18.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"typescript": "^5.9.3",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"@univerjs-infra/shared": "0.17.0"
|
|
51
|
+
"vitest": "^4.1.0",
|
|
52
|
+
"@univerjs-infra/shared": "0.18.0"
|
|
54
53
|
},
|
|
55
54
|
"scripts": {
|
|
56
55
|
"test": "vitest run",
|
|
57
56
|
"test:watch": "vitest",
|
|
58
57
|
"coverage": "vitest run --coverage",
|
|
59
58
|
"typecheck": "tsc --noEmit",
|
|
60
|
-
"build": "univer-cli build"
|
|
59
|
+
"build:bundle": "univer-cli build",
|
|
60
|
+
"build:types": "tsc -p tsconfig.node.json",
|
|
61
|
+
"build": "pnpm run build:bundle && pnpm run build:types"
|
|
61
62
|
},
|
|
62
63
|
"module": "./lib/es/index.js"
|
|
63
64
|
}
|