@forevka/wordcanvas 0.7.1 → 0.7.3

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 (64) hide show
  1. package/dist-lib/assets/{worker-D8rUOKfg.js → worker-CqU4Popa.js} +10903 -10736
  2. package/dist-lib/assets/worker-Cw5cYW5z.js +2418 -0
  3. package/dist-lib/blockFactory-DDCRWDnA.js +91 -0
  4. package/dist-lib/browser-BUrsjziD.js +612 -0
  5. package/dist-lib/builder.js +13 -13
  6. package/dist-lib/editorApp-CB_ZArIF.js +9566 -0
  7. package/dist-lib/export.js +4507 -4456
  8. package/dist-lib/generate-toc.js +7 -7
  9. package/dist-lib/import.js +2 -2
  10. package/dist-lib/lists-DpmgbDyt.js +110 -0
  11. package/dist-lib/measure.js +2 -2
  12. package/dist-lib/{measureHost-CMiJKdlk.js → measureHost-BlukHGwx.js} +1 -1
  13. package/dist-lib/metrics-bvGO8KDK.js +96 -0
  14. package/dist-lib/paintStyle-vT6jtWbH.js +74 -0
  15. package/dist-lib/pipeline-UryP-u7Z.js +1850 -0
  16. package/dist-lib/recalc-docx.js +2 -2
  17. package/dist-lib/recalcToc-BfXlXZik.js +3985 -0
  18. package/dist-lib/styleProps-DhqDEfvc.js +149 -0
  19. package/dist-lib/stylesheet-LTBEGkvG.js +146 -0
  20. package/dist-lib/toc-D09f4PrI.js +939 -0
  21. package/dist-lib/{webmcp-6WxRNKCc.js → webmcp-K6UZgQJ0.js} +60 -68
  22. package/dist-lib/wordcanvas-DBx2ana_.js +734 -0
  23. package/dist-lib/wordcanvas.js +4 -2
  24. package/dist-node/{chunk-CDN6WU2P.js → chunk-373K2XRY.js} +40 -22
  25. package/dist-node/chunk-373K2XRY.js.map +7 -0
  26. package/dist-node/{chunk-22JHAERT.js → chunk-3PUV3BG6.js} +235 -39
  27. package/dist-node/chunk-3PUV3BG6.js.map +7 -0
  28. package/dist-node/{chunk-4ICCHZX4.js → chunk-5RX3IHWE.js} +39 -3
  29. package/dist-node/chunk-5RX3IHWE.js.map +7 -0
  30. package/dist-node/{chunk-4PDVRJF6.js → chunk-EMY2P524.js} +32 -2
  31. package/dist-node/chunk-EMY2P524.js.map +7 -0
  32. package/dist-node/{chunk-BRAPV465.js → chunk-HWQKGDS2.js} +2 -2
  33. package/dist-node/{chunk-6AJJMHKY.js → chunk-KJV7GJ3H.js} +1 -1
  34. package/dist-node/chunk-KJV7GJ3H.js.map +7 -0
  35. package/dist-node/{chunk-RNB336F3.js → chunk-ZLLSXOO2.js} +92 -14
  36. package/dist-node/{chunk-RNB336F3.js.map → chunk-ZLLSXOO2.js.map} +2 -2
  37. package/dist-node/{engine-5FGDJD2H.js → engine-LLA6PCS5.js} +4 -4
  38. package/dist-node/export.js +89 -24
  39. package/dist-node/export.js.map +2 -2
  40. package/dist-node/generate-toc.js +6 -6
  41. package/dist-node/import.js +3 -3
  42. package/dist-node/measure.js +2 -2
  43. package/dist-node/recalc-docx.js +4 -4
  44. package/package.json +1 -1
  45. package/types/model.d.ts +46 -0
  46. package/types/wordcanvas.d.ts +493 -1
  47. package/dist-lib/assets/worker-wXuuyshQ.js +0 -2258
  48. package/dist-lib/blockFactory-CUI4Rqiq.js +0 -186
  49. package/dist-lib/browser-DkKxreJM.js +0 -1305
  50. package/dist-lib/editorApp-DLXMmtu5.js +0 -8023
  51. package/dist-lib/lists-Sc5I40JO.js +0 -110
  52. package/dist-lib/metrics-CkAo4zh8.js +0 -143
  53. package/dist-lib/pipeline-CbxmCE84.js +0 -1705
  54. package/dist-lib/recalcToc-g1hFKSNs.js +0 -3935
  55. package/dist-lib/styleProps-Db5pEkG8.js +0 -127
  56. package/dist-lib/toc-B6VpkJge.js +0 -213
  57. package/dist-lib/wordcanvas-CFqpDK0k.js +0 -125
  58. package/dist-node/chunk-22JHAERT.js.map +0 -7
  59. package/dist-node/chunk-4ICCHZX4.js.map +0 -7
  60. package/dist-node/chunk-4PDVRJF6.js.map +0 -7
  61. package/dist-node/chunk-6AJJMHKY.js.map +0 -7
  62. package/dist-node/chunk-CDN6WU2P.js.map +0 -7
  63. /package/dist-node/{chunk-BRAPV465.js.map → chunk-HWQKGDS2.js.map} +0 -0
  64. /package/dist-node/{engine-5FGDJD2H.js.map → engine-LLA6PCS5.js.map} +0 -0
