@mce/bigesj 0.2.3 → 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.
@@ -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, ctx?: CanvasRenderingContext2D): Promise<Partial<StyleObject>[] | undefined>;
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 Y, definePlugin as k } from "mce";
2
- import { Element2D as O } from "modern-canvas";
3
- import { ref as I, effectScope as v, getCurrentScope as Q, onScopeDispose as X, onBeforeUnmount as G } from "vue";
4
- import { idGenerator as x, normalizeCRLF as W, isGradient as F } from "modern-idoc";
5
- import { gunzipSync as P } from "fflate";
6
- const p = I([]);
7
- function U(e, o) {
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 <= o.length; 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 <= o.length; t++)
14
- for (let a = 1; a <= e.length; a++) {
15
- const s = e[a - 1] === o[t - 1] ? 0 : 1;
16
- n[t][a] = Math.min(n[t - 1][a] + 1, n[t][a - 1] + 1, n[t - 1][a - 1] + s);
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[o.length][e.length];
18
+ return n[r.length][e.length];
19
19
  }
20
- function B() {
20
+ function U() {
21
21
  const {
22
22
  loadFont: e
23
- } = Y(), o = I(/* @__PURE__ */ new Map());
24
- async function n(s) {
25
- let f = p.value;
26
- return f.length || (f = await fetch(s).then((M) => M.json()).then((M) => M.data.datalist), p.value = f), f;
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(s, f = p.value) {
29
- const M = new Map(f.map((r, c) => [r.id, c])), L = new Map(
30
- f.flatMap((r, c) => [...r.en_name.split(","), ...r.name.split(",")].map((l) => [l, c]))
31
- ), d = s.replace(/"/g, "").split(",");
32
- let i;
33
- if (d.forEach((r) => {
34
- i ??= M.get(r), i ??= L.get(r);
35
- }), i === void 0) {
36
- let r;
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((m, u) => {
42
- const y = U(l, u);
41
+ L.forEach((u, m) => {
42
+ const y = J(l, m);
43
43
  if (w <= y)
44
44
  return;
45
- const g = -(y * 0.9 + (u.endsWith("常规") ? 0 : 1) * 0.1);
46
- (r === void 0 || g > r) && (r = g, i = m);
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 i !== void 0 ? f[i] : void 0;
50
+ return M !== void 0 ? s[M] : void 0;
51
51
  }
52
- async function a(s) {
53
- const f = typeof s == "string" ? [s] : s, M = [];
54
- for (const L of f) {
55
- let d = o.value.get(L);
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 i = t(L);
58
- if (i && (d = o.value.get(i.en_name), !d)) {
59
- const r = Array.from(
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, i.en_name].filter(Boolean).map((c) => c.replace(/"/g, ""))
61
+ [L, M.en_name].filter(Boolean).map((c) => c.replace(/"/g, ""))
62
62
  )
63
63
  );
64
64
  d = e({
65
- family: r,
66
- src: i.fonturl
67
- }), r.forEach((c) => o.value.set(c, d)), o.value.set(String(L), d);
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 && M.push(d);
70
+ d && f.push(d);
71
71
  }
72
- return await Promise.all(M);
72
+ return await Promise.all(f);
73
73
  }
74
74
  return {
75
- bigeFonts: p,
75
+ bigeFonts: C,
76
76
  searchBigeFont: t,
77
77
  loadBigeFonts: n,
78
- loadFont: a
78
+ loadFont: i
79
79
  };
80
80
  }
81
- function J(e, o) {
82
- return Q() ? (X(e, o), !0) : !1;
81
+ function R(e, r) {
82
+ return X() ? (G(e, r), !0) : !1;
83
83
  }
84
- const R = typeof window < "u" && typeof document < "u";
84
+ const Z = typeof window < "u" && typeof document < "u";
85
85
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
86
86
  // @__NO_SIDE_EFFECTS__
87
- function Z(e) {
88
- if (!R) return e;
89
- let o = 0, n, t;
90
- const a = () => {
91
- o -= 1, t && o <= 0 && (t.stop(), n = void 0, t = void 0);
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 ((...s) => (o += 1, t || (t = v(!0), n = t.run(() => e(...s))), J(a), n));
93
+ return ((...o) => (r += 1, t || (t = Q(!0), n = t.run(() => e(...o))), R(i), n));
94
94
  }
95
- const S = /* @__PURE__ */ Z(() => {
95
+ const I = /* @__PURE__ */ $(() => {
96
96
  const e = /* @__PURE__ */ new Map();
97
- function o(t, a) {
98
- let s = e.get(t);
99
- return s || (s = fetch(t).then(a), e.set(t, s)), s;
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 o(t, (a) => a.text());
102
+ return r(t, (i) => i.text());
103
103
  }
104
104
  return {
105
105
  fetchToText: n
106
106
  };
107
- }), C = {
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 h(e, o, n) {
440
+ function A(e, r, n) {
441
441
  const {
442
442
  name: t,
443
- delay: a = 0,
444
- duration: s,
445
- iterations: f,
446
- mode: M,
443
+ delay: i = 0,
444
+ duration: o,
445
+ iterations: s,
446
+ mode: f,
447
447
  easing: L,
448
448
  path: d,
449
- offsetRotate: i,
450
- ...r
451
- } = o;
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((m) => {
456
- const u = Object.keys(m);
457
- l += ` ${u[0]}${m[u[0]].join(" ")}`;
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: i },
464
- { offsetDistance: "0%", offsetPath: w, offsetRotate: i }
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: i },
470
- { offsetDistance: "100%", offsetPath: w, offsetRotate: i }
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: i },
476
- { opacity: 0, offsetDistance: "100%", offsetPath: w, offsetRotate: i }
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 = C.textIn[t]?.[0] ?? C.in[t];
483
+ c = g.textIn[t]?.[0] ?? g.in[t];
484
484
  break;
485
485
  case "stay":
486
- c = C.stay[t];
486
+ c = g.stay[t];
487
487
  break;
488
488
  case "out":
489
- c = C.out[t];
489
+ c = g.out[t];
490
490
  break;
491
491
  }
492
492
  return {
493
- id: x(),
494
- name: o.name ?? o.title ?? o.id,
495
- delay: a,
496
- duration: t ? s * (f || 1) : 0,
497
- effectMode: M === "逐字" || M === "逐行" ? "sibling" : "parent",
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: C.easing[L],
499
+ easing: g.easing[L],
500
500
  meta: {
501
- ...r,
501
+ ...a,
502
502
  inCanvasIs: "Animation",
503
503
  inPptIs: "Animation",
504
504
  inEditorIs: "Node"
505
505
  }
506
506
  };
507
507
  }
508
- function $(e) {
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 o, n, t;
516
- e.animations[0].in ? (o = e.animations[0].in, n = e.animations[0].stay, t = e.animations[0].out) : (o = e.animations?.find((M) => M.category === "in"), n = e.animations?.find((M) => M.category === "stay"), t = e.animations?.find((M) => M.category === "out"));
517
- const a = o?.delay ?? 0, s = t ? t.delay - a + t.duration : 0, f = [];
518
- return o && f.push(
519
- h(e, {
520
- ...o,
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 && f.push(
524
- h(e, {
523
+ ), n && s.push(
524
+ A(e, {
525
525
  ...n,
526
- delay: n.delay - a
526
+ delay: n.delay - i
527
527
  }, "stay")
528
- ), t && f.push(
529
- h(e, {
528
+ ), t && s.push(
529
+ A(e, {
530
530
  ...t,
531
- delay: t.delay - a
531
+ delay: t.delay - i
532
532
  }, "out")
533
533
  ), {
534
- delay: a,
535
- duration: s - a,
536
- animations: f.filter((M) => !!M?.keyframes)
534
+ delay: i,
535
+ duration: o - i,
536
+ animations: s.filter((f) => !!f?.keyframes)
537
537
  };
538
538
  }
539
- const H = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgNzIgNzIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDcyIDcyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+CjxnPgoJPHBhdGggZD0iTTE5LjMsMzguMWMwLjIsMC41LDAuNCwwLjksMC43LDEuNGMwLjIsMC4zLDAuNCwwLjQsMC44LDAuNGMwLjMsMCwwLjUtMC4xLDAuNi0wLjRjMC4xLTAuMywwLjEtMC42LDAuMi0wLjkgICBjMC0wLjIsMC4xLTAuNCwwLjMtMC41YzAuMi0wLjEsMC40LTAuMiwwLjYtMC4xYzAuMiwwLDAuNCwwLjEsMC41LDAuM2MwLjEsMC4yLDAuMiwwLjQsMC4xLDAuNmMtMC4xLDAuNi0wLjIsMS4yLTAuNCwxLjcgICBjLTAuMywwLjgtMC45LDEuMi0xLjcsMS4yYy0wLjksMC0xLjYtMC40LTIuMS0xLjJjLTAuMy0wLjQtMC41LTAuOC0wLjctMS4zYy0wLjQsMC4zLTEsMC42LTEuNywxYy0wLjUsMC4yLTAuOCwwLjEtMS4xLTAuMyAgIGMtMC4yLTAuNS0wLjEtMC45LDAuMy0xLjFjMC43LTAuNCwxLjQtMC44LDEuOS0xLjFjLTAuMi0wLjktMC40LTIuMS0wLjUtMy43TDE1LjksMzRjLTAuMiwwLTAuNCwwLTAuNi0wLjEgICBjLTAuMi0wLjEtMC4zLTAuMy0wLjMtMC41YzAtMC4yLDAtMC40LDAuMi0wLjZzMC4zLTAuMywwLjUtMC4zb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LTAuNmMwLjItMC4yLDAuMy0wLjIsMC42LTAuMiAgIHMwLjQsMC4xLDAuNiwwLjJjMC4yLDAuMiwwLjIsMC40LDAuMiwwLjZWNDAuN3ogTTUyLjgsNDAuN2MwLDAuMi0wLjEsMC40LTAuMiwwLjZjLTAuMiwwLjEtMC40LDAuMi0wLjYsMC4yICAgYy0wLjIsMC0wLjQtMC4xLTAuNi0wLjJjLTAuMi0wLjEtMC4yLTAuMy0wLjItMC42bDAtMS42YzAtMC4yLDAuMS0wLjQsMC4yLTAuNmMwLjItMC4yLDAuMy0wLjIsMC42LTAuMmMwLjIsMCwwLjQsMC4xLDAuNiwwLjIgICBjMC4yLDAuMiwwLjIsMC40LDAuMiwwLjZWNDAuN3ogTTU2LjYsNDAuM2MwLjIsMC40LDAuMSwwLjgtMC4zLDEuMWMtMC41LDAuMy0wLjgsMC4yLTEuMS0wLjNsLTEtMS43Yy0wLjItMC41LTAuMS0wLjgsMC4zLTEuMSAgIGMwLjUtMC4yLDAuOS0wLjEsMS4xLDAuM0w1Ni42LDQwLjN6Ii8+CjwvZz4KPC9zdmc+";
540
+ async function V(e, r = !1) {
541
+ const { fetchToText: n } = I(), t = {
542
542
  ...e.style,
543
- highlightReferImage: H,
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), o || (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;
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 V(e, o) {
550
- const n = e.textEffects ?? [];
551
- if (n.length)
549
+ async function q(e) {
550
+ const r = e.textEffects ?? [];
551
+ if (r.length)
552
552
  return await Promise.all(
553
- [...n].reverse().map(async (t) => {
554
- const a = {}, { offset: s, skew: f, stroke: M, shadow: L, filling: d } = t;
555
- if (s && (a.translateX = s.x, a.translateY = s.y), f && (a.skewX = f.x, a.skewY = f.y), M?.color && M.width && (a.textStrokeWidth = M.width, a.textStrokeColor = M.color), L && (a.shadowOffsetX = L.offsetX, a.shadowOffsetY = L.offsetY, a.shadowBlur = L.blur, a.shadowColor = L.color), d) {
556
- const { color: i, imageContent: r, gradient: c } = d;
557
- if (!r?.image)
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 a;
559
+ return t;
568
560
  })
569
561
  );
570
562
  }
571
- function q(e) {
572
- return e.version ? e.contents : e.contents.map((o) => {
563
+ function K(e) {
564
+ return e.version ? e.contents : e.contents.map((r) => {
573
565
  let n;
574
- return o.map((t, a) => {
575
- let s = t.content;
576
- s = s.replace(/ |\r\n|\n\r|[\n\r\t\v]/g, " "), s = s.replace(/<br\/>/g, `
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 f = "";
579
- for (const M of Array.from(s))
580
- a === 0 && M === " " || n === " " && M === " " || (f += M), n = M;
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: f
575
+ content: s
584
576
  };
585
577
  }).filter((t) => t.content);
586
578
  });
587
579
  }
588
- async function K(e, o = !1) {
589
- const { fetchToText: n } = S(), t = q(e), a = [];
590
- for (let s = 0, f = t.length; s < f; s++) {
591
- const M = t[s], L = {
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
- a.push(L);
595
- for (let d = 0, i = M.length; d < i; d++) {
596
- const r = { ...M[d] };
597
- r.fontSize && (r.fontSize = Math.floor(r.fontSize)), r.content = W(r.content), r.highlight && (r.highlightImage = await n(r.highlight.image), o ? r.highlightSize = "cover" : r.highlight.size && (r.highlightSize = `${r.highlight.size}rem`), r.highlight.colormap && (r.highlightColormap = r.highlight.colormap), r.highlight.line && (r.highlightLine = r.highlight.line), r.highlight.thickness && (r.highlightThickness = `${r.highlight.thickness}%`), delete r.highlight), o || (r.listMode ? L.listStyleType = "disc" : r.listStyle && (L.listStyleImage = await n(r.listStyle.image), L.listStyleSize = `${r.listStyle.size * 100}%`)), L.fragments.push(r);
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 a;
596
+ return i;
601
597
  }
602
- const A = (e) => (Number.parseFloat(e) || 0) / 100;
603
- async function z(e, o, n) {
604
- const t = e.style ?? e;
605
- t.borderRadius && (t.borderRadius = t.borderRadius * 0.01 * Math.max(t.height, t.width)), o && e.groupStyle && (t.width = o.style.width * A(e.groupStyle.width), t.height = o.style.height * A(e.groupStyle.height), t.left = o.style.width * A(e.groupStyle.left), t.top = o.style.height * A(e.groupStyle.top));
606
- const a = {
607
- id: x(),
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
- // TODO 过滤掉部分属性
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 = $(e);
623
- a.delay = s.delay, a.duration = s.duration, a.children.push(...s.animations), n && (s.animations.forEach((f) => {
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 (a.meta.inPptIs = "Picture", a.foreground = {
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: M,
638
- imageHeight: L,
639
- maskWidth: d = s,
640
- maskHeight: i = f,
641
- translateX: r,
642
- translateY: c,
643
- zoom: l = 1
644
- } = e.cropping, w = M * l, m = L * l, u = (w - d) / 2 - r, y = (m - i) / 2 - c, g = u + d / 2, j = y + i / 2, T = -(s / 2 - g), D = -(f / 2 - j), b = w - (T + s), E = m - (D + f);
645
- a.foreground.cropRect = {
646
- left: T / w,
647
- top: D / m,
648
- right: b / w,
649
- bottom: E / m
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
- a.meta.inPptIs = "Picture";
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}"`), a.foreground = {
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
- a.meta.inPptIs = "Shape", t.writingMode === "horizontal-tb" ? a.style.width = Math.ceil(t.width + t.letterSpacing) : a.style.height = Math.ceil(t.height + t.letterSpacing), a.text = {
664
- content: await K(e),
665
- style: await _(e),
666
- effects: await V(e),
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
- a.meta.inPptIs = "GroupShape", a.children = await Promise.all(
674
- e.children.map((s) => z(s, e, n))
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 a;
691
+ return o;
703
692
  }
704
- async function tt(e, o = !0, n) {
705
- const t = x(), a = {
693
+ async function et(e, r = !0, n) {
694
+ const t = h(), i = {
706
695
  ...e.style ?? e
707
696
  };
708
- o && (a.overflow = "hidden");
709
- let s;
710
- return e.background && (e.background.color && (s ??= {}, F(e.background.color ?? "") ? s.image = e.background.color : s.color = e.background.color), e.background.image && (s ??= {}, s.image = e.background.image)), {
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: o ? `Frame ${t}` : e.name,
713
- style: a,
701
+ name: r ? `Frame ${t}` : e.name,
702
+ style: i,
714
703
  // TODO 过滤掉部分属性
715
- background: s,
704
+ background: o,
716
705
  children: await Promise.all(
717
- e.elements.map((f) => z(f, void 0, n))
706
+ e.elements.map((s) => S(s, void 0, n))
718
707
  ),
719
708
  meta: {
720
- inPptIs: o ? "Slide" : "GroupShape",
721
- inEditorIs: o ? "Frame" : "Element"
709
+ inPptIs: r ? "Slide" : "GroupShape",
710
+ inEditorIs: r ? "Frame" : "Element"
722
711
  }
723
712
  };
724
713
  }
725
- async function N(e, o = 48) {
714
+ async function z(e, r = 48) {
726
715
  const {
727
716
  layouts: n,
728
717
  metas: t = {}
729
- } = e, a = {
718
+ } = e, i = {
730
719
  endTime: 0
731
720
  };
732
- let s = await Promise.all(
721
+ let o = await Promise.all(
733
722
  n.map(async (L, d) => ({
734
723
  index: d,
735
- element: await tt(L, !0, a)
724
+ element: await et(L, !0, i)
736
725
  }))
737
- ), f = 0;
738
- s = s.sort((L, d) => L.index - d.index).map((L, d) => {
739
- const i = L.element;
740
- return i.style && (i.style.top = f, f += Number(i.style.height) + o), i.name = `Frame ${d + 1}`, i;
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 M = s.reduce((L) => {
743
- const d = L.style?.left ?? 0, i = L.style?.top ?? 0, r = L.style?.width ?? 0, c = L.style?.height ?? 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: i,
747
- maxX: d + r,
748
- maxY: i + c
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 ?? M.maxX - M.minX,
755
- height: t?.height ?? M.maxY - M.minY
743
+ width: t?.width ?? f.maxX - f.minX,
744
+ height: t?.height ?? f.maxY - f.minY
756
745
  },
757
- children: s,
746
+ children: o,
758
747
  meta: {
759
748
  ...t,
760
- endTime: a.endTime,
749
+ endTime: i.endTime,
761
750
  inEditorIs: "Doc"
762
751
  }
763
752
  };
764
753
  }
765
- function et(e, o) {
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 a = t.bid ?? t.tid ?? "", s = async (i) => await fetch(
772
- (t.bid ? o.bid : o.tid).replace("%d", i)
773
- ).then((r) => r.json()).then((r) => JSON.parse(r.data.content));
774
- let f = 0;
775
- const M = await Promise.all(
776
- a.split("|").map(async (i) => {
777
- let [r, c] = i.split("[");
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((u) => Number(u)) : void 0, w = await s(r);
780
- l !== void 0 && (w.layouts = w.layouts.filter((u, y) => l.includes(y)));
781
- const m = await N(w, n.value.frameGap);
782
- return f = Math.max(f, m.meta?.maxTime ?? 0), m;
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 = { ...M[0], id: a, children: [] };
785
- L.meta ??= {}, L.meta.maxTime = f, L.meta.inEditorIs = "Doc";
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 M.forEach((i) => {
788
- let r = 0;
789
- i.children?.forEach((c) => {
790
- c.style && (c.style.left = d, r = Math.max(r, Number(c.style.width)), L.children.push(c));
791
- }), d += r + n.value.frameGap;
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 at(e) {
797
- const { config: o } = e;
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 N(
791
+ load: async (n) => await z(
803
792
  JSON.parse(
804
793
  new TextDecoder().decode(
805
- P(new Uint8Array(await n.arrayBuffer()))
794
+ B(new Uint8Array(await n.arrayBuffer()))
806
795
  )
807
796
  ).content,
808
- o.value.frameGap
797
+ r.value.frameGap
809
798
  )
810
799
  };
811
800
  }
812
- function Mt(e = {}) {
801
+ function Lt(e = {}) {
813
802
  const {
814
- font: o,
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 k((a) => ({
811
+ return O((i) => ({
823
812
  name: "bigesj",
824
813
  loaders: [
825
- at(a),
826
- et(a, t)
814
+ st(i),
815
+ at(i, t)
827
816
  ],
828
817
  setup: async () => {
829
- o && await st(a, t);
818
+ r && await rt(i, t);
830
819
  }
831
820
  }));
832
821
  }
833
- async function st(e, o) {
822
+ async function rt(e, r) {
834
823
  const {
835
824
  on: n,
836
825
  off: t,
837
- root: a
826
+ root: i
838
827
  } = e, {
839
- loadBigeFonts: s,
840
- loadFont: f
841
- } = B();
842
- function M(i) {
843
- i instanceof O && (i.style.fontFamily && f(i.style.fontFamily).then(() => i.text.update()), i.text.content.forEach((r) => {
844
- r.fragments.forEach((c) => {
845
- c.fontFamily && f(c.fontFamily).then(() => i.text.update());
846
- }), r.fontFamily && f(r.fontFamily).then(() => i.text.update());
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(i) {
850
- i.forEach((r) => {
851
- M(r), r.findOne((c) => (M(c), !1));
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
- a.value && L([a.value]);
844
+ i.value && L([i.value]);
856
845
  }
857
- G(() => {
846
+ W(() => {
858
847
  t("setDoc", d), t("addElement", L);
859
- }), n("setDoc", d), n("addElement", L), await s(o.fonts);
848
+ }), n("setDoc", d), n("addElement", L), await o(r.fonts);
860
849
  }
861
850
  export {
862
- et as bidTidLoader,
863
- at as bigeLoader,
864
- h as convertAnimation,
865
- N as convertDoc,
866
- z as convertElement,
867
- tt as convertLayout,
868
- Mt as default,
869
- $ as parseAnimations,
870
- Mt as plugin,
871
- B as useFonts,
872
- S as useSharedTextAssets
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.3",
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.17",
51
+ "modern-canvas": "^0.12.19",
52
52
  "modern-font": "^0.4.4",
53
53
  "modern-idoc": "^0.10.5",
54
54
  "vue": "^3.5.22",
55
- "mce": "0.2.3"
55
+ "mce": "0.2.4"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "mce": "^0"