@mce/bigesj 0.2.5 → 0.2.7
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 +261 -255
- package/dist/loaders/bige.d.ts +1 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
1
|
import { useEditor as rt, definePlugin as ot } from "mce";
|
|
2
2
|
import { assets as B, Element2D as nt } 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 n = [];
|
|
9
9
|
for (let t = 0; t <= r.length; t++)
|
|
10
|
-
|
|
10
|
+
n[t] = [t];
|
|
11
11
|
for (let t = 0; t <= e.length; t++)
|
|
12
|
-
|
|
12
|
+
n[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
|
+
n[t][s] = Math.min(n[t - 1][s] + 1, n[t][s - 1] + 1, n[t - 1][s - 1] + i);
|
|
17
17
|
}
|
|
18
|
-
return
|
|
18
|
+
return n[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
|
|
25
|
-
let
|
|
26
|
-
return
|
|
24
|
+
async function n(i) {
|
|
25
|
+
let o = X.value;
|
|
26
|
+
return o.length || (o = await fetch(i).then((f) => f.json()).then((f) => f.data.datalist), X.value = o), o;
|
|
27
27
|
}
|
|
28
|
-
function t(
|
|
29
|
-
const f = new Map(
|
|
30
|
-
|
|
31
|
-
), d =
|
|
32
|
-
let
|
|
28
|
+
function t(i, o = X.value) {
|
|
29
|
+
const f = new Map(o.map((a, M) => [a.id, M])), c = new Map(
|
|
30
|
+
o.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
|
-
|
|
41
|
+
c.forEach((y, m) => {
|
|
42
42
|
const C = wt(L, m);
|
|
43
43
|
if (w <= C)
|
|
44
44
|
return;
|
|
45
45
|
const j = -(C * 0.9 + (m.endsWith("常规") ? 0 : 1) * 0.1);
|
|
46
|
-
(a === void 0 || j > a) && (a = j,
|
|
46
|
+
(a === void 0 || j > a) && (a = j, l = y);
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
return
|
|
50
|
+
return l !== void 0 ? o[l] : void 0;
|
|
51
51
|
}
|
|
52
|
-
async function s(
|
|
53
|
-
const
|
|
54
|
-
for (const
|
|
55
|
-
let d = r.value.get(
|
|
52
|
+
async function s(i) {
|
|
53
|
+
const o = typeof i == "string" ? [i] : i, f = [];
|
|
54
|
+
for (const c of o) {
|
|
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: n,
|
|
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, n, t;
|
|
90
90
|
const s = () => {
|
|
91
|
-
r -= 1, t && r <= 0 && (t.stop(),
|
|
91
|
+
r -= 1, t && r <= 0 && (t.stop(), n = void 0, t = void 0);
|
|
92
92
|
};
|
|
93
|
-
return ((...
|
|
93
|
+
return ((...i) => (r += 1, t || (t = it(!0), n = t.run(() => e(...i))), ut(s), n));
|
|
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 n(t) {
|
|
102
102
|
return r(t, (s) => s.text());
|
|
103
103
|
}
|
|
104
104
|
return {
|
|
105
|
-
fetchToText:
|
|
105
|
+
fetchToText: n
|
|
106
106
|
};
|
|
107
107
|
}), Y = {
|
|
108
108
|
easing: {
|
|
@@ -437,19 +437,19 @@ const _ = /* @__PURE__ */ yt(() => {
|
|
|
437
437
|
]
|
|
438
438
|
}
|
|
439
439
|
};
|
|
440
|
-
function
|
|
440
|
+
function U(e, r, n) {
|
|
441
441
|
const {
|
|
442
442
|
name: t,
|
|
443
443
|
delay: s = 0,
|
|
444
|
-
duration:
|
|
445
|
-
iterations:
|
|
444
|
+
duration: i,
|
|
445
|
+
iterations: o,
|
|
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
455
|
d.forEach((y) => {
|
|
@@ -457,46 +457,46 @@ function G(e, r, o) {
|
|
|
457
457
|
L += ` ${m[0]}${y[m[0]].join(" ")}`;
|
|
458
458
|
});
|
|
459
459
|
const w = `path("${L}")`;
|
|
460
|
-
switch (
|
|
460
|
+
switch (n) {
|
|
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 (n) {
|
|
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 * (o || 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,49 +512,49 @@ 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,
|
|
518
|
-
return r &&
|
|
519
|
-
|
|
515
|
+
let r, n, t;
|
|
516
|
+
e.animations[0].in ? (r = e.animations[0].in, n = e.animations[0].stay, t = e.animations[0].out) : (r = e.animations?.find((f) => f.category === "in"), n = 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, o = [];
|
|
518
|
+
return r && o.push(
|
|
519
|
+
U(e, {
|
|
520
520
|
...r,
|
|
521
521
|
delay: 0
|
|
522
522
|
}, "in")
|
|
523
|
-
),
|
|
524
|
-
|
|
525
|
-
...
|
|
526
|
-
delay:
|
|
523
|
+
), n && o.push(
|
|
524
|
+
U(e, {
|
|
525
|
+
...n,
|
|
526
|
+
delay: n.delay - s
|
|
527
527
|
}, "stay")
|
|
528
|
-
), t &&
|
|
529
|
-
|
|
528
|
+
), t && o.push(
|
|
529
|
+
U(e, {
|
|
530
530
|
...t,
|
|
531
531
|
delay: t.delay - s
|
|
532
532
|
}, "out")
|
|
533
533
|
), {
|
|
534
534
|
delay: s,
|
|
535
|
-
duration:
|
|
536
|
-
animations:
|
|
535
|
+
duration: i - s,
|
|
536
|
+
animations: o.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: n = {},
|
|
543
543
|
maskUrl: t,
|
|
544
544
|
imageEffects: s = [],
|
|
545
|
-
imageEffectsRatio:
|
|
546
|
-
} = e,
|
|
545
|
+
imageEffectsRatio: i = 1
|
|
546
|
+
} = e, o = 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 &&
|
|
556
|
-
return
|
|
557
|
-
const L = await B.fetchImageBitmap(
|
|
553
|
+
filter: M
|
|
554
|
+
} = n;
|
|
555
|
+
if (f === 0 && c === 0 && d === 1 && l === 1 && a === 1 && !t && !M && !s.length)
|
|
556
|
+
return o;
|
|
557
|
+
const L = await B.fetchImageBitmap(o), {
|
|
558
558
|
originWidth: w = L.width,
|
|
559
559
|
originHeight: y = L.height,
|
|
560
560
|
imageWidth: m = w,
|
|
@@ -562,28 +562,28 @@ async function V(e) {
|
|
|
562
562
|
} = r, {
|
|
563
563
|
width: j = w,
|
|
564
564
|
height: h = y
|
|
565
|
-
} =
|
|
566
|
-
if (
|
|
565
|
+
} = n, D = window.devicePixelRatio || 1, [g, u] = W(j, h, D);
|
|
566
|
+
if (M && (u.filter = M), u.scale(l, a), u.translate(l < 0 ? -j : 0, a < 0 ? -h : 0), t) {
|
|
567
567
|
const T = await B.fetchImageBitmap(t);
|
|
568
568
|
u.drawImage(T, 0, 0, T.width, T.height, 0, 0, j, h), T.close(), u.globalCompositeOperation = "source-in";
|
|
569
569
|
}
|
|
570
|
-
const A = m * d, k = C * d, tt = -(A / 2 - m / 2) + f, et = -(k / 2 - C / 2) +
|
|
570
|
+
const A = m * d, k = C * d, tt = -(A / 2 - m / 2) + f, et = -(k / 2 - C / 2) + c;
|
|
571
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
572
|
const S = {
|
|
573
573
|
x: (j - j * 0.9) / 2,
|
|
574
574
|
y: (h - h * 0.9) / 2
|
|
575
575
|
}, v = await createImageBitmap(g);
|
|
576
576
|
u.clearRect(0, 0, g.width, g.height), u.scale(0.9, 0.9);
|
|
577
|
-
for (let
|
|
578
|
-
const { filling:
|
|
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 (
|
|
580
|
+
if (b) {
|
|
581
581
|
const [I, x] = W(j, h, D);
|
|
582
|
-
if (x.drawImage(z, 0, 0, j, h), x.globalCompositeOperation = "source-in",
|
|
582
|
+
if (x.drawImage(z, 0, 0, j, h), x.globalCompositeOperation = "source-in", b.color) {
|
|
583
583
|
const [p, N] = W(j, h, D);
|
|
584
|
-
N.fillStyle =
|
|
585
|
-
} else if (
|
|
586
|
-
const p = await B.fetchImageBitmap(
|
|
584
|
+
N.fillStyle = b.color, N.fillRect(0, 0, j, h), x.drawImage(p, 0, 0, j, h);
|
|
585
|
+
} else if (b.imageContent?.image) {
|
|
586
|
+
const p = await B.fetchImageBitmap(b.imageContent.image);
|
|
587
587
|
x.drawImage(p, 0, 0, j, h), p.close();
|
|
588
588
|
}
|
|
589
589
|
z = I;
|
|
@@ -593,19 +593,19 @@ 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, u.drawImage(z, I + S.x, x + S.y, j, h);
|
|
609
609
|
} else
|
|
610
610
|
u.drawImage(z, S.x, S.y, j, h);
|
|
611
611
|
}
|
|
@@ -616,16 +616,16 @@ async function V(e) {
|
|
|
616
616
|
try {
|
|
617
617
|
T(URL.createObjectURL(S));
|
|
618
618
|
} catch (v) {
|
|
619
|
-
console.error(`Failed to URL.createObjectURL, url: ${
|
|
619
|
+
console.error(`Failed to URL.createObjectURL, url: ${o}`, v), T(o);
|
|
620
620
|
}
|
|
621
621
|
});
|
|
622
622
|
});
|
|
623
623
|
}
|
|
624
|
-
function W(e, r,
|
|
624
|
+
function W(e, r, n = 1) {
|
|
625
625
|
const t = document.createElement("canvas");
|
|
626
|
-
t.width = e *
|
|
626
|
+
t.width = e * n, t.height = r * n, 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(n, n), [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 (
|
|
636
|
+
make(r, n) {
|
|
637
|
+
const { canvas: t } = this, s = this.canvas.getContext("2d"), i = n.thickness * 2, [o, f] = [r.width, r.height].map((c) => c + i);
|
|
638
|
+
return (o !== t.width || f !== t.height) && (t.width = o, t.height = f), s.clearRect(0, 0, s.canvas.width, s.canvas.height), this.method(s, r, n), s.drawImage(r, n.thickness, n.thickness), t;
|
|
639
639
|
}
|
|
640
640
|
}
|
|
641
641
|
function Ct(e) {
|
|
642
|
-
const t = e.canvas.width, s = e.canvas.height,
|
|
643
|
-
let
|
|
642
|
+
const t = e.canvas.width, s = e.canvas.height, i = [];
|
|
643
|
+
let o = 3;
|
|
644
644
|
const f = 100;
|
|
645
645
|
return (() => {
|
|
646
|
-
const d = [],
|
|
647
|
-
let a,
|
|
646
|
+
const d = [], l = new Uint32Array(e.getImageData(0, 0, t, s).data.buffer);
|
|
647
|
+
let a, M, L, w, y = -1, m, C = 9;
|
|
648
648
|
const j = [9, 0, 3, 3, 2, 0, 9, 3, 1, 9, 1, 1, 2, 0, 2, 9];
|
|
649
649
|
function h(g, u) {
|
|
650
|
-
return g >= 0 && u >= 0 && g < t && u < s ?
|
|
650
|
+
return g >= 0 && u >= 0 && g < t && u < s ? l[u * t + g] >>> 24 > f : !1;
|
|
651
651
|
}
|
|
652
652
|
function D(g, u) {
|
|
653
653
|
let A = 0;
|
|
654
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
655
|
}
|
|
656
|
-
for (let g =
|
|
657
|
-
if (
|
|
658
|
-
y =
|
|
656
|
+
for (let g = o; g < l.length; g++)
|
|
657
|
+
if (l[g] >>> 24 > f) {
|
|
658
|
+
y = o = g;
|
|
659
659
|
break;
|
|
660
660
|
}
|
|
661
661
|
if (y >= 0) {
|
|
662
|
-
a = L = y % t,
|
|
662
|
+
a = L = y % t, M = w = Math.floor(y / t);
|
|
663
663
|
do
|
|
664
|
-
m = D(a,
|
|
665
|
-
while (a !== L ||
|
|
664
|
+
m = D(a, M), m === 0 ? M-- : m === 1 ? M++ : m === 2 ? a-- : m === 3 && a++, m !== C && (d.push({ x: a + 0, y: M + 0 }), C = m);
|
|
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: n,
|
|
674
674
|
url: t,
|
|
675
675
|
style: s = {},
|
|
676
|
-
background:
|
|
676
|
+
background: i = {}
|
|
677
677
|
} = e;
|
|
678
|
-
let
|
|
679
|
-
|
|
678
|
+
let o = n;
|
|
679
|
+
o || (o = await fetch(t).then((c) => c.text()));
|
|
680
680
|
const f = new DOMParser().parseFromString(
|
|
681
|
-
|
|
681
|
+
o.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
|
-
throw new TypeError(`Failed to DOMParser, parse svg to DOM error: ${
|
|
686
|
-
if (
|
|
687
|
-
const
|
|
688
|
-
if (d &&
|
|
685
|
+
throw new TypeError(`Failed to DOMParser, parse svg to DOM error: ${o}`);
|
|
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+CjxnPgoJPHBhdGggZD0iTTE5LjMsMzguMWMwLjIsMC41LDAuNCwwLjksMC43LDEuNGMwLjIsMC4zLDAuNCwwLjQsMC44LDAuNGMwLjMsMCwwLjUtMC4xLDAuNi0wLjRjMC4xLTAuMywwLjEtMC42LDAuMi0wLjkgICBjMC0wLjIsMC4xLTAuNCwwLjMtMC41YzAuMi0wLjEsMC40LTAuMiwwLjYtMC4xYzAuMiwwLDAuNCwwLjEsMC41LDAuM2MwLjEsMC4yLDAuMiwwLjQsMC4xLDAuNmMtMC4xLDAuNi0wLjIsMS4yLTAuNCwxLjcgICBjLTAuMywwLjgtMC45LDEuMi0xLjcsMS4yYy0wLjksMC0xLjYtMC40LTIuMS0xLjJjLTAuMy0wLjQtMC41LTAuOC0wLjctMS4zYy0wLjQsMC4zLTEsMC42LTEuNywxYy0wLjUsMC4yLTAuOCwwLjEtMS4xLTAuMyAgIGMtMC4yLTAuNS0wLjEtMC45LDAuMy0xLjFjMC43LTAuNCwxLjQtMC44LDEuOS0xLjFjLTAuMi0wLjktMC40LTIuMS0wLjUtMy43TDE1LjksMzRjLTAuMiwwLTAuNCwwLTAuNi0wLjEgICBjLTAuMi0wLjEtMC4zLTAuMy0wLjMtMC41YzAtMC4yLDAtMC40LDAuMi0wLjZzMC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tMC4yLDAuMS0wLjQsMC4yLTAuNmMwLjItMC4yLDAuMy0wLjIsMC42LTAuMmMwLjIsMCwwLjQsMC4xLDAuNiwwLjIgICBjMC4yLDAuMiwwLjIsMC40LDAuMiwwLjZWNDAuN3ogTTU2LjYsNDAuM2MwLjIsMC40LDAuMSwwLjgtMC4zLDEuMWMtMC41LDAuMy0wLjgsMC4yLTEuMS0wLjNsLTEtMS43Yy0wLjItMC41LTAuMS0wLjgsMC4zLTEuMSAgIGMwLjUtMC4yLDAuOS0wLjEsMS4xLDAuM0w1Ni42LDQwLjN6Ii8+CjwvZz4KPC9zdmc+";
|
|
710
710
|
async function xt(e, r = !1) {
|
|
711
|
-
const { fetchToText:
|
|
711
|
+
const { fetchToText: n } = _(), 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 n(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 (n) => {
|
|
724
|
+
const t = {}, { offset: s, skew: i, stroke: o, shadow: f, filling: c } = n;
|
|
725
|
+
if (s && (t.translateX = s.x, t.translateY = s.y), i && (t.skewX = i.x, t.skewY = i.y), o?.color && o.width && (t.textStrokeWidth = o.width, t.textStrokeColor = o.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,76 +732,80 @@ 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 n;
|
|
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
|
-
let
|
|
741
|
-
for (const
|
|
742
|
-
s === 0 && f === 0 &&
|
|
740
|
+
let o = "", f = 0;
|
|
741
|
+
for (const c of Array.from(i))
|
|
742
|
+
s === 0 && f === 0 && c === " " || n === " " && c === " " || (o += c), n = c, f++;
|
|
743
743
|
return {
|
|
744
744
|
...t,
|
|
745
|
-
content:
|
|
745
|
+
content: o
|
|
746
746
|
};
|
|
747
747
|
}).filter((t) => t.content);
|
|
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: n } = _(), t = Dt(e), s = [];
|
|
752
|
+
for (let i = 0, o = t.length; i < o; 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 n(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 n(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, n) {
|
|
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,
|
|
778
782
|
children: []
|
|
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
|
-
const
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
785
|
+
const o = jt(e);
|
|
786
|
+
i.delay = o.delay, i.duration = o.duration, i.children.push(...o.animations), n && (o.animations.forEach((f) => {
|
|
787
|
+
n.endTime = Math.max(
|
|
788
|
+
n.endTime,
|
|
789
|
+
o.delay + f.delay + f.duration
|
|
786
790
|
);
|
|
787
|
-
}),
|
|
791
|
+
}), n.endTime = Math.max(n.endTime, o.delay + o.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
|
-
const
|
|
796
|
-
imageWidth:
|
|
799
|
+
const o = e.style.width, f = e.style.height, {
|
|
800
|
+
imageWidth: c,
|
|
797
801
|
imageHeight: d,
|
|
798
|
-
maskWidth:
|
|
802
|
+
maskWidth: l = o,
|
|
799
803
|
maskHeight: a = f,
|
|
800
|
-
translateX:
|
|
804
|
+
translateX: M,
|
|
801
805
|
translateY: L,
|
|
802
806
|
zoom: w = 1
|
|
803
|
-
} = e.cropping, y =
|
|
804
|
-
|
|
807
|
+
} = e.cropping, y = c * w, m = d * w, C = (y - l) / 2 - M, j = (m - a) / 2 - L, h = C + l / 2, D = j + a / 2, g = -(o / 2 - h), u = -(f / 2 - D), A = y - (g + o), k = m - (u + f);
|
|
808
|
+
i.foreground.cropRect = {
|
|
805
809
|
left: g / y,
|
|
806
810
|
top: u / m,
|
|
807
811
|
right: A / y,
|
|
@@ -810,27 +814,26 @@ async function q(e, r, o) {
|
|
|
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",
|
|
831
|
-
e.children.map(async (
|
|
833
|
+
s.inPptIs = "GroupShape", i.children = (await Promise.all(
|
|
834
|
+
e.children.map(async (o) => {
|
|
832
835
|
try {
|
|
833
|
-
return await q(
|
|
836
|
+
return await q(o, e, n);
|
|
834
837
|
} catch (f) {
|
|
835
838
|
console.warn(f);
|
|
836
839
|
return;
|
|
@@ -863,69 +866,72 @@ async function q(e, r, o) {
|
|
|
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, n) {
|
|
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 o;
|
|
882
|
+
return e.background && (e.background.color && (o ??= {}, dt(e.background.color ?? "") ? o.image = e.background.color : o.color = e.background.color), e.background.image && (o ??= {}, o.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: o,
|
|
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, n);
|
|
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: n,
|
|
899
904
|
metas: t = {}
|
|
900
905
|
} = e, s = {
|
|
901
906
|
endTime: 0
|
|
902
907
|
};
|
|
903
|
-
let
|
|
904
|
-
|
|
908
|
+
let i = await Promise.all(
|
|
909
|
+
n.map(async (c, d) => ({
|
|
905
910
|
index: d,
|
|
906
|
-
element: await St(
|
|
911
|
+
element: await St(c, !0, s)
|
|
907
912
|
}))
|
|
908
|
-
),
|
|
909
|
-
|
|
910
|
-
const
|
|
911
|
-
return
|
|
913
|
+
), o = 0;
|
|
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 = o, o += 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,104 +940,104 @@ async function K(e, r = 0) {
|
|
|
934
940
|
};
|
|
935
941
|
}
|
|
936
942
|
function zt(e, r) {
|
|
937
|
-
const { config:
|
|
943
|
+
const { config: n } = 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",
|
|
948
|
+
const s = t.bid ?? t.tid ?? "", i = async (l) => await fetch(
|
|
949
|
+
(t.bid ? r.bid : r.tid).replace("%d", l)
|
|
944
950
|
).then((a) => a.json()).then((a) => JSON.parse(a.data.content));
|
|
945
|
-
let
|
|
951
|
+
let o = 0;
|
|
946
952
|
const f = await Promise.all(
|
|
947
|
-
s.split("|").map(async (
|
|
948
|
-
let [a,
|
|
949
|
-
|
|
950
|
-
const L =
|
|
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((m) => Number(m)) : void 0, w = await i(a);
|
|
951
957
|
L !== void 0 && (w.layouts = w.layouts.filter((m, C) => L.includes(C)));
|
|
952
958
|
const y = await K(w);
|
|
953
|
-
return
|
|
959
|
+
return o = Math.max(o, y.meta?.maxTime ?? 0), y;
|
|
954
960
|
})
|
|
955
|
-
),
|
|
956
|
-
|
|
961
|
+
), c = { ...f[0], id: s, children: [] };
|
|
962
|
+
c.meta ??= {}, c.meta.maxTime = o, 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 + n.value.frameGap;
|
|
969
|
+
}), c;
|
|
964
970
|
}
|
|
965
971
|
};
|
|
966
972
|
}
|
|
967
|
-
function Nt(
|
|
968
|
-
const { config: r } = e;
|
|
973
|
+
function Nt() {
|
|
969
974
|
return {
|
|
970
975
|
name: "bigesj:bige",
|
|
971
976
|
accept: ".bige",
|
|
972
|
-
test: (
|
|
973
|
-
load: async (
|
|
974
|
-
JSON.parse(
|
|
977
|
+
test: (e) => e instanceof File && e.name.endsWith(".bige"),
|
|
978
|
+
load: async (e) => {
|
|
979
|
+
const r = JSON.parse(
|
|
975
980
|
new TextDecoder().decode(
|
|
976
|
-
Lt(new Uint8Array(await
|
|
981
|
+
Lt(new Uint8Array(await e.arrayBuffer()))
|
|
977
982
|
)
|
|
978
|
-
)
|
|
979
|
-
|
|
983
|
+
), { content: n, ...t } = r, s = await K(n);
|
|
984
|
+
return s.meta.raw = t, s;
|
|
985
|
+
}
|
|
980
986
|
};
|
|
981
987
|
}
|
|
982
988
|
function Qt(e = {}) {
|
|
983
989
|
const {
|
|
984
990
|
font: r,
|
|
985
|
-
api:
|
|
991
|
+
api: n
|
|
986
992
|
} = e, t = {
|
|
987
993
|
fonts: "/new/design/fonts",
|
|
988
994
|
bid: "/new/udesign/info/%d",
|
|
989
995
|
tid: "/new/design/info/%d",
|
|
990
|
-
...
|
|
996
|
+
...n
|
|
991
997
|
};
|
|
992
998
|
return ot((s) => ({
|
|
993
999
|
name: "bigesj",
|
|
994
1000
|
loaders: [
|
|
995
|
-
Nt(
|
|
1001
|
+
Nt(),
|
|
996
1002
|
zt(s, t)
|
|
997
1003
|
],
|
|
998
1004
|
setup: async () => {
|
|
999
|
-
r && await
|
|
1005
|
+
r && await bt(s, t);
|
|
1000
1006
|
}
|
|
1001
1007
|
}));
|
|
1002
1008
|
}
|
|
1003
|
-
async function
|
|
1009
|
+
async function bt(e, r) {
|
|
1004
1010
|
const {
|
|
1005
|
-
on:
|
|
1011
|
+
on: n,
|
|
1006
1012
|
off: t,
|
|
1007
1013
|
root: s
|
|
1008
1014
|
} = e, {
|
|
1009
|
-
loadBigeFonts:
|
|
1010
|
-
loadFont:
|
|
1015
|
+
loadBigeFonts: i,
|
|
1016
|
+
loadFont: o
|
|
1011
1017
|
} = mt();
|
|
1012
|
-
function f(
|
|
1013
|
-
|
|
1014
|
-
a.fragments.forEach((
|
|
1015
|
-
|
|
1016
|
-
}), a.fontFamily &&
|
|
1018
|
+
function f(l) {
|
|
1019
|
+
l instanceof nt && (l.style.fontFamily && o(l.style.fontFamily).then(() => l.text.update()), l.text.content.forEach((a) => {
|
|
1020
|
+
a.fragments.forEach((M) => {
|
|
1021
|
+
M.fontFamily && o(M.fontFamily).then(() => l.text.update());
|
|
1022
|
+
}), a.fontFamily && o(a.fontFamily).then(() => l.text.update());
|
|
1017
1023
|
}));
|
|
1018
1024
|
}
|
|
1019
|
-
function
|
|
1020
|
-
|
|
1021
|
-
f(a), a.findOne((
|
|
1025
|
+
function c(l) {
|
|
1026
|
+
l.forEach((a) => {
|
|
1027
|
+
f(a), a.findOne((M) => (f(M), !1));
|
|
1022
1028
|
});
|
|
1023
1029
|
}
|
|
1024
1030
|
async function d() {
|
|
1025
|
-
s.value &&
|
|
1031
|
+
s.value && c([s.value]);
|
|
1026
1032
|
}
|
|
1027
1033
|
lt(() => {
|
|
1028
|
-
t("setDoc", d), t("addElement",
|
|
1029
|
-
}),
|
|
1034
|
+
t("setDoc", d), t("addElement", c);
|
|
1035
|
+
}), n("setDoc", d), n("addElement", c), await i(r.fonts);
|
|
1030
1036
|
}
|
|
1031
1037
|
export {
|
|
1032
1038
|
zt as bidTidLoader,
|
|
1033
1039
|
Nt as bigeLoader,
|
|
1034
|
-
|
|
1040
|
+
U as convertAnimation,
|
|
1035
1041
|
K as convertDoc,
|
|
1036
1042
|
q as convertElement,
|
|
1037
1043
|
V as convertImageElementToUrl,
|
package/dist/loaders/bige.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function bigeLoader(editor: Editor): Mce.Loader;
|
|
1
|
+
export declare function bigeLoader(): Mce.Loader;
|
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.7",
|
|
5
5
|
"description": "Plugin for mce",
|
|
6
6
|
"author": "wxm",
|
|
7
7
|
"license": "MIT",
|
|
@@ -52,7 +52,7 @@
|
|
|
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.7"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"mce": "^0"
|