@@ -1,9 +1,9 @@
1
- import { u as G, a as C, t as H, s as R, z as M } from "./browser-DkKxreJM.js";
2
- import { p as K, d as q, i as J, t as Q } from "./toc-B6VpkJge.js";
1
+ import { u as G, a as C, s as R, z as M } from "./browser-BUrsjziD.js";
2
+ import { p as H, d as K, t as q, i as J, a as Q } from "./toc-D09f4PrI.js";
3
3
  import { f as V } from "./contentTypes-f7VddqoF.js";
4
- import { r as N } from "./pipeline-CbxmCE84.js";
5
- import { p as Y, c as Z } from "./recalcToc-g1hFKSNs.js";
6
- import { e as d, r as tt, b as et, t as T, a as nt } from "./styleProps-Db5pEkG8.js";
4
+ import { r as N } from "./pipeline-UryP-u7Z.js";
5
+ import { p as Y, c as Z } from "./recalcToc-BfXlXZik.js";
6
+ import { e as d, r as tt, b as et, t as T, a as nt } from "./styleProps-DhqDEfvc.js";
7
7
  const b = (t) => d("w:r", void 0, d("w:fldChar", { "w:fldCharType": t })), j = (t) => d("w:r", void 0, d("w:instrText", { "xml:space": "preserve" }, nt(t)));
