@forevka/wordcanvas 0.7.0 → 0.7.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.
Files changed (66) hide show
  1. package/README.md +48 -1
  2. package/dist-lib/assets/{worker-BsOsK39A.js → worker-4HYrkNrG.js} +12276 -11981
  3. package/dist-lib/assets/worker-CJpwUzKh.js +2403 -0
  4. package/dist-lib/blockFactory-B_CLnkUh.js +106 -0
  5. package/dist-lib/browser-p_rkUcqE.js +1339 -0
  6. package/dist-lib/builder.js +365 -109
  7. package/dist-lib/editorApp-mTD0YNv-.js +9863 -0
  8. package/dist-lib/export.js +4670 -4567
  9. package/dist-lib/generate-toc.js +5 -5
  10. package/dist-lib/import.js +4 -1538
  11. package/dist-lib/{lists-BegzmTmD.js → lists-Sc5I40JO.js} +2 -2
  12. package/dist-lib/measure.js +2 -2
  13. package/dist-lib/{measureHost-CMiJKdlk.js → measureHost-B2aKX7lF.js} +1 -1
  14. package/dist-lib/metrics-BUMIC9Mv.js +164 -0
  15. package/dist-lib/pipeline-DD0nxAYM.js +1850 -0
  16. package/dist-lib/recalc-docx.js +2 -2
  17. package/dist-lib/recalcToc-CFCGCgij.js +3985 -0
  18. package/dist-lib/styleProps-DhqDEfvc.js +149 -0
  19. package/dist-lib/stylesheet-B6oczA-L.js +141 -0
  20. package/dist-lib/toc-Dj57zdz-.js +213 -0
  21. package/dist-lib/{webmcp-B7Gvd58E.js → webmcp-CXghUon_.js} +2 -2
  22. package/dist-lib/{wordcanvas-BAxBeErX.js → wordcanvas-D5DI9ZR1.js} +49 -23
  23. package/dist-lib/wordcanvas.js +1 -1
  24. package/dist-node/{chunk-GXFDF7UY.js → chunk-57L5XMCL.js} +327 -59
  25. package/dist-node/chunk-57L5XMCL.js.map +7 -0
  26. package/dist-node/{chunk-TBSXA2I4.js → chunk-EGSAVPCC.js} +1 -1
  27. package/dist-node/chunk-EGSAVPCC.js.map +7 -0
  28. package/dist-node/{chunk-4PDVRJF6.js → chunk-EMY2P524.js} +32 -2
  29. package/dist-node/chunk-EMY2P524.js.map +7 -0
  30. package/dist-node/{chunk-2RCPB7UZ.js → chunk-KJV7GJ3H.js} +1 -1
  31. package/dist-node/chunk-KJV7GJ3H.js.map +7 -0
  32. package/dist-node/{chunk-XDUDPPJW.js → chunk-PIMVQULL.js} +93 -24
  33. package/dist-node/chunk-PIMVQULL.js.map +7 -0
  34. package/dist-node/{chunk-BRAPV465.js → chunk-SA26UVIJ.js} +2 -2
  35. package/dist-node/{chunk-IJLL6IFJ.js → chunk-T3253N22.js} +202 -13
  36. package/dist-node/{chunk-IJLL6IFJ.js.map → chunk-T3253N22.js.map} +2 -2
  37. package/dist-node/{chunk-4ICCHZX4.js → chunk-U27EBKBG.js} +37 -1
  38. package/dist-node/chunk-U27EBKBG.js.map +7 -0
  39. package/dist-node/{engine-FRCX7PXF.js → engine-5F7DUU4W.js} +4 -4
  40. package/dist-node/export.js +178 -52
  41. package/dist-node/export.js.map +2 -2
  42. package/dist-node/generate-toc.js +7 -7
  43. package/dist-node/import.js +3 -3
  44. package/dist-node/measure.js +2 -2
  45. package/dist-node/recalc-docx.js +5 -5
  46. package/dist-node/recalc-docx.js.map +1 -1
  47. package/package.json +1 -1
  48. package/types/model.d.ts +277 -225
  49. package/types/recalc-docx.d.ts +27 -27
  50. package/types/wordcanvas.d.ts +212 -157
  51. package/dist-lib/assets/worker-BbFAIxdy.js +0 -2163
  52. package/dist-lib/blockFactory-Bcy0U40y.js +0 -178
  53. package/dist-lib/browser-5Sv4CuNy.js +0 -1284
  54. package/dist-lib/editorApp-DvjFPHiy.js +0 -7582
  55. package/dist-lib/metrics-CkAo4zh8.js +0 -143
  56. package/dist-lib/recalcToc-uaLWt59L.js +0 -3835
  57. package/dist-lib/styleProps-Db5pEkG8.js +0 -127
  58. package/dist-lib/toc-CZel_Kk3.js +0 -127
  59. package/dist-node/chunk-2RCPB7UZ.js.map +0 -7
  60. package/dist-node/chunk-4ICCHZX4.js.map +0 -7
  61. package/dist-node/chunk-4PDVRJF6.js.map +0 -7
  62. package/dist-node/chunk-GXFDF7UY.js.map +0 -7
  63. package/dist-node/chunk-TBSXA2I4.js.map +0 -7
  64. package/dist-node/chunk-XDUDPPJW.js.map +0 -7
  65. /package/dist-node/{chunk-BRAPV465.js.map → chunk-SA26UVIJ.js.map} +0 -0
  66. /package/dist-node/{engine-FRCX7PXF.js.map → engine-5F7DUU4W.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,141 @@
1
+ import { p as u } from "./browser-p_rkUcqE.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 m(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, d(s.char)), Object.assign(n, d(s.para));
15
+ return { char: o, para: n };
16
+ }
17
+ function g(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, d(n.char));
23
+ return o;
24
+ }
25
+ function b(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 O(e, t, a) {
36
+ return a ? a === t ? !0 : b(e, t).has(a) : !1;
37
+ }
38
+ function y(e) {
39
+ const t = (a) => Object.entries(d(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 S(e) {
43
+ const t = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
44
+ for (const n of e.styles) {
45
+ const s = y(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 [f, l] of t) l === i && t.set(f, 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 d(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 x(e, t) {
74
+ return u(e).filter((a) => a.style.namedStyle === t);
75
+ }
76
+ function P() {
77
+ return {
78
+ defaultStyleId: "Normal",
79
+ styles: [
80
+ {
81
+ id: "Normal",
82
+ name: "Normal",
83
+ char: { fontFamily: "Georgia, serif", fontSizePx: 16, bold: !1, italic: !1, color: "#202124" },
84
+ para: { ...{ lineHeight: 1.5, spaceBeforePx: 0, spaceAfterPx: 12 }, align: "left", indentFirstLinePx: 0 }
85
+ },
86
+ {
87
+ id: "Title",
88
+ name: "Title",
89
+ basedOn: "Normal",
90
+ char: { fontFamily: "Arial, sans-serif", fontSizePx: 32, bold: !0, color: "#1a1a2e" },
91
+ para: { align: "center", spaceAfterPx: 4 }
92
+ },
93
+ {
94
+ id: "Subtitle",
95
+ name: "Subtitle",
96
+ basedOn: "Normal",
97
+ char: { italic: !0, color: "#5f6368" },
98
+ para: { align: "center", spaceAfterPx: 28 }
99
+ },
100
+ {
101
+ id: "Heading1",
102
+ name: "Heading 1",
103
+ basedOn: "Normal",
104
+ char: { fontFamily: "Arial, sans-serif", fontSizePx: 24, bold: !0, color: "#1a1a2e" },
105
+ para: { spaceBeforePx: 18, spaceAfterPx: 8, keepWithNext: !0 }
106
+ },
107
+ {
108
+ id: "Heading2",
109
+ name: "Heading 2",
110
+ basedOn: "Heading1",
111
+ char: { fontSizePx: 19 },
112
+ para: { spaceBeforePx: 14, spaceAfterPx: 6 }
113
+ },
114
+ {
115
+ id: "Quote",
116
+ name: "Quote",
117
+ basedOn: "Normal",
118
+ char: { italic: !0, color: "#5f6368" },
119
+ para: { indentLeftPx: 36, spaceBeforePx: 8, spaceAfterPx: 8 }
120
+ },
121
+ {
122
+ id: "Code",
123
+ name: "Code",
124
+ basedOn: "Normal",
125
+ char: { fontFamily: "Consolas, monospace", fontSizePx: 14, color: "#0b57d0" },
126
+ para: { lineHeight: 1.35 }
127
+ }
128
+ ]
129
+ };
130
+ }
131
+ export {
132
+ p as a,
133
+ m as b,
134
+ b as c,
135
+ P as d,
136
+ S as m,
137
+ x as p,
138
+ g as r,
139
+ c as s,
140
+ O as w
141
+ };
@@ -0,0 +1,213 @@
1
+ import { t as b, x as k, A as v } from "./browser-p_rkUcqE.js";
2
+ function y(t, e = 0) {
3
+ let i = e;
4
+ return {
5
+ siteId: t,
6
+ next: () => `${t}-${(i++).toString(36)}`,
7
+ count: () => i
8
+ };
9
+ }
10
+ let h = y("local");
11
+ function A(t, e = 0) {
12
+ h = y(t, e);
13
+ }
14
+ function g() {
15
+ return h.next();
16
+ }
17
+ function E() {
18
+ return h.siteId;
19
+ }
20
+ const m = (t) => {
21
+ if (!t) return;
22
+ const e = t.match(/^(\d+)\s*-\s*(\d+)$/);
23
+ if (e) return { from: Number(e[1]), to: Number(e[2]) };
24
+ const i = t.match(/^\d+$/) ? Number(t) : NaN;
25
+ return Number.isNaN(i) ? void 0 : { from: i, to: i };
26
+ };
27
+ function S(t) {
28
+ const e = {
29
+ useOutlineLevels: /\\u\b/.test(t),
30
+ hyperlinks: /\\h\b/.test(t),
31
+ hideInWeb: /\\z\b/.test(t)
32
+ }, i = m(t.match(/\\o\s+"([^"]+)"/)?.[1]);
33
+ i && (e.outlineRange = i);
34
+ const n = m(t.match(/\\n\s+"?([0-9-]+)"?/)?.[1]);
35
+ n && (e.hidePageNumberRange = n);
36
+ const a = t.match(/\\p\s+"([^"]*)"/)?.[1];
37
+ a !== void 0 && (e.separator = a);
38
+ const s = t.match(/\\t\s+"([^"]+)"/)?.[1];
39
+ if (s) {
40
+ const r = s.split(","), o = {};
41
+ for (let l = 0; l + 1 < r.length; l += 2) {
42
+ const c = r[l].trim(), u = Number(r[l + 1].trim());
43
+ c && u >= 1 && (o[c] = u);
44
+ }
45
+ Object.keys(o).length > 0 && (e.customStyles = o);
46
+ }
47
+ return e;
48
+ }
49
+ function B(t) {
50
+ const e = ["TOC"];
51
+ if (t.outlineRange && e.push(`\\o "${t.outlineRange.from}-${t.outlineRange.to}"`), t.useOutlineLevels && e.push("\\u"), t.customStyles && Object.keys(t.customStyles).length > 0) {
52
+ const i = Object.entries(t.customStyles).map(([n, a]) => `${n},${a}`).join(",");
53
+ e.push(`\\t "${i}"`);
54
+ }
55
+ return t.hyperlinks && e.push("\\h"), t.hidePageNumberRange && e.push(`\\n "${t.hidePageNumberRange.from}-${t.hidePageNumberRange.to}"`), t.separator !== void 0 && e.push(`\\p "${t.separator}"`), t.hideInWeb && e.push("\\z"), ` ${e.join(" ")} `;
56
+ }
57
+ const C = (t, e) => !!t && e >= t.from && e <= t.to;
58
+ function p(t, e) {
59
+ if (!e || !t.stylesheet) return;
60
+ const i = new Map(t.stylesheet.styles.map((s) => [s.id, s]));
61
+ let n = i.get(e);
62
+ const a = /* @__PURE__ */ new Set();
63
+ for (; n && !a.has(n.id); ) {
64
+ if (n.name && /(?:^|\s)heading\s*\d/i.test(n.name)) return n.name;
65
+ a.add(n.id), n = n.basedOn ? i.get(n.basedOn) : void 0;
66
+ }
67
+ return i.get(e)?.name;
68
+ }
69
+ function I(t, e, i) {
70
+ const n = t.style.namedStyle;
71
+ if (i?.customStyles && n) {
72
+ const r = i.customStyles[n] ?? i.customStyles[p(e, n) ?? ""];
73
+ if (r) return r;
74
+ }
75
+ if (t.style.outlineLevel !== void 0) return t.style.outlineLevel + 1;
76
+ const a = n?.match(/^heading\s*(\d)$/i);
77
+ if (a) return Number(a[1]);
78
+ const s = p(e, n)?.match(/(?:^|\s)heading\s*(\d)/i);
79
+ return s ? Number(s[1]) : null;
80
+ }
81
+ function R(t, e, i = 3) {
82
+ const n = e?.outlineRange?.to ?? i, a = [];
83
+ for (const s of v(t)) {
84
+ const r = I(s, t, e);
85
+ r === null || r < 1 || r > n || e?.outlineRange && (r < e.outlineRange.from || r > e.outlineRange.to) || a.push({ block: s, level: r });
86
+ }
87
+ return a;
88
+ }
89
+ function H(t, e = 20) {
90
+ if (!t.bookmarks) return 0;
91
+ const i = t.section.pageWidthPx - t.section.marginPx.left - t.section.marginPx.right;
92
+ let n = 0;
93
+ for (const a of t.blocks) {
94
+ if (a.kind !== "paragraph" || a.style.tocEntry) continue;
95
+ const s = a.runs.find((u) => u.style.link?.startsWith("#"))?.style.link?.slice(1);
96
+ if (!s) continue;
97
+ const r = t.bookmarks[s]?.start.blockId;
98
+ if (!r) continue;
99
+ const o = b(a.runs), l = o.match(/\t\d+\s*$/);
100
+ if (!l) continue;
101
+ a.runs = k(a.runs, 0, o.length - l[0].length), a.runs.length === 0 && (a.runs = [{ text: "", style: { ...f } }]);
102
+ const c = Math.min(9, Math.max(1, Math.round((a.style.indentLeftPx || 0) / e) + 1));
103
+ a.style.tocEntry = { targetId: r, level: c }, !a.style.tabStops?.length && i > 0 && (a.style.tabStops = [{ posPx: i, align: "right", leader: "dot" }]), a.revision++, n++;
104
+ }
105
+ return n;
106
+ }
107
+ const f = {
108
+ fontFamily: "Georgia, serif",
109
+ fontSizePx: 13,
110
+ bold: !1,
111
+ italic: !1,
112
+ underline: !1,
113
+ strikethrough: !1,
114
+ color: "#202124"
115
+ };
116
+ function L(t, e, i, n) {
117
+ const a = t.indentStepPx ?? 20, s = t.leader ?? "dot";
118
+ let r, o;
119
+ if (n && (n.char || n.para)) {
120
+ r = { ...f, ...n.char, ...t.baseChar, ...t.levels?.[e]?.char };
121
+ const l = n.para?.indentLeftPx ?? 0;
122
+ o = {
123
+ align: "left",
124
+ lineHeight: 1.5,
125
+ spaceBeforePx: 0,
126
+ spaceAfterPx: 2,
127
+ indentFirstLinePx: 0,
128
+ ...n.para,
129
+ indentLeftPx: l + (e - 1) * a,
130
+ ...t.levels?.[e]?.para
131
+ };
132
+ } else
133
+ r = { ...{ ...f, ...t.baseChar }, fontSizePx: e === 1 ? 14 : 13, bold: e === 1, ...t.levels?.[e]?.char }, o = {
134
+ align: "left",
135
+ lineHeight: 1.5,
136
+ spaceBeforePx: 0,
137
+ spaceAfterPx: 2,
138
+ indentFirstLinePx: 0,
139
+ indentLeftPx: (e - 1) * a,
140
+ ...t.levels?.[e]?.para
141
+ };
142
+ return s !== "none" && i > 0 ? o.tabStops = [{ posPx: i, align: "right", leader: s }] : delete o.tabStops, { char: r, para: o };
143
+ }
144
+ function N(t) {
145
+ if (t.title === null) return null;
146
+ const e = t.title ?? {}, i = { ...f, ...t.baseChar };
147
+ return {
148
+ text: e.text ?? "Table of Contents",
149
+ char: { ...i, fontSizePx: 20, bold: !0, ...e.char },
150
+ para: {
151
+ align: "left",
152
+ lineHeight: 1.4,
153
+ spaceBeforePx: 8,
154
+ spaceAfterPx: 12,
155
+ indentFirstLinePx: 0,
156
+ indentLeftPx: 0,
157
+ namedStyle: e.namedStyle ?? "tocTitle",
158
+ ...e.para
159
+ }
160
+ };
161
+ }
162
+ const $ = 3;
163
+ function T(t, e = {}) {
164
+ const i = t.tocInstruction ? S(t.tocInstruction) : void 0, n = e.maxLevel ?? i?.outlineRange?.to ?? $, a = t.section.pageWidthPx - t.section.marginPx.left - t.section.marginPx.right, s = t.tocAnchorBlockId ? t.blocks.find((c) => c.kind === "paragraph" && c.id === t.tocAnchorBlockId) : void 0, r = s ? { char: s.runs[0]?.style, para: s.style } : void 0, o = [];
165
+ if (e.title !== void 0 ? e.title !== null : s === void 0) {
166
+ const c = N(e);
167
+ c && o.push({
168
+ kind: "paragraph",
169
+ id: g(),
170
+ revision: 0,
171
+ runs: [{ text: c.text, style: c.char }],
172
+ style: c.para
173
+ });
174
+ }
175
+ for (const { block: c, level: u } of R(t, i, n)) {
176
+ const d = b(c.runs).replace(/\v/g, " ").trim();
177
+ if (d.length === 0) continue;
178
+ const { char: x, para: P } = L(e, u, a, r);
179
+ o.push({
180
+ kind: "paragraph",
181
+ id: g(),
182
+ revision: 0,
183
+ runs: [{ text: d, style: x }],
184
+ style: { ...P, tocEntry: { targetId: c.id, level: u } }
185
+ });
186
+ }
187
+ return o;
188
+ }
189
+ function W(t, e = {}) {
190
+ if (t.blocks.some((r) => r.kind === "paragraph" && r.style.tocEntry))
191
+ return { doc: t, generated: 0, headings: 0 };
192
+ if (t.tocAnchorBlockId === void 0) return { doc: t, generated: 0, headings: 0 };
193
+ const i = t.blocks.findIndex((r) => r.id === t.tocAnchorBlockId);
194
+ if (i < 0) return { doc: t, generated: 0, headings: 0 };
195
+ const n = T(t, e), a = n.reduce((r, o) => r + (o.style.tocEntry ? 1 : 0), 0);
196
+ if (a === 0) return { doc: t, generated: 0, headings: 0 };
197
+ const s = [...t.blocks];
198
+ return s.splice(i, 1, ...n), { doc: { ...t, blocks: s }, generated: a, headings: a };
199
+ }
200
+ export {
201
+ T as a,
202
+ B as b,
203
+ E as c,
204
+ R as d,
205
+ A as e,
206
+ g as f,
207
+ W as g,
208
+ y as h,
209
+ C as i,
210
+ H as m,
211
+ S as p,
212
+ L as t
213
+ };
@@ -1,4 +1,4 @@
1
- import { p as j, c as _, n as F, t as k } from "./browser-5Sv4CuNy.js";
1
+ import { p as j, d as _, q as F, t as k } from "./browser-p_rkUcqE.js";
2
2
  const s = (e) => Math.round(e * 100) / 100;
3
3
  function L(e) {
4
4
  const o = { font: e.fontFamily, sizePx: e.fontSizePx };
@@ -339,7 +339,7 @@ function Y(e, o = {}, r = {}) {
339
339
  if (i && e.search(i).total === 0)
340
340
  return e.searchClear(), f(`text not found: ${i}`);
341
341
  if (!e.getSelection()) return f("no selection (pass 'find' or select_range first)");
342
- const { insertText: l } = await import("./editorApp-DvjFPHiy.js").then((m) => m.c);
342
+ const { insertText: l } = await import("./editorApp-mTD0YNv-.js").then((m) => m.c);
343
343
  return e.dispatch(l(t)), i && e.searchClear(), g("inserted");
344
344
  }
345
345
  }), a({
@@ -1,14 +1,14 @@
1
- function r(s, e) {
2
- const a = e > 0 ? s / e : 1;
3
- return { phase: "fonts", loaded: s, total: e, percent: 0.15 + (1 - 0.15) * a };
1
+ function i(a, e) {
2
+ const t = e > 0 ? a / e : 1;
3
+ return { phase: "fonts", loaded: a, total: e, percent: 0.15 + (1 - 0.15) * t };
4
4
  }
5
- class o {
5
+ class l {
6
6
  handle = null;
7
7
  ready;
8
8
  handlers = /* @__PURE__ */ new Map();
9
9
  constructor(e) {
10
- this.ready = new Promise((a) => {
11
- const t = {
10
+ this.ready = new Promise((t) => {
11
+ const r = {
12
12
  container: e.container,
13
13
  backendUrl: e.backendUrl,
14
14
  // `docId` is the canonical name; fall back to the deprecated `collabId`.
@@ -21,32 +21,58 @@ class o {
21
21
  knownUsers: e.knownUsers,
22
22
  resolveField: e.resolveField,
23
23
  agentTools: e.agentTools,
24
+ view: e.view,
24
25
  onLoadProgress: e.onLoadProgress,
25
26
  onReady: (n) => {
26
- this.handle = n, a(n);
27
+ this.handle = n, t(n);
27
28
  },
28
29
  onEvent: (n) => this.emit(n)
29
30
  };
30
- e.onLoadProgress?.({ phase: "bundle", percent: 0, loaded: 0, total: 0 }), import("./editorApp-DvjFPHiy.js").then((n) => n.e).then((n) => (e.onLoadProgress?.({ phase: "bundle", percent: 0.15, loaded: 0, total: 0 }), n.mountEditorApp(t)));
31
+ e.onLoadProgress?.({ phase: "bundle", percent: 0, loaded: 0, total: 0 }), import("./editorApp-mTD0YNv-.js").then((n) => n.e).then((n) => (e.onLoadProgress?.({ phase: "bundle", percent: 0.15, loaded: 0, total: 0 }), n.mountEditorApp(r)));
31
32
  });
32
33
  }
33
34
  /** Subscribe to a collaboration event. Returns an unsubscribe function. */
34
- on(e, a) {
35
- let t = this.handlers.get(e);
36
- return t || this.handlers.set(e, t = /* @__PURE__ */ new Set()), t.add(a), () => this.off(e, a);
35
+ on(e, t) {
36
+ let r = this.handlers.get(e);
37
+ return r || this.handlers.set(e, r = /* @__PURE__ */ new Set()), r.add(t), () => this.off(e, t);
37
38
  }
38
39
  /** Unsubscribe a handler previously passed to on(). */
39
- off(e, a) {
40
- this.handlers.get(e)?.delete(a);
40
+ off(e, t) {
41
+ this.handlers.get(e)?.delete(t);
41
42
  }
42
43
  emit(e) {
43
- const { type: a, ...t } = e;
44
- for (const n of this.handlers.get(a) ?? []) n(t);
44
+ const { type: t, ...r } = e;
45
+ for (const n of this.handlers.get(t) ?? []) n(r);
45
46
  }
46
47
  /** Resolves once the editor is mounted and ready. */
47
48
  whenReady() {
48
49
  return this.ready;
49
50
  }
51
+ /** Create a child document that shares this editor's live styles, fonts and
52
+ * theme. Use it to render a real, document-styled preview of a content slice
53
+ * (e.g. a style sample, a field result, or any blocks/fragment/OOXML) onto a
54
+ * canvas — instead of an HTML approximation — or to mount a canvas-native
55
+ * editor over a slice. Returned synchronously; render() calls before the editor
56
+ * is ready are buffered and flush on ready. (mountEditor() requires the editor
57
+ * to be ready — await whenReady() first.) */
58
+ createChild() {
59
+ let e = null, t = null, r = !1;
60
+ return this.ready.then((n) => {
61
+ r || (e = n.createChild(), t?.(), t = null);
62
+ }), {
63
+ render: (n, s, o) => {
64
+ const d = () => e?.render(n, s, o);
65
+ e ? d() : t = d;
66
+ },
67
+ mountEditor: (n, s, o) => {
68
+ if (!e) throw new Error("WordCanvas.createChild(): await whenReady() before mountEditor()");
69
+ return e.mountEditor(n, s, o);
70
+ },
71
+ destroy: () => {
72
+ r = !0, e?.destroy(), e = null;
73
+ }
74
+ };
75
+ }
50
76
  /** Open a .docx. When online, auto-publishes it and surfaces a share link. */
51
77
  async openDocx(e) {
52
78
  return (await this.ready).openDocx(e);
@@ -100,14 +126,14 @@ class o {
100
126
  /** Add a comment thread anchored to the current selection (a rich-text body;
101
127
  * `mentions` are @-tagged users). Resolves to the thread id, or null if
102
128
  * there's no selection. */
103
- async addComment(e, a) {
104
- return (await this.ready).addComment(e, a);
129
+ async addComment(e, t) {
130
+ return (await this.ready).addComment(e, t);
105
131
  }
106
- async replyToComment(e, a, t) {
107
- (await this.ready).replyToComment(e, a, t);
132
+ async replyToComment(e, t, r) {
133
+ (await this.ready).replyToComment(e, t, r);
108
134
  }
109
- async resolveThread(e, a = !0) {
110
- (await this.ready).resolveThread(e, a);
135
+ async resolveThread(e, t = !0) {
136
+ (await this.ready).resolveThread(e, t);
111
137
  }
112
138
  getDocId() {
113
139
  return this.handle?.getDocId() ?? null;
@@ -120,6 +146,6 @@ class o {
120
146
  }
121
147
  }
122
148
  export {
123
- o as W,
124
- r as f
149
+ l as W,
150
+ i as f
125
151
  };
@@ -1,4 +1,4 @@
1
- import { W as r } from "./wordcanvas-BAxBeErX.js";
1
+ import { W as r } from "./wordcanvas-D5DI9ZR1.js";
2
2
  export {
3
3
  r as WordCanvas
4
4
  };