@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
@@ -0,0 +1,149 @@
1
+ const l = (e) => Number.isFinite(e) ? e : 0, s = (e) => Math.round(l(e) * 15), d = (e) => Math.round(l(e) * 1.5), z = (e) => Math.round(l(e) * 9525), L = (e) => Math.max(2, Math.round(l(e) * 6)), w = (e) => Math.round(l(e) * 240), c = {
2
+ "#ffff00": "yellow",
3
+ "#00ff00": "green",
4
+ "#00ffff": "cyan",
5
+ "#ff00ff": "magenta",
6
+ "#0000ff": "blue",
7
+ "#ff0000": "red",
8
+ "#000080": "darkBlue",
9
+ "#008080": "darkCyan",
10
+ "#008000": "darkGreen",
11
+ "#800080": "darkMagenta",
12
+ "#800000": "darkRed",
13
+ "#808000": "darkYellow",
14
+ "#808080": "darkGray",
15
+ "#c0c0c0": "lightGray",
16
+ "#000000": "black",
17
+ "#ffffff": "white"
18
+ }, u = { left: "left", center: "center", right: "right", justify: "both" }, p = { left: "left", center: "center", right: "right", decimal: "decimal" }, g = { dot: "dot", dash: "hyphen", underscore: "underscore" }, f = (e) => e.replace(/^#/, "").toLowerCase();
19
+ function m(e) {
20
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
21
+ }
22
+ function k(e) {
23
+ return m(e).replace(/"/g, "&quot;");
24
+ }
25
+ function A(e) {
26
+ if (!e) return "";
27
+ let t = "";
28
+ for (const [i, o] of Object.entries(e))
29
+ o === void 0 || o === !1 || (t += ` ${i}="${k(String(o))}"`);
30
+ return t;
31
+ }
32
+ function n(e, t, i) {
33
+ const o = A(t);
34
+ return i === void 0 || i === "" ? `<${e}${o}/>` : `<${e}${o}>${i}</${e}>`;
35
+ }
36
+ function F(e) {
37
+ const t = /^\s|\s$|\s\s/.test(e) || e.includes(" ");
38
+ return n("w:t", t ? { "xml:space": "preserve" } : void 0, m(e));
39
+ }
40
+ const B = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
41
+ `, C = {
42
+ "xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
43
+ "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
44
+ "xmlns:wp": "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
45
+ "xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
46
+ "xmlns:pic": "http://schemas.openxmlformats.org/drawingml/2006/picture",
47
+ "xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml",
48
+ "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006"
49
+ };
50
+ function T(e) {
51
+ const t = (e.fontFamily.split(",")[0] ?? "").trim(), i = [];
52
+ if (e.charStyleId && i.push(n("w:rStyle", { "w:val": e.charStyleId })), t && i.push(n("w:rFonts", { "w:ascii": t, "w:hAnsi": t, "w:cs": t })), i.push(n("w:b", { "w:val": e.bold ? "1" : "0" })), i.push(n("w:i", { "w:val": e.italic ? "1" : "0" })), e.strikethrough && i.push(n("w:strike", { "w:val": "1" })), e.hidden && i.push(n("w:vanish", { "w:val": "1" })), i.push(n("w:color", { "w:val": f(e.color) })), i.push(n("w:sz", { "w:val": d(e.fontSizePx) })), i.push(n("w:szCs", { "w:val": d(e.fontSizePx) })), i.push(n("w:u", { "w:val": e.underline ? "single" : "none" })), e.letterSpacingPx !== void 0 && i.push(n("w:spacing", { "w:val": s(e.letterSpacingPx) })), e.highlightColor) {
53
+ const o = c[e.highlightColor.toLowerCase()];
54
+ o && i.push(n("w:highlight", { "w:val": o }));
55
+ }
56
+ return e.verticalAlign && i.push(n("w:vertAlign", { "w:val": e.verticalAlign === "super" ? "superscript" : "subscript" })), n("w:rPr", void 0, i.join(""));
57
+ }
58
+ function M(e) {
59
+ const t = [];
60
+ t.push(n("w:spacing", {
61
+ "w:before": s(e.spaceBeforePx),
62
+ "w:after": s(e.spaceAfterPx),
63
+ "w:line": w(e.lineHeight),
64
+ "w:lineRule": "auto"
65
+ }));
66
+ const i = {};
67
+ if (e.indentLeftPx && (i["w:left"] = s(e.indentLeftPx)), e.indentRightPx && (i["w:right"] = s(e.indentRightPx)), e.indentFirstLinePx > 0 ? i["w:firstLine"] = s(e.indentFirstLinePx) : e.indentFirstLinePx < 0 && (i["w:hanging"] = s(-e.indentFirstLinePx)), Object.keys(i).length > 0 && t.push(n("w:ind", i)), t.push(n("w:jc", { "w:val": u[e.align] })), e.tabStops && e.tabStops.length > 0) {
68
+ const o = e.tabStops.map(
69
+ (r) => n("w:tab", {
70
+ "w:val": r.align ? p[r.align] ?? "left" : "left",
71
+ "w:pos": s(r.posPx),
72
+ "w:leader": r.leader && r.leader !== "none" ? g[r.leader] : void 0
73
+ })
74
+ ).join("");
75
+ t.push(n("w:tabs", void 0, o));
76
+ }
77
+ return t.join("");
78
+ }
79
+ function v(e) {
80
+ const t = [];
81
+ if (e.fontFamily) {
82
+ const i = (e.fontFamily.split(",")[0] ?? "").trim();
83
+ i && t.push(n("w:rFonts", { "w:ascii": i, "w:hAnsi": i, "w:cs": i }));
84
+ }
85
+ if (e.bold !== void 0 && t.push(n("w:b", { "w:val": e.bold ? "1" : "0" })), e.italic !== void 0 && t.push(n("w:i", { "w:val": e.italic ? "1" : "0" })), e.strikethrough !== void 0 && t.push(n("w:strike", { "w:val": e.strikethrough ? "1" : "0" })), e.color && t.push(n("w:color", { "w:val": f(e.color) })), e.fontSizePx !== void 0) {
86
+ const i = Math.round(e.fontSizePx * 1.5);
87
+ t.push(n("w:sz", { "w:val": i })), t.push(n("w:szCs", { "w:val": i }));
88
+ }
89
+ if (e.underline !== void 0 && t.push(n("w:u", { "w:val": e.underline ? "single" : "none" })), e.highlightColor) {
90
+ const i = c[e.highlightColor.toLowerCase()];
91
+ i && t.push(n("w:highlight", { "w:val": i }));
92
+ }
93
+ return e.verticalAlign && t.push(n("w:vertAlign", { "w:val": e.verticalAlign === "super" ? "superscript" : "subscript" })), t.length > 0 ? n("w:rPr", void 0, t.join("")) : "";
94
+ }
95
+ function x(e) {
96
+ const t = [];
97
+ e.align && t.push(n("w:jc", { "w:val": u[e.align] ?? "left" }));
98
+ const i = {};
99
+ e.spaceBeforePx !== void 0 && (i["w:before"] = s(e.spaceBeforePx)), e.spaceAfterPx !== void 0 && (i["w:after"] = s(e.spaceAfterPx)), e.lineHeight !== void 0 && (i["w:line"] = w(e.lineHeight), i["w:lineRule"] = "auto"), Object.keys(i).length > 0 && t.push(n("w:spacing", i));
100
+ const o = {};
101
+ if (e.indentLeftPx !== void 0 && (o["w:left"] = s(e.indentLeftPx)), e.indentRightPx !== void 0 && (o["w:right"] = s(e.indentRightPx)), e.indentFirstLinePx !== void 0 && (e.indentFirstLinePx >= 0 ? o["w:firstLine"] = s(e.indentFirstLinePx) : o["w:hanging"] = s(-e.indentFirstLinePx)), Object.keys(o).length > 0 && t.push(n("w:ind", o)), e.keepWithNext && t.push(n("w:keepNext")), e.keepLinesTogether && t.push(n("w:keepLines")), e.tabStops && e.tabStops.length > 0) {
102
+ const r = e.tabStops.map(
103
+ (a) => n("w:tab", {
104
+ "w:val": a.align ? p[a.align] ?? "left" : "left",
105
+ "w:pos": s(a.posPx),
106
+ "w:leader": a.leader && a.leader !== "none" ? g[a.leader] : void 0
107
+ })
108
+ ).join("");
109
+ t.push(n("w:tabs", void 0, r));
110
+ }
111
+ return t.length > 0 ? n("w:pPr", void 0, t.join("")) : "";
112
+ }
113
+ function b(e, t) {
114
+ const i = (o, r) => {
115
+ if (!r) return "";
116
+ const a = r.style === "double" ? "double" : r.style === "dashed" ? "dashed" : r.style === "dotted" ? "dotted" : "single";
117
+ return n("w:" + o, { "w:val": a, "w:sz": L(r.widthPx), "w:space": 0, "w:color": f(r.color) });
118
+ };
119
+ return n(e, void 0, i("top", t.top) + i("left", t.left) + i("bottom", t.bottom) + i("right", t.right));
120
+ }
121
+ const P = (e) => n("w:shd", { "w:val": "clear", "w:color": "auto", "w:fill": f(e) });
122
+ function j(e, t) {
123
+ const i = [];
124
+ t.borders && i.push(b("w:tcBorders", t.borders)), t.shading && i.push(P(t.shading));
125
+ const o = i.length > 0 ? n("w:tcPr", void 0, i.join("")) : "";
126
+ return n("w:tblStylePr", { "w:type": e }, v(t.char ?? {}) + x(t.para ?? {}) + o);
127
+ }
128
+ function R(e) {
129
+ const t = e.conds.wholeTable ?? {}, i = [];
130
+ e.rowBandSize !== void 0 && i.push(n("w:tblStyleRowBandSize", { "w:val": e.rowBandSize })), e.colBandSize !== void 0 && i.push(n("w:tblStyleColBandSize", { "w:val": e.colBandSize })), t.borders && i.push(b("w:tblBorders", t.borders)), t.shading && i.push(P(t.shading));
131
+ const o = i.length > 0 ? n("w:tblPr", void 0, i.join("")) : "", r = Object.entries(e.conds).filter(([h]) => h !== "wholeTable").map(([h, S]) => j(h, S)).join(""), a = n("w:name", { "w:val": e.name }) + (e.basedOn ? n("w:basedOn", { "w:val": e.basedOn }) : "") + v(t.char ?? {}) + x(t.para ?? {}) + o + r;
132
+ return n("w:style", { "w:type": "table", "w:styleId": e.id }, a);
133
+ }
134
+ export {
135
+ C as W,
136
+ B as X,
137
+ m as a,
138
+ M as b,
139
+ z as c,
140
+ L as d,
141
+ n as e,
142
+ v as f,
143
+ x as g,
144
+ f as h,
145
+ R as i,
146
+ s as p,
147
+ T as r,
148
+ F as t
149
+ };
@@ -0,0 +1,146 @@
1
+ import { c as u } from "./toc-D09f4PrI.js";
2
+ function p(e) {
3
+ return e.type ?? "paragraph";
4
+ }
5
+ function c(e, t) {
6
+ return e.styles.find((a) => a.id === t);
7
+ }
8
+ function g(e, t) {
9
+ const a = [], r = /* @__PURE__ */ new Set();
10
+ for (let s = c(e, t); s && !r.has(s.id); s = s.basedOn ? c(e, s.basedOn) : void 0)
11
+ r.add(s.id), a.unshift(s);
12
+ const o = {}, n = {};
13
+ for (const s of a)
14
+ Object.assign(o, f(s.char)), Object.assign(n, f(s.para));
15
+ return { char: o, para: n };
16
+ }
17
+ function O(e, t) {
18
+ const a = [], r = /* @__PURE__ */ new Set();
19
+ for (let n = c(e, t); n && !r.has(n.id); n = n.basedOn ? c(e, n.basedOn) : void 0)
20
+ r.add(n.id), a.unshift(n);
21
+ const o = {};
22
+ for (const n of a) Object.assign(o, f(n.char));
23
+ return o;
24
+ }
25
+ function y(e, t) {
26
+ const a = /* @__PURE__ */ new Set();
27
+ let r = !0;
28
+ for (; r; ) {
29
+ r = !1;
30
+ for (const o of e.styles)
31
+ a.has(o.id) || o.basedOn !== void 0 && (o.basedOn === t || a.has(o.basedOn)) && (a.add(o.id), r = !0);
32
+ }
33
+ return a;
34
+ }
35
+ function S(e, t, a) {
36
+ return a ? a === t ? !0 : y(e, t).has(a) : !1;
37
+ }
38
+ function h(e) {
39
+ const t = (a) => Object.entries(f(a)).sort(([r], [o]) => r < o ? -1 : r > o ? 1 : 0);
40
+ return JSON.stringify([p(e), e.basedOn ?? "", t(e.char), t(e.para)]);
41
+ }
42
+ function x(e) {
43
+ const t = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
44
+ for (const n of e.styles) {
45
+ const s = h(n), i = a.get(s);
46
+ if (i === void 0)
47
+ a.set(s, n.id);
48
+ else if (n.id === e.defaultStyleId) {
49
+ a.set(s, n.id), t.set(i, n.id);
50
+ for (const [l, d] of t) d === i && t.set(l, n.id);
51
+ } else
52
+ t.set(n.id, i);
53
+ }
54
+ if (t.size === 0) return { sheet: e, remap: t };
55
+ const r = (n) => t.get(n) ?? n, o = [];
56
+ for (const n of e.styles) {
57
+ if (t.has(n.id)) continue;
58
+ const s = { ...n };
59
+ if (s.basedOn !== void 0) {
60
+ const i = r(s.basedOn);
61
+ i === s.id ? delete s.basedOn : s.basedOn = i;
62
+ }
63
+ o.push(s);
64
+ }
65
+ return { sheet: { styles: o, defaultStyleId: r(e.defaultStyleId) }, remap: t };
66
+ }
67
+ function f(e) {
68
+ const t = {};
69
+ for (const [a, r] of Object.entries(e))
70
+ r !== void 0 && (t[a] = r);
71
+ return t;
72
+ }
73
+ function P(e, t) {
74
+ return u(e).filter((a) => a.style.namedStyle === t);
75
+ }
76
+ function b(e = {}) {
77
+ const t = e.fontFamily ?? "Georgia, serif", a = e.fontSizePx ?? 16, r = e.color ?? "#202124", o = e.headingFontFamily ?? "Arial, sans-serif", n = { lineHeight: e.lineHeight ?? 1.5, spaceBeforePx: 0, spaceAfterPx: 12 };
78
+ return {
79
+ defaultStyleId: "Normal",
80
+ styles: [
81
+ {
82
+ id: "Normal",
83
+ name: "Normal",
84
+ char: { fontFamily: t, fontSizePx: a, bold: !1, italic: !1, color: r },
85
+ para: { ...n, align: "left", indentFirstLinePx: 0 }
86
+ },
87
+ {
88
+ id: "Title",
89
+ name: "Title",
90
+ basedOn: "Normal",
91
+ char: { fontFamily: o, fontSizePx: 32, bold: !0, color: "#1a1a2e" },
92
+ para: { align: "center", spaceAfterPx: 4 }
93
+ },
94
+ {
95
+ id: "Subtitle",
96
+ name: "Subtitle",
97
+ basedOn: "Normal",
98
+ char: { italic: !0, color: "#5f6368" },
99
+ para: { align: "center", spaceAfterPx: 28 }
100
+ },
101
+ {
102
+ id: "Heading1",
103
+ name: "Heading 1",
104
+ basedOn: "Normal",
105
+ char: { fontFamily: o, fontSizePx: 24, bold: !0, color: "#1a1a2e" },
106
+ para: { spaceBeforePx: 18, spaceAfterPx: 8, keepWithNext: !0 }
107
+ },
108
+ {
109
+ id: "Heading2",
110
+ name: "Heading 2",
111
+ basedOn: "Heading1",
112
+ char: { fontSizePx: 19 },
113
+ para: { spaceBeforePx: 14, spaceAfterPx: 6 }
114
+ },
115
+ {
116
+ id: "Quote",
117
+ name: "Quote",
118
+ basedOn: "Normal",
119
+ char: { italic: !0, color: "#5f6368" },
120
+ para: { indentLeftPx: 36, spaceBeforePx: 8, spaceAfterPx: 8 }
121
+ },
122
+ {
123
+ id: "Code",
124
+ name: "Code",
125
+ basedOn: "Normal",
126
+ char: { fontFamily: "Consolas, monospace", fontSizePx: 14, color: "#0b57d0" },
127
+ para: { lineHeight: 1.35 }
128
+ }
129
+ ]
130
+ };
131
+ }
132
+ function v() {
133
+ return b();
134
+ }
135
+ export {
136
+ p as a,
137
+ g as b,
138
+ x as c,
139
+ v as d,
140
+ y as e,
141
+ b as m,
142
+ P as p,
143
+ O as r,
144
+ c as s,
145
+ S as w
146
+ };