@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.
Files changed (2) hide show
  1. package/dist/index.js +276 -269
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,70 +1,70 @@
1
- import { useEditor as rt, definePlugin as ot } from "mce";
2
- import { assets as B, Element2D as nt } from "modern-canvas";
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 U, normalizeCRLF as Mt, isGradient as dt } from "modern-idoc";
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 i = [];
8
+ const o = [];
9
9
  for (let t = 0; t <= r.length; t++)
10
- i[t] = [t];
10
+ o[t] = [t];
11
11
  for (let t = 0; t <= e.length; t++)
12
- i[0][t] = t;
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 o = e[s - 1] === r[t - 1] ? 0 : 1;
16
- i[t][s] = Math.min(i[t - 1][s] + 1, i[t][s - 1] + 1, i[t - 1][s - 1] + o);
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 i[r.length][e.length];
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(o) {
24
+ async function o(i) {
25
25
  let n = X.value;
26
- return n.length || (n = await fetch(o).then((f) => f.json()).then((f) => f.data.datalist), X.value = n), n;
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(o, n = X.value) {
29
- const f = new Map(n.map((a, l) => [a.id, l])), M = new Map(
30
- n.flatMap((a, l) => [...a.en_name.split(","), ...a.name.split(",")].map((L) => [L, l]))
31
- ), d = o.replace(/"/g, "").split(",");
32
- let c;
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
- c ??= f.get(a), c ??= M.get(a);
35
- }), c === void 0) {
34
+ l ??= f.get(a), l ??= c.get(a);
35
+ }), l === void 0) {
36
36
  let a;
37
- d.forEach((l) => {
38
- let L = 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
- M.forEach((y, m) => {
42
- const C = wt(L, m);
41
+ c.forEach((h, u) => {
42
+ const C = wt(L, u);
43
43
  if (w <= C)
44
44
  return;
45
- const j = -(C * 0.9 + (m.endsWith("常规") ? 0 : 1) * 0.1);
46
- (a === void 0 || j > a) && (a = j, c = y);
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 c !== void 0 ? n[c] : void 0;
50
+ return l !== void 0 ? n[l] : void 0;
51
51
  }
52
- async function s(o) {
53
- const n = typeof o == "string" ? [o] : o, f = [];
54
- for (const M of n) {
55
- let d = r.value.get(M);
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 c = t(M);
58
- if (c && (d = r.value.get(c.en_name), !d)) {
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
- [M, c.en_name].filter(Boolean).map((l) => l.replace(/"/g, ""))
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: c.fonturl
67
- }), a.forEach((l) => r.value.set(l, d)), r.value.set(String(M), d);
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: i,
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, i, t;
89
+ let r = 0, o, t;
90
90
  const s = () => {
91
- r -= 1, t && r <= 0 && (t.stop(), i = void 0, t = void 0);
91
+ r -= 1, t && r <= 0 && (t.stop(), o = void 0, t = void 0);
92
92
  };
93
- return ((...o) => (r += 1, t || (t = it(!0), i = t.run(() => e(...o))), ut(s), i));
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 o = e.get(t);
99
- return o || (o = fetch(t).then(s), e.set(t, o)), o;
98
+ let i = e.get(t);
99
+ return i || (i = fetch(t).then(s), e.set(t, i)), i;
100
100
  }
101
- async function i(t) {
101
+ async function o(t) {
102
102
  return r(t, (s) => s.text());
103
103
  }
104
104
  return {
105
- fetchToText: i
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 G(e, r, i) {
440
+ function U(e, r, o) {
441
441
  const {
442
442
  name: t,
443
443
  delay: s = 0,
444
- duration: o,
444
+ duration: i,
445
445
  iterations: n,
446
446
  mode: f,
447
- easing: M,
447
+ easing: c,
448
448
  path: d,
449
- offsetRotate: c,
449
+ offsetRotate: l,
450
450
  ...a
451
451
  } = r;
452
- let l;
452
+ let M;
453
453
  if (t === "自定义路径" && d) {
454
454
  let L = `M ${e.style.width / 2} ${e.style.height / 2}`;
455
- d.forEach((y) => {
456
- const m = Object.keys(y);
457
- L += ` ${m[0]}${y[m[0]].join(" ")}`;
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 (i) {
460
+ switch (o) {
461
461
  case "in":
462
- l = [
463
- { opacity: 0, offsetDistance: "100%", offsetPath: w, offsetRotate: c },
464
- { offsetDistance: "0%", offsetPath: w, offsetRotate: c }
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
- l = [
469
- { offsetDistance: "0%", offsetPath: w, offsetRotate: c },
470
- { offsetDistance: "100%", offsetPath: w, offsetRotate: c }
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
- l = [
475
- { offsetDistance: "0%", offsetPath: w, offsetRotate: c },
476
- { opacity: 0, offsetDistance: "100%", offsetPath: w, offsetRotate: c }
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 (i) {
481
+ switch (o) {
482
482
  case "in":
483
- l = Y.textIn[t]?.[0] ?? Y.in[t];
483
+ M = Y.textIn[t]?.[0] ?? Y.in[t];
484
484
  break;
485
485
  case "stay":
486
- l = Y.stay[t];
486
+ M = Y.stay[t];
487
487
  break;
488
488
  case "out":
489
- l = Y.out[t];
489
+ M = Y.out[t];
490
490
  break;
491
491
  }
492
492
  return {
493
- id: U(),
493
+ id: F(),
494
494
  name: r.name ?? r.title ?? r.id,
495
495
  delay: s,
496
- duration: t ? o * (n || 1) : 0,
496
+ duration: t ? i * (n || 1) : 0,
497
497
  effectMode: f === "逐字" || f === "逐行" ? "sibling" : "parent",
498
- keyframes: l ?? [],
499
- easing: Y.easing[M],
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, i, t;
516
- e.animations[0].in ? (r = e.animations[0].in, i = e.animations[0].stay, t = e.animations[0].out) : (r = e.animations?.find((f) => f.category === "in"), i = e.animations?.find((f) => f.category === "stay"), t = e.animations?.find((f) => f.category === "out"));
517
- const s = r?.delay ?? 0, o = t ? t.delay - s + t.duration : 0, n = [];
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
- G(e, {
519
+ U(e, {
520
520
  ...r,
521
521
  delay: 0
522
522
  }, "in")
523
- ), i && n.push(
524
- G(e, {
525
- ...i,
526
- delay: i.delay - s
523
+ ), o && n.push(
524
+ U(e, {
525
+ ...o,
526
+ delay: o.delay - s
527
527
  }, "stay")
528
528
  ), t && n.push(
529
- G(e, {
529
+ U(e, {
530
530
  ...t,
531
531
  delay: t.delay - s
532
532
  }, "out")
533
533
  ), {
534
534
  delay: s,
535
- duration: o - s,
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: i = {},
542
+ style: o = {},
543
543
  maskUrl: t,
544
544
  imageEffects: s = [],
545
- imageEffectsRatio: o = 1
545
+ imageEffectsRatio: i = 1
546
546
  } = e, n = e.clipUrl || e.url, {
547
547
  translateX: f = 0,
548
- translateY: M = 0,
548
+ translateY: c = 0,
549
549
  zoom: d = 1
550
550
  } = r ?? {}, {
551
- scaleX: c = 1,
551
+ scaleX: l = 1,
552
552
  scaleY: a = 1,
553
- filter: l
554
- } = i;
555
- if (f === 0 && M === 0 && d === 1 && c === 1 && a === 1 && !t && !l && !s.length)
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: y = L.height,
560
- imageWidth: m = w,
561
- imageHeight: C = y
559
+ originHeight: h = L.height,
560
+ imageWidth: u = w,
561
+ imageHeight: C = h
562
562
  } = r, {
563
- width: j = w,
564
- height: h = y
565
- } = i, D = window.devicePixelRatio || 1, [g, u] = W(j, h, D);
566
- if (l && (u.filter = l), u.scale(c, a), u.translate(c < 0 ? -j : 0, a < 0 ? -h : 0), t) {
567
- const T = await B.fetchImageBitmap(t);
568
- u.drawImage(T, 0, 0, T.width, T.height, 0, 0, j, h), T.close(), u.globalCompositeOperation = "source-in";
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 = m * d, k = C * d, tt = -(A / 2 - m / 2) + f, et = -(k / 2 - C / 2) + M;
571
- if (u.drawImage(L, 0, 0, L.width, L.height, tt, et, A, k), L.close(), u.globalCompositeOperation = "source-over", s.length > 0) {
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: (j - j * 0.9) / 2,
574
- y: (h - h * 0.9) / 2
575
- }, v = await createImageBitmap(g);
576
- u.clearRect(0, 0, g.width, g.height), u.scale(0.9, 0.9);
577
- for (let F = s.length - 1; F >= 0; F--) {
578
- const { filling: E, offset: R, stroke: at } = s[F];
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 (E) {
581
- const [I, x] = W(j, h, D);
582
- if (x.drawImage(z, 0, 0, j, h), x.globalCompositeOperation = "source-in", E.color) {
583
- const [p, N] = W(j, h, D);
584
- N.fillStyle = E.color, N.fillRect(0, 0, j, h), x.drawImage(p, 0, 0, j, h);
585
- } else if (E.imageContent?.image) {
586
- const p = await B.fetchImageBitmap(E.imageContent.image);
587
- x.drawImage(p, 0, 0, j, h), p.close();
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((b) => {
597
- p.beginPath(), p.moveTo($ + b[0].x, H + b[1].y);
598
- for (let Q = 1; Q < b.length; Q++)
599
- p.lineTo($ + b[Q].x, H + b[Q].y);
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 * o
604
+ thickness: I / 50 * i
605
605
  });
606
606
  }), R) {
607
607
  let { x: I, y: x } = R;
608
- I = I / 50 * o * 200, x = x / 50 * o * 200, u.drawImage(z, I + S.x, x + S.y, j, h);
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
- u.drawImage(z, S.x, S.y, j, h);
610
+ y.drawImage(z, S.x, S.y, m, g);
611
611
  }
612
612
  v.close();
613
613
  }
614
- return await new Promise((T) => {
615
- g.toBlob((S) => {
614
+ return await new Promise((D) => {
615
+ j.toBlob((S) => {
616
616
  try {
617
- T(URL.createObjectURL(S));
617
+ D(URL.createObjectURL(S));
618
618
  } catch (v) {
619
- console.error(`Failed to URL.createObjectURL, url: ${n}`, v), T(n);
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, i = 1) {
624
+ function W(e, r, o = 1) {
625
625
  const t = document.createElement("canvas");
626
- t.width = e * i, t.height = r * i, t.style.width = `${e}px`, t.style.height = `${r}px`;
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(i, i), [t, s];
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, i) {
637
- const { canvas: t } = this, s = this.canvas.getContext("2d"), o = i.thickness * 2, [n, f] = [r.width, r.height].map((M) => M + o);
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, i), s.drawImage(r, i.thickness, i.thickness), t;
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, o = [];
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 = [], c = new Uint32Array(e.getImageData(0, 0, t, s).data.buffer);
647
- let a, l, L, w, y = -1, m, C = 9;
648
- const j = [9, 0, 3, 3, 2, 0, 9, 3, 1, 9, 1, 1, 2, 0, 2, 9];
649
- function h(g, u) {
650
- return g >= 0 && u >= 0 && g < t && u < s ? c[u * t + g] >>> 24 > f : !1;
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 D(g, u) {
652
+ function T(j, y) {
653
653
  let A = 0;
654
- return h(g - 1, u - 1) && (A += 1), h(g, u - 1) && (A += 2), h(g - 1, u) && (A += 4), h(g, u) && (A += 8), A === 6 ? C === 0 ? 2 : 3 : A === 9 ? C === 3 ? 0 : 1 : j[A];
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 g = n; g < c.length; g++)
657
- if (c[g] >>> 24 > f) {
658
- y = n = g;
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 (y >= 0) {
662
- a = L = y % t, l = w = Math.floor(y / t);
661
+ if (h >= 0) {
662
+ a = L = h % t, M = w = Math.floor(h / t);
663
663
  do
664
- m = D(a, l), m === 0 ? l-- : m === 1 ? l++ : m === 2 ? a-- : m === 3 && a++, m !== C && (d.push({ x: a + 0, y: l + 0 }), C = m);
665
- while (a !== L || l !== w);
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 o.push(d), d;
668
- })(), o;
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: i,
673
+ doc: o,
674
674
  url: t,
675
675
  style: s = {},
676
- background: o = {}
676
+ background: i = {}
677
677
  } = e;
678
- let n = i;
679
- n || (n = await fetch(t).then((M) => M.text()));
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 (o.src) {
687
- const M = `#${r}-fill-blip`, d = f.querySelector(M), c = d?.querySelector("image");
688
- if (d && c)
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(o.src).then((l) => {
690
+ const a = await B.fetchImageBitmap(i.src).then((M) => {
691
691
  const L = document.createElement("canvas");
692
- return L.width = l.width, L.height = l.height, L.getContext("2d")?.drawImage(l, 0, 0), l.close(), L.toDataURL("image/png");
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
- c?.setAttribute("href", a), d?.setAttribute("fill", M);
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+CjxnPgoJPHBhdGggZD0iTTE5LjMsMzguMWMwLj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wLjQtMC4yLDAuNWMtMC4xLDAuMS0wLjMsMC4yLTAuNiwwLjJoLTUuMnYxLjNoNGMwLjIsMCwwLjQsMC4xLDAuNiwwLjIgICBjMC4xLDAuMSwwLjIsMC4zLDAuMiwwLjZ2My40QzU1LjYsMzcuMyw1NS40LDM3LjYsNTUsMzcuN3ogTTUzLjksMzYuMnYtMmgtNy4xdjJINTMuOXogTTQ5LjYsNDAuN2MwLDAuMy0wLjEsMC41LTAuMiwwLjYgICBjLTAuMiwwLjEtMC40LDAuMi0wLjYsMC4yYy0wLjIsMC0wLjQtMC4xLTAuNi0wLjJjLTAuMS0wLjItMC4yLTAuNC0wLjItMC42bDAtMS42YzAtMC4yLDAuMS0wLjQsMC4yLTAuNmMwLjItMC4yLDAuMy0wLjIsMC42LTAuMiAgIHMwLjQsMC4xLDAuNiwwLjJjMC4yLDAuMiwwLjIsMC40LDAuMiwwLjZWNDAuN3ogTTUyLjgsNDAuN2MwLDAuMi0wLjEsMC40LTAuMiwwLjZjLTAuMiwwLjEtMC40LDAuMi0wLjYsMC4yICAgYy0wLjIsMC0wLjQtMC4xLTAuNi0wLjJjLTAuMi0wLjEtMC4yLTAuMy0wLjItMC42bDAtMS42YzAtMC4yLDAuMS0wLjQsMC4yLTAuNmMwLjItMC4yLDAuMy0wLjIsMC42LTAuMmMwLjIsMCwwLjQsMC4xLDAuNiwwLjIgICBjMC4yLDAuMiwwLjIsMC40LDAuMiwwLjZWNDAuN3ogTTU2LjYsNDAuM2MwLjIsMC40LDAuMSwwLjgtMC4zLDEuMWMtMC41LDAuMy0wLjgsMC4yLTEuMS0wLjNsLTEtMS43Yy0wLjItMC41LTAuMS0wLjgsMC4zLTEuMSAgIGMwLjUtMC4yLDAuOS0wLjEsMS4xLDAuM0w1Ni42LDQwLjN6Ii8+CjwvZz4KPC9zdmc+";
710
710
  async function xt(e, r = !1) {
711
- const { fetchToText: i } = _(), t = {
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 i(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;
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 (i) => {
724
- const t = {}, { offset: s, skew: o, stroke: n, shadow: f, filling: M } = i;
725
- if (s && (t.translateX = s.x, t.translateY = s.y), o && (t.skewX = o.x, t.skewY = o.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), M) {
726
- const { color: d, imageContent: c, gradient: a } = M;
727
- c?.image || (a ? t.color = `linear-gradient(${90 - a.angle}deg, ${a.stops.map((l) => `${l.color} ${l.offset * 100}%`).join(",")})` : d && (t.color = d));
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 i;
735
+ let o;
736
736
  return r.map((t, s) => {
737
- let o = t.content;
738
- o = o.replace(/ |\r\n|\n\r|[\n\r\t\v]/g, " "), o = o.replace(/<br\/>/g, `
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 M of Array.from(o))
742
- s === 0 && f === 0 && M === " " || i === " " && M === " " || (n += M), i = M, f++;
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: i } = _(), t = Dt(e), s = [];
752
- for (let o = 0, n = t.length; o < n; o++) {
753
- const f = t[o], M = {
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(M);
757
- for (let d = 0, c = f.length; d < c; d++) {
758
- const a = {}, l = f[d];
759
- for (const w in l)
760
- w !== "id" && l[w] !== "" && (a[w] = l[w]);
761
- a.fontSize && (a.fontSize = Math.floor(a.fontSize)), a.content = Mt(a.content), a.highlight && (a.highlightImage = await i(a.highlight.image), r ? a.highlightSize = "cover" : a.highlight.size && (a.highlightSize = `${a.highlight.size}rem`), a.highlight.colormap && (a.highlightColormap = a.highlight.colormap), a.highlight.line && (a.highlightLine = a.highlight.line), a.highlight.thickness && (a.highlightThickness = `${a.highlight.thickness}%`), delete a.highlight), r || (a.listMode ? M.listStyleType = "disc" : a.listStyle && (M.listStyleImage = await i(a.listStyle.image), M.listStyleSize = `${a.listStyle.size * 100}%`));
762
- const L = M.fragments[M.fragments.length - 1];
763
- L && Object.keys(L).length === 1 && L.content && Object.keys(a).length === 1 && a.content ? L.content += a.content : M.fragments.push(a);
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, i) {
770
- const t = { ...e.style ?? e }, s = {
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
- }, o = {
774
- id: U(),
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
- o.delay = n.delay, o.duration = n.duration, o.children.push(...n.animations), i && (n.animations.forEach((f) => {
783
- i.endTime = Math.max(
784
- i.endTime,
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
- }), i.endTime = Math.max(i.endTime, n.delay + n.duration));
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", o.foreground = {
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: M,
800
+ imageWidth: c,
797
801
  imageHeight: d,
798
- maskWidth: c = n,
802
+ maskWidth: l = n,
799
803
  maskHeight: a = f,
800
- translateX: l,
804
+ translateX: M,
801
805
  translateY: L,
802
806
  zoom: w = 1
803
- } = e.cropping, y = M * w, m = d * w, C = (y - c) / 2 - l, j = (m - a) / 2 - L, h = C + c / 2, D = j + a / 2, g = -(n / 2 - h), u = -(f / 2 - D), A = y - (g + n), k = m - (u + f);
804
- o.foreground.cropRect = {
805
- left: g / y,
806
- top: u / m,
807
- right: A / y,
808
- bottom: k / m
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", o.foreground = {
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), o.text = {
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", o.children = (await Promise.all(
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, i);
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 o;
869
+ return i;
867
870
  }
868
- async function St(e, r = !0, i) {
869
- const t = U(), s = {
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
- let o;
874
- 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
+ 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: o,
887
+ background: n,
880
888
  children: (await Promise.all(
881
- e.elements.map(async (n) => {
889
+ e.elements.map(async (f) => {
882
890
  try {
883
- return await q(n, void 0, i);
884
- } catch (f) {
885
- console.warn(f);
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: i,
903
+ layouts: o,
899
904
  metas: t = {}
900
905
  } = e, s = {
901
906
  endTime: 0
902
907
  };
903
- let o = await Promise.all(
904
- i.map(async (M, d) => ({
908
+ let i = await Promise.all(
909
+ o.map(async (c, d) => ({
905
910
  index: d,
906
- element: await St(M, !0, s)
911
+ element: await St(c, !0, s)
907
912
  }))
908
913
  ), n = 0;
909
- o = o.sort((M, d) => M.index - d.index).map((M, d) => {
910
- const c = M.element;
911
- return c.style && (c.style.top = n, n += Number(c.style.height) + r), c.name = `Frame ${d + 1}`, c;
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 = o.reduce((M) => {
914
- const d = M.style?.left ?? 0, c = M.style?.top ?? 0, a = M.style?.width ?? 0, l = M.style?.height ?? 0;
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: c,
922
+ minY: l,
918
923
  maxX: d + a,
919
- maxY: c + l
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: o,
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: i } = e;
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 ?? "", o = async (c) => await fetch(
943
- (t.bid ? r.bid : r.tid).replace("%d", c)
944
- ).then((a) => a.json()).then((a) => JSON.parse(a.data.content));
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 (c) => {
948
- let [a, l] = c.split("[");
949
- l && (l = l.substring(0, l.length - 1));
950
- const L = l ? l.split(",").map((m) => Number(m)) : void 0, w = await o(a);
951
- L !== void 0 && (w.layouts = w.layouts.filter((m, C) => L.includes(C)));
952
- const y = await K(w);
953
- return n = Math.max(n, y.meta?.maxTime ?? 0), y;
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
- ), M = { ...f[0], id: s, children: [] };
956
- M.meta ??= {}, M.meta.maxTime = n, M.meta.inEditorIs = "Doc";
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((c) => {
964
+ return f.forEach((l) => {
959
965
  let a = 0;
960
- c.children?.forEach((l) => {
961
- l.style && (l.style.left = d, a = Math.max(a, Number(l.style.width)), M.children.push(l));
962
- }), d += a + i.value.frameGap;
963
- }), M;
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) => await K(
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
- ).content
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: i
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
- ...i
996
+ ...o
990
997
  };
991
- return ot((s) => ({
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 Et(s, t);
1005
+ r && await bt(s, t);
999
1006
  }
1000
1007
  }));
1001
1008
  }
1002
- async function Et(e, r) {
1009
+ async function bt(e, r) {
1003
1010
  const {
1004
- on: i,
1011
+ on: o,
1005
1012
  off: t,
1006
1013
  root: s
1007
1014
  } = e, {
1008
- loadBigeFonts: o,
1015
+ loadBigeFonts: i,
1009
1016
  loadFont: n
1010
1017
  } = mt();
1011
- function f(c) {
1012
- c instanceof nt && (c.style.fontFamily && n(c.style.fontFamily).then(() => c.text.update()), c.text.content.forEach((a) => {
1013
- a.fragments.forEach((l) => {
1014
- l.fontFamily && n(l.fontFamily).then(() => c.text.update());
1015
- }), a.fontFamily && n(a.fontFamily).then(() => c.text.update());
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 M(c) {
1019
- c.forEach((a) => {
1020
- f(a), a.findOne((l) => (f(l), !1));
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 && M([s.value]);
1031
+ s.value && c([s.value]);
1025
1032
  }
1026
1033
  lt(() => {
1027
- t("setDoc", d), t("addElement", M);
1028
- }), i("setDoc", d), i("addElement", M), await o(r.fonts);
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
- G as convertAnimation,
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.2.6",
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.20",
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.2.6"
55
+ "mce": "0.11.0"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "mce": "^0"