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