@forevka/wordcanvas 0.7.1 → 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/dist-lib/assets/{worker-D8rUOKfg.js → worker-4HYrkNrG.js} +10873 -10730
- 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 +14 -13
- package/dist-lib/editorApp-mTD0YNv-.js +9863 -0
- package/dist-lib/export.js +4507 -4456
- package/dist-lib/generate-toc.js +5 -5
- package/dist-lib/import.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-B6VpkJge.js → toc-Dj57zdz-.js} +5 -5
- package/dist-lib/{webmcp-6WxRNKCc.js → webmcp-CXghUon_.js} +2 -2
- package/dist-lib/{wordcanvas-CFqpDK0k.js → wordcanvas-D5DI9ZR1.js} +49 -23
- package/dist-lib/wordcanvas.js +1 -1
- package/dist-node/{chunk-22JHAERT.js → chunk-57L5XMCL.js} +235 -39
- package/dist-node/chunk-57L5XMCL.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-6AJJMHKY.js → chunk-KJV7GJ3H.js} +1 -1
- package/dist-node/chunk-KJV7GJ3H.js.map +7 -0
- package/dist-node/{chunk-CDN6WU2P.js → chunk-PIMVQULL.js} +7 -1
- package/dist-node/chunk-PIMVQULL.js.map +7 -0
- package/dist-node/{chunk-BRAPV465.js → chunk-SA26UVIJ.js} +2 -2
- package/dist-node/{chunk-RNB336F3.js → chunk-T3253N22.js} +92 -14
- package/dist-node/{chunk-RNB336F3.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-5FGDJD2H.js → engine-5F7DUU4W.js} +4 -4
- package/dist-node/export.js +89 -24
- package/dist-node/export.js.map +2 -2
- package/dist-node/generate-toc.js +6 -6
- package/dist-node/import.js +3 -3
- package/dist-node/measure.js +2 -2
- package/dist-node/recalc-docx.js +4 -4
- package/package.json +1 -1
- package/types/model.d.ts +46 -0
- package/types/wordcanvas.d.ts +212 -157
- package/dist-lib/assets/worker-wXuuyshQ.js +0 -2258
- package/dist-lib/blockFactory-CUI4Rqiq.js +0 -186
- package/dist-lib/browser-DkKxreJM.js +0 -1305
- package/dist-lib/editorApp-DLXMmtu5.js +0 -8023
- package/dist-lib/metrics-CkAo4zh8.js +0 -143
- package/dist-lib/pipeline-CbxmCE84.js +0 -1705
- package/dist-lib/recalcToc-g1hFKSNs.js +0 -3935
- package/dist-lib/styleProps-Db5pEkG8.js +0 -127
- package/dist-node/chunk-22JHAERT.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-6AJJMHKY.js.map +0 -7
- package/dist-node/chunk-CDN6WU2P.js.map +0 -7
- /package/dist-node/{chunk-BRAPV465.js.map → chunk-SA26UVIJ.js.map} +0 -0
- /package/dist-node/{engine-5FGDJD2H.js.map → engine-5F7DUU4W.js.map} +0 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
const l = (e) => Number.isFinite(e) ? e : 0, s = (e) => Math.round(l(e) * 15), d = (e) => Math.round(l(e) * 1.5), z = (e) => Math.round(l(e) * 9525), L = (e) => Math.max(2, Math.round(l(e) * 6)), w = (e) => Math.round(l(e) * 240), c = {
|
|
2
|
+
"#ffff00": "yellow",
|
|
3
|
+
"#00ff00": "green",
|
|
4
|
+
"#00ffff": "cyan",
|
|
5
|
+
"#ff00ff": "magenta",
|
|
6
|
+
"#0000ff": "blue",
|
|
7
|
+
"#ff0000": "red",
|
|
8
|
+
"#000080": "darkBlue",
|
|
9
|
+
"#008080": "darkCyan",
|
|
10
|
+
"#008000": "darkGreen",
|
|
11
|
+
"#800080": "darkMagenta",
|
|
12
|
+
"#800000": "darkRed",
|
|
13
|
+
"#808000": "darkYellow",
|
|
14
|
+
"#808080": "darkGray",
|
|
15
|
+
"#c0c0c0": "lightGray",
|
|
16
|
+
"#000000": "black",
|
|
17
|
+
"#ffffff": "white"
|
|
18
|
+
}, u = { left: "left", center: "center", right: "right", justify: "both" }, p = { left: "left", center: "center", right: "right", decimal: "decimal" }, g = { dot: "dot", dash: "hyphen", underscore: "underscore" }, f = (e) => e.replace(/^#/, "").toLowerCase();
|
|
19
|
+
function m(e) {
|
|
20
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
21
|
+
}
|
|
22
|
+
function k(e) {
|
|
23
|
+
return m(e).replace(/"/g, """);
|
|
24
|
+
}
|
|
25
|
+
function A(e) {
|
|
26
|
+
if (!e) return "";
|
|
27
|
+
let t = "";
|
|
28
|
+
for (const [i, o] of Object.entries(e))
|
|
29
|
+
o === void 0 || o === !1 || (t += ` ${i}="${k(String(o))}"`);
|
|
30
|
+
return t;
|
|
31
|
+
}
|
|
32
|
+
function n(e, t, i) {
|
|
33
|
+
const o = A(t);
|
|
34
|
+
return i === void 0 || i === "" ? `<${e}${o}/>` : `<${e}${o}>${i}</${e}>`;
|
|
35
|
+
}
|
|
36
|
+
function F(e) {
|
|
37
|
+
const t = /^\s|\s$|\s\s/.test(e) || e.includes(" ");
|
|
38
|
+
return n("w:t", t ? { "xml:space": "preserve" } : void 0, m(e));
|
|
39
|
+
}
|
|
40
|
+
const B = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
41
|
+
`, C = {
|
|
42
|
+
"xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
|
43
|
+
"xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
|
44
|
+
"xmlns:wp": "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
|
|
45
|
+
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
|
|
46
|
+
"xmlns:pic": "http://schemas.openxmlformats.org/drawingml/2006/picture",
|
|
47
|
+
"xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml",
|
|
48
|
+
"xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
49
|
+
};
|
|
50
|
+
function T(e) {
|
|
51
|
+
const t = (e.fontFamily.split(",")[0] ?? "").trim(), i = [];
|
|
52
|
+
if (e.charStyleId && i.push(n("w:rStyle", { "w:val": e.charStyleId })), t && i.push(n("w:rFonts", { "w:ascii": t, "w:hAnsi": t, "w:cs": t })), i.push(n("w:b", { "w:val": e.bold ? "1" : "0" })), i.push(n("w:i", { "w:val": e.italic ? "1" : "0" })), e.strikethrough && i.push(n("w:strike", { "w:val": "1" })), e.hidden && i.push(n("w:vanish", { "w:val": "1" })), i.push(n("w:color", { "w:val": f(e.color) })), i.push(n("w:sz", { "w:val": d(e.fontSizePx) })), i.push(n("w:szCs", { "w:val": d(e.fontSizePx) })), i.push(n("w:u", { "w:val": e.underline ? "single" : "none" })), e.letterSpacingPx !== void 0 && i.push(n("w:spacing", { "w:val": s(e.letterSpacingPx) })), e.highlightColor) {
|
|
53
|
+
const o = c[e.highlightColor.toLowerCase()];
|
|
54
|
+
o && i.push(n("w:highlight", { "w:val": o }));
|
|
55
|
+
}
|
|
56
|
+
return e.verticalAlign && i.push(n("w:vertAlign", { "w:val": e.verticalAlign === "super" ? "superscript" : "subscript" })), n("w:rPr", void 0, i.join(""));
|
|
57
|
+
}
|
|
58
|
+
function M(e) {
|
|
59
|
+
const t = [];
|
|
60
|
+
t.push(n("w:spacing", {
|
|
61
|
+
"w:before": s(e.spaceBeforePx),
|
|
62
|
+
"w:after": s(e.spaceAfterPx),
|
|
63
|
+
"w:line": w(e.lineHeight),
|
|
64
|
+
"w:lineRule": "auto"
|
|
65
|
+
}));
|
|
66
|
+
const i = {};
|
|
67
|
+
if (e.indentLeftPx && (i["w:left"] = s(e.indentLeftPx)), e.indentRightPx && (i["w:right"] = s(e.indentRightPx)), e.indentFirstLinePx > 0 ? i["w:firstLine"] = s(e.indentFirstLinePx) : e.indentFirstLinePx < 0 && (i["w:hanging"] = s(-e.indentFirstLinePx)), Object.keys(i).length > 0 && t.push(n("w:ind", i)), t.push(n("w:jc", { "w:val": u[e.align] })), e.tabStops && e.tabStops.length > 0) {
|
|
68
|
+
const o = e.tabStops.map(
|
|
69
|
+
(r) => n("w:tab", {
|
|
70
|
+
"w:val": r.align ? p[r.align] ?? "left" : "left",
|
|
71
|
+
"w:pos": s(r.posPx),
|
|
72
|
+
"w:leader": r.leader && r.leader !== "none" ? g[r.leader] : void 0
|
|
73
|
+
})
|
|
74
|
+
).join("");
|
|
75
|
+
t.push(n("w:tabs", void 0, o));
|
|
76
|
+
}
|
|
77
|
+
return t.join("");
|
|
78
|
+
}
|
|
79
|
+
function v(e) {
|
|
80
|
+
const t = [];
|
|
81
|
+
if (e.fontFamily) {
|
|
82
|
+
const i = (e.fontFamily.split(",")[0] ?? "").trim();
|
|
83
|
+
i && t.push(n("w:rFonts", { "w:ascii": i, "w:hAnsi": i, "w:cs": i }));
|
|
84
|
+
}
|
|
85
|
+
if (e.bold !== void 0 && t.push(n("w:b", { "w:val": e.bold ? "1" : "0" })), e.italic !== void 0 && t.push(n("w:i", { "w:val": e.italic ? "1" : "0" })), e.strikethrough !== void 0 && t.push(n("w:strike", { "w:val": e.strikethrough ? "1" : "0" })), e.color && t.push(n("w:color", { "w:val": f(e.color) })), e.fontSizePx !== void 0) {
|
|
86
|
+
const i = Math.round(e.fontSizePx * 1.5);
|
|
87
|
+
t.push(n("w:sz", { "w:val": i })), t.push(n("w:szCs", { "w:val": i }));
|
|
88
|
+
}
|
|
89
|
+
if (e.underline !== void 0 && t.push(n("w:u", { "w:val": e.underline ? "single" : "none" })), e.highlightColor) {
|
|
90
|
+
const i = c[e.highlightColor.toLowerCase()];
|
|
91
|
+
i && t.push(n("w:highlight", { "w:val": i }));
|
|
92
|
+
}
|
|
93
|
+
return e.verticalAlign && t.push(n("w:vertAlign", { "w:val": e.verticalAlign === "super" ? "superscript" : "subscript" })), t.length > 0 ? n("w:rPr", void 0, t.join("")) : "";
|
|
94
|
+
}
|
|
95
|
+
function x(e) {
|
|
96
|
+
const t = [];
|
|
97
|
+
e.align && t.push(n("w:jc", { "w:val": u[e.align] ?? "left" }));
|
|
98
|
+
const i = {};
|
|
99
|
+
e.spaceBeforePx !== void 0 && (i["w:before"] = s(e.spaceBeforePx)), e.spaceAfterPx !== void 0 && (i["w:after"] = s(e.spaceAfterPx)), e.lineHeight !== void 0 && (i["w:line"] = w(e.lineHeight), i["w:lineRule"] = "auto"), Object.keys(i).length > 0 && t.push(n("w:spacing", i));
|
|
100
|
+
const o = {};
|
|
101
|
+
if (e.indentLeftPx !== void 0 && (o["w:left"] = s(e.indentLeftPx)), e.indentRightPx !== void 0 && (o["w:right"] = s(e.indentRightPx)), e.indentFirstLinePx !== void 0 && (e.indentFirstLinePx >= 0 ? o["w:firstLine"] = s(e.indentFirstLinePx) : o["w:hanging"] = s(-e.indentFirstLinePx)), Object.keys(o).length > 0 && t.push(n("w:ind", o)), e.keepWithNext && t.push(n("w:keepNext")), e.keepLinesTogether && t.push(n("w:keepLines")), e.tabStops && e.tabStops.length > 0) {
|
|
102
|
+
const r = e.tabStops.map(
|
|
103
|
+
(a) => n("w:tab", {
|
|
104
|
+
"w:val": a.align ? p[a.align] ?? "left" : "left",
|
|
105
|
+
"w:pos": s(a.posPx),
|
|
106
|
+
"w:leader": a.leader && a.leader !== "none" ? g[a.leader] : void 0
|
|
107
|
+
})
|
|
108
|
+
).join("");
|
|
109
|
+
t.push(n("w:tabs", void 0, r));
|
|
110
|
+
}
|
|
111
|
+
return t.length > 0 ? n("w:pPr", void 0, t.join("")) : "";
|
|
112
|
+
}
|
|
113
|
+
function b(e, t) {
|
|
114
|
+
const i = (o, r) => {
|
|
115
|
+
if (!r) return "";
|
|
116
|
+
const a = r.style === "double" ? "double" : r.style === "dashed" ? "dashed" : r.style === "dotted" ? "dotted" : "single";
|
|
117
|
+
return n("w:" + o, { "w:val": a, "w:sz": L(r.widthPx), "w:space": 0, "w:color": f(r.color) });
|
|
118
|
+
};
|
|
119
|
+
return n(e, void 0, i("top", t.top) + i("left", t.left) + i("bottom", t.bottom) + i("right", t.right));
|
|
120
|
+
}
|
|
121
|
+
const P = (e) => n("w:shd", { "w:val": "clear", "w:color": "auto", "w:fill": f(e) });
|
|
122
|
+
function j(e, t) {
|
|
123
|
+
const i = [];
|
|
124
|
+
t.borders && i.push(b("w:tcBorders", t.borders)), t.shading && i.push(P(t.shading));
|
|
125
|
+
const o = i.length > 0 ? n("w:tcPr", void 0, i.join("")) : "";
|
|
126
|
+
return n("w:tblStylePr", { "w:type": e }, v(t.char ?? {}) + x(t.para ?? {}) + o);
|
|
127
|
+
}
|
|
128
|
+
function R(e) {
|
|
129
|
+
const t = e.conds.wholeTable ?? {}, i = [];
|
|
130
|
+
e.rowBandSize !== void 0 && i.push(n("w:tblStyleRowBandSize", { "w:val": e.rowBandSize })), e.colBandSize !== void 0 && i.push(n("w:tblStyleColBandSize", { "w:val": e.colBandSize })), t.borders && i.push(b("w:tblBorders", t.borders)), t.shading && i.push(P(t.shading));
|
|
131
|
+
const o = i.length > 0 ? n("w:tblPr", void 0, i.join("")) : "", r = Object.entries(e.conds).filter(([h]) => h !== "wholeTable").map(([h, S]) => j(h, S)).join(""), a = n("w:name", { "w:val": e.name }) + (e.basedOn ? n("w:basedOn", { "w:val": e.basedOn }) : "") + v(t.char ?? {}) + x(t.para ?? {}) + o + r;
|
|
132
|
+
return n("w:style", { "w:type": "table", "w:styleId": e.id }, a);
|
|
133
|
+
}
|
|
134
|
+
export {
|
|
135
|
+
C as W,
|
|
136
|
+
B as X,
|
|
137
|
+
m as a,
|
|
138
|
+
M as b,
|
|
139
|
+
z as c,
|
|
140
|
+
L as d,
|
|
141
|
+
n as e,
|
|
142
|
+
v as f,
|
|
143
|
+
x as g,
|
|
144
|
+
f as h,
|
|
145
|
+
R as i,
|
|
146
|
+
s as p,
|
|
147
|
+
T as r,
|
|
148
|
+
F as t
|
|
149
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { p as u } from "./browser-p_rkUcqE.js";
|
|
2
|
+
function p(e) {
|
|
3
|
+
return e.type ?? "paragraph";
|
|
4
|
+
}
|
|
5
|
+
function c(e, t) {
|
|
6
|
+
return e.styles.find((a) => a.id === t);
|
|
7
|
+
}
|
|
8
|
+
function m(e, t) {
|
|
9
|
+
const a = [], r = /* @__PURE__ */ new Set();
|
|
10
|
+
for (let s = c(e, t); s && !r.has(s.id); s = s.basedOn ? c(e, s.basedOn) : void 0)
|
|
11
|
+
r.add(s.id), a.unshift(s);
|
|
12
|
+
const o = {}, n = {};
|
|
13
|
+
for (const s of a)
|
|
14
|
+
Object.assign(o, d(s.char)), Object.assign(n, d(s.para));
|
|
15
|
+
return { char: o, para: n };
|
|
16
|
+
}
|
|
17
|
+
function g(e, t) {
|
|
18
|
+
const a = [], r = /* @__PURE__ */ new Set();
|
|
19
|
+
for (let n = c(e, t); n && !r.has(n.id); n = n.basedOn ? c(e, n.basedOn) : void 0)
|
|
20
|
+
r.add(n.id), a.unshift(n);
|
|
21
|
+
const o = {};
|
|
22
|
+
for (const n of a) Object.assign(o, d(n.char));
|
|
23
|
+
return o;
|
|
24
|
+
}
|
|
25
|
+
function b(e, t) {
|
|
26
|
+
const a = /* @__PURE__ */ new Set();
|
|
27
|
+
let r = !0;
|
|
28
|
+
for (; r; ) {
|
|
29
|
+
r = !1;
|
|
30
|
+
for (const o of e.styles)
|
|
31
|
+
a.has(o.id) || o.basedOn !== void 0 && (o.basedOn === t || a.has(o.basedOn)) && (a.add(o.id), r = !0);
|
|
32
|
+
}
|
|
33
|
+
return a;
|
|
34
|
+
}
|
|
35
|
+
function O(e, t, a) {
|
|
36
|
+
return a ? a === t ? !0 : b(e, t).has(a) : !1;
|
|
37
|
+
}
|
|
38
|
+
function y(e) {
|
|
39
|
+
const t = (a) => Object.entries(d(a)).sort(([r], [o]) => r < o ? -1 : r > o ? 1 : 0);
|
|
40
|
+
return JSON.stringify([p(e), e.basedOn ?? "", t(e.char), t(e.para)]);
|
|
41
|
+
}
|
|
42
|
+
function S(e) {
|
|
43
|
+
const t = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
44
|
+
for (const n of e.styles) {
|
|
45
|
+
const s = y(n), i = a.get(s);
|
|
46
|
+
if (i === void 0)
|
|
47
|
+
a.set(s, n.id);
|
|
48
|
+
else if (n.id === e.defaultStyleId) {
|
|
49
|
+
a.set(s, n.id), t.set(i, n.id);
|
|
50
|
+
for (const [f, l] of t) l === i && t.set(f, n.id);
|
|
51
|
+
} else
|
|
52
|
+
t.set(n.id, i);
|
|
53
|
+
}
|
|
54
|
+
if (t.size === 0) return { sheet: e, remap: t };
|
|
55
|
+
const r = (n) => t.get(n) ?? n, o = [];
|
|
56
|
+
for (const n of e.styles) {
|
|
57
|
+
if (t.has(n.id)) continue;
|
|
58
|
+
const s = { ...n };
|
|
59
|
+
if (s.basedOn !== void 0) {
|
|
60
|
+
const i = r(s.basedOn);
|
|
61
|
+
i === s.id ? delete s.basedOn : s.basedOn = i;
|
|
62
|
+
}
|
|
63
|
+
o.push(s);
|
|
64
|
+
}
|
|
65
|
+
return { sheet: { styles: o, defaultStyleId: r(e.defaultStyleId) }, remap: t };
|
|
66
|
+
}
|
|
67
|
+
function d(e) {
|
|
68
|
+
const t = {};
|
|
69
|
+
for (const [a, r] of Object.entries(e))
|
|
70
|
+
r !== void 0 && (t[a] = r);
|
|
71
|
+
return t;
|
|
72
|
+
}
|
|
73
|
+
function x(e, t) {
|
|
74
|
+
return u(e).filter((a) => a.style.namedStyle === t);
|
|
75
|
+
}
|
|
76
|
+
function P() {
|
|
77
|
+
return {
|
|
78
|
+
defaultStyleId: "Normal",
|
|
79
|
+
styles: [
|
|
80
|
+
{
|
|
81
|
+
id: "Normal",
|
|
82
|
+
name: "Normal",
|
|
83
|
+
char: { fontFamily: "Georgia, serif", fontSizePx: 16, bold: !1, italic: !1, color: "#202124" },
|
|
84
|
+
para: { ...{ lineHeight: 1.5, spaceBeforePx: 0, spaceAfterPx: 12 }, align: "left", indentFirstLinePx: 0 }
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: "Title",
|
|
88
|
+
name: "Title",
|
|
89
|
+
basedOn: "Normal",
|
|
90
|
+
char: { fontFamily: "Arial, sans-serif", fontSizePx: 32, bold: !0, color: "#1a1a2e" },
|
|
91
|
+
para: { align: "center", spaceAfterPx: 4 }
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: "Subtitle",
|
|
95
|
+
name: "Subtitle",
|
|
96
|
+
basedOn: "Normal",
|
|
97
|
+
char: { italic: !0, color: "#5f6368" },
|
|
98
|
+
para: { align: "center", spaceAfterPx: 28 }
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: "Heading1",
|
|
102
|
+
name: "Heading 1",
|
|
103
|
+
basedOn: "Normal",
|
|
104
|
+
char: { fontFamily: "Arial, sans-serif", fontSizePx: 24, bold: !0, color: "#1a1a2e" },
|
|
105
|
+
para: { spaceBeforePx: 18, spaceAfterPx: 8, keepWithNext: !0 }
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
id: "Heading2",
|
|
109
|
+
name: "Heading 2",
|
|
110
|
+
basedOn: "Heading1",
|
|
111
|
+
char: { fontSizePx: 19 },
|
|
112
|
+
para: { spaceBeforePx: 14, spaceAfterPx: 6 }
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
id: "Quote",
|
|
116
|
+
name: "Quote",
|
|
117
|
+
basedOn: "Normal",
|
|
118
|
+
char: { italic: !0, color: "#5f6368" },
|
|
119
|
+
para: { indentLeftPx: 36, spaceBeforePx: 8, spaceAfterPx: 8 }
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
id: "Code",
|
|
123
|
+
name: "Code",
|
|
124
|
+
basedOn: "Normal",
|
|
125
|
+
char: { fontFamily: "Consolas, monospace", fontSizePx: 14, color: "#0b57d0" },
|
|
126
|
+
para: { lineHeight: 1.35 }
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
export {
|
|
132
|
+
p as a,
|
|
133
|
+
m as b,
|
|
134
|
+
b as c,
|
|
135
|
+
P as d,
|
|
136
|
+
S as m,
|
|
137
|
+
x as p,
|
|
138
|
+
g as r,
|
|
139
|
+
c as s,
|
|
140
|
+
O as w
|
|
141
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as b,
|
|
1
|
+
import { t as b, x as k, A as v } from "./browser-p_rkUcqE.js";
|
|
2
2
|
function y(t, e = 0) {
|
|
3
3
|
let i = e;
|
|
4
4
|
return {
|
|
@@ -8,13 +8,13 @@ function y(t, e = 0) {
|
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
let h = y("local");
|
|
11
|
-
function
|
|
11
|
+
function A(t, e = 0) {
|
|
12
12
|
h = y(t, e);
|
|
13
13
|
}
|
|
14
14
|
function g() {
|
|
15
15
|
return h.next();
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function E() {
|
|
18
18
|
return h.siteId;
|
|
19
19
|
}
|
|
20
20
|
const m = (t) => {
|
|
@@ -200,9 +200,9 @@ function W(t, e = {}) {
|
|
|
200
200
|
export {
|
|
201
201
|
T as a,
|
|
202
202
|
B as b,
|
|
203
|
-
|
|
203
|
+
E as c,
|
|
204
204
|
R as d,
|
|
205
|
-
|
|
205
|
+
A as e,
|
|
206
206
|
g as f,
|
|
207
207
|
W as g,
|
|
208
208
|
y as h,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as j,
|
|
1
|
+
import { p as j, d as _, q as F, t as k } from "./browser-p_rkUcqE.js";
|
|
2
2
|
const s = (e) => Math.round(e * 100) / 100;
|
|
3
3
|
function L(e) {
|
|
4
4
|
const o = { font: e.fontFamily, sizePx: e.fontSizePx };
|
|
@@ -339,7 +339,7 @@ function Y(e, o = {}, r = {}) {
|
|
|
339
339
|
if (i && e.search(i).total === 0)
|
|
340
340
|
return e.searchClear(), f(`text not found: ${i}`);
|
|
341
341
|
if (!e.getSelection()) return f("no selection (pass 'find' or select_range first)");
|
|
342
|
-
const { insertText: l } = await import("./editorApp-
|
|
342
|
+
const { insertText: l } = await import("./editorApp-mTD0YNv-.js").then((m) => m.c);
|
|
343
343
|
return e.dispatch(l(t)), i && e.searchClear(), g("inserted");
|
|
344
344
|
}
|
|
345
345
|
}), a({
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
3
|
-
return { phase: "fonts", loaded:
|
|
1
|
+
function i(a, e) {
|
|
2
|
+
const t = e > 0 ? a / e : 1;
|
|
3
|
+
return { phase: "fonts", loaded: a, total: e, percent: 0.15 + (1 - 0.15) * t };
|
|
4
4
|
}
|
|
5
|
-
class
|
|
5
|
+
class l {
|
|
6
6
|
handle = null;
|
|
7
7
|
ready;
|
|
8
8
|
handlers = /* @__PURE__ */ new Map();
|
|
9
9
|
constructor(e) {
|
|
10
|
-
this.ready = new Promise((
|
|
11
|
-
const
|
|
10
|
+
this.ready = new Promise((t) => {
|
|
11
|
+
const r = {
|
|
12
12
|
container: e.container,
|
|
13
13
|
backendUrl: e.backendUrl,
|
|
14
14
|
// `docId` is the canonical name; fall back to the deprecated `collabId`.
|
|
@@ -21,32 +21,58 @@ class o {
|
|
|
21
21
|
knownUsers: e.knownUsers,
|
|
22
22
|
resolveField: e.resolveField,
|
|
23
23
|
agentTools: e.agentTools,
|
|
24
|
+
view: e.view,
|
|
24
25
|
onLoadProgress: e.onLoadProgress,
|
|
25
26
|
onReady: (n) => {
|
|
26
|
-
this.handle = n,
|
|
27
|
+
this.handle = n, t(n);
|
|
27
28
|
},
|
|
28
29
|
onEvent: (n) => this.emit(n)
|
|
29
30
|
};
|
|
30
|
-
e.onLoadProgress?.({ phase: "bundle", percent: 0, loaded: 0, total: 0 }), import("./editorApp-
|
|
31
|
+
e.onLoadProgress?.({ phase: "bundle", percent: 0, loaded: 0, total: 0 }), import("./editorApp-mTD0YNv-.js").then((n) => n.e).then((n) => (e.onLoadProgress?.({ phase: "bundle", percent: 0.15, loaded: 0, total: 0 }), n.mountEditorApp(r)));
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
/** Subscribe to a collaboration event. Returns an unsubscribe function. */
|
|
34
|
-
on(e,
|
|
35
|
-
let
|
|
36
|
-
return
|
|
35
|
+
on(e, t) {
|
|
36
|
+
let r = this.handlers.get(e);
|
|
37
|
+
return r || this.handlers.set(e, r = /* @__PURE__ */ new Set()), r.add(t), () => this.off(e, t);
|
|
37
38
|
}
|
|
38
39
|
/** Unsubscribe a handler previously passed to on(). */
|
|
39
|
-
off(e,
|
|
40
|
-
this.handlers.get(e)?.delete(
|
|
40
|
+
off(e, t) {
|
|
41
|
+
this.handlers.get(e)?.delete(t);
|
|
41
42
|
}
|
|
42
43
|
emit(e) {
|
|
43
|
-
const { type:
|
|
44
|
-
for (const n of this.handlers.get(
|
|
44
|
+
const { type: t, ...r } = e;
|
|
45
|
+
for (const n of this.handlers.get(t) ?? []) n(r);
|
|
45
46
|
}
|
|
46
47
|
/** Resolves once the editor is mounted and ready. */
|
|
47
48
|
whenReady() {
|
|
48
49
|
return this.ready;
|
|
49
50
|
}
|
|
51
|
+
/** Create a child document that shares this editor's live styles, fonts and
|
|
52
|
+
* theme. Use it to render a real, document-styled preview of a content slice
|
|
53
|
+
* (e.g. a style sample, a field result, or any blocks/fragment/OOXML) onto a
|
|
54
|
+
* canvas — instead of an HTML approximation — or to mount a canvas-native
|
|
55
|
+
* editor over a slice. Returned synchronously; render() calls before the editor
|
|
56
|
+
* is ready are buffered and flush on ready. (mountEditor() requires the editor
|
|
57
|
+
* to be ready — await whenReady() first.) */
|
|
58
|
+
createChild() {
|
|
59
|
+
let e = null, t = null, r = !1;
|
|
60
|
+
return this.ready.then((n) => {
|
|
61
|
+
r || (e = n.createChild(), t?.(), t = null);
|
|
62
|
+
}), {
|
|
63
|
+
render: (n, s, o) => {
|
|
64
|
+
const d = () => e?.render(n, s, o);
|
|
65
|
+
e ? d() : t = d;
|
|
66
|
+
},
|
|
67
|
+
mountEditor: (n, s, o) => {
|
|
68
|
+
if (!e) throw new Error("WordCanvas.createChild(): await whenReady() before mountEditor()");
|
|
69
|
+
return e.mountEditor(n, s, o);
|
|
70
|
+
},
|
|
71
|
+
destroy: () => {
|
|
72
|
+
r = !0, e?.destroy(), e = null;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
50
76
|
/** Open a .docx. When online, auto-publishes it and surfaces a share link. */
|
|
51
77
|
async openDocx(e) {
|
|
52
78
|
return (await this.ready).openDocx(e);
|
|
@@ -100,14 +126,14 @@ class o {
|
|
|
100
126
|
/** Add a comment thread anchored to the current selection (a rich-text body;
|
|
101
127
|
* `mentions` are @-tagged users). Resolves to the thread id, or null if
|
|
102
128
|
* there's no selection. */
|
|
103
|
-
async addComment(e,
|
|
104
|
-
return (await this.ready).addComment(e,
|
|
129
|
+
async addComment(e, t) {
|
|
130
|
+
return (await this.ready).addComment(e, t);
|
|
105
131
|
}
|
|
106
|
-
async replyToComment(e,
|
|
107
|
-
(await this.ready).replyToComment(e,
|
|
132
|
+
async replyToComment(e, t, r) {
|
|
133
|
+
(await this.ready).replyToComment(e, t, r);
|
|
108
134
|
}
|
|
109
|
-
async resolveThread(e,
|
|
110
|
-
(await this.ready).resolveThread(e,
|
|
135
|
+
async resolveThread(e, t = !0) {
|
|
136
|
+
(await this.ready).resolveThread(e, t);
|
|
111
137
|
}
|
|
112
138
|
getDocId() {
|
|
113
139
|
return this.handle?.getDocId() ?? null;
|
|
@@ -120,6 +146,6 @@ class o {
|
|
|
120
146
|
}
|
|
121
147
|
}
|
|
122
148
|
export {
|
|
123
|
-
|
|
124
|
-
|
|
149
|
+
l as W,
|
|
150
|
+
i as f
|
|
125
151
|
};
|
package/dist-lib/wordcanvas.js
CHANGED