@7niao/doc-previewer 0.0.0-stage → 0.1.1
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/LICENSE +15 -0
- package/README.md +217 -2
- package/dist/assets/ArchiveRenderer-BZsm87A2.js +514 -0
- package/dist/assets/CadRenderer-DQiBmk71.js +1838 -0
- package/dist/assets/DocxRenderer-6BCR0R9L.js +3173 -0
- package/dist/assets/GisRenderer-BQ_T-z1A.js +9758 -0
- package/dist/assets/ImageRenderer-D1SFZkV3.js +24 -0
- package/dist/assets/MediaRenderer-DKj0V7cL.js +66 -0
- package/dist/assets/Model3dRenderer-DDk-HsYP.js +1966 -0
- package/dist/assets/OfdRenderer-1kDqHPDa.js +67 -0
- package/dist/assets/PdfRenderer-DuZpWPAu.js +16370 -0
- package/dist/assets/PptxRenderer-BSoVSGOz.js +48492 -0
- package/dist/assets/TextRenderer-pKpgA2wF.js +38 -0
- package/dist/assets/UnsupportedRenderer-CnjuGXg3.js +29 -0
- package/dist/assets/XlsxRenderer-Bohk5iIA.js +16257 -0
- package/dist/assets/_plugin-vue_export-helper-Djzt4Yr7.js +7 -0
- package/dist/assets/createLucideIcon-C_l8giLP.js +91 -0
- package/dist/assets/dom-Ba50_9e0.js +93 -0
- package/dist/assets/dwg2dxf-wasm-DO6Y5cnM.js +2148 -0
- package/dist/assets/file-question-mark-D7iJe3UN.js +21 -0
- package/dist/assets/jszip.min-OjSHaKmg.js +3039 -0
- package/dist/assets/ofd.es-CauEO04U.js +24255 -0
- package/dist/assets/rolldown-runtime-CwxnZyOB.js +22 -0
- package/dist/assets/three.module-B04XcvCz.js +12454 -0
- package/dist/assets/types-CVtHVd2P.js +168 -0
- package/dist/index.js +725 -0
- package/dist/libarchive/libarchive.wasm +0 -0
- package/dist/libarchive/worker-bundle.js +6 -0
- package/dist/style.css +2 -0
- package/dist/types/FileViewer.vue.d.ts +48 -0
- package/dist/types/components/PreviewToolbar.vue.d.ts +33 -0
- package/dist/types/composables/useFullscreen.d.ts +6 -0
- package/dist/types/composables/usePreviewSource.d.ts +14 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/renderers/ArchiveRenderer.vue.d.ts +18 -0
- package/dist/types/renderers/CadRenderer.vue.d.ts +29 -0
- package/dist/types/renderers/DocxRenderer.vue.d.ts +16 -0
- package/dist/types/renderers/GisRenderer.vue.d.ts +26 -0
- package/dist/types/renderers/ImageRenderer.vue.d.ts +16 -0
- package/dist/types/renderers/MediaRenderer.vue.d.ts +17 -0
- package/dist/types/renderers/Model3dRenderer.vue.d.ts +29 -0
- package/dist/types/renderers/OfdRenderer.vue.d.ts +16 -0
- package/dist/types/renderers/PdfRenderer.vue.d.ts +16 -0
- package/dist/types/renderers/PptxRenderer.vue.d.ts +16 -0
- package/dist/types/renderers/TextRenderer.vue.d.ts +16 -0
- package/dist/types/renderers/UnsupportedRenderer.vue.d.ts +14 -0
- package/dist/types/renderers/XlsxRenderer.vue.d.ts +16 -0
- package/dist/types/types.d.ts +51 -0
- package/dist/types/utils/detect.d.ts +10 -0
- package/dist/types/utils/dom.d.ts +13 -0
- package/dist/types/vendor/asn1js-stub.d.ts +10 -0
- package/package.json +77 -3
|
@@ -0,0 +1,3173 @@
|
|
|
1
|
+
import { i as e } from "./rolldown-runtime-CwxnZyOB.js";
|
|
2
|
+
import { t } from "./jszip.min-OjSHaKmg.js";
|
|
3
|
+
import { t as n } from "./_plugin-vue_export-helper-Djzt4Yr7.js";
|
|
4
|
+
import { createElementBlock as r, createElementVNode as i, defineComponent as a, onBeforeUnmount as o, onMounted as s, openBlock as c, ref as l } from "vue";
|
|
5
|
+
// node_modules/.pnpm/docx-preview@0.4.1/node_modules/docx-preview/dist/docx-preview.mjs
|
|
6
|
+
var u = /* @__PURE__ */ e(t(), 1), d;
|
|
7
|
+
(function(e) {
|
|
8
|
+
e.OfficeDocument = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", e.FontTable = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable", e.Image = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", e.Numbering = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering", e.Styles = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", e.StylesWithEffects = "http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects", e.Theme = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme", e.Settings = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings", e.WebSettings = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings", e.Hyperlink = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", e.Footnotes = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes", e.Endnotes = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes", e.Footer = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", e.Header = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", e.ExtendedProperties = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties", e.CoreProperties = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties", e.CustomProperties = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/custom-properties", e.Comments = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments", e.CommentsExtended = "http://schemas.microsoft.com/office/2011/relationships/commentsExtended", e.AltChunk = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk";
|
|
9
|
+
})(d ||= {});
|
|
10
|
+
function f(e, t) {
|
|
11
|
+
return t.elements(e).map((e) => ({
|
|
12
|
+
id: t.attr(e, "Id"),
|
|
13
|
+
type: t.attr(e, "Type"),
|
|
14
|
+
target: t.attr(e, "Target"),
|
|
15
|
+
targetMode: t.attr(e, "TargetMode")
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
function p(e) {
|
|
19
|
+
return e?.replace(/[ .]+/g, "-").replace(/[&]+/g, "and").toLowerCase();
|
|
20
|
+
}
|
|
21
|
+
function m(e) {
|
|
22
|
+
return /^[^"'].*\s.*[^"']$/.test(e) ? `'${e}'` : e;
|
|
23
|
+
}
|
|
24
|
+
function h(e) {
|
|
25
|
+
let t = e.lastIndexOf("/") + 1;
|
|
26
|
+
return [t == 0 ? "" : e.substring(0, t), t == 0 ? e : e.substring(t)];
|
|
27
|
+
}
|
|
28
|
+
function g(e, t) {
|
|
29
|
+
try {
|
|
30
|
+
return new URL(e, "http://docx/" + t).toString().substring(12);
|
|
31
|
+
} catch {
|
|
32
|
+
return `${t}${e}`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function _(e, t) {
|
|
36
|
+
return e.reduce((e, n) => (e[t(n)] = n, e), {});
|
|
37
|
+
}
|
|
38
|
+
function ee(e) {
|
|
39
|
+
return new Promise((t, n) => {
|
|
40
|
+
let r = new FileReader();
|
|
41
|
+
r.onloadend = () => t(r.result), r.onerror = () => n(), r.readAsDataURL(e);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function v(e) {
|
|
45
|
+
return e && typeof e == "object" && !Array.isArray(e);
|
|
46
|
+
}
|
|
47
|
+
function y(e) {
|
|
48
|
+
return typeof e == "string" || e instanceof String;
|
|
49
|
+
}
|
|
50
|
+
function b(e, ...t) {
|
|
51
|
+
if (!t.length) return e;
|
|
52
|
+
let n = t.shift();
|
|
53
|
+
if (v(e) && v(n)) for (let t in n) v(n[t]) ? b(e[t] ?? (e[t] = {}), n[t]) : e[t] = n[t];
|
|
54
|
+
return b(e, ...t);
|
|
55
|
+
}
|
|
56
|
+
function x(e) {
|
|
57
|
+
return Array.isArray(e) ? e : [e];
|
|
58
|
+
}
|
|
59
|
+
function te(e, t, n) {
|
|
60
|
+
return t > e ? t : n < e ? n : e;
|
|
61
|
+
}
|
|
62
|
+
var S = { wordml: "http://schemas.openxmlformats.org/wordprocessingml/2006/main" }, C = {
|
|
63
|
+
Dxa: {
|
|
64
|
+
mul: .05,
|
|
65
|
+
unit: "pt"
|
|
66
|
+
},
|
|
67
|
+
Emu: {
|
|
68
|
+
mul: 1 / 12700,
|
|
69
|
+
unit: "pt"
|
|
70
|
+
},
|
|
71
|
+
FontSize: {
|
|
72
|
+
mul: .5,
|
|
73
|
+
unit: "pt"
|
|
74
|
+
},
|
|
75
|
+
Border: {
|
|
76
|
+
mul: .125,
|
|
77
|
+
unit: "pt",
|
|
78
|
+
min: .25,
|
|
79
|
+
max: 12
|
|
80
|
+
},
|
|
81
|
+
Point: {
|
|
82
|
+
mul: 1,
|
|
83
|
+
unit: "pt"
|
|
84
|
+
},
|
|
85
|
+
Percent: {
|
|
86
|
+
mul: .02,
|
|
87
|
+
unit: "%"
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
function w(e, t = C.Dxa) {
|
|
91
|
+
if (e == null || /.+(p[xt]|[%])$/.test(e)) return e;
|
|
92
|
+
var n = parseInt(e) * t.mul;
|
|
93
|
+
return t.min && t.max && (n = te(n, t.min, t.max)), `${n.toFixed(2)}${t.unit}`;
|
|
94
|
+
}
|
|
95
|
+
function ne(e, t = !1) {
|
|
96
|
+
switch (e) {
|
|
97
|
+
case "1": return !0;
|
|
98
|
+
case "0": return !1;
|
|
99
|
+
case "on": return !0;
|
|
100
|
+
case "off": return !1;
|
|
101
|
+
case "true": return !0;
|
|
102
|
+
case "false": return !1;
|
|
103
|
+
default: return t;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function T(e, t, n) {
|
|
107
|
+
if (e.namespaceURI != S.wordml) return !1;
|
|
108
|
+
switch (e.localName) {
|
|
109
|
+
case "color":
|
|
110
|
+
t.color = n.attr(e, "val");
|
|
111
|
+
break;
|
|
112
|
+
case "sz":
|
|
113
|
+
t.fontSize = n.lengthAttr(e, "val", C.FontSize);
|
|
114
|
+
break;
|
|
115
|
+
default: return !1;
|
|
116
|
+
}
|
|
117
|
+
return !0;
|
|
118
|
+
}
|
|
119
|
+
function re(e, t = !1) {
|
|
120
|
+
t && (e = e.replace(/<[?].*[?]>/, "")), e = ae(e);
|
|
121
|
+
let n = new DOMParser().parseFromString(e, "application/xml"), r = ie(n);
|
|
122
|
+
if (r) throw Error(r);
|
|
123
|
+
return n;
|
|
124
|
+
}
|
|
125
|
+
function ie(e) {
|
|
126
|
+
return e.getElementsByTagName("parsererror")[0]?.textContent;
|
|
127
|
+
}
|
|
128
|
+
function ae(e) {
|
|
129
|
+
return e.charCodeAt(0) === 65279 ? e.substring(1) : e;
|
|
130
|
+
}
|
|
131
|
+
function oe(e) {
|
|
132
|
+
return new XMLSerializer().serializeToString(e);
|
|
133
|
+
}
|
|
134
|
+
var E = class {
|
|
135
|
+
elements(e, t = null) {
|
|
136
|
+
let n = [];
|
|
137
|
+
for (let r = 0, i = e.childNodes.length; r < i; r++) {
|
|
138
|
+
let i = e.childNodes.item(r);
|
|
139
|
+
i.nodeType == Node.ELEMENT_NODE && (t == null || i.localName == t) && n.push(i);
|
|
140
|
+
}
|
|
141
|
+
return n;
|
|
142
|
+
}
|
|
143
|
+
element(e, t) {
|
|
144
|
+
for (let n = 0, r = e.childNodes.length; n < r; n++) {
|
|
145
|
+
let r = e.childNodes.item(n);
|
|
146
|
+
if (r.nodeType == 1 && r.localName == t) return r;
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
elementAttr(e, t, n) {
|
|
151
|
+
var r = this.element(e, t);
|
|
152
|
+
return r ? this.attr(r, n) : void 0;
|
|
153
|
+
}
|
|
154
|
+
attrs(e) {
|
|
155
|
+
return Array.from(e.attributes);
|
|
156
|
+
}
|
|
157
|
+
attr(e, t) {
|
|
158
|
+
for (let n = 0, r = e.attributes.length; n < r; n++) {
|
|
159
|
+
let r = e.attributes.item(n);
|
|
160
|
+
if (r.localName == t) return r.value;
|
|
161
|
+
}
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
intAttr(e, t, n = null) {
|
|
165
|
+
var r = this.attr(e, t);
|
|
166
|
+
return r ? parseInt(r) : n;
|
|
167
|
+
}
|
|
168
|
+
hexAttr(e, t, n = null) {
|
|
169
|
+
var r = this.attr(e, t);
|
|
170
|
+
return r ? parseInt(r, 16) : n;
|
|
171
|
+
}
|
|
172
|
+
floatAttr(e, t, n = null) {
|
|
173
|
+
var r = this.attr(e, t);
|
|
174
|
+
return r ? parseFloat(r) : n;
|
|
175
|
+
}
|
|
176
|
+
boolAttr(e, t, n = null) {
|
|
177
|
+
return ne(this.attr(e, t), n);
|
|
178
|
+
}
|
|
179
|
+
lengthAttr(e, t, n = C.Dxa) {
|
|
180
|
+
return w(this.attr(e, t), n);
|
|
181
|
+
}
|
|
182
|
+
}, D = new E(), O = class {
|
|
183
|
+
constructor(e, t) {
|
|
184
|
+
this._package = e, this.path = t;
|
|
185
|
+
}
|
|
186
|
+
async load() {
|
|
187
|
+
this.rels = await this._package.loadRelationships(this.path);
|
|
188
|
+
let e = await this._package.load(this.path), t = this._package.parseXmlDocument(e);
|
|
189
|
+
this._package.options.keepOrigin && (this._xmlDocument = t), this.parseXml(t.firstElementChild);
|
|
190
|
+
}
|
|
191
|
+
save() {
|
|
192
|
+
this._package.update(this.path, oe(this._xmlDocument));
|
|
193
|
+
}
|
|
194
|
+
parseXml(e) {}
|
|
195
|
+
}, se = {
|
|
196
|
+
embedRegular: "regular",
|
|
197
|
+
embedBold: "bold",
|
|
198
|
+
embedItalic: "italic",
|
|
199
|
+
embedBoldItalic: "boldItalic"
|
|
200
|
+
};
|
|
201
|
+
function ce(e, t) {
|
|
202
|
+
return t.elements(e).map((e) => le(e, t));
|
|
203
|
+
}
|
|
204
|
+
function le(e, t) {
|
|
205
|
+
let n = {
|
|
206
|
+
name: t.attr(e, "name"),
|
|
207
|
+
embedFontRefs: []
|
|
208
|
+
};
|
|
209
|
+
for (let r of t.elements(e)) switch (r.localName) {
|
|
210
|
+
case "family":
|
|
211
|
+
n.family = t.attr(r, "val");
|
|
212
|
+
break;
|
|
213
|
+
case "altName":
|
|
214
|
+
n.altName = t.attr(r, "val");
|
|
215
|
+
break;
|
|
216
|
+
case "embedRegular":
|
|
217
|
+
case "embedBold":
|
|
218
|
+
case "embedItalic":
|
|
219
|
+
case "embedBoldItalic": n.embedFontRefs.push(ue(r, t));
|
|
220
|
+
}
|
|
221
|
+
return n;
|
|
222
|
+
}
|
|
223
|
+
function ue(e, t) {
|
|
224
|
+
return {
|
|
225
|
+
id: t.attr(e, "id"),
|
|
226
|
+
key: t.attr(e, "fontKey"),
|
|
227
|
+
type: se[e.localName]
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
var de = class extends O {
|
|
231
|
+
parseXml(e) {
|
|
232
|
+
this.fonts = ce(e, this._package.xmlParser);
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
function fe(e, t) {
|
|
236
|
+
return t.elements(e).map((e) => ({
|
|
237
|
+
extension: t.attr(e, "Extension"),
|
|
238
|
+
partName: t.attr(e, "PartName"),
|
|
239
|
+
contentType: t.attr(e, "ContentType")
|
|
240
|
+
}));
|
|
241
|
+
}
|
|
242
|
+
var pe = class e {
|
|
243
|
+
constructor(e, t) {
|
|
244
|
+
this._zip = e, this.options = t, this.xmlParser = new E();
|
|
245
|
+
}
|
|
246
|
+
get(e) {
|
|
247
|
+
let t = me(e);
|
|
248
|
+
return this._zip.files[t] ?? this._zip.files[t.replace(/\//g, "\\")];
|
|
249
|
+
}
|
|
250
|
+
update(e, t) {
|
|
251
|
+
this._zip.file(e, t);
|
|
252
|
+
}
|
|
253
|
+
static async load(t, n) {
|
|
254
|
+
let r = await u.default.loadAsync(t);
|
|
255
|
+
return new e(r, n);
|
|
256
|
+
}
|
|
257
|
+
save(e = "blob") {
|
|
258
|
+
return this._zip.generateAsync({ type: e });
|
|
259
|
+
}
|
|
260
|
+
load(e, t = "string") {
|
|
261
|
+
return this.get(e)?.async(t) ?? Promise.resolve(null);
|
|
262
|
+
}
|
|
263
|
+
async loadRelationships(e = null) {
|
|
264
|
+
let t = "_rels/.rels";
|
|
265
|
+
if (e != null) {
|
|
266
|
+
let [n, r] = h(e);
|
|
267
|
+
t = `${n}_rels/${r}.rels`;
|
|
268
|
+
}
|
|
269
|
+
let n = await this.load(t);
|
|
270
|
+
return n ? f(this.parseXmlDocument(n).firstElementChild, this.xmlParser) : null;
|
|
271
|
+
}
|
|
272
|
+
async loadContentTypes() {
|
|
273
|
+
let e = await this.load("[Content_Types].xml");
|
|
274
|
+
return e ? fe(this.parseXmlDocument(e).firstElementChild, this.xmlParser) : [];
|
|
275
|
+
}
|
|
276
|
+
parseXmlDocument(e) {
|
|
277
|
+
return re(e, this.options.trimXmlDeclaration);
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
function me(e) {
|
|
281
|
+
return e.startsWith("/") ? e.substr(1) : e;
|
|
282
|
+
}
|
|
283
|
+
var he = class extends O {
|
|
284
|
+
constructor(e, t, n) {
|
|
285
|
+
super(e, t), this._documentParser = n;
|
|
286
|
+
}
|
|
287
|
+
parseXml(e) {
|
|
288
|
+
this.body = this._documentParser.parseDocumentFile(e);
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
function k(e, t) {
|
|
292
|
+
return {
|
|
293
|
+
type: t.attr(e, "val"),
|
|
294
|
+
color: t.attr(e, "color"),
|
|
295
|
+
size: t.lengthAttr(e, "sz", C.Border),
|
|
296
|
+
offset: t.lengthAttr(e, "space", C.Point),
|
|
297
|
+
frame: t.boolAttr(e, "frame"),
|
|
298
|
+
shadow: t.boolAttr(e, "shadow")
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
function ge(e, t) {
|
|
302
|
+
var n = {};
|
|
303
|
+
for (let r of t.elements(e)) switch (r.localName) {
|
|
304
|
+
case "left":
|
|
305
|
+
n.left = k(r, t);
|
|
306
|
+
break;
|
|
307
|
+
case "top":
|
|
308
|
+
n.top = k(r, t);
|
|
309
|
+
break;
|
|
310
|
+
case "right":
|
|
311
|
+
n.right = k(r, t);
|
|
312
|
+
break;
|
|
313
|
+
case "bottom": n.bottom = k(r, t);
|
|
314
|
+
}
|
|
315
|
+
return n;
|
|
316
|
+
}
|
|
317
|
+
var _e;
|
|
318
|
+
(function(e) {
|
|
319
|
+
e.Continuous = "continuous", e.NextPage = "nextPage", e.NextColumn = "nextColumn", e.EvenPage = "evenPage", e.OddPage = "oddPage";
|
|
320
|
+
})(_e ||= {});
|
|
321
|
+
function A(e, t = D) {
|
|
322
|
+
var n = {};
|
|
323
|
+
for (let r of t.elements(e)) switch (r.localName) {
|
|
324
|
+
case "pgSz":
|
|
325
|
+
n.pageSize = {
|
|
326
|
+
width: t.lengthAttr(r, "w"),
|
|
327
|
+
height: t.lengthAttr(r, "h"),
|
|
328
|
+
orientation: t.attr(r, "orient")
|
|
329
|
+
};
|
|
330
|
+
break;
|
|
331
|
+
case "type":
|
|
332
|
+
n.type = t.attr(r, "val");
|
|
333
|
+
break;
|
|
334
|
+
case "pgMar":
|
|
335
|
+
n.pageMargins = {
|
|
336
|
+
left: t.lengthAttr(r, "left"),
|
|
337
|
+
right: t.lengthAttr(r, "right"),
|
|
338
|
+
top: t.lengthAttr(r, "top"),
|
|
339
|
+
bottom: t.lengthAttr(r, "bottom"),
|
|
340
|
+
header: t.lengthAttr(r, "header"),
|
|
341
|
+
footer: t.lengthAttr(r, "footer"),
|
|
342
|
+
gutter: t.lengthAttr(r, "gutter")
|
|
343
|
+
};
|
|
344
|
+
break;
|
|
345
|
+
case "cols":
|
|
346
|
+
n.columns = ve(r, t);
|
|
347
|
+
break;
|
|
348
|
+
case "headerReference":
|
|
349
|
+
(n.headerRefs ??= []).push(j(r, t));
|
|
350
|
+
break;
|
|
351
|
+
case "footerReference":
|
|
352
|
+
(n.footerRefs ??= []).push(j(r, t));
|
|
353
|
+
break;
|
|
354
|
+
case "titlePg":
|
|
355
|
+
n.titlePage = t.boolAttr(r, "val", !0);
|
|
356
|
+
break;
|
|
357
|
+
case "pgBorders":
|
|
358
|
+
n.pageBorders = ge(r, t);
|
|
359
|
+
break;
|
|
360
|
+
case "pgNumType": n.pageNumber = ye(r, t);
|
|
361
|
+
}
|
|
362
|
+
return n;
|
|
363
|
+
}
|
|
364
|
+
function ve(e, t) {
|
|
365
|
+
return {
|
|
366
|
+
numberOfColumns: t.intAttr(e, "num"),
|
|
367
|
+
space: t.lengthAttr(e, "space"),
|
|
368
|
+
separator: t.boolAttr(e, "sep"),
|
|
369
|
+
equalWidth: t.boolAttr(e, "equalWidth", !0),
|
|
370
|
+
columns: t.elements(e, "col").map((e) => ({
|
|
371
|
+
width: t.lengthAttr(e, "w"),
|
|
372
|
+
space: t.lengthAttr(e, "space")
|
|
373
|
+
}))
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
function ye(e, t) {
|
|
377
|
+
return {
|
|
378
|
+
chapSep: t.attr(e, "chapSep"),
|
|
379
|
+
chapStyle: t.attr(e, "chapStyle"),
|
|
380
|
+
format: t.attr(e, "fmt"),
|
|
381
|
+
start: t.intAttr(e, "start")
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
function j(e, t) {
|
|
385
|
+
return {
|
|
386
|
+
id: t.attr(e, "id"),
|
|
387
|
+
type: t.attr(e, "type")
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
function be(e, t) {
|
|
391
|
+
return {
|
|
392
|
+
before: t.lengthAttr(e, "before"),
|
|
393
|
+
after: t.lengthAttr(e, "after"),
|
|
394
|
+
line: t.intAttr(e, "line"),
|
|
395
|
+
lineRule: t.attr(e, "lineRule")
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
function M(e, t) {
|
|
399
|
+
let n = {};
|
|
400
|
+
for (let r of t.elements(e)) xe(r, n, t);
|
|
401
|
+
return n;
|
|
402
|
+
}
|
|
403
|
+
function xe(e, t, n) {
|
|
404
|
+
return !!T(e, t, n);
|
|
405
|
+
}
|
|
406
|
+
function N(e, t) {
|
|
407
|
+
let n = {};
|
|
408
|
+
for (let r of t.elements(e)) P(r, n, t);
|
|
409
|
+
return n;
|
|
410
|
+
}
|
|
411
|
+
function P(e, t, n) {
|
|
412
|
+
if (e.namespaceURI != S.wordml) return !1;
|
|
413
|
+
if (T(e, t, n)) return !0;
|
|
414
|
+
switch (e.localName) {
|
|
415
|
+
case "tabs":
|
|
416
|
+
t.tabs = Se(e, n);
|
|
417
|
+
break;
|
|
418
|
+
case "sectPr":
|
|
419
|
+
t.sectionProps = A(e, n);
|
|
420
|
+
break;
|
|
421
|
+
case "numPr":
|
|
422
|
+
t.numbering = Ce(e, n);
|
|
423
|
+
break;
|
|
424
|
+
case "spacing": return t.lineSpacing = be(e, n), !1;
|
|
425
|
+
case "textAlignment": return t.textAlignment = n.attr(e, "val"), !1;
|
|
426
|
+
case "keepLines":
|
|
427
|
+
t.keepLines = n.boolAttr(e, "val", !0);
|
|
428
|
+
break;
|
|
429
|
+
case "keepNext":
|
|
430
|
+
t.keepNext = n.boolAttr(e, "val", !0);
|
|
431
|
+
break;
|
|
432
|
+
case "pageBreakBefore":
|
|
433
|
+
t.pageBreakBefore = n.boolAttr(e, "val", !0);
|
|
434
|
+
break;
|
|
435
|
+
case "outlineLvl":
|
|
436
|
+
t.outlineLevel = n.intAttr(e, "val");
|
|
437
|
+
break;
|
|
438
|
+
case "pStyle":
|
|
439
|
+
t.styleName = n.attr(e, "val");
|
|
440
|
+
break;
|
|
441
|
+
case "rPr":
|
|
442
|
+
t.runProps = M(e, n);
|
|
443
|
+
break;
|
|
444
|
+
default: return !1;
|
|
445
|
+
}
|
|
446
|
+
return !0;
|
|
447
|
+
}
|
|
448
|
+
function Se(e, t) {
|
|
449
|
+
return t.elements(e, "tab").map((e) => ({
|
|
450
|
+
position: t.lengthAttr(e, "pos"),
|
|
451
|
+
leader: t.attr(e, "leader"),
|
|
452
|
+
style: t.attr(e, "val")
|
|
453
|
+
}));
|
|
454
|
+
}
|
|
455
|
+
function Ce(e, t) {
|
|
456
|
+
var n = {};
|
|
457
|
+
for (let r of t.elements(e)) switch (r.localName) {
|
|
458
|
+
case "numId":
|
|
459
|
+
n.id = t.attr(r, "val");
|
|
460
|
+
break;
|
|
461
|
+
case "ilvl": n.level = t.intAttr(r, "val");
|
|
462
|
+
}
|
|
463
|
+
return n;
|
|
464
|
+
}
|
|
465
|
+
function we(e, t) {
|
|
466
|
+
let n = {
|
|
467
|
+
numberings: [],
|
|
468
|
+
abstractNumberings: [],
|
|
469
|
+
bulletPictures: []
|
|
470
|
+
};
|
|
471
|
+
for (let r of t.elements(e)) switch (r.localName) {
|
|
472
|
+
case "num":
|
|
473
|
+
n.numberings.push(Te(r, t));
|
|
474
|
+
break;
|
|
475
|
+
case "abstractNum":
|
|
476
|
+
n.abstractNumberings.push(Ee(r, t));
|
|
477
|
+
break;
|
|
478
|
+
case "numPicBullet": n.bulletPictures.push(Oe(r, t));
|
|
479
|
+
}
|
|
480
|
+
return n;
|
|
481
|
+
}
|
|
482
|
+
function Te(e, t) {
|
|
483
|
+
let n = {
|
|
484
|
+
id: t.attr(e, "numId"),
|
|
485
|
+
overrides: []
|
|
486
|
+
};
|
|
487
|
+
for (let r of t.elements(e)) switch (r.localName) {
|
|
488
|
+
case "abstractNumId":
|
|
489
|
+
n.abstractId = t.attr(r, "val");
|
|
490
|
+
break;
|
|
491
|
+
case "lvlOverride": n.overrides.push(De(r, t));
|
|
492
|
+
}
|
|
493
|
+
return n;
|
|
494
|
+
}
|
|
495
|
+
function Ee(e, t) {
|
|
496
|
+
let n = {
|
|
497
|
+
id: t.attr(e, "abstractNumId"),
|
|
498
|
+
levels: []
|
|
499
|
+
};
|
|
500
|
+
for (let r of t.elements(e)) switch (r.localName) {
|
|
501
|
+
case "name":
|
|
502
|
+
n.name = t.attr(r, "val");
|
|
503
|
+
break;
|
|
504
|
+
case "multiLevelType":
|
|
505
|
+
n.multiLevelType = t.attr(r, "val");
|
|
506
|
+
break;
|
|
507
|
+
case "numStyleLink":
|
|
508
|
+
n.numberingStyleLink = t.attr(r, "val");
|
|
509
|
+
break;
|
|
510
|
+
case "styleLink":
|
|
511
|
+
n.styleLink = t.attr(r, "val");
|
|
512
|
+
break;
|
|
513
|
+
case "lvl": n.levels.push(F(r, t));
|
|
514
|
+
}
|
|
515
|
+
return n;
|
|
516
|
+
}
|
|
517
|
+
function F(e, t) {
|
|
518
|
+
let n = { level: t.intAttr(e, "ilvl") };
|
|
519
|
+
for (let r of t.elements(e)) switch (r.localName) {
|
|
520
|
+
case "start":
|
|
521
|
+
n.start = t.attr(r, "val");
|
|
522
|
+
break;
|
|
523
|
+
case "lvlRestart":
|
|
524
|
+
n.restart = t.intAttr(r, "val");
|
|
525
|
+
break;
|
|
526
|
+
case "numFmt":
|
|
527
|
+
n.format = t.attr(r, "val");
|
|
528
|
+
break;
|
|
529
|
+
case "lvlText":
|
|
530
|
+
n.text = t.attr(r, "val");
|
|
531
|
+
break;
|
|
532
|
+
case "lvlJc":
|
|
533
|
+
n.justification = t.attr(r, "val");
|
|
534
|
+
break;
|
|
535
|
+
case "lvlPicBulletId":
|
|
536
|
+
n.bulletPictureId = t.attr(r, "val");
|
|
537
|
+
break;
|
|
538
|
+
case "pStyle":
|
|
539
|
+
n.paragraphStyle = t.attr(r, "val");
|
|
540
|
+
break;
|
|
541
|
+
case "pPr":
|
|
542
|
+
n.paragraphProps = N(r, t);
|
|
543
|
+
break;
|
|
544
|
+
case "rPr": n.runProps = M(r, t);
|
|
545
|
+
}
|
|
546
|
+
return n;
|
|
547
|
+
}
|
|
548
|
+
function De(e, t) {
|
|
549
|
+
let n = { level: t.intAttr(e, "ilvl") };
|
|
550
|
+
for (let r of t.elements(e)) switch (r.localName) {
|
|
551
|
+
case "startOverride":
|
|
552
|
+
n.start = t.intAttr(r, "val");
|
|
553
|
+
break;
|
|
554
|
+
case "lvl": n.numberingLevel = F(r, t);
|
|
555
|
+
}
|
|
556
|
+
return n;
|
|
557
|
+
}
|
|
558
|
+
function Oe(e, t) {
|
|
559
|
+
var n = t.element(e, "pict"), r = n && t.element(n, "shape"), i = r && t.element(r, "imagedata");
|
|
560
|
+
return i ? {
|
|
561
|
+
id: t.attr(e, "numPicBulletId"),
|
|
562
|
+
referenceId: t.attr(i, "id"),
|
|
563
|
+
style: t.attr(r, "style")
|
|
564
|
+
} : null;
|
|
565
|
+
}
|
|
566
|
+
var ke = class extends O {
|
|
567
|
+
constructor(e, t, n) {
|
|
568
|
+
super(e, t), this._documentParser = n;
|
|
569
|
+
}
|
|
570
|
+
parseXml(e) {
|
|
571
|
+
Object.assign(this, we(e, this._package.xmlParser)), this.domNumberings = this._documentParser.parseNumberingFile(e);
|
|
572
|
+
}
|
|
573
|
+
}, Ae = class extends O {
|
|
574
|
+
constructor(e, t, n) {
|
|
575
|
+
super(e, t), this._documentParser = n;
|
|
576
|
+
}
|
|
577
|
+
parseXml(e) {
|
|
578
|
+
this.styles = this._documentParser.parseStylesFile(e);
|
|
579
|
+
}
|
|
580
|
+
}, I;
|
|
581
|
+
(function(e) {
|
|
582
|
+
e.Document = "document", e.Paragraph = "paragraph", e.Run = "run", e.Break = "break", e.NoBreakHyphen = "noBreakHyphen", e.Table = "table", e.Row = "row", e.Cell = "cell", e.Hyperlink = "hyperlink", e.SmartTag = "smartTag", e.Drawing = "drawing", e.Image = "image", e.Text = "text", e.Tab = "tab", e.Symbol = "symbol", e.BookmarkStart = "bookmarkStart", e.BookmarkEnd = "bookmarkEnd", e.Footer = "footer", e.Header = "header", e.FootnoteReference = "footnoteReference", e.EndnoteReference = "endnoteReference", e.Footnote = "footnote", e.Endnote = "endnote", e.SimpleField = "simpleField", e.ComplexField = "complexField", e.Instruction = "instruction", e.VmlPicture = "vmlPicture", e.MmlMath = "mmlMath", e.MmlMathParagraph = "mmlMathParagraph", e.MmlFraction = "mmlFraction", e.MmlFunction = "mmlFunction", e.MmlFunctionName = "mmlFunctionName", e.MmlNumerator = "mmlNumerator", e.MmlDenominator = "mmlDenominator", e.MmlRadical = "mmlRadical", e.MmlBase = "mmlBase", e.MmlDegree = "mmlDegree", e.MmlSuperscript = "mmlSuperscript", e.MmlSubscript = "mmlSubscript", e.MmlPreSubSuper = "mmlPreSubSuper", e.MmlSubArgument = "mmlSubArgument", e.MmlSuperArgument = "mmlSuperArgument", e.MmlNary = "mmlNary", e.MmlDelimiter = "mmlDelimiter", e.MmlRun = "mmlRun", e.MmlEquationArray = "mmlEquationArray", e.MmlLimit = "mmlLimit", e.MmlLimitLower = "mmlLimitLower", e.MmlMatrix = "mmlMatrix", e.MmlMatrixRow = "mmlMatrixRow", e.MmlBox = "mmlBox", e.MmlBar = "mmlBar", e.MmlGroupChar = "mmlGroupChar", e.VmlElement = "vmlElement", e.Inserted = "inserted", e.Deleted = "deleted", e.DeletedText = "deletedText", e.Comment = "comment", e.CommentReference = "commentReference", e.CommentRangeStart = "commentRangeStart", e.CommentRangeEnd = "commentRangeEnd", e.AltChunk = "altChunk";
|
|
583
|
+
})(I ||= {});
|
|
584
|
+
var L = class {
|
|
585
|
+
constructor() {
|
|
586
|
+
this.children = [], this.cssStyle = {};
|
|
587
|
+
}
|
|
588
|
+
}, je = class extends L {
|
|
589
|
+
constructor() {
|
|
590
|
+
super(...arguments), this.type = I.Header;
|
|
591
|
+
}
|
|
592
|
+
}, Me = class extends L {
|
|
593
|
+
constructor() {
|
|
594
|
+
super(...arguments), this.type = I.Footer;
|
|
595
|
+
}
|
|
596
|
+
}, R = class extends O {
|
|
597
|
+
constructor(e, t, n) {
|
|
598
|
+
super(e, t), this._documentParser = n;
|
|
599
|
+
}
|
|
600
|
+
parseXml(e) {
|
|
601
|
+
this.rootElement = this.createRootElement(), this.rootElement.children = this._documentParser.parseBodyElements(e);
|
|
602
|
+
}
|
|
603
|
+
}, Ne = class extends R {
|
|
604
|
+
createRootElement() {
|
|
605
|
+
return new je();
|
|
606
|
+
}
|
|
607
|
+
}, Pe = class extends R {
|
|
608
|
+
createRootElement() {
|
|
609
|
+
return new Me();
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
function Fe(e, t) {
|
|
613
|
+
let n = {};
|
|
614
|
+
for (let r of t.elements(e)) switch (r.localName) {
|
|
615
|
+
case "Template":
|
|
616
|
+
n.template = r.textContent;
|
|
617
|
+
break;
|
|
618
|
+
case "Pages":
|
|
619
|
+
n.pages = z(r.textContent);
|
|
620
|
+
break;
|
|
621
|
+
case "Words":
|
|
622
|
+
n.words = z(r.textContent);
|
|
623
|
+
break;
|
|
624
|
+
case "Characters":
|
|
625
|
+
n.characters = z(r.textContent);
|
|
626
|
+
break;
|
|
627
|
+
case "Application":
|
|
628
|
+
n.application = r.textContent;
|
|
629
|
+
break;
|
|
630
|
+
case "Lines":
|
|
631
|
+
n.lines = z(r.textContent);
|
|
632
|
+
break;
|
|
633
|
+
case "Paragraphs":
|
|
634
|
+
n.paragraphs = z(r.textContent);
|
|
635
|
+
break;
|
|
636
|
+
case "Company":
|
|
637
|
+
n.company = r.textContent;
|
|
638
|
+
break;
|
|
639
|
+
case "AppVersion": n.appVersion = r.textContent;
|
|
640
|
+
}
|
|
641
|
+
return n;
|
|
642
|
+
}
|
|
643
|
+
function z(e) {
|
|
644
|
+
if (e !== void 0) return parseInt(e);
|
|
645
|
+
}
|
|
646
|
+
var Ie = class extends O {
|
|
647
|
+
parseXml(e) {
|
|
648
|
+
this.props = Fe(e, this._package.xmlParser);
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
function Le(e, t) {
|
|
652
|
+
let n = {};
|
|
653
|
+
for (let r of t.elements(e)) switch (r.localName) {
|
|
654
|
+
case "title":
|
|
655
|
+
n.title = r.textContent;
|
|
656
|
+
break;
|
|
657
|
+
case "description":
|
|
658
|
+
n.description = r.textContent;
|
|
659
|
+
break;
|
|
660
|
+
case "subject":
|
|
661
|
+
n.subject = r.textContent;
|
|
662
|
+
break;
|
|
663
|
+
case "creator":
|
|
664
|
+
n.creator = r.textContent;
|
|
665
|
+
break;
|
|
666
|
+
case "keywords":
|
|
667
|
+
n.keywords = r.textContent;
|
|
668
|
+
break;
|
|
669
|
+
case "language":
|
|
670
|
+
n.language = r.textContent;
|
|
671
|
+
break;
|
|
672
|
+
case "lastModifiedBy":
|
|
673
|
+
n.lastModifiedBy = r.textContent;
|
|
674
|
+
break;
|
|
675
|
+
case "revision": r.textContent && (n.revision = parseInt(r.textContent));
|
|
676
|
+
}
|
|
677
|
+
return n;
|
|
678
|
+
}
|
|
679
|
+
var Re = class extends O {
|
|
680
|
+
parseXml(e) {
|
|
681
|
+
this.props = Le(e, this._package.xmlParser);
|
|
682
|
+
}
|
|
683
|
+
}, ze = class {};
|
|
684
|
+
function Be(e, t) {
|
|
685
|
+
var n = new ze(), r = t.element(e, "themeElements");
|
|
686
|
+
for (let e of t.elements(r)) switch (e.localName) {
|
|
687
|
+
case "clrScheme":
|
|
688
|
+
n.colorScheme = Ve(e, t);
|
|
689
|
+
break;
|
|
690
|
+
case "fontScheme": n.fontScheme = He(e, t);
|
|
691
|
+
}
|
|
692
|
+
return n;
|
|
693
|
+
}
|
|
694
|
+
function Ve(e, t) {
|
|
695
|
+
var n = {
|
|
696
|
+
name: t.attr(e, "name"),
|
|
697
|
+
colors: {}
|
|
698
|
+
};
|
|
699
|
+
for (let a of t.elements(e)) {
|
|
700
|
+
var r = t.element(a, "srgbClr"), i = t.element(a, "sysClr");
|
|
701
|
+
r ? n.colors[a.localName] = t.attr(r, "val") : i && (n.colors[a.localName] = t.attr(i, "lastClr"));
|
|
702
|
+
}
|
|
703
|
+
return n;
|
|
704
|
+
}
|
|
705
|
+
function He(e, t) {
|
|
706
|
+
var n = { name: t.attr(e, "name") };
|
|
707
|
+
for (let r of t.elements(e)) switch (r.localName) {
|
|
708
|
+
case "majorFont":
|
|
709
|
+
n.majorFont = B(r, t);
|
|
710
|
+
break;
|
|
711
|
+
case "minorFont": n.minorFont = B(r, t);
|
|
712
|
+
}
|
|
713
|
+
return n;
|
|
714
|
+
}
|
|
715
|
+
function B(e, t) {
|
|
716
|
+
return {
|
|
717
|
+
latinTypeface: t.elementAttr(e, "latin", "typeface"),
|
|
718
|
+
eaTypeface: t.elementAttr(e, "ea", "typeface"),
|
|
719
|
+
csTypeface: t.elementAttr(e, "cs", "typeface")
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
var Ue = class extends O {
|
|
723
|
+
constructor(e, t) {
|
|
724
|
+
super(e, t);
|
|
725
|
+
}
|
|
726
|
+
parseXml(e) {
|
|
727
|
+
this.theme = Be(e, this._package.xmlParser);
|
|
728
|
+
}
|
|
729
|
+
}, V = class {}, We = class extends V {
|
|
730
|
+
constructor() {
|
|
731
|
+
super(...arguments), this.type = I.Footnote;
|
|
732
|
+
}
|
|
733
|
+
}, Ge = class extends V {
|
|
734
|
+
constructor() {
|
|
735
|
+
super(...arguments), this.type = I.Endnote;
|
|
736
|
+
}
|
|
737
|
+
}, H = class extends O {
|
|
738
|
+
constructor(e, t, n) {
|
|
739
|
+
super(e, t), this._documentParser = n;
|
|
740
|
+
}
|
|
741
|
+
}, Ke = class extends H {
|
|
742
|
+
constructor(e, t, n) {
|
|
743
|
+
super(e, t, n);
|
|
744
|
+
}
|
|
745
|
+
parseXml(e) {
|
|
746
|
+
this.notes = this._documentParser.parseNotes(e, "footnote", We);
|
|
747
|
+
}
|
|
748
|
+
}, qe = class extends H {
|
|
749
|
+
constructor(e, t, n) {
|
|
750
|
+
super(e, t, n);
|
|
751
|
+
}
|
|
752
|
+
parseXml(e) {
|
|
753
|
+
this.notes = this._documentParser.parseNotes(e, "endnote", Ge);
|
|
754
|
+
}
|
|
755
|
+
};
|
|
756
|
+
function Je(e, t) {
|
|
757
|
+
var n = {};
|
|
758
|
+
for (let r of t.elements(e)) switch (r.localName) {
|
|
759
|
+
case "defaultTabStop":
|
|
760
|
+
n.defaultTabStop = t.lengthAttr(r, "val");
|
|
761
|
+
break;
|
|
762
|
+
case "footnotePr":
|
|
763
|
+
n.footnoteProps = U(r, t);
|
|
764
|
+
break;
|
|
765
|
+
case "endnotePr":
|
|
766
|
+
n.endnoteProps = U(r, t);
|
|
767
|
+
break;
|
|
768
|
+
case "autoHyphenation":
|
|
769
|
+
n.autoHyphenation = t.boolAttr(r, "val");
|
|
770
|
+
break;
|
|
771
|
+
case "evenAndOddHeaders": n.evenAndOddHeaders = t.boolAttr(r, "val", !0);
|
|
772
|
+
}
|
|
773
|
+
return n;
|
|
774
|
+
}
|
|
775
|
+
function U(e, t) {
|
|
776
|
+
var n = { defaultNoteIds: [] };
|
|
777
|
+
for (let r of t.elements(e)) switch (r.localName) {
|
|
778
|
+
case "numFmt":
|
|
779
|
+
n.nummeringFormat = t.attr(r, "val");
|
|
780
|
+
break;
|
|
781
|
+
case "footnote":
|
|
782
|
+
case "endnote": n.defaultNoteIds.push(t.attr(r, "id"));
|
|
783
|
+
}
|
|
784
|
+
return n;
|
|
785
|
+
}
|
|
786
|
+
var Ye = class extends O {
|
|
787
|
+
constructor(e, t) {
|
|
788
|
+
super(e, t);
|
|
789
|
+
}
|
|
790
|
+
parseXml(e) {
|
|
791
|
+
this.settings = Je(e, this._package.xmlParser);
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
function Xe(e, t) {
|
|
795
|
+
return t.elements(e, "property").map((e) => {
|
|
796
|
+
let n = e.firstChild;
|
|
797
|
+
return {
|
|
798
|
+
formatId: t.attr(e, "fmtid"),
|
|
799
|
+
name: t.attr(e, "name"),
|
|
800
|
+
type: n.nodeName,
|
|
801
|
+
value: n.textContent
|
|
802
|
+
};
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
var Ze = class extends O {
|
|
806
|
+
parseXml(e) {
|
|
807
|
+
this.props = Xe(e, this._package.xmlParser);
|
|
808
|
+
}
|
|
809
|
+
}, Qe = class extends O {
|
|
810
|
+
constructor(e, t, n) {
|
|
811
|
+
super(e, t), this._documentParser = n;
|
|
812
|
+
}
|
|
813
|
+
parseXml(e) {
|
|
814
|
+
this.comments = this._documentParser.parseComments(e), this.commentMap = _(this.comments, (e) => e.id);
|
|
815
|
+
}
|
|
816
|
+
}, $e = class extends O {
|
|
817
|
+
constructor(e, t) {
|
|
818
|
+
super(e, t), this.comments = [];
|
|
819
|
+
}
|
|
820
|
+
parseXml(e) {
|
|
821
|
+
let t = this._package.xmlParser;
|
|
822
|
+
for (let n of t.elements(e, "commentEx")) this.comments.push({
|
|
823
|
+
paraId: t.attr(n, "paraId"),
|
|
824
|
+
paraIdParent: t.attr(n, "paraIdParent"),
|
|
825
|
+
done: t.boolAttr(n, "done")
|
|
826
|
+
});
|
|
827
|
+
this.commentMap = _(this.comments, (e) => e.paraId);
|
|
828
|
+
}
|
|
829
|
+
}, et = [
|
|
830
|
+
{
|
|
831
|
+
type: d.OfficeDocument,
|
|
832
|
+
target: "word/document.xml"
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
type: d.ExtendedProperties,
|
|
836
|
+
target: "docProps/app.xml"
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
type: d.CoreProperties,
|
|
840
|
+
target: "docProps/core.xml"
|
|
841
|
+
},
|
|
842
|
+
{
|
|
843
|
+
type: d.CustomProperties,
|
|
844
|
+
target: "docProps/custom.xml"
|
|
845
|
+
}
|
|
846
|
+
], tt = class e {
|
|
847
|
+
constructor() {
|
|
848
|
+
this.parts = [], this.partsMap = {}, this.contentTypes = [];
|
|
849
|
+
}
|
|
850
|
+
static async load(t, n, r) {
|
|
851
|
+
var i = new e();
|
|
852
|
+
return i._options = r, i._parser = n, i._package = await pe.load(t, r), i.rels = await i._package.loadRelationships(), i.contentTypes = await i._package.loadContentTypes(), await Promise.all(et.map((e) => {
|
|
853
|
+
let t = i.rels.find((t) => t.type === e.type) ?? e;
|
|
854
|
+
return i.loadRelationshipPart(t.target, t.type);
|
|
855
|
+
})), i;
|
|
856
|
+
}
|
|
857
|
+
save(e = "blob") {
|
|
858
|
+
return this._package.save(e);
|
|
859
|
+
}
|
|
860
|
+
async loadRelationshipPart(e, t) {
|
|
861
|
+
if (this.partsMap[e]) return this.partsMap[e];
|
|
862
|
+
if (!this._package.get(e)) return null;
|
|
863
|
+
let n = null;
|
|
864
|
+
switch (t) {
|
|
865
|
+
case d.OfficeDocument:
|
|
866
|
+
this.documentPart = n = new he(this._package, e, this._parser);
|
|
867
|
+
break;
|
|
868
|
+
case d.FontTable:
|
|
869
|
+
this.fontTablePart = n = new de(this._package, e);
|
|
870
|
+
break;
|
|
871
|
+
case d.Numbering:
|
|
872
|
+
this.numberingPart = n = new ke(this._package, e, this._parser);
|
|
873
|
+
break;
|
|
874
|
+
case d.Styles:
|
|
875
|
+
this.stylesPart = n = new Ae(this._package, e, this._parser);
|
|
876
|
+
break;
|
|
877
|
+
case d.Theme:
|
|
878
|
+
this.themePart = n = new Ue(this._package, e);
|
|
879
|
+
break;
|
|
880
|
+
case d.Footnotes:
|
|
881
|
+
this.footnotesPart = n = new Ke(this._package, e, this._parser);
|
|
882
|
+
break;
|
|
883
|
+
case d.Endnotes:
|
|
884
|
+
this.endnotesPart = n = new qe(this._package, e, this._parser);
|
|
885
|
+
break;
|
|
886
|
+
case d.Footer:
|
|
887
|
+
n = new Pe(this._package, e, this._parser);
|
|
888
|
+
break;
|
|
889
|
+
case d.Header:
|
|
890
|
+
n = new Ne(this._package, e, this._parser);
|
|
891
|
+
break;
|
|
892
|
+
case d.CoreProperties:
|
|
893
|
+
this.corePropsPart = n = new Re(this._package, e);
|
|
894
|
+
break;
|
|
895
|
+
case d.ExtendedProperties:
|
|
896
|
+
this.extendedPropsPart = n = new Ie(this._package, e);
|
|
897
|
+
break;
|
|
898
|
+
case d.CustomProperties:
|
|
899
|
+
n = new Ze(this._package, e);
|
|
900
|
+
break;
|
|
901
|
+
case d.Settings:
|
|
902
|
+
this.settingsPart = n = new Ye(this._package, e);
|
|
903
|
+
break;
|
|
904
|
+
case d.Comments:
|
|
905
|
+
this.commentsPart = n = new Qe(this._package, e, this._parser);
|
|
906
|
+
break;
|
|
907
|
+
case d.CommentsExtended: this.commentsExtendedPart = n = new $e(this._package, e);
|
|
908
|
+
}
|
|
909
|
+
if (n == null) return Promise.resolve(null);
|
|
910
|
+
if (this.partsMap[e] = n, this.parts.push(n), await n.load(), n.rels?.length > 0) {
|
|
911
|
+
let [e] = h(n.path);
|
|
912
|
+
await Promise.all(n.rels.map((t) => this.loadRelationshipPart(g(t.target, e), t.type)));
|
|
913
|
+
}
|
|
914
|
+
return n;
|
|
915
|
+
}
|
|
916
|
+
async loadDocumentImage(e, t) {
|
|
917
|
+
let n = this.getPathById(t ?? this.documentPart, e);
|
|
918
|
+
return n ? this.blobToURL(await this._package.load(n, "blob"), n) : null;
|
|
919
|
+
}
|
|
920
|
+
async loadNumberingImage(e) {
|
|
921
|
+
let t = this.getPathById(this.numberingPart, e);
|
|
922
|
+
return t ? this.blobToURL(await this._package.load(t, "blob"), t) : null;
|
|
923
|
+
}
|
|
924
|
+
async loadFont(e, t) {
|
|
925
|
+
let n = this.getPathById(this.fontTablePart, e);
|
|
926
|
+
if (!n) return null;
|
|
927
|
+
let r = await this._package.load(n, "uint8array");
|
|
928
|
+
return r && this.blobToURL(new Blob([nt(r, t)]), n);
|
|
929
|
+
}
|
|
930
|
+
async loadAltChunk(e, t) {
|
|
931
|
+
let n = this.getPathById(t ?? this.documentPart, e);
|
|
932
|
+
return n ? this._package.load(n, "string") : Promise.resolve(null);
|
|
933
|
+
}
|
|
934
|
+
blobToURL(e, t) {
|
|
935
|
+
if (!e) return null;
|
|
936
|
+
if (t) {
|
|
937
|
+
let n = this.contentTypes.find((e) => e.partName === t || e.extension && t.endsWith(`.${e.extension}`));
|
|
938
|
+
e = n ? new Blob([e], { type: n.contentType }) : e;
|
|
939
|
+
}
|
|
940
|
+
return this._options.useBase64URL ? ee(e) : URL.createObjectURL(e);
|
|
941
|
+
}
|
|
942
|
+
findPartByRelId(e, t = null) {
|
|
943
|
+
var n = (t.rels ?? this.rels).find((t) => t.id == e);
|
|
944
|
+
let r = t ? h(t.path)[0] : "";
|
|
945
|
+
return n ? this.partsMap[g(n.target, r)] : null;
|
|
946
|
+
}
|
|
947
|
+
getPathById(e, t) {
|
|
948
|
+
let n = e.rels.find((e) => e.id == t), [r] = h(e.path);
|
|
949
|
+
return n ? g(n.target, r) : null;
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
function nt(e, t) {
|
|
953
|
+
let n = t.replace(/{|}|-/g, ""), r = Array(16);
|
|
954
|
+
for (let e = 0; e < 16; e++) r[16 - e - 1] = parseInt(n.substring(e * 2, e * 2 + 2), 16);
|
|
955
|
+
for (let t = 0; t < 32; t++) e[t] = e[t] ^ r[t % 16];
|
|
956
|
+
return e;
|
|
957
|
+
}
|
|
958
|
+
function rt(e, t) {
|
|
959
|
+
return {
|
|
960
|
+
type: I.BookmarkStart,
|
|
961
|
+
id: t.attr(e, "id"),
|
|
962
|
+
name: t.attr(e, "name"),
|
|
963
|
+
colFirst: t.intAttr(e, "colFirst"),
|
|
964
|
+
colLast: t.intAttr(e, "colLast")
|
|
965
|
+
};
|
|
966
|
+
}
|
|
967
|
+
function it(e, t) {
|
|
968
|
+
return {
|
|
969
|
+
type: I.BookmarkEnd,
|
|
970
|
+
id: t.attr(e, "id")
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
var at = class extends L {
|
|
974
|
+
constructor() {
|
|
975
|
+
super(...arguments), this.type = I.VmlElement, this.attrs = {};
|
|
976
|
+
}
|
|
977
|
+
};
|
|
978
|
+
function W(e, t) {
|
|
979
|
+
var n = new at();
|
|
980
|
+
switch (e.localName) {
|
|
981
|
+
case "rect":
|
|
982
|
+
n.tagName = "rect", Object.assign(n.attrs, {
|
|
983
|
+
width: "100%",
|
|
984
|
+
height: "100%"
|
|
985
|
+
});
|
|
986
|
+
break;
|
|
987
|
+
case "oval":
|
|
988
|
+
n.tagName = "ellipse", Object.assign(n.attrs, {
|
|
989
|
+
cx: "50%",
|
|
990
|
+
cy: "50%",
|
|
991
|
+
rx: "50%",
|
|
992
|
+
ry: "50%"
|
|
993
|
+
});
|
|
994
|
+
break;
|
|
995
|
+
case "line":
|
|
996
|
+
n.tagName = "line";
|
|
997
|
+
break;
|
|
998
|
+
case "shape":
|
|
999
|
+
n.tagName = "g";
|
|
1000
|
+
break;
|
|
1001
|
+
case "textbox":
|
|
1002
|
+
n.tagName = "foreignObject", Object.assign(n.attrs, {
|
|
1003
|
+
width: "100%",
|
|
1004
|
+
height: "100%"
|
|
1005
|
+
});
|
|
1006
|
+
break;
|
|
1007
|
+
default: return null;
|
|
1008
|
+
}
|
|
1009
|
+
for (let t of D.attrs(e)) switch (t.localName) {
|
|
1010
|
+
case "style":
|
|
1011
|
+
n.cssStyleText = t.value;
|
|
1012
|
+
break;
|
|
1013
|
+
case "fillcolor":
|
|
1014
|
+
n.attrs.fill = t.value;
|
|
1015
|
+
break;
|
|
1016
|
+
case "from":
|
|
1017
|
+
let [e, r] = G(t.value);
|
|
1018
|
+
Object.assign(n.attrs, {
|
|
1019
|
+
x1: e,
|
|
1020
|
+
y1: r
|
|
1021
|
+
});
|
|
1022
|
+
break;
|
|
1023
|
+
case "to":
|
|
1024
|
+
let [i, a] = G(t.value);
|
|
1025
|
+
Object.assign(n.attrs, {
|
|
1026
|
+
x2: i,
|
|
1027
|
+
y2: a
|
|
1028
|
+
});
|
|
1029
|
+
}
|
|
1030
|
+
for (let r of D.elements(e)) switch (r.localName) {
|
|
1031
|
+
case "stroke":
|
|
1032
|
+
Object.assign(n.attrs, ot(r));
|
|
1033
|
+
break;
|
|
1034
|
+
case "fill":
|
|
1035
|
+
Object.assign(n.attrs, st());
|
|
1036
|
+
break;
|
|
1037
|
+
case "imagedata":
|
|
1038
|
+
n.tagName = "image", Object.assign(n.attrs, {
|
|
1039
|
+
width: "100%",
|
|
1040
|
+
height: "100%"
|
|
1041
|
+
}), n.imageHref = {
|
|
1042
|
+
id: D.attr(r, "id"),
|
|
1043
|
+
title: D.attr(r, "title")
|
|
1044
|
+
};
|
|
1045
|
+
break;
|
|
1046
|
+
case "txbxContent":
|
|
1047
|
+
n.children.push(...t.parseBodyElements(r));
|
|
1048
|
+
break;
|
|
1049
|
+
default:
|
|
1050
|
+
let e = W(r, t);
|
|
1051
|
+
e && n.children.push(e);
|
|
1052
|
+
}
|
|
1053
|
+
return n;
|
|
1054
|
+
}
|
|
1055
|
+
function ot(e) {
|
|
1056
|
+
return {
|
|
1057
|
+
stroke: D.attr(e, "color"),
|
|
1058
|
+
"stroke-width": D.lengthAttr(e, "weight", C.Emu) ?? "1px"
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
function st(e) {
|
|
1062
|
+
return {};
|
|
1063
|
+
}
|
|
1064
|
+
function G(e) {
|
|
1065
|
+
return e.split(",");
|
|
1066
|
+
}
|
|
1067
|
+
var ct = class extends L {
|
|
1068
|
+
constructor() {
|
|
1069
|
+
super(...arguments), this.type = I.Comment;
|
|
1070
|
+
}
|
|
1071
|
+
}, lt = class extends L {
|
|
1072
|
+
constructor(e) {
|
|
1073
|
+
super(), this.id = e, this.type = I.CommentReference;
|
|
1074
|
+
}
|
|
1075
|
+
}, ut = class extends L {
|
|
1076
|
+
constructor(e) {
|
|
1077
|
+
super(), this.id = e, this.type = I.CommentRangeStart;
|
|
1078
|
+
}
|
|
1079
|
+
}, dt = class extends L {
|
|
1080
|
+
constructor(e) {
|
|
1081
|
+
super(), this.id = e, this.type = I.CommentRangeEnd;
|
|
1082
|
+
}
|
|
1083
|
+
}, K = {
|
|
1084
|
+
shd: "inherit",
|
|
1085
|
+
color: "black",
|
|
1086
|
+
borderColor: "black",
|
|
1087
|
+
highlight: "transparent"
|
|
1088
|
+
}, ft = [], q = {
|
|
1089
|
+
oMath: I.MmlMath,
|
|
1090
|
+
oMathPara: I.MmlMathParagraph,
|
|
1091
|
+
f: I.MmlFraction,
|
|
1092
|
+
func: I.MmlFunction,
|
|
1093
|
+
fName: I.MmlFunctionName,
|
|
1094
|
+
num: I.MmlNumerator,
|
|
1095
|
+
den: I.MmlDenominator,
|
|
1096
|
+
rad: I.MmlRadical,
|
|
1097
|
+
deg: I.MmlDegree,
|
|
1098
|
+
e: I.MmlBase,
|
|
1099
|
+
sSup: I.MmlSuperscript,
|
|
1100
|
+
sSub: I.MmlSubscript,
|
|
1101
|
+
sPre: I.MmlPreSubSuper,
|
|
1102
|
+
sup: I.MmlSuperArgument,
|
|
1103
|
+
sub: I.MmlSubArgument,
|
|
1104
|
+
d: I.MmlDelimiter,
|
|
1105
|
+
nary: I.MmlNary,
|
|
1106
|
+
eqArr: I.MmlEquationArray,
|
|
1107
|
+
lim: I.MmlLimit,
|
|
1108
|
+
limLow: I.MmlLimitLower,
|
|
1109
|
+
m: I.MmlMatrix,
|
|
1110
|
+
mr: I.MmlMatrixRow,
|
|
1111
|
+
box: I.MmlBox,
|
|
1112
|
+
bar: I.MmlBar,
|
|
1113
|
+
groupChr: I.MmlGroupChar
|
|
1114
|
+
}, pt = class {
|
|
1115
|
+
constructor(e) {
|
|
1116
|
+
this.options = {
|
|
1117
|
+
ignoreWidth: !1,
|
|
1118
|
+
debug: !1,
|
|
1119
|
+
...e
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
parseNotes(e, t, n) {
|
|
1123
|
+
var r = [];
|
|
1124
|
+
for (let i of D.elements(e, t)) {
|
|
1125
|
+
let e = new n();
|
|
1126
|
+
e.id = D.attr(i, "id"), e.noteType = D.attr(i, "type"), e.children = this.parseBodyElements(i), r.push(e);
|
|
1127
|
+
}
|
|
1128
|
+
return r;
|
|
1129
|
+
}
|
|
1130
|
+
parseComments(e) {
|
|
1131
|
+
var t = [];
|
|
1132
|
+
for (let n of D.elements(e, "comment")) {
|
|
1133
|
+
let e = new ct();
|
|
1134
|
+
e.id = D.attr(n, "id"), e.author = D.attr(n, "author"), e.initials = D.attr(n, "initials"), e.date = D.attr(n, "date"), e.children = this.parseBodyElements(n), t.push(e);
|
|
1135
|
+
}
|
|
1136
|
+
return t;
|
|
1137
|
+
}
|
|
1138
|
+
parseDocumentFile(e) {
|
|
1139
|
+
var t = D.element(e, "body"), n = D.element(e, "background"), r = D.element(t, "sectPr");
|
|
1140
|
+
return {
|
|
1141
|
+
type: I.Document,
|
|
1142
|
+
children: this.parseBodyElements(t),
|
|
1143
|
+
props: r ? A(r, D) : {},
|
|
1144
|
+
cssStyle: n ? this.parseBackground(n) : {}
|
|
1145
|
+
};
|
|
1146
|
+
}
|
|
1147
|
+
parseBackground(e) {
|
|
1148
|
+
var t = {}, n = J.colorAttr(e, "color");
|
|
1149
|
+
return n && (t["background-color"] = n), t;
|
|
1150
|
+
}
|
|
1151
|
+
parseBodyElements(e) {
|
|
1152
|
+
var t = [];
|
|
1153
|
+
for (let n of D.elements(e)) switch (n.localName) {
|
|
1154
|
+
case "p":
|
|
1155
|
+
t.push(this.parseParagraph(n));
|
|
1156
|
+
break;
|
|
1157
|
+
case "altChunk":
|
|
1158
|
+
t.push(this.parseAltChunk(n));
|
|
1159
|
+
break;
|
|
1160
|
+
case "tbl":
|
|
1161
|
+
t.push(this.parseTable(n));
|
|
1162
|
+
break;
|
|
1163
|
+
case "sdt": t.push(...this.parseSdt(n, (e) => this.parseBodyElements(e)));
|
|
1164
|
+
}
|
|
1165
|
+
return t;
|
|
1166
|
+
}
|
|
1167
|
+
parseStylesFile(e) {
|
|
1168
|
+
var t = [];
|
|
1169
|
+
for (let n of D.elements(e)) switch (n.localName) {
|
|
1170
|
+
case "style":
|
|
1171
|
+
t.push(this.parseStyle(n));
|
|
1172
|
+
break;
|
|
1173
|
+
case "docDefaults": t.push(this.parseDefaultStyles(n));
|
|
1174
|
+
}
|
|
1175
|
+
return t;
|
|
1176
|
+
}
|
|
1177
|
+
parseDefaultStyles(e) {
|
|
1178
|
+
var t = {
|
|
1179
|
+
id: null,
|
|
1180
|
+
name: null,
|
|
1181
|
+
target: null,
|
|
1182
|
+
basedOn: null,
|
|
1183
|
+
styles: []
|
|
1184
|
+
};
|
|
1185
|
+
for (let i of D.elements(e)) switch (i.localName) {
|
|
1186
|
+
case "rPrDefault":
|
|
1187
|
+
var n = D.element(i, "rPr");
|
|
1188
|
+
n && t.styles.push({
|
|
1189
|
+
target: "span",
|
|
1190
|
+
values: this.parseDefaultProperties(n, {})
|
|
1191
|
+
});
|
|
1192
|
+
break;
|
|
1193
|
+
case "pPrDefault":
|
|
1194
|
+
var r = D.element(i, "pPr");
|
|
1195
|
+
r && t.styles.push({
|
|
1196
|
+
target: "p",
|
|
1197
|
+
values: this.parseDefaultProperties(r, {})
|
|
1198
|
+
});
|
|
1199
|
+
}
|
|
1200
|
+
return t;
|
|
1201
|
+
}
|
|
1202
|
+
parseStyle(e) {
|
|
1203
|
+
var t = {
|
|
1204
|
+
id: D.attr(e, "styleId"),
|
|
1205
|
+
isDefault: D.boolAttr(e, "default"),
|
|
1206
|
+
name: null,
|
|
1207
|
+
target: null,
|
|
1208
|
+
basedOn: null,
|
|
1209
|
+
styles: [],
|
|
1210
|
+
linked: null
|
|
1211
|
+
};
|
|
1212
|
+
switch (D.attr(e, "type")) {
|
|
1213
|
+
case "paragraph":
|
|
1214
|
+
t.target = "p";
|
|
1215
|
+
break;
|
|
1216
|
+
case "table":
|
|
1217
|
+
t.target = "table";
|
|
1218
|
+
break;
|
|
1219
|
+
case "character": t.target = "span";
|
|
1220
|
+
}
|
|
1221
|
+
for (let n of D.elements(e)) switch (n.localName) {
|
|
1222
|
+
case "basedOn":
|
|
1223
|
+
t.basedOn = D.attr(n, "val");
|
|
1224
|
+
break;
|
|
1225
|
+
case "name":
|
|
1226
|
+
t.name = D.attr(n, "val");
|
|
1227
|
+
break;
|
|
1228
|
+
case "link":
|
|
1229
|
+
t.linked = D.attr(n, "val");
|
|
1230
|
+
break;
|
|
1231
|
+
case "next":
|
|
1232
|
+
t.next = D.attr(n, "val");
|
|
1233
|
+
break;
|
|
1234
|
+
case "aliases":
|
|
1235
|
+
t.aliases = D.attr(n, "val").split(",");
|
|
1236
|
+
break;
|
|
1237
|
+
case "pPr":
|
|
1238
|
+
t.styles.push({
|
|
1239
|
+
target: "p",
|
|
1240
|
+
values: this.parseDefaultProperties(n, {})
|
|
1241
|
+
}), t.paragraphProps = N(n, D);
|
|
1242
|
+
break;
|
|
1243
|
+
case "rPr":
|
|
1244
|
+
t.styles.push({
|
|
1245
|
+
target: "span",
|
|
1246
|
+
values: this.parseDefaultProperties(n, {})
|
|
1247
|
+
}), t.runProps = M(n, D);
|
|
1248
|
+
break;
|
|
1249
|
+
case "tblPr":
|
|
1250
|
+
case "tcPr":
|
|
1251
|
+
t.styles.push({
|
|
1252
|
+
target: "td",
|
|
1253
|
+
values: this.parseDefaultProperties(n, {})
|
|
1254
|
+
});
|
|
1255
|
+
break;
|
|
1256
|
+
case "tblStylePr":
|
|
1257
|
+
for (let e of this.parseTableStyle(n)) t.styles.push(e);
|
|
1258
|
+
break;
|
|
1259
|
+
case "rsid":
|
|
1260
|
+
case "qFormat":
|
|
1261
|
+
case "hidden":
|
|
1262
|
+
case "semiHidden":
|
|
1263
|
+
case "unhideWhenUsed":
|
|
1264
|
+
case "autoRedefine":
|
|
1265
|
+
case "uiPriority": break;
|
|
1266
|
+
default: this.options.debug && console.warn(`DOCX: Unknown style element: ${n.localName}`);
|
|
1267
|
+
}
|
|
1268
|
+
return t;
|
|
1269
|
+
}
|
|
1270
|
+
parseTableStyle(e) {
|
|
1271
|
+
var t = [], n = D.attr(e, "type"), r = "", i = "";
|
|
1272
|
+
switch (n) {
|
|
1273
|
+
case "firstRow":
|
|
1274
|
+
i = ".first-row", r = "tr.first-row td";
|
|
1275
|
+
break;
|
|
1276
|
+
case "lastRow":
|
|
1277
|
+
i = ".last-row", r = "tr.last-row td";
|
|
1278
|
+
break;
|
|
1279
|
+
case "firstCol":
|
|
1280
|
+
i = ".first-col", r = "td.first-col";
|
|
1281
|
+
break;
|
|
1282
|
+
case "lastCol":
|
|
1283
|
+
i = ".last-col", r = "td.last-col";
|
|
1284
|
+
break;
|
|
1285
|
+
case "band1Vert":
|
|
1286
|
+
i = ":not(.no-vband)", r = "td.odd-col";
|
|
1287
|
+
break;
|
|
1288
|
+
case "band2Vert":
|
|
1289
|
+
i = ":not(.no-vband)", r = "td.even-col";
|
|
1290
|
+
break;
|
|
1291
|
+
case "band1Horz":
|
|
1292
|
+
i = ":not(.no-hband)", r = "tr.odd-row";
|
|
1293
|
+
break;
|
|
1294
|
+
case "band2Horz":
|
|
1295
|
+
i = ":not(.no-hband)", r = "tr.even-row";
|
|
1296
|
+
break;
|
|
1297
|
+
default: return [];
|
|
1298
|
+
}
|
|
1299
|
+
for (let n of D.elements(e)) switch (n.localName) {
|
|
1300
|
+
case "pPr":
|
|
1301
|
+
t.push({
|
|
1302
|
+
target: `${r} p`,
|
|
1303
|
+
mod: i,
|
|
1304
|
+
values: this.parseDefaultProperties(n, {})
|
|
1305
|
+
});
|
|
1306
|
+
break;
|
|
1307
|
+
case "rPr":
|
|
1308
|
+
t.push({
|
|
1309
|
+
target: `${r} span`,
|
|
1310
|
+
mod: i,
|
|
1311
|
+
values: this.parseDefaultProperties(n, {})
|
|
1312
|
+
});
|
|
1313
|
+
break;
|
|
1314
|
+
case "tblPr":
|
|
1315
|
+
case "tcPr": t.push({
|
|
1316
|
+
target: r,
|
|
1317
|
+
mod: i,
|
|
1318
|
+
values: this.parseDefaultProperties(n, {})
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
return t;
|
|
1322
|
+
}
|
|
1323
|
+
parseNumberingFile(e) {
|
|
1324
|
+
let t = [], n = [], r = [];
|
|
1325
|
+
for (let i of D.elements(e)) switch (i.localName) {
|
|
1326
|
+
case "abstractNum":
|
|
1327
|
+
t.push(...this.parseAbstractNumbering(i, r));
|
|
1328
|
+
break;
|
|
1329
|
+
case "numPicBullet":
|
|
1330
|
+
r.push(this.parseNumberingPicBullet(i));
|
|
1331
|
+
break;
|
|
1332
|
+
case "num": n.push({
|
|
1333
|
+
numId: D.attr(i, "numId"),
|
|
1334
|
+
abstractNumId: D.elementAttr(i, "abstractNumId", "val")
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
return n.flatMap((e) => t.filter((t) => e.abstractNumId == t.id).map((t) => ({
|
|
1338
|
+
...t,
|
|
1339
|
+
id: e.numId
|
|
1340
|
+
})));
|
|
1341
|
+
}
|
|
1342
|
+
parseNumberingPicBullet(e) {
|
|
1343
|
+
var t = D.element(e, "pict"), n = t && D.element(t, "shape"), r = n && D.element(n, "imagedata");
|
|
1344
|
+
return r ? {
|
|
1345
|
+
id: D.intAttr(e, "numPicBulletId"),
|
|
1346
|
+
src: D.attr(r, "id"),
|
|
1347
|
+
style: D.attr(n, "style")
|
|
1348
|
+
} : null;
|
|
1349
|
+
}
|
|
1350
|
+
parseAbstractNumbering(e, t) {
|
|
1351
|
+
var n = [], r = D.attr(e, "abstractNumId");
|
|
1352
|
+
for (let i of D.elements(e)) switch (i.localName) {
|
|
1353
|
+
case "lvl": n.push(this.parseNumberingLevel(r, i, t));
|
|
1354
|
+
}
|
|
1355
|
+
return n;
|
|
1356
|
+
}
|
|
1357
|
+
parseNumberingLevel(e, t, n) {
|
|
1358
|
+
var r = {
|
|
1359
|
+
id: e,
|
|
1360
|
+
level: D.intAttr(t, "ilvl"),
|
|
1361
|
+
start: 1,
|
|
1362
|
+
pStyleName: void 0,
|
|
1363
|
+
pStyle: {},
|
|
1364
|
+
rStyle: {},
|
|
1365
|
+
suff: "tab"
|
|
1366
|
+
};
|
|
1367
|
+
for (let e of D.elements(t)) switch (e.localName) {
|
|
1368
|
+
case "start":
|
|
1369
|
+
r.start = D.intAttr(e, "val");
|
|
1370
|
+
break;
|
|
1371
|
+
case "pPr":
|
|
1372
|
+
this.parseDefaultProperties(e, r.pStyle);
|
|
1373
|
+
break;
|
|
1374
|
+
case "rPr":
|
|
1375
|
+
this.parseDefaultProperties(e, r.rStyle);
|
|
1376
|
+
break;
|
|
1377
|
+
case "lvlPicBulletId":
|
|
1378
|
+
var i = D.intAttr(e, "val");
|
|
1379
|
+
r.bullet = n.find((e) => e?.id == i);
|
|
1380
|
+
break;
|
|
1381
|
+
case "lvlText":
|
|
1382
|
+
r.levelText = D.attr(e, "val");
|
|
1383
|
+
break;
|
|
1384
|
+
case "pStyle":
|
|
1385
|
+
r.pStyleName = D.attr(e, "val");
|
|
1386
|
+
break;
|
|
1387
|
+
case "numFmt":
|
|
1388
|
+
r.format = D.attr(e, "val");
|
|
1389
|
+
break;
|
|
1390
|
+
case "suff": r.suff = D.attr(e, "val");
|
|
1391
|
+
}
|
|
1392
|
+
return r;
|
|
1393
|
+
}
|
|
1394
|
+
parseSdt(e, t) {
|
|
1395
|
+
let n = D.element(e, "sdtContent");
|
|
1396
|
+
return n ? t(n) : [];
|
|
1397
|
+
}
|
|
1398
|
+
parseChange(e, t, n) {
|
|
1399
|
+
return {
|
|
1400
|
+
type: e,
|
|
1401
|
+
children: n(t)?.children ?? [],
|
|
1402
|
+
id: D.attr(t, "id"),
|
|
1403
|
+
author: D.attr(t, "author"),
|
|
1404
|
+
date: D.attr(t, "date")
|
|
1405
|
+
};
|
|
1406
|
+
}
|
|
1407
|
+
parseAltChunk(e) {
|
|
1408
|
+
return {
|
|
1409
|
+
type: I.AltChunk,
|
|
1410
|
+
children: [],
|
|
1411
|
+
id: D.attr(e, "id")
|
|
1412
|
+
};
|
|
1413
|
+
}
|
|
1414
|
+
parseParagraph(e) {
|
|
1415
|
+
var t = {
|
|
1416
|
+
type: I.Paragraph,
|
|
1417
|
+
children: []
|
|
1418
|
+
};
|
|
1419
|
+
for (let n of D.elements(e)) switch (n.localName) {
|
|
1420
|
+
case "pPr":
|
|
1421
|
+
this.parseParagraphProperties(n, t);
|
|
1422
|
+
break;
|
|
1423
|
+
case "r":
|
|
1424
|
+
t.children.push(this.parseRun(n, t));
|
|
1425
|
+
break;
|
|
1426
|
+
case "hyperlink":
|
|
1427
|
+
t.children.push(this.parseHyperlink(n, t));
|
|
1428
|
+
break;
|
|
1429
|
+
case "smartTag":
|
|
1430
|
+
t.children.push(this.parseSmartTag(n, t));
|
|
1431
|
+
break;
|
|
1432
|
+
case "bookmarkStart":
|
|
1433
|
+
t.children.push(rt(n, D));
|
|
1434
|
+
break;
|
|
1435
|
+
case "bookmarkEnd":
|
|
1436
|
+
t.children.push(it(n, D));
|
|
1437
|
+
break;
|
|
1438
|
+
case "commentRangeStart":
|
|
1439
|
+
t.children.push(new ut(D.attr(n, "id")));
|
|
1440
|
+
break;
|
|
1441
|
+
case "commentRangeEnd":
|
|
1442
|
+
t.children.push(new dt(D.attr(n, "id")));
|
|
1443
|
+
break;
|
|
1444
|
+
case "oMath":
|
|
1445
|
+
case "oMathPara":
|
|
1446
|
+
t.children.push(this.parseMathElement(n));
|
|
1447
|
+
break;
|
|
1448
|
+
case "sdt":
|
|
1449
|
+
t.children.push(...this.parseSdt(n, (e) => this.parseParagraph(e).children));
|
|
1450
|
+
break;
|
|
1451
|
+
case "ins":
|
|
1452
|
+
t.children.push(this.parseChange(I.Inserted, n, (e) => this.parseParagraph(e)));
|
|
1453
|
+
break;
|
|
1454
|
+
case "del": t.children.push(this.parseChange(I.Deleted, n, (e) => this.parseParagraph(e)));
|
|
1455
|
+
}
|
|
1456
|
+
return t;
|
|
1457
|
+
}
|
|
1458
|
+
parseParagraphProperties(e, t) {
|
|
1459
|
+
this.parseDefaultProperties(e, t.cssStyle = {}, null, (e) => {
|
|
1460
|
+
if (P(e, t, D)) return !0;
|
|
1461
|
+
switch (e.localName) {
|
|
1462
|
+
case "pStyle":
|
|
1463
|
+
t.styleName = D.attr(e, "val");
|
|
1464
|
+
break;
|
|
1465
|
+
case "cnfStyle":
|
|
1466
|
+
t.className = Y.classNameOfCnfStyle(e);
|
|
1467
|
+
break;
|
|
1468
|
+
case "framePr":
|
|
1469
|
+
this.parseFrame(e, t);
|
|
1470
|
+
break;
|
|
1471
|
+
case "rPr": break;
|
|
1472
|
+
default: return !1;
|
|
1473
|
+
}
|
|
1474
|
+
return !0;
|
|
1475
|
+
});
|
|
1476
|
+
}
|
|
1477
|
+
parseFrame(e, t) {
|
|
1478
|
+
D.attr(e, "dropCap") == "drop" && (t.cssStyle.float = "left");
|
|
1479
|
+
}
|
|
1480
|
+
parseHyperlink(e, t) {
|
|
1481
|
+
var n = {
|
|
1482
|
+
type: I.Hyperlink,
|
|
1483
|
+
parent: t,
|
|
1484
|
+
children: []
|
|
1485
|
+
};
|
|
1486
|
+
n.anchor = D.attr(e, "anchor"), n.id = D.attr(e, "id");
|
|
1487
|
+
for (let t of D.elements(e)) switch (t.localName) {
|
|
1488
|
+
case "r": n.children.push(this.parseRun(t, n));
|
|
1489
|
+
}
|
|
1490
|
+
return n;
|
|
1491
|
+
}
|
|
1492
|
+
parseSmartTag(e, t) {
|
|
1493
|
+
var n = {
|
|
1494
|
+
type: I.SmartTag,
|
|
1495
|
+
parent: t,
|
|
1496
|
+
children: []
|
|
1497
|
+
}, r = D.attr(e, "uri"), i = D.attr(e, "element");
|
|
1498
|
+
r && (n.uri = r), i && (n.element = i);
|
|
1499
|
+
for (let t of D.elements(e)) switch (t.localName) {
|
|
1500
|
+
case "r":
|
|
1501
|
+
n.children.push(this.parseRun(t, n));
|
|
1502
|
+
break;
|
|
1503
|
+
case "smartTag": n.children.push(this.parseSmartTag(t, n));
|
|
1504
|
+
}
|
|
1505
|
+
return n;
|
|
1506
|
+
}
|
|
1507
|
+
parseRun(e, t) {
|
|
1508
|
+
var n = {
|
|
1509
|
+
type: I.Run,
|
|
1510
|
+
parent: t,
|
|
1511
|
+
children: []
|
|
1512
|
+
};
|
|
1513
|
+
for (let t of D.elements(e)) switch (t = this.checkAlternateContent(t), t?.localName) {
|
|
1514
|
+
case "t":
|
|
1515
|
+
n.children.push({
|
|
1516
|
+
type: I.Text,
|
|
1517
|
+
text: t.textContent
|
|
1518
|
+
});
|
|
1519
|
+
break;
|
|
1520
|
+
case "delText":
|
|
1521
|
+
n.children.push({
|
|
1522
|
+
type: I.DeletedText,
|
|
1523
|
+
text: t.textContent
|
|
1524
|
+
});
|
|
1525
|
+
break;
|
|
1526
|
+
case "commentReference":
|
|
1527
|
+
n.children.push(new lt(D.attr(t, "id")));
|
|
1528
|
+
break;
|
|
1529
|
+
case "fldSimple":
|
|
1530
|
+
n.children.push({
|
|
1531
|
+
type: I.SimpleField,
|
|
1532
|
+
instruction: D.attr(t, "instr"),
|
|
1533
|
+
lock: D.boolAttr(t, "lock", !1),
|
|
1534
|
+
dirty: D.boolAttr(t, "dirty", !1)
|
|
1535
|
+
});
|
|
1536
|
+
break;
|
|
1537
|
+
case "instrText":
|
|
1538
|
+
n.fieldRun = !0, n.children.push({
|
|
1539
|
+
type: I.Instruction,
|
|
1540
|
+
text: t.textContent
|
|
1541
|
+
});
|
|
1542
|
+
break;
|
|
1543
|
+
case "fldChar":
|
|
1544
|
+
n.fieldRun = !0, n.children.push({
|
|
1545
|
+
type: I.ComplexField,
|
|
1546
|
+
charType: D.attr(t, "fldCharType"),
|
|
1547
|
+
lock: D.boolAttr(t, "lock", !1),
|
|
1548
|
+
dirty: D.boolAttr(t, "dirty", !1)
|
|
1549
|
+
});
|
|
1550
|
+
break;
|
|
1551
|
+
case "noBreakHyphen":
|
|
1552
|
+
n.children.push({ type: I.NoBreakHyphen });
|
|
1553
|
+
break;
|
|
1554
|
+
case "br":
|
|
1555
|
+
n.children.push({
|
|
1556
|
+
type: I.Break,
|
|
1557
|
+
break: D.attr(t, "type") || "textWrapping"
|
|
1558
|
+
});
|
|
1559
|
+
break;
|
|
1560
|
+
case "lastRenderedPageBreak":
|
|
1561
|
+
n.children.push({
|
|
1562
|
+
type: I.Break,
|
|
1563
|
+
break: "lastRenderedPageBreak"
|
|
1564
|
+
});
|
|
1565
|
+
break;
|
|
1566
|
+
case "sym":
|
|
1567
|
+
n.children.push({
|
|
1568
|
+
type: I.Symbol,
|
|
1569
|
+
font: m(D.attr(t, "font")),
|
|
1570
|
+
char: D.hexAttr(t, "char")
|
|
1571
|
+
});
|
|
1572
|
+
break;
|
|
1573
|
+
case "tab":
|
|
1574
|
+
n.children.push({ type: I.Tab });
|
|
1575
|
+
break;
|
|
1576
|
+
case "footnoteReference":
|
|
1577
|
+
n.children.push({
|
|
1578
|
+
type: I.FootnoteReference,
|
|
1579
|
+
id: D.attr(t, "id")
|
|
1580
|
+
});
|
|
1581
|
+
break;
|
|
1582
|
+
case "endnoteReference":
|
|
1583
|
+
n.children.push({
|
|
1584
|
+
type: I.EndnoteReference,
|
|
1585
|
+
id: D.attr(t, "id")
|
|
1586
|
+
});
|
|
1587
|
+
break;
|
|
1588
|
+
case "drawing":
|
|
1589
|
+
let e = this.parseDrawing(t);
|
|
1590
|
+
e && n.children.push(e);
|
|
1591
|
+
break;
|
|
1592
|
+
case "pict":
|
|
1593
|
+
n.children.push(this.parseVmlPicture(t));
|
|
1594
|
+
break;
|
|
1595
|
+
case "rPr": this.parseRunProperties(t, n);
|
|
1596
|
+
}
|
|
1597
|
+
return n;
|
|
1598
|
+
}
|
|
1599
|
+
parseMathElement(e) {
|
|
1600
|
+
let t = `${e.localName}Pr`, n = {
|
|
1601
|
+
type: q[e.localName],
|
|
1602
|
+
children: []
|
|
1603
|
+
};
|
|
1604
|
+
for (let i of D.elements(e)) if (q[i.localName]) n.children.push(this.parseMathElement(i));
|
|
1605
|
+
else if (i.localName == "r") {
|
|
1606
|
+
var r = this.parseRun(i);
|
|
1607
|
+
r.type = I.MmlRun, n.children.push(r);
|
|
1608
|
+
} else i.localName == t && (n.props = this.parseMathProperies(i));
|
|
1609
|
+
return n;
|
|
1610
|
+
}
|
|
1611
|
+
parseMathProperies(e) {
|
|
1612
|
+
let t = {};
|
|
1613
|
+
for (let n of D.elements(e)) switch (n.localName) {
|
|
1614
|
+
case "chr":
|
|
1615
|
+
t.char = D.attr(n, "val");
|
|
1616
|
+
break;
|
|
1617
|
+
case "vertJc":
|
|
1618
|
+
t.verticalJustification = D.attr(n, "val");
|
|
1619
|
+
break;
|
|
1620
|
+
case "pos":
|
|
1621
|
+
t.position = D.attr(n, "val");
|
|
1622
|
+
break;
|
|
1623
|
+
case "degHide":
|
|
1624
|
+
t.hideDegree = D.boolAttr(n, "val");
|
|
1625
|
+
break;
|
|
1626
|
+
case "begChr":
|
|
1627
|
+
t.beginChar = D.attr(n, "val");
|
|
1628
|
+
break;
|
|
1629
|
+
case "endChr": t.endChar = D.attr(n, "val");
|
|
1630
|
+
}
|
|
1631
|
+
return t;
|
|
1632
|
+
}
|
|
1633
|
+
parseRunProperties(e, t) {
|
|
1634
|
+
this.parseDefaultProperties(e, t.cssStyle = {}, null, (e) => {
|
|
1635
|
+
switch (e.localName) {
|
|
1636
|
+
case "rStyle":
|
|
1637
|
+
t.styleName = D.attr(e, "val");
|
|
1638
|
+
break;
|
|
1639
|
+
case "vertAlign":
|
|
1640
|
+
t.verticalAlign = Y.valueOfVertAlign(e, !0);
|
|
1641
|
+
break;
|
|
1642
|
+
default: return !1;
|
|
1643
|
+
}
|
|
1644
|
+
return !0;
|
|
1645
|
+
});
|
|
1646
|
+
}
|
|
1647
|
+
parseVmlPicture(e) {
|
|
1648
|
+
let t = {
|
|
1649
|
+
type: I.VmlPicture,
|
|
1650
|
+
children: []
|
|
1651
|
+
};
|
|
1652
|
+
for (let n of D.elements(e)) {
|
|
1653
|
+
let e = W(n, this);
|
|
1654
|
+
e && t.children.push(e);
|
|
1655
|
+
}
|
|
1656
|
+
return t;
|
|
1657
|
+
}
|
|
1658
|
+
checkAlternateContent(e) {
|
|
1659
|
+
if (e.localName != "AlternateContent") return e;
|
|
1660
|
+
var t = D.element(e, "Choice");
|
|
1661
|
+
if (t) {
|
|
1662
|
+
var n = D.attr(t, "Requires"), r = e.lookupNamespaceURI(n);
|
|
1663
|
+
if (ft.includes(r)) return t.firstElementChild;
|
|
1664
|
+
}
|
|
1665
|
+
return D.element(e, "Fallback")?.firstElementChild;
|
|
1666
|
+
}
|
|
1667
|
+
parseDrawing(e) {
|
|
1668
|
+
for (var t of D.elements(e)) switch (t.localName) {
|
|
1669
|
+
case "inline":
|
|
1670
|
+
case "anchor": return this.parseDrawingWrapper(t);
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
parseDrawingWrapper(e) {
|
|
1674
|
+
var t = {
|
|
1675
|
+
type: I.Drawing,
|
|
1676
|
+
children: [],
|
|
1677
|
+
cssStyle: {}
|
|
1678
|
+
}, n = e.localName == "anchor";
|
|
1679
|
+
let r = null, i = D.boolAttr(e, "simplePos");
|
|
1680
|
+
D.boolAttr(e, "behindDoc");
|
|
1681
|
+
let a = {
|
|
1682
|
+
relative: "page",
|
|
1683
|
+
align: "left",
|
|
1684
|
+
offset: "0"
|
|
1685
|
+
}, o = {
|
|
1686
|
+
relative: "page",
|
|
1687
|
+
align: "top",
|
|
1688
|
+
offset: "0"
|
|
1689
|
+
};
|
|
1690
|
+
for (var s of D.elements(e)) switch (s.localName) {
|
|
1691
|
+
case "simplePos":
|
|
1692
|
+
i && (a.offset = D.lengthAttr(s, "x", C.Emu), o.offset = D.lengthAttr(s, "y", C.Emu));
|
|
1693
|
+
break;
|
|
1694
|
+
case "extent":
|
|
1695
|
+
t.cssStyle.width = D.lengthAttr(s, "cx", C.Emu), t.cssStyle.height = D.lengthAttr(s, "cy", C.Emu);
|
|
1696
|
+
break;
|
|
1697
|
+
case "positionH":
|
|
1698
|
+
case "positionV":
|
|
1699
|
+
if (!i) {
|
|
1700
|
+
let e = s.localName == "positionH" ? a : o;
|
|
1701
|
+
var c = D.element(s, "align"), l = D.element(s, "posOffset");
|
|
1702
|
+
e.relative = D.attr(s, "relativeFrom") ?? e.relative, c && (e.align = c.textContent), l && (e.offset = w(l.textContent, C.Emu));
|
|
1703
|
+
}
|
|
1704
|
+
break;
|
|
1705
|
+
case "wrapTopAndBottom":
|
|
1706
|
+
r = "wrapTopAndBottom";
|
|
1707
|
+
break;
|
|
1708
|
+
case "wrapNone":
|
|
1709
|
+
r = "wrapNone";
|
|
1710
|
+
break;
|
|
1711
|
+
case "graphic":
|
|
1712
|
+
var u = this.parseGraphic(s);
|
|
1713
|
+
u && t.children.push(u);
|
|
1714
|
+
}
|
|
1715
|
+
return r == "wrapTopAndBottom" ? (t.cssStyle.display = "block", a.align && (t.cssStyle["text-align"] = a.align, t.cssStyle.width = "100%")) : r == "wrapNone" ? (t.cssStyle.display = "block", t.cssStyle.position = "relative", t.cssStyle.width = "0px", t.cssStyle.height = "0px", a.offset && (t.cssStyle.left = a.offset), o.offset && (t.cssStyle.top = o.offset)) : n && (a.align == "left" || a.align == "right") && (t.cssStyle.float = a.align), t;
|
|
1716
|
+
}
|
|
1717
|
+
parseGraphic(e) {
|
|
1718
|
+
var t = D.element(e, "graphicData");
|
|
1719
|
+
for (let e of D.elements(t)) switch (e.localName) {
|
|
1720
|
+
case "pic": return this.parsePicture(e);
|
|
1721
|
+
}
|
|
1722
|
+
return null;
|
|
1723
|
+
}
|
|
1724
|
+
parsePicture(e) {
|
|
1725
|
+
var t = {
|
|
1726
|
+
type: I.Image,
|
|
1727
|
+
src: "",
|
|
1728
|
+
cssStyle: {}
|
|
1729
|
+
}, n = D.element(e, "blipFill"), r = D.element(n, "blip"), i = D.element(n, "srcRect");
|
|
1730
|
+
t.src = D.attr(r, "embed"), i && (t.srcRect = [
|
|
1731
|
+
D.intAttr(i, "l", 0) / 1e5,
|
|
1732
|
+
D.intAttr(i, "t", 0) / 1e5,
|
|
1733
|
+
D.intAttr(i, "r", 0) / 1e5,
|
|
1734
|
+
D.intAttr(i, "b", 0) / 1e5
|
|
1735
|
+
]);
|
|
1736
|
+
var a = D.element(e, "spPr"), o = D.element(a, "xfrm");
|
|
1737
|
+
if (t.cssStyle.position = "relative", o) {
|
|
1738
|
+
t.rotation = D.intAttr(o, "rot", 0) / 6e4;
|
|
1739
|
+
for (var s of D.elements(o)) switch (s.localName) {
|
|
1740
|
+
case "ext":
|
|
1741
|
+
t.cssStyle.width = D.lengthAttr(s, "cx", C.Emu), t.cssStyle.height = D.lengthAttr(s, "cy", C.Emu);
|
|
1742
|
+
break;
|
|
1743
|
+
case "off": t.cssStyle.left = D.lengthAttr(s, "x", C.Emu), t.cssStyle.top = D.lengthAttr(s, "y", C.Emu);
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
return t;
|
|
1747
|
+
}
|
|
1748
|
+
parseTable(e) {
|
|
1749
|
+
var t = {
|
|
1750
|
+
type: I.Table,
|
|
1751
|
+
children: []
|
|
1752
|
+
};
|
|
1753
|
+
for (let n of D.elements(e)) switch (n.localName) {
|
|
1754
|
+
case "tr":
|
|
1755
|
+
t.children.push(this.parseTableRow(n));
|
|
1756
|
+
break;
|
|
1757
|
+
case "tblGrid":
|
|
1758
|
+
t.columns = this.parseTableColumns(n);
|
|
1759
|
+
break;
|
|
1760
|
+
case "tblPr": this.parseTableProperties(n, t);
|
|
1761
|
+
}
|
|
1762
|
+
return t;
|
|
1763
|
+
}
|
|
1764
|
+
parseTableColumns(e) {
|
|
1765
|
+
var t = [];
|
|
1766
|
+
for (let n of D.elements(e)) switch (n.localName) {
|
|
1767
|
+
case "gridCol": t.push({ width: D.lengthAttr(n, "w") });
|
|
1768
|
+
}
|
|
1769
|
+
return t;
|
|
1770
|
+
}
|
|
1771
|
+
parseTableProperties(e, t) {
|
|
1772
|
+
switch (t.cssStyle = {}, t.cellStyle = {}, this.parseDefaultProperties(e, t.cssStyle, t.cellStyle, (e) => {
|
|
1773
|
+
switch (e.localName) {
|
|
1774
|
+
case "tblStyle":
|
|
1775
|
+
t.styleName = D.attr(e, "val");
|
|
1776
|
+
break;
|
|
1777
|
+
case "tblLook":
|
|
1778
|
+
t.className = Y.classNameOftblLook(e);
|
|
1779
|
+
break;
|
|
1780
|
+
case "tblpPr":
|
|
1781
|
+
this.parseTablePosition(e, t);
|
|
1782
|
+
break;
|
|
1783
|
+
case "tblStyleColBandSize":
|
|
1784
|
+
t.colBandSize = D.intAttr(e, "val");
|
|
1785
|
+
break;
|
|
1786
|
+
case "tblStyleRowBandSize":
|
|
1787
|
+
t.rowBandSize = D.intAttr(e, "val");
|
|
1788
|
+
break;
|
|
1789
|
+
case "hidden":
|
|
1790
|
+
t.cssStyle.display = "none";
|
|
1791
|
+
break;
|
|
1792
|
+
default: return !1;
|
|
1793
|
+
}
|
|
1794
|
+
return !0;
|
|
1795
|
+
}), t.cssStyle["text-align"]) {
|
|
1796
|
+
case "center":
|
|
1797
|
+
delete t.cssStyle["text-align"], t.cssStyle["margin-left"] = "auto", t.cssStyle["margin-right"] = "auto";
|
|
1798
|
+
break;
|
|
1799
|
+
case "right": delete t.cssStyle["text-align"], t.cssStyle["margin-left"] = "auto";
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
parseTablePosition(e, t) {
|
|
1803
|
+
var n = D.lengthAttr(e, "topFromText"), r = D.lengthAttr(e, "bottomFromText"), i = D.lengthAttr(e, "rightFromText"), a = D.lengthAttr(e, "leftFromText");
|
|
1804
|
+
t.cssStyle.float = "left", t.cssStyle["margin-bottom"] = Y.addSize(t.cssStyle["margin-bottom"], r), t.cssStyle["margin-left"] = Y.addSize(t.cssStyle["margin-left"], a), t.cssStyle["margin-right"] = Y.addSize(t.cssStyle["margin-right"], i), t.cssStyle["margin-top"] = Y.addSize(t.cssStyle["margin-top"], n);
|
|
1805
|
+
}
|
|
1806
|
+
parseTableRow(e) {
|
|
1807
|
+
var t = {
|
|
1808
|
+
type: I.Row,
|
|
1809
|
+
children: []
|
|
1810
|
+
};
|
|
1811
|
+
for (let n of D.elements(e)) switch (n.localName) {
|
|
1812
|
+
case "tc":
|
|
1813
|
+
t.children.push(this.parseTableCell(n));
|
|
1814
|
+
break;
|
|
1815
|
+
case "trPr":
|
|
1816
|
+
case "tblPrEx": this.parseTableRowProperties(n, t);
|
|
1817
|
+
}
|
|
1818
|
+
return t;
|
|
1819
|
+
}
|
|
1820
|
+
parseTableRowProperties(e, t) {
|
|
1821
|
+
t.cssStyle = this.parseDefaultProperties(e, {}, null, (e) => {
|
|
1822
|
+
switch (e.localName) {
|
|
1823
|
+
case "cnfStyle":
|
|
1824
|
+
t.className = Y.classNameOfCnfStyle(e);
|
|
1825
|
+
break;
|
|
1826
|
+
case "tblHeader":
|
|
1827
|
+
t.isHeader = D.boolAttr(e, "val");
|
|
1828
|
+
break;
|
|
1829
|
+
case "gridBefore":
|
|
1830
|
+
t.gridBefore = D.intAttr(e, "val");
|
|
1831
|
+
break;
|
|
1832
|
+
case "gridAfter":
|
|
1833
|
+
t.gridAfter = D.intAttr(e, "val");
|
|
1834
|
+
break;
|
|
1835
|
+
default: return !1;
|
|
1836
|
+
}
|
|
1837
|
+
return !0;
|
|
1838
|
+
});
|
|
1839
|
+
}
|
|
1840
|
+
parseTableCell(e) {
|
|
1841
|
+
var t = {
|
|
1842
|
+
type: I.Cell,
|
|
1843
|
+
children: []
|
|
1844
|
+
};
|
|
1845
|
+
for (let n of D.elements(e)) switch (n.localName) {
|
|
1846
|
+
case "tbl":
|
|
1847
|
+
t.children.push(this.parseTable(n));
|
|
1848
|
+
break;
|
|
1849
|
+
case "p":
|
|
1850
|
+
t.children.push(this.parseParagraph(n));
|
|
1851
|
+
break;
|
|
1852
|
+
case "tcPr": this.parseTableCellProperties(n, t);
|
|
1853
|
+
}
|
|
1854
|
+
return t;
|
|
1855
|
+
}
|
|
1856
|
+
parseTableCellProperties(e, t) {
|
|
1857
|
+
t.cssStyle = this.parseDefaultProperties(e, {}, null, (e) => {
|
|
1858
|
+
switch (e.localName) {
|
|
1859
|
+
case "gridSpan":
|
|
1860
|
+
t.span = D.intAttr(e, "val", null);
|
|
1861
|
+
break;
|
|
1862
|
+
case "vMerge":
|
|
1863
|
+
t.verticalMerge = D.attr(e, "val") ?? "continue";
|
|
1864
|
+
break;
|
|
1865
|
+
case "cnfStyle":
|
|
1866
|
+
t.className = Y.classNameOfCnfStyle(e);
|
|
1867
|
+
break;
|
|
1868
|
+
default: return !1;
|
|
1869
|
+
}
|
|
1870
|
+
return !0;
|
|
1871
|
+
}), this.parseTableCellVerticalText(e, t);
|
|
1872
|
+
}
|
|
1873
|
+
parseTableCellVerticalText(e, t) {
|
|
1874
|
+
let n = {
|
|
1875
|
+
btLr: {
|
|
1876
|
+
writingMode: "vertical-rl",
|
|
1877
|
+
transform: "rotate(180deg)"
|
|
1878
|
+
},
|
|
1879
|
+
lrTb: {
|
|
1880
|
+
writingMode: "vertical-lr",
|
|
1881
|
+
transform: "none"
|
|
1882
|
+
},
|
|
1883
|
+
tbRl: {
|
|
1884
|
+
writingMode: "vertical-rl",
|
|
1885
|
+
transform: "none"
|
|
1886
|
+
}
|
|
1887
|
+
};
|
|
1888
|
+
for (let r of D.elements(e)) if (r.localName === "textDirection") {
|
|
1889
|
+
let e = n[D.attr(r, "val")] || { writingMode: "horizontal-tb" };
|
|
1890
|
+
t.cssStyle["writing-mode"] = e.writingMode, t.cssStyle.transform = e.transform;
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
parseDefaultProperties(e, t = null, n = null, r = null) {
|
|
1894
|
+
t ||= {};
|
|
1895
|
+
for (let i of D.elements(e)) if (!r?.(i)) switch (i.localName) {
|
|
1896
|
+
case "jc":
|
|
1897
|
+
t["text-align"] = Y.valueOfJc(i);
|
|
1898
|
+
break;
|
|
1899
|
+
case "textAlignment":
|
|
1900
|
+
t["vertical-align"] = Y.valueOfTextAlignment(i);
|
|
1901
|
+
break;
|
|
1902
|
+
case "color":
|
|
1903
|
+
t.color = J.colorAttr(i, "val", null, K.color);
|
|
1904
|
+
break;
|
|
1905
|
+
case "sz":
|
|
1906
|
+
t["font-size"] = t["min-height"] = D.lengthAttr(i, "val", C.FontSize);
|
|
1907
|
+
break;
|
|
1908
|
+
case "shd":
|
|
1909
|
+
t["background-color"] = J.colorAttr(i, "fill", null, K.shd);
|
|
1910
|
+
break;
|
|
1911
|
+
case "highlight":
|
|
1912
|
+
t["background-color"] = J.colorAttr(i, "val", null, K.highlight);
|
|
1913
|
+
break;
|
|
1914
|
+
case "vertAlign": break;
|
|
1915
|
+
case "position":
|
|
1916
|
+
t.verticalAlign = D.lengthAttr(i, "val", C.FontSize);
|
|
1917
|
+
break;
|
|
1918
|
+
case "tcW": if (this.options.ignoreWidth) break;
|
|
1919
|
+
case "tblW":
|
|
1920
|
+
t.width = Y.valueOfSize(i, "w");
|
|
1921
|
+
break;
|
|
1922
|
+
case "trHeight":
|
|
1923
|
+
this.parseTrHeight(i, t);
|
|
1924
|
+
break;
|
|
1925
|
+
case "strike":
|
|
1926
|
+
t["text-decoration"] = D.boolAttr(i, "val", !0) ? "line-through" : "none";
|
|
1927
|
+
break;
|
|
1928
|
+
case "b":
|
|
1929
|
+
t["font-weight"] = D.boolAttr(i, "val", !0) ? "bold" : "normal";
|
|
1930
|
+
break;
|
|
1931
|
+
case "i":
|
|
1932
|
+
t["font-style"] = D.boolAttr(i, "val", !0) ? "italic" : "normal";
|
|
1933
|
+
break;
|
|
1934
|
+
case "caps":
|
|
1935
|
+
t["text-transform"] = D.boolAttr(i, "val", !0) ? "uppercase" : "none";
|
|
1936
|
+
break;
|
|
1937
|
+
case "smallCaps":
|
|
1938
|
+
t["font-variant"] = D.boolAttr(i, "val", !0) ? "small-caps" : "none";
|
|
1939
|
+
break;
|
|
1940
|
+
case "u":
|
|
1941
|
+
this.parseUnderline(i, t);
|
|
1942
|
+
break;
|
|
1943
|
+
case "ind":
|
|
1944
|
+
case "tblInd":
|
|
1945
|
+
this.parseIndentation(i, t);
|
|
1946
|
+
break;
|
|
1947
|
+
case "rFonts":
|
|
1948
|
+
this.parseFont(i, t);
|
|
1949
|
+
break;
|
|
1950
|
+
case "tblBorders":
|
|
1951
|
+
this.parseBorderProperties(i, n || t);
|
|
1952
|
+
break;
|
|
1953
|
+
case "tblCellSpacing":
|
|
1954
|
+
t["border-spacing"] = Y.valueOfMargin(i), t["border-collapse"] = "separate";
|
|
1955
|
+
break;
|
|
1956
|
+
case "pBdr":
|
|
1957
|
+
this.parseBorderProperties(i, t);
|
|
1958
|
+
break;
|
|
1959
|
+
case "bdr":
|
|
1960
|
+
t.border = Y.valueOfBorder(i);
|
|
1961
|
+
break;
|
|
1962
|
+
case "tcBorders":
|
|
1963
|
+
this.parseBorderProperties(i, t);
|
|
1964
|
+
break;
|
|
1965
|
+
case "vanish":
|
|
1966
|
+
D.boolAttr(i, "val", !0) && (t.display = "none");
|
|
1967
|
+
break;
|
|
1968
|
+
case "kern": break;
|
|
1969
|
+
case "noWrap": break;
|
|
1970
|
+
case "tblCellMar":
|
|
1971
|
+
case "tcMar":
|
|
1972
|
+
this.parseMarginProperties(i, n || t);
|
|
1973
|
+
break;
|
|
1974
|
+
case "tblLayout":
|
|
1975
|
+
t["table-layout"] = Y.valueOfTblLayout(i);
|
|
1976
|
+
break;
|
|
1977
|
+
case "vAlign":
|
|
1978
|
+
t["vertical-align"] = Y.valueOfTextAlignment(i);
|
|
1979
|
+
break;
|
|
1980
|
+
case "spacing":
|
|
1981
|
+
e.localName == "pPr" && this.parseSpacing(i, t);
|
|
1982
|
+
break;
|
|
1983
|
+
case "wordWrap":
|
|
1984
|
+
D.boolAttr(i, "val") && (t["overflow-wrap"] = "break-word");
|
|
1985
|
+
break;
|
|
1986
|
+
case "suppressAutoHyphens":
|
|
1987
|
+
t.hyphens = D.boolAttr(i, "val", !0) ? "none" : "auto";
|
|
1988
|
+
break;
|
|
1989
|
+
case "lang":
|
|
1990
|
+
t.$lang = D.attr(i, "val");
|
|
1991
|
+
break;
|
|
1992
|
+
case "rtl":
|
|
1993
|
+
case "bidi":
|
|
1994
|
+
D.boolAttr(i, "val", !0) && (t.direction = "rtl");
|
|
1995
|
+
break;
|
|
1996
|
+
case "bCs":
|
|
1997
|
+
case "iCs":
|
|
1998
|
+
case "szCs":
|
|
1999
|
+
case "tabs":
|
|
2000
|
+
case "outlineLvl":
|
|
2001
|
+
case "contextualSpacing":
|
|
2002
|
+
case "tblStyleColBandSize":
|
|
2003
|
+
case "tblStyleRowBandSize":
|
|
2004
|
+
case "webHidden":
|
|
2005
|
+
case "pageBreakBefore":
|
|
2006
|
+
case "suppressLineNumbers":
|
|
2007
|
+
case "keepLines":
|
|
2008
|
+
case "keepNext":
|
|
2009
|
+
case "widowControl":
|
|
2010
|
+
case "noProof": break;
|
|
2011
|
+
default: this.options.debug && console.warn(`DOCX: Unknown document element: ${e.localName}.${i.localName}`);
|
|
2012
|
+
}
|
|
2013
|
+
return t;
|
|
2014
|
+
}
|
|
2015
|
+
parseUnderline(e, t) {
|
|
2016
|
+
var n = D.attr(e, "val");
|
|
2017
|
+
if (n != null) {
|
|
2018
|
+
switch (n) {
|
|
2019
|
+
case "dash":
|
|
2020
|
+
case "dashDotDotHeavy":
|
|
2021
|
+
case "dashDotHeavy":
|
|
2022
|
+
case "dashedHeavy":
|
|
2023
|
+
case "dashLong":
|
|
2024
|
+
case "dashLongHeavy":
|
|
2025
|
+
case "dotDash":
|
|
2026
|
+
case "dotDotDash":
|
|
2027
|
+
t["text-decoration"] = "underline dashed";
|
|
2028
|
+
break;
|
|
2029
|
+
case "dotted":
|
|
2030
|
+
case "dottedHeavy":
|
|
2031
|
+
t["text-decoration"] = "underline dotted";
|
|
2032
|
+
break;
|
|
2033
|
+
case "double":
|
|
2034
|
+
t["text-decoration"] = "underline double";
|
|
2035
|
+
break;
|
|
2036
|
+
case "single":
|
|
2037
|
+
case "thick":
|
|
2038
|
+
t["text-decoration"] = "underline";
|
|
2039
|
+
break;
|
|
2040
|
+
case "wave":
|
|
2041
|
+
case "wavyDouble":
|
|
2042
|
+
case "wavyHeavy":
|
|
2043
|
+
t["text-decoration"] = "underline wavy";
|
|
2044
|
+
break;
|
|
2045
|
+
case "words":
|
|
2046
|
+
t["text-decoration"] = "underline";
|
|
2047
|
+
break;
|
|
2048
|
+
case "none": t["text-decoration"] = "none";
|
|
2049
|
+
}
|
|
2050
|
+
var r = J.colorAttr(e, "color");
|
|
2051
|
+
r && (t["text-decoration-color"] = r);
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
parseFont(e, t) {
|
|
2055
|
+
var n = [
|
|
2056
|
+
D.attr(e, "ascii"),
|
|
2057
|
+
Y.themeValue(e, "asciiTheme"),
|
|
2058
|
+
D.attr(e, "eastAsia")
|
|
2059
|
+
].filter((e) => e).map((e) => m(e));
|
|
2060
|
+
n.length > 0 && (t["font-family"] = [...new Set(n)].join(", "));
|
|
2061
|
+
}
|
|
2062
|
+
parseIndentation(e, t) {
|
|
2063
|
+
var n = D.lengthAttr(e, "firstLine"), r = D.lengthAttr(e, "hanging"), i = D.lengthAttr(e, "left"), a = D.lengthAttr(e, "start"), o = D.lengthAttr(e, "right"), s = D.lengthAttr(e, "end");
|
|
2064
|
+
n && (t["text-indent"] = n), r && (t["text-indent"] = `-${r}`), (i || a) && (t["margin-inline-start"] = i || a), (o || s) && (t["margin-inline-end"] = o || s);
|
|
2065
|
+
}
|
|
2066
|
+
parseSpacing(e, t) {
|
|
2067
|
+
var n = D.lengthAttr(e, "before"), r = D.lengthAttr(e, "after"), i = D.intAttr(e, "line", null), a = D.attr(e, "lineRule");
|
|
2068
|
+
if (n && (t["margin-top"] = n), r && (t["margin-bottom"] = r), i !== null) switch (a) {
|
|
2069
|
+
case "auto":
|
|
2070
|
+
t["line-height"] = `${(i / 240).toFixed(2)}`;
|
|
2071
|
+
break;
|
|
2072
|
+
case "atLeast":
|
|
2073
|
+
t["line-height"] = `calc(100% + ${i / 20}pt)`;
|
|
2074
|
+
break;
|
|
2075
|
+
default: t["line-height"] = t["min-height"] = `${i / 20}pt`;
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
parseMarginProperties(e, t) {
|
|
2079
|
+
for (let n of D.elements(e)) switch (n.localName) {
|
|
2080
|
+
case "left":
|
|
2081
|
+
t["padding-left"] = Y.valueOfMargin(n);
|
|
2082
|
+
break;
|
|
2083
|
+
case "right":
|
|
2084
|
+
t["padding-right"] = Y.valueOfMargin(n);
|
|
2085
|
+
break;
|
|
2086
|
+
case "top":
|
|
2087
|
+
t["padding-top"] = Y.valueOfMargin(n);
|
|
2088
|
+
break;
|
|
2089
|
+
case "bottom": t["padding-bottom"] = Y.valueOfMargin(n);
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
parseTrHeight(e, t) {
|
|
2093
|
+
switch (D.attr(e, "hRule")) {
|
|
2094
|
+
case "exact":
|
|
2095
|
+
t.height = D.lengthAttr(e, "val");
|
|
2096
|
+
break;
|
|
2097
|
+
default: t.height = D.lengthAttr(e, "val");
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
parseBorderProperties(e, t) {
|
|
2101
|
+
for (let n of D.elements(e)) switch (n.localName) {
|
|
2102
|
+
case "start":
|
|
2103
|
+
case "left":
|
|
2104
|
+
t["border-left"] = Y.valueOfBorder(n);
|
|
2105
|
+
break;
|
|
2106
|
+
case "end":
|
|
2107
|
+
case "right":
|
|
2108
|
+
t["border-right"] = Y.valueOfBorder(n);
|
|
2109
|
+
break;
|
|
2110
|
+
case "top":
|
|
2111
|
+
t["border-top"] = Y.valueOfBorder(n);
|
|
2112
|
+
break;
|
|
2113
|
+
case "bottom": t["border-bottom"] = Y.valueOfBorder(n);
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
}, mt = [
|
|
2117
|
+
"black",
|
|
2118
|
+
"blue",
|
|
2119
|
+
"cyan",
|
|
2120
|
+
"darkBlue",
|
|
2121
|
+
"darkCyan",
|
|
2122
|
+
"darkGray",
|
|
2123
|
+
"darkGreen",
|
|
2124
|
+
"darkMagenta",
|
|
2125
|
+
"darkRed",
|
|
2126
|
+
"darkYellow",
|
|
2127
|
+
"green",
|
|
2128
|
+
"lightGray",
|
|
2129
|
+
"magenta",
|
|
2130
|
+
"none",
|
|
2131
|
+
"red",
|
|
2132
|
+
"white",
|
|
2133
|
+
"yellow"
|
|
2134
|
+
], J = class {
|
|
2135
|
+
static colorAttr(e, t, n = null, r = "black") {
|
|
2136
|
+
var i = D.attr(e, t);
|
|
2137
|
+
if (i) return i == "auto" ? r : mt.includes(i) ? i : `#${i}`;
|
|
2138
|
+
var a = D.attr(e, "themeColor");
|
|
2139
|
+
return a ? `var(--docx-${a}-color)` : n;
|
|
2140
|
+
}
|
|
2141
|
+
}, Y = class e {
|
|
2142
|
+
static themeValue(e, t) {
|
|
2143
|
+
var n = D.attr(e, t);
|
|
2144
|
+
return n ? `var(--docx-${n}-font)` : null;
|
|
2145
|
+
}
|
|
2146
|
+
static valueOfSize(e, t) {
|
|
2147
|
+
var n = C.Dxa;
|
|
2148
|
+
switch (D.attr(e, "type")) {
|
|
2149
|
+
case "dxa": break;
|
|
2150
|
+
case "pct":
|
|
2151
|
+
n = C.Percent;
|
|
2152
|
+
break;
|
|
2153
|
+
case "auto": return "auto";
|
|
2154
|
+
}
|
|
2155
|
+
return D.lengthAttr(e, t, n);
|
|
2156
|
+
}
|
|
2157
|
+
static valueOfMargin(e) {
|
|
2158
|
+
return D.lengthAttr(e, "w");
|
|
2159
|
+
}
|
|
2160
|
+
static valueOfBorder(t) {
|
|
2161
|
+
var n = e.parseBorderType(D.attr(t, "val"));
|
|
2162
|
+
if (n == "none") return "none";
|
|
2163
|
+
var r = J.colorAttr(t, "color");
|
|
2164
|
+
return `${D.lengthAttr(t, "sz", C.Border)} ${n} ${r == "auto" ? K.borderColor : r}`;
|
|
2165
|
+
}
|
|
2166
|
+
static parseBorderType(e) {
|
|
2167
|
+
switch (e) {
|
|
2168
|
+
case "single": return "solid";
|
|
2169
|
+
case "dashDotStroked": return "solid";
|
|
2170
|
+
case "dashed": return "dashed";
|
|
2171
|
+
case "dashSmallGap": return "dashed";
|
|
2172
|
+
case "dotDash": return "dotted";
|
|
2173
|
+
case "dotDotDash": return "dotted";
|
|
2174
|
+
case "dotted": return "dotted";
|
|
2175
|
+
case "double": return "double";
|
|
2176
|
+
case "doubleWave": return "double";
|
|
2177
|
+
case "inset": return "inset";
|
|
2178
|
+
case "nil": return "none";
|
|
2179
|
+
case "none": return "none";
|
|
2180
|
+
case "outset": return "outset";
|
|
2181
|
+
case "thick": return "solid";
|
|
2182
|
+
case "thickThinLargeGap": return "solid";
|
|
2183
|
+
case "thickThinMediumGap": return "solid";
|
|
2184
|
+
case "thickThinSmallGap": return "solid";
|
|
2185
|
+
case "thinThickLargeGap": return "solid";
|
|
2186
|
+
case "thinThickMediumGap": return "solid";
|
|
2187
|
+
case "thinThickSmallGap": return "solid";
|
|
2188
|
+
case "thinThickThinLargeGap": return "solid";
|
|
2189
|
+
case "thinThickThinMediumGap": return "solid";
|
|
2190
|
+
case "thinThickThinSmallGap": return "solid";
|
|
2191
|
+
case "threeDEmboss": return "solid";
|
|
2192
|
+
case "threeDEngrave": return "solid";
|
|
2193
|
+
case "triple": return "double";
|
|
2194
|
+
case "wave": return "solid";
|
|
2195
|
+
}
|
|
2196
|
+
return "solid";
|
|
2197
|
+
}
|
|
2198
|
+
static valueOfTblLayout(e) {
|
|
2199
|
+
return D.attr(e, "val") == "fixed" ? "fixed" : "auto";
|
|
2200
|
+
}
|
|
2201
|
+
static classNameOfCnfStyle(e) {
|
|
2202
|
+
let t = D.attr(e, "val"), n = [
|
|
2203
|
+
"first-row",
|
|
2204
|
+
"last-row",
|
|
2205
|
+
"first-col",
|
|
2206
|
+
"last-col",
|
|
2207
|
+
"odd-col",
|
|
2208
|
+
"even-col",
|
|
2209
|
+
"odd-row",
|
|
2210
|
+
"even-row",
|
|
2211
|
+
"ne-cell",
|
|
2212
|
+
"nw-cell",
|
|
2213
|
+
"se-cell",
|
|
2214
|
+
"sw-cell"
|
|
2215
|
+
];
|
|
2216
|
+
if (t) return n.filter((e, n) => t[n] == "1").join(" ");
|
|
2217
|
+
let r = [
|
|
2218
|
+
"firstRow",
|
|
2219
|
+
"lastRow",
|
|
2220
|
+
"firstColumn",
|
|
2221
|
+
"lastColumn",
|
|
2222
|
+
"oddVBand",
|
|
2223
|
+
"evenVBand",
|
|
2224
|
+
"oddHBand",
|
|
2225
|
+
"evenHBand",
|
|
2226
|
+
"firstRowLastColumn",
|
|
2227
|
+
"firstRowFirstColumn",
|
|
2228
|
+
"lastRowLastColumn",
|
|
2229
|
+
"lastRowFirstColumn"
|
|
2230
|
+
];
|
|
2231
|
+
return n.filter((t, n) => D.boolAttr(e, r[n])).join(" ");
|
|
2232
|
+
}
|
|
2233
|
+
static valueOfJc(e) {
|
|
2234
|
+
var t = D.attr(e, "val");
|
|
2235
|
+
switch (t) {
|
|
2236
|
+
case "start":
|
|
2237
|
+
case "left": return "left";
|
|
2238
|
+
case "center": return "center";
|
|
2239
|
+
case "end":
|
|
2240
|
+
case "right": return "right";
|
|
2241
|
+
case "both": return "justify";
|
|
2242
|
+
}
|
|
2243
|
+
return t;
|
|
2244
|
+
}
|
|
2245
|
+
static valueOfVertAlign(e, t = !1) {
|
|
2246
|
+
var n = D.attr(e, "val");
|
|
2247
|
+
switch (n) {
|
|
2248
|
+
case "subscript": return "sub";
|
|
2249
|
+
case "superscript": return t ? "sup" : "super";
|
|
2250
|
+
}
|
|
2251
|
+
return t ? null : n;
|
|
2252
|
+
}
|
|
2253
|
+
static valueOfTextAlignment(e) {
|
|
2254
|
+
var t = D.attr(e, "val");
|
|
2255
|
+
switch (t) {
|
|
2256
|
+
case "auto":
|
|
2257
|
+
case "baseline": return "baseline";
|
|
2258
|
+
case "top": return "top";
|
|
2259
|
+
case "center": return "middle";
|
|
2260
|
+
case "bottom": return "bottom";
|
|
2261
|
+
}
|
|
2262
|
+
return t;
|
|
2263
|
+
}
|
|
2264
|
+
static addSize(e, t) {
|
|
2265
|
+
return e == null ? t : t == null ? e : `calc(${e} + ${t})`;
|
|
2266
|
+
}
|
|
2267
|
+
static classNameOftblLook(e) {
|
|
2268
|
+
let t = D.hexAttr(e, "val", 0), n = "";
|
|
2269
|
+
return (D.boolAttr(e, "firstRow") || t & 32) && (n += " first-row"), (D.boolAttr(e, "lastRow") || t & 64) && (n += " last-row"), (D.boolAttr(e, "firstColumn") || t & 128) && (n += " first-col"), (D.boolAttr(e, "lastColumn") || t & 256) && (n += " last-col"), (D.boolAttr(e, "noHBand") || t & 512) && (n += " no-hband"), (D.boolAttr(e, "noVBand") || t & 1024) && (n += " no-vband"), n.trim();
|
|
2270
|
+
}
|
|
2271
|
+
}, X = {
|
|
2272
|
+
pos: 0,
|
|
2273
|
+
leader: "none",
|
|
2274
|
+
style: "left"
|
|
2275
|
+
}, ht = 50;
|
|
2276
|
+
function gt(e = document.body) {
|
|
2277
|
+
let t = document.createElement("div");
|
|
2278
|
+
t.style.width = "100pt", e.appendChild(t);
|
|
2279
|
+
let n = 100 / t.offsetWidth;
|
|
2280
|
+
return e.removeChild(t), n;
|
|
2281
|
+
}
|
|
2282
|
+
function _t(e, t, n, r = 72 / 96) {
|
|
2283
|
+
let i = e.closest("p"), a = e.getBoundingClientRect(), o = i.getBoundingClientRect(), s = getComputedStyle(i), c = t?.length > 0 ? t.map((e) => ({
|
|
2284
|
+
pos: Z(e.position),
|
|
2285
|
+
leader: e.leader,
|
|
2286
|
+
style: e.style
|
|
2287
|
+
})).sort((e, t) => e.pos - t.pos) : [X], l = c[c.length - 1], u = o.width * r, d = Z(n), f = l.pos + d;
|
|
2288
|
+
if (f < u) for (; f < u && c.length < ht; f += d) c.push({
|
|
2289
|
+
...X,
|
|
2290
|
+
pos: f
|
|
2291
|
+
});
|
|
2292
|
+
let p = parseFloat(s.marginLeft), m = o.left + p, h = (a.left - m) * r, g = c.find((e) => e.style != "clear" && e.pos > h);
|
|
2293
|
+
if (g == null) return;
|
|
2294
|
+
let _ = 1;
|
|
2295
|
+
if (g.style == "right" || g.style == "center") {
|
|
2296
|
+
let t = Array.from(i.querySelectorAll(`.${e.className}`)), n = t.indexOf(e) + 1, a = document.createRange();
|
|
2297
|
+
a.setStart(e, 1), n < t.length ? a.setEndBefore(t[n]) : a.setEndAfter(i);
|
|
2298
|
+
let s = g.style == "center" ? .5 : 1, c = a.getBoundingClientRect(), l = c.left + s * c.width - (o.left - p);
|
|
2299
|
+
_ = g.pos - l * r;
|
|
2300
|
+
} else _ = g.pos - h;
|
|
2301
|
+
switch (e.innerHTML = " ", e.style.textDecoration = "inherit", e.style.wordSpacing = `${_.toFixed(0)}pt`, g.leader) {
|
|
2302
|
+
case "dot":
|
|
2303
|
+
case "middleDot":
|
|
2304
|
+
e.style.textDecoration = "underline", e.style.textDecorationStyle = "dotted";
|
|
2305
|
+
break;
|
|
2306
|
+
case "hyphen":
|
|
2307
|
+
case "heavy":
|
|
2308
|
+
case "underscore": e.style.textDecoration = "underline";
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
function Z(e) {
|
|
2312
|
+
return parseFloat(e);
|
|
2313
|
+
}
|
|
2314
|
+
var Q;
|
|
2315
|
+
(function(e) {
|
|
2316
|
+
e.html = "http://www.w3.org/1999/xhtml", e.svg = "http://www.w3.org/2000/svg", e.mathML = "http://www.w3.org/1998/Math/MathML";
|
|
2317
|
+
})(Q ||= {});
|
|
2318
|
+
function $(e) {
|
|
2319
|
+
if (y(e)) return document.createTextNode(e);
|
|
2320
|
+
if (e instanceof Node) return e;
|
|
2321
|
+
let { ns: t, tagName: n, className: r, style: i, children: a, ...o } = e;
|
|
2322
|
+
if (n === "#fragment") {
|
|
2323
|
+
let e = document.createDocumentFragment();
|
|
2324
|
+
return a && a.forEach((t) => e.appendChild($(t))), e;
|
|
2325
|
+
}
|
|
2326
|
+
if (n === "#comment") return document.createComment(a ? a[0] : "");
|
|
2327
|
+
let s = t ? document.createElementNS(t, n) : document.createElement(n);
|
|
2328
|
+
if (r && s.setAttribute("class", r), i && (y(i) ? s.setAttribute("style", i) : Object.assign(s.style, i)), o) for (let [e, t] of Object.entries(o)) t !== void 0 && (s[e] = t);
|
|
2329
|
+
return a && a.forEach((e) => s.appendChild($(e))), s;
|
|
2330
|
+
}
|
|
2331
|
+
function vt(...e) {
|
|
2332
|
+
return e.filter(Boolean).join(" ");
|
|
2333
|
+
}
|
|
2334
|
+
var yt = class {
|
|
2335
|
+
constructor() {
|
|
2336
|
+
this.className = "docx", this.styleMap = {}, this.currentPart = null, this.tableVerticalMerges = [], this.currentVerticalMerge = null, this.tableCellPositions = [], this.currentCellPosition = null, this.footnoteMap = {}, this.endnoteMap = {}, this.currentEndnoteIds = [], this.usedHederFooterParts = [], this.currentTabs = [], this.commentMap = {}, this.tasks = [], this.postRenderTasks = [], this.h = $;
|
|
2337
|
+
}
|
|
2338
|
+
async render(e, t) {
|
|
2339
|
+
this.document = e, this.options = t, this.className = t.className, this.rootSelector = t.inWrapper ? `.${this.className}-wrapper` : ":root", this.h = t.h ?? $, this.styleMap = null, this.tasks = [], this.options.renderComments && globalThis.Highlight && (this.commentHighlight = new Highlight());
|
|
2340
|
+
let n = [...this.renderDefaultStyle()];
|
|
2341
|
+
e.themePart && n.push(...this.renderTheme(e.themePart)), e.stylesPart != null && (this.styleMap = this.processStyles(e.stylesPart.styles), n.push(...this.renderStyles(e.stylesPart.styles))), e.numberingPart && (this.prodessNumberings(e.numberingPart.domNumberings), n.push(...await this.renderNumbering(e.numberingPart.domNumberings))), e.footnotesPart && (this.footnoteMap = _(e.footnotesPart.notes, (e) => e.id)), e.endnotesPart && (this.endnoteMap = _(e.endnotesPart.notes, (e) => e.id)), e.settingsPart && (this.defaultTabSize = e.settingsPart.settings?.defaultTabStop), !t.ignoreFonts && e.fontTablePart && n.push(...await this.renderFontTable(e.fontTablePart));
|
|
2342
|
+
var r = this.renderSections(e.documentPart.body);
|
|
2343
|
+
return this.options.inWrapper ? n.push(this.renderWrapper(r)) : n.push(...r), this.commentHighlight && t.renderComments && CSS.highlights.set(`${this.className}-comments`, this.commentHighlight), this.postRenderTasks.forEach((e) => e()), await Promise.allSettled(this.tasks), this.refreshTabStops(), n;
|
|
2344
|
+
}
|
|
2345
|
+
renderTheme(e) {
|
|
2346
|
+
let t = {}, n = e.theme?.fontScheme;
|
|
2347
|
+
n && (n.majorFont && (t["--docx-majorHAnsi-font"] = n.majorFont.latinTypeface), n.minorFont && (t["--docx-minorHAnsi-font"] = n.minorFont.latinTypeface));
|
|
2348
|
+
let r = e.theme?.colorScheme;
|
|
2349
|
+
if (r) for (let [e, n] of Object.entries(r.colors)) t[`--docx-${e}-color`] = `#${n}`;
|
|
2350
|
+
let i = this.styleToString(`.${this.className}`, t);
|
|
2351
|
+
return [this.h({
|
|
2352
|
+
tagName: "#comment",
|
|
2353
|
+
children: ["docxjs document theme values"]
|
|
2354
|
+
}), this.h({
|
|
2355
|
+
tagName: "style",
|
|
2356
|
+
children: [i]
|
|
2357
|
+
})];
|
|
2358
|
+
}
|
|
2359
|
+
async renderFontTable(e) {
|
|
2360
|
+
let t = [];
|
|
2361
|
+
for (let n of e.fonts) for (let e of n.embedFontRefs) try {
|
|
2362
|
+
let r = await this.document.loadFont(e.id, e.key), i = {
|
|
2363
|
+
"font-family": m(n.name),
|
|
2364
|
+
src: `url(${r})`
|
|
2365
|
+
};
|
|
2366
|
+
(e.type == "bold" || e.type == "boldItalic") && (i["font-weight"] = "bold"), (e.type == "italic" || e.type == "boldItalic") && (i["font-style"] = "italic"), t.push(this.h({
|
|
2367
|
+
tagName: "#comment",
|
|
2368
|
+
children: [`docxjs ${n.name} font`]
|
|
2369
|
+
})), t.push(this.h({
|
|
2370
|
+
tagName: "style",
|
|
2371
|
+
children: [this.styleToString("@font-face", i)]
|
|
2372
|
+
}));
|
|
2373
|
+
} catch {
|
|
2374
|
+
this.options.debug && console.warn(`Can't load font with id ${e.id} and key ${e.key}`);
|
|
2375
|
+
}
|
|
2376
|
+
return t;
|
|
2377
|
+
}
|
|
2378
|
+
processStyleName(e) {
|
|
2379
|
+
return e ? `${this.className}_${p(e)}` : this.className;
|
|
2380
|
+
}
|
|
2381
|
+
processStyles(e) {
|
|
2382
|
+
let t = _(e.filter((e) => e.id != null), (e) => e.id);
|
|
2383
|
+
for (let r of e.filter((e) => e.basedOn)) {
|
|
2384
|
+
var n = t[r.basedOn];
|
|
2385
|
+
if (n) {
|
|
2386
|
+
r.paragraphProps = b(r.paragraphProps, n.paragraphProps), r.runProps = b(r.runProps, n.runProps);
|
|
2387
|
+
for (let e of n.styles) {
|
|
2388
|
+
let t = r.styles.find((t) => t.target == e.target);
|
|
2389
|
+
t ? this.copyStyleProperties(e.values, t.values) : r.styles.push({
|
|
2390
|
+
...e,
|
|
2391
|
+
values: { ...e.values }
|
|
2392
|
+
});
|
|
2393
|
+
}
|
|
2394
|
+
} else this.options.debug && console.warn(`Can't find base style ${r.basedOn}`);
|
|
2395
|
+
}
|
|
2396
|
+
for (let t of e) t.cssName = this.processStyleName(t.id);
|
|
2397
|
+
return t;
|
|
2398
|
+
}
|
|
2399
|
+
prodessNumberings(e) {
|
|
2400
|
+
for (let t of e.filter((e) => e.pStyleName)) {
|
|
2401
|
+
let e = this.findStyle(t.pStyleName);
|
|
2402
|
+
e?.paragraphProps?.numbering && (e.paragraphProps.numbering.level = t.level);
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
processElement(e) {
|
|
2406
|
+
if (e.children) for (var t of e.children) t.parent = e, t.type == I.Table ? this.processTable(t) : this.processElement(t);
|
|
2407
|
+
}
|
|
2408
|
+
processTable(e) {
|
|
2409
|
+
for (var t of e.children) for (var n of t.children) n.cssStyle = this.copyStyleProperties(e.cellStyle, n.cssStyle, [
|
|
2410
|
+
"border-left",
|
|
2411
|
+
"border-right",
|
|
2412
|
+
"border-top",
|
|
2413
|
+
"border-bottom",
|
|
2414
|
+
"padding-left",
|
|
2415
|
+
"padding-right",
|
|
2416
|
+
"padding-top",
|
|
2417
|
+
"padding-bottom"
|
|
2418
|
+
]), this.processElement(n);
|
|
2419
|
+
}
|
|
2420
|
+
copyStyleProperties(e, t, n = null) {
|
|
2421
|
+
if (!e) return t;
|
|
2422
|
+
t ??= {}, n ??= Object.getOwnPropertyNames(e);
|
|
2423
|
+
for (var r of n) e.hasOwnProperty(r) && !t.hasOwnProperty(r) && (t[r] = e[r]);
|
|
2424
|
+
return t;
|
|
2425
|
+
}
|
|
2426
|
+
createPageElement(e, t, n) {
|
|
2427
|
+
let r = { ...n };
|
|
2428
|
+
return t && (t.pageMargins && (r.paddingLeft = t.pageMargins.left, r.paddingRight = t.pageMargins.right, r.paddingTop = t.pageMargins.top, r.paddingBottom = t.pageMargins.bottom), t.pageSize && (this.options.ignoreWidth || (r.width = t.pageSize.width), this.options.ignoreHeight || (r.minHeight = t.pageSize.height))), this.h({
|
|
2429
|
+
tagName: "section",
|
|
2430
|
+
className: e,
|
|
2431
|
+
style: r
|
|
2432
|
+
});
|
|
2433
|
+
}
|
|
2434
|
+
createSectionContent(e) {
|
|
2435
|
+
let t = {};
|
|
2436
|
+
return e.columns && e.columns.numberOfColumns && (t.columnCount = `${e.columns.numberOfColumns}`, t.columnGap = e.columns.space, e.columns.separator && (t.columnRule = "1px solid black")), this.h({
|
|
2437
|
+
tagName: "article",
|
|
2438
|
+
style: t
|
|
2439
|
+
});
|
|
2440
|
+
}
|
|
2441
|
+
renderSections(e) {
|
|
2442
|
+
let t = [];
|
|
2443
|
+
this.processElement(e);
|
|
2444
|
+
let n = this.splitBySection(e.children, e.props), r = this.groupByPageBreaks(n), i = null;
|
|
2445
|
+
for (let n = 0, o = r.length; n < o; n++) {
|
|
2446
|
+
this.currentFootnoteIds = [];
|
|
2447
|
+
let s = r[n][0].sectProps, c = this.createPageElement(this.className, s, e.cssStyle);
|
|
2448
|
+
this.options.renderHeaders && this.renderHeaderFooter(s.headerRefs, s, t.length, i != s, c);
|
|
2449
|
+
for (let e of r[n]) {
|
|
2450
|
+
var a = this.createSectionContent(e.sectProps);
|
|
2451
|
+
this.renderElements(e.elements, a), c.appendChild(a), s = e.sectProps;
|
|
2452
|
+
}
|
|
2453
|
+
if (this.options.renderFootnotes) {
|
|
2454
|
+
let e = this.renderNotes(this.currentFootnoteIds, this.footnoteMap);
|
|
2455
|
+
e && c.appendChild(e);
|
|
2456
|
+
}
|
|
2457
|
+
if (this.options.renderEndnotes && n == o - 1) {
|
|
2458
|
+
let e = this.renderNotes(this.currentEndnoteIds, this.endnoteMap);
|
|
2459
|
+
e && c.appendChild(e);
|
|
2460
|
+
}
|
|
2461
|
+
this.options.renderFooters && this.renderHeaderFooter(s.footerRefs, s, t.length, i != s, c), t.push(c), i = s;
|
|
2462
|
+
}
|
|
2463
|
+
return t;
|
|
2464
|
+
}
|
|
2465
|
+
renderHeaderFooter(e, t, n, r, i) {
|
|
2466
|
+
if (!e) return;
|
|
2467
|
+
let a = this.document.settingsPart?.settings?.evenAndOddHeaders ?? !1;
|
|
2468
|
+
var o = (t.titlePage && r ? e.find((e) => e.type == "first") : null) ?? (n % 2 == 1 && a ? e.find((e) => e.type == "even") : null) ?? e.find((e) => e.type == "default"), s = o && this.document.findPartByRelId(o.id, this.document.documentPart);
|
|
2469
|
+
if (s) {
|
|
2470
|
+
this.currentPart = s, this.usedHederFooterParts.includes(s.path) || (this.processElement(s.rootElement), this.usedHederFooterParts.push(s.path));
|
|
2471
|
+
let [e] = this.renderElements([s.rootElement], i);
|
|
2472
|
+
t?.pageMargins && (s.rootElement.type === I.Header ? (e.style.marginTop = `calc(${t.pageMargins.header} - ${t.pageMargins.top})`, e.style.minHeight = `calc(${t.pageMargins.top} - ${t.pageMargins.header})`) : s.rootElement.type === I.Footer && (e.style.marginBottom = `calc(${t.pageMargins.footer} - ${t.pageMargins.bottom})`, e.style.minHeight = `calc(${t.pageMargins.bottom} - ${t.pageMargins.footer})`)), this.currentPart = null;
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
isPageBreakElement(e) {
|
|
2476
|
+
return e.type == I.Break ? e.break == "lastRenderedPageBreak" ? !this.options.ignoreLastRenderedPageBreak : e.break == "page" : !1;
|
|
2477
|
+
}
|
|
2478
|
+
isPageBreakSection(e, t) {
|
|
2479
|
+
return !e || !t ? !1 : e.pageSize?.orientation != t.pageSize?.orientation || e.pageSize?.width != t.pageSize?.width || e.pageSize?.height != t.pageSize?.height;
|
|
2480
|
+
}
|
|
2481
|
+
splitBySection(e, t) {
|
|
2482
|
+
var n = {
|
|
2483
|
+
sectProps: null,
|
|
2484
|
+
elements: [],
|
|
2485
|
+
pageBreak: !1
|
|
2486
|
+
}, r = [n];
|
|
2487
|
+
for (let t of e) {
|
|
2488
|
+
if (t.type == I.Paragraph) {
|
|
2489
|
+
let e = t, a = this.findStyle(e.styleName);
|
|
2490
|
+
(e.pageBreakBefore || a?.paragraphProps?.pageBreakBefore) && (n.sectProps = i, n.pageBreak = !0, n = {
|
|
2491
|
+
sectProps: null,
|
|
2492
|
+
elements: [],
|
|
2493
|
+
pageBreak: !1
|
|
2494
|
+
}, r.push(n));
|
|
2495
|
+
}
|
|
2496
|
+
if (n.elements.push(t), t.type == I.Paragraph) {
|
|
2497
|
+
let e = t;
|
|
2498
|
+
var i = e.sectionProps, a = -1, o = -1;
|
|
2499
|
+
if (this.options.breakPages && e.children && (a = e.children.findIndex((e) => (o = e.children?.findIndex(this.isPageBreakElement.bind(this)) ?? -1, o != -1))), (i || a != -1) && (n.sectProps = i, n.pageBreak = a != -1, n = {
|
|
2500
|
+
sectProps: null,
|
|
2501
|
+
elements: [],
|
|
2502
|
+
pageBreak: !1
|
|
2503
|
+
}, r.push(n)), a != -1) {
|
|
2504
|
+
let r = e.children[a], i = o < r.children.length - 1;
|
|
2505
|
+
if (a < e.children.length - 1 || i) {
|
|
2506
|
+
var s = t.children, c = {
|
|
2507
|
+
...t,
|
|
2508
|
+
children: s.slice(a)
|
|
2509
|
+
};
|
|
2510
|
+
if (t.children = s.slice(0, a), n.elements.push(c), i) {
|
|
2511
|
+
let e = r.children, n = {
|
|
2512
|
+
...r,
|
|
2513
|
+
children: e.slice(0, o)
|
|
2514
|
+
};
|
|
2515
|
+
t.children.push(n), r.children = e.slice(o);
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
let l = null;
|
|
2522
|
+
for (let e = r.length - 1; e >= 0; e--) r[e].sectProps == null ? r[e].sectProps = l ?? t : l = r[e].sectProps;
|
|
2523
|
+
return r;
|
|
2524
|
+
}
|
|
2525
|
+
groupByPageBreaks(e) {
|
|
2526
|
+
let t = [], n, r = [t];
|
|
2527
|
+
for (let i of e) t.push(i), (this.options.ignoreLastRenderedPageBreak || i.pageBreak || this.isPageBreakSection(n, i.sectProps)) && r.push(t = []), n = i.sectProps;
|
|
2528
|
+
return r.filter((e) => e.length > 0);
|
|
2529
|
+
}
|
|
2530
|
+
renderWrapper(e) {
|
|
2531
|
+
return this.h({
|
|
2532
|
+
tagName: "div",
|
|
2533
|
+
className: `${this.className}-wrapper`,
|
|
2534
|
+
children: e
|
|
2535
|
+
});
|
|
2536
|
+
}
|
|
2537
|
+
renderDefaultStyle() {
|
|
2538
|
+
var e = this.className, t = `
|
|
2539
|
+
.${e}-wrapper { background: gray; padding: 30px; padding-bottom: 0px; display: flex; flex-flow: column; align-items: center; }
|
|
2540
|
+
.${e}-wrapper>section.${e} { background: white; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); margin-bottom: 30px; }`;
|
|
2541
|
+
this.options.hideWrapperOnPrint && (t = `@media not print { ${t} }`);
|
|
2542
|
+
var n = `${t}
|
|
2543
|
+
.${e} { color: black; hyphens: auto; text-underline-position: from-font; }
|
|
2544
|
+
section.${e} { box-sizing: border-box; display: flex; flex-flow: column nowrap; position: relative; overflow: hidden; }
|
|
2545
|
+
section.${e}>article { margin-bottom: auto; z-index: 1; }
|
|
2546
|
+
section.${e}>footer { z-index: 1; }
|
|
2547
|
+
.${e} table { border-collapse: collapse; }
|
|
2548
|
+
.${e} table td, .${e} table th { vertical-align: top; }
|
|
2549
|
+
.${e} p { margin: 0pt; min-height: 1em; }
|
|
2550
|
+
.${e} span { white-space: pre-wrap; overflow-wrap: break-word; }
|
|
2551
|
+
.${e} a { color: inherit; text-decoration: inherit; }
|
|
2552
|
+
.${e} svg { fill: transparent; }
|
|
2553
|
+
`;
|
|
2554
|
+
return this.options.renderComments && (n += `
|
|
2555
|
+
.${e}-comment-ref { cursor: default; }
|
|
2556
|
+
.${e}-comment-popover { display: none; z-index: 1000; padding: 0.5rem; background: white; position: absolute; box-shadow: 0 0 0.25rem rgba(0, 0, 0, 0.25); width: 30ch; }
|
|
2557
|
+
.${e}-comment-ref:hover~.${e}-comment-popover { display: block; }
|
|
2558
|
+
.${e}-comment-author,.${e}-comment-date { font-size: 0.875rem; color: #888; }
|
|
2559
|
+
`), [this.h({
|
|
2560
|
+
tagName: "#comment",
|
|
2561
|
+
children: ["docxjs library predefined styles"]
|
|
2562
|
+
}), this.h({
|
|
2563
|
+
tagName: "style",
|
|
2564
|
+
children: [n]
|
|
2565
|
+
})];
|
|
2566
|
+
}
|
|
2567
|
+
async renderNumbering(e) {
|
|
2568
|
+
var t = "", n = [];
|
|
2569
|
+
for (var r of e) {
|
|
2570
|
+
var i = `p.${this.numberingClass(r.id, r.level)}`, a = "none";
|
|
2571
|
+
if (r.bullet) {
|
|
2572
|
+
let e = `--${this.className}-${r.bullet.src}`.toLowerCase();
|
|
2573
|
+
t += this.styleToString(`${i}:before`, {
|
|
2574
|
+
content: "' '",
|
|
2575
|
+
display: "inline-block",
|
|
2576
|
+
background: `var(${e})`
|
|
2577
|
+
}, r.bullet.style);
|
|
2578
|
+
try {
|
|
2579
|
+
let n = await this.document.loadNumberingImage(r.bullet.src);
|
|
2580
|
+
t += `${this.rootSelector} { ${e}: url(${n}) }`;
|
|
2581
|
+
} catch {
|
|
2582
|
+
this.options.debug && console.warn(`Can't load numbering image with src ${r.bullet.src}`);
|
|
2583
|
+
}
|
|
2584
|
+
} else if (r.levelText) {
|
|
2585
|
+
let e = this.numberingCounter(r.id, r.level), a = e + " " + (r.start - 1);
|
|
2586
|
+
r.level > 0 && (t += this.styleToString(`p.${this.numberingClass(r.id, r.level - 1)}`, { "counter-set": a })), n.push(a), t += this.styleToString(`${i}:before`, {
|
|
2587
|
+
content: this.levelTextToContent(r.levelText, r.suff, r.id, this.numFormatToCssValue(r.format)),
|
|
2588
|
+
"counter-increment": e,
|
|
2589
|
+
...r.rStyle
|
|
2590
|
+
});
|
|
2591
|
+
} else a = this.numFormatToCssValue(r.format);
|
|
2592
|
+
t += this.styleToString(i, {
|
|
2593
|
+
display: "list-item",
|
|
2594
|
+
"list-style-position": "inside",
|
|
2595
|
+
"list-style-type": a,
|
|
2596
|
+
...r.pStyle
|
|
2597
|
+
});
|
|
2598
|
+
}
|
|
2599
|
+
return n.length > 0 && (t += this.styleToString(this.rootSelector, { "counter-reset": n.join(" ") })), [this.h({
|
|
2600
|
+
tagName: "#comment",
|
|
2601
|
+
children: ["docxjs document numbering styles"]
|
|
2602
|
+
}), this.h({
|
|
2603
|
+
tagName: "style",
|
|
2604
|
+
children: [t]
|
|
2605
|
+
})];
|
|
2606
|
+
}
|
|
2607
|
+
renderStyles(e) {
|
|
2608
|
+
var t = "";
|
|
2609
|
+
let n = this.styleMap, r = _(e.filter((e) => e.isDefault), (e) => e.target);
|
|
2610
|
+
for (let s of e) {
|
|
2611
|
+
var i = s.styles;
|
|
2612
|
+
if (s.linked) {
|
|
2613
|
+
var a = s.linked && n[s.linked];
|
|
2614
|
+
a ? i = i.concat(a.styles) : this.options.debug && console.warn(`Can't find linked style ${s.linked}`);
|
|
2615
|
+
}
|
|
2616
|
+
for (let e of i) {
|
|
2617
|
+
var o = `${s.target ?? ""}.${s.cssName}`;
|
|
2618
|
+
s.target != e.target && (o += ` ${e.target}`), r[s.target] == s && (o = `.${this.className} ${s.target}, ` + o), t += this.styleToString(o, e.values);
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2621
|
+
return [this.h({
|
|
2622
|
+
tagName: "#comment",
|
|
2623
|
+
children: ["docxjs document styles"]
|
|
2624
|
+
}), this.h({
|
|
2625
|
+
tagName: "style",
|
|
2626
|
+
children: [t]
|
|
2627
|
+
})];
|
|
2628
|
+
}
|
|
2629
|
+
renderNotes(e, t) {
|
|
2630
|
+
var n = e.map((e) => t[e]).filter((e) => e);
|
|
2631
|
+
if (n.length > 0) return this.h({
|
|
2632
|
+
tagName: "ol",
|
|
2633
|
+
children: this.renderElements(n)
|
|
2634
|
+
});
|
|
2635
|
+
}
|
|
2636
|
+
renderElement(e) {
|
|
2637
|
+
switch (e.type) {
|
|
2638
|
+
case I.Paragraph: return this.renderParagraph(e);
|
|
2639
|
+
case I.BookmarkStart: return this.renderBookmarkStart(e);
|
|
2640
|
+
case I.BookmarkEnd: return null;
|
|
2641
|
+
case I.Run: return this.renderRun(e);
|
|
2642
|
+
case I.Table: return this.renderTable(e);
|
|
2643
|
+
case I.Row: return this.renderTableRow(e);
|
|
2644
|
+
case I.Cell: return this.renderTableCell(e);
|
|
2645
|
+
case I.Hyperlink: return this.renderHyperlink(e);
|
|
2646
|
+
case I.SmartTag: return this.renderSmartTag(e);
|
|
2647
|
+
case I.Drawing: return this.renderDrawing(e);
|
|
2648
|
+
case I.Image: return this.renderImage(e);
|
|
2649
|
+
case I.Text: return this.renderText(e);
|
|
2650
|
+
case I.Text: return this.renderText(e);
|
|
2651
|
+
case I.DeletedText: return this.renderDeletedText(e);
|
|
2652
|
+
case I.Tab: return this.renderTab(e);
|
|
2653
|
+
case I.Symbol: return this.renderSymbol(e);
|
|
2654
|
+
case I.Break: return this.renderBreak(e);
|
|
2655
|
+
case I.Footer: return this.renderContainer(e, "footer");
|
|
2656
|
+
case I.Header: return this.renderContainer(e, "header");
|
|
2657
|
+
case I.Footnote:
|
|
2658
|
+
case I.Endnote: return this.renderContainer(e, "li");
|
|
2659
|
+
case I.FootnoteReference: return this.renderFootnoteReference(e);
|
|
2660
|
+
case I.EndnoteReference: return this.renderEndnoteReference(e);
|
|
2661
|
+
case I.NoBreakHyphen: return this.h({ tagName: "wbr" });
|
|
2662
|
+
case I.VmlPicture: return this.renderVmlPicture(e);
|
|
2663
|
+
case I.VmlElement: return this.renderVmlElement(e);
|
|
2664
|
+
case I.MmlMath: return this.renderContainerNS(e, Q.mathML, "math", { xmlns: Q.mathML });
|
|
2665
|
+
case I.MmlMathParagraph: return this.renderContainer(e, "span");
|
|
2666
|
+
case I.MmlFraction: return this.renderContainerNS(e, Q.mathML, "mfrac");
|
|
2667
|
+
case I.MmlBase: return this.renderContainerNS(e, Q.mathML, e.parent.type == I.MmlMatrixRow ? "mtd" : "mrow");
|
|
2668
|
+
case I.MmlNumerator:
|
|
2669
|
+
case I.MmlDenominator:
|
|
2670
|
+
case I.MmlFunction:
|
|
2671
|
+
case I.MmlLimit:
|
|
2672
|
+
case I.MmlBox: return this.renderContainerNS(e, Q.mathML, "mrow");
|
|
2673
|
+
case I.MmlGroupChar: return this.renderMmlGroupChar(e);
|
|
2674
|
+
case I.MmlLimitLower: return this.renderContainerNS(e, Q.mathML, "munder");
|
|
2675
|
+
case I.MmlMatrix: return this.renderContainerNS(e, Q.mathML, "mtable");
|
|
2676
|
+
case I.MmlMatrixRow: return this.renderContainerNS(e, Q.mathML, "mtr");
|
|
2677
|
+
case I.MmlRadical: return this.renderMmlRadical(e);
|
|
2678
|
+
case I.MmlSuperscript: return this.renderContainerNS(e, Q.mathML, "msup");
|
|
2679
|
+
case I.MmlSubscript: return this.renderContainerNS(e, Q.mathML, "msub");
|
|
2680
|
+
case I.MmlDegree:
|
|
2681
|
+
case I.MmlSuperArgument:
|
|
2682
|
+
case I.MmlSubArgument: return this.renderContainerNS(e, Q.mathML, "mn");
|
|
2683
|
+
case I.MmlFunctionName: return this.renderContainerNS(e, Q.mathML, "ms");
|
|
2684
|
+
case I.MmlDelimiter: return this.renderMmlDelimiter(e);
|
|
2685
|
+
case I.MmlRun: return this.renderMmlRun(e);
|
|
2686
|
+
case I.MmlNary: return this.renderMmlNary(e);
|
|
2687
|
+
case I.MmlPreSubSuper: return this.renderMmlPreSubSuper(e);
|
|
2688
|
+
case I.MmlBar: return this.renderMmlBar(e);
|
|
2689
|
+
case I.MmlEquationArray: return this.renderMllList(e);
|
|
2690
|
+
case I.Inserted: return this.renderInserted(e);
|
|
2691
|
+
case I.Deleted: return this.renderDeleted(e);
|
|
2692
|
+
case I.CommentRangeStart: return this.renderCommentRangeStart(e);
|
|
2693
|
+
case I.CommentRangeEnd: return this.renderCommentRangeEnd(e);
|
|
2694
|
+
case I.CommentReference: return this.renderCommentReference(e);
|
|
2695
|
+
case I.AltChunk: return this.renderAltChunk(e);
|
|
2696
|
+
}
|
|
2697
|
+
return null;
|
|
2698
|
+
}
|
|
2699
|
+
renderElements(e, t) {
|
|
2700
|
+
if (e == null) return null;
|
|
2701
|
+
var n = e.flatMap((e) => this.renderElement(e)).filter((e) => e != null);
|
|
2702
|
+
return t && n.forEach((e) => t.appendChild(y(e) ? document.createTextNode(e) : e)), n;
|
|
2703
|
+
}
|
|
2704
|
+
renderContainer(e, t, n) {
|
|
2705
|
+
return this.h({
|
|
2706
|
+
tagName: t,
|
|
2707
|
+
children: this.renderElements(e.children),
|
|
2708
|
+
...n
|
|
2709
|
+
});
|
|
2710
|
+
}
|
|
2711
|
+
renderContainerNS(e, t, n, r) {
|
|
2712
|
+
return this.h({
|
|
2713
|
+
ns: t,
|
|
2714
|
+
tagName: n,
|
|
2715
|
+
children: this.renderElements(e.children),
|
|
2716
|
+
...r
|
|
2717
|
+
});
|
|
2718
|
+
}
|
|
2719
|
+
renderParagraph(e) {
|
|
2720
|
+
var t = this.toHTML(e, Q.html, "p");
|
|
2721
|
+
let n = this.findStyle(e.styleName);
|
|
2722
|
+
e.tabs ??= n?.paragraphProps?.tabs;
|
|
2723
|
+
let r = e.numbering ?? n?.paragraphProps?.numbering;
|
|
2724
|
+
return r && t.classList.add(this.numberingClass(r.id, r.level)), t;
|
|
2725
|
+
}
|
|
2726
|
+
renderHyperlink(e) {
|
|
2727
|
+
let t = this.toH(e, Q.html, "a");
|
|
2728
|
+
return t.href = "", e.id && (t.href = this.document.documentPart.rels.find((t) => t.id == e.id && t.targetMode === "External")?.target ?? t.href), e.anchor && (t.href += `#${e.anchor}`), this.h(t);
|
|
2729
|
+
}
|
|
2730
|
+
renderSmartTag(e) {
|
|
2731
|
+
return this.renderContainer(e, "span");
|
|
2732
|
+
}
|
|
2733
|
+
renderCommentRangeStart(e) {
|
|
2734
|
+
if (!this.options.renderComments) return null;
|
|
2735
|
+
let t = new Range();
|
|
2736
|
+
this.commentHighlight?.add(t);
|
|
2737
|
+
let n = this.h({
|
|
2738
|
+
tagName: "#comment",
|
|
2739
|
+
children: [`start of comment #${e.id}`]
|
|
2740
|
+
});
|
|
2741
|
+
return this.later(() => t.setStart(n, 0)), this.commentMap[e.id] = t, n;
|
|
2742
|
+
}
|
|
2743
|
+
renderCommentRangeEnd(e) {
|
|
2744
|
+
if (!this.options.renderComments) return null;
|
|
2745
|
+
let t = this.commentMap[e.id], n = this.h({
|
|
2746
|
+
tagName: "#comment",
|
|
2747
|
+
children: [`end of comment #${e.id}`]
|
|
2748
|
+
});
|
|
2749
|
+
return this.later(() => t?.setEnd(n, 0)), n;
|
|
2750
|
+
}
|
|
2751
|
+
renderCommentReference(e) {
|
|
2752
|
+
if (!this.options.renderComments) return null;
|
|
2753
|
+
var t = this.document.commentsPart?.commentMap[e.id];
|
|
2754
|
+
if (!t) return null;
|
|
2755
|
+
let n = this.h({
|
|
2756
|
+
tagName: "span",
|
|
2757
|
+
className: `${this.className}-comment-ref`,
|
|
2758
|
+
children: ["💬"]
|
|
2759
|
+
}), r = this.h({
|
|
2760
|
+
tagName: "div",
|
|
2761
|
+
className: `${this.className}-comment-popover`,
|
|
2762
|
+
children: [
|
|
2763
|
+
this.h({
|
|
2764
|
+
tagName: "div",
|
|
2765
|
+
className: `${this.className}-comment-author`,
|
|
2766
|
+
children: [t.author]
|
|
2767
|
+
}),
|
|
2768
|
+
this.h({
|
|
2769
|
+
tagName: "div",
|
|
2770
|
+
className: `${this.className}-comment-date`,
|
|
2771
|
+
children: [new Date(t.date).toLocaleString()]
|
|
2772
|
+
}),
|
|
2773
|
+
...this.renderElements(t.children)
|
|
2774
|
+
]
|
|
2775
|
+
});
|
|
2776
|
+
return this.h({
|
|
2777
|
+
tagName: "#fragment",
|
|
2778
|
+
children: [
|
|
2779
|
+
this.h({
|
|
2780
|
+
tagName: "#comment",
|
|
2781
|
+
children: [`comment #${t.id} by ${t.author} on ${t.date}`]
|
|
2782
|
+
}),
|
|
2783
|
+
n,
|
|
2784
|
+
r
|
|
2785
|
+
]
|
|
2786
|
+
});
|
|
2787
|
+
}
|
|
2788
|
+
renderAltChunk(e) {
|
|
2789
|
+
if (!this.options.renderAltChunks) return null;
|
|
2790
|
+
var t = this.h({ tagName: "iframe" });
|
|
2791
|
+
return this.tasks.push(this.document.loadAltChunk(e.id, this.currentPart).then((e) => {
|
|
2792
|
+
t.srcdoc = e;
|
|
2793
|
+
})), t;
|
|
2794
|
+
}
|
|
2795
|
+
renderDrawing(e) {
|
|
2796
|
+
var t = this.toHTML(e, Q.html, "div");
|
|
2797
|
+
return t.style.display = "inline-block", t.style.position = "relative", t.style.textIndent = "0px", t;
|
|
2798
|
+
}
|
|
2799
|
+
renderImage(e) {
|
|
2800
|
+
let t = this.toHTML(e, Q.html, "img", []), n = e.cssStyle?.transform;
|
|
2801
|
+
if (e.srcRect && e.srcRect.some((e) => e != 0)) {
|
|
2802
|
+
var [r, i, a, o] = e.srcRect;
|
|
2803
|
+
n = `scale(${1 / (1 - r - a)}, ${1 / (1 - i - o)})`, t.style["clip-path"] = `rect(${(100 * i).toFixed(2)}% ${(100 * (1 - a)).toFixed(2)}% ${(100 * (1 - o)).toFixed(2)}% ${(100 * r).toFixed(2)}%)`;
|
|
2804
|
+
}
|
|
2805
|
+
return e.rotation && (n = `rotate(${e.rotation}deg) ${n ?? ""}`), t.style.transform = n?.trim(), this.document && this.tasks.push(this.document.loadDocumentImage(e.src, this.currentPart).then((e) => {
|
|
2806
|
+
t.src = e;
|
|
2807
|
+
})), t;
|
|
2808
|
+
}
|
|
2809
|
+
renderText(e) {
|
|
2810
|
+
return this.h(e.text);
|
|
2811
|
+
}
|
|
2812
|
+
renderDeletedText(e) {
|
|
2813
|
+
return this.options.renderChanges ? this.renderText(e) : null;
|
|
2814
|
+
}
|
|
2815
|
+
renderBreak(e) {
|
|
2816
|
+
return e.break == "textWrapping" ? this.h({ tagName: "br" }) : null;
|
|
2817
|
+
}
|
|
2818
|
+
renderInserted(e) {
|
|
2819
|
+
return this.options.renderChanges ? this.renderChange(e, "ins") : this.renderElements(e.children);
|
|
2820
|
+
}
|
|
2821
|
+
renderDeleted(e) {
|
|
2822
|
+
return this.options.renderChanges ? this.renderChange(e, "del") : null;
|
|
2823
|
+
}
|
|
2824
|
+
renderChange(e, t) {
|
|
2825
|
+
return this.renderContainer(e, t, { dateTime: e.date });
|
|
2826
|
+
}
|
|
2827
|
+
renderSymbol(e) {
|
|
2828
|
+
return this.h({
|
|
2829
|
+
tagName: "span",
|
|
2830
|
+
children: [String.fromCharCode(e.char)],
|
|
2831
|
+
style: { fontFamily: e.font }
|
|
2832
|
+
});
|
|
2833
|
+
}
|
|
2834
|
+
renderFootnoteReference(e) {
|
|
2835
|
+
return this.currentFootnoteIds.push(e.id), this.h({
|
|
2836
|
+
tagName: "sup",
|
|
2837
|
+
children: [`${this.currentFootnoteIds.length}`]
|
|
2838
|
+
});
|
|
2839
|
+
}
|
|
2840
|
+
renderEndnoteReference(e) {
|
|
2841
|
+
return this.currentEndnoteIds.push(e.id), this.h({
|
|
2842
|
+
tagName: "sup",
|
|
2843
|
+
children: [`${this.currentEndnoteIds.length}`]
|
|
2844
|
+
});
|
|
2845
|
+
}
|
|
2846
|
+
renderTab(e) {
|
|
2847
|
+
var t = this.h({
|
|
2848
|
+
tagName: "span",
|
|
2849
|
+
children: [" "]
|
|
2850
|
+
});
|
|
2851
|
+
if (this.options.experimental) {
|
|
2852
|
+
t.className = this.tabStopClass();
|
|
2853
|
+
var n = bt(e, I.Paragraph)?.tabs;
|
|
2854
|
+
this.currentTabs.push({
|
|
2855
|
+
stops: n,
|
|
2856
|
+
span: t
|
|
2857
|
+
});
|
|
2858
|
+
}
|
|
2859
|
+
return t;
|
|
2860
|
+
}
|
|
2861
|
+
renderBookmarkStart(e) {
|
|
2862
|
+
return this.h({
|
|
2863
|
+
tagName: "span",
|
|
2864
|
+
id: e.name
|
|
2865
|
+
});
|
|
2866
|
+
}
|
|
2867
|
+
renderRun(e) {
|
|
2868
|
+
if (e.fieldRun) return null;
|
|
2869
|
+
let t = this.renderElements(e.children);
|
|
2870
|
+
e.verticalAlign && (t = [this.h({
|
|
2871
|
+
tagName: e.verticalAlign,
|
|
2872
|
+
children: this.renderElements(e.children)
|
|
2873
|
+
})]);
|
|
2874
|
+
let n = this.toHTML(e, Q.html, "span", t);
|
|
2875
|
+
return e.id && (n.id = e.id), n;
|
|
2876
|
+
}
|
|
2877
|
+
renderTable(e) {
|
|
2878
|
+
this.tableCellPositions.push(this.currentCellPosition), this.tableVerticalMerges.push(this.currentVerticalMerge), this.currentVerticalMerge = {}, this.currentCellPosition = {
|
|
2879
|
+
col: 0,
|
|
2880
|
+
row: 0
|
|
2881
|
+
};
|
|
2882
|
+
let t = [];
|
|
2883
|
+
return e.columns && t.push(this.renderTableColumns(e.columns)), t.push(...this.renderElements(e.children)), this.currentVerticalMerge = this.tableVerticalMerges.pop(), this.currentCellPosition = this.tableCellPositions.pop(), this.toHTML(e, Q.html, "table", t);
|
|
2884
|
+
}
|
|
2885
|
+
renderTableColumns(e) {
|
|
2886
|
+
let t = e.map((e) => this.h({
|
|
2887
|
+
tagName: "col",
|
|
2888
|
+
style: { width: e.width }
|
|
2889
|
+
}));
|
|
2890
|
+
return this.h({
|
|
2891
|
+
tagName: "colgroup",
|
|
2892
|
+
children: t
|
|
2893
|
+
});
|
|
2894
|
+
}
|
|
2895
|
+
renderTableRow(e) {
|
|
2896
|
+
this.currentCellPosition.col = 0;
|
|
2897
|
+
let t = [];
|
|
2898
|
+
return e.gridBefore && t.push(this.renderTableCellPlaceholder(e.gridBefore)), t.push(...this.renderElements(e.children)), e.gridAfter && t.push(this.renderTableCellPlaceholder(e.gridAfter)), this.currentCellPosition.row++, this.toHTML(e, Q.html, "tr", t);
|
|
2899
|
+
}
|
|
2900
|
+
renderTableCellPlaceholder(e) {
|
|
2901
|
+
return this.h({
|
|
2902
|
+
tagName: "td",
|
|
2903
|
+
colSpan: e,
|
|
2904
|
+
style: { border: "none" }
|
|
2905
|
+
});
|
|
2906
|
+
}
|
|
2907
|
+
renderTableCell(e) {
|
|
2908
|
+
let t = this.toHTML(e, Q.html, "td"), n = this.currentCellPosition.col;
|
|
2909
|
+
return e.verticalMerge ? e.verticalMerge == "restart" ? (this.currentVerticalMerge[n] = t, t.rowSpan = 1) : this.currentVerticalMerge[n] && (this.currentVerticalMerge[n].rowSpan += 1, t.style.display = "none") : this.currentVerticalMerge[n] = null, e.span && (t.colSpan = e.span), this.currentCellPosition.col += t.colSpan, t;
|
|
2910
|
+
}
|
|
2911
|
+
renderVmlPicture(e) {
|
|
2912
|
+
return this.renderContainer(e, "div");
|
|
2913
|
+
}
|
|
2914
|
+
renderVmlElement(e) {
|
|
2915
|
+
var t = this.h({
|
|
2916
|
+
ns: Q.svg,
|
|
2917
|
+
tagName: "svg",
|
|
2918
|
+
style: e.cssStyleText
|
|
2919
|
+
});
|
|
2920
|
+
let n = this.renderVmlChildElement(e);
|
|
2921
|
+
return e.imageHref?.id && this.tasks.push(this.document?.loadDocumentImage(e.imageHref.id, this.currentPart).then((e) => n.setAttribute("href", e))), t.appendChild(n), requestAnimationFrame(() => {
|
|
2922
|
+
let e = t.firstElementChild.getBBox();
|
|
2923
|
+
t.setAttribute("width", `${Math.ceil(e.x + e.width)}`), t.setAttribute("height", `${Math.ceil(e.y + e.height)}`);
|
|
2924
|
+
}), t;
|
|
2925
|
+
}
|
|
2926
|
+
renderVmlChildElement(e) {
|
|
2927
|
+
let t = this.createSvgElement(e.tagName);
|
|
2928
|
+
Object.entries(e.attrs).forEach(([e, n]) => t.setAttribute(e, n));
|
|
2929
|
+
for (let n of e.children) n.type == I.VmlElement ? t.appendChild(this.renderVmlChildElement(n)) : t.appendChild(...x(this.renderElement(n)));
|
|
2930
|
+
return t;
|
|
2931
|
+
}
|
|
2932
|
+
renderMmlRadical(e) {
|
|
2933
|
+
let t = e.children.find((e) => e.type == I.MmlBase);
|
|
2934
|
+
if (e.props?.hideDegree) return this.createMathMLElement("msqrt", null, this.renderElements([t]));
|
|
2935
|
+
let n = e.children.find((e) => e.type == I.MmlDegree);
|
|
2936
|
+
return this.createMathMLElement("mroot", null, this.renderElements([t, n]));
|
|
2937
|
+
}
|
|
2938
|
+
renderMmlDelimiter(e) {
|
|
2939
|
+
let t = [];
|
|
2940
|
+
return t.push(this.createMathMLElement("mo", null, [e.props.beginChar ?? "("])), t.push(...this.renderElements(e.children)), t.push(this.createMathMLElement("mo", null, [e.props.endChar ?? ")"])), this.createMathMLElement("mrow", null, t);
|
|
2941
|
+
}
|
|
2942
|
+
renderMmlNary(e) {
|
|
2943
|
+
let t = [], n = _(e.children, (e) => e.type), r = n[I.MmlSuperArgument], i = n[I.MmlSubArgument], a = r ? this.createMathMLElement("mo", null, x(this.renderElement(r))) : null, o = i ? this.createMathMLElement("mo", null, x(this.renderElement(i))) : null, s = this.createMathMLElement("mo", null, [e.props?.char ?? "∫"]);
|
|
2944
|
+
return a || o ? t.push(this.createMathMLElement("munderover", null, [
|
|
2945
|
+
s,
|
|
2946
|
+
o,
|
|
2947
|
+
a
|
|
2948
|
+
])) : a ? t.push(this.createMathMLElement("mover", null, [s, a])) : o ? t.push(this.createMathMLElement("munder", null, [s, o])) : t.push(s), t.push(...this.renderElements(n[I.MmlBase].children)), this.createMathMLElement("mrow", null, t);
|
|
2949
|
+
}
|
|
2950
|
+
renderMmlPreSubSuper(e) {
|
|
2951
|
+
let t = [], n = _(e.children, (e) => e.type), r = n[I.MmlSuperArgument], i = n[I.MmlSubArgument], a = r ? this.createMathMLElement("mo", null, x(this.renderElement(r))) : null, o = i ? this.createMathMLElement("mo", null, x(this.renderElement(i))) : null, s = this.createMathMLElement("mo", null);
|
|
2952
|
+
return t.push(this.createMathMLElement("msubsup", null, [
|
|
2953
|
+
s,
|
|
2954
|
+
o,
|
|
2955
|
+
a
|
|
2956
|
+
])), t.push(...this.renderElements(n[I.MmlBase].children)), this.createMathMLElement("mrow", null, t);
|
|
2957
|
+
}
|
|
2958
|
+
renderMmlGroupChar(e) {
|
|
2959
|
+
let t = e.props.verticalJustification === "bot" ? "mover" : "munder", n = this.renderContainerNS(e, Q.mathML, t);
|
|
2960
|
+
return e.props.char && n.appendChild(this.createMathMLElement("mo", null, [e.props.char])), n;
|
|
2961
|
+
}
|
|
2962
|
+
renderMmlBar(e) {
|
|
2963
|
+
let t = {};
|
|
2964
|
+
switch (e.props.position) {
|
|
2965
|
+
case "top":
|
|
2966
|
+
t.textDecoration = "overline";
|
|
2967
|
+
break;
|
|
2968
|
+
case "bottom": t.textDecoration = "underline";
|
|
2969
|
+
}
|
|
2970
|
+
return this.renderContainerNS(e, Q.mathML, "mrow", { style: t });
|
|
2971
|
+
}
|
|
2972
|
+
renderMmlRun(e) {
|
|
2973
|
+
return this.toHTML(e, Q.mathML, "ms");
|
|
2974
|
+
}
|
|
2975
|
+
renderMllList(e) {
|
|
2976
|
+
let t = this.renderElements(e.children).map((e) => this.createMathMLElement("mtr", null, [this.createMathMLElement("mtd", null, [e])]));
|
|
2977
|
+
return this.toHTML(e, Q.mathML, "mtable", t);
|
|
2978
|
+
}
|
|
2979
|
+
toH(e, t, n, r = null) {
|
|
2980
|
+
let { $lang: i, ...a } = e.cssStyle ?? {};
|
|
2981
|
+
return {
|
|
2982
|
+
ns: t,
|
|
2983
|
+
tagName: n,
|
|
2984
|
+
className: vt(e.className, e.styleName && this.processStyleName(e.styleName)),
|
|
2985
|
+
lang: i,
|
|
2986
|
+
style: a,
|
|
2987
|
+
children: r ?? this.renderElements(e.children)
|
|
2988
|
+
};
|
|
2989
|
+
}
|
|
2990
|
+
toHTML(e, t, n, r = null) {
|
|
2991
|
+
return this.h(this.toH(e, t, n, r));
|
|
2992
|
+
}
|
|
2993
|
+
findStyle(e) {
|
|
2994
|
+
return e && this.styleMap?.[e];
|
|
2995
|
+
}
|
|
2996
|
+
numberingClass(e, t) {
|
|
2997
|
+
return `${this.className}-num-${e}-${t}`;
|
|
2998
|
+
}
|
|
2999
|
+
tabStopClass() {
|
|
3000
|
+
return `${this.className}-tab-stop`;
|
|
3001
|
+
}
|
|
3002
|
+
styleToString(e, t, n = null) {
|
|
3003
|
+
let r = `${e} {\r\n`;
|
|
3004
|
+
for (let e in t) e.startsWith("$") || (r += ` ${e}: ${t[e]};\r\n`);
|
|
3005
|
+
return n && (r += n), r + "}\r\n";
|
|
3006
|
+
}
|
|
3007
|
+
numberingCounter(e, t) {
|
|
3008
|
+
return `${this.className}-num-${e}-${t}`;
|
|
3009
|
+
}
|
|
3010
|
+
levelTextToContent(e, t, n, r) {
|
|
3011
|
+
return `"${e.replace(/%\d*/g, (e) => {
|
|
3012
|
+
let t = parseInt(e.substring(1), 10) - 1;
|
|
3013
|
+
return `"counter(${this.numberingCounter(n, t)}, ${r})"`;
|
|
3014
|
+
})}${{
|
|
3015
|
+
tab: "\\9",
|
|
3016
|
+
space: "\\a0"
|
|
3017
|
+
}[t] ?? ""}"`;
|
|
3018
|
+
}
|
|
3019
|
+
numFormatToCssValue(e) {
|
|
3020
|
+
return {
|
|
3021
|
+
none: "none",
|
|
3022
|
+
bullet: "disc",
|
|
3023
|
+
decimal: "decimal",
|
|
3024
|
+
lowerLetter: "lower-alpha",
|
|
3025
|
+
upperLetter: "upper-alpha",
|
|
3026
|
+
lowerRoman: "lower-roman",
|
|
3027
|
+
upperRoman: "upper-roman",
|
|
3028
|
+
decimalZero: "decimal-leading-zero",
|
|
3029
|
+
aiueo: "katakana",
|
|
3030
|
+
aiueoFullWidth: "katakana",
|
|
3031
|
+
chineseCounting: "simp-chinese-informal",
|
|
3032
|
+
chineseCountingThousand: "simp-chinese-informal",
|
|
3033
|
+
chineseLegalSimplified: "simp-chinese-formal",
|
|
3034
|
+
chosung: "hangul-consonant",
|
|
3035
|
+
ideographDigital: "cjk-ideographic",
|
|
3036
|
+
ideographTraditional: "cjk-heavenly-stem",
|
|
3037
|
+
ideographLegalTraditional: "trad-chinese-formal",
|
|
3038
|
+
ideographZodiac: "cjk-earthly-branch",
|
|
3039
|
+
iroha: "katakana-iroha",
|
|
3040
|
+
irohaFullWidth: "katakana-iroha",
|
|
3041
|
+
japaneseCounting: "japanese-informal",
|
|
3042
|
+
japaneseDigitalTenThousand: "cjk-decimal",
|
|
3043
|
+
japaneseLegal: "japanese-formal",
|
|
3044
|
+
thaiNumbers: "thai",
|
|
3045
|
+
koreanCounting: "korean-hangul-formal",
|
|
3046
|
+
koreanDigital: "korean-hangul-formal",
|
|
3047
|
+
koreanDigital2: "korean-hanja-informal",
|
|
3048
|
+
hebrew1: "hebrew",
|
|
3049
|
+
hebrew2: "hebrew",
|
|
3050
|
+
hindiNumbers: "devanagari",
|
|
3051
|
+
ganada: "hangul",
|
|
3052
|
+
taiwaneseCounting: "cjk-ideographic",
|
|
3053
|
+
taiwaneseCountingThousand: "cjk-ideographic",
|
|
3054
|
+
taiwaneseDigital: "cjk-decimal"
|
|
3055
|
+
}[e] ?? e;
|
|
3056
|
+
}
|
|
3057
|
+
refreshTabStops() {
|
|
3058
|
+
this.options.experimental && setTimeout(() => {
|
|
3059
|
+
let e = gt();
|
|
3060
|
+
for (let t of this.currentTabs) _t(t.span, t.stops, this.defaultTabSize, e);
|
|
3061
|
+
}, 500);
|
|
3062
|
+
}
|
|
3063
|
+
createElementNS(e, t, n, r) {
|
|
3064
|
+
return this.h({
|
|
3065
|
+
ns: e,
|
|
3066
|
+
tagName: t,
|
|
3067
|
+
children: r,
|
|
3068
|
+
...n
|
|
3069
|
+
});
|
|
3070
|
+
}
|
|
3071
|
+
createElement(e, t, n) {
|
|
3072
|
+
return this.createElementNS(Q.html, e, t, n);
|
|
3073
|
+
}
|
|
3074
|
+
createMathMLElement(e, t, n) {
|
|
3075
|
+
return this.createElementNS(Q.mathML, e, t, n);
|
|
3076
|
+
}
|
|
3077
|
+
createSvgElement(e, t, n) {
|
|
3078
|
+
return this.createElementNS(Q.svg, e, t, n);
|
|
3079
|
+
}
|
|
3080
|
+
later(e) {
|
|
3081
|
+
this.postRenderTasks.push(e);
|
|
3082
|
+
}
|
|
3083
|
+
};
|
|
3084
|
+
function bt(e, t) {
|
|
3085
|
+
for (var n = e.parent; n != null && n.type != t;) n = n.parent;
|
|
3086
|
+
return n;
|
|
3087
|
+
}
|
|
3088
|
+
var xt = {
|
|
3089
|
+
ignoreHeight: !1,
|
|
3090
|
+
ignoreWidth: !1,
|
|
3091
|
+
ignoreFonts: !1,
|
|
3092
|
+
breakPages: !0,
|
|
3093
|
+
debug: !1,
|
|
3094
|
+
experimental: !1,
|
|
3095
|
+
className: "docx",
|
|
3096
|
+
inWrapper: !0,
|
|
3097
|
+
hideWrapperOnPrint: !1,
|
|
3098
|
+
trimXmlDeclaration: !0,
|
|
3099
|
+
ignoreLastRenderedPageBreak: !0,
|
|
3100
|
+
renderHeaders: !0,
|
|
3101
|
+
renderFooters: !0,
|
|
3102
|
+
renderFootnotes: !0,
|
|
3103
|
+
renderEndnotes: !0,
|
|
3104
|
+
useBase64URL: !1,
|
|
3105
|
+
renderChanges: !1,
|
|
3106
|
+
renderComments: !1,
|
|
3107
|
+
renderAltChunks: !0,
|
|
3108
|
+
h: $
|
|
3109
|
+
};
|
|
3110
|
+
function St(e, t) {
|
|
3111
|
+
let n = {
|
|
3112
|
+
...xt,
|
|
3113
|
+
...t
|
|
3114
|
+
};
|
|
3115
|
+
return tt.load(e, new pt(n), n);
|
|
3116
|
+
}
|
|
3117
|
+
async function Ct(e, t) {
|
|
3118
|
+
let n = {
|
|
3119
|
+
...xt,
|
|
3120
|
+
...t
|
|
3121
|
+
};
|
|
3122
|
+
return await new yt().render(e, n);
|
|
3123
|
+
}
|
|
3124
|
+
async function wt(e, t, n, r) {
|
|
3125
|
+
let i = await St(e, r), a = await Ct(i, r);
|
|
3126
|
+
n ??= t, n.innerHTML = "", t.innerHTML = "";
|
|
3127
|
+
for (let e of a) (e.nodeName === "STYLE" ? n : t).appendChild(e);
|
|
3128
|
+
return i;
|
|
3129
|
+
}
|
|
3130
|
+
// src/components/file-viewer/renderers/DocxRenderer.vue?vue&type=script&setup=true&lang.ts
|
|
3131
|
+
var Tt = { class: "fv-docx" }, Et = /*#__PURE__*/ n(/* @__PURE__ */ a({
|
|
3132
|
+
__name: "DocxRenderer",
|
|
3133
|
+
props: {
|
|
3134
|
+
source: {},
|
|
3135
|
+
options: {},
|
|
3136
|
+
viewportWidth: {},
|
|
3137
|
+
viewportHeight: {}
|
|
3138
|
+
},
|
|
3139
|
+
emits: ["ready", "error"],
|
|
3140
|
+
setup(e, { emit: t }) {
|
|
3141
|
+
let n = e, a = t, u = l(null), d = l(null), f = !1;
|
|
3142
|
+
return s(async () => {
|
|
3143
|
+
try {
|
|
3144
|
+
let e = await n.source.getBlob();
|
|
3145
|
+
if (f || !u.value || !d.value || (await wt(e, u.value, d.value, {
|
|
3146
|
+
inWrapper: !0,
|
|
3147
|
+
breakPages: !0,
|
|
3148
|
+
renderHeaders: !0,
|
|
3149
|
+
renderFooters: !0,
|
|
3150
|
+
renderFootnotes: !0,
|
|
3151
|
+
renderEndnotes: !0,
|
|
3152
|
+
useBase64URL: !0,
|
|
3153
|
+
ignoreLastRenderedPageBreak: !1
|
|
3154
|
+
}), f)) return;
|
|
3155
|
+
a("ready");
|
|
3156
|
+
} catch (e) {
|
|
3157
|
+
if (f) return;
|
|
3158
|
+
a("error", e instanceof Error ? e.message : "Word 文档解析失败");
|
|
3159
|
+
}
|
|
3160
|
+
}), o(() => {
|
|
3161
|
+
f = !0, u.value && (u.value.innerHTML = ""), d.value && (d.value.innerHTML = "");
|
|
3162
|
+
}), (e, t) => (c(), r("div", Tt, [i("div", {
|
|
3163
|
+
ref_key: "styles",
|
|
3164
|
+
ref: d,
|
|
3165
|
+
class: "fv-docx-styles"
|
|
3166
|
+
}, null, 512), i("div", {
|
|
3167
|
+
ref_key: "body",
|
|
3168
|
+
ref: u,
|
|
3169
|
+
class: "fv-docx-body"
|
|
3170
|
+
}, null, 512)]));
|
|
3171
|
+
}
|
|
3172
|
+
}), [["__scopeId", "data-v-4f61d703"]]);
|
|
3173
|
+
export { Et as default };
|