ai-word-editor 0.0.70 → 0.0.71
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/wordDocxImport.js +370 -344
- package/package.json +1 -1
package/dist/wordDocxImport.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { J as et } from "./jszip.min-CpHe4acG.js";
|
|
2
|
-
async function
|
|
3
|
-
const n = e.importWordDelRevision === !0, o = await t.arrayBuffer(),
|
|
2
|
+
async function pe(t, e = {}) {
|
|
3
|
+
const n = e.importWordDelRevision === !0, o = await t.arrayBuffer(), s = await et.loadAsync(o), a = s.file("word/comments.xml");
|
|
4
4
|
if (!a) return [];
|
|
5
|
-
const
|
|
5
|
+
const c = await a.async("text"), u = ct(c), r = /* @__PURE__ */ new Map(), i = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", d = u.getElementsByTagNameNS(i, "comment");
|
|
6
6
|
for (const m of d) {
|
|
7
|
-
const A = m.getAttribute("w:id"), N = m.getAttribute("w:author") || "", b = m.getAttribute("w:date") || "",
|
|
8
|
-
r.set(A, { author: N, date: b, note:
|
|
7
|
+
const A = m.getAttribute("w:id"), N = m.getAttribute("w:author") || "", b = m.getAttribute("w:date") || "", T = Rt(m, i);
|
|
8
|
+
r.set(A, { author: N, date: b, note: T });
|
|
9
9
|
}
|
|
10
10
|
if (r.size === 0) return [];
|
|
11
|
-
const l =
|
|
12
|
-
if (!l) return
|
|
13
|
-
const f = await l.async("text"), g = ct(f), { selectedTextMap: w, containsDelTextMap: h } =
|
|
11
|
+
const l = s.file("word/document.xml");
|
|
12
|
+
if (!l) return Gt(r);
|
|
13
|
+
const f = await l.async("text"), g = ct(f), { selectedTextMap: w, containsDelTextMap: h } = Vt(
|
|
14
14
|
g,
|
|
15
|
-
|
|
15
|
+
i,
|
|
16
16
|
n
|
|
17
17
|
), y = [];
|
|
18
18
|
for (const [m, A] of r)
|
|
@@ -29,36 +29,36 @@ async function fe(t, e = {}) {
|
|
|
29
29
|
function ct(t) {
|
|
30
30
|
return new DOMParser().parseFromString(t, "application/xml");
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function Rt(t, e) {
|
|
33
33
|
return [...t.getElementsByTagNameNS(e, "t")].map((o) => o.textContent).join("");
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
const o = /* @__PURE__ */ new Map(),
|
|
35
|
+
function Vt(t, e, n) {
|
|
36
|
+
const o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), u = t.getElementsByTagNameNS(e, "body")[0];
|
|
37
37
|
return u ? (ut(
|
|
38
38
|
u,
|
|
39
39
|
e,
|
|
40
40
|
a,
|
|
41
|
-
|
|
41
|
+
c,
|
|
42
42
|
o,
|
|
43
|
-
|
|
43
|
+
s,
|
|
44
44
|
n
|
|
45
|
-
), { selectedTextMap: o, containsDelTextMap:
|
|
45
|
+
), { selectedTextMap: o, containsDelTextMap: s }) : { selectedTextMap: o, containsDelTextMap: s };
|
|
46
46
|
}
|
|
47
|
-
function ut(t, e, n, o,
|
|
47
|
+
function ut(t, e, n, o, s, a, c) {
|
|
48
48
|
for (const u of t.childNodes) {
|
|
49
49
|
const r = u.localName;
|
|
50
50
|
if (r === "commentRangeStart") {
|
|
51
|
-
const
|
|
52
|
-
|
|
51
|
+
const i = u.getAttribute("w:id");
|
|
52
|
+
i && (n.set(i, ""), o.set(i, !1));
|
|
53
53
|
} else if (r === "commentRangeEnd") {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
} else if (r === "t" ||
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
54
|
+
const i = u.getAttribute("w:id");
|
|
55
|
+
i && n.has(i) && (s.set(i, n.get(i)), a.set(i, !!o.get(i)), n.delete(i), o.delete(i));
|
|
56
|
+
} else if (r === "t" || c && r === "delText") {
|
|
57
|
+
const i = u.textContent;
|
|
58
|
+
if (i && n.size > 0)
|
|
59
59
|
for (const [d, l] of n)
|
|
60
|
-
n.set(d, l +
|
|
61
|
-
if (
|
|
60
|
+
n.set(d, l + i);
|
|
61
|
+
if (c && r === "delText")
|
|
62
62
|
for (const d of o.keys())
|
|
63
63
|
o.set(d, !0);
|
|
64
64
|
} else r === "instrText" || u.childNodes && u.childNodes.length > 0 && ut(
|
|
@@ -66,13 +66,13 @@ function ut(t, e, n, o, i, a, s) {
|
|
|
66
66
|
e,
|
|
67
67
|
n,
|
|
68
68
|
o,
|
|
69
|
-
|
|
69
|
+
s,
|
|
70
70
|
a,
|
|
71
|
-
|
|
71
|
+
c
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function Gt(t) {
|
|
76
76
|
return [...t.entries()].map(([e, n]) => ({
|
|
77
77
|
wordId: e,
|
|
78
78
|
author: n.author,
|
|
@@ -82,63 +82,63 @@ function Ot(t) {
|
|
|
82
82
|
}));
|
|
83
83
|
}
|
|
84
84
|
const nt = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", ft = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", dt = "http://schemas.openxmlformats.org/drawingml/2006/main", it = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing";
|
|
85
|
-
async function
|
|
86
|
-
const n = await t.arrayBuffer(), o = await et.loadAsync(n),
|
|
87
|
-
return await
|
|
85
|
+
async function ge(t, e = {}) {
|
|
86
|
+
const n = await t.arrayBuffer(), o = await et.loadAsync(n), s = await pt(o), a = await gt(o), c = await yt(o, a, e), u = e.importWordDelRevision === !0;
|
|
87
|
+
return await Zt(o, s, a, c, u);
|
|
88
88
|
}
|
|
89
|
-
async function
|
|
90
|
-
const n = await t.arrayBuffer(), o = await et.loadAsync(n),
|
|
91
|
-
return await
|
|
89
|
+
async function he(t, e = {}) {
|
|
90
|
+
const n = await t.arrayBuffer(), o = await et.loadAsync(n), s = await pt(o), a = await gt(o), c = await yt(o, a, e), u = e.importWordDelRevision === !0;
|
|
91
|
+
return await ie(o, s, a, c, u);
|
|
92
92
|
}
|
|
93
93
|
async function pt(t) {
|
|
94
94
|
const e = t.file("word/styles.xml");
|
|
95
95
|
if (!e) return /* @__PURE__ */ new Map();
|
|
96
|
-
const n = await e.async("text"), o =
|
|
96
|
+
const n = await e.async("text"), o = R(n), s = /* @__PURE__ */ new Map(), a = o.getElementsByTagNameNS(nt, "style");
|
|
97
97
|
for (const r of a) {
|
|
98
|
-
const
|
|
99
|
-
if (!
|
|
98
|
+
const i = r.getAttribute("w:styleId");
|
|
99
|
+
if (!i) continue;
|
|
100
100
|
const l = p(r, "basedOn")?.getAttribute("w:val") || null, f = p(r, "rPr"), g = p(r, "pPr");
|
|
101
|
-
|
|
101
|
+
s.set(i, {
|
|
102
102
|
basedOn: l,
|
|
103
|
-
rProps: f ?
|
|
103
|
+
rProps: f ? O(f) : {},
|
|
104
104
|
pProps: g ? ot(g) : {},
|
|
105
105
|
name: p(r, "name")?.getAttribute("w:val") || ""
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
|
-
const
|
|
109
|
-
const d =
|
|
108
|
+
const c = /* @__PURE__ */ new Map(), u = (r, i = /* @__PURE__ */ new Set()) => {
|
|
109
|
+
const d = c.get(r);
|
|
110
110
|
if (d) return d;
|
|
111
|
-
if (
|
|
112
|
-
|
|
113
|
-
const l =
|
|
111
|
+
if (i.has(r)) return { rProps: {}, pProps: {}, name: "" };
|
|
112
|
+
i.add(r);
|
|
113
|
+
const l = s.get(r);
|
|
114
114
|
if (!l) return { rProps: {}, pProps: {}, name: "" };
|
|
115
115
|
let f = { rProps: {}, pProps: {} };
|
|
116
|
-
l.basedOn && (f = u(l.basedOn,
|
|
116
|
+
l.basedOn && (f = u(l.basedOn, i));
|
|
117
117
|
const g = {
|
|
118
118
|
rProps: { ...f.rProps, ...l.rProps },
|
|
119
119
|
pProps: { ...f.pProps, ...l.pProps },
|
|
120
120
|
name: l.name
|
|
121
121
|
};
|
|
122
|
-
return
|
|
122
|
+
return c.set(r, g), g;
|
|
123
123
|
};
|
|
124
|
-
for (const r of
|
|
125
|
-
return
|
|
124
|
+
for (const r of s.keys()) u(r);
|
|
125
|
+
return c;
|
|
126
126
|
}
|
|
127
127
|
async function gt(t) {
|
|
128
128
|
const e = t.file("word/_rels/document.xml.rels");
|
|
129
129
|
if (!e) return /* @__PURE__ */ new Map();
|
|
130
|
-
const n = await e.async("text"), o =
|
|
131
|
-
for (const
|
|
132
|
-
const u =
|
|
133
|
-
u &&
|
|
130
|
+
const n = await e.async("text"), o = R(n), s = /* @__PURE__ */ new Map(), a = o.getElementsByTagName("Relationship");
|
|
131
|
+
for (const c of a) {
|
|
132
|
+
const u = c.getAttribute("Id");
|
|
133
|
+
u && s.set(u, c.getAttribute("Target"));
|
|
134
134
|
}
|
|
135
|
-
return
|
|
135
|
+
return s;
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function Xt(t) {
|
|
138
138
|
const e = String(t || "").toLowerCase();
|
|
139
139
|
return e.endsWith(".png") ? "image/png" : e.endsWith(".gif") ? "image/gif" : e.endsWith(".webp") ? "image/webp" : e.endsWith(".bmp") ? "image/bmp" : e.endsWith(".svg") || e.endsWith(".svgz") ? "image/svg+xml" : e.endsWith(".tif") || e.endsWith(".tiff") ? "image/tiff" : e.endsWith(".emf") ? "image/x-emf" : e.endsWith(".wmf") ? "image/wmf" : "image/jpeg";
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function _t(t) {
|
|
142
142
|
if (t == null || String(t).trim() === "") return null;
|
|
143
143
|
const e = String(t).trim();
|
|
144
144
|
if (/^https?:\/\//i.test(e)) return null;
|
|
@@ -160,15 +160,15 @@ function mt(t) {
|
|
|
160
160
|
}
|
|
161
161
|
function bt(t, e) {
|
|
162
162
|
if (!t.length || e <= 0) return t;
|
|
163
|
-
const n = t.reduce((a,
|
|
163
|
+
const n = t.reduce((a, c) => a + c, 0);
|
|
164
164
|
if (n <= e) return t;
|
|
165
165
|
const o = t.map((a) => Math.max(1, Math.floor(a * e / n)));
|
|
166
|
-
let
|
|
167
|
-
for (let a = o.length - 1;
|
|
168
|
-
o[a]++,
|
|
166
|
+
let s = e - o.reduce((a, c) => a + c, 0);
|
|
167
|
+
for (let a = o.length - 1; s > 0 && a >= 0; a--)
|
|
168
|
+
o[a]++, s--;
|
|
169
169
|
return o;
|
|
170
170
|
}
|
|
171
|
-
function
|
|
171
|
+
function Ut(t) {
|
|
172
172
|
let e = t;
|
|
173
173
|
for (; e; ) {
|
|
174
174
|
if (e.nodeType === 1 && e.localName === "pic") return e;
|
|
@@ -176,59 +176,59 @@ function _t(t) {
|
|
|
176
176
|
}
|
|
177
177
|
return null;
|
|
178
178
|
}
|
|
179
|
-
function
|
|
179
|
+
function qt(t) {
|
|
180
180
|
const e = p(t, "spPr"), n = e ? p(e, "xfrm") : null, o = n ? p(n, "ext") : null;
|
|
181
181
|
return o ? {
|
|
182
182
|
cx: parseInt(o.getAttribute("cx") ?? "", 10) || null,
|
|
183
183
|
cy: parseInt(o.getAttribute("cy") ?? "", 10) || null
|
|
184
184
|
} : { cx: null, cy: null };
|
|
185
185
|
}
|
|
186
|
-
function
|
|
187
|
-
const e = p(t, "nvPicPr"), n = e ? p(e, "cNvPr") : null, o = n?.getAttribute("descr") || "",
|
|
188
|
-
return String(o ||
|
|
186
|
+
function Yt(t) {
|
|
187
|
+
const e = p(t, "nvPicPr"), n = e ? p(e, "cNvPr") : null, o = n?.getAttribute("descr") || "", s = n?.getAttribute("name") || "";
|
|
188
|
+
return String(o || s || "").trim() || null;
|
|
189
189
|
}
|
|
190
190
|
function wt(t) {
|
|
191
191
|
const e = [], n = t.getElementsByTagNameNS(dt, "blip"), o = t.getElementsByTagNameNS(it, "inline")[0] || t.getElementsByTagNameNS(it, "anchor")[0];
|
|
192
|
-
for (let
|
|
193
|
-
const a = n.item(
|
|
194
|
-
if (!
|
|
192
|
+
for (let s = 0; s < n.length; s++) {
|
|
193
|
+
const a = n.item(s), c = ht(a);
|
|
194
|
+
if (!c) continue;
|
|
195
195
|
let u = null, r = null;
|
|
196
196
|
if (o) {
|
|
197
197
|
const l = p(o, "extent");
|
|
198
198
|
l && (u = parseInt(l.getAttribute("cx") ?? "", 10) || null, r = parseInt(l.getAttribute("cy") ?? "", 10) || null);
|
|
199
199
|
}
|
|
200
|
-
const
|
|
200
|
+
const i = Ut(a);
|
|
201
201
|
let d = null;
|
|
202
|
-
if (
|
|
202
|
+
if (i) {
|
|
203
203
|
if (u == null || r == null) {
|
|
204
|
-
const l =
|
|
204
|
+
const l = qt(i);
|
|
205
205
|
u = u ?? l.cx, r = r ?? l.cy;
|
|
206
206
|
}
|
|
207
|
-
d =
|
|
207
|
+
d = Yt(i);
|
|
208
208
|
}
|
|
209
|
-
e.push({ embedId:
|
|
209
|
+
e.push({ embedId: c, cx: u, cy: r, title: d });
|
|
210
210
|
}
|
|
211
211
|
return e;
|
|
212
212
|
}
|
|
213
213
|
async function yt(t, e, n = {}) {
|
|
214
|
-
const o = /* @__PURE__ */ new Map(),
|
|
215
|
-
if (!
|
|
216
|
-
const a = await
|
|
214
|
+
const o = /* @__PURE__ */ new Map(), s = t.file("word/document.xml");
|
|
215
|
+
if (!s) return o;
|
|
216
|
+
const a = await s.async("text"), u = R(a).getElementsByTagNameNS(dt, "blip"), r = /* @__PURE__ */ new Set();
|
|
217
217
|
for (let d = 0; d < u.length; d++) {
|
|
218
218
|
const l = ht(u.item(d));
|
|
219
219
|
l && r.add(l);
|
|
220
220
|
}
|
|
221
|
-
const
|
|
221
|
+
const i = typeof n.uploadImageFile == "function" ? n.uploadImageFile : null;
|
|
222
222
|
for (const d of r) {
|
|
223
|
-
const l = e.get(d), f =
|
|
223
|
+
const l = e.get(d), f = _t(l);
|
|
224
224
|
if (!f) continue;
|
|
225
225
|
const g = t.file(f);
|
|
226
226
|
if (!g) continue;
|
|
227
|
-
const w = await g.async("arraybuffer"), h =
|
|
227
|
+
const w = await g.async("arraybuffer"), h = Xt(f), m = (f.includes("/") ? f.slice(f.lastIndexOf("/") + 1) : f).match(/\.[a-z0-9]+$/i), A = m ? m[0] : ".bin";
|
|
228
228
|
try {
|
|
229
|
-
if (
|
|
230
|
-
const N = new File([w], `word-import-${d}${A}`, { type: h }), b = await
|
|
231
|
-
|
|
229
|
+
if (i) {
|
|
230
|
+
const N = new File([w], `word-import-${d}${A}`, { type: h }), b = await i(N, { rId: d, partPath: f }), T = b && b.url;
|
|
231
|
+
T && o.set(d, { url: String(T), id: b.id != null ? b.id : null });
|
|
232
232
|
} else {
|
|
233
233
|
const N = new Blob([w], { type: h }), b = URL.createObjectURL(N);
|
|
234
234
|
o.set(d, { url: b, id: null });
|
|
@@ -237,16 +237,16 @@ async function yt(t, e, n = {}) {
|
|
|
237
237
|
console.warn("[wordStyleImport] 嵌入图解析失败", d, f, N);
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
-
return r.size > 0 && !
|
|
240
|
+
return r.size > 0 && !i && console.warn(
|
|
241
241
|
"[wordStyleImport] 当前 Word 文档包含嵌入图片,但未设置 options.uploadImageFile。图片将使用浏览器 blob URL,通常仅本会话有效,刷新或分享文档后可能无法显示。若需持久地址,请在 parseDocxToJson / parseDocxToHtml 第二参传入 uploadImageFile(可与编辑器 onFileUpload 一致)。"
|
|
242
242
|
), o;
|
|
243
243
|
}
|
|
244
|
-
async function
|
|
244
|
+
async function Zt(t, e, n, o = /* @__PURE__ */ new Map(), s = !1) {
|
|
245
245
|
const a = t.file("word/document.xml");
|
|
246
246
|
if (!a) return "<p></p>";
|
|
247
|
-
const
|
|
247
|
+
const c = await a.async("text"), r = R(c).getElementsByTagNameNS(nt, "body")[0];
|
|
248
248
|
if (!r) return "<p></p>";
|
|
249
|
-
const
|
|
249
|
+
const i = p(r, "sectPr"), d = i ? Y(i) : { count: 1, gap: 720, widths: [] }, l = xt(i), f = [];
|
|
250
250
|
let g = { colInfo: null, nodes: [] };
|
|
251
251
|
for (const h of r.childNodes) {
|
|
252
252
|
if (h.nodeType !== 1) continue;
|
|
@@ -260,21 +260,21 @@ async function qt(t, e, n, o = /* @__PURE__ */ new Map(), i = !1) {
|
|
|
260
260
|
let w = "";
|
|
261
261
|
for (const h of f) {
|
|
262
262
|
const y = h.colInfo || { count: 1, widths: [] };
|
|
263
|
-
y.count > 1 ? w +=
|
|
263
|
+
y.count > 1 ? w += Kt(
|
|
264
264
|
h.nodes,
|
|
265
265
|
y,
|
|
266
266
|
e,
|
|
267
267
|
n,
|
|
268
268
|
o,
|
|
269
269
|
l,
|
|
270
|
-
|
|
270
|
+
s
|
|
271
271
|
) : w += Nt(
|
|
272
272
|
h.nodes,
|
|
273
273
|
e,
|
|
274
274
|
n,
|
|
275
275
|
o,
|
|
276
276
|
l,
|
|
277
|
-
|
|
277
|
+
s
|
|
278
278
|
);
|
|
279
279
|
}
|
|
280
280
|
return w || "<p></p>";
|
|
@@ -285,35 +285,35 @@ function xt(t) {
|
|
|
285
285
|
if (!e) return 0;
|
|
286
286
|
const n = parseInt(e.getAttribute("w:w") ?? "", 10);
|
|
287
287
|
if (!n || n <= 0) return 0;
|
|
288
|
-
const o = p(t, "pgMar"),
|
|
289
|
-
return Math.max(n -
|
|
288
|
+
const o = p(t, "pgMar"), s = o && parseInt(o.getAttribute("w:left") ?? "", 10) || 0, a = o && parseInt(o.getAttribute("w:right") ?? "", 10) || 0;
|
|
289
|
+
return Math.max(n - s - a, 1);
|
|
290
290
|
}
|
|
291
291
|
function Y(t) {
|
|
292
292
|
const e = p(t, "cols");
|
|
293
293
|
if (!e) return { count: 1, gap: 720, widths: [] };
|
|
294
|
-
const n = parseInt(e.getAttribute("w:num") ?? "", 10) || 1, o = parseInt(e.getAttribute("w:space") ?? "", 10) || 720,
|
|
295
|
-
(
|
|
294
|
+
const n = parseInt(e.getAttribute("w:num") ?? "", 10) || 1, o = parseInt(e.getAttribute("w:space") ?? "", 10) || 720, s = [...e.childNodes].filter(
|
|
295
|
+
(c) => c.nodeType === 1 && c.localName === "col"
|
|
296
296
|
);
|
|
297
297
|
let a = [];
|
|
298
|
-
if (
|
|
299
|
-
const
|
|
300
|
-
a =
|
|
298
|
+
if (s.length >= n) {
|
|
299
|
+
const c = s.map((r) => parseInt(r.getAttribute("w:w") ?? "", 10) || 0), u = c.reduce((r, i) => r + i, 0) || 1;
|
|
300
|
+
a = c.map((r) => (r / u * 100).toFixed(2));
|
|
301
301
|
}
|
|
302
302
|
return { count: n, gap: o, widths: a };
|
|
303
303
|
}
|
|
304
|
-
function
|
|
305
|
-
const { count: u, widths: r } = e,
|
|
304
|
+
function Kt(t, e, n, o, s, a = 0, c = !1) {
|
|
305
|
+
const { count: u, widths: r } = e, i = Array.from({ length: u }, () => []);
|
|
306
306
|
let d = 0;
|
|
307
307
|
for (const w of t)
|
|
308
|
-
d >= u && (d = u - 1), w.type === "p" && At(w.node) ? (
|
|
309
|
-
const f = `<colgroup data-word-col-layout="1">${Array.from({ length: u }, (w, h) => `<col style="width:${r[h] ? `${r[h]}%` : `${(100 / u).toFixed(2)}%`}"/>`).join("")}</colgroup>`, g =
|
|
308
|
+
d >= u && (d = u - 1), w.type === "p" && At(w.node) ? (i[d].push({ ...w, stripColBreak: !0 }), d < u - 1 && d++) : i[d].push(w);
|
|
309
|
+
const f = `<colgroup data-word-col-layout="1">${Array.from({ length: u }, (w, h) => `<col style="width:${r[h] ? `${r[h]}%` : `${(100 / u).toFixed(2)}%`}"/>`).join("")}</colgroup>`, g = i.map((w, h) => {
|
|
310
310
|
const y = Nt(
|
|
311
311
|
w,
|
|
312
312
|
n,
|
|
313
313
|
o,
|
|
314
|
-
|
|
314
|
+
s,
|
|
315
315
|
a,
|
|
316
|
-
|
|
316
|
+
c
|
|
317
317
|
);
|
|
318
318
|
return `<td style="${r[h] ? `width:${r[h]}%;` : `width:${(100 / u).toFixed(2)}%;`}vertical-align:top;padding:0 4px;">${y || "<p></p>"}</td>`;
|
|
319
319
|
});
|
|
@@ -326,90 +326,90 @@ function At(t) {
|
|
|
326
326
|
if (n.localName === "r")
|
|
327
327
|
for (const o of n.childNodes) {
|
|
328
328
|
if (o.nodeType !== 1) continue;
|
|
329
|
-
const
|
|
330
|
-
if (
|
|
329
|
+
const s = o;
|
|
330
|
+
if (s.localName === "br" && s.getAttribute("w:type") === "column")
|
|
331
331
|
return !0;
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
334
|
return !1;
|
|
335
335
|
}
|
|
336
|
-
function Nt(t, e, n, o,
|
|
337
|
-
let
|
|
338
|
-
for (const { type: r, node:
|
|
336
|
+
function Nt(t, e, n, o, s = 0, a = !1) {
|
|
337
|
+
let c = "", u = [];
|
|
338
|
+
for (const { type: r, node: i, stripColBreak: d } of t)
|
|
339
339
|
if (r === "p") {
|
|
340
|
-
const { tag: l, pStyle: f, isList: g, content: w } =
|
|
341
|
-
|
|
340
|
+
const { tag: l, pStyle: f, isList: g, content: w } = Tt(
|
|
341
|
+
i,
|
|
342
342
|
e,
|
|
343
343
|
n,
|
|
344
344
|
o,
|
|
345
345
|
d,
|
|
346
346
|
a
|
|
347
347
|
);
|
|
348
|
-
g ? u.push(`<li${f}>${w}</li>`) : (u.length && (
|
|
349
|
-
} else r === "tbl" && (u.length && (
|
|
350
|
-
|
|
348
|
+
g ? u.push(`<li${f}>${w}</li>`) : (u.length && (c += `<ul>${u.join("")}</ul>`, u = []), c += `<${l}${f}>${w}</${l}>`);
|
|
349
|
+
} else r === "tbl" && (u.length && (c += `<ul>${u.join("")}</ul>`, u = []), c += Et(
|
|
350
|
+
i,
|
|
351
351
|
e,
|
|
352
352
|
n,
|
|
353
353
|
o,
|
|
354
|
-
|
|
354
|
+
s,
|
|
355
355
|
a
|
|
356
356
|
));
|
|
357
|
-
return u.length && (
|
|
357
|
+
return u.length && (c += `<ul>${u.join("")}</ul>`), c;
|
|
358
358
|
}
|
|
359
|
-
function
|
|
360
|
-
const
|
|
361
|
-
...
|
|
362
|
-
...f ?
|
|
363
|
-
}, h = (
|
|
359
|
+
function Tt(t, e, n, o, s = !1, a = !1) {
|
|
360
|
+
const c = p(t, "pPr"), r = (c ? p(c, "pStyle") : null)?.getAttribute("w:val") || "", i = e.get(r) ?? { rProps: {}, pProps: {}, name: "" }, d = c ? ot(c) : {}, l = { ...i.pProps, ...d }, f = c ? p(c, "rPr") : null, g = {
|
|
361
|
+
...i.rProps || {},
|
|
362
|
+
...f ? O(f) : {}
|
|
363
|
+
}, h = (c ? p(c, "numPr") : null) !== null || r === "ListParagraph" || !!(i.name && /list/i.test(i.name)), y = St(r, i.name), m = y ? `h${y}` : "p", A = se(l), N = A ? ` style="${A}"` : "", b = _(
|
|
364
364
|
t,
|
|
365
365
|
g,
|
|
366
366
|
e,
|
|
367
367
|
n,
|
|
368
368
|
o,
|
|
369
|
-
|
|
369
|
+
s,
|
|
370
370
|
a
|
|
371
371
|
);
|
|
372
372
|
return { tag: m, pStyle: N, isList: h, content: b };
|
|
373
373
|
}
|
|
374
|
-
function
|
|
374
|
+
function _(t, e, n, o, s, a = !1, c = !1) {
|
|
375
375
|
let u = "";
|
|
376
376
|
for (const r of t.childNodes) {
|
|
377
377
|
if (r.nodeType !== 1) continue;
|
|
378
|
-
const
|
|
378
|
+
const i = r, d = i.localName;
|
|
379
379
|
if (d === "r") {
|
|
380
|
-
if (a && It(
|
|
381
|
-
u +=
|
|
380
|
+
if (a && It(i)) continue;
|
|
381
|
+
u += te(i, e, s, c);
|
|
382
382
|
} else if (d === "hyperlink") {
|
|
383
|
-
const l =
|
|
384
|
-
|
|
383
|
+
const l = i.getAttribute("r:id") || i.getAttributeNS(ft, "id"), f = l ? o.get(l) : null, g = (f != null && f !== "" ? f : null) ?? "#", w = _(
|
|
384
|
+
i,
|
|
385
385
|
e,
|
|
386
386
|
n,
|
|
387
387
|
o,
|
|
388
|
-
|
|
388
|
+
s,
|
|
389
389
|
a,
|
|
390
|
-
|
|
390
|
+
c
|
|
391
391
|
);
|
|
392
|
-
u += `<a href="${
|
|
392
|
+
u += `<a href="${D(g)}">${w}</a>`;
|
|
393
393
|
} else if (d === "ins") {
|
|
394
|
-
const l =
|
|
395
|
-
|
|
394
|
+
const l = _(
|
|
395
|
+
i,
|
|
396
396
|
e,
|
|
397
397
|
n,
|
|
398
398
|
o,
|
|
399
|
-
|
|
399
|
+
s,
|
|
400
400
|
a,
|
|
401
|
-
|
|
401
|
+
c
|
|
402
402
|
);
|
|
403
403
|
l && (u += `<span data-word-rev="ins" style="background:rgba(255,230,150,.6);">${l}</span>`);
|
|
404
|
-
} else if (d === "del" &&
|
|
405
|
-
const l =
|
|
406
|
-
|
|
404
|
+
} else if (d === "del" && c) {
|
|
405
|
+
const l = _(
|
|
406
|
+
i,
|
|
407
407
|
e,
|
|
408
408
|
n,
|
|
409
409
|
o,
|
|
410
|
-
|
|
410
|
+
s,
|
|
411
411
|
a,
|
|
412
|
-
|
|
412
|
+
c
|
|
413
413
|
);
|
|
414
414
|
l && (u += `<span data-word-rev="del" style="text-decoration:line-through;">${l}</span>`);
|
|
415
415
|
}
|
|
@@ -425,20 +425,39 @@ function It(t) {
|
|
|
425
425
|
}
|
|
426
426
|
return !1;
|
|
427
427
|
}
|
|
428
|
-
function
|
|
428
|
+
function Pt(t, e) {
|
|
429
|
+
let n = "";
|
|
430
|
+
for (const o of t.childNodes) {
|
|
431
|
+
if (o.nodeType !== 1) continue;
|
|
432
|
+
const s = o;
|
|
433
|
+
s.localName !== "drawing" && (s.localName === "t" || e && s.localName === "delText" ? n += s.textContent ?? "" : s.localName === "br" ? s.getAttribute("w:type") !== "column" && (n += `
|
|
434
|
+
`) : s.localName === "tab" && (n += " "));
|
|
435
|
+
}
|
|
436
|
+
return n;
|
|
437
|
+
}
|
|
438
|
+
function $t(t, e, n, o) {
|
|
439
|
+
o.length > 0 && /^\s+$/.test(o) && t.underline === !0 && e.underline === !1 && (n.underline = !0);
|
|
440
|
+
}
|
|
441
|
+
function Qt(t) {
|
|
429
442
|
return t ? t.split(`
|
|
430
|
-
`).map((o) => /^[ \t]+$/.test(o) ? o.replace(/ /g, " ").replace(/\t/g, " ") :
|
|
443
|
+
`).map((o) => /^[ \t]+$/.test(o) ? o.replace(/ /g, " ").replace(/\t/g, " ") : vt(o)).join("<br/>") : "";
|
|
431
444
|
}
|
|
432
|
-
function
|
|
433
|
-
const
|
|
445
|
+
function te(t, e, n, o = !1) {
|
|
446
|
+
const s = p(t, "rPr"), a = s ? O(s) : {}, c = { ...e, ...a };
|
|
447
|
+
$t(
|
|
448
|
+
e,
|
|
449
|
+
a,
|
|
450
|
+
c,
|
|
451
|
+
Pt(t, o)
|
|
452
|
+
);
|
|
434
453
|
let u = "", r = "";
|
|
435
|
-
const
|
|
454
|
+
const i = () => {
|
|
436
455
|
if (!r) return;
|
|
437
|
-
const d =
|
|
456
|
+
const d = Qt(r);
|
|
438
457
|
if (r = "", !d) return;
|
|
439
|
-
const l =
|
|
458
|
+
const l = le(c);
|
|
440
459
|
let f = "";
|
|
441
|
-
if (
|
|
460
|
+
if (c.lang && (f += ` data-word-lang="${D(String(c.lang))}"`), c.langEastAsia && (f += ` data-word-lang-eastAsia="${D(String(c.langEastAsia))}"`), c.noProof && (f += ' data-word-no-proof="1"'), l || f) {
|
|
442
461
|
const g = l ? ` style="${l}"` : "";
|
|
443
462
|
u += `<span${g}${f}>${d}</span>`;
|
|
444
463
|
} else
|
|
@@ -448,31 +467,31 @@ function Kt(t, e, n, o = !1) {
|
|
|
448
467
|
if (d.nodeType !== 1) continue;
|
|
449
468
|
const l = d;
|
|
450
469
|
if (l.localName === "drawing") {
|
|
451
|
-
|
|
470
|
+
i();
|
|
452
471
|
const f = wt(l);
|
|
453
472
|
for (const g of f) {
|
|
454
473
|
const w = n && n.get(g.embedId), h = w?.url;
|
|
455
474
|
if (!h) continue;
|
|
456
|
-
const y = q(g.cx) ?? 150, m = q(g.cy) ?? 80, A = w?.id ? "true" : "false", N = g.title ? ` title="${
|
|
457
|
-
u += `<inline-img src="${
|
|
475
|
+
const y = q(g.cx) ?? 150, m = q(g.cy) ?? 80, A = w?.id ? "true" : "false", N = g.title ? ` title="${D(g.title)}"` : "";
|
|
476
|
+
u += `<inline-img src="${D(h)}" width="${y}" height="${m}" data-uploaded="${A}"${N}></inline-img>`;
|
|
458
477
|
}
|
|
459
478
|
continue;
|
|
460
479
|
}
|
|
461
480
|
l.localName === "t" || o && l.localName === "delText" ? r += l.textContent : l.localName === "br" ? l.getAttribute("w:type") !== "column" && (r += `
|
|
462
481
|
`) : l.localName === "tab" && (r += " ");
|
|
463
482
|
}
|
|
464
|
-
return
|
|
483
|
+
return i(), u;
|
|
465
484
|
}
|
|
466
|
-
function
|
|
467
|
-
const
|
|
485
|
+
function Et(t, e, n, o, s = 0, a = !1) {
|
|
486
|
+
const c = p(t, "tblPr"), u = ee(c), r = ne(c), i = c ? p(c, "tblW") : null, d = i?.getAttribute("w:type") || "", l = i && parseInt(i.getAttribute("w:w") ?? "", 10) || 0;
|
|
468
487
|
let f = "100%";
|
|
469
|
-
d === "pct" && l > 0 ? f = `${(l / 50).toFixed(1)}%` : d === "dxa" && l > 0 &&
|
|
470
|
-
const g =
|
|
488
|
+
d === "pct" && l > 0 ? f = `${(l / 50).toFixed(1)}%` : d === "dxa" && l > 0 && s > 0 && (f = `${Math.min(l / s * 100, 100).toFixed(1)}%`);
|
|
489
|
+
const g = c ? p(c, "tblCellMar") : null, w = rt(g) ?? { top: 0, right: 108, bottom: 0, left: 108 }, h = p(t, "tblGrid"), y = [];
|
|
471
490
|
if (h) {
|
|
472
491
|
for (const x of h.childNodes)
|
|
473
492
|
if (x.nodeType === 1 && x.localName === "gridCol") {
|
|
474
|
-
const I = x,
|
|
475
|
-
y.push(parseInt(
|
|
493
|
+
const I = x, $ = I.getAttribute("w:w") ?? I.getAttribute("w");
|
|
494
|
+
y.push(parseInt($ ?? "", 10) || 0);
|
|
476
495
|
}
|
|
477
496
|
}
|
|
478
497
|
const m = [...y], A = Array.from(t.childNodes).find(
|
|
@@ -482,9 +501,9 @@ function $t(t, e, n, o, i = 0, a = !1) {
|
|
|
482
501
|
let x = 0;
|
|
483
502
|
for (const I of A.childNodes) {
|
|
484
503
|
if (I.nodeType !== 1) continue;
|
|
485
|
-
const
|
|
486
|
-
if (
|
|
487
|
-
const C = p(
|
|
504
|
+
const $ = I;
|
|
505
|
+
if ($.localName !== "tc") continue;
|
|
506
|
+
const C = p($, "tcPr"), B = C ? p(C, "gridSpan") : null, L = B && parseInt(B.getAttribute("w:val") ?? "", 10) || 1;
|
|
488
507
|
if (L === 1 && x < m.length) {
|
|
489
508
|
const F = C ? p(C, "tcW") : null;
|
|
490
509
|
if (F) {
|
|
@@ -502,97 +521,97 @@ function $t(t, e, n, o, i = 0, a = !1) {
|
|
|
502
521
|
let x = 0;
|
|
503
522
|
for (const I of A.childNodes) {
|
|
504
523
|
if (I.nodeType !== 1) continue;
|
|
505
|
-
const
|
|
506
|
-
if (
|
|
507
|
-
const C = p(
|
|
524
|
+
const $ = I;
|
|
525
|
+
if ($.localName !== "tc") continue;
|
|
526
|
+
const C = p($, "tcPr"), B = C ? p(C, "gridSpan") : null;
|
|
508
527
|
x += B && parseInt(B.getAttribute("w:val") ?? "", 10) || 1;
|
|
509
528
|
}
|
|
510
529
|
b = Math.max(x, 1);
|
|
511
530
|
} else
|
|
512
531
|
b = 1;
|
|
513
|
-
const
|
|
514
|
-
let
|
|
515
|
-
|
|
516
|
-
const S = (
|
|
532
|
+
const T = N > 0 && m.length > 0 ? m.map((x) => (x / N * 100).toFixed(2)) : Array.from({ length: b }, () => (100 / b).toFixed(2));
|
|
533
|
+
let P = "";
|
|
534
|
+
T.length && (P = `<colgroup>${T.map((I) => `<col style="width:${I}%"/>`).join("")}</colgroup>`);
|
|
535
|
+
const S = (c ? p(c, "jc") : null)?.getAttribute("w:val") || "left", W = `border-collapse:collapse;table-layout:fixed;width:${f};${S === "center" ? "margin:0 auto;" : ""}`, E = [];
|
|
517
536
|
for (const x of t.childNodes) {
|
|
518
537
|
if (x.nodeType !== 1) continue;
|
|
519
538
|
const I = x;
|
|
520
539
|
if (I.localName !== "tr") continue;
|
|
521
|
-
const
|
|
540
|
+
const $ = [];
|
|
522
541
|
let C = 0;
|
|
523
542
|
for (const B of I.childNodes) {
|
|
524
543
|
if (B.nodeType !== 1) continue;
|
|
525
544
|
const L = B;
|
|
526
545
|
if (L.localName !== "tc") continue;
|
|
527
|
-
const F = p(L, "tcPr"), j = F ? p(F, "gridSpan") : null, z = j && parseInt(j.getAttribute("w:val") ?? "", 10) || 1, Z = F ? p(F, "vMerge") : null,
|
|
528
|
-
|
|
546
|
+
const F = p(L, "tcPr"), j = F ? p(F, "gridSpan") : null, z = j && parseInt(j.getAttribute("w:val") ?? "", 10) || 1, Z = F ? p(F, "vMerge") : null, J = Z?.getAttribute("w:val") || (Z ? "continue" : null), K = J === "restart" ? "restart" : J === "continue" ? "continue" : null;
|
|
547
|
+
$.push({ tc: L, tcPrEl: F, colspan: z, vMerge: K, colIdx: C }), C += z;
|
|
529
548
|
}
|
|
530
|
-
E.push(
|
|
549
|
+
E.push($);
|
|
531
550
|
}
|
|
532
551
|
function k(x, I) {
|
|
533
|
-
for (const
|
|
534
|
-
if (I >=
|
|
552
|
+
for (const $ of x)
|
|
553
|
+
if (I >= $.colIdx && I < $.colIdx + $.colspan) return $;
|
|
535
554
|
return null;
|
|
536
555
|
}
|
|
537
556
|
for (let x = 0; x < E.length; x++)
|
|
538
557
|
for (const I of E[x]) {
|
|
539
558
|
if (I.vMerge !== "restart") continue;
|
|
540
|
-
let
|
|
559
|
+
let $ = 1;
|
|
541
560
|
for (let C = x + 1; C < E.length; C++) {
|
|
542
561
|
const B = k(E[C], I.colIdx);
|
|
543
|
-
if (B && B.vMerge === "continue")
|
|
562
|
+
if (B && B.vMerge === "continue") $++;
|
|
544
563
|
else break;
|
|
545
564
|
}
|
|
546
|
-
I.rowspan =
|
|
565
|
+
I.rowspan = $;
|
|
547
566
|
}
|
|
548
567
|
let M = "";
|
|
549
568
|
for (const x of E) {
|
|
550
569
|
let I = "";
|
|
551
|
-
for (const
|
|
552
|
-
if (
|
|
553
|
-
const { tc: C, tcPrEl: B, colspan: L, rowspan: F = 1 } =
|
|
570
|
+
for (const $ of x) {
|
|
571
|
+
if ($.vMerge === "continue") continue;
|
|
572
|
+
const { tc: C, tcPrEl: B, colspan: L, rowspan: F = 1 } = $, z = oe(B, u) ? "border:1px solid #d0d0d0;" : "border:none;", J = (B ? p(B, "vAlign") : null)?.getAttribute("w:val") || "top", K = J === "center" ? "middle" : J === "bottom" ? "bottom" : "top", Ft = B ? p(B, "tcMar") : null, V = rt(Ft) ?? w, Wt = X(V.top ?? w.top ?? 0), kt = X(V.right ?? w.right ?? 108), Ht = X(V.bottom ?? w.bottom ?? 0), Lt = X(V.left ?? w.left ?? 108), zt = `padding:${Wt}px ${kt}px ${Ht}px ${Lt}px;`;
|
|
554
573
|
let Q = "";
|
|
555
574
|
for (const lt of C.childNodes) {
|
|
556
575
|
if (lt.nodeType !== 1) continue;
|
|
557
|
-
const
|
|
558
|
-
if (
|
|
559
|
-
const { tag: st, pStyle:
|
|
560
|
-
|
|
576
|
+
const G = lt;
|
|
577
|
+
if (G.localName === "p") {
|
|
578
|
+
const { tag: st, pStyle: Dt, content: Ot } = Tt(
|
|
579
|
+
G,
|
|
561
580
|
e,
|
|
562
581
|
n,
|
|
563
582
|
o,
|
|
564
583
|
!1,
|
|
565
584
|
a
|
|
566
585
|
);
|
|
567
|
-
Q += `<${st}${
|
|
568
|
-
} else
|
|
569
|
-
|
|
586
|
+
Q += `<${st}${Dt}>${Ot}</${st}>`;
|
|
587
|
+
} else G.localName === "tbl" && (Q += Et(
|
|
588
|
+
G,
|
|
570
589
|
e,
|
|
571
590
|
n,
|
|
572
591
|
o,
|
|
573
|
-
|
|
592
|
+
s,
|
|
574
593
|
a
|
|
575
594
|
));
|
|
576
595
|
}
|
|
577
|
-
const
|
|
578
|
-
I += `<td${
|
|
596
|
+
const jt = L > 1 ? ` colspan="${L}"` : "", Jt = F > 1 ? ` rowspan="${F}"` : "";
|
|
597
|
+
I += `<td${jt}${Jt} style="${z}${zt}vertical-align:${K};">${Q}</td>`;
|
|
579
598
|
}
|
|
580
599
|
M += `<tr>${I}</tr>`;
|
|
581
600
|
}
|
|
582
601
|
const H = r ? ` data-word-tbl-borders='${JSON.stringify(r)}'` : "";
|
|
583
|
-
return `<table style="${W}"${H}>${
|
|
602
|
+
return `<table style="${W}"${H}>${P}${M}</table>`;
|
|
584
603
|
}
|
|
585
|
-
function
|
|
604
|
+
function ee(t) {
|
|
586
605
|
if (!t) return !0;
|
|
587
606
|
const e = p(t, "tblBorders");
|
|
588
607
|
if (!e) return !0;
|
|
589
608
|
const n = ["top", "bottom", "left", "right", "insideH", "insideV"];
|
|
590
609
|
let o = !0;
|
|
591
|
-
for (const
|
|
592
|
-
const a = p(e,
|
|
610
|
+
for (const s of n) {
|
|
611
|
+
const a = p(e, s);
|
|
593
612
|
if (a) {
|
|
594
|
-
const
|
|
595
|
-
if (
|
|
613
|
+
const c = a.getAttribute("w:val") || "";
|
|
614
|
+
if (c !== "none" && c !== "nil") {
|
|
596
615
|
o = !1;
|
|
597
616
|
break;
|
|
598
617
|
}
|
|
@@ -600,32 +619,32 @@ function Qt(t) {
|
|
|
600
619
|
}
|
|
601
620
|
return !o;
|
|
602
621
|
}
|
|
603
|
-
function
|
|
622
|
+
function ne(t) {
|
|
604
623
|
if (!t) return null;
|
|
605
624
|
const e = p(t, "tblBorders");
|
|
606
625
|
if (!e) return null;
|
|
607
626
|
const n = p(e, "top");
|
|
608
627
|
if (!n) return null;
|
|
609
|
-
const o = n.getAttribute("w:val") || "",
|
|
610
|
-
return { val: o, sz:
|
|
628
|
+
const o = n.getAttribute("w:val") || "", s = n.getAttribute("w:sz") || "", a = n.getAttribute("w:color") || "", c = n.getAttribute("w:space") || "";
|
|
629
|
+
return { val: o, sz: s, color: a, space: c };
|
|
611
630
|
}
|
|
612
|
-
function
|
|
631
|
+
function oe(t, e) {
|
|
613
632
|
if (!t) return e;
|
|
614
633
|
const n = p(t, "tcBorders");
|
|
615
634
|
if (!n) return e;
|
|
616
635
|
const o = ["top", "bottom", "left", "right"];
|
|
617
|
-
let
|
|
636
|
+
let s = !0;
|
|
618
637
|
for (const a of o) {
|
|
619
|
-
const
|
|
620
|
-
if (
|
|
621
|
-
const u =
|
|
638
|
+
const c = p(n, a);
|
|
639
|
+
if (c) {
|
|
640
|
+
const u = c.getAttribute("w:val") || "";
|
|
622
641
|
if (u !== "none" && u !== "nil") {
|
|
623
|
-
|
|
642
|
+
s = !1;
|
|
624
643
|
break;
|
|
625
644
|
}
|
|
626
645
|
}
|
|
627
646
|
}
|
|
628
|
-
return !
|
|
647
|
+
return !s;
|
|
629
648
|
}
|
|
630
649
|
function rt(t) {
|
|
631
650
|
if (!t) return null;
|
|
@@ -633,16 +652,16 @@ function rt(t) {
|
|
|
633
652
|
for (const n of ["top", "right", "bottom", "left"]) {
|
|
634
653
|
const o = p(t, n);
|
|
635
654
|
if (o) {
|
|
636
|
-
const
|
|
637
|
-
!isNaN(
|
|
655
|
+
const s = parseInt(o.getAttribute("w:w") ?? "", 10);
|
|
656
|
+
!isNaN(s) && s >= 0 && (e[n] = s);
|
|
638
657
|
}
|
|
639
658
|
}
|
|
640
659
|
return Object.keys(e).length > 0 ? e : null;
|
|
641
660
|
}
|
|
642
|
-
function
|
|
661
|
+
function X(t) {
|
|
643
662
|
return Math.round(t / 15);
|
|
644
663
|
}
|
|
645
|
-
function
|
|
664
|
+
function O(t) {
|
|
646
665
|
const e = {}, n = p(t, "rFonts");
|
|
647
666
|
if (n) {
|
|
648
667
|
const l = n.getAttribute("w:eastAsia") || n.getAttribute("w:ascii") || n.getAttribute("w:hAnsi") || n.getAttribute("w:cs") || "";
|
|
@@ -653,9 +672,9 @@ function R(t) {
|
|
|
653
672
|
const l = parseInt(o.getAttribute("w:val") ?? "", 10);
|
|
654
673
|
!isNaN(l) && l > 0 && (e.fontSize = (l / 2 * 1.333).toFixed(1) + "px");
|
|
655
674
|
}
|
|
656
|
-
const
|
|
657
|
-
if (
|
|
658
|
-
const l =
|
|
675
|
+
const s = p(t, "b");
|
|
676
|
+
if (s) {
|
|
677
|
+
const l = s.getAttribute("w:val");
|
|
659
678
|
e.bold = l !== "0" && l !== "false";
|
|
660
679
|
}
|
|
661
680
|
const a = p(t, "i");
|
|
@@ -663,9 +682,9 @@ function R(t) {
|
|
|
663
682
|
const l = a.getAttribute("w:val");
|
|
664
683
|
e.italic = l !== "0" && l !== "false";
|
|
665
684
|
}
|
|
666
|
-
const
|
|
667
|
-
if (
|
|
668
|
-
const l =
|
|
685
|
+
const c = p(t, "u");
|
|
686
|
+
if (c) {
|
|
687
|
+
const l = c.getAttribute("w:val") || "single";
|
|
669
688
|
e.underline = l !== "none";
|
|
670
689
|
}
|
|
671
690
|
const u = p(t, "strike") || p(t, "dstrike");
|
|
@@ -678,9 +697,9 @@ function R(t) {
|
|
|
678
697
|
const l = r.getAttribute("w:val") || "";
|
|
679
698
|
l && l !== "auto" && (e.color = "#" + l);
|
|
680
699
|
}
|
|
681
|
-
const
|
|
682
|
-
if (
|
|
683
|
-
const l =
|
|
700
|
+
const i = p(t, "lang");
|
|
701
|
+
if (i) {
|
|
702
|
+
const l = i.getAttribute("w:val") || "", f = i.getAttribute("w:eastAsia") || "";
|
|
684
703
|
l && (e.lang = l), f && (e.langEastAsia = f);
|
|
685
704
|
}
|
|
686
705
|
return p(t, "noProof") && (e.noProof = !0), e;
|
|
@@ -688,27 +707,27 @@ function R(t) {
|
|
|
688
707
|
function ot(t) {
|
|
689
708
|
const e = {}, n = p(t, "jc");
|
|
690
709
|
if (n) {
|
|
691
|
-
const a = n.getAttribute("w:val") || "",
|
|
710
|
+
const a = n.getAttribute("w:val") || "", c = {
|
|
692
711
|
left: "left",
|
|
693
712
|
center: "center",
|
|
694
713
|
right: "right",
|
|
695
714
|
both: "justify",
|
|
696
715
|
distribute: "justify"
|
|
697
716
|
};
|
|
698
|
-
a in
|
|
717
|
+
a in c && (e.textAlign = c[a]);
|
|
699
718
|
}
|
|
700
719
|
const o = p(t, "ind");
|
|
701
720
|
if (o) {
|
|
702
721
|
const a = parseInt(o.getAttribute("w:left") ?? "", 10);
|
|
703
722
|
!isNaN(a) && a > 0 && (e.paddingLeft = Math.round(a / 15) + "px");
|
|
704
723
|
}
|
|
705
|
-
const
|
|
706
|
-
if (
|
|
707
|
-
const a =
|
|
724
|
+
const s = p(t, "spacing");
|
|
725
|
+
if (s) {
|
|
726
|
+
const a = s.getAttribute("w:line"), c = s.getAttribute("w:lineRule") || "auto", u = s.getAttribute("w:before"), r = s.getAttribute("w:after");
|
|
708
727
|
if (a) {
|
|
709
728
|
const l = parseInt(a ?? "", 10);
|
|
710
729
|
if (!isNaN(l) && l > 0)
|
|
711
|
-
if (
|
|
730
|
+
if (c === "auto") {
|
|
712
731
|
const f = l / 240;
|
|
713
732
|
f > 0.25 && f < 4 && (e.lineHeight = Number(f.toFixed(2)));
|
|
714
733
|
} else {
|
|
@@ -716,20 +735,20 @@ function ot(t) {
|
|
|
716
735
|
f > 0 && (e.lineHeightPx = f + "px");
|
|
717
736
|
}
|
|
718
737
|
}
|
|
719
|
-
const
|
|
720
|
-
!isNaN(
|
|
738
|
+
const i = parseInt(u ?? "", 10);
|
|
739
|
+
!isNaN(i) && i > 0 && (e.marginTop = Math.round(i / 15) + "px");
|
|
721
740
|
const d = parseInt(r ?? "", 10);
|
|
722
741
|
!isNaN(d) && d > 0 && (e.marginBottom = Math.round(d / 15) + "px");
|
|
723
742
|
}
|
|
724
743
|
return e;
|
|
725
744
|
}
|
|
726
|
-
function
|
|
745
|
+
function le(t) {
|
|
727
746
|
const e = [];
|
|
728
747
|
t.fontFamily && e.push(`font-family:${t.fontFamily}`), t.fontSize && e.push(`font-size:${t.fontSize}`), t.bold && e.push("font-weight:bold"), t.italic && e.push("font-style:italic");
|
|
729
748
|
const n = [];
|
|
730
749
|
return t.underline && n.push("underline"), t.strike && n.push("line-through"), n.length && e.push(`text-decoration:${n.join(" ")}`), t.color && e.push(`color:${t.color}`), e.join(";");
|
|
731
750
|
}
|
|
732
|
-
function
|
|
751
|
+
function se(t) {
|
|
733
752
|
const e = [];
|
|
734
753
|
return t.textAlign && t.textAlign !== "left" && e.push(`text-align:${t.textAlign}`), t.paddingLeft && e.push(`padding-left:${t.paddingLeft}`), t.lineHeight ? e.push(`line-height:${t.lineHeight}`) : t.lineHeightPx && e.push(`line-height:${t.lineHeightPx}`), t.marginTop && e.push(`margin-top:${t.marginTop}`), t.marginBottom && e.push(`margin-bottom:${t.marginBottom}`), e.join(";");
|
|
735
754
|
}
|
|
@@ -747,7 +766,7 @@ const at = {
|
|
|
747
766
|
5: 5,
|
|
748
767
|
6: 6
|
|
749
768
|
};
|
|
750
|
-
function
|
|
769
|
+
function St(t, e) {
|
|
751
770
|
if (at[t] !== void 0) return at[t];
|
|
752
771
|
const n = t.match(/^Heading(\d)$/i) || t.match(/^heading(\d)$/i);
|
|
753
772
|
if (n) return parseInt(n[1], 10);
|
|
@@ -757,7 +776,7 @@ function Tt(t, e) {
|
|
|
757
776
|
}
|
|
758
777
|
return 0;
|
|
759
778
|
}
|
|
760
|
-
function
|
|
779
|
+
function R(t) {
|
|
761
780
|
return new DOMParser().parseFromString(t, "application/xml");
|
|
762
781
|
}
|
|
763
782
|
function p(t, e) {
|
|
@@ -766,21 +785,21 @@ function p(t, e) {
|
|
|
766
785
|
if (n.nodeType === 1 && n.localName === e) return n;
|
|
767
786
|
return null;
|
|
768
787
|
}
|
|
769
|
-
function
|
|
788
|
+
function vt(t) {
|
|
770
789
|
return String(t).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
771
790
|
}
|
|
772
|
-
function
|
|
773
|
-
return
|
|
791
|
+
function D(t) {
|
|
792
|
+
return vt(t).replace(/"/g, """);
|
|
774
793
|
}
|
|
775
|
-
function
|
|
776
|
-
const
|
|
794
|
+
function Bt(t, e, n, o, s = 0, a = !1) {
|
|
795
|
+
const c = [];
|
|
777
796
|
let u = [];
|
|
778
797
|
const r = () => {
|
|
779
|
-
u.length && (
|
|
798
|
+
u.length && (c.push({ type: "bulletList", content: u }), u = []);
|
|
780
799
|
};
|
|
781
|
-
for (const { type:
|
|
782
|
-
if (
|
|
783
|
-
const { node: f, isList: g } =
|
|
800
|
+
for (const { type: i, node: d, stripColBreak: l } of t)
|
|
801
|
+
if (i === "p") {
|
|
802
|
+
const { node: f, isList: g } = Ct(
|
|
784
803
|
d,
|
|
785
804
|
e,
|
|
786
805
|
n,
|
|
@@ -788,32 +807,32 @@ function St(t, e, n, o, i = 0, a = !1) {
|
|
|
788
807
|
l,
|
|
789
808
|
a
|
|
790
809
|
);
|
|
791
|
-
g ? u.push({ type: "listItem", content: [f] }) : (r(),
|
|
792
|
-
} else
|
|
793
|
-
|
|
810
|
+
g ? u.push({ type: "listItem", content: [f] }) : (r(), c.push(f));
|
|
811
|
+
} else i === "tbl" && (r(), c.push(
|
|
812
|
+
Mt(d, e, n, o, s, a)
|
|
794
813
|
));
|
|
795
|
-
return r(),
|
|
814
|
+
return r(), c;
|
|
796
815
|
}
|
|
797
|
-
function
|
|
798
|
-
const { count: u, widths: r } = e,
|
|
816
|
+
function ce(t, e, n, o, s, a = 0, c = !1) {
|
|
817
|
+
const { count: u, widths: r } = e, i = Array.from({ length: u }, () => []);
|
|
799
818
|
let d = 0;
|
|
800
819
|
for (const m of t)
|
|
801
|
-
d >= u && (d = u - 1), m.type === "p" && At(m.node) ? (
|
|
820
|
+
d >= u && (d = u - 1), m.type === "p" && At(m.node) ? (i[d].push({ ...m, stripColBreak: !0 }), d < u - 1 && d++) : i[d].push(m);
|
|
802
821
|
const l = "26px", f = () => ({
|
|
803
822
|
type: "paragraph",
|
|
804
823
|
attrs: { indent: null, textAlign: null, lineHeight: l, margin: {} },
|
|
805
824
|
content: []
|
|
806
|
-
}), g = mt(a), w =
|
|
825
|
+
}), g = mt(a), w = i.map((m, A) => {
|
|
807
826
|
const N = r && r[A] != null && String(r[A]).trim() !== "" ? parseFloat(String(r[A])) : 100 / u;
|
|
808
827
|
return Number.isFinite(N) && N > 0 ? Math.max(1, Math.round(N / 100 * g)) : Math.max(1, Math.round(g / Math.max(u, 1)));
|
|
809
|
-
}), h = bt(w, g), y =
|
|
810
|
-
const N =
|
|
828
|
+
}), h = bt(w, g), y = i.map((m, A) => {
|
|
829
|
+
const N = Bt(
|
|
811
830
|
m,
|
|
812
831
|
n,
|
|
813
832
|
o,
|
|
814
|
-
|
|
833
|
+
s,
|
|
815
834
|
a,
|
|
816
|
-
|
|
835
|
+
c
|
|
817
836
|
);
|
|
818
837
|
return {
|
|
819
838
|
type: "tableCell",
|
|
@@ -834,12 +853,12 @@ function le(t, e, n, o, i, a = 0, s = !1) {
|
|
|
834
853
|
content: [{ type: "tableRow", content: y }]
|
|
835
854
|
};
|
|
836
855
|
}
|
|
837
|
-
async function
|
|
856
|
+
async function ie(t, e, n, o = /* @__PURE__ */ new Map(), s = !1) {
|
|
838
857
|
const a = t.file("word/document.xml");
|
|
839
858
|
if (!a) return { type: "doc", content: [] };
|
|
840
|
-
const
|
|
859
|
+
const c = await a.async("text"), r = R(c).getElementsByTagNameNS(nt, "body")[0];
|
|
841
860
|
if (!r) return { type: "doc", content: [] };
|
|
842
|
-
const
|
|
861
|
+
const i = p(r, "sectPr"), d = i ? Y(i) : { count: 1, gap: 720, widths: [] }, l = xt(i), f = [];
|
|
843
862
|
let g = { colInfo: null, nodes: [] };
|
|
844
863
|
for (const h of r.childNodes) {
|
|
845
864
|
if (h.nodeType !== 1) continue;
|
|
@@ -854,54 +873,54 @@ async function se(t, e, n, o = /* @__PURE__ */ new Map(), i = !1) {
|
|
|
854
873
|
for (const h of f) {
|
|
855
874
|
const y = h.colInfo || { count: 1, widths: [] };
|
|
856
875
|
y.count > 1 ? w.push(
|
|
857
|
-
|
|
876
|
+
ce(
|
|
858
877
|
h.nodes,
|
|
859
878
|
y,
|
|
860
879
|
e,
|
|
861
880
|
n,
|
|
862
881
|
o,
|
|
863
882
|
l,
|
|
864
|
-
|
|
883
|
+
s
|
|
865
884
|
)
|
|
866
885
|
) : w.push(
|
|
867
|
-
...
|
|
886
|
+
...Bt(
|
|
868
887
|
h.nodes,
|
|
869
888
|
e,
|
|
870
889
|
n,
|
|
871
890
|
o,
|
|
872
891
|
l,
|
|
873
|
-
|
|
892
|
+
s
|
|
874
893
|
)
|
|
875
894
|
);
|
|
876
895
|
}
|
|
877
896
|
return { type: "doc", content: w };
|
|
878
897
|
}
|
|
879
|
-
function
|
|
898
|
+
function re(t) {
|
|
880
899
|
let n = null;
|
|
881
900
|
t.textAlign && t.textAlign !== "left" && (n = t.textAlign === "both" ? "justify" : t.textAlign);
|
|
882
|
-
const o = t.lineHeight != null ? Number(t.lineHeight) : t.lineHeightPx != null ? String(t.lineHeightPx) : "26px",
|
|
883
|
-
return t.marginTop && (
|
|
901
|
+
const o = t.lineHeight != null ? Number(t.lineHeight) : t.lineHeightPx != null ? String(t.lineHeightPx) : "26px", s = {};
|
|
902
|
+
return t.marginTop && (s.top = String(parseInt(t.marginTop, 10))), t.marginBottom && (s.bottom = String(parseInt(t.marginBottom, 10))), { indent: null, textAlign: n, lineHeight: o, margin: s };
|
|
884
903
|
}
|
|
885
|
-
function
|
|
886
|
-
const n = [], o = t.color || "",
|
|
887
|
-
return (
|
|
904
|
+
function ae(t, e = !1) {
|
|
905
|
+
const n = [], o = t.color || "", s = t.fontFamily || "", a = t.fontSize || "";
|
|
906
|
+
return (s || a || o) && n.push({
|
|
888
907
|
type: "textStyle",
|
|
889
|
-
attrs: { fontFamily:
|
|
908
|
+
attrs: { fontFamily: s, fontSize: a, color: o }
|
|
890
909
|
}), t.bold && n.push({ type: "bold" }), t.italic && n.push({ type: "italic" }), t.underline && n.push({ type: "underline" }), (e || t.strike) && n.push({ type: "strike" }), n;
|
|
891
910
|
}
|
|
892
|
-
function
|
|
911
|
+
function ue(t, e) {
|
|
893
912
|
const n = e && e.get(t.embedId), o = n?.url;
|
|
894
913
|
if (!o) return null;
|
|
895
|
-
const
|
|
914
|
+
const s = q(t.cx) ?? 150, a = q(t.cy) ?? 80, c = n?.id != null ? n.id : null;
|
|
896
915
|
return {
|
|
897
916
|
type: "inlineImage",
|
|
898
917
|
attrs: {
|
|
899
918
|
name: t.title ?? null,
|
|
900
919
|
size: null,
|
|
901
|
-
id:
|
|
920
|
+
id: c,
|
|
902
921
|
src: o,
|
|
903
922
|
content: null,
|
|
904
|
-
width:
|
|
923
|
+
width: s,
|
|
905
924
|
height: a,
|
|
906
925
|
left: 0,
|
|
907
926
|
top: 0,
|
|
@@ -911,24 +930,31 @@ function re(t, e) {
|
|
|
911
930
|
equalProportion: !1,
|
|
912
931
|
flipX: !1,
|
|
913
932
|
flipY: !1,
|
|
914
|
-
uploaded: !!
|
|
933
|
+
uploaded: !!c,
|
|
915
934
|
error: !1,
|
|
916
935
|
previewType: "image",
|
|
917
936
|
inline: !0
|
|
918
937
|
}
|
|
919
938
|
};
|
|
920
939
|
}
|
|
921
|
-
function
|
|
922
|
-
const a = p(t, "rPr"),
|
|
940
|
+
function fe(t, e, n, o = !1, s = !1) {
|
|
941
|
+
const a = p(t, "rPr"), c = a ? O(a) : {}, u = {
|
|
923
942
|
...e,
|
|
924
|
-
...
|
|
925
|
-
strike: !!(
|
|
926
|
-
}
|
|
943
|
+
...c,
|
|
944
|
+
strike: !!(c.strike || e.strike) || o
|
|
945
|
+
};
|
|
946
|
+
$t(
|
|
947
|
+
e,
|
|
948
|
+
c,
|
|
949
|
+
u,
|
|
950
|
+
Pt(t, s)
|
|
951
|
+
);
|
|
952
|
+
const r = ae(u, o), i = (w) => /^[ \t]+$/.test(w) ? w.replace(/ /g, " ").replace(/\t/g, " ") : w, d = (w) => {
|
|
927
953
|
if (!w) return [];
|
|
928
954
|
const h = w.split(`
|
|
929
955
|
`), y = [];
|
|
930
956
|
for (let m = 0; m < h.length; m++) {
|
|
931
|
-
const A = h[m], N =
|
|
957
|
+
const A = h[m], N = i(A);
|
|
932
958
|
y.push({
|
|
933
959
|
type: "text",
|
|
934
960
|
text: N,
|
|
@@ -950,51 +976,51 @@ function ae(t, e, n, o = !1, i = !1) {
|
|
|
950
976
|
g();
|
|
951
977
|
const y = wt(h);
|
|
952
978
|
for (const m of y) {
|
|
953
|
-
const A =
|
|
979
|
+
const A = ue(m, n);
|
|
954
980
|
A && f.push(A);
|
|
955
981
|
}
|
|
956
982
|
continue;
|
|
957
983
|
}
|
|
958
|
-
h.localName === "t" ||
|
|
984
|
+
h.localName === "t" || s && h.localName === "delText" ? l += h.textContent : h.localName === "br" ? h.getAttribute("w:type") !== "column" && (l += `
|
|
959
985
|
`) : h.localName === "tab" && (l += " ");
|
|
960
986
|
}
|
|
961
987
|
return g(), f;
|
|
962
988
|
}
|
|
963
|
-
function U(t, e, n, o,
|
|
964
|
-
const { forceStrike: u = !1, importWordDelRevision: r = !1 } =
|
|
965
|
-
let
|
|
989
|
+
function U(t, e, n, o, s, a = !1, c = {}) {
|
|
990
|
+
const { forceStrike: u = !1, importWordDelRevision: r = !1 } = c;
|
|
991
|
+
let i = [];
|
|
966
992
|
for (const d of t.childNodes) {
|
|
967
993
|
if (d.nodeType !== 1) continue;
|
|
968
994
|
const l = d, f = l.localName;
|
|
969
995
|
if (f === "r") {
|
|
970
996
|
if (a && It(l)) continue;
|
|
971
|
-
|
|
972
|
-
|
|
997
|
+
i = i.concat(
|
|
998
|
+
fe(l, e, s, u, r)
|
|
973
999
|
);
|
|
974
|
-
} else f === "hyperlink" ?
|
|
975
|
-
U(l, e, n, o,
|
|
1000
|
+
} else f === "hyperlink" ? i = i.concat(
|
|
1001
|
+
U(l, e, n, o, s, a, {
|
|
976
1002
|
forceStrike: u,
|
|
977
1003
|
importWordDelRevision: r
|
|
978
1004
|
})
|
|
979
|
-
) : f === "ins" ?
|
|
980
|
-
U(l, e, n, o,
|
|
1005
|
+
) : f === "ins" ? i = i.concat(
|
|
1006
|
+
U(l, e, n, o, s, a, {
|
|
981
1007
|
forceStrike: u,
|
|
982
1008
|
importWordDelRevision: r
|
|
983
1009
|
})
|
|
984
|
-
) : f === "del" && r && (
|
|
985
|
-
U(l, e, n, o,
|
|
1010
|
+
) : f === "del" && r && (i = i.concat(
|
|
1011
|
+
U(l, e, n, o, s, a, {
|
|
986
1012
|
forceStrike: !0,
|
|
987
1013
|
importWordDelRevision: r
|
|
988
1014
|
})
|
|
989
1015
|
));
|
|
990
1016
|
}
|
|
991
|
-
return
|
|
1017
|
+
return i;
|
|
992
1018
|
}
|
|
993
|
-
function
|
|
994
|
-
const
|
|
995
|
-
...
|
|
996
|
-
...f ?
|
|
997
|
-
}, h = (
|
|
1019
|
+
function Ct(t, e, n, o, s = !1, a = !1) {
|
|
1020
|
+
const c = p(t, "pPr"), r = (c ? p(c, "pStyle") : null)?.getAttribute("w:val") || "", i = e.get(r) ?? { rProps: {}, pProps: {}, name: "" }, d = c ? ot(c) : {}, l = { ...i.pProps, ...d }, f = c ? p(c, "rPr") : null, g = {
|
|
1021
|
+
...i.rProps || {},
|
|
1022
|
+
...f ? O(f) : {}
|
|
1023
|
+
}, h = (c ? p(c, "numPr") : null) !== null || r === "ListParagraph" || !!(i.name && /list/i.test(i.name)), y = St(r, i.name), { indent: m, textAlign: A, lineHeight: N, margin: b } = re(l), T = U(t, g, e, n, o, s, {
|
|
998
1024
|
importWordDelRevision: a
|
|
999
1025
|
});
|
|
1000
1026
|
return y && !h ? {
|
|
@@ -1002,36 +1028,36 @@ function vt(t, e, n, o, i = !1, a = !1) {
|
|
|
1002
1028
|
node: {
|
|
1003
1029
|
type: "heading",
|
|
1004
1030
|
attrs: { indent: m, textAlign: A, lineHeight: N, margin: b, level: y },
|
|
1005
|
-
content:
|
|
1031
|
+
content: T
|
|
1006
1032
|
}
|
|
1007
1033
|
} : {
|
|
1008
1034
|
isList: h,
|
|
1009
1035
|
node: {
|
|
1010
1036
|
type: "paragraph",
|
|
1011
1037
|
attrs: { indent: m, textAlign: A, lineHeight: N, margin: b },
|
|
1012
|
-
content:
|
|
1038
|
+
content: T
|
|
1013
1039
|
}
|
|
1014
1040
|
};
|
|
1015
1041
|
}
|
|
1016
|
-
function
|
|
1017
|
-
const
|
|
1018
|
-
if (
|
|
1019
|
-
for (const b of
|
|
1042
|
+
function Mt(t, e, n, o, s = 0, a = !1) {
|
|
1043
|
+
const c = p(t, "tblGrid"), u = [];
|
|
1044
|
+
if (c) {
|
|
1045
|
+
for (const b of c.childNodes)
|
|
1020
1046
|
if (b.nodeType === 1 && b.localName === "gridCol") {
|
|
1021
|
-
const
|
|
1022
|
-
u.push(parseInt(
|
|
1047
|
+
const T = b.getAttribute("w:w") ?? b.getAttribute("w");
|
|
1048
|
+
u.push(parseInt(T ?? "", 10) || 0);
|
|
1023
1049
|
}
|
|
1024
1050
|
}
|
|
1025
|
-
const r = [...u],
|
|
1051
|
+
const r = [...u], i = Array.from(t.childNodes).find(
|
|
1026
1052
|
(b) => b.nodeType === 1 && b.localName === "tr"
|
|
1027
1053
|
);
|
|
1028
|
-
if (
|
|
1054
|
+
if (i) {
|
|
1029
1055
|
let b = 0;
|
|
1030
|
-
for (const
|
|
1031
|
-
if (
|
|
1032
|
-
const
|
|
1033
|
-
if (
|
|
1034
|
-
const v = p(
|
|
1056
|
+
for (const T of i.childNodes) {
|
|
1057
|
+
if (T.nodeType !== 1) continue;
|
|
1058
|
+
const P = T;
|
|
1059
|
+
if (P.localName !== "tc") continue;
|
|
1060
|
+
const v = p(P, "tcPr"), S = v ? p(v, "gridSpan") : null, W = S && parseInt(S.getAttribute("w:val") ?? "", 10) || 1;
|
|
1035
1061
|
if (W === 1 && b < r.length) {
|
|
1036
1062
|
const E = v ? p(v, "tcW") : null;
|
|
1037
1063
|
if (E) {
|
|
@@ -1042,22 +1068,22 @@ function Bt(t, e, n, o, i = 0, a = !1) {
|
|
|
1042
1068
|
b += W;
|
|
1043
1069
|
}
|
|
1044
1070
|
}
|
|
1045
|
-
const d = r.reduce((b,
|
|
1071
|
+
const d = r.reduce((b, T) => b + T, 0);
|
|
1046
1072
|
let l = r.length;
|
|
1047
1073
|
if (l === 0 || d <= 0)
|
|
1048
|
-
if (
|
|
1074
|
+
if (i) {
|
|
1049
1075
|
let b = 0;
|
|
1050
|
-
for (const
|
|
1051
|
-
if (
|
|
1052
|
-
const
|
|
1053
|
-
if (
|
|
1054
|
-
const v = p(
|
|
1076
|
+
for (const T of i.childNodes) {
|
|
1077
|
+
if (T.nodeType !== 1) continue;
|
|
1078
|
+
const P = T;
|
|
1079
|
+
if (P.localName !== "tc") continue;
|
|
1080
|
+
const v = p(P, "tcPr"), S = v ? p(v, "gridSpan") : null;
|
|
1055
1081
|
b += S && parseInt(S.getAttribute("w:val") ?? "", 10) || 1;
|
|
1056
1082
|
}
|
|
1057
1083
|
l = Math.max(b, 1);
|
|
1058
1084
|
} else
|
|
1059
1085
|
l = 1;
|
|
1060
|
-
const f =
|
|
1086
|
+
const f = s > 0 ? s : 8320;
|
|
1061
1087
|
let g = [];
|
|
1062
1088
|
if (r.length > 0 && d > 0)
|
|
1063
1089
|
g = r.map((b) => tt(b));
|
|
@@ -1065,39 +1091,39 @@ function Bt(t, e, n, o, i = 0, a = !1) {
|
|
|
1065
1091
|
const b = f / Math.max(l, 1);
|
|
1066
1092
|
g = Array.from({ length: l }, () => tt(b));
|
|
1067
1093
|
}
|
|
1068
|
-
const w = mt(
|
|
1094
|
+
const w = mt(s);
|
|
1069
1095
|
g = bt(g, w);
|
|
1070
1096
|
const h = [];
|
|
1071
1097
|
for (const b of t.childNodes) {
|
|
1072
1098
|
if (b.nodeType !== 1) continue;
|
|
1073
|
-
const
|
|
1074
|
-
if (
|
|
1075
|
-
const
|
|
1099
|
+
const T = b;
|
|
1100
|
+
if (T.localName !== "tr") continue;
|
|
1101
|
+
const P = [];
|
|
1076
1102
|
let v = 0;
|
|
1077
|
-
for (const S of
|
|
1103
|
+
for (const S of T.childNodes) {
|
|
1078
1104
|
if (S.nodeType !== 1) continue;
|
|
1079
1105
|
const W = S;
|
|
1080
1106
|
if (W.localName !== "tc") continue;
|
|
1081
1107
|
const E = p(W, "tcPr"), k = E ? p(E, "gridSpan") : null, M = k && parseInt(k.getAttribute("w:val") ?? "", 10) || 1, H = E ? p(E, "vMerge") : null, x = H?.getAttribute("w:val") || (H ? "continue" : null), I = x === "restart" ? "restart" : x === "continue" ? "continue" : null;
|
|
1082
|
-
|
|
1108
|
+
P.push({ tc: W, tcPrEl: E, colspan: M, vMerge: I, colIdx: v }), v += M;
|
|
1083
1109
|
}
|
|
1084
|
-
h.push(
|
|
1110
|
+
h.push(P);
|
|
1085
1111
|
}
|
|
1086
|
-
function y(b,
|
|
1087
|
-
for (const
|
|
1088
|
-
if (
|
|
1112
|
+
function y(b, T) {
|
|
1113
|
+
for (const P of b)
|
|
1114
|
+
if (T >= P.colIdx && T < P.colIdx + P.colspan) return P;
|
|
1089
1115
|
return null;
|
|
1090
1116
|
}
|
|
1091
1117
|
for (let b = 0; b < h.length; b++)
|
|
1092
|
-
for (const
|
|
1093
|
-
if (
|
|
1094
|
-
let
|
|
1118
|
+
for (const T of h[b]) {
|
|
1119
|
+
if (T.vMerge !== "restart") continue;
|
|
1120
|
+
let P = 1;
|
|
1095
1121
|
for (let v = b + 1; v < h.length; v++) {
|
|
1096
|
-
const S = y(h[v],
|
|
1097
|
-
if (S && S.vMerge === "continue")
|
|
1122
|
+
const S = y(h[v], T.colIdx);
|
|
1123
|
+
if (S && S.vMerge === "continue") P++;
|
|
1098
1124
|
else break;
|
|
1099
1125
|
}
|
|
1100
|
-
|
|
1126
|
+
T.rowspan = P;
|
|
1101
1127
|
}
|
|
1102
1128
|
const m = "26px", A = () => ({
|
|
1103
1129
|
type: "paragraph",
|
|
@@ -1105,10 +1131,10 @@ function Bt(t, e, n, o, i = 0, a = !1) {
|
|
|
1105
1131
|
content: []
|
|
1106
1132
|
}), N = [];
|
|
1107
1133
|
for (const b of h) {
|
|
1108
|
-
const
|
|
1109
|
-
for (const
|
|
1110
|
-
if (
|
|
1111
|
-
const { tc: v, colspan: S, rowspan: W = 1, colIdx: E } =
|
|
1134
|
+
const T = [];
|
|
1135
|
+
for (const P of b) {
|
|
1136
|
+
if (P.vMerge === "continue") continue;
|
|
1137
|
+
const { tc: v, colspan: S, rowspan: W = 1, colIdx: E } = P;
|
|
1112
1138
|
let k = null;
|
|
1113
1139
|
if (S > 0 && g.length > 0) {
|
|
1114
1140
|
const H = Math.min(E + S, g.length), x = g.slice(E, H), I = Math.max(1, Math.round(w / Math.max(l, 1)));
|
|
@@ -1120,7 +1146,7 @@ function Bt(t, e, n, o, i = 0, a = !1) {
|
|
|
1120
1146
|
if (H.nodeType !== 1) continue;
|
|
1121
1147
|
const x = H;
|
|
1122
1148
|
if (x.localName === "p") {
|
|
1123
|
-
const { node: I } =
|
|
1149
|
+
const { node: I } = Ct(
|
|
1124
1150
|
x,
|
|
1125
1151
|
e,
|
|
1126
1152
|
n,
|
|
@@ -1130,17 +1156,17 @@ function Bt(t, e, n, o, i = 0, a = !1) {
|
|
|
1130
1156
|
);
|
|
1131
1157
|
M.push(I);
|
|
1132
1158
|
} else x.localName === "tbl" && M.push(
|
|
1133
|
-
|
|
1159
|
+
Mt(
|
|
1134
1160
|
x,
|
|
1135
1161
|
e,
|
|
1136
1162
|
n,
|
|
1137
1163
|
o,
|
|
1138
|
-
|
|
1164
|
+
s,
|
|
1139
1165
|
a
|
|
1140
1166
|
)
|
|
1141
1167
|
);
|
|
1142
1168
|
}
|
|
1143
|
-
|
|
1169
|
+
T.push({
|
|
1144
1170
|
type: "tableCell",
|
|
1145
1171
|
attrs: {
|
|
1146
1172
|
colspan: S,
|
|
@@ -1153,7 +1179,7 @@ function Bt(t, e, n, o, i = 0, a = !1) {
|
|
|
1153
1179
|
content: M.length ? M : [A()]
|
|
1154
1180
|
});
|
|
1155
1181
|
}
|
|
1156
|
-
N.push({ type: "tableRow", content:
|
|
1182
|
+
N.push({ type: "tableRow", content: T });
|
|
1157
1183
|
}
|
|
1158
1184
|
return {
|
|
1159
1185
|
type: "table",
|
|
@@ -1162,7 +1188,7 @@ function Bt(t, e, n, o, i = 0, a = !1) {
|
|
|
1162
1188
|
};
|
|
1163
1189
|
}
|
|
1164
1190
|
export {
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1191
|
+
pe as parseDocxComments,
|
|
1192
|
+
ge as parseDocxToHtml,
|
|
1193
|
+
he as parseDocxToJson
|
|
1168
1194
|
};
|