docxmlater 9.7.2 → 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.
Files changed (49) hide show
  1. package/dist/core/Document.d.ts +27 -0
  2. package/dist/core/Document.d.ts.map +1 -1
  3. package/dist/core/Document.js +113 -21
  4. package/dist/core/Document.js.map +1 -1
  5. package/dist/core/DocumentGenerator.d.ts +7 -1
  6. package/dist/core/DocumentGenerator.d.ts.map +1 -1
  7. package/dist/core/DocumentGenerator.js +25 -2
  8. package/dist/core/DocumentGenerator.js.map +1 -1
  9. package/dist/core/DocumentParser.d.ts +7 -0
  10. package/dist/core/DocumentParser.d.ts.map +1 -1
  11. package/dist/core/DocumentParser.js +287 -58
  12. package/dist/core/DocumentParser.js.map +1 -1
  13. package/dist/core/Relationship.d.ts +1 -0
  14. package/dist/core/Relationship.d.ts.map +1 -1
  15. package/dist/core/Relationship.js +8 -1
  16. package/dist/core/Relationship.js.map +1 -1
  17. package/dist/core/RelationshipManager.d.ts +1 -0
  18. package/dist/core/RelationshipManager.d.ts.map +1 -1
  19. package/dist/core/RelationshipManager.js +5 -0
  20. package/dist/core/RelationshipManager.js.map +1 -1
  21. package/dist/elements/Field.d.ts +5 -1
  22. package/dist/elements/Field.d.ts.map +1 -1
  23. package/dist/elements/Field.js +83 -7
  24. package/dist/elements/Field.js.map +1 -1
  25. package/dist/elements/Paragraph.d.ts +13 -0
  26. package/dist/elements/Paragraph.d.ts.map +1 -1
  27. package/dist/elements/Paragraph.js +50 -0
  28. package/dist/elements/Paragraph.js.map +1 -1
  29. package/dist/elements/Run.d.ts +49 -1
  30. package/dist/elements/Run.d.ts.map +1 -1
  31. package/dist/elements/Run.js +165 -6
  32. package/dist/elements/Run.js.map +1 -1
  33. package/dist/elements/Section.d.ts +20 -0
  34. package/dist/elements/Section.d.ts.map +1 -1
  35. package/dist/elements/Section.js +41 -0
  36. package/dist/elements/Section.js.map +1 -1
  37. package/dist/elements/Table.d.ts +3 -0
  38. package/dist/elements/Table.d.ts.map +1 -1
  39. package/dist/elements/Table.js +30 -0
  40. package/dist/elements/Table.js.map +1 -1
  41. package/dist/elements/TableCell.d.ts +3 -0
  42. package/dist/elements/TableCell.d.ts.map +1 -1
  43. package/dist/elements/TableCell.js +15 -0
  44. package/dist/elements/TableCell.js.map +1 -1
  45. package/dist/xml/XMLBuilder.d.ts +1 -1
  46. package/dist/xml/XMLBuilder.d.ts.map +1 -1
  47. package/dist/xml/XMLBuilder.js +7 -4
  48. package/dist/xml/XMLBuilder.js.map +1 -1
  49. 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 rows = prevElement.getRows();
