@mce/bigesj 0.2.0 → 0.2.2

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