8
8
  function st(t, a, r) {
9
9
  return b("begin") + j(` PAGEREF ${t} \\h `) + b("separate") + d("w:r", void 0, r + (a ? T(a) : "")) + b("end");
@@ -73,7 +73,7 @@ function ut(t, a = {}) {
73
73
  if (!i) return { bytes: t, generated: 0, headings: 0, bookmarksSynthesized: 0 };
74
74
  const c = C(i), o = ot(c);
75
75
  if (!o) return { bytes: t, generated: 0, headings: 0, bookmarksSynthesized: 0 };
76
- const p = K(o.instr), s = N(t).doc, g = p.outlineRange?.to ?? a.maxLevel ?? 3, u = q(s, p, g), x = s.section.pageWidthPx - s.section.marginPx.left - s.section.marginPx.right, y = a.hyperlink ?? p.hyperlinks, v = a.includePageNumbers ?? !0, h = /* @__PURE__ */ new Map();
76
+ const p = H(o.instr), s = N(t).doc, g = p.outlineRange?.to ?? a.maxLevel ?? 3, u = K(s, p, g), x = s.section.pageWidthPx - s.section.marginPx.left - s.section.marginPx.right, y = a.hyperlink ?? p.hyperlinks, v = a.includePageNumbers ?? !0, h = /* @__PURE__ */ new Map();
77
77
  for (const [e, m] of Object.entries(s.bookmarks ?? {})) {
78
78
  const f = h.get(m.start.blockId);
79
79
  (!f || !f.startsWith("_Toc") && e.startsWith("_Toc")) && h.set(m.start.blockId, e);
@@ -83,7 +83,7 @@ function ut(t, a = {}) {
83
83
  const S = /* @__PURE__ */ new Map();
84
84
  let F = 9e5, L = 0;
85
85
  const w = u.map((e, m) => {
86
- const f = H(e.block.runs).replace(/\v/g, " ").trim(), z = v && !J(p.hidePageNumberRange, e.level);
86
+ const f = q(e.block.runs).replace(/\v/g, " ").trim(), z = v && !J(p.hidePageNumberRange, e.level);
87
87
  let k;
88
88
  return (z || y) && (k = h.get(e.block.id), k || (k = `_CwToc${L++}`, S.set(m, { name: k, id: F++ }))), { label: f, level: e.level, anchor: k, numText: z ? "1" : "" };
89
89
  }).filter((e) => e.label.length > 0);
@@ -1,6 +1,6 @@
1
- import "./toc-B6VpkJge.js";
1
+ import "./toc-D09f4PrI.js";
2
2
  import "./contentTypes-f7VddqoF.js";
3
- import { r as t } from "./pipeline-CbxmCE84.js";
3
+ import { r as t } from "./pipeline-UryP-u7Z.js";
4
4
  export {
5
5
  t as runImport
6
6
  };
@@ -0,0 +1,110 @@
1
+ const T = [
2
+ [1e3, "m"],
3
+ [900, "cm"],
4
+ [500, "d"],
5
+ [400, "cd"],
6
+ [100, "c"],
7
+ [90, "xc"],
8
+ [50, "l"],
9
+ [40, "xl"],
10
+ [10, "x"],
11
+ [9, "ix"],
12
+ [5, "v"],
13
+ [4, "iv"],
14
+ [1, "i"]
15
+ ];
16
+ function u(t) {
17
+ let n = "", e = Math.max(1, t);
18
+ for (const [r, l] of T)
19
+ for (; e >= r; )
20
+ n += l, e -= r;
21
+ return n;
22
+ }
23
+ function c(t) {
24
+ let n = "", e = Math.max(1, t);
25
+ for (; e > 0; )
26
+ e -= 1, n = String.fromCharCode(97 + e % 26) + n, e = Math.floor(e / 26);
27
+ return n;
28
+ }
29
+ function E(t, n) {
30
+ switch (n) {
31
+ case "decimal":
32
+ return String(t);
33
+ case "lowerLetter":
34
+ return c(t);
35
+ case "upperLetter":
36
+ return c(t).toUpperCase();
37
+ case "lowerRoman":
38
+ return u(t);
39
+ case "upperRoman":
40
+ return u(t).toUpperCase();
41
+ case "bullet":
42
+ return "";
43
+ }
44
+ }
45
+ function d(t, n, e) {
46
+ const r = t.levels[Math.min(n, t.levels.length - 1)];
47
+ return r ? r.format === "bullet" ? r.bulletChar ?? _ : r.text.replace(/%(\d)/g, (l, v) => {
48
+ const a = Number(v) - 1, i = t.levels[Math.min(a, t.levels.length - 1)], g = e[a] ?? i?.start ?? 1;
49
+ return E(g, i?.format ?? "decimal");
50
+ }) : "";
51
+ }
52
+ const b = "bullets", p = "numbers", P = "multilevel", s = 9, m = 24, h = 18, x = 22, _ = "•", L = [_, "◦", "▪"], f = ["decimal", "lowerLetter", "lowerRoman"], o = (t) => m * (t + 1);
53
+ function U(t) {
54
+ const n = [];
55
+ for (let e = 0; e < s; e++)
56
+ t === "bullet" ? n.push({
57
+ format: "bullet",
58
+ text: "",
59
+ bulletChar: L[e % L.length],
60
+ indentLeftPx: o(e),
61
+ hangingPx: h,
62
+ start: 1
63
+ }) : n.push({
64
+ format: f[e % f.length],
65
+ text: `%${e + 1}.`,
66
+ indentLeftPx: o(e),
67
+ hangingPx: x,
68
+ start: 1
69
+ });
70
+ return { id: t === "bullet" ? b : p, levels: n };
71
+ }
72
+ function D(t, n) {
73
+ const e = [];
74
+ for (let r = 0; r < s; r++)
75
+ e.push({ format: "bullet", text: "", bulletChar: n, indentLeftPx: o(r), hangingPx: h, start: 1 });
76
+ return { id: t, levels: e };
77
+ }
78
+ function I(t, n, e) {
79
+ const r = [];
80
+ for (let l = 0; l < s; l++)
81
+ r.push({ format: n, text: `%${l + 1}${e}`, indentLeftPx: o(l), hangingPx: x, start: 1 });
82
+ return { id: t, levels: r };
83
+ }
84
+ function N() {
85
+ const t = [];
86
+ for (let n = 0; n < s; n++) {
87
+ const e = Array.from({ length: n + 1 }, (r, l) => `%${l + 1}`).join(".") + ".";
88
+ t.push({
89
+ format: "decimal",
90
+ text: e,
91
+ // "%1.", "%1.%2.", "%1.%2.%3.", …
92
+ indentLeftPx: o(n),
93
+ hangingPx: m + n * 8,
94
+ // compound markers widen with depth
95
+ start: 1
96
+ });
97
+ }
98
+ return { id: P, levels: t };
99
+ }
100
+ export {
101
+ p as D,
102
+ b as a,
103
+ D as b,
104
+ P as c,
105
+ U as d,
106
+ d as e,
107
+ E as f,
108
+ N as m,
109
+ I as n
110
+ };
@@ -1,6 +1,6 @@
1
1
  import "./TimesNewRoman-Regular-DtG34YRm.js";
2
- import { i as s } from "./measureHost-CMiJKdlk.js";
3
- import "./metrics-CkAo4zh8.js";
2
+ import { i as s } from "./measureHost-BlukHGwx.js";
3
+ import "./metrics-bvGO8KDK.js";
4
4
  export {
5
5
  s as installMeasureHost
6
6
  };
@@ -1,5 +1,5 @@
1
1
  import { _ as Fn, a as Bn, b as Dn, c as Ln, d as Mn, e as Rn, f as Nn, g as Un, h as Gn, i as Vn, j as zn, k as qn, l as Wn, m as Hn, n as Xn, o as $n, p as jn, q as Zn, r as Yn, s as Kn, t as Jn, u as _n, v as Qn, w as ei } from "./TimesNewRoman-Regular-DtG34YRm.js";
2
- import { i as ti, j as ri, k as si } from "./metrics-CkAo4zh8.js";
2
+ import { c as ti, F as ri, s as si } from "./metrics-bvGO8KDK.js";
3
3
  import { B as C0 } from "./index-6mKfgpcs.js";
4
4
  var Z1 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
5
5
  function E0(i) {
@@ -0,0 +1,96 @@
1
+ import { S as m } from "./paintStyle-vT6jtWbH.js";
2
+ const u = ["Carlito", "Caladea", "Gelasio", "Arimo", "TimesNewRoman", "Cousine"], C = "Arimo", d = {
3
+ // metric clones of common Office/Windows fonts
4
+ calibri: "Carlito",
5
+ cambria: "Caladea",
6
+ georgia: "Gelasio",
7
+ arial: "Arimo",
8
+ helvetica: "Arimo",
9
+ "helvetica neue": "Arimo",
10
+ "times new roman": "TimesNewRoman",
11
+ times: "TimesNewRoman",
12
+ "courier new": "Cousine",
13
+ courier: "Cousine",
14
+ // reasonable substitutes for fonts we don't ship
15
+ verdana: "Arimo",
16
+ tahoma: "Arimo",
17
+ "segoe ui": "Arimo",
18
+ "trebuchet ms": "Arimo",
19
+ consolas: "Cousine",
20
+ monaco: "Cousine",
21
+ "lucida console": "Cousine",
22
+ garamond: "TimesNewRoman",
23
+ "book antiqua": "Caladea",
24
+ palatino: "Caladea",
25
+ // generic CSS families
26
+ serif: "TimesNewRoman",
27
+ "sans-serif": "Arimo",
28
+ sans: "Arimo",
29
+ monospace: "Cousine",
30
+ mono: "Cousine",
31
+ // identity (already a clone)
32
+ carlito: "Carlito",
33
+ caladea: "Caladea",
34
+ gelasio: "Gelasio",
35
+ arimo: "Arimo",
36
+ timesnewroman: "TimesNewRoman",
37
+ cousine: "Cousine"
38
+ }, f = {
39
+ Carlito: { ascent: 0.9375, descent: 0.25 },
40
+ Caladea: { ascent: 0.9375, descent: 0.25 },
41
+ Gelasio: { ascent: 0.9375, descent: 0.3125 },
42
+ Arimo: { ascent: 0.875, descent: 0.1875 },
43
+ TimesNewRoman: { ascent: 0.875, descent: 0.1875 },
44
+ Cousine: { ascent: 0.625, descent: 0.1875 }
45
+ };
46
+ function c(e) {
47
+ const a = e.trim().toLowerCase().replace(/^["']|["']$/g, ""), o = d[a];
48
+ return o ? { clone: o, substituted: !1 } : { clone: C, substituted: !0 };
49
+ }
50
+ const A = (e) => (e.split(",")[0] ?? "").trim(), b = ["Regular", "Bold", "Italic", "BoldItalic"], N = u.flatMap(
51
+ (e) => b.map((a) => `${e}-${a}.ttf`)
52
+ ), x = [
53
+ { value: "Calibri, sans-serif", label: "Calibri (Carlito)" },
54
+ { value: "Cambria, serif", label: "Cambria (Caladea)" },
55
+ { value: "Georgia, serif", label: "Georgia (Gelasio)" },
56
+ { value: "Arial, sans-serif", label: "Arial (Arimo)" },
57
+ { value: "Times New Roman, serif", label: "Times New Roman" },
58
+ { value: "Verdana, sans-serif", label: "Verdana (Arimo)" },
59
+ { value: "Consolas, monospace", label: "Consolas (Cousine)" },
60
+ { value: "Courier New, monospace", label: "Courier New (Cousine)" }
61
+ ];
62
+ let t = null, n = null;
63
+ function p(e) {
64
+ t = e;
65
+ }
66
+ function T() {
67
+ return t || (n || (n = document.createElement("canvas").getContext("2d")), n);
68
+ }
69
+ const l = /* @__PURE__ */ new Map();
70
+ function F(e) {
71
+ const a = e.italic ? "italic " : "", o = e.bold ? "700" : "400", i = e.verticalAlign ? Math.round(e.fontSizePx * m) : e.fontSizePx, s = c(A(e.fontFamily)).clone;
72
+ return `${a}${o} ${i}px ${s}`;
73
+ }
74
+ function g(e, a) {
75
+ const o = T();
76
+ return o.font = a, o.measureText(e).width;
77
+ }
78
+ function h(e) {
79
+ let a = l.get(e);
80
+ if (!a) {
81
+ const o = /(\d+(?:\.\d+)?)px/.exec(e), i = o ? parseFloat(o[1]) : 16, s = e.slice(e.indexOf("px ") + 3).trim(), r = f[c(s).clone] ?? { ascent: 0.9, descent: 0.25 };
82
+ a = { ascent: Math.round(r.ascent * i), descent: Math.round(r.descent * i) }, l.set(e, a);
83
+ }
84
+ return a;
85
+ }
86
+ export {
87
+ u as C,
88
+ N as F,
89
+ x as T,
90
+ F as a,
91
+ b,
92
+ c,
93
+ h as f,
94
+ g as m,
95
+ p as s
96
+ };
@@ -0,0 +1,74 @@
1
+ const p = "#c0c4c9", x = "#0b57d0", B = "#1a73e8", A = "#202124", I = "#80868b", m = "#7a8aa0", k = "#9aa0a6", M = "#f1f3f4", P = /* @__PURE__ */ new Set([
2
+ "#0563c1",
3
+ "#0000ff",
4
+ "#0000ee",
5
+ "#0b57d0",
6
+ "#0066cc",
7
+ "#1155cc"
8
+ ]), w = (t) => P.has(t.toLowerCase()) ? A : t, G = 0.65, D = -0.38, U = 0.16;
9
+ function H(t, o) {
10
+ return t === "super" ? D * o : t === "sub" ? U * o : 0;
11
+ }
12
+ const X = (t) => Math.max(1, t / 14), v = 1.5, K = (t) => -0.28 * t;
13
+ function g(t, o = x) {
14
+ const i = t.link !== void 0 && t.link.startsWith("#"), n = t.link !== void 0 && !i;
15
+ let c = t.color;
16
+ return n ? c = o : i && P.has(t.color.toLowerCase()) && (c = A), {
17
+ color: c,
18
+ underline: n || !!t.underline && !i,
19
+ strike: !!t.strikethrough,
20
+ externalLink: n
21
+ };
22
+ }
23
+ function z(t) {
24
+ return t === "dot" ? [1, 3] : t === "dash" ? [4, 3] : [];
25
+ }
26
+ const W = (t) => Math.max(1, t / 14), Y = [1, 4], j = 8, q = 1 / 3, J = "#c0c4c9", F = 24;
27
+ function Q(t, o, i, n) {
28
+ const c = t.offsetFrom === "text", a = (s) => s?.spacePx ?? F, O = c ? n.left - a(t.left) : a(t.left), E = c ? o - n.right + a(t.right) : o - a(t.right), L = c ? n.top - a(t.top) : a(t.top), l = c ? i - n.bottom + a(t.bottom) : i - a(t.bottom), r = [], R = (s, u, e, T, f) => {
29
+ if (!s || s.style === "none") return;
30
+ const h = s.style === "thick" ? Math.max(2, s.widthPx) : Math.max(0.5, s.widthPx), C = s.color === "auto" ? "#000000" : s.color, S = s.style === "dashed" ? [h * 3, h * 2] : s.style === "dotted" ? [h, h * 1.5] : [];
31
+ if (r.push({ x1: u, y1: e, x2: T, y2: f, widthPx: h, color: C, dash: S }), s.style === "double") {
32
+ const d = h + 1;
33
+ if (e === f) {
34
+ const _ = e < i / 2 ? d : -d;
35
+ r.push({ x1: u, y1: e + _, x2: T, y2: f + _, widthPx: h, color: C, dash: [] });
36
+ } else {
37
+ const _ = u < o / 2 ? d : -d;
38
+ r.push({ x1: u + _, y1: e, x2: T + _, y2: f, widthPx: h, color: C, dash: [] });
39
+ }
40
+ }
41
+ };
42
+ return R(t.top, O, L, E, L), R(t.bottom, O, l, E, l), R(t.left, O, L, O, l), R(t.right, E, L, E, l), r;
43
+ }
44
+ const V = (t) => Math.max(0.5, t);
45
+ function Z(t, o) {
46
+ return t === "dashed" ? [o * 3, o * 2] : t === "dotted" ? [o, o * 1.5] : [];
47
+ }
48
+ const $ = (t) => t + 1;
49
+ export {
50
+ B as A,
51
+ J as C,
52
+ p as D,
53
+ x as E,
54
+ I as F,
55
+ M as I,
56
+ G as S,
57
+ j as T,
58
+ v as U,
59
+ k as a,
60
+ Y as b,
61
+ z as c,
62
+ X as d,
63
+ V as e,
64
+ Z as f,
65
+ $ as g,
66
+ q as h,
67
+ m as i,
68
+ W as l,
69
+ w as n,
70
+ Q as p,
71
+ g as r,
72
+ K as s,
73
+ H as v
74
+ };