@univerjs/slides 0.6.7 → 0.6.8
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 +736 -0
- package/package.json +4 -4
package/lib/index.js
ADDED
|
@@ -0,0 +1,736 @@
|
|
|
1
|
+
var ye = Object.defineProperty;
|
|
2
|
+
var be = (r, e, i) => e in r ? ye(r, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : r[e] = i;
|
|
3
|
+
var h = (r, e, i) => be(r, typeof e != "symbol" ? e + "" : e, i);
|
|
4
|
+
import { Plugin as me, merge as De, UniverInstanceType as Oe, Inject as H, Injector as G, IConfigService as we, Registry as Ee, LocaleService as ce, PageElementType as Y, DocumentDataModel as Me, getColorStyle as te, BasicShapes as he, sortRules as ke, SlideDataModel as Ve, IContextService as Xe, Styles as je, Worksheet as Re } from "@univerjs/core";
|
|
5
|
+
import { IRenderingEngine as ze, IRenderManagerService as Ae, Liquid as Le, DocumentViewModel as Ne, DocumentSkeleton as He, Documents as We, SceneViewer as _e, Scene as oe, Viewport as C, ScrollBar as ve, Image as Se, PageLayoutType as pe, RichText as Ce, Rect as U, Slide as Ye, SpreadsheetSkeleton as $e, Spreadsheet as Fe, SpreadsheetRowHeader as Ke, SpreadsheetColumnHeader as Be, getColor as ge } from "@univerjs/engine-render";
|
|
6
|
+
const qe = "slides.config", ue = {};
|
|
7
|
+
var Ue = Object.getOwnPropertyDescriptor, Ge = (r, e, i, n) => {
|
|
8
|
+
for (var t = n > 1 ? void 0 : n ? Ue(e, i) : e, a = r.length - 1, s; a >= 0; a--)
|
|
9
|
+
(s = r[a]) && (t = s(t) || t);
|
|
10
|
+
return t;
|
|
11
|
+
}, ee = (r, e) => (i, n) => e(i, n, r);
|
|
12
|
+
const Ze = "slides";
|
|
13
|
+
var q;
|
|
14
|
+
let fe = (q = class extends me {
|
|
15
|
+
// private _canvasView: CanvasView | null = null;
|
|
16
|
+
constructor(e = ue, i, n, t) {
|
|
17
|
+
super();
|
|
18
|
+
h(this, "_canvasEngine", null);
|
|
19
|
+
this._config = e, this._injector = i, this._renderManagerService = n, this._configService = t;
|
|
20
|
+
const { ...a } = De(
|
|
21
|
+
{},
|
|
22
|
+
ue,
|
|
23
|
+
this._config
|
|
24
|
+
);
|
|
25
|
+
this._configService.setConfig(qe, a), this._initializeDependencies(this._injector);
|
|
26
|
+
}
|
|
27
|
+
initialize() {
|
|
28
|
+
this.initCanvasEngine();
|
|
29
|
+
}
|
|
30
|
+
onReady() {
|
|
31
|
+
}
|
|
32
|
+
getConfig() {
|
|
33
|
+
return this._config;
|
|
34
|
+
}
|
|
35
|
+
initCanvasEngine() {
|
|
36
|
+
this._canvasEngine = this._injector.get(ze);
|
|
37
|
+
}
|
|
38
|
+
onRendered() {
|
|
39
|
+
this.initialize();
|
|
40
|
+
}
|
|
41
|
+
getCanvasEngine() {
|
|
42
|
+
return this._canvasEngine;
|
|
43
|
+
}
|
|
44
|
+
_initializeDependencies(e) {
|
|
45
|
+
[
|
|
46
|
+
// [CanvasView],
|
|
47
|
+
// [DocSelectionManagerService],
|
|
48
|
+
].forEach((n) => {
|
|
49
|
+
e.add(n);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}, h(q, "pluginName", Ze), h(q, "type", Oe.UNIVER_SLIDE), q);
|
|
53
|
+
fe = Ge([
|
|
54
|
+
ee(1, H(G)),
|
|
55
|
+
ee(2, Ae),
|
|
56
|
+
ee(3, we)
|
|
57
|
+
], fe);
|
|
58
|
+
class $ {
|
|
59
|
+
constructor() {
|
|
60
|
+
h(this, "zIndex", 0);
|
|
61
|
+
h(this, "viewKey", null);
|
|
62
|
+
}
|
|
63
|
+
check(e) {
|
|
64
|
+
if (e === this.viewKey)
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
create(e) {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const W = Ee.create();
|
|
71
|
+
var Je = Object.getOwnPropertyDescriptor, Qe = (r, e, i, n) => {
|
|
72
|
+
for (var t = n > 1 ? void 0 : n ? Je(e, i) : e, a = r.length - 1, s; a >= 0; a--)
|
|
73
|
+
(s = r[a]) && (t = s(t) || t);
|
|
74
|
+
return t;
|
|
75
|
+
}, et = (r, e) => (i, n) => e(i, n, r);
|
|
76
|
+
let re = class extends $ {
|
|
77
|
+
constructor(e) {
|
|
78
|
+
super();
|
|
79
|
+
h(this, "zIndex", 5);
|
|
80
|
+
h(this, "viewKey", Y.DOCUMENT);
|
|
81
|
+
h(this, "_liquid", new Le());
|
|
82
|
+
this._localeService = e;
|
|
83
|
+
}
|
|
84
|
+
check(e) {
|
|
85
|
+
if (e === this.viewKey)
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
// eslint-disable-next-line max-lines-per-function
|
|
89
|
+
convert(e, i) {
|
|
90
|
+
var le, de;
|
|
91
|
+
const {
|
|
92
|
+
id: n,
|
|
93
|
+
zIndex: t,
|
|
94
|
+
left: a = 0,
|
|
95
|
+
top: s = 0,
|
|
96
|
+
width: o,
|
|
97
|
+
height: c,
|
|
98
|
+
angle: _,
|
|
99
|
+
scaleX: v,
|
|
100
|
+
scaleY: g,
|
|
101
|
+
skewX: l,
|
|
102
|
+
skewY: d,
|
|
103
|
+
flipX: w,
|
|
104
|
+
flipY: u,
|
|
105
|
+
title: D,
|
|
106
|
+
description: V,
|
|
107
|
+
document: P
|
|
108
|
+
} = e;
|
|
109
|
+
if (P == null)
|
|
110
|
+
return;
|
|
111
|
+
const x = new Me(P), p = new Ne(x), S = He.create(p, this._localeService), I = new We("__DocsRender__", S);
|
|
112
|
+
S.calculate();
|
|
113
|
+
const y = new _e("__DocsViewer__" + n, {
|
|
114
|
+
top: s,
|
|
115
|
+
left: a,
|
|
116
|
+
width: o,
|
|
117
|
+
height: c,
|
|
118
|
+
zIndex: t,
|
|
119
|
+
angle: _,
|
|
120
|
+
scaleX: v,
|
|
121
|
+
scaleY: g,
|
|
122
|
+
skewX: l,
|
|
123
|
+
skewY: d,
|
|
124
|
+
flipX: w,
|
|
125
|
+
flipY: u
|
|
126
|
+
}), f = new oe("__DocsScene__" + n, y), T = new C("__DocsViewPort_" + n, f, {
|
|
127
|
+
left: 0,
|
|
128
|
+
top: 0,
|
|
129
|
+
bottom: 0,
|
|
130
|
+
right: 0,
|
|
131
|
+
explicitViewportWidthSet: !1,
|
|
132
|
+
explicitViewportHeightSet: !1,
|
|
133
|
+
isWheelPreventDefaultX: !0
|
|
134
|
+
});
|
|
135
|
+
f.attachControl(), f.onMouseWheel$.subscribeEvent((E, N) => {
|
|
136
|
+
const m = E;
|
|
137
|
+
if (m.ctrlKey) {
|
|
138
|
+
const j = Math.abs(m.deltaX);
|
|
139
|
+
let M = j < 40 ? 0.2 : j < 80 ? 0.4 : 0.2;
|
|
140
|
+
M *= m.deltaY > 0 ? -1 : 1, f.scaleX < 1 && (M /= 2), f.scaleX + M > 4 ? f.scale(4, 4) : f.scaleX + M < 0.1 ? f.scale(0.1, 0.1) : (m.deltaY > 0, m.preventDefault());
|
|
141
|
+
} else
|
|
142
|
+
T.onMouseWheel(m, N);
|
|
143
|
+
}), new ve(T, {
|
|
144
|
+
mainScene: i
|
|
145
|
+
}), f.addObject(I);
|
|
146
|
+
const b = S.getActualSize();
|
|
147
|
+
I.resize(b.actualWidth, b.actualHeight), f.resize(b.actualWidth, b.actualHeight + 200), (le = I.getSkeleton()) == null || le.getPageSize(), I.pageRender$.subscribe((E) => {
|
|
148
|
+
const { page: N, pageLeft: m, pageTop: j, ctx: M } = E, { width: Z, height: J, marginBottom: Q, marginLeft: k, marginRight: F, marginTop: K } = N;
|
|
149
|
+
M.save(), M.translate(m - 0.5, j - 0.5), M.restore();
|
|
150
|
+
});
|
|
151
|
+
const { left: X, top: R } = I, A = S.getSkeletonData();
|
|
152
|
+
if (A == null)
|
|
153
|
+
return;
|
|
154
|
+
const { pages: L } = A, O = [], z = /* @__PURE__ */ new Map();
|
|
155
|
+
this._recalculateSizeBySkeleton(I, f, S);
|
|
156
|
+
for (let E = 0, N = L.length; E < N; E++) {
|
|
157
|
+
const m = L[E], { skeDrawings: j, marginLeft: M, marginTop: Z, pageWidth: J, pageHeight: Q } = m;
|
|
158
|
+
this._liquid.translatePagePadding(m), j.forEach((k) => {
|
|
159
|
+
const { aLeft: F, aTop: K, height: Ie, width: xe, drawingOrigin: Te } = k, { docTransform: Tt } = Te, Pe = new Se(k.drawingId, {
|
|
160
|
+
// url: docTransform.imageProperties?.contentUrl || '',
|
|
161
|
+
left: F + X + this._liquid.x,
|
|
162
|
+
top: K + R + this._liquid.y,
|
|
163
|
+
width: xe,
|
|
164
|
+
height: Ie,
|
|
165
|
+
zIndex: 11
|
|
166
|
+
});
|
|
167
|
+
z.set(k.drawingId, {
|
|
168
|
+
marginLeft: this._liquid.x,
|
|
169
|
+
marginTop: this._liquid.y
|
|
170
|
+
}), O.push(Pe);
|
|
171
|
+
}), this._liquid.translatePage(
|
|
172
|
+
m,
|
|
173
|
+
I.pageLayoutType,
|
|
174
|
+
I.pageMarginLeft,
|
|
175
|
+
I.pageMarginTop
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
return f.addObjects(O), O.forEach((E) => {
|
|
179
|
+
f.attachTransformerTo(E);
|
|
180
|
+
}), (de = f.getTransformer()) == null || de.changing$.subscribe((E) => {
|
|
181
|
+
const { objects: N } = E;
|
|
182
|
+
N.forEach((m) => {
|
|
183
|
+
const { oKey: j, left: M, top: Z, height: J, width: Q } = m, k = z.get(j), F = (k == null ? void 0 : k.marginLeft) || 0, K = (k == null ? void 0 : k.marginTop) || 0;
|
|
184
|
+
S == null || S.getViewModel().getDataModel().updateDrawing(j, {
|
|
185
|
+
left: M - X - F,
|
|
186
|
+
top: Z - R - K,
|
|
187
|
+
height: J,
|
|
188
|
+
width: Q
|
|
189
|
+
});
|
|
190
|
+
}), S == null || S.calculate();
|
|
191
|
+
}), this._calculatePagePosition(I, f, T), y;
|
|
192
|
+
}
|
|
193
|
+
_recalculateSizeBySkeleton(e, i, n) {
|
|
194
|
+
var o;
|
|
195
|
+
const t = (o = n.getSkeletonData()) == null ? void 0 : o.pages;
|
|
196
|
+
if (t == null)
|
|
197
|
+
return;
|
|
198
|
+
let a = 0, s = 0;
|
|
199
|
+
for (let c = 0, _ = t.length; c < _; c++) {
|
|
200
|
+
const v = t[c], { pageWidth: g, pageHeight: l } = v;
|
|
201
|
+
e.pageLayoutType === pe.VERTICAL ? (s += l, s += e.pageMarginTop, c === _ - 1 && (s += e.pageMarginTop), a = Math.max(a, g)) : e.pageLayoutType === pe.HORIZONTAL && (a += g, c !== _ - 1 && (a += e.pageMarginLeft), s = Math.max(s, l));
|
|
202
|
+
}
|
|
203
|
+
e.resize(a, s), i.resize(a, s);
|
|
204
|
+
}
|
|
205
|
+
_calculatePagePosition(e, i, n, t = 1) {
|
|
206
|
+
const a = i == null ? void 0 : i.getParent(), { width: s, height: o, pageMarginLeft: c, pageMarginTop: _ } = e;
|
|
207
|
+
if (a == null || s === Number.POSITIVE_INFINITY || o === Number.POSITIVE_INFINITY)
|
|
208
|
+
return;
|
|
209
|
+
const { width: v, height: g } = a;
|
|
210
|
+
let l = 0, d = 0, w = 0, u = 0, D = Number.POSITIVE_INFINITY;
|
|
211
|
+
if (v > (s + c * 2) * t ? (l = v / 2 - s * t / 2, l /= t, w = (v - c * 2) / t, D = 0) : (l = c, w = s + c * 2, D = (w - v / t) / 2), g > o ? (d = g / 2 - o / 2, u = (g - _ * 2) / t) : (d = _, u = o + _ * 2), i.resize(w, u + 200), e.translate(l, d), D !== Number.POSITIVE_INFINITY && n != null) {
|
|
212
|
+
const V = n.transScroll2ViewportScrollValue(D, 0).x;
|
|
213
|
+
n.scrollToBarPos({
|
|
214
|
+
x: V
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
return this;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
re = Qe([
|
|
221
|
+
et(0, H(ce))
|
|
222
|
+
], re);
|
|
223
|
+
class tt {
|
|
224
|
+
constructor() {
|
|
225
|
+
h(this, "zIndex", 5);
|
|
226
|
+
}
|
|
227
|
+
create(e) {
|
|
228
|
+
return e.createInstance(re);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
W.add(new tt());
|
|
232
|
+
class rt extends $ {
|
|
233
|
+
constructor() {
|
|
234
|
+
super(...arguments);
|
|
235
|
+
h(this, "zIndex", 1);
|
|
236
|
+
h(this, "viewKey", Y.IMAGE);
|
|
237
|
+
}
|
|
238
|
+
check(i) {
|
|
239
|
+
if (i === this.viewKey)
|
|
240
|
+
return this;
|
|
241
|
+
}
|
|
242
|
+
convert(i) {
|
|
243
|
+
const {
|
|
244
|
+
id: n,
|
|
245
|
+
zIndex: t,
|
|
246
|
+
left: a = 0,
|
|
247
|
+
top: s = 0,
|
|
248
|
+
width: o,
|
|
249
|
+
height: c,
|
|
250
|
+
angle: _,
|
|
251
|
+
scaleX: v,
|
|
252
|
+
scaleY: g,
|
|
253
|
+
skewX: l,
|
|
254
|
+
skewY: d,
|
|
255
|
+
flipX: w,
|
|
256
|
+
flipY: u,
|
|
257
|
+
title: D,
|
|
258
|
+
description: V,
|
|
259
|
+
image: P = {}
|
|
260
|
+
} = i, { imageProperties: x, placeholder: p, link: S } = P, I = (x == null ? void 0 : x.contentUrl) || "";
|
|
261
|
+
return new Se(n, {
|
|
262
|
+
url: I,
|
|
263
|
+
top: s,
|
|
264
|
+
left: a,
|
|
265
|
+
width: o,
|
|
266
|
+
height: c,
|
|
267
|
+
zIndex: t,
|
|
268
|
+
angle: _,
|
|
269
|
+
scaleX: v,
|
|
270
|
+
scaleY: g,
|
|
271
|
+
skewX: l,
|
|
272
|
+
skewY: d,
|
|
273
|
+
flipX: w,
|
|
274
|
+
flipY: u,
|
|
275
|
+
forceRender: !0
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
class it {
|
|
280
|
+
constructor() {
|
|
281
|
+
h(this, "zIndex", 4);
|
|
282
|
+
}
|
|
283
|
+
create(e) {
|
|
284
|
+
return e.createInstance(rt);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
W.add(new it());
|
|
288
|
+
var nt = Object.getOwnPropertyDescriptor, at = (r, e, i, n) => {
|
|
289
|
+
for (var t = n > 1 ? void 0 : n ? nt(e, i) : e, a = r.length - 1, s; a >= 0; a--)
|
|
290
|
+
(s = r[a]) && (t = s(t) || t);
|
|
291
|
+
return t;
|
|
292
|
+
}, st = (r, e) => (i, n) => e(i, n, r);
|
|
293
|
+
let ie = class extends $ {
|
|
294
|
+
constructor(e) {
|
|
295
|
+
super();
|
|
296
|
+
h(this, "zIndex", 2);
|
|
297
|
+
h(this, "viewKey", Y.TEXT);
|
|
298
|
+
this._localeService = e;
|
|
299
|
+
}
|
|
300
|
+
check(e) {
|
|
301
|
+
if (e === this.viewKey)
|
|
302
|
+
return this;
|
|
303
|
+
}
|
|
304
|
+
convert(e, i) {
|
|
305
|
+
const {
|
|
306
|
+
id: n,
|
|
307
|
+
zIndex: t,
|
|
308
|
+
left: a = 0,
|
|
309
|
+
top: s = 0,
|
|
310
|
+
width: o,
|
|
311
|
+
height: c,
|
|
312
|
+
angle: _,
|
|
313
|
+
scaleX: v,
|
|
314
|
+
scaleY: g,
|
|
315
|
+
skewX: l,
|
|
316
|
+
skewY: d,
|
|
317
|
+
flipX: w,
|
|
318
|
+
flipY: u,
|
|
319
|
+
title: D,
|
|
320
|
+
description: V,
|
|
321
|
+
richText: P = {}
|
|
322
|
+
} = e, { text: x, ff: p, fs: S, it: I, bl: y, ul: f, st: T, ol: b, bg: X, bd: R, cl: A, rich: L } = P;
|
|
323
|
+
let O = {
|
|
324
|
+
top: s,
|
|
325
|
+
left: a,
|
|
326
|
+
width: o,
|
|
327
|
+
height: c,
|
|
328
|
+
zIndex: t,
|
|
329
|
+
angle: _,
|
|
330
|
+
scaleX: v,
|
|
331
|
+
scaleY: g,
|
|
332
|
+
skewX: l,
|
|
333
|
+
skewY: d,
|
|
334
|
+
flipX: w,
|
|
335
|
+
flipY: u,
|
|
336
|
+
forceRender: !0
|
|
337
|
+
}, z = !1;
|
|
338
|
+
if (x != null ? (O = { ...O, text: x, ff: p, fs: S, it: I, bl: y, ul: f, st: T, ol: b, bg: X, bd: R, cl: A }, z = !0) : L != null && (O = { ...O, richText: L }, z = !0), z !== !1)
|
|
339
|
+
return new Ce(this._localeService, n, O);
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
ie = at([
|
|
343
|
+
st(0, H(ce))
|
|
344
|
+
], ie);
|
|
345
|
+
class ct {
|
|
346
|
+
constructor() {
|
|
347
|
+
h(this, "zIndex", 0);
|
|
348
|
+
}
|
|
349
|
+
create(e) {
|
|
350
|
+
return e.createInstance(ie);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
W.add(new ct());
|
|
354
|
+
class ot extends $ {
|
|
355
|
+
constructor() {
|
|
356
|
+
super(...arguments);
|
|
357
|
+
h(this, "zIndex", 2);
|
|
358
|
+
h(this, "viewKey", Y.SHAPE);
|
|
359
|
+
}
|
|
360
|
+
check(i) {
|
|
361
|
+
if (i === this.viewKey)
|
|
362
|
+
return this;
|
|
363
|
+
}
|
|
364
|
+
convert(i) {
|
|
365
|
+
const {
|
|
366
|
+
id: n,
|
|
367
|
+
zIndex: t,
|
|
368
|
+
left: a = 0,
|
|
369
|
+
top: s = 0,
|
|
370
|
+
width: o,
|
|
371
|
+
height: c,
|
|
372
|
+
angle: _,
|
|
373
|
+
scaleX: v,
|
|
374
|
+
scaleY: g,
|
|
375
|
+
skewX: l,
|
|
376
|
+
skewY: d,
|
|
377
|
+
flipX: w,
|
|
378
|
+
flipY: u,
|
|
379
|
+
title: D,
|
|
380
|
+
description: V
|
|
381
|
+
} = i, { shapeType: P, text: x, shapeProperties: p, placeholder: S, link: I } = i.shape || {}, y = p == null ? "" : te(p.shapeBackgroundFill) || "rgba(255,255,255,1)", f = p == null ? void 0 : p.outline, T = {};
|
|
382
|
+
if (f) {
|
|
383
|
+
const { outlineFill: b, weight: X } = f;
|
|
384
|
+
T.strokeWidth = X, T.stroke = te(b) || "rgba(0,0,0,1)";
|
|
385
|
+
}
|
|
386
|
+
if (P === he.Rect)
|
|
387
|
+
return new U(n, {
|
|
388
|
+
fill: y,
|
|
389
|
+
top: s,
|
|
390
|
+
left: a,
|
|
391
|
+
width: o,
|
|
392
|
+
height: c,
|
|
393
|
+
zIndex: t,
|
|
394
|
+
angle: _,
|
|
395
|
+
scaleX: v,
|
|
396
|
+
scaleY: g,
|
|
397
|
+
skewX: l,
|
|
398
|
+
skewY: d,
|
|
399
|
+
flipX: w,
|
|
400
|
+
flipY: u,
|
|
401
|
+
forceRender: !0,
|
|
402
|
+
...T
|
|
403
|
+
});
|
|
404
|
+
if (P === he.RoundRect) {
|
|
405
|
+
const b = (p == null ? void 0 : p.radius) || 0;
|
|
406
|
+
return new U(n, {
|
|
407
|
+
fill: y,
|
|
408
|
+
top: s,
|
|
409
|
+
left: a,
|
|
410
|
+
width: o,
|
|
411
|
+
height: c,
|
|
412
|
+
zIndex: t,
|
|
413
|
+
angle: _,
|
|
414
|
+
scaleX: v,
|
|
415
|
+
scaleY: g,
|
|
416
|
+
skewX: l,
|
|
417
|
+
skewY: d,
|
|
418
|
+
flipX: w,
|
|
419
|
+
flipY: u,
|
|
420
|
+
forceRender: !0,
|
|
421
|
+
radius: b,
|
|
422
|
+
...T
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
class lt {
|
|
428
|
+
constructor() {
|
|
429
|
+
h(this, "zIndex", 2);
|
|
430
|
+
}
|
|
431
|
+
create(e) {
|
|
432
|
+
return e.createInstance(ot);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
W.add(new lt());
|
|
436
|
+
var dt = Object.getOwnPropertyDescriptor, ht = (r, e, i, n) => {
|
|
437
|
+
for (var t = n > 1 ? void 0 : n ? dt(e, i) : e, a = r.length - 1, s; a >= 0; a--)
|
|
438
|
+
(s = r[a]) && (t = s(t) || t);
|
|
439
|
+
return t;
|
|
440
|
+
}, pt = (r, e) => (i, n) => e(i, n, r);
|
|
441
|
+
let ne = class {
|
|
442
|
+
constructor(r) {
|
|
443
|
+
h(this, "_adaptors", []);
|
|
444
|
+
this._injector = r, this._adaptorLoader();
|
|
445
|
+
}
|
|
446
|
+
convertToRenderObjects(r, e) {
|
|
447
|
+
const i = Object.keys(r), n = [];
|
|
448
|
+
return i.forEach((t) => {
|
|
449
|
+
const a = r[t], s = this._executor(a, e);
|
|
450
|
+
s != null && n.push(s);
|
|
451
|
+
}), n;
|
|
452
|
+
}
|
|
453
|
+
convertToRenderObject(r, e) {
|
|
454
|
+
return this._executor(r, e);
|
|
455
|
+
}
|
|
456
|
+
_executor(r, e) {
|
|
457
|
+
var t;
|
|
458
|
+
const { id: i, type: n } = r;
|
|
459
|
+
for (const a of this._adaptors) {
|
|
460
|
+
const s = (t = a.check(n)) == null ? void 0 : t.convert(r, e);
|
|
461
|
+
if (s != null)
|
|
462
|
+
return s;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
_adaptorLoader() {
|
|
466
|
+
W.getData().sort(ke).forEach((r) => {
|
|
467
|
+
this._adaptors.push(r.create(this._injector));
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
ne = ht([
|
|
472
|
+
pt(0, H(G))
|
|
473
|
+
], ne);
|
|
474
|
+
var gt = Object.getOwnPropertyDescriptor, ut = (r, e, i, n) => {
|
|
475
|
+
for (var t = n > 1 ? void 0 : n ? gt(e, i) : e, a = r.length - 1, s; a >= 0; a--)
|
|
476
|
+
(s = r[a]) && (t = s(t) || t);
|
|
477
|
+
return t;
|
|
478
|
+
}, ft = (r, e) => (i, n) => e(i, n, r), wt = /* @__PURE__ */ ((r) => (r.MAIN = "__SLIDERender__", r.SCENE_VIEWER = "__SLIDEViewer__", r.SCENE = "__SLIDEScene__", r.VIEWPORT = "__SLIDEViewPort_", r))(wt || {});
|
|
479
|
+
let ae = class extends $ {
|
|
480
|
+
constructor(e) {
|
|
481
|
+
super();
|
|
482
|
+
h(this, "zIndex", 6);
|
|
483
|
+
h(this, "viewKey", Y.SLIDE);
|
|
484
|
+
h(this, "_ObjectProvider", null);
|
|
485
|
+
this._injector = e;
|
|
486
|
+
}
|
|
487
|
+
check(e) {
|
|
488
|
+
if (e === this.viewKey)
|
|
489
|
+
return this;
|
|
490
|
+
}
|
|
491
|
+
convert(e, i) {
|
|
492
|
+
const {
|
|
493
|
+
id: n,
|
|
494
|
+
zIndex: t,
|
|
495
|
+
left: a = 0,
|
|
496
|
+
top: s = 0,
|
|
497
|
+
width: o,
|
|
498
|
+
height: c,
|
|
499
|
+
angle: _,
|
|
500
|
+
scaleX: v,
|
|
501
|
+
scaleY: g,
|
|
502
|
+
skewX: l,
|
|
503
|
+
skewY: d,
|
|
504
|
+
flipX: w,
|
|
505
|
+
flipY: u,
|
|
506
|
+
title: D,
|
|
507
|
+
description: V,
|
|
508
|
+
slide: P
|
|
509
|
+
} = e;
|
|
510
|
+
if (P == null)
|
|
511
|
+
return;
|
|
512
|
+
const x = new Ve(P), p = new Ye("__SLIDERender__" + n, {
|
|
513
|
+
top: s,
|
|
514
|
+
left: a,
|
|
515
|
+
width: o,
|
|
516
|
+
height: c,
|
|
517
|
+
zIndex: t,
|
|
518
|
+
angle: _,
|
|
519
|
+
scaleX: v,
|
|
520
|
+
scaleY: g,
|
|
521
|
+
skewX: l,
|
|
522
|
+
skewY: d,
|
|
523
|
+
flipX: w,
|
|
524
|
+
flipY: u,
|
|
525
|
+
forceRender: !0
|
|
526
|
+
});
|
|
527
|
+
p.enableNav(), p.enableSelectedClipElement();
|
|
528
|
+
const S = x.getPageOrder(), I = x.getPages();
|
|
529
|
+
if (!S || !I)
|
|
530
|
+
return p;
|
|
531
|
+
this._ObjectProvider = new ne(this._injector);
|
|
532
|
+
for (let y = 0, f = S.length; y < f; y++) {
|
|
533
|
+
const T = I[S[y]], { id: b } = T;
|
|
534
|
+
p.addPageScene(this._createScene(b, p, T, i, x));
|
|
535
|
+
}
|
|
536
|
+
return p.activeFirstPage(), p;
|
|
537
|
+
}
|
|
538
|
+
_createScene(e, i, n, t, a) {
|
|
539
|
+
var d;
|
|
540
|
+
const { width: s, height: o } = i, c = new oe(e, i, {
|
|
541
|
+
width: s,
|
|
542
|
+
height: o
|
|
543
|
+
});
|
|
544
|
+
new C(`PageViewer_${e}`, c, {
|
|
545
|
+
left: 0,
|
|
546
|
+
top: 0,
|
|
547
|
+
bottom: 0,
|
|
548
|
+
right: 0,
|
|
549
|
+
explicitViewportWidthSet: !1,
|
|
550
|
+
explicitViewportHeightSet: !1
|
|
551
|
+
}).closeClip();
|
|
552
|
+
const { pageElements: v, pageBackgroundFill: g } = n, l = (d = this._ObjectProvider) == null ? void 0 : d.convertToRenderObjects(v, t);
|
|
553
|
+
return this._addBackgroundRect(c, g, a), c.addObjects(l), l == null || l.forEach((w) => {
|
|
554
|
+
c.attachTransformerTo(w);
|
|
555
|
+
}), c;
|
|
556
|
+
}
|
|
557
|
+
_addBackgroundRect(e, i, n) {
|
|
558
|
+
const t = n.getPageSize(), { width: a = 0, height: s = 0 } = t, o = new U("canvas", {
|
|
559
|
+
left: 0,
|
|
560
|
+
top: 0,
|
|
561
|
+
width: a,
|
|
562
|
+
height: s,
|
|
563
|
+
strokeWidth: 1,
|
|
564
|
+
stroke: "rgba(198,198,198, 1)",
|
|
565
|
+
fill: te(i) || "rgba(255,255,255, 1)",
|
|
566
|
+
zIndex: 0,
|
|
567
|
+
evented: !1
|
|
568
|
+
});
|
|
569
|
+
e.addObject(o, 0);
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
ae = ut([
|
|
573
|
+
ft(0, H(G))
|
|
574
|
+
], ae);
|
|
575
|
+
class _t {
|
|
576
|
+
constructor() {
|
|
577
|
+
h(this, "zIndex", 6);
|
|
578
|
+
}
|
|
579
|
+
create(e) {
|
|
580
|
+
return e.createInstance(ae);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
W.add(new _t());
|
|
584
|
+
var vt = Object.getOwnPropertyDescriptor, St = (r, e, i, n) => {
|
|
585
|
+
for (var t = n > 1 ? void 0 : n ? vt(e, i) : e, a = r.length - 1, s; a >= 0; a--)
|
|
586
|
+
(s = r[a]) && (t = s(t) || t);
|
|
587
|
+
return t;
|
|
588
|
+
}, B = (r, e) => (i, n) => e(i, n, r);
|
|
589
|
+
let se = class extends $ {
|
|
590
|
+
constructor(e, i, n, t) {
|
|
591
|
+
super();
|
|
592
|
+
h(this, "zIndex", 4);
|
|
593
|
+
h(this, "viewKey", Y.SPREADSHEET);
|
|
594
|
+
this._localeService = e, this._contextService = i, this._configService = n, this._injector = t;
|
|
595
|
+
}
|
|
596
|
+
check(e) {
|
|
597
|
+
if (e === this.viewKey)
|
|
598
|
+
return this;
|
|
599
|
+
}
|
|
600
|
+
convert(e, i) {
|
|
601
|
+
const {
|
|
602
|
+
id: n,
|
|
603
|
+
zIndex: t,
|
|
604
|
+
left: a = 0,
|
|
605
|
+
top: s = 0,
|
|
606
|
+
width: o,
|
|
607
|
+
height: c,
|
|
608
|
+
angle: _,
|
|
609
|
+
scaleX: v,
|
|
610
|
+
scaleY: g,
|
|
611
|
+
skewX: l,
|
|
612
|
+
skewY: d,
|
|
613
|
+
flipX: w,
|
|
614
|
+
flipY: u,
|
|
615
|
+
spreadsheet: D
|
|
616
|
+
} = e;
|
|
617
|
+
if (D == null)
|
|
618
|
+
return;
|
|
619
|
+
const { worksheet: V, styles: P } = D, x = new je(P), p = new $e(
|
|
620
|
+
new Re(n, V, x),
|
|
621
|
+
// FIXME: worksheet in slide doesn't has a Worksheet object
|
|
622
|
+
x,
|
|
623
|
+
this._localeService,
|
|
624
|
+
this._contextService,
|
|
625
|
+
this._configService,
|
|
626
|
+
this._injector
|
|
627
|
+
), { rowTotalHeight: S, columnTotalWidth: I, rowHeaderWidth: y, columnHeaderHeight: f } = p, T = I + V.rowHeader.width || 0, b = S + V.columnHeader.height || 0, X = new _e("spreadInSlideSceneViewer" + n, {
|
|
628
|
+
top: s,
|
|
629
|
+
left: a,
|
|
630
|
+
width: o,
|
|
631
|
+
height: c,
|
|
632
|
+
zIndex: t,
|
|
633
|
+
angle: _,
|
|
634
|
+
scaleX: v,
|
|
635
|
+
scaleY: g,
|
|
636
|
+
skewX: l,
|
|
637
|
+
skewY: d,
|
|
638
|
+
flipX: w,
|
|
639
|
+
flipY: u,
|
|
640
|
+
forceRender: !0
|
|
641
|
+
}), R = new oe("spreadInSlideScene" + n, X, {
|
|
642
|
+
width: T,
|
|
643
|
+
height: b
|
|
644
|
+
});
|
|
645
|
+
this._updateViewport(n, y, f, R, i);
|
|
646
|
+
const A = new Fe("testSheetViewer", p, !1), L = new Ke("spreadInSlideRow", p), O = new Be("spreadInSlideColumn", p), z = new U("spreadInSlideLeftTop", {
|
|
647
|
+
zIndex: 2,
|
|
648
|
+
left: -1,
|
|
649
|
+
top: -1,
|
|
650
|
+
width: y,
|
|
651
|
+
height: f,
|
|
652
|
+
fill: ge([248, 249, 250]),
|
|
653
|
+
stroke: ge([217, 217, 217]),
|
|
654
|
+
strokeWidth: 1
|
|
655
|
+
});
|
|
656
|
+
return A.zIndex = 10, R.addObjects([A], 1), R.addObjects([L, O, z], 2), X;
|
|
657
|
+
}
|
|
658
|
+
// eslint-disable-next-line max-lines-per-function
|
|
659
|
+
_updateViewport(e, i, n, t, a) {
|
|
660
|
+
if (a == null)
|
|
661
|
+
return;
|
|
662
|
+
const s = i * t.scaleX, o = n * t.scaleY, c = new C("spreadInSlideViewMain" + e, t, {
|
|
663
|
+
left: s,
|
|
664
|
+
top: o,
|
|
665
|
+
bottom: 0,
|
|
666
|
+
right: 0,
|
|
667
|
+
explicitViewportWidthSet: !1,
|
|
668
|
+
explicitViewportHeightSet: !1,
|
|
669
|
+
isWheelPreventDefaultX: !0
|
|
670
|
+
}), _ = new C("spreadInSlideViewTop" + e, t, {
|
|
671
|
+
left: s,
|
|
672
|
+
height: o,
|
|
673
|
+
top: 0,
|
|
674
|
+
right: 0,
|
|
675
|
+
explicitViewportWidthSet: !1,
|
|
676
|
+
isWheelPreventDefaultX: !0
|
|
677
|
+
}), v = new C("spreadInSlideViewLeft" + e, t, {
|
|
678
|
+
left: 0,
|
|
679
|
+
bottom: 0,
|
|
680
|
+
top: o,
|
|
681
|
+
width: s,
|
|
682
|
+
explicitViewportHeightSet: !1,
|
|
683
|
+
isWheelPreventDefaultX: !0
|
|
684
|
+
});
|
|
685
|
+
new C("spreadInSlideViewLeftTop" + e, t, {
|
|
686
|
+
left: 0,
|
|
687
|
+
top: 0,
|
|
688
|
+
width: s,
|
|
689
|
+
height: o,
|
|
690
|
+
isWheelPreventDefaultX: !0
|
|
691
|
+
}), c.onScrollAfter$.subscribeEvent((g) => {
|
|
692
|
+
const { scrollX: l, scrollY: d, viewportScrollX: w, viewportScrollY: u } = g;
|
|
693
|
+
_.updateScrollVal({
|
|
694
|
+
scrollX: l,
|
|
695
|
+
viewportScrollX: w
|
|
696
|
+
}), v.updateScrollVal({
|
|
697
|
+
scrollY: d,
|
|
698
|
+
viewportScrollY: u
|
|
699
|
+
});
|
|
700
|
+
}), t.attachControl(), new ve(c, {
|
|
701
|
+
mainScene: a
|
|
702
|
+
}), t.onMouseWheel$.subscribeEvent((g, l) => {
|
|
703
|
+
const d = g;
|
|
704
|
+
if (d.ctrlKey) {
|
|
705
|
+
const w = Math.abs(d.deltaX);
|
|
706
|
+
let u = w < 40 ? 0.05 : w < 80 ? 0.02 : 0.01;
|
|
707
|
+
u *= d.deltaY > 0 ? -1 : 1, t.scaleX < 1 && (u /= 2), t.scaleX + u > 4 ? t.scale(4, 4) : t.scaleX + u < 0.1 ? t.scale(0.1, 0.1) : (t.scaleBy(u, u), d.preventDefault());
|
|
708
|
+
} else
|
|
709
|
+
c.onMouseWheel(d, l);
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
se = St([
|
|
714
|
+
B(0, H(ce)),
|
|
715
|
+
B(1, Xe),
|
|
716
|
+
B(2, we),
|
|
717
|
+
B(3, H(G))
|
|
718
|
+
], se);
|
|
719
|
+
class It {
|
|
720
|
+
constructor() {
|
|
721
|
+
h(this, "zIndex", 4);
|
|
722
|
+
}
|
|
723
|
+
create(e) {
|
|
724
|
+
return e.createInstance(se);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
W.add(new It());
|
|
728
|
+
var xt = /* @__PURE__ */ ((r) => (r.COMPONENT = "__slideRender__", r.SCENE = "__mainScene__", r.VIEW = "__mainView__", r))(xt || {});
|
|
729
|
+
export {
|
|
730
|
+
W as CanvasObjectProviderRegistry,
|
|
731
|
+
$ as ObjectAdaptor,
|
|
732
|
+
ne as ObjectProvider,
|
|
733
|
+
xt as SLIDE_KEY,
|
|
734
|
+
wt as SLIDE_VIEW_KEY,
|
|
735
|
+
fe as UniverSlidesPlugin
|
|
736
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/slides",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"lib"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@univerjs/core": "0.6.
|
|
49
|
-
"@univerjs/engine-render": "0.6.
|
|
48
|
+
"@univerjs/core": "0.6.8",
|
|
49
|
+
"@univerjs/engine-render": "0.6.8"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"typescript": "^5.8.2",
|
|
53
53
|
"vite": "^6.2.3",
|
|
54
54
|
"vitest": "^3.0.9",
|
|
55
|
-
"@univerjs-infra/shared": "0.6.
|
|
55
|
+
"@univerjs-infra/shared": "0.6.8"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"test": "vitest run",
|