183
- const lastRow = rows[rows.length - 1];
184
- if (lastRow) {
185
- const cells = lastRow.getCells();
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 rows = currentElement.getRows();
307
- const firstRow = rows[0];
308
- if (firstRow) {
309
- const cells = firstRow.getCells();
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 rows = lastElement.getRows();
337
- const lastRow = rows[rows.length - 1];
338
- if (lastRow) {
339
- const cells = lastRow.getCells();
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 rows = lastElement.getRows();
365
- const lastRow = rows[rows.length - 1];
366
- if (lastRow) {
367
- const cells = lastRow.getCells();
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
  }
@@ -2308,6 +2292,7 @@ class DocumentParser {
2308
2292
  let hasBegin = false;
2309
2293
  let hasEnd = false;
2310
2294
  let hasSeparate = false;
2295
+ let formFieldData = undefined;
2311
2296
  for (const run of fieldRuns) {
2312
2297
  const runContent = run.getContent();
2313
2298
  const fieldCharToken = runContent.find((c) => c.type === "fieldChar");
@@ -2316,6 +2301,9 @@ class DocumentParser {
2316
2301
  case "begin":
2317
2302
  hasBegin = true;
2318
2303
  instructionFormatting = run.getFormatting();
2304
+ if (fieldCharToken.formFieldData) {
2305
+ formFieldData = fieldCharToken.formFieldData;
2306
+ }
2319
2307
  break;
2320
2308
  case "separate":
2321
2309
  hasSeparate = true;
@@ -2374,6 +2362,7 @@ class DocumentParser {
2374
2362
  resultFormatting,
2375
2363
  multiParagraph: false,
2376
2364
  hasResult: hasSeparate,
2365
+ formFieldData,
2377
2366
  };
2378
2367
  return new Field_1.ComplexField(properties);
2379
2368
  }
@@ -2400,6 +2389,79 @@ class DocumentParser {
2400
2389
  }
2401
2390
  return (value === "1" || value === 1 || value === true || value === "true");
2402
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
+ };
2403
2465
  if (runObj["_orderedChildren"]) {
2404
2466
  for (const child of runObj["_orderedChildren"]) {
2405
2467
  const elementType = child.type;
@@ -2472,12 +2534,18 @@ class DocumentParser {
2472
2534
  const charType = (fldChar["@_w:fldCharType"] ||
2473
2535
  fldChar["@_fldCharType"]);
2474
2536
  if (charType) {
2475
- content.push({
2537
+ const fldContent = {
2476
2538
  type: "fieldChar",
2477
2539
  fieldCharType: charType,
2478
2540
  fieldCharDirty: parseBooleanAttr(fldChar["@_w:dirty"]),
2479
2541
  fieldCharLocked: parseBooleanAttr(fldChar["@_w:fldLock"] ?? fldChar["@_w:lock"]),
2480
- });
2542
+ };
2543
+ if (charType === "begin") {
2544
+ const ffData = parseFormFieldData(fldChar);
2545
+ if (ffData)
2546
+ fldContent.formFieldData = ffData;
2547
+ }
2548
+ content.push(fldContent);
2481
2549
  }
2482
2550
  }
2483
2551
  break;
@@ -2516,6 +2584,26 @@ class DocumentParser {
2516
2584
  case "w:annotationRef":
2517
2585
  content.push({ type: "annotationRef" });
2518
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
+ }
2519
2607
  case "w:dayShort":
2520
2608
  content.push({ type: "dayShort" });
2521
2609
  break;
@@ -2616,12 +2704,18 @@ class DocumentParser {
2616
2704
  const charType = (fldChar["@_w:fldCharType"] ||
2617
2705
  fldChar["@_fldCharType"]);
2618
2706
  if (charType) {
2619
- content.push({
2707
+ const fldContent = {
2620
2708
  type: "fieldChar",
2621
2709
  fieldCharType: charType,
2622
2710
  fieldCharDirty: parseBooleanAttr(fldChar["@_w:dirty"]),
2623
2711
  fieldCharLocked: parseBooleanAttr(fldChar["@_w:fldLock"] ?? fldChar["@_w:lock"]),
2624
- });
2712
+ };
2713
+ if (charType === "begin") {
2714
+ const ffData = parseFormFieldData(fldChar);
2715
+ if (ffData)
2716
+ fldContent.formFieldData = ffData;
2717
+ }
2718
+ content.push(fldContent);
2625
2719
  }
2626
2720
  }
2627
2721
  }
@@ -2658,6 +2752,26 @@ class DocumentParser {
2658
2752
  if (runObj["w:annotationRef"] !== undefined) {
2659
2753
  content.push({ type: "annotationRef" });
2660
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
+ }
2661
2775
  if (runObj["w:dayShort"] !== undefined) {
2662
2776
  content.push({ type: "dayShort" });
2663
2777
  }
@@ -3074,6 +3188,12 @@ class DocumentParser {
3074
3188
  if (rPrObj["w:u"]) {
3075
3189
  const uVal = rPrObj["w:u"]["@_w:val"];
3076
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);
3077
3197
  }
3078
3198
  if (rPrObj["w:spacing"]) {
3079
3199
  const val = rPrObj["w:spacing"]["@_w:val"];
@@ -3146,6 +3266,14 @@ class DocumentParser {
3146
3266
  run.setFontCs(rFonts["@_w:cs"]);
3147
3267
  if (rFonts["@_w:hint"])
3148
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"]);
3149
3277
  }
3150
3278
  if (rPrObj["w:sz"]) {
3151
3279
  run.setSize((0, units_1.halfPointsToPoints)(parseInt(rPrObj["w:sz"]["@_w:val"], 10)));
@@ -3176,6 +3304,14 @@ class DocumentParser {
3176
3304
  if (rPrObj["w:highlight"]) {
3177
3305
  run.setHighlight(rPrObj["w:highlight"]["@_w:val"]);
3178
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
+ }
3179
3315
  if (rPrObj["w:rPrChange"]) {
3180
3316
  const changeObj = rPrObj["w:rPrChange"];
3181
3317
  const propChange = {
@@ -4017,8 +4153,8 @@ class DocumentParser {
4017
4153
  const cells = row.getCells();
4018
4154
  const lastCell = cells[cells.length - 1];
4019
4155
  if (lastCell) {
4020
- const cellParas = lastCell.getParagraphs();
4021
- const lastPara = cellParas[cellParas.length - 1];
4156
+ const paras = lastCell.getParagraphs();
4157
+ const lastPara = paras[paras.length - 1];
4022
4158
  if (lastPara) {
4023
4159
  for (const bookmark of bookmarkEnds) {
4024
4160
  lastPara.addBookmarkEnd(bookmark);
@@ -4130,6 +4266,12 @@ class DocumentParser {
4130
4266
  table.setCellSpacingType(spacingType);
4131
4267
  }
4132
4268
  }
4269
+ if (tblPrObj["w:tblLayout"]) {
4270
+ const layoutType = tblPrObj["w:tblLayout"]["@_w:type"];
4271
+ if (layoutType) {
4272
+ table.setLayout(layoutType);
4273
+ }
4274
+ }
4133
4275
  if (tblPrObj["w:tblCellMar"]) {
4134
4276
  const cellMar = tblPrObj["w:tblCellMar"];
4135
4277
  const margins = {};
@@ -4484,6 +4626,15 @@ class DocumentParser {
4484
4626
  cell.setVerticalMerge("continue");
4485
4627
  }
4486
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
+ }
4487
4638
  if (tcPr["w:cellIns"]) {
4488
4639
  const cellIns = tcPr["w:cellIns"];
4489
4640
  const id = parseInt(cellIns["@_w:id"] || "0", 10);
@@ -5451,6 +5602,64 @@ class DocumentParser {
5451
5602
  }
5452
5603
  }
5453
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
+ }
5454
5663
  const colsElements = XMLParser_1.XMLParser.extractElements(sectPr, "w:cols");
5455
5664
  if (colsElements.length > 0) {
5456
5665
  const cols = colsElements[0];
@@ -6328,6 +6537,26 @@ class DocumentParser {
6328
6537
  }
6329
6538
  return namespaces;
6330
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
+ }
6331
6560
  async parseHeadersAndFooters(zipHandler, section, relationshipManager, imageManager) {
6332
6561
  const headers = [];
6333
6562
  const footers = [];