@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.
- package/README.md +48 -1
- package/dist-lib/assets/{worker-BsOsK39A.js → worker-4HYrkNrG.js} +12276 -11981
- package/dist-lib/assets/worker-CJpwUzKh.js +2403 -0
- package/dist-lib/blockFactory-B_CLnkUh.js +106 -0
- package/dist-lib/browser-p_rkUcqE.js +1339 -0
- package/dist-lib/builder.js +365 -109
- package/dist-lib/editorApp-mTD0YNv-.js +9863 -0
- package/dist-lib/export.js +4670 -4567
- package/dist-lib/generate-toc.js +5 -5
- package/dist-lib/import.js +4 -1538
- package/dist-lib/{lists-BegzmTmD.js → lists-Sc5I40JO.js} +2 -2
- package/dist-lib/measure.js +2 -2
- package/dist-lib/{measureHost-CMiJKdlk.js → measureHost-B2aKX7lF.js} +1 -1
- package/dist-lib/metrics-BUMIC9Mv.js +164 -0
- package/dist-lib/pipeline-DD0nxAYM.js +1850 -0
- package/dist-lib/recalc-docx.js +2 -2
- package/dist-lib/recalcToc-CFCGCgij.js +3985 -0
- package/dist-lib/styleProps-DhqDEfvc.js +149 -0
- package/dist-lib/stylesheet-B6oczA-L.js +141 -0
- package/dist-lib/toc-Dj57zdz-.js +213 -0
- package/dist-lib/{webmcp-B7Gvd58E.js → webmcp-CXghUon_.js} +2 -2
- package/dist-lib/{wordcanvas-BAxBeErX.js → wordcanvas-D5DI9ZR1.js} +49 -23
- package/dist-lib/wordcanvas.js +1 -1
- package/dist-node/{chunk-GXFDF7UY.js → chunk-57L5XMCL.js} +327 -59
- package/dist-node/chunk-57L5XMCL.js.map +7 -0
- package/dist-node/{chunk-TBSXA2I4.js → chunk-EGSAVPCC.js} +1 -1
- package/dist-node/chunk-EGSAVPCC.js.map +7 -0
- package/dist-node/{chunk-4PDVRJF6.js → chunk-EMY2P524.js} +32 -2
- package/dist-node/chunk-EMY2P524.js.map +7 -0
- package/dist-node/{chunk-2RCPB7UZ.js → chunk-KJV7GJ3H.js} +1 -1
- package/dist-node/chunk-KJV7GJ3H.js.map +7 -0
- package/dist-node/{chunk-XDUDPPJW.js → chunk-PIMVQULL.js} +93 -24
- package/dist-node/chunk-PIMVQULL.js.map +7 -0
- package/dist-node/{chunk-BRAPV465.js → chunk-SA26UVIJ.js} +2 -2
- package/dist-node/{chunk-IJLL6IFJ.js → chunk-T3253N22.js} +202 -13
- package/dist-node/{chunk-IJLL6IFJ.js.map → chunk-T3253N22.js.map} +2 -2
- package/dist-node/{chunk-4ICCHZX4.js → chunk-U27EBKBG.js} +37 -1
- package/dist-node/chunk-U27EBKBG.js.map +7 -0
- package/dist-node/{engine-FRCX7PXF.js → engine-5F7DUU4W.js} +4 -4
- package/dist-node/export.js +178 -52
- package/dist-node/export.js.map +2 -2
- package/dist-node/generate-toc.js +7 -7
- package/dist-node/import.js +3 -3
- package/dist-node/measure.js +2 -2
- package/dist-node/recalc-docx.js +5 -5
- package/dist-node/recalc-docx.js.map +1 -1
- package/package.json +1 -1
- package/types/model.d.ts +277 -225
- package/types/recalc-docx.d.ts +27 -27
- package/types/wordcanvas.d.ts +212 -157
- package/dist-lib/assets/worker-BbFAIxdy.js +0 -2163
- package/dist-lib/blockFactory-Bcy0U40y.js +0 -178
- package/dist-lib/browser-5Sv4CuNy.js +0 -1284
- package/dist-lib/editorApp-DvjFPHiy.js +0 -7582
- package/dist-lib/metrics-CkAo4zh8.js +0 -143
- package/dist-lib/recalcToc-uaLWt59L.js +0 -3835
- package/dist-lib/styleProps-Db5pEkG8.js +0 -127
- package/dist-lib/toc-CZel_Kk3.js +0 -127
- package/dist-node/chunk-2RCPB7UZ.js.map +0 -7
- package/dist-node/chunk-4ICCHZX4.js.map +0 -7
- package/dist-node/chunk-4PDVRJF6.js.map +0 -7
- package/dist-node/chunk-GXFDF7UY.js.map +0 -7
- package/dist-node/chunk-TBSXA2I4.js.map +0 -7
- package/dist-node/chunk-XDUDPPJW.js.map +0 -7
- /package/dist-node/{chunk-BRAPV465.js.map → chunk-SA26UVIJ.js.map} +0 -0
- /package/dist-node/{engine-FRCX7PXF.js.map → engine-5F7DUU4W.js.map} +0 -0
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
const l = (i) => Number.isFinite(i) ? i : 0, s = (i) => Math.round(l(i) * 15), f = (i) => Math.round(l(i) * 1.5), x = (i) => Math.round(l(i) * 9525), P = (i) => Math.max(2, Math.round(l(i) * 6)), h = (i) => Math.round(l(i) * 240), w = {
|
|
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
|
-
}, c = { left: "left", center: "center", right: "right", justify: "both" }, p = { left: "left", center: "center", right: "right", decimal: "decimal" }, u = { dot: "dot", dash: "hyphen", underscore: "underscore" }, d = (i) => i.replace(/^#/, "").toLowerCase();
|
|
19
|
-
function g(i) {
|
|
20
|
-
return i.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
21
|
-
}
|
|
22
|
-
function m(i) {
|
|
23
|
-
return g(i).replace(/"/g, """);
|
|
24
|
-
}
|
|
25
|
-
function v(i) {
|
|
26
|
-
if (!i) return "";
|
|
27
|
-
let n = "";
|
|
28
|
-
for (const [e, o] of Object.entries(i))
|
|
29
|
-
o === void 0 || o === !1 || (n += ` ${e}="${m(String(o))}"`);
|
|
30
|
-
return n;
|
|
31
|
-
}
|
|
32
|
-
function t(i, n, e) {
|
|
33
|
-
const o = v(n);
|
|
34
|
-
return e === void 0 || e === "" ? `<${i}${o}/>` : `<${i}${o}>${e}</${i}>`;
|
|
35
|
-
}
|
|
36
|
-
function b(i) {
|
|
37
|
-
const n = /^\s|\s$|\s\s/.test(i) || i.includes(" ");
|
|
38
|
-
return t("w:t", n ? { "xml:space": "preserve" } : void 0, g(i));
|
|
39
|
-
}
|
|
40
|
-
const L = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
41
|
-
`, k = {
|
|
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 A(i) {
|
|
51
|
-
const n = (i.fontFamily.split(",")[0] ?? "").trim(), e = [];
|
|
52
|
-
if (n && e.push(t("w:rFonts", { "w:ascii": n, "w:hAnsi": n, "w:cs": n })), e.push(t("w:b", { "w:val": i.bold ? "1" : "0" })), e.push(t("w:i", { "w:val": i.italic ? "1" : "0" })), i.strikethrough && e.push(t("w:strike", { "w:val": "1" })), i.hidden && e.push(t("w:vanish", { "w:val": "1" })), e.push(t("w:color", { "w:val": d(i.color) })), e.push(t("w:sz", { "w:val": f(i.fontSizePx) })), e.push(t("w:szCs", { "w:val": f(i.fontSizePx) })), e.push(t("w:u", { "w:val": i.underline ? "single" : "none" })), i.letterSpacingPx !== void 0 && e.push(t("w:spacing", { "w:val": s(i.letterSpacingPx) })), i.highlightColor) {
|
|
53
|
-
const o = w[i.highlightColor.toLowerCase()];
|
|
54
|
-
o && e.push(t("w:highlight", { "w:val": o }));
|
|
55
|
-
}
|
|
56
|
-
return i.verticalAlign && e.push(t("w:vertAlign", { "w:val": i.verticalAlign === "super" ? "superscript" : "subscript" })), t("w:rPr", void 0, e.join(""));
|
|
57
|
-
}
|
|
58
|
-
function F(i) {
|
|
59
|
-
const n = [];
|
|
60
|
-
n.push(t("w:spacing", {
|
|
61
|
-
"w:before": s(i.spaceBeforePx),
|
|
62
|
-
"w:after": s(i.spaceAfterPx),
|
|
63
|
-
"w:line": h(i.lineHeight),
|
|
64
|
-
"w:lineRule": "auto"
|
|
65
|
-
}));
|
|
66
|
-
const e = {};
|
|
67
|
-
if (i.indentLeftPx && (e["w:left"] = s(i.indentLeftPx)), i.indentRightPx && (e["w:right"] = s(i.indentRightPx)), i.indentFirstLinePx > 0 ? e["w:firstLine"] = s(i.indentFirstLinePx) : i.indentFirstLinePx < 0 && (e["w:hanging"] = s(-i.indentFirstLinePx)), Object.keys(e).length > 0 && n.push(t("w:ind", e)), n.push(t("w:jc", { "w:val": c[i.align] })), i.tabStops && i.tabStops.length > 0) {
|
|
68
|
-
const o = i.tabStops.map(
|
|
69
|
-
(r) => t("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" ? u[r.leader] : void 0
|
|
73
|
-
})
|
|
74
|
-
).join("");
|
|
75
|
-
n.push(t("w:tabs", void 0, o));
|
|
76
|
-
}
|
|
77
|
-
return n.join("");
|
|
78
|
-
}
|
|
79
|
-
function C(i) {
|
|
80
|
-
const n = [];
|
|
81
|
-
if (i.fontFamily) {
|
|
82
|
-
const e = (i.fontFamily.split(",")[0] ?? "").trim();
|
|
83
|
-
e && n.push(t("w:rFonts", { "w:ascii": e, "w:hAnsi": e, "w:cs": e }));
|
|
84
|
-
}
|
|
85
|
-
if (i.bold !== void 0 && n.push(t("w:b", { "w:val": i.bold ? "1" : "0" })), i.italic !== void 0 && n.push(t("w:i", { "w:val": i.italic ? "1" : "0" })), i.strikethrough !== void 0 && n.push(t("w:strike", { "w:val": i.strikethrough ? "1" : "0" })), i.color && n.push(t("w:color", { "w:val": d(i.color) })), i.fontSizePx !== void 0) {
|
|
86
|
-
const e = Math.round(i.fontSizePx * 1.5);
|
|
87
|
-
n.push(t("w:sz", { "w:val": e })), n.push(t("w:szCs", { "w:val": e }));
|
|
88
|
-
}
|
|
89
|
-
if (i.underline !== void 0 && n.push(t("w:u", { "w:val": i.underline ? "single" : "none" })), i.highlightColor) {
|
|
90
|
-
const e = w[i.highlightColor.toLowerCase()];
|
|
91
|
-
e && n.push(t("w:highlight", { "w:val": e }));
|
|
92
|
-
}
|
|
93
|
-
return i.verticalAlign && n.push(t("w:vertAlign", { "w:val": i.verticalAlign === "super" ? "superscript" : "subscript" })), n.length > 0 ? t("w:rPr", void 0, n.join("")) : "";
|
|
94
|
-
}
|
|
95
|
-
function S(i) {
|
|
96
|
-
const n = [];
|
|
97
|
-
i.align && n.push(t("w:jc", { "w:val": c[i.align] ?? "left" }));
|
|
98
|
-
const e = {};
|
|
99
|
-
i.spaceBeforePx !== void 0 && (e["w:before"] = s(i.spaceBeforePx)), i.spaceAfterPx !== void 0 && (e["w:after"] = s(i.spaceAfterPx)), i.lineHeight !== void 0 && (e["w:line"] = h(i.lineHeight), e["w:lineRule"] = "auto"), Object.keys(e).length > 0 && n.push(t("w:spacing", e));
|
|
100
|
-
const o = {};
|
|
101
|
-
if (i.indentLeftPx !== void 0 && (o["w:left"] = s(i.indentLeftPx)), i.indentRightPx !== void 0 && (o["w:right"] = s(i.indentRightPx)), i.indentFirstLinePx !== void 0 && (i.indentFirstLinePx >= 0 ? o["w:firstLine"] = s(i.indentFirstLinePx) : o["w:hanging"] = s(-i.indentFirstLinePx)), Object.keys(o).length > 0 && n.push(t("w:ind", o)), i.keepWithNext && n.push(t("w:keepNext")), i.keepLinesTogether && n.push(t("w:keepLines")), i.tabStops && i.tabStops.length > 0) {
|
|
102
|
-
const r = i.tabStops.map(
|
|
103
|
-
(a) => t("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" ? u[a.leader] : void 0
|
|
107
|
-
})
|
|
108
|
-
).join("");
|
|
109
|
-
n.push(t("w:tabs", void 0, r));
|
|
110
|
-
}
|
|
111
|
-
return n.length > 0 ? t("w:pPr", void 0, n.join("")) : "";
|
|
112
|
-
}
|
|
113
|
-
export {
|
|
114
|
-
k as W,
|
|
115
|
-
L as X,
|
|
116
|
-
g as a,
|
|
117
|
-
F as b,
|
|
118
|
-
x as c,
|
|
119
|
-
P as d,
|
|
120
|
-
t as e,
|
|
121
|
-
C as f,
|
|
122
|
-
S as g,
|
|
123
|
-
d as h,
|
|
124
|
-
s as p,
|
|
125
|
-
A as r,
|
|
126
|
-
b as t
|
|
127
|
-
};
|
package/dist-lib/toc-CZel_Kk3.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { t as h, r as g, y as b } from "./browser-5Sv4CuNy.js";
|
|
2
|
-
const m = (t) => {
|
|
3
|
-
if (!t) return;
|
|
4
|
-
const e = t.match(/^(\d+)\s*-\s*(\d+)$/);
|
|
5
|
-
if (e) return { from: Number(e[1]), to: Number(e[2]) };
|
|
6
|
-
const o = t.match(/^\d+$/) ? Number(t) : NaN;
|
|
7
|
-
return Number.isNaN(o) ? void 0 : { from: o, to: o };
|
|
8
|
-
};
|
|
9
|
-
function x(t) {
|
|
10
|
-
const e = {
|
|
11
|
-
useOutlineLevels: /\\u\b/.test(t),
|
|
12
|
-
hyperlinks: /\\h\b/.test(t),
|
|
13
|
-
hideInWeb: /\\z\b/.test(t)
|
|
14
|
-
}, o = m(t.match(/\\o\s+"([^"]+)"/)?.[1]);
|
|
15
|
-
o && (e.outlineRange = o);
|
|
16
|
-
const s = m(t.match(/\\n\s+"?([0-9-]+)"?/)?.[1]);
|
|
17
|
-
s && (e.hidePageNumberRange = s);
|
|
18
|
-
const n = t.match(/\\p\s+"([^"]*)"/)?.[1];
|
|
19
|
-
n !== void 0 && (e.separator = n);
|
|
20
|
-
const a = t.match(/\\t\s+"([^"]+)"/)?.[1];
|
|
21
|
-
if (a) {
|
|
22
|
-
const i = a.split(","), r = {};
|
|
23
|
-
for (let l = 0; l + 1 < i.length; l += 2) {
|
|
24
|
-
const c = i[l].trim(), u = Number(i[l + 1].trim());
|
|
25
|
-
c && u >= 1 && (r[c] = u);
|
|
26
|
-
}
|
|
27
|
-
Object.keys(r).length > 0 && (e.customStyles = r);
|
|
28
|
-
}
|
|
29
|
-
return e;
|
|
30
|
-
}
|
|
31
|
-
const P = (t, e) => !!t && e >= t.from && e <= t.to;
|
|
32
|
-
function d(t, e) {
|
|
33
|
-
if (!e || !t.stylesheet) return;
|
|
34
|
-
const o = new Map(t.stylesheet.styles.map((a) => [a.id, a]));
|
|
35
|
-
let s = o.get(e);
|
|
36
|
-
const n = /* @__PURE__ */ new Set();
|
|
37
|
-
for (; s && !n.has(s.id); ) {
|
|
38
|
-
if (s.name && /(?:^|\s)heading\s*\d/i.test(s.name)) return s.name;
|
|
39
|
-
n.add(s.id), s = s.basedOn ? o.get(s.basedOn) : void 0;
|
|
40
|
-
}
|
|
41
|
-
return o.get(e)?.name;
|
|
42
|
-
}
|
|
43
|
-
function y(t, e, o) {
|
|
44
|
-
const s = t.style.namedStyle;
|
|
45
|
-
if (o?.customStyles && s) {
|
|
46
|
-
const i = o.customStyles[s] ?? o.customStyles[d(e, s) ?? ""];
|
|
47
|
-
if (i) return i;
|
|
48
|
-
}
|
|
49
|
-
if (t.style.outlineLevel !== void 0) return t.style.outlineLevel + 1;
|
|
50
|
-
const n = s?.match(/^heading\s*(\d)$/i);
|
|
51
|
-
if (n) return Number(n[1]);
|
|
52
|
-
const a = d(e, s)?.match(/(?:^|\s)heading\s*(\d)/i);
|
|
53
|
-
return a ? Number(a[1]) : null;
|
|
54
|
-
}
|
|
55
|
-
function S(t, e, o = 3) {
|
|
56
|
-
const s = e?.outlineRange?.to ?? o, n = [];
|
|
57
|
-
for (const a of b(t)) {
|
|
58
|
-
const i = y(a, t, e);
|
|
59
|
-
i === null || i < 1 || i > s || e?.outlineRange && (i < e.outlineRange.from || i > e.outlineRange.to) || n.push({ block: a, level: i });
|
|
60
|
-
}
|
|
61
|
-
return n;
|
|
62
|
-
}
|
|
63
|
-
function k(t, e = 20) {
|
|
64
|
-
if (!t.bookmarks) return 0;
|
|
65
|
-
const o = t.section.pageWidthPx - t.section.marginPx.left - t.section.marginPx.right;
|
|
66
|
-
let s = 0;
|
|
67
|
-
for (const n of t.blocks) {
|
|
68
|
-
if (n.kind !== "paragraph" || n.style.tocEntry) continue;
|
|
69
|
-
const a = n.runs.find((u) => u.style.link?.startsWith("#"))?.style.link?.slice(1);
|
|
70
|
-
if (!a) continue;
|
|
71
|
-
const i = t.bookmarks[a]?.start.blockId;
|
|
72
|
-
if (!i) continue;
|
|
73
|
-
const r = h(n.runs), l = r.match(/\t\d+\s*$/);
|
|
74
|
-
if (!l) continue;
|
|
75
|
-
n.runs = g(n.runs, 0, r.length - l[0].length), n.runs.length === 0 && (n.runs = [{ text: "", style: { ...f } }]);
|
|
76
|
-
const c = Math.min(9, Math.max(1, Math.round((n.style.indentLeftPx || 0) / e) + 1));
|
|
77
|
-
n.style.tocEntry = { targetId: i, level: c }, !n.style.tabStops?.length && o > 0 && (n.style.tabStops = [{ posPx: o, align: "right", leader: "dot" }]), n.revision++, s++;
|
|
78
|
-
}
|
|
79
|
-
return s;
|
|
80
|
-
}
|
|
81
|
-
const f = {
|
|
82
|
-
fontFamily: "Georgia, serif",
|
|
83
|
-
fontSizePx: 13,
|
|
84
|
-
bold: !1,
|
|
85
|
-
italic: !1,
|
|
86
|
-
underline: !1,
|
|
87
|
-
strikethrough: !1,
|
|
88
|
-
color: "#202124"
|
|
89
|
-
};
|
|
90
|
-
function N(t, e, o) {
|
|
91
|
-
const s = t.indentStepPx ?? 20, n = t.leader ?? "dot", i = { ...{ ...f, ...t.baseChar }, fontSizePx: e === 1 ? 14 : 13, bold: e === 1, ...t.levels?.[e]?.char }, r = {
|
|
92
|
-
align: "left",
|
|
93
|
-
lineHeight: 1.5,
|
|
94
|
-
spaceBeforePx: 0,
|
|
95
|
-
spaceAfterPx: 2,
|
|
96
|
-
indentFirstLinePx: 0,
|
|
97
|
-
indentLeftPx: (e - 1) * s,
|
|
98
|
-
...t.levels?.[e]?.para
|
|
99
|
-
};
|
|
100
|
-
return n !== "none" && o > 0 && (r.tabStops = [{ posPx: o, align: "right", leader: n }]), { char: i, para: r };
|
|
101
|
-
}
|
|
102
|
-
function v(t) {
|
|
103
|
-
if (t.title === null) return null;
|
|
104
|
-
const e = t.title ?? {}, o = { ...f, ...t.baseChar };
|
|
105
|
-
return {
|
|
106
|
-
text: e.text ?? "Table of Contents",
|
|
107
|
-
char: { ...o, fontSizePx: 20, bold: !0, ...e.char },
|
|
108
|
-
para: {
|
|
109
|
-
align: "left",
|
|
110
|
-
lineHeight: 1.4,
|
|
111
|
-
spaceBeforePx: 8,
|
|
112
|
-
spaceAfterPx: 12,
|
|
113
|
-
indentFirstLinePx: 0,
|
|
114
|
-
indentLeftPx: 0,
|
|
115
|
-
namedStyle: e.namedStyle ?? "tocTitle",
|
|
116
|
-
...e.para
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
export {
|
|
121
|
-
v as a,
|
|
122
|
-
S as d,
|
|
123
|
-
P as i,
|
|
124
|
-
k as m,
|
|
125
|
-
x as p,
|
|
126
|
-
N as t
|
|
127
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/import/docx/types.ts", "../../node_modules/txml/dist/txml.mjs", "../src/import/docx/xml.ts", "../src/import/docx/contentTypes.ts"],
|
|
4
|
-
"sourcesContent": ["// .docx import \u2014 shared types.\n//\n// The pipeline is: zip \u2192 XML parts \u2192 IR (intermediate representation) \u2192 model.\n// The IR is a faithful-but-minimal decode of document.xml: the parser keeps\n// everything it understands (even what the model can't hold yet); mapToModel\n// decides what survives and emits an ImportWarning for every lossy decision.\n\nimport type { Document, FieldDef } from \"@cw/shared\";\n\nexport type ImportPhase = \"unzip\" | \"styles\" | \"parse\" | \"map\";\n\nexport type ImportErrorCode = \"NOT_ZIP\" | \"ENCRYPTED\" | \"NO_DOCUMENT_PART\" | \"MALFORMED_XML\";\n\nexport class ImportError extends Error {\n readonly code: ImportErrorCode;\n constructor(code: ImportErrorCode, message: string) {\n super(message);\n this.name = \"ImportError\";\n this.code = code;\n }\n}\n\nexport interface ImportWarning {\n code: string;\n message: string;\n}\n\n/** Deduplicating warning collector \u2014 a 70-page doc with 400 tabs should say\n * \"tabs converted\" once, not 400 times. */\nexport class WarningSink {\n readonly list: ImportWarning[] = [];\n private readonly seen = new Set<string>();\n add(code: string, message: string): void {\n if (this.seen.has(code)) return;\n this.seen.add(code);\n this.list.push({ code, message });\n }\n}\n\nexport interface ImportResult {\n doc: Document;\n /** Every lossy mapping decision \u2014 surfaced, not swallowed. */\n warnings: ImportWarning[];\n /** blob: URLs created for embedded media; caller revokes when the doc is discarded. */\n mediaUrls: string[];\n /** Raw embedded image bytes, populated only when runImport is called with\n * { collectMediaBytes: true } \u2014 the Node/backend path, which content-addresses\n * them into its own media store instead of minting blob: URLs. Each `src`\n * matches the ImageBlock.src the mapper assigned, so the caller can swap in a\n * mediaId. Empty (and mediaUrls carry blob: URLs) in the browser path. */\n media: ImportMedia[];\n}\n\n/** A collected embedded image (Node/backend path). */\nexport interface ImportMedia {\n /** The synthetic src the mapper put on the ImageBlock (e.g. \"cw-media:0\"). */\n src: string;\n bytes: Uint8Array;\n mime: string;\n}\n\n/** Sink the media store routes raw image bytes to instead of creating a blob:\n * URL. Returns the src string to stamp on the ImageBlock. */\nexport interface MediaCollector {\n add(bytes: Uint8Array, mime: string): string;\n}\n\nexport interface RunImportOpts {\n onProgress?: (phase: ImportPhase, pct: number) => void;\n /** Collect raw image bytes (and skip blob: URL creation) for Node/backend\n * callers that content-address media themselves. */\n collectMediaBytes?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Worker protocol\n\nexport interface ToWorker {\n id: number;\n buf: ArrayBuffer; // transferred, not cloned\n}\n\nexport type FromWorker =\n | { id: number; type: \"progress\"; phase: ImportPhase; pct: number }\n | { id: number; type: \"done\"; result: ImportResult }\n | { id: number; type: \"error\"; code: ImportErrorCode; message: string };\n\n// ---------------------------------------------------------------------------\n// IR \u2014 what documentParser produces. Units stay as OOXML units (twips,\n// half-points); conversion to px happens in mapToModel via units.ts.\n\n/** Direct run formatting decoded from w:rPr. Absent field = \"inherit\" \u2014\n * resolved through the style cascade in milestone 2, from defaults today. */\nexport interface IRRunProps {\n /** w:rStyle reference \u2014 recorded now, resolved when StyleResolver lands. */\n styleId?: string;\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n strikethrough?: boolean;\n /** Raw w:color value: hex without '#' (\"FF0000\") or \"auto\". */\n color?: string;\n /** w:sz \u2014 half-points. */\n sizeHalfPoints?: number;\n /** w:rFonts w:ascii. */\n fontAscii?: string;\n /** w:rFonts w:asciiTheme \u2014 theme font slot (\"minorHAnsi\", \"majorHAnsi\", \u2026). */\n fontThemeAscii?: string;\n /** w:color w:themeColor \u2014 theme color slot (\"accent1\", \"text1\", \u2026). */\n colorTheme?: string;\n /** w:highlight w:val \u2014 named highlight color (\"yellow\", \"green\", \u2026). */\n highlight?: string;\n /** w:vertAlign w:val \u2014 \"superscript\" | \"subscript\" | \"baseline\". */\n vertAlign?: string;\n /** w:vanish \u2014 hidden text (Word shows it only with \u00B6 marks on). */\n vanish?: boolean;\n /** Hyperlink membership (set on runs inside a w:hyperlink). Resolved to a URL\n * in mapToModel: relId via the part's rels (external target), or anchor for\n * an in-document bookmark (kept as \"#name\"). */\n linkRelId?: string;\n linkAnchor?: string;\n /** w:footnoteReference w:id \u2014 this run is a footnote marker. mapToModel sets\n * the run text to the sequential note number and CharStyle.footnoteRef. */\n footnoteId?: string;\n}\n\n/** w:sdtPr \u2014 content-control properties, decoded faithfully (mapToModel turns\n * these into the model's SdtProps; runs inside the control carry the sdtId). */\nexport interface IRSdtProps {\n type: \"richText\" | \"plainText\" | \"checkbox\" | \"dropDown\" | \"comboBox\" | \"date\";\n alias?: string;\n tag?: string;\n /** w:showingPlcHdr \u2014 the content is currently the gray placeholder. */\n placeholder?: boolean;\n listItems?: { display: string; value: string }[];\n dateFormat?: string;\n checked?: boolean;\n lockContent?: boolean;\n lockControl?: boolean;\n}\n\nexport type IRInline =\n | { kind: \"run\"; text: string; props: IRRunProps; sdtId?: string }\n /** w:br / w:cr \u2014 soft line break (model has none; mapToModel splits the\n * paragraph). page=true for w:br w:type=\"page\" (\u2192 pageBreakBefore on the\n * follower); column=true for w:br w:type=\"column\" (\u2192 columnBreakBefore). */\n | { kind: \"break\"; page?: boolean; column?: boolean }\n /** w:drawing / w:pict \u2014 becomes a block-level ImageBlock (model has no inline images). */\n | {\n kind: \"image\";\n relId: string;\n widthEmu?: number;\n heightEmu?: number;\n anchored: boolean;\n /** For wp:anchor: square = text wraps around (maps to ImageBlock.wrap);\n * block = wrap mode the model can't express (none/topAndBottom). */\n anchorWrap?: \"square\" | \"block\";\n /** wp:positionH/wp:align when present. */\n anchorAlign?: \"left\" | \"right\" | \"center\";\n };\n\nexport interface IRParaProps {\n /** w:pStyle reference \u2014 recorded now, resolved when StyleResolver lands. */\n styleId?: string;\n align?: \"left\" | \"center\" | \"right\" | \"justify\";\n spaceBeforeTwips?: number;\n spaceAfterTwips?: number;\n /** Multiplier \u2014 only set when lineRule is \"auto\" (or absent). */\n lineHeight?: number;\n indentLeftTwips?: number;\n /** w:ind/@w:right|@w:end \u2014 right-edge indent. */\n indentRightTwips?: number;\n /** Negative = hanging indent (w:hanging). */\n indentFirstLineTwips?: number;\n /** w:keepNext \u2014 maps onto ParaStyle.keepWithNext. */\n keepWithNext?: boolean;\n /** w:keepLines \u2014 maps onto ParaStyle.keepLinesTogether. */\n keepLinesTogether?: boolean;\n /** w:pPr/w:tabs \u2014 raw tab stops (pos in twips; val/leader raw OOXML names). */\n tabStops?: { posTwips: number; val?: string; leader?: string }[];\n /** w:pageBreakBefore \u2014 this paragraph starts a new page. */\n pageBreakBefore?: boolean;\n /** w:outlineLvl \u2014 0-8. Heading styles set it; drives TOC `\\u`/heading detection. */\n outlineLevel?: number;\n /** w:numPr \u2014 list membership. numId \"0\" / null = explicitly NOT a list\n * (overrides an inherited list from the paragraph style). */\n list?: { numId: string; level: number } | null;\n /** w:pPr/w:sectPr \u2014 this paragraph ENDS a section. \"page\" (nextPage/odd/even)\n * implies the following content starts a new page; \"continuous\" doesn't. */\n sectionBreak?: \"page\" | \"continuous\";\n /** The ending section's page size (twips), when its w:sectPr declares pgSz.\n * A \"page\" break only forces a new page when this differs from the document's\n * page size \u2014 geometry-preserving breaks (footer/header switches, which these\n * generated reports emit by the dozen) flow instead of leaving half-empty\n * pages, matching Word. */\n sectionPgSize?: { w: number; h: number };\n /** The ending section's margins (twips) \u2014 for a SectionPatch when geometry differs. */\n sectionMarginTwips?: { top: number; right: number; bottom: number; left: number };\n /** The ending section's newspaper columns (count > 1). */\n sectionColumns?: { count: number; spaceTwips?: number };\n /** The ending section's w:pgNumType w:start (page-number restart). */\n sectionPageNumberStart?: number;\n /** The ending section's sectPr declares its own header/footer references \u2014\n * when such a section is flowed (not page-broken) its bands aren't applied. */\n sectionHasBands?: boolean;\n /** w:pPr/w:rPr \u2014 the paragraph MARK's run formatting. Word styles empty\n * paragraphs (and the \u00B6 itself) with this; we use it for empty-run style. */\n markRunProps?: IRRunProps;\n}\n\n/** A w:bookmarkStart / w:bookmarkEnd seen while walking a paragraph: its w:id\n * (pairs start\u2194end, possibly across paragraphs), w:name (start only), and the\n * UTF-16 offset within the paragraph text where it sits. */\nexport interface BookmarkMarker {\n id: string;\n name?: string;\n kind: \"start\" | \"end\";\n offset: number;\n}\n\nexport interface IRParagraph {\n kind: \"paragraph\";\n props: IRParaProps;\n inlines: IRInline[];\n /** w:bookmarkStart names anchored in this paragraph (TOC/cross-ref heuristics). */\n bookmarks?: string[];\n /** Start/end markers with offsets \u2014 resolved to model ranges in mapToModel. */\n bookmarkMarkers?: BookmarkMarker[];\n /** Custom-field result membership \u2014 mapped onto Block.fieldId. */\n fieldId?: string;\n}\n\n/** One raw border edge (w:top/w:left/\u2026 inside w:tblBorders or w:tcBorders).\n * Kept raw (OOXML units) until mapToModel collapses the cascade to px. */\nexport interface IRRawBorder {\n /** w:val \u2014 \"single\", \"double\", \"dashed\", \"nil\"/\"none\", \u2026 */\n val: string;\n /** w:sz \u2014 eighths of a point. */\n sizeEighthPt?: number;\n /** w:color \u2014 hex without '#', or \"auto\". */\n color?: string;\n}\n\nexport interface IRBorders {\n top?: IRRawBorder;\n left?: IRRawBorder;\n bottom?: IRRawBorder;\n right?: IRRawBorder;\n /** Interior horizontal/vertical edges (w:tblBorders only). */\n insideH?: IRRawBorder;\n insideV?: IRRawBorder;\n}\n\n/** Cell margins in twips, per side. Any side may be absent (inherits the next\n * level of the cascade: cell \u2192 table \u2192 Word default). w:tcMar / w:tblCellMar. */\nexport interface IRCellMargin {\n top?: number;\n right?: number;\n bottom?: number;\n left?: number;\n}\n\nexport interface IRTableCell {\n /** Full block content: paragraphs, images (inside paragraphs), nested tables. */\n blocks: IRBlock[];\n /** w:gridSpan \u2014 columns this cell covers (1 = normal). Maps to TableCell.colSpan. */\n gridSpan: number;\n /** w:vMerge continuation \u2014 this cell is swallowed by the cell above. */\n vMergeContinue: boolean;\n /** w:tcPr/w:tcBorders. */\n borders?: IRBorders;\n /** A w:tcBorders element is present \u2014 even if empty (all edges nil/absent), the\n * author explicitly chose this cell's borders, so it must NOT fall back to the\n * renderer's default grid. */\n bordersSpecified?: boolean;\n /** w:tcPr/w:shd \u2192 CSS fill. */\n shd?: string;\n /** w:tcPr/w:tcMar \u2014 per-side inner padding override (twips). */\n marginTwips?: IRCellMargin;\n}\n\nexport interface IRTableRow {\n cells: IRTableCell[];\n}\n\nexport interface IRTable {\n kind: \"table\";\n rows: IRTableRow[];\n /** w:tblGrid/w:gridCol widths \u2014 become TableBlock.colFractions. */\n colWidthsTwips?: number[];\n /** w:tblPr/w:tblStyle \u2014 table style id (its borders/shd are the cascade base). */\n styleId?: string;\n /** w:tblPr/w:tblBorders. */\n borders?: IRBorders;\n /** A w:tblBorders element is present \u2014 even if empty, the table explicitly\n * declares its borders (e.g. \"no borders\"), suppressing the default grid. */\n bordersSpecified?: boolean;\n /** w:tblPr/w:shd \u2192 CSS fill applied to every cell unless overridden. */\n shd?: string;\n /** w:tblPr/w:tblCellMar \u2014 table-wide cell-margin default (twips), the base each\n * cell's own w:tcMar overrides per side. */\n cellMarginTwips?: IRCellMargin;\n /** Custom-field result membership \u2014 mapped onto Block.fieldId. */\n fieldId?: string;\n}\n\nexport type IRBlock = IRParagraph | IRTable;\n\n// ---------------------------------------------------------------------------\n// Numbering (numbering.xml) \u2014 raw decode; mapToModel converts to model lists.\n\nexport interface IRListLevel {\n /** Raw w:numFmt w:val (\"decimal\", \"bullet\", \"lowerRoman\", \"none\", \u2026). */\n format: string;\n /** Raw w:lvlText w:val \u2014 \"%1.\" pattern, or the bullet glyph for bullets. */\n lvlText: string;\n start: number;\n indentLeftTwips?: number;\n hangingTwips?: number;\n /** w:lvl/w:rPr \u2014 marker glyph styling (esp. the bullet font). */\n markerRunProps?: IRRunProps;\n}\n\nexport interface IRListDefinition {\n /** numId (the id space paragraphs reference via w:numPr/w:numId). */\n id: string;\n levels: IRListLevel[];\n}\n\nexport interface IRSection {\n pageWidthTwips?: number;\n pageHeightTwips?: number;\n marginTwips?: { top: number; right: number; bottom: number; left: number };\n /** w:pgMar/@w:header and @w:footer \u2014 band distances from the page edges (twips). */\n headerDistTwips?: number;\n footerDistTwips?: number;\n /** w:headerReference / w:footerReference by type \u2014 r:id into the document\n * part's rels; the referenced parts are parsed separately. Variants are\n * gated downstream (first by w:titlePg, even by settings evenAndOdd). */\n headerRefs?: BandRefs;\n footerRefs?: BandRefs;\n /** w:titlePg \u2014 this section has a distinct first-page header/footer. */\n titlePg?: boolean;\n /** w:cols \u2014 newspaper columns (only count > 1 is meaningful). */\n columns?: { count: number; spaceTwips?: number };\n /** w:pgNumType w:start \u2014 restart page numbering at this value. */\n pageNumberStart?: number;\n}\n\n/** Header/footer relationship ids by Word variant. */\nexport interface BandRefs {\n default?: string;\n first?: string;\n even?: string;\n}\n\nexport interface IRDocument {\n blocks: IRBlock[];\n section: IRSection | null;\n /** Content controls found in the body (header/footer parsing extends it). */\n sdts: Record<string, IRSdtProps>;\n /** Custom (non-built-in) complex fields captured in the body, keyed by id. */\n fields?: Record<string, FieldDef>;\n}\n", "function t(t){return t.replace(/&(#x[0-9a-fA-F]+|#\\d+|amp|lt|gt|quot|apos);/g,function(t,r){if(\"amp\"===r)return\"&\";if(\"lt\"===r)return\"<\";if(\"gt\"===r)return\">\";if(\"quot\"===r)return'\"';if(\"apos\"===r)return\"'\";if(\"#\"===r[0]){var e=\"x\"===r[1]||\"X\"===r[1],a=parseInt(r.slice(e?2:1),e?16:10);if(!Number.isNaN(a)&&a>=0&&a<=1114111)try{return String.fromCodePoint(a)}catch(r){return t}}return t})}function r(t){return t.replace(/&/g,\"&\").replace(/</g,\"<\").replace(/>/g,\">\")}function e(t){return t.replace(/&/g,\"&\").replace(/</g,\"<\").replace(/>/g,\">\").replace(/\"/g,\""\").replace(/'/g,\"'\")}function a(r,e){var a=(e=e||{}).pos||0,i=!!e.keepComments,c=!!e.keepWhitespace,f=!!e.decodeEntities,s=\"<\".charCodeAt(0),u=\">\".charCodeAt(0),h=\"-\".charCodeAt(0),l=\"/\".charCodeAt(0),d=\"!\".charCodeAt(0),g=\"?\".charCodeAt(0),A=\"'\".charCodeAt(0),p='\"'.charCodeAt(0),C=\"=\".charCodeAt(0),v=\"[\".charCodeAt(0),y=\"]\".charCodeAt(0),m=\"?\".charCodeAt(0);function b(t){for(var e=[];r[a];)if(r.charCodeAt(a)==s){if(r.charCodeAt(a+1)===l){var n=a+2;if(a=r.indexOf(\">\",a),-1==r.substring(n,a).indexOf(t)){var o=r.substring(0,a).split(\"\\n\");throw new Error(\"Unexpected close tag\\nLine: \"+(o.length-1)+\"\\nColumn: \"+(o[o.length-1].length+1)+\"\\nChar: \"+r[a])}return a+1&&(a+=1),e}if(r.charCodeAt(a+1)===d){if(r.charCodeAt(a+2)==h){const t=a;for(;-1!==a&&(r.charCodeAt(a)!==u||r.charCodeAt(a-1)!=h||r.charCodeAt(a-2)!=h||-1==a);)a=r.indexOf(\">\",a+1);-1===a&&(a=r.length),i&&e.push(r.substring(t,a+1))}else{if(r.charCodeAt(a+2)===v&&r.charCodeAt(a+8)===v&&\"cdata\"===r.substr(a+3,5).toLowerCase()){var f=r.indexOf(\"]]>\",a);-1==f?(e.push(r.substr(a+9)),a=r.length):(e.push(r.substring(a+9,f)),a=f+3);continue}{const t=a+1;a+=2;for(var g=!1;(r.charCodeAt(a)!==u||!0===g)&&r[a];)r.charCodeAt(a)===v?g=!0:!0===g&&r.charCodeAt(a)===y&&(g=!1),a++;e.push(r.substring(t,a))}}a++;continue}var A=k();e.push(A)}else{var p=N();if(c)p.length>0&&e.push(p);else{var C=p.trim();C.length>0&&e.push(C)}a++}return e}function N(){var e=a;-2===(a=r.indexOf(\"<\",a)-1)&&(a=r.length);var n=r.slice(e,a+1);return f?t(n):n}var x=\"\\r\\n\\t>/= \";function O(){for(var t=a;-1===x.indexOf(r[a])&&r[a];)a++;return r.slice(t,a)}var j,E=e.selfClosingTags||e.noChildNodes||[\"img\",\"br\",\"input\",\"meta\",\"link\",\"hr\"];function k(){a++;const e=O(),n=\"?\"===e[0],i=a,o={};let c=[];for(;r[a]&&r.charCodeAt(a)!==u&&(!n||r.charCodeAt(a)!==g||r.charCodeAt(a+1)!==u);){var s=r.charCodeAt(a);if(s>64&&s<91||s>96&&s<123){for(var h=O(),d=null;32===r.charCodeAt(a)||9===r.charCodeAt(a)||10===r.charCodeAt(a)||13===r.charCodeAt(a);)a++;if(r.charCodeAt(a)===C){for(a++;32===r.charCodeAt(a)||9===r.charCodeAt(a)||10===r.charCodeAt(a)||13===r.charCodeAt(a);)a++;var v=r.charCodeAt(a);if(v===A||v===p){if(d=w(),-1===a)return{tagName:e,attributes:o,children:c}}else if(v&&v!==u){for(var y=a;r[a]&&-1===x.indexOf(r[a]);)a++;d=r.slice(y,a),f&&(d=t(d))}}o[h]=d}else a++}if(n){var N=r.slice(i,a).trim();return N.length>0&&0===Object.keys(o).length&&(c=[N]),r.charCodeAt(a)===g&&r.charCodeAt(a+1)===u?a+=2:r.charCodeAt(a)===u&&(a+=1),{tagName:e,attributes:o,children:c}}if(r.charCodeAt(a-1)!==l&&r.charCodeAt(a-1)!==m)if(\"script\"==e){var j=a+1;a=r.indexOf(\"<\\/script>\",a),c=[r.slice(j,a)],a+=9}else if(\"style\"==e){j=a+1;a=r.indexOf(\"</style>\",a),c=[r.slice(j,a)],a+=8}else-1===E.indexOf(e)?(a++,c=b(e)):a++;else a++;return{tagName:e,attributes:o,children:c}}function w(){var e=r[a],n=a+1;a=r.indexOf(e,n);var i=r.slice(n,a);return f?t(i):i}function V(){if(!e||!e.attrName||!e.attrValue)return-1;var t=new RegExp(\"\\\\s\"+e.attrName+\"\\\\s*=['\\\"]\"+e.attrValue+\"['\\\"]\").exec(r);return t?t.index:-1}if(void 0!==e.attrValue)for(e.attrName=e.attrName||\"id\",j=[];-1!==(a=V());)-1!==(a=r.lastIndexOf(\"<\",a))&&j.push(k()),r=r.substr(a),a=0;else j=e.parseNode?k():b(\"\");if(e.filter&&Array.isArray(j)&&(j=o(j,e.filter)),e.simplify){return n(Array.isArray(j)?j:[j])}return e.setPos&&\"object\"==typeof j&&!Array.isArray(j)&&(j.pos=a),j}function n(t){if(\"string\"==typeof t)return n(a(t));if(!Array.isArray(t))throw new TypeError(\"simplify() expects parsed node array or XML string\");var r={};if(!t.length)return\"\";if(1===t.length&&\"string\"==typeof t[0])return t[0];for(var e in t.forEach(function(t){if(\"object\"==typeof t){r[t.tagName]||(r[t.tagName]=[]);var e=n(t.children);r[t.tagName].push(e),Object.keys(t.attributes).length&&\"object\"==typeof e&&!Array.isArray(e)&&(e._attributes=t.attributes)}}),r)1==r[e].length&&(r[e]=r[e][0]);return r}function i(t,r={}){var e={};return t.length?1===t.length&&\"string\"==typeof t[0]?Object.keys(r).length?{_attributes:r,value:t[0]}:t[0]:(t.forEach(function(t){if(\"object\"==typeof t){e[t.tagName]||(e[t.tagName]=[]);var r=i(t.children||[],t.attributes);e[t.tagName].push(r),Object.keys(t.attributes).length&&\"object\"==typeof r&&!Array.isArray(r)&&(r._attributes=t.attributes)}}),e):e}function o(t,r,e=0,a=\"\"){var n=[];return t.forEach(function(t,i){if(\"object\"==typeof t&&r(t,i,e,a)&&n.push(t),\"object\"==typeof t&&t.children){var c=o(t.children,r,e+1,(a?a+\".\":\"\")+i+\".\"+t.tagName);n=n.concat(c)}}),n}function c(t,a){if(!t)return\"\";var n=!!(a=a||{}).encodeEntities,i=\"\";function o(t){if(t)for(var e=0;e<t.length;e++){var a=t[e];if(\"string\"==typeof a){var o=a.trim();i+=n?r(o):o}else a&&c(a)}}function c(t){if(t){for(var r in i+=\"<\"+t.tagName,t.attributes){var a=t.attributes[r];null===a?i+=\" \"+r:n?i+=\" \"+r+'=\"'+e(a.trim())+'\"':-1===a.indexOf('\"')?i+=\" \"+r+'=\"'+a.trim()+'\"':i+=\" \"+r+\"='\"+a.trim()+\"'\"}if(\"?\"!==t.tagName[0])i+=\">\",o(t.children),i+=\"</\"+t.tagName+\">\";else{if(t.children&&t.children.length){var c=t.children.filter(function(t){return\"string\"==typeof t}).join(\" \").trim();c.length>0&&(i+=\" \"+c)}i+=\"?>\"}}}return o(Array.isArray(t)?t:[t]),i}function f(t){if(Array.isArray(t)){var r=\"\";return t.forEach(function(t){r=(r+=\" \"+f(t)).trim()}),r}return\"object\"==typeof t&&null!==t?f(t.children):\" \"+t}function s(t,r,e){var i=a(t,{attrValue:r});return e?n(i):i[0]}function u(t,r,e){const i=a(t,{attrName:\"class\",attrValue:\"[a-zA-Z0-9- ]*\"+r+\"[a-zA-Z0-9- ]*\"});return e?n(i):i}function h(t){return\"string\"==typeof t}function l(t){return\"object\"==typeof t&&null!==t&&\"tagName\"in t}export{o as filter,s as getElementById,u as getElementsByClassName,l as isElementNode,h as isTextNode,a as parse,n as simplify,i as simplifyLostLess,c as stringify,f as toContentString};\n", "// txml helpers. DOMParser is window-only (not available in workers), so we use\n// txml \u2014 a tiny pure-JS parser that returns an ORDERED node tree. Order matters:\n// in document.xml, run order IS the text.\n//\n// OOXML namespace handling: prefixes (w:, a:, wp:) are technically remappable,\n// but Word always emits the conventional ones, so we match qualified names\n// directly \u2014 the same pragmatic choice docx-preview and mammoth make.\n\nimport { isElementNode, parse, type TNode } from \"txml/txml\";\nimport { ImportError } from \"./types\";\n\nexport type XmlNode = TNode;\n\n/** Parse an XML part. keepWhitespace matters: a run whose text is a single\n * space (`<w:t xml:space=\"preserve\"> </w:t>`) must not be dropped. */\nexport function parseXml(text: string, partName: string): XmlNode[] {\n try {\n return parse(text, { keepWhitespace: true, decodeEntities: true }).filter(isElementNode);\n } catch (e) {\n throw new ImportError(\n \"MALFORMED_XML\",\n `Failed to parse ${partName}: ${e instanceof Error ? e.message : String(e)}`,\n );\n }\n}\n\n/** Top-level element by qualified name (skips the XML declaration / PIs). */\nexport function rootEl(nodes: XmlNode[], tagName: string): XmlNode | undefined {\n return nodes.find((n) => n.tagName === tagName);\n}\n\n/** Element children only (text nodes filtered out). */\nexport function children(node: XmlNode): XmlNode[] {\n return node.children.filter(isElementNode);\n}\n\n/** First child element with the given qualified name. */\nexport function el(node: XmlNode, tagName: string): XmlNode | undefined {\n return node.children.find((c): c is XmlNode => isElementNode(c) && c.tagName === tagName);\n}\n\n/** All child elements with the given qualified name. */\nexport function els(node: XmlNode, tagName: string): XmlNode[] {\n return node.children.filter((c): c is XmlNode => isElementNode(c) && c.tagName === tagName);\n}\n\n/** Attribute value by qualified name; valueless attributes read as \"\". */\nexport function attr(node: XmlNode, name: string): string | undefined {\n const v = node.attributes[name];\n return v === undefined ? undefined : (v ?? \"\");\n}\n\n/** Depth-first search for a descendant element. Used where the exact nesting\n * is deep and producer-dependent (e.g. a:blip inside w:drawing). */\nexport function findDeep(node: XmlNode, tagName: string): XmlNode | undefined {\n for (const c of node.children) {\n if (!isElementNode(c)) continue;\n if (c.tagName === tagName) return c;\n const found = findDeep(c, tagName);\n if (found) return found;\n }\n return undefined;\n}\n\n/** Concatenated text content (direct string children \u2014 w:t never nests). */\nexport function textOf(node: XmlNode): string {\n let out = \"\";\n for (const c of node.children) if (typeof c === \"string\") out += c;\n return out;\n}\n\n/** Shorthand for the ubiquitous `<w:x w:val=\"\u2026\"/>` child-element pattern. */\nexport function val(node: XmlNode, tagName: string): string | undefined {\n const child = el(node, tagName);\n return child ? attr(child, \"w:val\") : undefined;\n}\n\n/** OOXML on/off property: `<w:b/>` is on; w:val of 0/false/none/off is off. */\nexport function onOff(node: XmlNode | undefined): boolean | undefined {\n if (!node) return undefined;\n const v = attr(node, \"w:val\");\n if (v === undefined) return true;\n return ![\"0\", \"false\", \"none\", \"off\"].includes(v);\n}\n\n/** Numeric attribute (OOXML writes plain decimal integers). */\nexport function numAttr(node: XmlNode | undefined, name: string): number | undefined {\n if (!node) return undefined;\n const v = attr(node, name);\n if (v === undefined) return undefined;\n const n = Number(v);\n return Number.isFinite(n) ? n : undefined;\n}\n", "// [Content_Types].xml \u2192 locate the main document part. Usually\n// \"word/document.xml\", but the spec allows any part name (and macro-enabled\n// .docm uses a different content type), so don't hardcode.\n\nimport { attr, children, parseXml, rootEl } from \"./xml\";\n\nconst MAIN_CONTENT_TYPES = new Set([\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\",\n \"application/vnd.ms-word.document.macroEnabled.main+xml\",\n]);\n\nexport function findMainDocumentPart(contentTypesXml: string): string | undefined {\n const types = rootEl(parseXml(contentTypesXml, \"[Content_Types].xml\"), \"Types\");\n if (!types) return undefined;\n for (const child of children(types)) {\n if (child.tagName !== \"Override\") continue;\n const ct = attr(child, \"ContentType\");\n const partName = attr(child, \"PartName\");\n if (ct && partName && MAIN_CONTENT_TYPES.has(ct)) {\n return partName.replace(/^\\//, \"\"); // OPC part names are /-rooted; zip entries aren't\n }\n }\n return undefined;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;AAaO,IAAM,cAAN,cAA0B,MAAM;AAAA,EAC5B;AAAA,EACT,YAAY,MAAuB,SAAiB;AAClD,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;AASO,IAAM,cAAN,MAAkB;AAAA,EACd,OAAwB,CAAC;AAAA,EACjB,OAAO,oBAAI,IAAY;AAAA,EACxC,IAAI,MAAc,SAAuB;AACvC,QAAI,KAAK,KAAK,IAAI,IAAI,EAAG;AACzB,SAAK,KAAK,IAAI,IAAI;AAClB,SAAK,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AAAA,EAClC;AACF;;;ACrCA,SAAS,EAAEA,IAAE;AAAC,SAAOA,GAAE,QAAQ,gDAA+C,SAASA,IAAE,GAAE;AAAC,QAAG,UAAQ,EAAE,QAAM;AAAI,QAAG,SAAO,EAAE,QAAM;AAAI,QAAG,SAAO,EAAE,QAAM;AAAI,QAAG,WAAS,EAAE,QAAM;AAAI,QAAG,WAAS,EAAE,QAAM;AAAI,QAAG,QAAM,EAAE,CAAC,GAAE;AAAC,UAAI,IAAE,QAAM,EAAE,CAAC,KAAG,QAAM,EAAE,CAAC,GAAEC,KAAE,SAAS,EAAE,MAAM,IAAE,IAAE,CAAC,GAAE,IAAE,KAAG,EAAE;AAAE,UAAG,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;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
|
-
"names": ["t", "a", "r", "a", "l", "t", "e", "n", "o", "f", "g", "A", "p", "C", "i", "c", "s", "h", "d", "v", "y", "N", "j", "t", "a", "n", "t", "n"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/fonts/clones.ts", "../src/paint/paintStyle.ts", "../src/layout/metrics.ts"],
|
|
4
|
-
"sourcesContent": ["// Single source of truth for font substitution. The editor and both exporters\n// render & measure with these freely-redistributable metric clones instead of\n// the (Windows-only) originals, so layout is identical across the editor, the\n// browser export, and the Node backend \u2014 no system fonts anywhere. The model\n// keeps the original family names; only rendering/measuring/embedding map to a\n// clone. See src/export/shared/fonts/LICENSES.md.\n\n// \"TimesNewRoman\" is the genuine Microsoft Times New Roman (bundled at the user's\n// request), not a clone \u2014 see FONTS.md / fonts/LICENSES.md for the licensing note.\nexport const CLONE_FAMILIES = [\"Carlito\", \"Caladea\", \"Gelasio\", \"Arimo\", \"TimesNewRoman\", \"Cousine\"] as const;\nexport const FALLBACK_CLONE = \"Arimo\";\n\n// Requested family (lowercased, first CSS-stack token) -> bundled clone family.\n// Includes identity entries for the clone names themselves (so already-mapped\n// strings resolve to themselves) and the generic CSS families.\nexport const CLONE_OF: Record<string, string> = {\n // metric clones of common Office/Windows fonts\n calibri: \"Carlito\",\n cambria: \"Caladea\",\n georgia: \"Gelasio\",\n arial: \"Arimo\",\n helvetica: \"Arimo\",\n \"helvetica neue\": \"Arimo\",\n \"times new roman\": \"TimesNewRoman\",\n times: \"TimesNewRoman\",\n \"courier new\": \"Cousine\",\n courier: \"Cousine\",\n // reasonable substitutes for fonts we don't ship\n verdana: \"Arimo\",\n tahoma: \"Arimo\",\n \"segoe ui\": \"Arimo\",\n \"trebuchet ms\": \"Arimo\",\n consolas: \"Cousine\",\n monaco: \"Cousine\",\n \"lucida console\": \"Cousine\",\n garamond: \"TimesNewRoman\",\n \"book antiqua\": \"Caladea\",\n palatino: \"Caladea\",\n // generic CSS families\n serif: \"TimesNewRoman\",\n \"sans-serif\": \"Arimo\",\n sans: \"Arimo\",\n monospace: \"Cousine\",\n mono: \"Cousine\",\n // identity (already a clone)\n carlito: \"Carlito\",\n caladea: \"Caladea\",\n gelasio: \"Gelasio\",\n arimo: \"Arimo\",\n timesnewroman: \"TimesNewRoman\",\n cousine: \"Cousine\",\n};\n\n// Per-clone vertical metrics as a fraction of font size (ascent, descent above/\n// below the baseline). Used by fontMetrics so line heights are computed the SAME\n// way in the editor and both exporters \u2014 otherwise the browser's canvas\n// fontBoundingBox (editor) and fontkit's tables (export) disagree by a hair and\n// pagination drifts by a page. Values measured from the browser's canvas\n// fontBoundingBox at 16px (an exact multiple here), so the editor's appearance is\n// unchanged while the export now matches it on every platform.\nexport const CLONE_METRICS: Record<string, { ascent: number; descent: number }> = {\n Carlito: { ascent: 0.9375, descent: 0.25 },\n Caladea: { ascent: 0.9375, descent: 0.25 },\n Gelasio: { ascent: 0.9375, descent: 0.3125 },\n Arimo: { ascent: 0.875, descent: 0.1875 },\n TimesNewRoman: { ascent: 0.875, descent: 0.1875 },\n Cousine: { ascent: 0.625, descent: 0.1875 },\n};\n\n/** Resolve one CSS-stack family token to its bundled clone family. */\nexport function cloneFamilyFor(family: string): { clone: string; substituted: boolean } {\n const key = family.trim().toLowerCase().replace(/^[\"']|[\"']$/g, \"\");\n const clone = CLONE_OF[key];\n return clone ? { clone, substituted: false } : { clone: FALLBACK_CLONE, substituted: true };\n}\n\n/** First token of a CSS font-family stack (\"Calibri, serif\" -> \"Calibri\"). */\nexport const firstFamilyToken = (stack: string): string => (stack.split(\",\")[0] ?? \"\").trim();\n\nexport const FONT_STYLES = [\"Regular\", \"Bold\", \"Italic\", \"BoldItalic\"] as const;\n\n/** Every bundled face filename. */\nexport const FONT_FILES: string[] = CLONE_FAMILIES.flatMap((fam) =>\n FONT_STYLES.map((style) => `${fam}-${style}.ttf`),\n);\n\n/** Toolbar font list: value is the original family (stored in the model), label\n * shows the clone we actually render \u2014 e.g. \"Calibri (Carlito)\". */\nexport const TOOLBAR_FONTS: { value: string; label: string }[] = [\n { value: \"Calibri, sans-serif\", label: \"Calibri (Carlito)\" },\n { value: \"Cambria, serif\", label: \"Cambria (Caladea)\" },\n { value: \"Georgia, serif\", label: \"Georgia (Gelasio)\" },\n { value: \"Arial, sans-serif\", label: \"Arial (Arimo)\" },\n { value: \"Times New Roman, serif\", label: \"Times New Roman\" },\n { value: \"Verdana, sans-serif\", label: \"Verdana (Arimo)\" },\n { value: \"Consolas, monospace\", label: \"Consolas (Cousine)\" },\n { value: \"Courier New, monospace\", label: \"Courier New (Cousine)\" },\n];\n", "// Shared paint styling \u2014 the constants and per-run styling DECISIONS that the\n// canvas renderer (src/paint/renderer.ts) and the PDF painter\n// (src/export/pdf/paintBlock.ts) must keep in lockstep. Centralising the magic\n// numbers and the link/colour rules stops the two painters from silently\n// drifting; the actual draw calls stay separate (canvas vs pdfkit are different\n// APIs). Pure data + math \u2014 no DOM, no rendering backend.\n\nimport type { CharStyle, TabLeader } from \"@cw/shared\";\n\n// --- colours ---------------------------------------------------------------\n/** Unstyled/native table grid (when a cell carries no explicit borders). */\nexport const DEFAULT_GRID_COLOR = \"#c0c4c9\";\n/** External hyperlinks paint in this blue (Word's affordance). */\nexport const EXTERNAL_LINK_COLOR = \"#0b57d0\";\n/** In-document anchors that inherited a Hyperlink blue read as plain text. */\nexport const ANCHOR_TEXT_COLOR = \"#202124\";\nexport const FOOTNOTE_RULE_COLOR = \"#80868b\";\nexport const TOC_LEADER_COLOR = \"#9aa0a6\";\nexport const IMAGE_PLACEHOLDER_COLOR = \"#f1f3f4\";\n\n/** Office \"Hyperlink\" character-style blues, normalised to text colour when they\n * arrive on an in-document anchor (TOC/cross-ref) so those read as plain text. */\nexport const HYPERLINK_BLUES = new Set([\n \"#0563c1\", \"#0000ff\", \"#0000ee\", \"#0b57d0\", \"#0066cc\", \"#1155cc\",\n]);\n\n/** A leader/TOC colour that inherited a Hyperlink blue \u2192 text colour. */\nexport const normalizeLinkBlue = (color: string): string =>\n HYPERLINK_BLUES.has(color.toLowerCase()) ? ANCHOR_TEXT_COLOR : color;\n\n// --- sub/superscript -------------------------------------------------------\n/** Sub/superscript is MEASURED and PAINTED at this fraction of the run size\n * (metrics.charStyleToFont scales the font; the painters scale to match). */\nexport const SUB_SUPER_SCALE = 0.65;\nconst SUPER_SHIFT = -0.38;\nconst SUB_SHIFT = 0.16;\n\n/** Baseline shift (px) for a sub/superscript run \u2014 fraction of the ORIGINAL size. */\nexport function verticalShift(vertical: CharStyle[\"verticalAlign\"], fontSizePx: number): number {\n if (vertical === \"super\") return SUPER_SHIFT * fontSizePx;\n if (vertical === \"sub\") return SUB_SHIFT * fontSizePx;\n return 0;\n}\n\n// --- text decorations ------------------------------------------------------\n/** Underline / strikethrough thickness (px). */\nexport const decorationThickness = (fontSizePx: number): number => Math.max(1, fontSizePx / 14);\n/** Underline distance below the baseline (the run's vShift is added by the caller). */\nexport const UNDERLINE_OFFSET_PX = 1.5;\n/** Strikethrough offset relative to the baseline (above it). */\nexport const strikeOffset = (fontSizePx: number): number => -0.28 * fontSizePx;\n\n/** The colour + decoration decision for a run, with link normalisation applied. */\nexport interface RunPaint {\n color: string;\n underline: boolean;\n strike: boolean;\n /** External (non-anchor) link \u2014 paints blue+underlined; the PDF also annotates it. */\n externalLink: boolean;\n}\nexport function runPaint(style: CharStyle): RunPaint {\n const anchor = style.link !== undefined && style.link.startsWith(\"#\");\n const externalLink = style.link !== undefined && !anchor;\n let color = style.color;\n if (externalLink) color = EXTERNAL_LINK_COLOR;\n else if (anchor && HYPERLINK_BLUES.has(style.color.toLowerCase())) color = ANCHOR_TEXT_COLOR;\n return {\n color,\n underline: externalLink || (!!style.underline && !anchor),\n strike: !!style.strikethrough,\n externalLink,\n };\n}\n\n// --- leaders (tab + TOC) ---------------------------------------------------\n/** Tab-leader dash pattern; [] = solid (underscore/none). */\nexport function leaderDash(kind: TabLeader): number[] {\n return kind === \"dot\" ? [1, 3] : kind === \"dash\" ? [4, 3] : [];\n}\nexport const leaderWidth = (fontSizePx: number): number => Math.max(1, fontSizePx / 14);\nexport const TOC_LEADER_DASH: number[] = [1, 4];\n/** Gap (px) between an entry's text/number and its dot leader. */\nexport const TOC_LEADER_GAP_PX = 8;\n\n// --- footnote rule ---------------------------------------------------------\n/** The separator rule spans this fraction of the content width (Word style). */\nexport const FOOTNOTE_RULE_WIDTH_FRACTION = 1 / 3;\n\n// --- cell borders ----------------------------------------------------------\n/** Hairlines clamp up so a thin rule stays visible. */\nexport const cellBorderWidth = (widthPx: number): number => Math.max(0.5, widthPx);\n/** Dash pattern for a cell edge of stroke width w; [] = solid. */\nexport function cellBorderDash(style: string | undefined, w: number): number[] {\n return style === \"dashed\" ? [w * 3, w * 2] : style === \"dotted\" ? [w, w * 1.5] : [];\n}\n/** Offset of the inner stroke of a \"double\" border. */\nexport const doubleBorderGap = (w: number): number => w + 1;\n", "// Vertical font metrics (pretext measures widths; ascent/descent are ours).\n// One hidden canvas, results cached per font string.\n\nimport type { CharStyle } from \"@cw/shared\";\nimport { CLONE_METRICS, cloneFamilyFor, firstFamilyToken } from \"../fonts/clones\";\nimport { SUB_SUPER_SCALE } from \"../paint/paintStyle\";\n\nexport interface FontMetrics {\n ascent: number;\n descent: number;\n}\n\n/** The slice of CanvasRenderingContext2D the layout actually measures through.\n * DOM-free hosts (the export worker, Node backends) inject their own via\n * {@link setMeasureContext}; the browser falls back to a real canvas. */\nexport interface MeasureContext {\n font: string;\n measureText(text: string): {\n width: number;\n fontBoundingBoxAscent: number;\n fontBoundingBoxDescent: number;\n };\n}\n\nlet injectedCtx: MeasureContext | null = null;\nlet browserCtx: MeasureContext | null = null;\n\n/** Install a measurement context (export/Node hosts). Must be called before the\n * engine measures any text. No-op for the browser, which uses a real canvas. */\nexport function setMeasureContext(ctx: MeasureContext): void {\n injectedCtx = ctx;\n}\n\n// Lazily created so importing this module never touches the DOM \u2014 the engine can\n// run under Node once a context is injected (browser path stays byte-identical).\nfunction measureContext(): MeasureContext {\n if (injectedCtx) return injectedCtx;\n if (!browserCtx) {\n browserCtx = document.createElement(\"canvas\").getContext(\"2d\")! as unknown as MeasureContext;\n }\n return browserCtx;\n}\n\nconst metricsCache = new Map<string, FontMetrics>();\n\nexport function charStyleToFont(s: CharStyle): string {\n const italic = s.italic ? \"italic \" : \"\";\n const weight = s.bold ? \"700\" : \"400\";\n // Sub/superscript runs are MEASURED at the scaled size (paint shifts the\n // baseline) \u2014 pretext must measure exactly what paint draws.\n const size = s.verticalAlign ? Math.round(s.fontSizePx * SUB_SUPER_SCALE) : s.fontSizePx;\n // Render & measure with the bundled metric clone (e.g. Calibri -> Carlito), so\n // the editor, the browser export, and the Node backend all lay out identically\n // \u2014 no dependency on system fonts. The model keeps the original family.\n const family = cloneFamilyFor(firstFamilyToken(s.fontFamily)).clone;\n return `${italic}${weight} ${size}px ${family}`;\n}\n\n/** One-off text width at a font \u2014 LAYOUT-time only (paint never measures).\n * Used for paint-only decorations the engine positions (TOC page numbers). */\nexport function measureTextWidth(text: string, font: string): number {\n const ctx = measureContext();\n ctx.font = font;\n return ctx.measureText(text).width;\n}\n\n// Vertical metrics come from baked per-clone ratios (NOT the canvas/fontkit\n// context), so the editor and the exporters compute identical line heights and\n// therefore identical pagination on every platform. charStyleToFont already\n// emits the clone family, so the last token of the font string is it.\nexport function fontMetrics(font: string): FontMetrics {\n let m = metricsCache.get(font);\n if (!m) {\n const sizeMatch = /(\\d+(?:\\.\\d+)?)px/.exec(font);\n const size = sizeMatch ? parseFloat(sizeMatch[1]!) : 16;\n const family = font.slice(font.indexOf(\"px \") + 3).trim();\n const r = CLONE_METRICS[cloneFamilyFor(family).clone] ?? { ascent: 0.9, descent: 0.25 };\n m = { ascent: Math.round(r.ascent * size), descent: Math.round(r.descent * size) };\n metricsCache.set(font, m);\n }\n return m;\n}\n"],
|
|
5
|
-
"mappings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AAO,IAAI,YAAY,IAAI,EAAE;AAC/B;AAMO,SAAS,YAAY,MAA2B;AACrD,MAAI,IAAI,aAAa,IAAI,IAAI;AAC7B,MAAI,CAAC,GAAG;AACN,UAAM,YAAY,oBAAoB,KAAK,IAAI;AAC/C,UAAM,OAAO,YAAY,WAAW,UAAU,CAAC,CAAE,IAAI;AACrD,UAAM,SAAS,KAAK,MAAM,KAAK,QAAQ,KAAK,IAAI,CAAC,EAAE,KAAK;AACxD,UAAM,IAAI,cAAc,eAAe,MAAM,EAAE,KAAK,KAAK,EAAE,QAAQ,KAAK,SAAS,KAAK;AACtF,QAAI,EAAE,QAAQ,KAAK,MAAM,EAAE,SAAS,IAAI,GAAG,SAAS,KAAK,MAAM,EAAE,UAAU,IAAI,EAAE;AACjF,iBAAa,IAAI,MAAM,CAAC;AAAA,EAC1B;AACA,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/export/docx/xmlWrite.ts", "../src/export/units.ts", "../src/export/docx/mappings.ts", "../src/export/docx/styleProps.ts"],
|
|
4
|
-
"sourcesContent": ["// Minimal, dependency-free XML string emitter for OOXML parts. Attribute order is\n// insertion order (Word doesn't care); empty children collapse to self-closing.\n\nexport type Attrs = Record<string, string | number | boolean | undefined>;\n\nexport function escapeText(s: string): string {\n return s.replace(/&/g, \"&\").replace(/</g, \"<\").replace(/>/g, \">\");\n}\n\nfunction escapeAttr(s: string): string {\n return escapeText(s).replace(/\"/g, \""\");\n}\n\nfunction serializeAttrs(attrs: Attrs | undefined): string {\n if (!attrs) return \"\";\n let out = \"\";\n for (const [k, v] of Object.entries(attrs)) {\n if (v === undefined || v === false) continue;\n out += ` ${k}=\"${escapeAttr(String(v))}\"`;\n }\n return out;\n}\n\n/** An element. `children` is pre-serialized XML (caller joins arrays). Pass \"\"\n * or undefined for an empty element (self-closing). */\nexport function el(tag: string, attrs?: Attrs, children?: string): string {\n const a = serializeAttrs(attrs);\n if (children === undefined || children === \"\") return `<${tag}${a}/>`;\n return `<${tag}${a}>${children}</${tag}>`;\n}\n\n/** A w:t, preserving leading/trailing whitespace when present. */\nexport function textEl(text: string): string {\n const needsPreserve = /^\\s|\\s$|\\s\\s/.test(text) || text.includes(\"\\t\");\n return el(\"w:t\", needsPreserve ? { \"xml:space\": \"preserve\" } : undefined, escapeText(text));\n}\n\nexport const XML_DECL = '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\\n';\n\n/** The w: + relationships + drawing namespaces Word expects on a document root. */\nexport const WML_NS = {\n \"xmlns:w\": \"http://schemas.openxmlformats.org/wordprocessingml/2006/main\",\n \"xmlns:r\": \"http://schemas.openxmlformats.org/officeDocument/2006/relationships\",\n \"xmlns:wp\": \"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\",\n \"xmlns:a\": \"http://schemas.openxmlformats.org/drawingml/2006/main\",\n \"xmlns:pic\": \"http://schemas.openxmlformats.org/drawingml/2006/picture\",\n \"xmlns:w14\": \"http://schemas.microsoft.com/office/word/2010/wordml\",\n \"xmlns:mc\": \"http://schemas.openxmlformats.org/markup-compatibility/2006\",\n} as const;\n", "// px (CSS, 96dpi) -> OOXML units. Exact inverses of src/import/docx/units.ts.\r\n\r\n// A non-finite value (NaN/Infinity from an undefined style field) would serialize\r\n// to an invalid w:val=\"NaN\" and corrupt the .docx. Coerce to 0 so output stays\r\n// well-formed \u2014 these are pure unit conversions, so NaN never legitimately occurs.\r\nconst finite = (n: number): number => (Number.isFinite(n) ? n : 0);\r\n\r\n/** px -> twips: px \u00D7 15 (twip = 1/20pt, px = tw/15). */\r\nexport const pxToTwips = (px: number): number => Math.round(finite(px) * 15);\r\n\r\n/** px -> half-points: px \u00D7 1.5 (w:sz; px = hp \u00D7 2/3). */\r\nexport const pxToHalfPoints = (px: number): number => Math.round(finite(px) * 1.5);\r\n\r\n/** px -> EMU: px \u00D7 9525 (image extents; 914400 EMU/in \u00F7 96). */\r\nexport const pxToEmu = (px: number): number => Math.round(finite(px) * 9525);\r\n\r\n/** px -> eighth-points: px \u00D7 6 (border w:sz; px = sz/6). */\r\nexport const pxToEighthPoints = (px: number): number => Math.max(2, Math.round(finite(px) * 6));\r\n\r\n/** line-height multiplier -> w:line 240ths (lineRule=\"auto\"). */\r\nexport const multiplierToLine = (m: number): number => Math.round(finite(m) * 240);\r\n", "// Single source for model \u2192 WordprocessingML value mappings shared across the\r\n// exporter (documentXml, styleProps) and the headless TOC generator. Keeping\r\n// these in one place prevents the maps from drifting apart (they already had).\r\n\r\nimport type { ParaStyle } from \"@cw/shared\";\r\n\r\n/** highlight hex \u2192 Word highlight color name (w:highlight w:val). */\r\nexport const HIGHLIGHT_NAME: Record<string, string> = {\r\n \"#ffff00\": \"yellow\", \"#00ff00\": \"green\", \"#00ffff\": \"cyan\", \"#ff00ff\": \"magenta\",\r\n \"#0000ff\": \"blue\", \"#ff0000\": \"red\", \"#000080\": \"darkBlue\", \"#008080\": \"darkCyan\",\r\n \"#008000\": \"darkGreen\", \"#800080\": \"darkMagenta\", \"#800000\": \"darkRed\", \"#808000\": \"darkYellow\",\r\n \"#808080\": \"darkGray\", \"#c0c0c0\": \"lightGray\", \"#000000\": \"black\", \"#ffffff\": \"white\",\r\n};\r\n\r\n/** paragraph align \u2192 w:jc w:val. */\r\nexport const JC: Record<ParaStyle[\"align\"], string> = { left: \"left\", center: \"center\", right: \"right\", justify: \"both\" };\r\n\r\n/** tab align \u2192 w:tab w:val. */\r\nexport const TAB_VAL: Record<string, string> = { left: \"left\", center: \"center\", right: \"right\", decimal: \"decimal\" };\r\n\r\n/** tab leader \u2192 w:tab w:leader. */\r\nexport const TAB_LEADER: Record<string, string> = { dot: \"dot\", dash: \"hyphen\", underscore: \"underscore\" };\r\n\r\n/** strip a leading \"#\" and lowercase a hex color for OOXML w:val attributes. */\r\nexport const hexColor = (c: string): string => c.replace(/^#/, \"\").toLowerCase();\r\n", "// Partial rPr/pPr emitters for style-gallery patches (NamedStyle.char/.para) and\r\n// list-marker run props. Only DEFINED fields are written \u2014 the importer reads\r\n// each w:* element into a patch field, so absent elements stay absent.\r\n\r\nimport type { CharStyle, ParaStyle } from \"@cw/shared\";\r\nimport { multiplierToLine, pxToHalfPoints, pxToTwips } from \"../units\";\r\nimport { HIGHLIGHT_NAME, hexColor as hex, JC, TAB_LEADER, TAB_VAL } from \"./mappings\";\r\nimport { el } from \"./xmlWrite\";\r\n\r\n// Full rPr serializer: every toggle written explicitly (on/off) so a run's\r\n// direct formatting fully overrides any inherited paragraph/named style on\r\n// re-import. Shared by the main exporter (documentXml) and the headless TOC\r\n// generator (recalc/generateTocDocx) so they can't drift.\r\nexport function runPropsXml(s: CharStyle): string {\r\n const family = (s.fontFamily.split(\",\")[0] ?? \"\").trim();\r\n const children: string[] = [];\r\n if (family) children.push(el(\"w:rFonts\", { \"w:ascii\": family, \"w:hAnsi\": family, \"w:cs\": family }));\r\n children.push(el(\"w:b\", { \"w:val\": s.bold ? \"1\" : \"0\" }));\r\n children.push(el(\"w:i\", { \"w:val\": s.italic ? \"1\" : \"0\" }));\r\n if (s.strikethrough) children.push(el(\"w:strike\", { \"w:val\": \"1\" }));\r\n if (s.hidden) children.push(el(\"w:vanish\", { \"w:val\": \"1\" })); // preserved hidden text\r\n children.push(el(\"w:color\", { \"w:val\": hex(s.color) }));\r\n children.push(el(\"w:sz\", { \"w:val\": pxToHalfPoints(s.fontSizePx) }));\r\n children.push(el(\"w:szCs\", { \"w:val\": pxToHalfPoints(s.fontSizePx) }));\r\n children.push(el(\"w:u\", { \"w:val\": s.underline ? \"single\" : \"none\" }));\r\n if (s.letterSpacingPx !== undefined) children.push(el(\"w:spacing\", { \"w:val\": pxToTwips(s.letterSpacingPx) }));\r\n if (s.highlightColor) {\r\n const name = HIGHLIGHT_NAME[s.highlightColor.toLowerCase()];\r\n if (name) children.push(el(\"w:highlight\", { \"w:val\": name }));\r\n }\r\n if (s.verticalAlign) children.push(el(\"w:vertAlign\", { \"w:val\": s.verticalAlign === \"super\" ? \"superscript\" : \"subscript\" }));\r\n return el(\"w:rPr\", undefined, children.join(\"\"));\r\n}\r\n\r\n// The spacing/indent/jc/tabs core shared by every full pPr: returned as\r\n// concatenated child elements (NOT wrapped in w:pPr) so the main exporter can\r\n// interleave it with pStyle/numPr/breaks/section props, while the TOC generator\r\n// wraps it directly. Emission order matches OOXML's tolerant exporter convention.\r\nexport function paraCoreXml(style: ParaStyle): string {\r\n const c: string[] = [];\r\n c.push(el(\"w:spacing\", {\r\n \"w:before\": pxToTwips(style.spaceBeforePx),\r\n \"w:after\": pxToTwips(style.spaceAfterPx),\r\n \"w:line\": multiplierToLine(style.lineHeight),\r\n \"w:lineRule\": \"auto\",\r\n }));\r\n const ind: Record<string, number> = {};\r\n if (style.indentLeftPx) ind[\"w:left\"] = pxToTwips(style.indentLeftPx);\r\n if (style.indentRightPx) ind[\"w:right\"] = pxToTwips(style.indentRightPx);\r\n if (style.indentFirstLinePx > 0) ind[\"w:firstLine\"] = pxToTwips(style.indentFirstLinePx);\r\n else if (style.indentFirstLinePx < 0) ind[\"w:hanging\"] = pxToTwips(-style.indentFirstLinePx);\r\n if (Object.keys(ind).length > 0) c.push(el(\"w:ind\", ind));\r\n c.push(el(\"w:jc\", { \"w:val\": JC[style.align] }));\r\n if (style.tabStops && style.tabStops.length > 0) {\r\n const tabs = style.tabStops\r\n .map((t) =>\r\n el(\"w:tab\", {\r\n \"w:val\": t.align ? (TAB_VAL[t.align] ?? \"left\") : \"left\",\r\n \"w:pos\": pxToTwips(t.posPx),\r\n \"w:leader\": t.leader && t.leader !== \"none\" ? TAB_LEADER[t.leader] : undefined,\r\n }),\r\n )\r\n .join(\"\");\r\n c.push(el(\"w:tabs\", undefined, tabs));\r\n }\r\n return c.join(\"\");\r\n}\r\n\r\nexport function partialRPrXml(c: Partial<CharStyle>): string {\r\n const out: string[] = [];\r\n if (c.fontFamily) {\r\n const fam = (c.fontFamily.split(\",\")[0] ?? \"\").trim();\r\n if (fam) out.push(el(\"w:rFonts\", { \"w:ascii\": fam, \"w:hAnsi\": fam, \"w:cs\": fam }));\r\n }\r\n if (c.bold !== undefined) out.push(el(\"w:b\", { \"w:val\": c.bold ? \"1\" : \"0\" }));\r\n if (c.italic !== undefined) out.push(el(\"w:i\", { \"w:val\": c.italic ? \"1\" : \"0\" }));\r\n if (c.strikethrough !== undefined) out.push(el(\"w:strike\", { \"w:val\": c.strikethrough ? \"1\" : \"0\" }));\r\n if (c.color) out.push(el(\"w:color\", { \"w:val\": hex(c.color) }));\r\n if (c.fontSizePx !== undefined) {\r\n const sz = Math.round(c.fontSizePx * 1.5);\r\n out.push(el(\"w:sz\", { \"w:val\": sz }));\r\n out.push(el(\"w:szCs\", { \"w:val\": sz }));\r\n }\r\n if (c.underline !== undefined) out.push(el(\"w:u\", { \"w:val\": c.underline ? \"single\" : \"none\" }));\r\n if (c.highlightColor) {\r\n const name = HIGHLIGHT_NAME[c.highlightColor.toLowerCase()];\r\n if (name) out.push(el(\"w:highlight\", { \"w:val\": name }));\r\n }\r\n if (c.verticalAlign) out.push(el(\"w:vertAlign\", { \"w:val\": c.verticalAlign === \"super\" ? \"superscript\" : \"subscript\" }));\r\n return out.length > 0 ? el(\"w:rPr\", undefined, out.join(\"\")) : \"\";\r\n}\r\n\r\nexport function partialPPrXml(p: Partial<ParaStyle>): string {\r\n const out: string[] = [];\r\n if (p.align) out.push(el(\"w:jc\", { \"w:val\": JC[p.align] ?? \"left\" }));\r\n const sp: Record<string, number | string> = {};\r\n if (p.spaceBeforePx !== undefined) sp[\"w:before\"] = pxToTwips(p.spaceBeforePx);\r\n if (p.spaceAfterPx !== undefined) sp[\"w:after\"] = pxToTwips(p.spaceAfterPx);\r\n if (p.lineHeight !== undefined) {\r\n sp[\"w:line\"] = multiplierToLine(p.lineHeight);\r\n sp[\"w:lineRule\"] = \"auto\";\r\n }\r\n if (Object.keys(sp).length > 0) out.push(el(\"w:spacing\", sp));\r\n const ind: Record<string, number> = {};\r\n if (p.indentLeftPx !== undefined) ind[\"w:left\"] = pxToTwips(p.indentLeftPx);\r\n if (p.indentRightPx !== undefined) ind[\"w:right\"] = pxToTwips(p.indentRightPx);\r\n if (p.indentFirstLinePx !== undefined) {\r\n if (p.indentFirstLinePx >= 0) ind[\"w:firstLine\"] = pxToTwips(p.indentFirstLinePx);\r\n else ind[\"w:hanging\"] = pxToTwips(-p.indentFirstLinePx);\r\n }\r\n if (Object.keys(ind).length > 0) out.push(el(\"w:ind\", ind));\r\n if (p.keepWithNext) out.push(el(\"w:keepNext\"));\r\n if (p.keepLinesTogether) out.push(el(\"w:keepLines\"));\r\n if (p.tabStops && p.tabStops.length > 0) {\r\n const tabs = p.tabStops\r\n .map((t) =>\r\n el(\"w:tab\", {\r\n \"w:val\": t.align ? (TAB_VAL[t.align] ?? \"left\") : \"left\",\r\n \"w:pos\": pxToTwips(t.posPx),\r\n \"w:leader\": t.leader && t.leader !== \"none\" ? TAB_LEADER[t.leader] : undefined,\r\n }),\r\n )\r\n .join(\"\");\r\n out.push(el(\"w:tabs\", undefined, tabs));\r\n }\r\n return out.length > 0 ? el(\"w:pPr\", undefined, out.join(\"\")) : \"\";\r\n}\r\n"],
|
|
5
|
-
"mappings": ";;;;;;;;AAKO,SAAS,WAAW,GAAmB;AAC5C,SAAO,EAAE,QAAQ,MAAM,OAAO,EAAE,QAAQ,MAAM,MAAM,EAAE,QAAQ,MAAM,MAAM;AAC5E;AAEA,SAAS,WAAW,GAAmB;AACrC,SAAO,WAAW,CAAC,EAAE,QAAQ,MAAM,QAAQ;AAC7C;AAEA,SAAS,eAAe,OAAkC;AACxD,MAAI,CAAC,MAAO,QAAO;AACnB,MAAI,MAAM;AACV,aAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,KAAK,GAAG;AAC1C,QAAI,MAAM,UAAa,MAAM,MAAO;AACpC,WAAO,IAAI,CAAC,KAAK,WAAW,OAAO,CAAC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