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