docxmlater 9.7.1 → 9.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/Document.d.ts +27 -0
- package/dist/core/Document.d.ts.map +1 -1
- package/dist/core/Document.js +125 -21
- package/dist/core/Document.js.map +1 -1
- package/dist/core/DocumentGenerator.d.ts +7 -1
- package/dist/core/DocumentGenerator.d.ts.map +1 -1
- package/dist/core/DocumentGenerator.js +25 -2
- package/dist/core/DocumentGenerator.js.map +1 -1
- package/dist/core/DocumentParser.d.ts +7 -0
- package/dist/core/DocumentParser.d.ts.map +1 -1
- package/dist/core/DocumentParser.js +307 -59
- package/dist/core/DocumentParser.js.map +1 -1
- package/dist/core/Relationship.d.ts +1 -0
- package/dist/core/Relationship.d.ts.map +1 -1
- package/dist/core/Relationship.js +8 -1
- package/dist/core/Relationship.js.map +1 -1
- package/dist/core/RelationshipManager.d.ts +1 -0
- package/dist/core/RelationshipManager.d.ts.map +1 -1
- package/dist/core/RelationshipManager.js +5 -0
- package/dist/core/RelationshipManager.js.map +1 -1
- package/dist/elements/Field.d.ts +5 -1
- package/dist/elements/Field.d.ts.map +1 -1
- package/dist/elements/Field.js +83 -7
- package/dist/elements/Field.js.map +1 -1
- package/dist/elements/Paragraph.d.ts +13 -0
- package/dist/elements/Paragraph.d.ts.map +1 -1
- package/dist/elements/Paragraph.js +100 -50
- package/dist/elements/Paragraph.js.map +1 -1
- package/dist/elements/PropertyChangeTypes.d.ts +1 -0
- package/dist/elements/PropertyChangeTypes.d.ts.map +1 -1
- package/dist/elements/PropertyChangeTypes.js.map +1 -1
- package/dist/elements/Revision.d.ts.map +1 -1
- package/dist/elements/Revision.js +4 -0
- package/dist/elements/Revision.js.map +1 -1
- package/dist/elements/Run.d.ts +49 -1
- package/dist/elements/Run.d.ts.map +1 -1
- package/dist/elements/Run.js +169 -62
- package/dist/elements/Run.js.map +1 -1
- package/dist/elements/Section.d.ts +20 -0
- package/dist/elements/Section.d.ts.map +1 -1
- package/dist/elements/Section.js +41 -0
- package/dist/elements/Section.js.map +1 -1
- package/dist/elements/Table.d.ts +3 -0
- package/dist/elements/Table.d.ts.map +1 -1
- package/dist/elements/Table.js +30 -0
- package/dist/elements/Table.js.map +1 -1
- package/dist/elements/TableCell.d.ts +3 -0
- package/dist/elements/TableCell.d.ts.map +1 -1
- package/dist/elements/TableCell.js +15 -0
- package/dist/elements/TableCell.js.map +1 -1
- package/dist/xml/XMLBuilder.d.ts +1 -1
- package/dist/xml/XMLBuilder.d.ts.map +1 -1
- package/dist/xml/XMLBuilder.js +7 -4
- package/dist/xml/XMLBuilder.js.map +1 -1
- package/package.json +1 -1
|
@@ -105,6 +105,7 @@ class DocumentParser {
|
|
|
105
105
|
instanceCount: numbering.numberingInstances.length
|
|
106
106
|
});
|
|
107
107
|
const section = this.parseSectionProperties(docXml);
|
|
108
|
+
const documentBackground = this.parseDocumentBackground(docXml);
|
|
108
109
|
const namespaces = this.parseNamespaces(docXml);
|
|
109
110
|
let paragraphCount = 0;
|
|
110
111
|
let tableCount = 0;
|
|
@@ -131,6 +132,7 @@ class DocumentParser {
|
|
|
131
132
|
numberingInstances: numbering.numberingInstances,
|
|
132
133
|
section,
|
|
133
134
|
namespaces,
|
|
135
|
+
documentBackground,
|
|
134
136
|
};
|
|
135
137
|
}
|
|
136
138
|
async parseBodyElements(docXml, relationshipManager, zipHandler, imageManager) {
|
|
@@ -179,19 +181,10 @@ class DocumentParser {
|
|
|
179
181
|
}
|
|
180
182
|
}
|
|
181
183
|
else if (prevElement instanceof Table_1.Table) {
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const lastCell = cells[cells.length - 1];
|
|
187
|
-
if (lastCell) {
|
|
188
|
-
const cellParas = lastCell.getParagraphs();
|
|
189
|
-
const lastPara = cellParas[cellParas.length - 1];
|
|
190
|
-
if (lastPara) {
|
|
191
|
-
for (const bookmark of bookmarkEnds) {
|
|
192
|
-
lastPara.addBookmarkEnd(bookmark);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
184
|
+
const lastPara = prevElement.getLastParagraph();
|
|
185
|
+
if (lastPara) {
|
|
186
|
+
for (const bookmark of bookmarkEnds) {
|
|
187
|
+
lastPara.addBookmarkEnd(bookmark);
|
|
195
188
|
}
|
|
196
189
|
}
|
|
197
190
|
}
|
|
@@ -303,19 +296,10 @@ class DocumentParser {
|
|
|
303
296
|
}
|
|
304
297
|
}
|
|
305
298
|
else if (currentElement instanceof Table_1.Table) {
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
const firstCell = cells[0];
|
|
311
|
-
if (firstCell) {
|
|
312
|
-
const cellParas = firstCell.getParagraphs();
|
|
313
|
-
const firstPara = cellParas[0];
|
|
314
|
-
if (firstPara) {
|
|
315
|
-
for (const bookmark of pendingBookmarkStarts) {
|
|
316
|
-
firstPara.addBookmarkStart(bookmark);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
299
|
+
const firstPara = currentElement.getFirstParagraph();
|
|
300
|
+
if (firstPara) {
|
|
301
|
+
for (const bookmark of pendingBookmarkStarts) {
|
|
302
|
+
firstPara.addBookmarkStart(bookmark);
|
|
319
303
|
}
|
|
320
304
|
}
|
|
321
305
|
}
|
|
@@ -333,19 +317,10 @@ class DocumentParser {
|
|
|
333
317
|
}
|
|
334
318
|
}
|
|
335
319
|
else if (lastElement instanceof Table_1.Table) {
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
const lastCell = cells[cells.length - 1];
|
|
341
|
-
if (lastCell) {
|
|
342
|
-
const cellParas = lastCell.getParagraphs();
|
|
343
|
-
const lastPara = cellParas[cellParas.length - 1];
|
|
344
|
-
if (lastPara) {
|
|
345
|
-
for (const bookmark of trailingBookmarkEnds) {
|
|
346
|
-
lastPara.addBookmarkEnd(bookmark);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
320
|
+
const lastPara = lastElement.getLastParagraph();
|
|
321
|
+
if (lastPara) {
|
|
322
|
+
for (const bookmark of trailingBookmarkEnds) {
|
|
323
|
+
lastPara.addBookmarkEnd(bookmark);
|
|
349
324
|
}
|
|
350
325
|
}
|
|
351
326
|
}
|
|
@@ -361,19 +336,10 @@ class DocumentParser {
|
|
|
361
336
|
}
|
|
362
337
|
}
|
|
363
338
|
else if (lastElement instanceof Table_1.Table) {
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
const lastCell = cells[cells.length - 1];
|
|
369
|
-
if (lastCell) {
|
|
370
|
-
const cellParas = lastCell.getParagraphs();
|
|
371
|
-
const lastPara = cellParas[cellParas.length - 1];
|
|
372
|
-
if (lastPara) {
|
|
373
|
-
for (const bookmark of trailingBookmarkStarts) {
|
|
374
|
-
lastPara.addBookmarkStart(bookmark);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
339
|
+
const lastPara = lastElement.getLastParagraph();
|
|
340
|
+
if (lastPara) {
|
|
341
|
+
for (const bookmark of trailingBookmarkStarts) {
|
|
342
|
+
lastPara.addBookmarkStart(bookmark);
|
|
377
343
|
}
|
|
378
344
|
}
|
|
379
345
|
}
|
|
@@ -1572,6 +1538,24 @@ class DocumentParser {
|
|
|
1572
1538
|
if (pPrObj["w:suppressAutoHyphens"]) {
|
|
1573
1539
|
paragraph.setSuppressAutoHyphens(true);
|
|
1574
1540
|
}
|
|
1541
|
+
if (pPrObj["w:kinsoku"]) {
|
|
1542
|
+
paragraph.setKinsoku((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj["w:kinsoku"]));
|
|
1543
|
+
}
|
|
1544
|
+
if (pPrObj["w:wordWrap"]) {
|
|
1545
|
+
paragraph.setWordWrap((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj["w:wordWrap"]));
|
|
1546
|
+
}
|
|
1547
|
+
if (pPrObj["w:overflowPunct"]) {
|
|
1548
|
+
paragraph.setOverflowPunct((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj["w:overflowPunct"]));
|
|
1549
|
+
}
|
|
1550
|
+
if (pPrObj["w:topLinePunct"]) {
|
|
1551
|
+
paragraph.setTopLinePunct((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj["w:topLinePunct"]));
|
|
1552
|
+
}
|
|
1553
|
+
if (pPrObj["w:autoSpaceDE"]) {
|
|
1554
|
+
paragraph.setAutoSpaceDE((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj["w:autoSpaceDE"]));
|
|
1555
|
+
}
|
|
1556
|
+
if (pPrObj["w:autoSpaceDN"]) {
|
|
1557
|
+
paragraph.setAutoSpaceDN((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj["w:autoSpaceDN"]));
|
|
1558
|
+
}
|
|
1575
1559
|
if (pPrObj["w:suppressOverlap"]) {
|
|
1576
1560
|
paragraph.setSuppressOverlap(true);
|
|
1577
1561
|
}
|
|
@@ -1700,6 +1684,9 @@ class DocumentParser {
|
|
|
1700
1684
|
if (prevPPr["w:textDirection"]?.["@_w:val"]) {
|
|
1701
1685
|
previousProperties.textDirection = String(prevPPr["w:textDirection"]["@_w:val"]);
|
|
1702
1686
|
}
|
|
1687
|
+
if (prevPPr["w:textAlignment"]?.["@_w:val"]) {
|
|
1688
|
+
previousProperties.textAlignment = String(prevPPr["w:textAlignment"]["@_w:val"]);
|
|
1689
|
+
}
|
|
1703
1690
|
if (prevPPr["w:pBdr"]) {
|
|
1704
1691
|
const pBdr = prevPPr["w:pBdr"];
|
|
1705
1692
|
previousProperties.borders = {};
|
|
@@ -2305,6 +2292,7 @@ class DocumentParser {
|
|
|
2305
2292
|
let hasBegin = false;
|
|
2306
2293
|
let hasEnd = false;
|
|
2307
2294
|
let hasSeparate = false;
|
|
2295
|
+
let formFieldData = undefined;
|
|
2308
2296
|
for (const run of fieldRuns) {
|
|
2309
2297
|
const runContent = run.getContent();
|
|
2310
2298
|
const fieldCharToken = runContent.find((c) => c.type === "fieldChar");
|
|
@@ -2313,6 +2301,9 @@ class DocumentParser {
|
|
|
2313
2301
|
case "begin":
|
|
2314
2302
|
hasBegin = true;
|
|
2315
2303
|
instructionFormatting = run.getFormatting();
|
|
2304
|
+
if (fieldCharToken.formFieldData) {
|
|
2305
|
+
formFieldData = fieldCharToken.formFieldData;
|
|
2306
|
+
}
|
|
2316
2307
|
break;
|
|
2317
2308
|
case "separate":
|
|
2318
2309
|
hasSeparate = true;
|
|
@@ -2371,6 +2362,7 @@ class DocumentParser {
|
|
|
2371
2362
|
resultFormatting,
|
|
2372
2363
|
multiParagraph: false,
|
|
2373
2364
|
hasResult: hasSeparate,
|
|
2365
|
+
formFieldData,
|
|
2374
2366
|
};
|
|
2375
2367
|
return new Field_1.ComplexField(properties);
|
|
2376
2368
|
}
|
|
@@ -2397,6 +2389,79 @@ class DocumentParser {
|
|
|
2397
2389
|
}
|
|
2398
2390
|
return (value === "1" || value === 1 || value === true || value === "true");
|
|
2399
2391
|
};
|
|
2392
|
+
const parseFormFieldData = (fldCharObj) => {
|
|
2393
|
+
const ffDataObj = fldCharObj["w:ffData"];
|
|
2394
|
+
if (!ffDataObj || typeof ffDataObj !== "object")
|
|
2395
|
+
return undefined;
|
|
2396
|
+
const ffd = {};
|
|
2397
|
+
if (ffDataObj["w:name"]?.["@_w:val"] !== undefined) {
|
|
2398
|
+
ffd.name = String(ffDataObj["w:name"]["@_w:val"]);
|
|
2399
|
+
}
|
|
2400
|
+
if (ffDataObj["w:enabled"] !== undefined) {
|
|
2401
|
+
const enabledVal = ffDataObj["w:enabled"]?.["@_w:val"];
|
|
2402
|
+
ffd.enabled = enabledVal === "0" || enabledVal === 0 ? false : true;
|
|
2403
|
+
}
|
|
2404
|
+
if (ffDataObj["w:calcOnExit"] !== undefined) {
|
|
2405
|
+
const calcVal = ffDataObj["w:calcOnExit"]?.["@_w:val"];
|
|
2406
|
+
ffd.calcOnExit = calcVal === "1" || calcVal === 1 || calcVal === true;
|
|
2407
|
+
}
|
|
2408
|
+
if (ffDataObj["w:helpText"]?.["@_w:val"] !== undefined) {
|
|
2409
|
+
ffd.helpText = String(ffDataObj["w:helpText"]["@_w:val"]);
|
|
2410
|
+
}
|
|
2411
|
+
if (ffDataObj["w:statusText"]?.["@_w:val"] !== undefined) {
|
|
2412
|
+
ffd.statusText = String(ffDataObj["w:statusText"]["@_w:val"]);
|
|
2413
|
+
}
|
|
2414
|
+
if (ffDataObj["w:entryMacro"]?.["@_w:val"] !== undefined) {
|
|
2415
|
+
ffd.entryMacro = String(ffDataObj["w:entryMacro"]["@_w:val"]);
|
|
2416
|
+
}
|
|
2417
|
+
if (ffDataObj["w:exitMacro"]?.["@_w:val"] !== undefined) {
|
|
2418
|
+
ffd.exitMacro = String(ffDataObj["w:exitMacro"]["@_w:val"]);
|
|
2419
|
+
}
|
|
2420
|
+
if (ffDataObj["w:textInput"] !== undefined) {
|
|
2421
|
+
const ti = ffDataObj["w:textInput"];
|
|
2422
|
+
const textInput = { type: 'textInput' };
|
|
2423
|
+
if (ti["w:type"]?.["@_w:val"] !== undefined)
|
|
2424
|
+
textInput.inputType = String(ti["w:type"]["@_w:val"]);
|
|
2425
|
+
if (ti["w:default"]?.["@_w:val"] !== undefined)
|
|
2426
|
+
textInput.defaultValue = String(ti["w:default"]["@_w:val"]);
|
|
2427
|
+
if (ti["w:maxLength"]?.["@_w:val"] !== undefined)
|
|
2428
|
+
textInput.maxLength = Number(ti["w:maxLength"]["@_w:val"]);
|
|
2429
|
+
if (ti["w:format"]?.["@_w:val"] !== undefined)
|
|
2430
|
+
textInput.format = String(ti["w:format"]["@_w:val"]);
|
|
2431
|
+
ffd.fieldType = textInput;
|
|
2432
|
+
}
|
|
2433
|
+
if (ffDataObj["w:checkBox"] !== undefined) {
|
|
2434
|
+
const cb = ffDataObj["w:checkBox"];
|
|
2435
|
+
const checkBox = { type: 'checkBox' };
|
|
2436
|
+
if (cb["w:default"]?.["@_w:val"] !== undefined) {
|
|
2437
|
+
checkBox.defaultChecked = cb["w:default"]["@_w:val"] === "1" || cb["w:default"]["@_w:val"] === 1;
|
|
2438
|
+
}
|
|
2439
|
+
if (cb["w:checked"]?.["@_w:val"] !== undefined) {
|
|
2440
|
+
checkBox.checked = cb["w:checked"]["@_w:val"] === "1" || cb["w:checked"]["@_w:val"] === 1;
|
|
2441
|
+
}
|
|
2442
|
+
if (cb["w:size"]?.["@_w:val"] !== undefined) {
|
|
2443
|
+
checkBox.size = Number(cb["w:size"]["@_w:val"]);
|
|
2444
|
+
}
|
|
2445
|
+
else if (cb["w:sizeAuto"] !== undefined) {
|
|
2446
|
+
checkBox.size = 'auto';
|
|
2447
|
+
}
|
|
2448
|
+
ffd.fieldType = checkBox;
|
|
2449
|
+
}
|
|
2450
|
+
if (ffDataObj["w:ddList"] !== undefined) {
|
|
2451
|
+
const dd = ffDataObj["w:ddList"];
|
|
2452
|
+
const ddList = { type: 'dropDownList' };
|
|
2453
|
+
if (dd["w:result"]?.["@_w:val"] !== undefined)
|
|
2454
|
+
ddList.result = Number(dd["w:result"]["@_w:val"]);
|
|
2455
|
+
if (dd["w:default"]?.["@_w:val"] !== undefined)
|
|
2456
|
+
ddList.defaultResult = Number(dd["w:default"]["@_w:val"]);
|
|
2457
|
+
if (dd["w:listEntry"] !== undefined) {
|
|
2458
|
+
const entries = Array.isArray(dd["w:listEntry"]) ? dd["w:listEntry"] : [dd["w:listEntry"]];
|
|
2459
|
+
ddList.listEntries = entries.map((e) => String(e?.["@_w:val"] ?? e ?? ""));
|
|
2460
|
+
}
|
|
2461
|
+
ffd.fieldType = ddList;
|
|
2462
|
+
}
|
|
2463
|
+
return Object.keys(ffd).length > 0 ? ffd : undefined;
|
|
2464
|
+
};
|
|
2400
2465
|
if (runObj["_orderedChildren"]) {
|
|
2401
2466
|
for (const child of runObj["_orderedChildren"]) {
|
|
2402
2467
|
const elementType = child.type;
|
|
@@ -2469,12 +2534,18 @@ class DocumentParser {
|
|
|
2469
2534
|
const charType = (fldChar["@_w:fldCharType"] ||
|
|
2470
2535
|
fldChar["@_fldCharType"]);
|
|
2471
2536
|
if (charType) {
|
|
2472
|
-
|
|
2537
|
+
const fldContent = {
|
|
2473
2538
|
type: "fieldChar",
|
|
2474
2539
|
fieldCharType: charType,
|
|
2475
2540
|
fieldCharDirty: parseBooleanAttr(fldChar["@_w:dirty"]),
|
|
2476
2541
|
fieldCharLocked: parseBooleanAttr(fldChar["@_w:fldLock"] ?? fldChar["@_w:lock"]),
|
|
2477
|
-
}
|
|
2542
|
+
};
|
|
2543
|
+
if (charType === "begin") {
|
|
2544
|
+
const ffData = parseFormFieldData(fldChar);
|
|
2545
|
+
if (ffData)
|
|
2546
|
+
fldContent.formFieldData = ffData;
|
|
2547
|
+
}
|
|
2548
|
+
content.push(fldContent);
|
|
2478
2549
|
}
|
|
2479
2550
|
}
|
|
2480
2551
|
break;
|
|
@@ -2513,6 +2584,26 @@ class DocumentParser {
|
|
|
2513
2584
|
case "w:annotationRef":
|
|
2514
2585
|
content.push({ type: "annotationRef" });
|
|
2515
2586
|
break;
|
|
2587
|
+
case "w:footnoteReference": {
|
|
2588
|
+
const fnRefElements = toArray(runObj["w:footnoteReference"]);
|
|
2589
|
+
const fnRef = fnRefElements[elementIndex] || fnRefElements[0];
|
|
2590
|
+
const fnId = fnRef?.["@_w:id"];
|
|
2591
|
+
content.push({
|
|
2592
|
+
type: "footnoteReference",
|
|
2593
|
+
footnoteId: fnId !== undefined ? parseInt(fnId, 10) : undefined,
|
|
2594
|
+
});
|
|
2595
|
+
break;
|
|
2596
|
+
}
|
|
2597
|
+
case "w:endnoteReference": {
|
|
2598
|
+
const enRefElements = toArray(runObj["w:endnoteReference"]);
|
|
2599
|
+
const enRef = enRefElements[elementIndex] || enRefElements[0];
|
|
2600
|
+
const enId = enRef?.["@_w:id"];
|
|
2601
|
+
content.push({
|
|
2602
|
+
type: "endnoteReference",
|
|
2603
|
+
endnoteId: enId !== undefined ? parseInt(enId, 10) : undefined,
|
|
2604
|
+
});
|
|
2605
|
+
break;
|
|
2606
|
+
}
|
|
2516
2607
|
case "w:dayShort":
|
|
2517
2608
|
content.push({ type: "dayShort" });
|
|
2518
2609
|
break;
|
|
@@ -2613,12 +2704,18 @@ class DocumentParser {
|
|
|
2613
2704
|
const charType = (fldChar["@_w:fldCharType"] ||
|
|
2614
2705
|
fldChar["@_fldCharType"]);
|
|
2615
2706
|
if (charType) {
|
|
2616
|
-
|
|
2707
|
+
const fldContent = {
|
|
2617
2708
|
type: "fieldChar",
|
|
2618
2709
|
fieldCharType: charType,
|
|
2619
2710
|
fieldCharDirty: parseBooleanAttr(fldChar["@_w:dirty"]),
|
|
2620
2711
|
fieldCharLocked: parseBooleanAttr(fldChar["@_w:fldLock"] ?? fldChar["@_w:lock"]),
|
|
2621
|
-
}
|
|
2712
|
+
};
|
|
2713
|
+
if (charType === "begin") {
|
|
2714
|
+
const ffData = parseFormFieldData(fldChar);
|
|
2715
|
+
if (ffData)
|
|
2716
|
+
fldContent.formFieldData = ffData;
|
|
2717
|
+
}
|
|
2718
|
+
content.push(fldContent);
|
|
2622
2719
|
}
|
|
2623
2720
|
}
|
|
2624
2721
|
}
|
|
@@ -2655,6 +2752,26 @@ class DocumentParser {
|
|
|
2655
2752
|
if (runObj["w:annotationRef"] !== undefined) {
|
|
2656
2753
|
content.push({ type: "annotationRef" });
|
|
2657
2754
|
}
|
|
2755
|
+
if (runObj["w:footnoteReference"] !== undefined) {
|
|
2756
|
+
const fnRefElements = toArray(runObj["w:footnoteReference"]);
|
|
2757
|
+
for (const fnRef of fnRefElements) {
|
|
2758
|
+
const fnId = fnRef?.["@_w:id"];
|
|
2759
|
+
content.push({
|
|
2760
|
+
type: "footnoteReference",
|
|
2761
|
+
footnoteId: fnId !== undefined ? parseInt(fnId, 10) : undefined,
|
|
2762
|
+
});
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2765
|
+
if (runObj["w:endnoteReference"] !== undefined) {
|
|
2766
|
+
const enRefElements = toArray(runObj["w:endnoteReference"]);
|
|
2767
|
+
for (const enRef of enRefElements) {
|
|
2768
|
+
const enId = enRef?.["@_w:id"];
|
|
2769
|
+
content.push({
|
|
2770
|
+
type: "endnoteReference",
|
|
2771
|
+
endnoteId: enId !== undefined ? parseInt(enId, 10) : undefined,
|
|
2772
|
+
});
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2658
2775
|
if (runObj["w:dayShort"] !== undefined) {
|
|
2659
2776
|
content.push({ type: "dayShort" });
|
|
2660
2777
|
}
|
|
@@ -3071,6 +3188,12 @@ class DocumentParser {
|
|
|
3071
3188
|
if (rPrObj["w:u"]) {
|
|
3072
3189
|
const uVal = rPrObj["w:u"]["@_w:val"];
|
|
3073
3190
|
run.setUnderline(uVal || true);
|
|
3191
|
+
const uColor = rPrObj["w:u"]["@_w:color"];
|
|
3192
|
+
if (uColor)
|
|
3193
|
+
run.setUnderlineColor(uColor);
|
|
3194
|
+
const uThemeColor = rPrObj["w:u"]["@_w:themeColor"];
|
|
3195
|
+
if (uThemeColor)
|
|
3196
|
+
run.setUnderlineThemeColor(uThemeColor, rPrObj["w:u"]["@_w:themeTint"] ? parseInt(rPrObj["w:u"]["@_w:themeTint"], 16) : undefined, rPrObj["w:u"]["@_w:themeShade"] ? parseInt(rPrObj["w:u"]["@_w:themeShade"], 16) : undefined);
|
|
3074
3197
|
}
|
|
3075
3198
|
if (rPrObj["w:spacing"]) {
|
|
3076
3199
|
const val = rPrObj["w:spacing"]["@_w:val"];
|
|
@@ -3143,6 +3266,14 @@ class DocumentParser {
|
|
|
3143
3266
|
run.setFontCs(rFonts["@_w:cs"]);
|
|
3144
3267
|
if (rFonts["@_w:hint"])
|
|
3145
3268
|
run.setFontHint(rFonts["@_w:hint"]);
|
|
3269
|
+
if (rFonts["@_w:asciiTheme"])
|
|
3270
|
+
run.setFontAsciiTheme(rFonts["@_w:asciiTheme"]);
|
|
3271
|
+
if (rFonts["@_w:hAnsiTheme"])
|
|
3272
|
+
run.setFontHAnsiTheme(rFonts["@_w:hAnsiTheme"]);
|
|
3273
|
+
if (rFonts["@_w:eastAsiaTheme"])
|
|
3274
|
+
run.setFontEastAsiaTheme(rFonts["@_w:eastAsiaTheme"]);
|
|
3275
|
+
if (rFonts["@_w:cstheme"])
|
|
3276
|
+
run.setFontCsTheme(rFonts["@_w:cstheme"]);
|
|
3146
3277
|
}
|
|
3147
3278
|
if (rPrObj["w:sz"]) {
|
|
3148
3279
|
run.setSize((0, units_1.halfPointsToPoints)(parseInt(rPrObj["w:sz"]["@_w:val"], 10)));
|
|
@@ -3173,6 +3304,14 @@ class DocumentParser {
|
|
|
3173
3304
|
if (rPrObj["w:highlight"]) {
|
|
3174
3305
|
run.setHighlight(rPrObj["w:highlight"]["@_w:val"]);
|
|
3175
3306
|
}
|
|
3307
|
+
for (const key of Object.keys(rPrObj)) {
|
|
3308
|
+
if (key.startsWith("w14:")) {
|
|
3309
|
+
const rawXml = this.objectToXml({ [key]: rPrObj[key] });
|
|
3310
|
+
if (rawXml) {
|
|
3311
|
+
run.addRawW14Property(rawXml);
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3176
3315
|
if (rPrObj["w:rPrChange"]) {
|
|
3177
3316
|
const changeObj = rPrObj["w:rPrChange"];
|
|
3178
3317
|
const propChange = {
|
|
@@ -3198,7 +3337,17 @@ class DocumentParser {
|
|
|
3198
3337
|
prevProps.strike = (0, parsingHelpers_1.parseOoxmlBoolean)(prevRPr["w:strike"]);
|
|
3199
3338
|
}
|
|
3200
3339
|
if (prevRPr["w:rFonts"]) {
|
|
3201
|
-
|
|
3340
|
+
const rFonts = prevRPr["w:rFonts"];
|
|
3341
|
+
if (rFonts["@_w:ascii"])
|
|
3342
|
+
prevProps.font = rFonts["@_w:ascii"];
|
|
3343
|
+
if (rFonts["@_w:hAnsi"])
|
|
3344
|
+
prevProps.fontHAnsi = rFonts["@_w:hAnsi"];
|
|
3345
|
+
if (rFonts["@_w:eastAsia"])
|
|
3346
|
+
prevProps.fontEastAsia = rFonts["@_w:eastAsia"];
|
|
3347
|
+
if (rFonts["@_w:cs"])
|
|
3348
|
+
prevProps.fontCs = rFonts["@_w:cs"];
|
|
3349
|
+
if (rFonts["@_w:hint"])
|
|
3350
|
+
prevProps.fontHint = rFonts["@_w:hint"];
|
|
3202
3351
|
}
|
|
3203
3352
|
if (prevRPr["w:sz"]) {
|
|
3204
3353
|
prevProps.size = (0, units_1.halfPointsToPoints)((0, parsingHelpers_1.safeParseInt)(prevRPr["w:sz"]["@_w:val"]));
|
|
@@ -3262,6 +3411,9 @@ class DocumentParser {
|
|
|
3262
3411
|
if (prevRPr["w:specVanish"]) {
|
|
3263
3412
|
prevProps.specVanish = (0, parsingHelpers_1.parseOoxmlBoolean)(prevRPr["w:specVanish"]);
|
|
3264
3413
|
}
|
|
3414
|
+
if (prevRPr["w:webHidden"]) {
|
|
3415
|
+
prevProps.webHidden = (0, parsingHelpers_1.parseOoxmlBoolean)(prevRPr["w:webHidden"]);
|
|
3416
|
+
}
|
|
3265
3417
|
if (prevRPr["w:rtl"]) {
|
|
3266
3418
|
prevProps.rtl = (0, parsingHelpers_1.parseOoxmlBoolean)(prevRPr["w:rtl"]);
|
|
3267
3419
|
}
|
|
@@ -3277,6 +3429,9 @@ class DocumentParser {
|
|
|
3277
3429
|
if (prevRPr["w:iCs"]) {
|
|
3278
3430
|
prevProps.complexScriptItalic = (0, parsingHelpers_1.parseOoxmlBoolean)(prevRPr["w:iCs"]);
|
|
3279
3431
|
}
|
|
3432
|
+
if (prevRPr["w:cs"]) {
|
|
3433
|
+
prevProps.complexScript = (0, parsingHelpers_1.parseOoxmlBoolean)(prevRPr["w:cs"]);
|
|
3434
|
+
}
|
|
3280
3435
|
if (prevRPr["w:spacing"]) {
|
|
3281
3436
|
const spacingVal = prevRPr["w:spacing"]["@_w:val"];
|
|
3282
3437
|
if (spacingVal !== undefined) {
|
|
@@ -3998,8 +4153,8 @@ class DocumentParser {
|
|
|
3998
4153
|
const cells = row.getCells();
|
|
3999
4154
|
const lastCell = cells[cells.length - 1];
|
|
4000
4155
|
if (lastCell) {
|
|
4001
|
-
const
|
|
4002
|
-
const lastPara =
|
|
4156
|
+
const paras = lastCell.getParagraphs();
|
|
4157
|
+
const lastPara = paras[paras.length - 1];
|
|
4003
4158
|
if (lastPara) {
|
|
4004
4159
|
for (const bookmark of bookmarkEnds) {
|
|
4005
4160
|
lastPara.addBookmarkEnd(bookmark);
|
|
@@ -4111,6 +4266,12 @@ class DocumentParser {
|
|
|
4111
4266
|
table.setCellSpacingType(spacingType);
|
|
4112
4267
|
}
|
|
4113
4268
|
}
|
|
4269
|
+
if (tblPrObj["w:tblLayout"]) {
|
|
4270
|
+
const layoutType = tblPrObj["w:tblLayout"]["@_w:type"];
|
|
4271
|
+
if (layoutType) {
|
|
4272
|
+
table.setLayout(layoutType);
|
|
4273
|
+
}
|
|
4274
|
+
}
|
|
4114
4275
|
if (tblPrObj["w:tblCellMar"]) {
|
|
4115
4276
|
const cellMar = tblPrObj["w:tblCellMar"];
|
|
4116
4277
|
const margins = {};
|
|
@@ -4465,6 +4626,15 @@ class DocumentParser {
|
|
|
4465
4626
|
cell.setVerticalMerge("continue");
|
|
4466
4627
|
}
|
|
4467
4628
|
}
|
|
4629
|
+
if (tcPr["w:hMerge"]) {
|
|
4630
|
+
const hMergeVal = tcPr["w:hMerge"]["@_w:val"];
|
|
4631
|
+
if (hMergeVal === "restart") {
|
|
4632
|
+
cell.setHorizontalMerge("restart");
|
|
4633
|
+
}
|
|
4634
|
+
else {
|
|
4635
|
+
cell.setHorizontalMerge("continue");
|
|
4636
|
+
}
|
|
4637
|
+
}
|
|
4468
4638
|
if (tcPr["w:cellIns"]) {
|
|
4469
4639
|
const cellIns = tcPr["w:cellIns"];
|
|
4470
4640
|
const id = parseInt(cellIns["@_w:id"] || "0", 10);
|
|
@@ -5432,6 +5602,64 @@ class DocumentParser {
|
|
|
5432
5602
|
}
|
|
5433
5603
|
}
|
|
5434
5604
|
}
|
|
5605
|
+
const pgBordersElements = XMLParser_1.XMLParser.extractElements(sectPr, "w:pgBorders");
|
|
5606
|
+
if (pgBordersElements.length > 0) {
|
|
5607
|
+
const pgBordersXml = pgBordersElements[0];
|
|
5608
|
+
if (pgBordersXml) {
|
|
5609
|
+
const pageBorders = {};
|
|
5610
|
+
const offsetFrom = XMLParser_1.XMLParser.extractAttribute(pgBordersXml, "w:offsetFrom");
|
|
5611
|
+
if (offsetFrom)
|
|
5612
|
+
pageBorders.offsetFrom = offsetFrom;
|
|
5613
|
+
const display = XMLParser_1.XMLParser.extractAttribute(pgBordersXml, "w:display");
|
|
5614
|
+
if (display)
|
|
5615
|
+
pageBorders.display = display;
|
|
5616
|
+
const zOrder = XMLParser_1.XMLParser.extractAttribute(pgBordersXml, "w:zOrder");
|
|
5617
|
+
if (zOrder)
|
|
5618
|
+
pageBorders.zOrder = zOrder;
|
|
5619
|
+
const parseBorder = (sideXml) => {
|
|
5620
|
+
if (!sideXml)
|
|
5621
|
+
return undefined;
|
|
5622
|
+
const border = {};
|
|
5623
|
+
const val = XMLParser_1.XMLParser.extractAttribute(sideXml, "w:val");
|
|
5624
|
+
if (val)
|
|
5625
|
+
border.style = val;
|
|
5626
|
+
const sz = XMLParser_1.XMLParser.extractAttribute(sideXml, "w:sz");
|
|
5627
|
+
if (sz)
|
|
5628
|
+
border.size = parseInt(sz.toString(), 10);
|
|
5629
|
+
const color = XMLParser_1.XMLParser.extractAttribute(sideXml, "w:color");
|
|
5630
|
+
if (color)
|
|
5631
|
+
border.color = color;
|
|
5632
|
+
const space = XMLParser_1.XMLParser.extractAttribute(sideXml, "w:space");
|
|
5633
|
+
if (space)
|
|
5634
|
+
border.space = parseInt(space.toString(), 10);
|
|
5635
|
+
const shadow = XMLParser_1.XMLParser.extractAttribute(sideXml, "w:shadow");
|
|
5636
|
+
if (shadow === "1" || shadow === "true")
|
|
5637
|
+
border.shadow = true;
|
|
5638
|
+
const frame = XMLParser_1.XMLParser.extractAttribute(sideXml, "w:frame");
|
|
5639
|
+
if (frame === "1" || frame === "true")
|
|
5640
|
+
border.frame = true;
|
|
5641
|
+
const themeColor = XMLParser_1.XMLParser.extractAttribute(sideXml, "w:themeColor");
|
|
5642
|
+
if (themeColor)
|
|
5643
|
+
border.themeColor = themeColor;
|
|
5644
|
+
const artId = XMLParser_1.XMLParser.extractAttribute(sideXml, "w:id");
|
|
5645
|
+
if (artId)
|
|
5646
|
+
border.artId = parseInt(artId.toString(), 10);
|
|
5647
|
+
return Object.keys(border).length > 0 ? border : undefined;
|
|
5648
|
+
};
|
|
5649
|
+
const sides = ["top", "left", "bottom", "right"];
|
|
5650
|
+
for (const side of sides) {
|
|
5651
|
+
const sideElements = XMLParser_1.XMLParser.extractElements(pgBordersXml, `w:${side}`);
|
|
5652
|
+
if (sideElements.length > 0 && sideElements[0]) {
|
|
5653
|
+
const border = parseBorder(sideElements[0]);
|
|
5654
|
+
if (border)
|
|
5655
|
+
pageBorders[side] = border;
|
|
5656
|
+
}
|
|
5657
|
+
}
|
|
5658
|
+
if (Object.keys(pageBorders).length > 0) {
|
|
5659
|
+
sectionProps.pageBorders = pageBorders;
|
|
5660
|
+
}
|
|
5661
|
+
}
|
|
5662
|
+
}
|
|
5435
5663
|
const colsElements = XMLParser_1.XMLParser.extractElements(sectPr, "w:cols");
|
|
5436
5664
|
if (colsElements.length > 0) {
|
|
5437
5665
|
const cols = colsElements[0];
|
|
@@ -6309,6 +6537,26 @@ class DocumentParser {
|
|
|
6309
6537
|
}
|
|
6310
6538
|
return namespaces;
|
|
6311
6539
|
}
|
|
6540
|
+
parseDocumentBackground(docXml) {
|
|
6541
|
+
const bgMatch = docXml.match(/<w:background([^>]*?)\/>/);
|
|
6542
|
+
if (!bgMatch || !bgMatch[1])
|
|
6543
|
+
return undefined;
|
|
6544
|
+
const attrStr = bgMatch[1];
|
|
6545
|
+
const result = {};
|
|
6546
|
+
const colorMatch = attrStr.match(/w:color="([^"]+)"/);
|
|
6547
|
+
if (colorMatch && colorMatch[1])
|
|
6548
|
+
result.color = colorMatch[1];
|
|
6549
|
+
const themeColorMatch = attrStr.match(/w:themeColor="([^"]+)"/);
|
|
6550
|
+
if (themeColorMatch && themeColorMatch[1])
|
|
6551
|
+
result.themeColor = themeColorMatch[1];
|
|
6552
|
+
const themeTintMatch = attrStr.match(/w:themeTint="([^"]+)"/);
|
|
6553
|
+
if (themeTintMatch && themeTintMatch[1])
|
|
6554
|
+
result.themeTint = themeTintMatch[1];
|
|
6555
|
+
const themeShadeMatch = attrStr.match(/w:themeShade="([^"]+)"/);
|
|
6556
|
+
if (themeShadeMatch && themeShadeMatch[1])
|
|
6557
|
+
result.themeShade = themeShadeMatch[1];
|
|
6558
|
+
return Object.keys(result).length > 0 ? result : undefined;
|
|
6559
|
+
}
|
|
6312
6560
|
async parseHeadersAndFooters(zipHandler, section, relationshipManager, imageManager) {
|
|
6313
6561
|
const headers = [];
|
|
6314
6562
|
const footers = [];
|