@forevka/wordcanvas 0.7.2 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/assets/{worker-4HYrkNrG.js → worker-CqU4Popa.js} +399 -375
- package/dist-lib/assets/{worker-CJpwUzKh.js → worker-Cw5cYW5z.js} +359 -344
- package/dist-lib/{blockFactory-B_CLnkUh.js → blockFactory-DDCRWDnA.js} +16 -31
- package/dist-lib/browser-BUrsjziD.js +612 -0
- package/dist-lib/builder.js +16 -17
- package/dist-lib/editorApp-CB_ZArIF.js +9566 -0
- package/dist-lib/export.js +28 -28
- package/dist-lib/generate-toc.js +6 -6
- package/dist-lib/import.js +2 -2
- package/dist-lib/lists-DpmgbDyt.js +110 -0
- package/dist-lib/measure.js +2 -2
- package/dist-lib/{measureHost-B2aKX7lF.js → measureHost-BlukHGwx.js} +1 -1
- package/dist-lib/metrics-bvGO8KDK.js +96 -0
- package/dist-lib/paintStyle-vT6jtWbH.js +74 -0
- package/dist-lib/{pipeline-DD0nxAYM.js → pipeline-UryP-u7Z.js} +80 -80
- package/dist-lib/recalc-docx.js +2 -2
- package/dist-lib/{recalcToc-CFCGCgij.js → recalcToc-BfXlXZik.js} +3 -3
- package/dist-lib/{stylesheet-B6oczA-L.js → stylesheet-LTBEGkvG.js} +32 -27
- package/dist-lib/toc-D09f4PrI.js +939 -0
- package/dist-lib/{webmcp-CXghUon_.js → webmcp-K6UZgQJ0.js} +60 -68
- package/dist-lib/wordcanvas-DBx2ana_.js +734 -0
- package/dist-lib/wordcanvas.js +4 -2
- package/dist-node/{chunk-PIMVQULL.js → chunk-373K2XRY.js} +34 -22
- package/dist-node/chunk-373K2XRY.js.map +7 -0
- package/dist-node/{chunk-57L5XMCL.js → chunk-3PUV3BG6.js} +2 -2
- package/dist-node/{chunk-U27EBKBG.js → chunk-5RX3IHWE.js} +3 -3
- package/dist-node/chunk-5RX3IHWE.js.map +7 -0
- package/dist-node/{chunk-SA26UVIJ.js → chunk-HWQKGDS2.js} +2 -2
- package/dist-node/{chunk-T3253N22.js → chunk-ZLLSXOO2.js} +3 -3
- package/dist-node/{engine-5F7DUU4W.js → engine-LLA6PCS5.js} +4 -4
- package/dist-node/export.js +5 -5
- package/dist-node/generate-toc.js +4 -4
- package/dist-node/import.js +2 -2
- package/dist-node/measure.js +2 -2
- package/dist-node/recalc-docx.js +3 -3
- package/package.json +1 -1
- package/types/wordcanvas.d.ts +649 -212
- package/dist-lib/browser-p_rkUcqE.js +0 -1339
- package/dist-lib/editorApp-mTD0YNv-.js +0 -9863
- package/dist-lib/lists-Sc5I40JO.js +0 -110
- package/dist-lib/metrics-BUMIC9Mv.js +0 -164
- package/dist-lib/toc-Dj57zdz-.js +0 -213
- package/dist-lib/wordcanvas-D5DI9ZR1.js +0 -151
- package/dist-node/chunk-PIMVQULL.js.map +0 -7
- package/dist-node/chunk-U27EBKBG.js.map +0 -7
- /package/dist-node/{chunk-57L5XMCL.js.map → chunk-3PUV3BG6.js.map} +0 -0
- /package/dist-node/{chunk-SA26UVIJ.js.map → chunk-HWQKGDS2.js.map} +0 -0
- /package/dist-node/{chunk-T3253N22.js.map → chunk-ZLLSXOO2.js.map} +0 -0
- /package/dist-node/{engine-5F7DUU4W.js.map → engine-LLA6PCS5.js.map} +0 -0
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
const f = [
|
|
2
|
-
[1e3, "m"],
|
|
3
|
-
[900, "cm"],
|
|
4
|
-
[500, "d"],
|
|
5
|
-
[400, "cd"],
|
|
6
|
-
[100, "c"],
|
|
7
|
-
[90, "xc"],
|
|
8
|
-
[50, "l"],
|
|
9
|
-
[40, "xl"],
|
|
10
|
-
[10, "x"],
|
|
11
|
-
[9, "ix"],
|
|
12
|
-
[5, "v"],
|
|
13
|
-
[4, "iv"],
|
|
14
|
-
[1, "i"]
|
|
15
|
-
];
|
|
16
|
-
function a(e) {
|
|
17
|
-
let n = "", t = Math.max(1, e);
|
|
18
|
-
for (const [r, l] of f)
|
|
19
|
-
for (; t >= r; )
|
|
20
|
-
n += l, t -= r;
|
|
21
|
-
return n;
|
|
22
|
-
}
|
|
23
|
-
function i(e) {
|
|
24
|
-
let n = "", t = Math.max(1, e);
|
|
25
|
-
for (; t > 0; )
|
|
26
|
-
t -= 1, n = String.fromCharCode(97 + t % 26) + n, t = Math.floor(t / 26);
|
|
27
|
-
return n;
|
|
28
|
-
}
|
|
29
|
-
function m(e, n) {
|
|
30
|
-
switch (n) {
|
|
31
|
-
case "decimal":
|
|
32
|
-
return String(e);
|
|
33
|
-
case "lowerLetter":
|
|
34
|
-
return i(e);
|
|
35
|
-
case "upperLetter":
|
|
36
|
-
return i(e).toUpperCase();
|
|
37
|
-
case "lowerRoman":
|
|
38
|
-
return a(e);
|
|
39
|
-
case "upperRoman":
|
|
40
|
-
return a(e).toUpperCase();
|
|
41
|
-
case "bullet":
|
|
42
|
-
return "";
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function g(e, n, t) {
|
|
46
|
-
const r = e.levels[Math.min(n, e.levels.length - 1)];
|
|
47
|
-
return r ? r.format === "bullet" ? r.bulletChar ?? "•" : r.text.replace(/%(\d)/g, (l, u) => {
|
|
48
|
-
const o = Number(u) - 1, s = e.levels[Math.min(o, e.levels.length - 1)], c = t[o] ?? s?.start ?? 1;
|
|
49
|
-
return m(c, s?.format ?? "decimal");
|
|
50
|
-
}) : "";
|
|
51
|
-
}
|
|
52
|
-
const L = "bullets", h = "numbers", x = "multilevel", v = ["•", "◦", "▪"], b = ["decimal", "lowerLetter", "lowerRoman"];
|
|
53
|
-
function p(e) {
|
|
54
|
-
const n = [];
|
|
55
|
-
for (let t = 0; t < 9; t++)
|
|
56
|
-
e === "bullet" ? n.push({
|
|
57
|
-
format: "bullet",
|
|
58
|
-
text: "",
|
|
59
|
-
bulletChar: v[t % 3],
|
|
60
|
-
indentLeftPx: 24 + t * 24,
|
|
61
|
-
hangingPx: 18,
|
|
62
|
-
start: 1
|
|
63
|
-
}) : n.push({
|
|
64
|
-
format: b[t % 3],
|
|
65
|
-
text: `%${t + 1}.`,
|
|
66
|
-
indentLeftPx: 24 + t * 24,
|
|
67
|
-
hangingPx: 22,
|
|
68
|
-
start: 1
|
|
69
|
-
});
|
|
70
|
-
return { id: e === "bullet" ? L : h, levels: n };
|
|
71
|
-
}
|
|
72
|
-
function d(e, n) {
|
|
73
|
-
const t = [];
|
|
74
|
-
for (let r = 0; r < 9; r++)
|
|
75
|
-
t.push({ format: "bullet", text: "", bulletChar: n, indentLeftPx: 24 + r * 24, hangingPx: 18, start: 1 });
|
|
76
|
-
return { id: e, levels: t };
|
|
77
|
-
}
|
|
78
|
-
function _(e, n, t) {
|
|
79
|
-
const r = [];
|
|
80
|
-
for (let l = 0; l < 9; l++)
|
|
81
|
-
r.push({ format: n, text: `%${l + 1}${t}`, indentLeftPx: 24 + l * 24, hangingPx: 22, start: 1 });
|
|
82
|
-
return { id: e, levels: r };
|
|
83
|
-
}
|
|
84
|
-
function D() {
|
|
85
|
-
const e = [];
|
|
86
|
-
for (let n = 0; n < 9; n++) {
|
|
87
|
-
const t = Array.from({ length: n + 1 }, (r, l) => `%${l + 1}`).join(".") + ".";
|
|
88
|
-
e.push({
|
|
89
|
-
format: "decimal",
|
|
90
|
-
text: t,
|
|
91
|
-
// "%1.", "%1.%2.", "%1.%2.%3.", …
|
|
92
|
-
indentLeftPx: 24 + n * 24,
|
|
93
|
-
hangingPx: 24 + n * 8,
|
|
94
|
-
// compound markers widen with depth
|
|
95
|
-
start: 1
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
return { id: x, levels: e };
|
|
99
|
-
}
|
|
100
|
-
export {
|
|
101
|
-
h as D,
|
|
102
|
-
L as a,
|
|
103
|
-
d as b,
|
|
104
|
-
x as c,
|
|
105
|
-
p as d,
|
|
106
|
-
g as e,
|
|
107
|
-
m as f,
|
|
108
|
-
D as m,
|
|
109
|
-
_ as n
|
|
110
|
-
};
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
const S = ["Carlito", "Caladea", "Gelasio", "Arimo", "TimesNewRoman", "Cousine"], b = "Arimo", M = {
|
|
2
|
-
// metric clones of common Office/Windows fonts
|
|
3
|
-
calibri: "Carlito",
|
|
4
|
-
cambria: "Caladea",
|
|
5
|
-
georgia: "Gelasio",
|
|
6
|
-
arial: "Arimo",
|
|
7
|
-
helvetica: "Arimo",
|
|
8
|
-
"helvetica neue": "Arimo",
|
|
9
|
-
"times new roman": "TimesNewRoman",
|
|
10
|
-
times: "TimesNewRoman",
|
|
11
|
-
"courier new": "Cousine",
|
|
12
|
-
courier: "Cousine",
|
|
13
|
-
// reasonable substitutes for fonts we don't ship
|
|
14
|
-
verdana: "Arimo",
|
|
15
|
-
tahoma: "Arimo",
|
|
16
|
-
"segoe ui": "Arimo",
|
|
17
|
-
"trebuchet ms": "Arimo",
|
|
18
|
-
consolas: "Cousine",
|
|
19
|
-
monaco: "Cousine",
|
|
20
|
-
"lucida console": "Cousine",
|
|
21
|
-
garamond: "TimesNewRoman",
|
|
22
|
-
"book antiqua": "Caladea",
|
|
23
|
-
palatino: "Caladea",
|
|
24
|
-
// generic CSS families
|
|
25
|
-
serif: "TimesNewRoman",
|
|
26
|
-
"sans-serif": "Arimo",
|
|
27
|
-
sans: "Arimo",
|
|
28
|
-
monospace: "Cousine",
|
|
29
|
-
mono: "Cousine",
|
|
30
|
-
// identity (already a clone)
|
|
31
|
-
carlito: "Carlito",
|
|
32
|
-
caladea: "Caladea",
|
|
33
|
-
gelasio: "Gelasio",
|
|
34
|
-
arimo: "Arimo",
|
|
35
|
-
timesnewroman: "TimesNewRoman",
|
|
36
|
-
cousine: "Cousine"
|
|
37
|
-
}, P = {
|
|
38
|
-
Carlito: { ascent: 0.9375, descent: 0.25 },
|
|
39
|
-
Caladea: { ascent: 0.9375, descent: 0.25 },
|
|
40
|
-
Gelasio: { ascent: 0.9375, descent: 0.3125 },
|
|
41
|
-
Arimo: { ascent: 0.875, descent: 0.1875 },
|
|
42
|
-
TimesNewRoman: { ascent: 0.875, descent: 0.1875 },
|
|
43
|
-
Cousine: { ascent: 0.625, descent: 0.1875 }
|
|
44
|
-
};
|
|
45
|
-
function N(t) {
|
|
46
|
-
const e = t.trim().toLowerCase().replace(/^["']|["']$/g, ""), a = M[e];
|
|
47
|
-
return a ? { clone: a, substituted: !1 } : { clone: b, substituted: !0 };
|
|
48
|
-
}
|
|
49
|
-
const I = (t) => (t.split(",")[0] ?? "").trim(), v = ["Regular", "Bold", "Italic", "BoldItalic"], $ = S.flatMap(
|
|
50
|
-
(t) => v.map((e) => `${t}-${e}.ttf`)
|
|
51
|
-
), H = [
|
|
52
|
-
{ value: "Calibri, sans-serif", label: "Calibri (Carlito)" },
|
|
53
|
-
{ value: "Cambria, serif", label: "Cambria (Caladea)" },
|
|
54
|
-
{ value: "Georgia, serif", label: "Georgia (Gelasio)" },
|
|
55
|
-
{ value: "Arial, sans-serif", label: "Arial (Arimo)" },
|
|
56
|
-
{ value: "Times New Roman, serif", label: "Times New Roman" },
|
|
57
|
-
{ value: "Verdana, sans-serif", label: "Verdana (Arimo)" },
|
|
58
|
-
{ value: "Consolas, monospace", label: "Consolas (Cousine)" },
|
|
59
|
-
{ value: "Courier New, monospace", label: "Courier New (Cousine)" }
|
|
60
|
-
], K = "#c0c4c9", g = "#0b57d0", w = "#202124", X = "#80868b", y = "#7a8aa0", W = "#9aa0a6", j = "#f1f3f4", F = /* @__PURE__ */ new Set([
|
|
61
|
-
"#0563c1",
|
|
62
|
-
"#0000ff",
|
|
63
|
-
"#0000ee",
|
|
64
|
-
"#0b57d0",
|
|
65
|
-
"#0066cc",
|
|
66
|
-
"#1155cc"
|
|
67
|
-
]), q = (t) => F.has(t.toLowerCase()) ? w : t, B = 0.65, D = -0.38, k = 0.16;
|
|
68
|
-
function V(t, e) {
|
|
69
|
-
return t === "super" ? D * e : t === "sub" ? k * e : 0;
|
|
70
|
-
}
|
|
71
|
-
const Y = (t) => Math.max(1, t / 14), J = 1.5, Q = (t) => -0.28 * t;
|
|
72
|
-
function Z(t) {
|
|
73
|
-
const e = t.link !== void 0 && t.link.startsWith("#"), a = t.link !== void 0 && !e;
|
|
74
|
-
let o = t.color;
|
|
75
|
-
return a ? o = g : e && F.has(t.color.toLowerCase()) && (o = w), {
|
|
76
|
-
color: o,
|
|
77
|
-
underline: a || !!t.underline && !e,
|
|
78
|
-
strike: !!t.strikethrough,
|
|
79
|
-
externalLink: a
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
function tt(t) {
|
|
83
|
-
return t === "dot" ? [1, 3] : t === "dash" ? [4, 3] : [];
|
|
84
|
-
}
|
|
85
|
-
const et = (t) => Math.max(1, t / 14), at = [1, 4], ot = 8, st = 1 / 3, nt = "#c0c4c9", G = 24;
|
|
86
|
-
function it(t, e, a, o) {
|
|
87
|
-
const i = t.offsetFrom === "text", n = (s) => s?.spacePx ?? G, u = i ? o.left - n(t.left) : n(t.left), m = i ? e - o.right + n(t.right) : e - n(t.right), C = i ? o.top - n(t.top) : n(t.top), d = i ? a - o.bottom + n(t.bottom) : a - n(t.bottom), h = [], f = (s, O, l, R, T) => {
|
|
88
|
-
if (!s || s.style === "none") return;
|
|
89
|
-
const c = s.style === "thick" ? Math.max(2, s.widthPx) : Math.max(0.5, s.widthPx), _ = s.color === "auto" ? "#000000" : s.color, p = s.style === "dashed" ? [c * 3, c * 2] : s.style === "dotted" ? [c, c * 1.5] : [];
|
|
90
|
-
if (h.push({ x1: O, y1: l, x2: R, y2: T, widthPx: c, color: _, dash: p }), s.style === "double") {
|
|
91
|
-
const A = c + 1;
|
|
92
|
-
if (l === T) {
|
|
93
|
-
const r = l < a / 2 ? A : -A;
|
|
94
|
-
h.push({ x1: O, y1: l + r, x2: R, y2: T + r, widthPx: c, color: _, dash: [] });
|
|
95
|
-
} else {
|
|
96
|
-
const r = O < e / 2 ? A : -A;
|
|
97
|
-
h.push({ x1: O + r, y1: l, x2: R + r, y2: T, widthPx: c, color: _, dash: [] });
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
return f(t.top, u, C, m, C), f(t.bottom, u, d, m, d), f(t.left, u, C, u, d), f(t.right, m, C, m, d), h;
|
|
102
|
-
}
|
|
103
|
-
const ct = (t) => Math.max(0.5, t);
|
|
104
|
-
function lt(t, e) {
|
|
105
|
-
return t === "dashed" ? [e * 3, e * 2] : t === "dotted" ? [e, e * 1.5] : [];
|
|
106
|
-
}
|
|
107
|
-
const rt = (t) => t + 1;
|
|
108
|
-
let E = null, L = null;
|
|
109
|
-
function ut(t) {
|
|
110
|
-
E = t;
|
|
111
|
-
}
|
|
112
|
-
function U() {
|
|
113
|
-
return E || (L || (L = document.createElement("canvas").getContext("2d")), L);
|
|
114
|
-
}
|
|
115
|
-
const x = /* @__PURE__ */ new Map();
|
|
116
|
-
function mt(t) {
|
|
117
|
-
const e = t.italic ? "italic " : "", a = t.bold ? "700" : "400", o = t.verticalAlign ? Math.round(t.fontSizePx * B) : t.fontSizePx, i = N(I(t.fontFamily)).clone;
|
|
118
|
-
return `${e}${a} ${o}px ${i}`;
|
|
119
|
-
}
|
|
120
|
-
function Ct(t, e) {
|
|
121
|
-
const a = U();
|
|
122
|
-
return a.font = e, a.measureText(t).width;
|
|
123
|
-
}
|
|
124
|
-
function dt(t) {
|
|
125
|
-
let e = x.get(t);
|
|
126
|
-
if (!e) {
|
|
127
|
-
const a = /(\d+(?:\.\d+)?)px/.exec(t), o = a ? parseFloat(a[1]) : 16, i = t.slice(t.indexOf("px ") + 3).trim(), n = P[N(i).clone] ?? { ascent: 0.9, descent: 0.25 };
|
|
128
|
-
e = { ascent: Math.round(n.ascent * o), descent: Math.round(n.descent * o) }, x.set(t, e);
|
|
129
|
-
}
|
|
130
|
-
return e;
|
|
131
|
-
}
|
|
132
|
-
export {
|
|
133
|
-
nt as C,
|
|
134
|
-
K as D,
|
|
135
|
-
X as F,
|
|
136
|
-
j as I,
|
|
137
|
-
B as S,
|
|
138
|
-
ot as T,
|
|
139
|
-
J as U,
|
|
140
|
-
W as a,
|
|
141
|
-
at as b,
|
|
142
|
-
tt as c,
|
|
143
|
-
Y as d,
|
|
144
|
-
ct as e,
|
|
145
|
-
lt as f,
|
|
146
|
-
rt as g,
|
|
147
|
-
st as h,
|
|
148
|
-
N as i,
|
|
149
|
-
$ as j,
|
|
150
|
-
ut as k,
|
|
151
|
-
et as l,
|
|
152
|
-
mt as m,
|
|
153
|
-
q as n,
|
|
154
|
-
y as o,
|
|
155
|
-
it as p,
|
|
156
|
-
H as q,
|
|
157
|
-
Z as r,
|
|
158
|
-
Q as s,
|
|
159
|
-
S as t,
|
|
160
|
-
v as u,
|
|
161
|
-
V as v,
|
|
162
|
-
Ct as w,
|
|
163
|
-
dt as x
|
|
164
|
-
};
|
package/dist-lib/toc-Dj57zdz-.js
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
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,151 +0,0 @@
|
|
|
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
|
-
}
|
|
5
|
-
class l {
|
|
6
|
-
handle = null;
|
|
7
|
-
ready;
|
|
8
|
-
handlers = /* @__PURE__ */ new Map();
|
|
9
|
-
constructor(e) {
|
|
10
|
-
this.ready = new Promise((t) => {
|
|
11
|
-
const r = {
|
|
12
|
-
container: e.container,
|
|
13
|
-
backendUrl: e.backendUrl,
|
|
14
|
-
// `docId` is the canonical name; fall back to the deprecated `collabId`.
|
|
15
|
-
collabId: e.docId ?? e.collabId,
|
|
16
|
-
user: e.user,
|
|
17
|
-
onShareLink: e.onShareLink,
|
|
18
|
-
readonly: e.readonly,
|
|
19
|
-
mode: e.mode,
|
|
20
|
-
allowedModes: e.allowedModes,
|
|
21
|
-
knownUsers: e.knownUsers,
|
|
22
|
-
resolveField: e.resolveField,
|
|
23
|
-
agentTools: e.agentTools,
|
|
24
|
-
view: e.view,
|
|
25
|
-
onLoadProgress: e.onLoadProgress,
|
|
26
|
-
onReady: (n) => {
|
|
27
|
-
this.handle = n, t(n);
|
|
28
|
-
},
|
|
29
|
-
onEvent: (n) => this.emit(n)
|
|
30
|
-
};
|
|
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)));
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
/** Subscribe to a collaboration event. Returns an unsubscribe function. */
|
|
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);
|
|
38
|
-
}
|
|
39
|
-
/** Unsubscribe a handler previously passed to on(). */
|
|
40
|
-
off(e, t) {
|
|
41
|
-
this.handlers.get(e)?.delete(t);
|
|
42
|
-
}
|
|
43
|
-
emit(e) {
|
|
44
|
-
const { type: t, ...r } = e;
|
|
45
|
-
for (const n of this.handlers.get(t) ?? []) n(r);
|
|
46
|
-
}
|
|
47
|
-
/** Resolves once the editor is mounted and ready. */
|
|
48
|
-
whenReady() {
|
|
49
|
-
return this.ready;
|
|
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
|
-
}
|
|
76
|
-
/** Open a .docx. When online, auto-publishes it and surfaces a share link. */
|
|
77
|
-
async openDocx(e) {
|
|
78
|
-
return (await this.ready).openDocx(e);
|
|
79
|
-
}
|
|
80
|
-
/** Replace the open document with a programmatically-built one (e.g. a
|
|
81
|
-
* DocumentBuilder result). The input is cloned. Like openDocx, this starts
|
|
82
|
-
* a NEW document: undo history and any live collab session are dropped
|
|
83
|
-
* (the next share() forks). Zoom and scroll position are preserved, so
|
|
84
|
-
* calling this on every data change gives a stable live preview. */
|
|
85
|
-
async setDocument(e) {
|
|
86
|
-
(await this.ready).setDocument(e);
|
|
87
|
-
}
|
|
88
|
-
/** Publish the current document and resolve its shareable link (online only). */
|
|
89
|
-
async share() {
|
|
90
|
-
return (await this.ready).share();
|
|
91
|
-
}
|
|
92
|
-
// ---- review layer (track changes + comments) ----------------------------
|
|
93
|
-
/** Current editor mode. Returns null before the editor is ready. */
|
|
94
|
-
getMode() {
|
|
95
|
-
return this.handle?.getMode() ?? null;
|
|
96
|
-
}
|
|
97
|
-
/** Switch mode. Resolves to false if the mode isn't allowed (or not ready). */
|
|
98
|
-
async setMode(e) {
|
|
99
|
-
return (await this.ready).setMode(e);
|
|
100
|
-
}
|
|
101
|
-
/** Snapshot of the review overlay (suggestions + comment threads). */
|
|
102
|
-
async getReview() {
|
|
103
|
-
return (await this.ready).getReview();
|
|
104
|
-
}
|
|
105
|
-
/** The effective @-mentionable roster: the configured base PLUS whoever is
|
|
106
|
-
* live-editing the document right now (auto-merged from presence). */
|
|
107
|
-
async getKnownUsers() {
|
|
108
|
-
return (await this.ready).getKnownUsers();
|
|
109
|
-
}
|
|
110
|
-
/** Replace the configured base roster (live editors are still merged on top). */
|
|
111
|
-
async setKnownUsers(e) {
|
|
112
|
-
(await this.ready).setKnownUsers(e);
|
|
113
|
-
}
|
|
114
|
-
async acceptSuggestion(e) {
|
|
115
|
-
(await this.ready).acceptSuggestion(e);
|
|
116
|
-
}
|
|
117
|
-
async rejectSuggestion(e) {
|
|
118
|
-
(await this.ready).rejectSuggestion(e);
|
|
119
|
-
}
|
|
120
|
-
async acceptAllSuggestions() {
|
|
121
|
-
(await this.ready).acceptAllSuggestions();
|
|
122
|
-
}
|
|
123
|
-
async rejectAllSuggestions() {
|
|
124
|
-
(await this.ready).rejectAllSuggestions();
|
|
125
|
-
}
|
|
126
|
-
/** Add a comment thread anchored to the current selection (a rich-text body;
|
|
127
|
-
* `mentions` are @-tagged users). Resolves to the thread id, or null if
|
|
128
|
-
* there's no selection. */
|
|
129
|
-
async addComment(e, t) {
|
|
130
|
-
return (await this.ready).addComment(e, t);
|
|
131
|
-
}
|
|
132
|
-
async replyToComment(e, t, r) {
|
|
133
|
-
(await this.ready).replyToComment(e, t, r);
|
|
134
|
-
}
|
|
135
|
-
async resolveThread(e, t = !0) {
|
|
136
|
-
(await this.ready).resolveThread(e, t);
|
|
137
|
-
}
|
|
138
|
-
getDocId() {
|
|
139
|
-
return this.handle?.getDocId() ?? null;
|
|
140
|
-
}
|
|
141
|
-
getShareLink() {
|
|
142
|
-
return this.handle?.getShareLink() ?? null;
|
|
143
|
-
}
|
|
144
|
-
destroy() {
|
|
145
|
-
this.handle?.destroy(), this.handle = null, this.handlers.clear();
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
export {
|
|
149
|
-
l as W,
|
|
150
|
-
i as f
|
|
151
|
-
};
|