@mce/bigesj 0.2.3 → 0.2.5
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/dist/convert/image.d.ts +1 -0
- package/dist/convert/index.d.ts +3 -0
- package/dist/convert/svg.d.ts +1 -0
- package/dist/convert/text.d.ts +1 -1
- package/dist/index.js +493 -317
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function convertImageElementToUrl(el: Record<string, any>): Promise<string>;
|
package/dist/convert/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function convertSvgElementToUrl(el: Record<string, any>): Promise<string>;
|
package/dist/convert/text.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NormalizedTextContent, StyleObject } from 'modern-idoc';
|
|
2
2
|
type BigeElementText = Record<string, any>;
|
|
3
3
|
export declare function convertTextStyle(el: BigeElementText, isByWord?: boolean): Promise<Partial<StyleObject>>;
|
|
4
|
-
export declare function convertTextEffects(el: BigeElementText
|
|
4
|
+
export declare function convertTextEffects(el: BigeElementText): Promise<Partial<StyleObject>[] | undefined>;
|
|
5
5
|
export declare function getTextContents(el: BigeElementText): BigeElementText['contents'];
|
|
6
6
|
export declare function convertTextContent(el: BigeElementText, isByWord?: boolean): Promise<NormalizedTextContent>;
|
|
7
7
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
import { useEditor as
|
|
2
|
-
import { Element2D as
|
|
3
|
-
import { ref as
|
|
4
|
-
import { idGenerator as
|
|
5
|
-
import { gunzipSync as
|
|
6
|
-
const
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
for (let t = 0; t <=
|
|
10
|
-
|
|
1
|
+
import { useEditor as rt, definePlugin as ot } from "mce";
|
|
2
|
+
import { assets as B, Element2D as nt } from "modern-canvas";
|
|
3
|
+
import { ref as Z, effectScope as it, getCurrentScope as ft, onScopeDispose as ct, onBeforeUnmount as lt } from "vue";
|
|
4
|
+
import { idGenerator as U, normalizeCRLF as Mt, isGradient as dt } from "modern-idoc";
|
|
5
|
+
import { gunzipSync as Lt } from "fflate";
|
|
6
|
+
const X = Z([]);
|
|
7
|
+
function wt(e, r) {
|
|
8
|
+
const o = [];
|
|
9
|
+
for (let t = 0; t <= r.length; t++)
|
|
10
|
+
o[t] = [t];
|
|
11
11
|
for (let t = 0; t <= e.length; t++)
|
|
12
|
-
|
|
13
|
-
for (let t = 1; t <=
|
|
14
|
-
for (let
|
|
15
|
-
const
|
|
16
|
-
|
|
12
|
+
o[0][t] = t;
|
|
13
|
+
for (let t = 1; t <= r.length; t++)
|
|
14
|
+
for (let s = 1; s <= e.length; s++) {
|
|
15
|
+
const n = e[s - 1] === r[t - 1] ? 0 : 1;
|
|
16
|
+
o[t][s] = Math.min(o[t - 1][s] + 1, o[t][s - 1] + 1, o[t - 1][s - 1] + n);
|
|
17
17
|
}
|
|
18
|
-
return
|
|
18
|
+
return o[r.length][e.length];
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function mt() {
|
|
21
21
|
const {
|
|
22
22
|
loadFont: e
|
|
23
|
-
} =
|
|
24
|
-
async function n
|
|
25
|
-
let
|
|
26
|
-
return
|
|
23
|
+
} = rt(), r = Z(/* @__PURE__ */ new Map());
|
|
24
|
+
async function o(n) {
|
|
25
|
+
let i = X.value;
|
|
26
|
+
return i.length || (i = await fetch(n).then((f) => f.json()).then((f) => f.data.datalist), X.value = i), i;
|
|
27
27
|
}
|
|
28
|
-
function t(
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
), d =
|
|
32
|
-
let
|
|
33
|
-
if (d.forEach((
|
|
34
|
-
|
|
35
|
-
}),
|
|
36
|
-
let
|
|
37
|
-
d.forEach((
|
|
38
|
-
let
|
|
39
|
-
|
|
40
|
-
const w =
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
if (w <=
|
|
28
|
+
function t(n, i = X.value) {
|
|
29
|
+
const f = new Map(i.map((a, l) => [a.id, l])), M = new Map(
|
|
30
|
+
i.flatMap((a, l) => [...a.en_name.split(","), ...a.name.split(",")].map((L) => [L, l]))
|
|
31
|
+
), d = n.replace(/"/g, "").split(",");
|
|
32
|
+
let c;
|
|
33
|
+
if (d.forEach((a) => {
|
|
34
|
+
c ??= f.get(a), c ??= M.get(a);
|
|
35
|
+
}), c === void 0) {
|
|
36
|
+
let a;
|
|
37
|
+
d.forEach((l) => {
|
|
38
|
+
let L = l;
|
|
39
|
+
L.endsWith(" R") ? L = `${L.substring(0, L.length - 2)}常规` : L.endsWith(" B") && (L = `${L.substring(0, L.length - 2)}粗体`);
|
|
40
|
+
const w = L.length;
|
|
41
|
+
M.forEach((y, m) => {
|
|
42
|
+
const C = wt(L, m);
|
|
43
|
+
if (w <= C)
|
|
44
44
|
return;
|
|
45
|
-
const
|
|
46
|
-
(
|
|
45
|
+
const j = -(C * 0.9 + (m.endsWith("常规") ? 0 : 1) * 0.1);
|
|
46
|
+
(a === void 0 || j > a) && (a = j, c = y);
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
return
|
|
50
|
+
return c !== void 0 ? i[c] : void 0;
|
|
51
51
|
}
|
|
52
|
-
async function
|
|
53
|
-
const
|
|
54
|
-
for (const
|
|
55
|
-
let d =
|
|
52
|
+
async function s(n) {
|
|
53
|
+
const i = typeof n == "string" ? [n] : n, f = [];
|
|
54
|
+
for (const M of i) {
|
|
55
|
+
let d = r.value.get(M);
|
|
56
56
|
if (!d) {
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
const
|
|
57
|
+
const c = t(M);
|
|
58
|
+
if (c && (d = r.value.get(c.en_name), !d)) {
|
|
59
|
+
const a = Array.from(
|
|
60
60
|
new Set(
|
|
61
|
-
[
|
|
61
|
+
[M, c.en_name].filter(Boolean).map((l) => l.replace(/"/g, ""))
|
|
62
62
|
)
|
|
63
63
|
);
|
|
64
64
|
d = e({
|
|
65
|
-
family:
|
|
66
|
-
src:
|
|
67
|
-
}),
|
|
65
|
+
family: a,
|
|
66
|
+
src: c.fonturl
|
|
67
|
+
}), a.forEach((l) => r.value.set(l, d)), r.value.set(String(M), d);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
d &&
|
|
70
|
+
d && f.push(d);
|
|
71
71
|
}
|
|
72
|
-
return await Promise.all(
|
|
72
|
+
return await Promise.all(f);
|
|
73
73
|
}
|
|
74
74
|
return {
|
|
75
|
-
bigeFonts:
|
|
75
|
+
bigeFonts: X,
|
|
76
76
|
searchBigeFont: t,
|
|
77
|
-
loadBigeFonts:
|
|
78
|
-
loadFont:
|
|
77
|
+
loadBigeFonts: o,
|
|
78
|
+
loadFont: s
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
return
|
|
81
|
+
function ut(e, r) {
|
|
82
|
+
return ft() ? (ct(e, r), !0) : !1;
|
|
83
83
|
}
|
|
84
|
-
const
|
|
84
|
+
const gt = typeof window < "u" && typeof document < "u";
|
|
85
85
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
86
86
|
// @__NO_SIDE_EFFECTS__
|
|
87
|
-
function
|
|
88
|
-
if (!
|
|
89
|
-
let
|
|
90
|
-
const
|
|
91
|
-
|
|
87
|
+
function yt(e) {
|
|
88
|
+
if (!gt) return e;
|
|
89
|
+
let r = 0, o, t;
|
|
90
|
+
const s = () => {
|
|
91
|
+
r -= 1, t && r <= 0 && (t.stop(), o = void 0, t = void 0);
|
|
92
92
|
};
|
|
93
|
-
return ((...
|
|
93
|
+
return ((...n) => (r += 1, t || (t = it(!0), o = t.run(() => e(...n))), ut(s), o));
|
|
94
94
|
}
|
|
95
|
-
const
|
|
95
|
+
const _ = /* @__PURE__ */ yt(() => {
|
|
96
96
|
const e = /* @__PURE__ */ new Map();
|
|
97
|
-
function
|
|
98
|
-
let
|
|
99
|
-
return
|
|
97
|
+
function r(t, s) {
|
|
98
|
+
let n = e.get(t);
|
|
99
|
+
return n || (n = fetch(t).then(s), e.set(t, n)), n;
|
|
100
100
|
}
|
|
101
|
-
async function
|
|
102
|
-
return
|
|
101
|
+
async function o(t) {
|
|
102
|
+
return r(t, (s) => s.text());
|
|
103
103
|
}
|
|
104
104
|
return {
|
|
105
|
-
fetchToText:
|
|
105
|
+
fetchToText: o
|
|
106
106
|
};
|
|
107
|
-
}),
|
|
107
|
+
}), Y = {
|
|
108
108
|
easing: {
|
|
109
109
|
匀速: "linear",
|
|
110
110
|
加速: "cubic-bezier(0.55, 0, 1, 0.45)",
|
|
@@ -437,242 +437,406 @@ const S = /* @__PURE__ */ Z(() => {
|
|
|
437
437
|
]
|
|
438
438
|
}
|
|
439
439
|
};
|
|
440
|
-
function
|
|
440
|
+
function G(e, r, o) {
|
|
441
441
|
const {
|
|
442
442
|
name: t,
|
|
443
|
-
delay:
|
|
444
|
-
duration:
|
|
445
|
-
iterations:
|
|
446
|
-
mode:
|
|
447
|
-
easing:
|
|
443
|
+
delay: s = 0,
|
|
444
|
+
duration: n,
|
|
445
|
+
iterations: i,
|
|
446
|
+
mode: f,
|
|
447
|
+
easing: M,
|
|
448
448
|
path: d,
|
|
449
|
-
offsetRotate:
|
|
450
|
-
...
|
|
451
|
-
} =
|
|
452
|
-
let
|
|
449
|
+
offsetRotate: c,
|
|
450
|
+
...a
|
|
451
|
+
} = r;
|
|
452
|
+
let l;
|
|
453
453
|
if (t === "自定义路径" && d) {
|
|
454
|
-
let
|
|
455
|
-
d.forEach((
|
|
456
|
-
const
|
|
457
|
-
|
|
454
|
+
let L = `M ${e.style.width / 2} ${e.style.height / 2}`;
|
|
455
|
+
d.forEach((y) => {
|
|
456
|
+
const m = Object.keys(y);
|
|
457
|
+
L += ` ${m[0]}${y[m[0]].join(" ")}`;
|
|
458
458
|
});
|
|
459
|
-
const w = `path("${
|
|
460
|
-
switch (
|
|
459
|
+
const w = `path("${L}")`;
|
|
460
|
+
switch (o) {
|
|
461
461
|
case "in":
|
|
462
|
-
|
|
463
|
-
{ opacity: 0, offsetDistance: "100%", offsetPath: w, offsetRotate:
|
|
464
|
-
{ offsetDistance: "0%", offsetPath: w, offsetRotate:
|
|
462
|
+
l = [
|
|
463
|
+
{ opacity: 0, offsetDistance: "100%", offsetPath: w, offsetRotate: c },
|
|
464
|
+
{ offsetDistance: "0%", offsetPath: w, offsetRotate: c }
|
|
465
465
|
];
|
|
466
466
|
break;
|
|
467
467
|
case "stay":
|
|
468
|
-
|
|
469
|
-
{ offsetDistance: "0%", offsetPath: w, offsetRotate:
|
|
470
|
-
{ offsetDistance: "100%", offsetPath: w, offsetRotate:
|
|
468
|
+
l = [
|
|
469
|
+
{ offsetDistance: "0%", offsetPath: w, offsetRotate: c },
|
|
470
|
+
{ offsetDistance: "100%", offsetPath: w, offsetRotate: c }
|
|
471
471
|
];
|
|
472
472
|
break;
|
|
473
473
|
case "out":
|
|
474
|
-
|
|
475
|
-
{ offsetDistance: "0%", offsetPath: w, offsetRotate:
|
|
476
|
-
{ opacity: 0, offsetDistance: "100%", offsetPath: w, offsetRotate:
|
|
474
|
+
l = [
|
|
475
|
+
{ offsetDistance: "0%", offsetPath: w, offsetRotate: c },
|
|
476
|
+
{ opacity: 0, offsetDistance: "100%", offsetPath: w, offsetRotate: c }
|
|
477
477
|
];
|
|
478
478
|
break;
|
|
479
479
|
}
|
|
480
480
|
} else
|
|
481
|
-
switch (
|
|
481
|
+
switch (o) {
|
|
482
482
|
case "in":
|
|
483
|
-
|
|
483
|
+
l = Y.textIn[t]?.[0] ?? Y.in[t];
|
|
484
484
|
break;
|
|
485
485
|
case "stay":
|
|
486
|
-
|
|
486
|
+
l = Y.stay[t];
|
|
487
487
|
break;
|
|
488
488
|
case "out":
|
|
489
|
-
|
|
489
|
+
l = Y.out[t];
|
|
490
490
|
break;
|
|
491
491
|
}
|
|
492
492
|
return {
|
|
493
|
-
id:
|
|
494
|
-
name:
|
|
495
|
-
delay:
|
|
496
|
-
duration: t ?
|
|
497
|
-
effectMode:
|
|
498
|
-
keyframes:
|
|
499
|
-
easing:
|
|
493
|
+
id: U(),
|
|
494
|
+
name: r.name ?? r.title ?? r.id,
|
|
495
|
+
delay: s,
|
|
496
|
+
duration: t ? n * (i || 1) : 0,
|
|
497
|
+
effectMode: f === "逐字" || f === "逐行" ? "sibling" : "parent",
|
|
498
|
+
keyframes: l ?? [],
|
|
499
|
+
easing: Y.easing[M],
|
|
500
500
|
meta: {
|
|
501
|
-
...
|
|
501
|
+
...a,
|
|
502
502
|
inCanvasIs: "Animation",
|
|
503
503
|
inPptIs: "Animation",
|
|
504
504
|
inEditorIs: "Node"
|
|
505
505
|
}
|
|
506
506
|
};
|
|
507
507
|
}
|
|
508
|
-
function
|
|
508
|
+
function jt(e) {
|
|
509
509
|
if (!e.animations?.length)
|
|
510
510
|
return {
|
|
511
511
|
delay: 0,
|
|
512
512
|
duration: 0,
|
|
513
513
|
animations: []
|
|
514
514
|
};
|
|
515
|
-
let
|
|
516
|
-
e.animations[0].in ? (
|
|
517
|
-
const
|
|
518
|
-
return
|
|
519
|
-
|
|
520
|
-
...
|
|
515
|
+
let r, o, t;
|
|
516
|
+
e.animations[0].in ? (r = e.animations[0].in, o = e.animations[0].stay, t = e.animations[0].out) : (r = e.animations?.find((f) => f.category === "in"), o = e.animations?.find((f) => f.category === "stay"), t = e.animations?.find((f) => f.category === "out"));
|
|
517
|
+
const s = r?.delay ?? 0, n = t ? t.delay - s + t.duration : 0, i = [];
|
|
518
|
+
return r && i.push(
|
|
519
|
+
G(e, {
|
|
520
|
+
...r,
|
|
521
521
|
delay: 0
|
|
522
522
|
}, "in")
|
|
523
|
-
),
|
|
524
|
-
|
|
525
|
-
...
|
|
526
|
-
delay:
|
|
523
|
+
), o && i.push(
|
|
524
|
+
G(e, {
|
|
525
|
+
...o,
|
|
526
|
+
delay: o.delay - s
|
|
527
527
|
}, "stay")
|
|
528
|
-
), t &&
|
|
529
|
-
|
|
528
|
+
), t && i.push(
|
|
529
|
+
G(e, {
|
|
530
530
|
...t,
|
|
531
|
-
delay: t.delay -
|
|
531
|
+
delay: t.delay - s
|
|
532
532
|
}, "out")
|
|
533
533
|
), {
|
|
534
|
-
delay:
|
|
535
|
-
duration:
|
|
536
|
-
animations:
|
|
534
|
+
delay: s,
|
|
535
|
+
duration: n - s,
|
|
536
|
+
animations: i.filter((f) => !!f?.keyframes)
|
|
537
537
|
};
|
|
538
538
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
539
|
+
async function V(e) {
|
|
540
|
+
const {
|
|
541
|
+
transform: r = {},
|
|
542
|
+
style: o = {},
|
|
543
|
+
maskUrl: t,
|
|
544
|
+
imageEffects: s = [],
|
|
545
|
+
imageEffectsRatio: n = 1
|
|
546
|
+
} = e, i = e.clipUrl || e.url, {
|
|
547
|
+
translateX: f = 0,
|
|
548
|
+
translateY: M = 0,
|
|
549
|
+
zoom: d = 1
|
|
550
|
+
} = r ?? {}, {
|
|
551
|
+
scaleX: c = 1,
|
|
552
|
+
scaleY: a = 1,
|
|
553
|
+
filter: l
|
|
554
|
+
} = o;
|
|
555
|
+
if (f === 0 && M === 0 && d === 1 && c === 1 && a === 1 && !t && !l && !s.length)
|
|
556
|
+
return i;
|
|
557
|
+
const L = await B.fetchImageBitmap(i), {
|
|
558
|
+
originWidth: w = L.width,
|
|
559
|
+
originHeight: y = L.height,
|
|
560
|
+
imageWidth: m = w,
|
|
561
|
+
imageHeight: C = y
|
|
562
|
+
} = r, {
|
|
563
|
+
width: j = w,
|
|
564
|
+
height: h = y
|
|
565
|
+
} = o, D = window.devicePixelRatio || 1, [g, u] = W(j, h, D);
|
|
566
|
+
if (l && (u.filter = l), u.scale(c, a), u.translate(c < 0 ? -j : 0, a < 0 ? -h : 0), t) {
|
|
567
|
+
const T = await B.fetchImageBitmap(t);
|
|
568
|
+
u.drawImage(T, 0, 0, T.width, T.height, 0, 0, j, h), T.close(), u.globalCompositeOperation = "source-in";
|
|
569
|
+
}
|
|
570
|
+
const A = m * d, k = C * d, tt = -(A / 2 - m / 2) + f, et = -(k / 2 - C / 2) + M;
|
|
571
|
+
if (u.drawImage(L, 0, 0, L.width, L.height, tt, et, A, k), L.close(), u.globalCompositeOperation = "source-over", s.length > 0) {
|
|
572
|
+
const S = {
|
|
573
|
+
x: (j - j * 0.9) / 2,
|
|
574
|
+
y: (h - h * 0.9) / 2
|
|
575
|
+
}, v = await createImageBitmap(g);
|
|
576
|
+
u.clearRect(0, 0, g.width, g.height), u.scale(0.9, 0.9);
|
|
577
|
+
for (let F = s.length - 1; F >= 0; F--) {
|
|
578
|
+
const { filling: E, offset: R, stroke: at } = s[F];
|
|
579
|
+
let z = v;
|
|
580
|
+
if (E) {
|
|
581
|
+
const [I, x] = W(j, h, D);
|
|
582
|
+
if (x.drawImage(z, 0, 0, j, h), x.globalCompositeOperation = "source-in", E.color) {
|
|
583
|
+
const [p, N] = W(j, h, D);
|
|
584
|
+
N.fillStyle = E.color, N.fillRect(0, 0, j, h), x.drawImage(p, 0, 0, j, h);
|
|
585
|
+
} else if (E.imageContent?.image) {
|
|
586
|
+
const p = await B.fetchImageBitmap(E.imageContent.image);
|
|
587
|
+
x.drawImage(p, 0, 0, j, h), p.close();
|
|
588
|
+
}
|
|
589
|
+
z = I;
|
|
590
|
+
}
|
|
591
|
+
if (at?.forEach(({ width: I, color: x }) => {
|
|
592
|
+
z = new ht().use((p, N, O) => {
|
|
593
|
+
const [, J] = W(N.width, N.height);
|
|
594
|
+
J.drawImage(N, 0, 0);
|
|
595
|
+
const st = Ct(J), $ = O.thickness, H = O.thickness;
|
|
596
|
+
p.strokeStyle = O.color, p.lineWidth = O.thickness * 2, p.lineJoin = "round", st.forEach((b) => {
|
|
597
|
+
p.beginPath(), p.moveTo($ + b[0].x, H + b[1].y);
|
|
598
|
+
for (let Q = 1; Q < b.length; Q++)
|
|
599
|
+
p.lineTo($ + b[Q].x, H + b[Q].y);
|
|
600
|
+
p.closePath();
|
|
601
|
+
}), p.stroke();
|
|
602
|
+
}).make(z, {
|
|
603
|
+
color: x,
|
|
604
|
+
thickness: I / 50 * n
|
|
605
|
+
});
|
|
606
|
+
}), R) {
|
|
607
|
+
let { x: I, y: x } = R;
|
|
608
|
+
I = I / 50 * n * 200, x = x / 50 * n * 200, u.drawImage(z, I + S.x, x + S.y, j, h);
|
|
609
|
+
} else
|
|
610
|
+
u.drawImage(z, S.x, S.y, j, h);
|
|
611
|
+
}
|
|
612
|
+
v.close();
|
|
613
|
+
}
|
|
614
|
+
return await new Promise((T) => {
|
|
615
|
+
g.toBlob((S) => {
|
|
616
|
+
try {
|
|
617
|
+
T(URL.createObjectURL(S));
|
|
618
|
+
} catch (v) {
|
|
619
|
+
console.error(`Failed to URL.createObjectURL, url: ${i}`, v), T(i);
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
function W(e, r, o = 1) {
|
|
625
|
+
const t = document.createElement("canvas");
|
|
626
|
+
t.width = e * o, t.height = r * o, t.style.width = `${e}px`, t.style.height = `${r}px`;
|
|
627
|
+
const s = t.getContext("2d");
|
|
628
|
+
return s.scale(o, o), [t, s];
|
|
629
|
+
}
|
|
630
|
+
class ht {
|
|
631
|
+
canvas = document.createElement("canvas");
|
|
632
|
+
method;
|
|
633
|
+
use(r) {
|
|
634
|
+
return this.method = r, this;
|
|
635
|
+
}
|
|
636
|
+
make(r, o) {
|
|
637
|
+
const { canvas: t } = this, s = this.canvas.getContext("2d"), n = o.thickness * 2, [i, f] = [r.width, r.height].map((M) => M + n);
|
|
638
|
+
return (i !== t.width || f !== t.height) && (t.width = i, t.height = f), s.clearRect(0, 0, s.canvas.width, s.canvas.height), this.method(s, r, o), s.drawImage(r, o.thickness, o.thickness), t;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
function Ct(e) {
|
|
642
|
+
const t = e.canvas.width, s = e.canvas.height, n = [];
|
|
643
|
+
let i = 3;
|
|
644
|
+
const f = 100;
|
|
645
|
+
return (() => {
|
|
646
|
+
const d = [], c = new Uint32Array(e.getImageData(0, 0, t, s).data.buffer);
|
|
647
|
+
let a, l, L, w, y = -1, m, C = 9;
|
|
648
|
+
const j = [9, 0, 3, 3, 2, 0, 9, 3, 1, 9, 1, 1, 2, 0, 2, 9];
|
|
649
|
+
function h(g, u) {
|
|
650
|
+
return g >= 0 && u >= 0 && g < t && u < s ? c[u * t + g] >>> 24 > f : !1;
|
|
651
|
+
}
|
|
652
|
+
function D(g, u) {
|
|
653
|
+
let A = 0;
|
|
654
|
+
return h(g - 1, u - 1) && (A += 1), h(g, u - 1) && (A += 2), h(g - 1, u) && (A += 4), h(g, u) && (A += 8), A === 6 ? C === 0 ? 2 : 3 : A === 9 ? C === 3 ? 0 : 1 : j[A];
|
|
655
|
+
}
|
|
656
|
+
for (let g = i; g < c.length; g++)
|
|
657
|
+
if (c[g] >>> 24 > f) {
|
|
658
|
+
y = i = g;
|
|
659
|
+
break;
|
|
660
|
+
}
|
|
661
|
+
if (y >= 0) {
|
|
662
|
+
a = L = y % t, l = w = Math.floor(y / t);
|
|
663
|
+
do
|
|
664
|
+
m = D(a, l), m === 0 ? l-- : m === 1 ? l++ : m === 2 ? a-- : m === 3 && a++, m !== C && (d.push({ x: a + 0, y: l + 0 }), C = m);
|
|
665
|
+
while (a !== L || l !== w);
|
|
666
|
+
}
|
|
667
|
+
return n.push(d), d;
|
|
668
|
+
})(), n;
|
|
669
|
+
}
|
|
670
|
+
async function pt(e) {
|
|
671
|
+
const {
|
|
672
|
+
id: r,
|
|
673
|
+
doc: o,
|
|
674
|
+
url: t,
|
|
675
|
+
style: s = {},
|
|
676
|
+
background: n = {}
|
|
677
|
+
} = e;
|
|
678
|
+
let i = o;
|
|
679
|
+
i || (i = await fetch(t).then((M) => M.text()));
|
|
680
|
+
const f = new DOMParser().parseFromString(
|
|
681
|
+
i.replace(new RegExp(`#el-${r} `, "gi"), "").replace(/data-colors\s/, " ").replace(/[a-z-]+="([^\s<]*<\S*)"/gi, ""),
|
|
682
|
+
"image/svg+xml"
|
|
683
|
+
).documentElement;
|
|
684
|
+
if (!(f instanceof SVGElement))
|
|
685
|
+
throw new TypeError(`Failed to DOMParser, parse svg to DOM error: ${i}`);
|
|
686
|
+
if (n.src) {
|
|
687
|
+
const M = `#${r}-fill-blip`, d = f.querySelector(M), c = d?.querySelector("image");
|
|
688
|
+
if (d && c)
|
|
689
|
+
try {
|
|
690
|
+
const a = await B.fetchImageBitmap(n.src).then((l) => {
|
|
691
|
+
const L = document.createElement("canvas");
|
|
692
|
+
return L.width = l.width, L.height = l.height, L.getContext("2d")?.drawImage(l, 0, 0), l.close(), L.toDataURL("image/png");
|
|
693
|
+
});
|
|
694
|
+
c?.setAttribute("href", a), d?.setAttribute("fill", M);
|
|
695
|
+
} catch (a) {
|
|
696
|
+
console.error(a);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
return s.width && f.setAttribute("width", String(s.width * 2)), s.height && f.setAttribute("height", String(s.height * 2)), await V({
|
|
700
|
+
...e,
|
|
701
|
+
transform: {
|
|
702
|
+
...e.transform,
|
|
703
|
+
originWidth: s.width,
|
|
704
|
+
originHeight: s.height
|
|
705
|
+
},
|
|
706
|
+
url: `data:image/svg+xml;charset=utf-8,${encodeURIComponent(f.outerHTML)}`
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
const At = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgNzIgNzIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDcyIDcyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+CjxnPgoJPHBhdGggZD0iTTE5LjMsMzguMWMwLjIsMC41LDAuNCwwLjksMC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ightReferImage: At,
|
|
544
714
|
listStyleType: "none",
|
|
545
715
|
listStyleImage: "none"
|
|
546
716
|
};
|
|
547
|
-
return e.style.fontSize && (t.fontSize = Math.floor(e.style.fontSize)), e.listStyle?.colormap && (t.listStyleColormap = e.listStyle?.colormap),
|
|
717
|
+
return e.style.fontSize && (t.fontSize = Math.floor(e.style.fontSize)), e.listStyle?.colormap && (t.listStyleColormap = e.listStyle?.colormap), r || (e.listMode ? t.listStyleType = "disc" : e.listStyle && (t.listStyleImage = await o(e.listStyle.image), t.listStyleSize = `${e.listStyle.size * 100}%`)), e.background?.enabled ? (t.backgroundImage = e.background.image, t.backgroundSize = e.background.size, t.backgroundColormap = e.background.colormap, t.padding = e.background.padding) : t.padding = 0, t;
|
|
548
718
|
}
|
|
549
|
-
async function
|
|
550
|
-
const
|
|
551
|
-
if (
|
|
719
|
+
async function Tt(e) {
|
|
720
|
+
const r = e.textEffects ?? [];
|
|
721
|
+
if (r.length)
|
|
552
722
|
return await Promise.all(
|
|
553
|
-
[...
|
|
554
|
-
const
|
|
555
|
-
if (s && (
|
|
556
|
-
const { color:
|
|
557
|
-
|
|
558
|
-
c ? a.color = `linear-gradient(${90 - c.angle}deg, ${c.stops.map((l) => `${l.color} ${l.offset * 100}%`).join(",")})` : i && (a.color = i);
|
|
559
|
-
else {
|
|
560
|
-
const { image: l, repeat: w } = r, m = await fetch(l).then((g) => g.blob()), u = URL.createObjectURL(m), y = await new Promise((g) => {
|
|
561
|
-
const j = new Image();
|
|
562
|
-
j.crossOrigin = "anonymous", j.onload = () => g(j), j.src = u;
|
|
563
|
-
});
|
|
564
|
-
a.color = o?.createPattern(y, w ? "repeat" : "no-repeat"), URL.revokeObjectURL(u);
|
|
565
|
-
}
|
|
723
|
+
[...r].reverse().map(async (o) => {
|
|
724
|
+
const t = {}, { offset: s, skew: n, stroke: i, shadow: f, filling: M } = o;
|
|
725
|
+
if (s && (t.translateX = s.x, t.translateY = s.y), n && (t.skewX = n.x, t.skewY = n.y), i?.color && i.width && (t.textStrokeWidth = i.width, t.textStrokeColor = i.color), f && (t.shadowOffsetX = f.offsetX, t.shadowOffsetY = f.offsetY, t.shadowBlur = f.blur, t.shadowColor = f.color), M) {
|
|
726
|
+
const { color: d, imageContent: c, gradient: a } = M;
|
|
727
|
+
c?.image || (a ? t.color = `linear-gradient(${90 - a.angle}deg, ${a.stops.map((l) => `${l.color} ${l.offset * 100}%`).join(",")})` : d && (t.color = d));
|
|
566
728
|
}
|
|
567
|
-
return
|
|
729
|
+
return t;
|
|
568
730
|
})
|
|
569
731
|
);
|
|
570
732
|
}
|
|
571
|
-
function
|
|
572
|
-
return e.version ? e.contents : e.contents.map((
|
|
573
|
-
let
|
|
574
|
-
return
|
|
575
|
-
let
|
|
576
|
-
|
|
733
|
+
function Dt(e) {
|
|
734
|
+
return e.version ? e.contents : e.contents.map((r) => {
|
|
735
|
+
let o;
|
|
736
|
+
return r.map((t, s) => {
|
|
737
|
+
let n = t.content;
|
|
738
|
+
n = n.replace(/ |\r\n|\n\r|[\n\r\t\v]/g, " "), n = n.replace(/<br\/>/g, `
|
|
577
739
|
`);
|
|
578
|
-
let
|
|
579
|
-
for (const M of Array.from(
|
|
580
|
-
|
|
740
|
+
let i = "", f = 0;
|
|
741
|
+
for (const M of Array.from(n))
|
|
742
|
+
s === 0 && f === 0 && M === " " || o === " " && M === " " || (i += M), o = M, f++;
|
|
581
743
|
return {
|
|
582
744
|
...t,
|
|
583
|
-
content:
|
|
745
|
+
content: i
|
|
584
746
|
};
|
|
585
747
|
}).filter((t) => t.content);
|
|
586
748
|
});
|
|
587
749
|
}
|
|
588
|
-
async function
|
|
589
|
-
const { fetchToText:
|
|
590
|
-
for (let
|
|
591
|
-
const
|
|
750
|
+
async function It(e, r = !1) {
|
|
751
|
+
const { fetchToText: o } = _(), t = Dt(e), s = [];
|
|
752
|
+
for (let n = 0, i = t.length; n < i; n++) {
|
|
753
|
+
const f = t[n], M = {
|
|
592
754
|
fragments: []
|
|
593
755
|
};
|
|
594
|
-
|
|
595
|
-
for (let d = 0,
|
|
596
|
-
const
|
|
597
|
-
|
|
756
|
+
s.push(M);
|
|
757
|
+
for (let d = 0, c = f.length; d < c; d++) {
|
|
758
|
+
const a = {}, l = f[d];
|
|
759
|
+
for (const w in l)
|
|
760
|
+
w !== "id" && l[w] !== "" && (a[w] = l[w]);
|
|
761
|
+
a.fontSize && (a.fontSize = Math.floor(a.fontSize)), a.content = Mt(a.content), a.highlight && (a.highlightImage = await o(a.highlight.image), r ? a.highlightSize = "cover" : a.highlight.size && (a.highlightSize = `${a.highlight.size}rem`), a.highlight.colormap && (a.highlightColormap = a.highlight.colormap), a.highlight.line && (a.highlightLine = a.highlight.line), a.highlight.thickness && (a.highlightThickness = `${a.highlight.thickness}%`), delete a.highlight), r || (a.listMode ? M.listStyleType = "disc" : a.listStyle && (M.listStyleImage = await o(a.listStyle.image), M.listStyleSize = `${a.listStyle.size * 100}%`));
|
|
762
|
+
const L = M.fragments[M.fragments.length - 1];
|
|
763
|
+
L && Object.keys(L).length === 1 && L.content && Object.keys(a).length === 1 && a.content ? L.content += a.content : M.fragments.push(a);
|
|
598
764
|
}
|
|
599
765
|
}
|
|
600
|
-
return
|
|
766
|
+
return s;
|
|
601
767
|
}
|
|
602
|
-
const
|
|
603
|
-
async function
|
|
604
|
-
const t = e.style ?? e
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
768
|
+
const P = (e) => (Number.parseFloat(e) || 0) / 100;
|
|
769
|
+
async function q(e, r, o) {
|
|
770
|
+
const t = { ...e.style ?? e }, s = {
|
|
771
|
+
inPptIs: "Shape",
|
|
772
|
+
inEditorIs: "Element"
|
|
773
|
+
}, n = {
|
|
774
|
+
id: U(),
|
|
608
775
|
name: e.name ?? e.title ?? e.id,
|
|
609
|
-
style:
|
|
610
|
-
|
|
611
|
-
...t,
|
|
612
|
-
visibility: e.editable === !1 ? "hidden" : "visible"
|
|
613
|
-
},
|
|
614
|
-
meta: {
|
|
615
|
-
inPptIs: "Shape",
|
|
616
|
-
inEditorIs: "Element",
|
|
617
|
-
lock: e.lock === !0
|
|
618
|
-
},
|
|
776
|
+
style: t,
|
|
777
|
+
meta: s,
|
|
619
778
|
children: []
|
|
620
779
|
};
|
|
621
|
-
if (e.animations?.length) {
|
|
622
|
-
const
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
780
|
+
if (t.borderRadius && (t.borderRadius = t.borderRadius * 0.01 * Math.max(t.height, t.width)), r && e.groupStyle && (t.width = r.style.width * P(e.groupStyle.width), t.height = r.style.height * P(e.groupStyle.height), t.left = r.style.width * P(e.groupStyle.left), t.top = r.style.height * P(e.groupStyle.top)), e.editable === !1 && (t.visibility = "hidden"), e.lock === !0 && (s.lock = !0), e.animations?.length) {
|
|
781
|
+
const i = jt(e);
|
|
782
|
+
n.delay = i.delay, n.duration = i.duration, n.children.push(...i.animations), o && (i.animations.forEach((f) => {
|
|
783
|
+
o.endTime = Math.max(
|
|
784
|
+
o.endTime,
|
|
785
|
+
i.delay + f.delay + f.duration
|
|
627
786
|
);
|
|
628
|
-
}),
|
|
787
|
+
}), o.endTime = Math.max(o.endTime, i.delay + i.duration));
|
|
629
788
|
}
|
|
630
789
|
switch (e.type) {
|
|
631
790
|
case "image":
|
|
632
|
-
if (
|
|
633
|
-
image: e
|
|
791
|
+
if (s.inPptIs = "Picture", n.foreground = {
|
|
792
|
+
image: await V(e),
|
|
634
793
|
fillWithShape: !0
|
|
635
|
-
}, e.
|
|
636
|
-
const
|
|
794
|
+
}, e.clipUrl && (s.rawForegroundImage = e.url), e.cropping) {
|
|
795
|
+
const i = e.style.width, f = e.style.height, {
|
|
637
796
|
imageWidth: M,
|
|
638
|
-
imageHeight:
|
|
639
|
-
maskWidth:
|
|
640
|
-
maskHeight:
|
|
641
|
-
translateX:
|
|
642
|
-
translateY:
|
|
643
|
-
zoom:
|
|
644
|
-
} = e.cropping,
|
|
645
|
-
|
|
646
|
-
left:
|
|
647
|
-
top:
|
|
648
|
-
right:
|
|
649
|
-
bottom:
|
|
797
|
+
imageHeight: d,
|
|
798
|
+
maskWidth: c = i,
|
|
799
|
+
maskHeight: a = f,
|
|
800
|
+
translateX: l,
|
|
801
|
+
translateY: L,
|
|
802
|
+
zoom: w = 1
|
|
803
|
+
} = e.cropping, y = M * w, m = d * w, C = (y - c) / 2 - l, j = (m - a) / 2 - L, h = C + c / 2, D = j + a / 2, g = -(i / 2 - h), u = -(f / 2 - D), A = y - (g + i), k = m - (u + f);
|
|
804
|
+
n.foreground.cropRect = {
|
|
805
|
+
left: g / y,
|
|
806
|
+
top: u / m,
|
|
807
|
+
right: A / y,
|
|
808
|
+
bottom: k / m
|
|
650
809
|
};
|
|
651
810
|
}
|
|
652
811
|
break;
|
|
653
812
|
case "svg": {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
s || (s = await fetch(e.url).then((f) => f.text())), s = s.replace(new RegExp(`#el-${e.id} `, "gi"), ""), s = s.replace('width="100%"', `width="${t.width * 2}"`), s = s.replace('height="100%"', `height="${t.height * 2}"`), a.foreground = {
|
|
657
|
-
image: `data:image/svg+xml;charset=utf-8,${encodeURIComponent(s)}`,
|
|
813
|
+
s.inPptIs = "Picture", n.foreground = {
|
|
814
|
+
image: await pt(e),
|
|
658
815
|
fillWithShape: !0
|
|
659
816
|
};
|
|
660
817
|
break;
|
|
661
818
|
}
|
|
662
819
|
case "text": {
|
|
663
|
-
|
|
664
|
-
content: await
|
|
665
|
-
style: await
|
|
666
|
-
effects: await
|
|
820
|
+
s.inPptIs = "Shape", t.writingMode === "horizontal-tb" ? t.width = Math.ceil(t.width + t.letterSpacing) : t.height = Math.ceil(t.height + t.letterSpacing), n.text = {
|
|
821
|
+
content: await It(e),
|
|
822
|
+
style: await xt(e),
|
|
823
|
+
effects: await Tt(e),
|
|
667
824
|
// plugins: [deformation(el.deformation?.type?.endsWith("byWord") ? -1 : 999, () => el.deformation)],
|
|
668
825
|
drawMode: "texture"
|
|
669
826
|
};
|
|
670
827
|
break;
|
|
671
828
|
}
|
|
672
829
|
case "com":
|
|
673
|
-
|
|
674
|
-
e.children.map((
|
|
675
|
-
|
|
830
|
+
s.inPptIs = "GroupShape", n.children = (await Promise.all(
|
|
831
|
+
e.children.map(async (i) => {
|
|
832
|
+
try {
|
|
833
|
+
return await q(i, e, o);
|
|
834
|
+
} catch (f) {
|
|
835
|
+
console.warn(f);
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
})
|
|
839
|
+
)).filter(Boolean);
|
|
676
840
|
break;
|
|
677
841
|
case "pic":
|
|
678
842
|
case "mosaic":
|
|
@@ -699,175 +863,187 @@ async function z(e, o, n) {
|
|
|
699
863
|
console.warn(e);
|
|
700
864
|
break;
|
|
701
865
|
}
|
|
702
|
-
return
|
|
866
|
+
return n;
|
|
703
867
|
}
|
|
704
|
-
async function
|
|
705
|
-
const t =
|
|
868
|
+
async function St(e, r = !0, o) {
|
|
869
|
+
const t = U(), s = {
|
|
706
870
|
...e.style ?? e
|
|
707
871
|
};
|
|
708
|
-
|
|
709
|
-
let
|
|
710
|
-
return e.background && (e.background.color && (
|
|
872
|
+
r && (s.overflow = "hidden");
|
|
873
|
+
let n;
|
|
874
|
+
return e.background && (e.background.color && (n ??= {}, dt(e.background.color ?? "") ? n.image = e.background.color : n.color = e.background.color), e.background.image && (n ??= {}, n.image = e.background.image)), {
|
|
711
875
|
id: t,
|
|
712
|
-
name:
|
|
713
|
-
style:
|
|
876
|
+
name: r ? `Frame ${t}` : e.name,
|
|
877
|
+
style: s,
|
|
714
878
|
// TODO 过滤掉部分属性
|
|
715
|
-
background:
|
|
716
|
-
children: await Promise.all(
|
|
717
|
-
e.elements.map((
|
|
718
|
-
|
|
879
|
+
background: n,
|
|
880
|
+
children: (await Promise.all(
|
|
881
|
+
e.elements.map(async (i) => {
|
|
882
|
+
try {
|
|
883
|
+
return await q(i, void 0, o);
|
|
884
|
+
} catch (f) {
|
|
885
|
+
console.warn(f);
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
})
|
|
889
|
+
)).filter(Boolean),
|
|
719
890
|
meta: {
|
|
720
|
-
inPptIs:
|
|
721
|
-
inEditorIs:
|
|
891
|
+
inPptIs: r ? "Slide" : "GroupShape",
|
|
892
|
+
inEditorIs: r ? "Frame" : "Element"
|
|
722
893
|
}
|
|
723
894
|
};
|
|
724
895
|
}
|
|
725
|
-
async function
|
|
896
|
+
async function K(e, r = 0) {
|
|
726
897
|
const {
|
|
727
|
-
layouts:
|
|
898
|
+
layouts: o,
|
|
728
899
|
metas: t = {}
|
|
729
|
-
} = e,
|
|
900
|
+
} = e, s = {
|
|
730
901
|
endTime: 0
|
|
731
902
|
};
|
|
732
|
-
let
|
|
733
|
-
|
|
903
|
+
let n = await Promise.all(
|
|
904
|
+
o.map(async (M, d) => ({
|
|
734
905
|
index: d,
|
|
735
|
-
element: await
|
|
906
|
+
element: await St(M, !0, s)
|
|
736
907
|
}))
|
|
737
|
-
),
|
|
738
|
-
|
|
739
|
-
const
|
|
740
|
-
return
|
|
908
|
+
), i = 0;
|
|
909
|
+
n = n.sort((M, d) => M.index - d.index).map((M, d) => {
|
|
910
|
+
const c = M.element;
|
|
911
|
+
return c.style && (c.style.top = i, i += Number(c.style.height) + r), c.name = `Frame ${d + 1}`, c;
|
|
741
912
|
});
|
|
742
|
-
const
|
|
743
|
-
const d =
|
|
913
|
+
const f = n.reduce((M) => {
|
|
914
|
+
const d = M.style?.left ?? 0, c = M.style?.top ?? 0, a = M.style?.width ?? 0, l = M.style?.height ?? 0;
|
|
744
915
|
return {
|
|
745
916
|
minX: d,
|
|
746
|
-
minY:
|
|
747
|
-
maxX: d +
|
|
748
|
-
maxY:
|
|
917
|
+
minY: c,
|
|
918
|
+
maxX: d + a,
|
|
919
|
+
maxY: c + l
|
|
749
920
|
};
|
|
750
921
|
}, { minX: 0, minY: 0, maxX: 0, maxY: 0 });
|
|
751
922
|
return {
|
|
752
923
|
name: t.name || "doc",
|
|
753
924
|
style: {
|
|
754
|
-
width: t?.width ??
|
|
755
|
-
height: t?.height ??
|
|
925
|
+
width: t?.width ?? f.maxX - f.minX,
|
|
926
|
+
height: t?.height ?? f.maxY - f.minY
|
|
756
927
|
},
|
|
757
|
-
children:
|
|
928
|
+
children: n,
|
|
758
929
|
meta: {
|
|
759
930
|
...t,
|
|
760
|
-
endTime:
|
|
931
|
+
endTime: s.endTime,
|
|
761
932
|
inEditorIs: "Doc"
|
|
762
933
|
}
|
|
763
934
|
};
|
|
764
935
|
}
|
|
765
|
-
function
|
|
766
|
-
const { config:
|
|
936
|
+
function zt(e, r) {
|
|
937
|
+
const { config: o } = e;
|
|
767
938
|
return {
|
|
768
939
|
name: "bigesj:bidTid",
|
|
769
940
|
test: (t) => typeof t == "object" && t && !!(t.bid || t.tid),
|
|
770
941
|
load: async (t) => {
|
|
771
|
-
const
|
|
772
|
-
(t.bid ?
|
|
773
|
-
).then((
|
|
774
|
-
let
|
|
775
|
-
const
|
|
776
|
-
|
|
777
|
-
let [
|
|
778
|
-
|
|
779
|
-
const
|
|
780
|
-
|
|
781
|
-
const
|
|
782
|
-
return
|
|
942
|
+
const s = t.bid ?? t.tid ?? "", n = async (c) => await fetch(
|
|
943
|
+
(t.bid ? r.bid : r.tid).replace("%d", c)
|
|
944
|
+
).then((a) => a.json()).then((a) => JSON.parse(a.data.content));
|
|
945
|
+
let i = 0;
|
|
946
|
+
const f = await Promise.all(
|
|
947
|
+
s.split("|").map(async (c) => {
|
|
948
|
+
let [a, l] = c.split("[");
|
|
949
|
+
l && (l = l.substring(0, l.length - 1));
|
|
950
|
+
const L = l ? l.split(",").map((m) => Number(m)) : void 0, w = await n(a);
|
|
951
|
+
L !== void 0 && (w.layouts = w.layouts.filter((m, C) => L.includes(C)));
|
|
952
|
+
const y = await K(w);
|
|
953
|
+
return i = Math.max(i, y.meta?.maxTime ?? 0), y;
|
|
783
954
|
})
|
|
784
|
-
),
|
|
785
|
-
|
|
955
|
+
), M = { ...f[0], id: s, children: [] };
|
|
956
|
+
M.meta ??= {}, M.meta.maxTime = i, M.meta.inEditorIs = "Doc";
|
|
786
957
|
let d = 0;
|
|
787
|
-
return
|
|
788
|
-
let
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
}), d +=
|
|
792
|
-
}),
|
|
958
|
+
return f.forEach((c) => {
|
|
959
|
+
let a = 0;
|
|
960
|
+
c.children?.forEach((l) => {
|
|
961
|
+
l.style && (l.style.left = d, a = Math.max(a, Number(l.style.width)), M.children.push(l));
|
|
962
|
+
}), d += a + o.value.frameGap;
|
|
963
|
+
}), M;
|
|
793
964
|
}
|
|
794
965
|
};
|
|
795
966
|
}
|
|
796
|
-
function
|
|
797
|
-
const { config:
|
|
967
|
+
function Nt(e) {
|
|
968
|
+
const { config: r } = e;
|
|
798
969
|
return {
|
|
799
970
|
name: "bigesj:bige",
|
|
800
971
|
accept: ".bige",
|
|
801
|
-
test: (
|
|
802
|
-
load: async (
|
|
972
|
+
test: (o) => o instanceof File && o.name.endsWith(".bige"),
|
|
973
|
+
load: async (o) => await K(
|
|
803
974
|
JSON.parse(
|
|
804
975
|
new TextDecoder().decode(
|
|
805
|
-
|
|
976
|
+
Lt(new Uint8Array(await o.arrayBuffer()))
|
|
806
977
|
)
|
|
807
|
-
).content
|
|
808
|
-
o.value.frameGap
|
|
978
|
+
).content
|
|
809
979
|
)
|
|
810
980
|
};
|
|
811
981
|
}
|
|
812
|
-
function
|
|
982
|
+
function Qt(e = {}) {
|
|
813
983
|
const {
|
|
814
|
-
font:
|
|
815
|
-
api:
|
|
984
|
+
font: r,
|
|
985
|
+
api: o
|
|
816
986
|
} = e, t = {
|
|
817
987
|
fonts: "/new/design/fonts",
|
|
818
988
|
bid: "/new/udesign/info/%d",
|
|
819
989
|
tid: "/new/design/info/%d",
|
|
820
|
-
...
|
|
990
|
+
...o
|
|
821
991
|
};
|
|
822
|
-
return
|
|
992
|
+
return ot((s) => ({
|
|
823
993
|
name: "bigesj",
|
|
824
994
|
loaders: [
|
|
825
|
-
|
|
826
|
-
|
|
995
|
+
Nt(s),
|
|
996
|
+
zt(s, t)
|
|
827
997
|
],
|
|
828
998
|
setup: async () => {
|
|
829
|
-
|
|
999
|
+
r && await Et(s, t);
|
|
830
1000
|
}
|
|
831
1001
|
}));
|
|
832
1002
|
}
|
|
833
|
-
async function
|
|
1003
|
+
async function Et(e, r) {
|
|
834
1004
|
const {
|
|
835
|
-
on:
|
|
1005
|
+
on: o,
|
|
836
1006
|
off: t,
|
|
837
|
-
root:
|
|
1007
|
+
root: s
|
|
838
1008
|
} = e, {
|
|
839
|
-
loadBigeFonts:
|
|
840
|
-
loadFont:
|
|
841
|
-
} =
|
|
842
|
-
function
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
}),
|
|
1009
|
+
loadBigeFonts: n,
|
|
1010
|
+
loadFont: i
|
|
1011
|
+
} = mt();
|
|
1012
|
+
function f(c) {
|
|
1013
|
+
c instanceof nt && (c.style.fontFamily && i(c.style.fontFamily).then(() => c.text.update()), c.text.content.forEach((a) => {
|
|
1014
|
+
a.fragments.forEach((l) => {
|
|
1015
|
+
l.fontFamily && i(l.fontFamily).then(() => c.text.update());
|
|
1016
|
+
}), a.fontFamily && i(a.fontFamily).then(() => c.text.update());
|
|
847
1017
|
}));
|
|
848
1018
|
}
|
|
849
|
-
function
|
|
850
|
-
|
|
851
|
-
|
|
1019
|
+
function M(c) {
|
|
1020
|
+
c.forEach((a) => {
|
|
1021
|
+
f(a), a.findOne((l) => (f(l), !1));
|
|
852
1022
|
});
|
|
853
1023
|
}
|
|
854
1024
|
async function d() {
|
|
855
|
-
|
|
1025
|
+
s.value && M([s.value]);
|
|
856
1026
|
}
|
|
857
|
-
|
|
858
|
-
t("setDoc", d), t("addElement",
|
|
859
|
-
}),
|
|
1027
|
+
lt(() => {
|
|
1028
|
+
t("setDoc", d), t("addElement", M);
|
|
1029
|
+
}), o("setDoc", d), o("addElement", M), await n(r.fonts);
|
|
860
1030
|
}
|
|
861
1031
|
export {
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
1032
|
+
zt as bidTidLoader,
|
|
1033
|
+
Nt as bigeLoader,
|
|
1034
|
+
G as convertAnimation,
|
|
1035
|
+
K as convertDoc,
|
|
1036
|
+
q as convertElement,
|
|
1037
|
+
V as convertImageElementToUrl,
|
|
1038
|
+
St as convertLayout,
|
|
1039
|
+
pt as convertSvgElementToUrl,
|
|
1040
|
+
It as convertTextContent,
|
|
1041
|
+
Tt as convertTextEffects,
|
|
1042
|
+
xt as convertTextStyle,
|
|
1043
|
+
Qt as default,
|
|
1044
|
+
Dt as getTextContents,
|
|
1045
|
+
jt as parseAnimations,
|
|
1046
|
+
Qt as plugin,
|
|
1047
|
+
mt as useFonts,
|
|
1048
|
+
_ as useSharedTextAssets
|
|
873
1049
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mce/bigesj",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.5",
|
|
5
5
|
"description": "Plugin for mce",
|
|
6
6
|
"author": "wxm",
|
|
7
7
|
"license": "MIT",
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"fflate": "^0.8.2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"modern-canvas": "^0.12.
|
|
51
|
+
"modern-canvas": "^0.12.20",
|
|
52
52
|
"modern-font": "^0.4.4",
|
|
53
53
|
"modern-idoc": "^0.10.5",
|
|
54
54
|
"vue": "^3.5.22",
|
|
55
|
-
"mce": "0.2.
|
|
55
|
+
"mce": "0.2.5"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"mce": "^0"
|