@mce/bigesj 0.2.2 → 0.2.4
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/text.d.ts +1 -1
- package/dist/index.js +261 -272
- package/package.json +4 -4
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
|
|
1
|
+
import { useEditor as k, definePlugin as O } from "mce";
|
|
2
|
+
import { Element2D as v } from "modern-canvas";
|
|
3
|
+
import { ref as D, effectScope as Q, getCurrentScope as X, onScopeDispose as G, onBeforeUnmount as W } from "vue";
|
|
4
|
+
import { idGenerator as h, normalizeCRLF as F, isGradient as P } from "modern-idoc";
|
|
5
|
+
import { gunzipSync as B } from "fflate";
|
|
6
|
+
const C = D([]);
|
|
7
|
+
function J(e, r) {
|
|
8
8
|
const n = [];
|
|
9
|
-
for (let t = 0; t <=
|
|
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
|
-
for (let t = 1; t <=
|
|
14
|
-
for (let
|
|
15
|
-
const
|
|
16
|
-
n[t][
|
|
13
|
+
for (let t = 1; t <= r.length; t++)
|
|
14
|
+
for (let i = 1; i <= e.length; i++) {
|
|
15
|
+
const o = e[i - 1] === r[t - 1] ? 0 : 1;
|
|
16
|
+
n[t][i] = Math.min(n[t - 1][i] + 1, n[t][i - 1] + 1, n[t - 1][i - 1] + o);
|
|
17
17
|
}
|
|
18
|
-
return n[
|
|
18
|
+
return n[r.length][e.length];
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function U() {
|
|
21
21
|
const {
|
|
22
22
|
loadFont: e
|
|
23
|
-
} =
|
|
24
|
-
async function n(
|
|
25
|
-
let
|
|
26
|
-
return
|
|
23
|
+
} = k(), r = D(/* @__PURE__ */ new Map());
|
|
24
|
+
async function n(o) {
|
|
25
|
+
let s = C.value;
|
|
26
|
+
return s.length || (s = await fetch(o).then((f) => f.json()).then((f) => f.data.datalist), C.value = s), s;
|
|
27
27
|
}
|
|
28
|
-
function t(
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
), d =
|
|
32
|
-
let
|
|
33
|
-
if (d.forEach((
|
|
34
|
-
|
|
35
|
-
}),
|
|
36
|
-
let
|
|
28
|
+
function t(o, s = C.value) {
|
|
29
|
+
const f = new Map(s.map((a, c) => [a.id, c])), L = new Map(
|
|
30
|
+
s.flatMap((a, c) => [...a.en_name.split(","), ...a.name.split(",")].map((l) => [l, c]))
|
|
31
|
+
), d = o.replace(/"/g, "").split(",");
|
|
32
|
+
let M;
|
|
33
|
+
if (d.forEach((a) => {
|
|
34
|
+
M ??= f.get(a), M ??= L.get(a);
|
|
35
|
+
}), M === void 0) {
|
|
36
|
+
let a;
|
|
37
37
|
d.forEach((c) => {
|
|
38
38
|
let l = c;
|
|
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
|
-
L.forEach((
|
|
42
|
-
const y =
|
|
41
|
+
L.forEach((u, m) => {
|
|
42
|
+
const y = J(l, m);
|
|
43
43
|
if (w <= y)
|
|
44
44
|
return;
|
|
45
|
-
const
|
|
46
|
-
(
|
|
45
|
+
const j = -(y * 0.9 + (m.endsWith("常规") ? 0 : 1) * 0.1);
|
|
46
|
+
(a === void 0 || j > a) && (a = j, M = u);
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
return
|
|
50
|
+
return M !== void 0 ? s[M] : void 0;
|
|
51
51
|
}
|
|
52
|
-
async function
|
|
53
|
-
const
|
|
54
|
-
for (const L of
|
|
55
|
-
let d =
|
|
52
|
+
async function i(o) {
|
|
53
|
+
const s = typeof o == "string" ? [o] : o, f = [];
|
|
54
|
+
for (const L of s) {
|
|
55
|
+
let d = r.value.get(L);
|
|
56
56
|
if (!d) {
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
const
|
|
57
|
+
const M = t(L);
|
|
58
|
+
if (M && (d = r.value.get(M.en_name), !d)) {
|
|
59
|
+
const a = Array.from(
|
|
60
60
|
new Set(
|
|
61
|
-
[L,
|
|
61
|
+
[L, M.en_name].filter(Boolean).map((c) => c.replace(/"/g, ""))
|
|
62
62
|
)
|
|
63
63
|
);
|
|
64
64
|
d = e({
|
|
65
|
-
family:
|
|
66
|
-
src:
|
|
67
|
-
}),
|
|
65
|
+
family: a,
|
|
66
|
+
src: M.fonturl
|
|
67
|
+
}), a.forEach((c) => r.value.set(c, d)), r.value.set(String(L), 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: C,
|
|
76
76
|
searchBigeFont: t,
|
|
77
77
|
loadBigeFonts: n,
|
|
78
|
-
loadFont:
|
|
78
|
+
loadFont: i
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
return
|
|
81
|
+
function R(e, r) {
|
|
82
|
+
return X() ? (G(e, r), !0) : !1;
|
|
83
83
|
}
|
|
84
|
-
const
|
|
84
|
+
const Z = 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 $(e) {
|
|
88
|
+
if (!Z) return e;
|
|
89
|
+
let r = 0, n, t;
|
|
90
|
+
const i = () => {
|
|
91
|
+
r -= 1, t && r <= 0 && (t.stop(), n = void 0, t = void 0);
|
|
92
92
|
};
|
|
93
|
-
return ((...
|
|
93
|
+
return ((...o) => (r += 1, t || (t = Q(!0), n = t.run(() => e(...o))), R(i), n));
|
|
94
94
|
}
|
|
95
|
-
const
|
|
95
|
+
const I = /* @__PURE__ */ $(() => {
|
|
96
96
|
const e = /* @__PURE__ */ new Map();
|
|
97
|
-
function
|
|
98
|
-
let
|
|
99
|
-
return
|
|
97
|
+
function r(t, i) {
|
|
98
|
+
let o = e.get(t);
|
|
99
|
+
return o || (o = fetch(t).then(i), e.set(t, o)), o;
|
|
100
100
|
}
|
|
101
101
|
async function n(t) {
|
|
102
|
-
return
|
|
102
|
+
return r(t, (i) => i.text());
|
|
103
103
|
}
|
|
104
104
|
return {
|
|
105
105
|
fetchToText: n
|
|
106
106
|
};
|
|
107
|
-
}),
|
|
107
|
+
}), g = {
|
|
108
108
|
easing: {
|
|
109
109
|
匀速: "linear",
|
|
110
110
|
加速: "cubic-bezier(0.55, 0, 1, 0.45)",
|
|
@@ -437,190 +437,179 @@ const S = /* @__PURE__ */ Z(() => {
|
|
|
437
437
|
]
|
|
438
438
|
}
|
|
439
439
|
};
|
|
440
|
-
function
|
|
440
|
+
function A(e, r, n) {
|
|
441
441
|
const {
|
|
442
442
|
name: t,
|
|
443
|
-
delay:
|
|
444
|
-
duration:
|
|
445
|
-
iterations:
|
|
446
|
-
mode:
|
|
443
|
+
delay: i = 0,
|
|
444
|
+
duration: o,
|
|
445
|
+
iterations: s,
|
|
446
|
+
mode: f,
|
|
447
447
|
easing: L,
|
|
448
448
|
path: d,
|
|
449
|
-
offsetRotate:
|
|
450
|
-
...
|
|
451
|
-
} =
|
|
449
|
+
offsetRotate: M,
|
|
450
|
+
...a
|
|
451
|
+
} = r;
|
|
452
452
|
let c;
|
|
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((u) => {
|
|
456
|
+
const m = Object.keys(u);
|
|
457
|
+
l += ` ${m[0]}${u[m[0]].join(" ")}`;
|
|
458
458
|
});
|
|
459
459
|
const w = `path("${l}")`;
|
|
460
460
|
switch (n) {
|
|
461
461
|
case "in":
|
|
462
462
|
c = [
|
|
463
|
-
{ opacity: 0, offsetDistance: "100%", offsetPath: w, offsetRotate:
|
|
464
|
-
{ offsetDistance: "0%", offsetPath: w, offsetRotate:
|
|
463
|
+
{ opacity: 0, offsetDistance: "100%", offsetPath: w, offsetRotate: M },
|
|
464
|
+
{ offsetDistance: "0%", offsetPath: w, offsetRotate: M }
|
|
465
465
|
];
|
|
466
466
|
break;
|
|
467
467
|
case "stay":
|
|
468
468
|
c = [
|
|
469
|
-
{ offsetDistance: "0%", offsetPath: w, offsetRotate:
|
|
470
|
-
{ offsetDistance: "100%", offsetPath: w, offsetRotate:
|
|
469
|
+
{ offsetDistance: "0%", offsetPath: w, offsetRotate: M },
|
|
470
|
+
{ offsetDistance: "100%", offsetPath: w, offsetRotate: M }
|
|
471
471
|
];
|
|
472
472
|
break;
|
|
473
473
|
case "out":
|
|
474
474
|
c = [
|
|
475
|
-
{ offsetDistance: "0%", offsetPath: w, offsetRotate:
|
|
476
|
-
{ opacity: 0, offsetDistance: "100%", offsetPath: w, offsetRotate:
|
|
475
|
+
{ offsetDistance: "0%", offsetPath: w, offsetRotate: M },
|
|
476
|
+
{ opacity: 0, offsetDistance: "100%", offsetPath: w, offsetRotate: M }
|
|
477
477
|
];
|
|
478
478
|
break;
|
|
479
479
|
}
|
|
480
480
|
} else
|
|
481
481
|
switch (n) {
|
|
482
482
|
case "in":
|
|
483
|
-
c =
|
|
483
|
+
c = g.textIn[t]?.[0] ?? g.in[t];
|
|
484
484
|
break;
|
|
485
485
|
case "stay":
|
|
486
|
-
c =
|
|
486
|
+
c = g.stay[t];
|
|
487
487
|
break;
|
|
488
488
|
case "out":
|
|
489
|
-
c =
|
|
489
|
+
c = g.out[t];
|
|
490
490
|
break;
|
|
491
491
|
}
|
|
492
492
|
return {
|
|
493
|
-
id:
|
|
494
|
-
name:
|
|
495
|
-
delay:
|
|
496
|
-
duration: t ?
|
|
497
|
-
effectMode:
|
|
493
|
+
id: h(),
|
|
494
|
+
name: r.name ?? r.title ?? r.id,
|
|
495
|
+
delay: i,
|
|
496
|
+
duration: t ? o * (s || 1) : 0,
|
|
497
|
+
effectMode: f === "逐字" || f === "逐行" ? "sibling" : "parent",
|
|
498
498
|
keyframes: c ?? [],
|
|
499
|
-
easing:
|
|
499
|
+
easing: g.easing[L],
|
|
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 H(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, 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 i = r?.delay ?? 0, o = t ? t.delay - i + t.duration : 0, s = [];
|
|
518
|
+
return r && s.push(
|
|
519
|
+
A(e, {
|
|
520
|
+
...r,
|
|
521
521
|
delay: 0
|
|
522
522
|
}, "in")
|
|
523
|
-
), n &&
|
|
524
|
-
|
|
523
|
+
), n && s.push(
|
|
524
|
+
A(e, {
|
|
525
525
|
...n,
|
|
526
|
-
delay: n.delay -
|
|
526
|
+
delay: n.delay - i
|
|
527
527
|
}, "stay")
|
|
528
|
-
), t &&
|
|
529
|
-
|
|
528
|
+
), t && s.push(
|
|
529
|
+
A(e, {
|
|
530
530
|
...t,
|
|
531
|
-
delay: t.delay -
|
|
531
|
+
delay: t.delay - i
|
|
532
532
|
}, "out")
|
|
533
533
|
), {
|
|
534
|
-
delay:
|
|
535
|
-
duration:
|
|
536
|
-
animations:
|
|
534
|
+
delay: i,
|
|
535
|
+
duration: o - i,
|
|
536
|
+
animations: s.filter((f) => !!f?.keyframes)
|
|
537
537
|
};
|
|
538
538
|
}
|
|
539
|
-
const
|
|
540
|
-
async function
|
|
541
|
-
const { fetchToText: n } =
|
|
539
|
+
const _ = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgNzIgNzIiIHN0eWxlPSJlbmFibGUtYmFja2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vZz4KPC9zdmc+";
|
|
540
|
+
async function V(e, r = !1) {
|
|
541
|
+
const { fetchToText: n } = I(), t = {
|
|
542
542
|
...e.style,
|
|
543
|
-
highlightReferImage:
|
|
543
|
+
highlightReferImage: _,
|
|
544
544
|
listStyleType: "none",
|
|
545
545
|
listStyleImage: "none"
|
|
546
546
|
};
|
|
547
|
-
return e.style.fontSize && (t.fontSize = Math.floor(e.style.fontSize)), e.listStyle?.colormap && (t.listStyleColormap = e.listStyle?.colormap),
|
|
547
|
+
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;
|
|
548
548
|
}
|
|
549
|
-
async function
|
|
550
|
-
const
|
|
551
|
-
if (
|
|
549
|
+
async function q(e) {
|
|
550
|
+
const r = e.textEffects ?? [];
|
|
551
|
+
if (r.length)
|
|
552
552
|
return await Promise.all(
|
|
553
|
-
[...
|
|
554
|
-
const
|
|
555
|
-
if (
|
|
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
|
-
}
|
|
553
|
+
[...r].reverse().map(async (n) => {
|
|
554
|
+
const t = {}, { offset: i, skew: o, stroke: s, shadow: f, filling: L } = n;
|
|
555
|
+
if (i && (t.translateX = i.x, t.translateY = i.y), o && (t.skewX = o.x, t.skewY = o.y), s?.color && s.width && (t.textStrokeWidth = s.width, t.textStrokeColor = s.color), f && (t.shadowOffsetX = f.offsetX, t.shadowOffsetY = f.offsetY, t.shadowBlur = f.blur, t.shadowColor = f.color), L) {
|
|
556
|
+
const { color: d, imageContent: M, gradient: a } = L;
|
|
557
|
+
M?.image || (a ? t.color = `linear-gradient(${90 - a.angle}deg, ${a.stops.map((c) => `${c.color} ${c.offset * 100}%`).join(",")})` : d && (t.color = d));
|
|
566
558
|
}
|
|
567
|
-
return
|
|
559
|
+
return t;
|
|
568
560
|
})
|
|
569
561
|
);
|
|
570
562
|
}
|
|
571
|
-
function
|
|
572
|
-
return e.version ? e.contents : e.contents.map((
|
|
563
|
+
function K(e) {
|
|
564
|
+
return e.version ? e.contents : e.contents.map((r) => {
|
|
573
565
|
let n;
|
|
574
|
-
return
|
|
575
|
-
let
|
|
576
|
-
|
|
566
|
+
return r.map((t, i) => {
|
|
567
|
+
let o = t.content;
|
|
568
|
+
o = o.replace(/ |\r\n|\n\r|[\n\r\t\v]/g, " "), o = o.replace(/<br\/>/g, `
|
|
577
569
|
`);
|
|
578
|
-
let
|
|
579
|
-
for (const
|
|
580
|
-
|
|
570
|
+
let s = "", f = 0;
|
|
571
|
+
for (const L of Array.from(o))
|
|
572
|
+
i === 0 && f === 0 && L === " " || n === " " && L === " " || (s += L), n = L, f++;
|
|
581
573
|
return {
|
|
582
574
|
...t,
|
|
583
|
-
content:
|
|
575
|
+
content: s
|
|
584
576
|
};
|
|
585
577
|
}).filter((t) => t.content);
|
|
586
578
|
});
|
|
587
579
|
}
|
|
588
|
-
async function
|
|
589
|
-
const { fetchToText: n } =
|
|
590
|
-
for (let
|
|
591
|
-
const
|
|
580
|
+
async function tt(e, r = !1) {
|
|
581
|
+
const { fetchToText: n } = I(), t = K(e), i = [];
|
|
582
|
+
for (let o = 0, s = t.length; o < s; o++) {
|
|
583
|
+
const f = t[o], L = {
|
|
592
584
|
fragments: []
|
|
593
585
|
};
|
|
594
|
-
|
|
595
|
-
for (let d = 0,
|
|
596
|
-
const
|
|
597
|
-
|
|
586
|
+
i.push(L);
|
|
587
|
+
for (let d = 0, M = f.length; d < M; d++) {
|
|
588
|
+
const a = {}, c = f[d];
|
|
589
|
+
for (const w in c)
|
|
590
|
+
w !== "id" && c[w] !== "" && (a[w] = c[w]);
|
|
591
|
+
a.fontSize && (a.fontSize = Math.floor(a.fontSize)), a.content = F(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 ? L.listStyleType = "disc" : a.listStyle && (L.listStyleImage = await n(a.listStyle.image), L.listStyleSize = `${a.listStyle.size * 100}%`));
|
|
592
|
+
const l = L.fragments[L.fragments.length - 1];
|
|
593
|
+
l && Object.keys(l).length === 1 && l.content && Object.keys(a).length === 1 && a.content ? l.content += a.content : L.fragments.push(a);
|
|
598
594
|
}
|
|
599
595
|
}
|
|
600
|
-
return
|
|
596
|
+
return i;
|
|
601
597
|
}
|
|
602
|
-
const
|
|
603
|
-
async function
|
|
604
|
-
const t = e.style ?? e
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
598
|
+
const p = (e) => (Number.parseFloat(e) || 0) / 100;
|
|
599
|
+
async function S(e, r, n) {
|
|
600
|
+
const t = { ...e.style ?? e }, i = {
|
|
601
|
+
inPptIs: "Shape",
|
|
602
|
+
inEditorIs: "Element"
|
|
603
|
+
}, o = {
|
|
604
|
+
id: h(),
|
|
608
605
|
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
|
-
},
|
|
606
|
+
style: t,
|
|
607
|
+
meta: i,
|
|
619
608
|
children: []
|
|
620
609
|
};
|
|
621
|
-
if (e.animations?.length) {
|
|
622
|
-
const s =
|
|
623
|
-
|
|
610
|
+
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 && (i.lock = !0), e.animations?.length) {
|
|
611
|
+
const s = H(e);
|
|
612
|
+
o.delay = s.delay, o.duration = s.duration, o.children.push(...s.animations), n && (s.animations.forEach((f) => {
|
|
624
613
|
n.endTime = Math.max(
|
|
625
614
|
n.endTime,
|
|
626
615
|
s.delay + f.delay + f.duration
|
|
@@ -629,49 +618,49 @@ async function z(e, o, n) {
|
|
|
629
618
|
}
|
|
630
619
|
switch (e.type) {
|
|
631
620
|
case "image":
|
|
632
|
-
if (
|
|
621
|
+
if (i.inPptIs = "Picture", o.foreground = {
|
|
633
622
|
image: e.url,
|
|
634
623
|
fillWithShape: !0
|
|
635
624
|
}, e.maskUrl, e.cropping) {
|
|
636
625
|
const s = e.style.width, f = e.style.height, {
|
|
637
|
-
imageWidth:
|
|
638
|
-
imageHeight:
|
|
639
|
-
maskWidth:
|
|
640
|
-
maskHeight:
|
|
641
|
-
translateX:
|
|
642
|
-
translateY:
|
|
643
|
-
zoom:
|
|
644
|
-
} = e.cropping,
|
|
645
|
-
|
|
646
|
-
left:
|
|
647
|
-
top:
|
|
648
|
-
right: b /
|
|
649
|
-
bottom:
|
|
626
|
+
imageWidth: L,
|
|
627
|
+
imageHeight: d,
|
|
628
|
+
maskWidth: M = s,
|
|
629
|
+
maskHeight: a = f,
|
|
630
|
+
translateX: c,
|
|
631
|
+
translateY: l,
|
|
632
|
+
zoom: w = 1
|
|
633
|
+
} = e.cropping, u = L * w, m = d * w, y = (u - M) / 2 - c, j = (m - a) / 2 - l, N = y + M / 2, E = j + a / 2, x = -(s / 2 - N), T = -(f / 2 - E), b = u - (x + s), Y = m - (T + f);
|
|
634
|
+
o.foreground.cropRect = {
|
|
635
|
+
left: x / u,
|
|
636
|
+
top: T / m,
|
|
637
|
+
right: b / u,
|
|
638
|
+
bottom: Y / m
|
|
650
639
|
};
|
|
651
640
|
}
|
|
652
641
|
break;
|
|
653
642
|
case "svg": {
|
|
654
|
-
|
|
643
|
+
i.inPptIs = "Picture";
|
|
655
644
|
let s = e.doc;
|
|
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}"`),
|
|
645
|
+
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}"`), o.foreground = {
|
|
657
646
|
image: `data:image/svg+xml;charset=utf-8,${encodeURIComponent(s)}`,
|
|
658
647
|
fillWithShape: !0
|
|
659
648
|
};
|
|
660
649
|
break;
|
|
661
650
|
}
|
|
662
651
|
case "text": {
|
|
663
|
-
|
|
664
|
-
content: await
|
|
665
|
-
style: await
|
|
666
|
-
effects: await
|
|
652
|
+
i.inPptIs = "Shape", t.writingMode === "horizontal-tb" ? t.width = Math.ceil(t.width + t.letterSpacing) : t.height = Math.ceil(t.height + t.letterSpacing), o.text = {
|
|
653
|
+
content: await tt(e),
|
|
654
|
+
style: await V(e),
|
|
655
|
+
effects: await q(e),
|
|
667
656
|
// plugins: [deformation(el.deformation?.type?.endsWith("byWord") ? -1 : 999, () => el.deformation)],
|
|
668
657
|
drawMode: "texture"
|
|
669
658
|
};
|
|
670
659
|
break;
|
|
671
660
|
}
|
|
672
661
|
case "com":
|
|
673
|
-
|
|
674
|
-
e.children.map((s) =>
|
|
662
|
+
i.inPptIs = "GroupShape", o.children = await Promise.all(
|
|
663
|
+
e.children.map((s) => S(s, e, n))
|
|
675
664
|
);
|
|
676
665
|
break;
|
|
677
666
|
case "pic":
|
|
@@ -699,119 +688,119 @@ async function z(e, o, n) {
|
|
|
699
688
|
console.warn(e);
|
|
700
689
|
break;
|
|
701
690
|
}
|
|
702
|
-
return
|
|
691
|
+
return o;
|
|
703
692
|
}
|
|
704
|
-
async function
|
|
705
|
-
const t =
|
|
693
|
+
async function et(e, r = !0, n) {
|
|
694
|
+
const t = h(), i = {
|
|
706
695
|
...e.style ?? e
|
|
707
696
|
};
|
|
708
|
-
|
|
709
|
-
let
|
|
710
|
-
return e.background && (e.background.color && (
|
|
697
|
+
r && (i.overflow = "hidden");
|
|
698
|
+
let o;
|
|
699
|
+
return e.background && (e.background.color && (o ??= {}, P(e.background.color ?? "") ? o.image = e.background.color : o.color = e.background.color), e.background.image && (o ??= {}, o.image = e.background.image)), {
|
|
711
700
|
id: t,
|
|
712
|
-
name:
|
|
713
|
-
style:
|
|
701
|
+
name: r ? `Frame ${t}` : e.name,
|
|
702
|
+
style: i,
|
|
714
703
|
// TODO 过滤掉部分属性
|
|
715
|
-
background:
|
|
704
|
+
background: o,
|
|
716
705
|
children: await Promise.all(
|
|
717
|
-
e.elements.map((
|
|
706
|
+
e.elements.map((s) => S(s, void 0, n))
|
|
718
707
|
),
|
|
719
708
|
meta: {
|
|
720
|
-
inPptIs:
|
|
721
|
-
inEditorIs:
|
|
709
|
+
inPptIs: r ? "Slide" : "GroupShape",
|
|
710
|
+
inEditorIs: r ? "Frame" : "Element"
|
|
722
711
|
}
|
|
723
712
|
};
|
|
724
713
|
}
|
|
725
|
-
async function
|
|
714
|
+
async function z(e, r = 48) {
|
|
726
715
|
const {
|
|
727
716
|
layouts: n,
|
|
728
717
|
metas: t = {}
|
|
729
|
-
} = e,
|
|
718
|
+
} = e, i = {
|
|
730
719
|
endTime: 0
|
|
731
720
|
};
|
|
732
|
-
let
|
|
721
|
+
let o = await Promise.all(
|
|
733
722
|
n.map(async (L, d) => ({
|
|
734
723
|
index: d,
|
|
735
|
-
element: await
|
|
724
|
+
element: await et(L, !0, i)
|
|
736
725
|
}))
|
|
737
|
-
),
|
|
738
|
-
|
|
739
|
-
const
|
|
740
|
-
return
|
|
726
|
+
), s = 0;
|
|
727
|
+
o = o.sort((L, d) => L.index - d.index).map((L, d) => {
|
|
728
|
+
const M = L.element;
|
|
729
|
+
return M.style && (M.style.top = s, s += Number(M.style.height) + r), M.name = `Frame ${d + 1}`, M;
|
|
741
730
|
});
|
|
742
|
-
const
|
|
743
|
-
const d = L.style?.left ?? 0,
|
|
731
|
+
const f = o.reduce((L) => {
|
|
732
|
+
const d = L.style?.left ?? 0, M = L.style?.top ?? 0, a = L.style?.width ?? 0, c = L.style?.height ?? 0;
|
|
744
733
|
return {
|
|
745
734
|
minX: d,
|
|
746
|
-
minY:
|
|
747
|
-
maxX: d +
|
|
748
|
-
maxY:
|
|
735
|
+
minY: M,
|
|
736
|
+
maxX: d + a,
|
|
737
|
+
maxY: M + c
|
|
749
738
|
};
|
|
750
739
|
}, { minX: 0, minY: 0, maxX: 0, maxY: 0 });
|
|
751
740
|
return {
|
|
752
741
|
name: t.name || "doc",
|
|
753
742
|
style: {
|
|
754
|
-
width: t?.width ??
|
|
755
|
-
height: t?.height ??
|
|
743
|
+
width: t?.width ?? f.maxX - f.minX,
|
|
744
|
+
height: t?.height ?? f.maxY - f.minY
|
|
756
745
|
},
|
|
757
|
-
children:
|
|
746
|
+
children: o,
|
|
758
747
|
meta: {
|
|
759
748
|
...t,
|
|
760
|
-
endTime:
|
|
749
|
+
endTime: i.endTime,
|
|
761
750
|
inEditorIs: "Doc"
|
|
762
751
|
}
|
|
763
752
|
};
|
|
764
753
|
}
|
|
765
|
-
function
|
|
754
|
+
function at(e, r) {
|
|
766
755
|
const { config: n } = e;
|
|
767
756
|
return {
|
|
768
757
|
name: "bigesj:bidTid",
|
|
769
758
|
test: (t) => typeof t == "object" && t && !!(t.bid || t.tid),
|
|
770
759
|
load: async (t) => {
|
|
771
|
-
const
|
|
772
|
-
(t.bid ?
|
|
773
|
-
).then((
|
|
774
|
-
let
|
|
775
|
-
const
|
|
776
|
-
|
|
777
|
-
let [
|
|
760
|
+
const i = t.bid ?? t.tid ?? "", o = async (M) => await fetch(
|
|
761
|
+
(t.bid ? r.bid : r.tid).replace("%d", M)
|
|
762
|
+
).then((a) => a.json()).then((a) => JSON.parse(a.data.content));
|
|
763
|
+
let s = 0;
|
|
764
|
+
const f = await Promise.all(
|
|
765
|
+
i.split("|").map(async (M) => {
|
|
766
|
+
let [a, c] = M.split("[");
|
|
778
767
|
c && (c = c.substring(0, c.length - 1));
|
|
779
|
-
const l = c ? c.split(",").map((
|
|
780
|
-
l !== void 0 && (w.layouts = w.layouts.filter((
|
|
781
|
-
const
|
|
782
|
-
return
|
|
768
|
+
const l = c ? c.split(",").map((m) => Number(m)) : void 0, w = await o(a);
|
|
769
|
+
l !== void 0 && (w.layouts = w.layouts.filter((m, y) => l.includes(y)));
|
|
770
|
+
const u = await z(w, n.value.frameGap);
|
|
771
|
+
return s = Math.max(s, u.meta?.maxTime ?? 0), u;
|
|
783
772
|
})
|
|
784
|
-
), L = { ...
|
|
785
|
-
L.meta ??= {}, L.meta.maxTime =
|
|
773
|
+
), L = { ...f[0], id: i, children: [] };
|
|
774
|
+
L.meta ??= {}, L.meta.maxTime = s, L.meta.inEditorIs = "Doc";
|
|
786
775
|
let d = 0;
|
|
787
|
-
return
|
|
788
|
-
let
|
|
789
|
-
|
|
790
|
-
c.style && (c.style.left = d,
|
|
791
|
-
}), d +=
|
|
776
|
+
return f.forEach((M) => {
|
|
777
|
+
let a = 0;
|
|
778
|
+
M.children?.forEach((c) => {
|
|
779
|
+
c.style && (c.style.left = d, a = Math.max(a, Number(c.style.width)), L.children.push(c));
|
|
780
|
+
}), d += a + n.value.frameGap;
|
|
792
781
|
}), L;
|
|
793
782
|
}
|
|
794
783
|
};
|
|
795
784
|
}
|
|
796
|
-
function
|
|
797
|
-
const { config:
|
|
785
|
+
function st(e) {
|
|
786
|
+
const { config: r } = e;
|
|
798
787
|
return {
|
|
799
788
|
name: "bigesj:bige",
|
|
800
789
|
accept: ".bige",
|
|
801
790
|
test: (n) => n instanceof File && n.name.endsWith(".bige"),
|
|
802
|
-
load: async (n) => await
|
|
791
|
+
load: async (n) => await z(
|
|
803
792
|
JSON.parse(
|
|
804
793
|
new TextDecoder().decode(
|
|
805
|
-
|
|
794
|
+
B(new Uint8Array(await n.arrayBuffer()))
|
|
806
795
|
)
|
|
807
796
|
).content,
|
|
808
|
-
|
|
797
|
+
r.value.frameGap
|
|
809
798
|
)
|
|
810
799
|
};
|
|
811
800
|
}
|
|
812
|
-
function
|
|
801
|
+
function Lt(e = {}) {
|
|
813
802
|
const {
|
|
814
|
-
font:
|
|
803
|
+
font: r,
|
|
815
804
|
api: n
|
|
816
805
|
} = e, t = {
|
|
817
806
|
fonts: "/new/design/fonts",
|
|
@@ -819,55 +808,55 @@ function Mt(e = {}) {
|
|
|
819
808
|
tid: "/new/design/info/%d",
|
|
820
809
|
...n
|
|
821
810
|
};
|
|
822
|
-
return
|
|
811
|
+
return O((i) => ({
|
|
823
812
|
name: "bigesj",
|
|
824
813
|
loaders: [
|
|
825
|
-
|
|
826
|
-
|
|
814
|
+
st(i),
|
|
815
|
+
at(i, t)
|
|
827
816
|
],
|
|
828
817
|
setup: async () => {
|
|
829
|
-
|
|
818
|
+
r && await rt(i, t);
|
|
830
819
|
}
|
|
831
820
|
}));
|
|
832
821
|
}
|
|
833
|
-
async function
|
|
822
|
+
async function rt(e, r) {
|
|
834
823
|
const {
|
|
835
824
|
on: n,
|
|
836
825
|
off: t,
|
|
837
|
-
root:
|
|
826
|
+
root: i
|
|
838
827
|
} = e, {
|
|
839
|
-
loadBigeFonts:
|
|
840
|
-
loadFont:
|
|
841
|
-
} =
|
|
842
|
-
function M
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
c.fontFamily &&
|
|
846
|
-
}),
|
|
828
|
+
loadBigeFonts: o,
|
|
829
|
+
loadFont: s
|
|
830
|
+
} = U();
|
|
831
|
+
function f(M) {
|
|
832
|
+
M instanceof v && (M.style.fontFamily && s(M.style.fontFamily).then(() => M.text.update()), M.text.content.forEach((a) => {
|
|
833
|
+
a.fragments.forEach((c) => {
|
|
834
|
+
c.fontFamily && s(c.fontFamily).then(() => M.text.update());
|
|
835
|
+
}), a.fontFamily && s(a.fontFamily).then(() => M.text.update());
|
|
847
836
|
}));
|
|
848
837
|
}
|
|
849
|
-
function L(
|
|
850
|
-
|
|
851
|
-
|
|
838
|
+
function L(M) {
|
|
839
|
+
M.forEach((a) => {
|
|
840
|
+
f(a), a.findOne((c) => (f(c), !1));
|
|
852
841
|
});
|
|
853
842
|
}
|
|
854
843
|
async function d() {
|
|
855
|
-
|
|
844
|
+
i.value && L([i.value]);
|
|
856
845
|
}
|
|
857
|
-
|
|
846
|
+
W(() => {
|
|
858
847
|
t("setDoc", d), t("addElement", L);
|
|
859
|
-
}), n("setDoc", d), n("addElement", L), await
|
|
848
|
+
}), n("setDoc", d), n("addElement", L), await o(r.fonts);
|
|
860
849
|
}
|
|
861
850
|
export {
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
851
|
+
at as bidTidLoader,
|
|
852
|
+
st as bigeLoader,
|
|
853
|
+
A as convertAnimation,
|
|
854
|
+
z as convertDoc,
|
|
855
|
+
S as convertElement,
|
|
856
|
+
et as convertLayout,
|
|
857
|
+
Lt as default,
|
|
858
|
+
H as parseAnimations,
|
|
859
|
+
Lt as plugin,
|
|
860
|
+
U as useFonts,
|
|
861
|
+
I as useSharedTextAssets
|
|
873
862
|
};
|
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.4",
|
|
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.19",
|
|
52
52
|
"modern-font": "^0.4.4",
|
|
53
|
-
"modern-idoc": "^0.10.
|
|
53
|
+
"modern-idoc": "^0.10.5",
|
|
54
54
|
"vue": "^3.5.22",
|
|
55
|
-
"mce": "0.2.
|
|
55
|
+
"mce": "0.2.4"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"mce": "^0"
|