docxmlater 10.3.6 → 10.4.0
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/README.md +158 -7
- package/dist/core/Document.d.ts +97 -3
- package/dist/core/Document.d.ts.map +1 -1
- package/dist/core/Document.js +727 -50
- package/dist/core/Document.js.map +1 -1
- package/dist/core/DocumentContent.d.ts.map +1 -1
- package/dist/core/DocumentContent.js +0 -8
- package/dist/core/DocumentContent.js.map +1 -1
- package/dist/core/DocumentGenerator.d.ts.map +1 -1
- package/dist/core/DocumentGenerator.js +9 -5
- package/dist/core/DocumentGenerator.js.map +1 -1
- package/dist/core/DocumentParser.d.ts.map +1 -1
- package/dist/core/DocumentParser.js +573 -101
- package/dist/core/DocumentParser.js.map +1 -1
- package/dist/core/RelationshipManager.d.ts.map +1 -1
- package/dist/core/RelationshipManager.js +4 -3
- package/dist/core/RelationshipManager.js.map +1 -1
- package/dist/elements/Bookmark.d.ts +7 -0
- package/dist/elements/Bookmark.d.ts.map +1 -1
- package/dist/elements/Bookmark.js +24 -4
- package/dist/elements/Bookmark.js.map +1 -1
- package/dist/elements/BookmarkManager.d.ts.map +1 -1
- package/dist/elements/BookmarkManager.js +4 -3
- package/dist/elements/BookmarkManager.js.map +1 -1
- package/dist/elements/CommonTypes.d.ts +2 -2
- package/dist/elements/CommonTypes.d.ts.map +1 -1
- package/dist/elements/CommonTypes.js +14 -1
- package/dist/elements/CommonTypes.js.map +1 -1
- package/dist/elements/Field.d.ts +1 -1
- package/dist/elements/Field.d.ts.map +1 -1
- package/dist/elements/Field.js +1 -1
- package/dist/elements/Field.js.map +1 -1
- package/dist/elements/Footer.d.ts +2 -0
- package/dist/elements/Footer.d.ts.map +1 -1
- package/dist/elements/Footer.js +6 -0
- package/dist/elements/Footer.js.map +1 -1
- package/dist/elements/Header.d.ts +2 -0
- package/dist/elements/Header.d.ts.map +1 -1
- package/dist/elements/Header.js +6 -0
- package/dist/elements/Header.js.map +1 -1
- package/dist/elements/Image.d.ts.map +1 -1
- package/dist/elements/Image.js +3 -0
- package/dist/elements/Image.js.map +1 -1
- package/dist/elements/Paragraph.d.ts +81 -1
- package/dist/elements/Paragraph.d.ts.map +1 -1
- package/dist/elements/Paragraph.js +515 -21
- package/dist/elements/Paragraph.js.map +1 -1
- package/dist/elements/Revision.d.ts +0 -1
- package/dist/elements/Revision.d.ts.map +1 -1
- package/dist/elements/Revision.js +0 -12
- package/dist/elements/Revision.js.map +1 -1
- package/dist/elements/RevisionManager.d.ts +0 -1
- package/dist/elements/RevisionManager.d.ts.map +1 -1
- package/dist/elements/RevisionManager.js +0 -2
- package/dist/elements/RevisionManager.js.map +1 -1
- package/dist/elements/Run.d.ts +16 -4
- package/dist/elements/Run.d.ts.map +1 -1
- package/dist/elements/Run.js +114 -22
- package/dist/elements/Run.js.map +1 -1
- package/dist/elements/Section.d.ts +7 -1
- package/dist/elements/Section.d.ts.map +1 -1
- package/dist/elements/Section.js +185 -4
- package/dist/elements/Section.js.map +1 -1
- package/dist/elements/Shape.js.map +1 -1
- package/dist/elements/Table.d.ts +30 -1
- package/dist/elements/Table.d.ts.map +1 -1
- package/dist/elements/Table.js +357 -40
- 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 +30 -3
- package/dist/elements/TableCell.js.map +1 -1
- package/dist/elements/TableGridChange.d.ts +0 -1
- package/dist/elements/TableGridChange.d.ts.map +1 -1
- package/dist/elements/TableGridChange.js +0 -10
- package/dist/elements/TableGridChange.js.map +1 -1
- package/dist/elements/TableRow.d.ts +4 -0
- package/dist/elements/TableRow.d.ts.map +1 -1
- package/dist/elements/TableRow.js +31 -3
- package/dist/elements/TableRow.js.map +1 -1
- package/dist/formatting/AbstractNumbering.d.ts +5 -0
- package/dist/formatting/AbstractNumbering.d.ts.map +1 -1
- package/dist/formatting/AbstractNumbering.js +22 -0
- package/dist/formatting/AbstractNumbering.js.map +1 -1
- package/dist/formatting/NumberingLevel.d.ts.map +1 -1
- package/dist/formatting/NumberingLevel.js +3 -3
- package/dist/formatting/NumberingLevel.js.map +1 -1
- package/dist/formatting/Style.d.ts +1 -0
- package/dist/formatting/Style.d.ts.map +1 -1
- package/dist/formatting/Style.js +25 -59
- package/dist/formatting/Style.js.map +1 -1
- package/dist/formatting/StylesManager.d.ts +1 -0
- package/dist/formatting/StylesManager.d.ts.map +1 -1
- package/dist/formatting/StylesManager.js +12 -0
- package/dist/formatting/StylesManager.js.map +1 -1
- package/dist/helpers/CleanupHelper.js.map +1 -1
- package/dist/images/ImageOptimizer.d.ts.map +1 -1
- package/dist/images/ImageOptimizer.js +0 -1
- package/dist/images/ImageOptimizer.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/managers/DrawingManager.d.ts.map +1 -1
- package/dist/managers/DrawingManager.js +4 -2
- package/dist/managers/DrawingManager.js.map +1 -1
- package/dist/types/formatting.d.ts +2 -2
- package/dist/types/formatting.d.ts.map +1 -1
- package/dist/types/formatting.js.map +1 -1
- package/dist/utils/ChangelogGenerator.d.ts +2 -2
- package/dist/utils/ChangelogGenerator.d.ts.map +1 -1
- package/dist/utils/ChangelogGenerator.js +4 -5
- package/dist/utils/ChangelogGenerator.js.map +1 -1
- package/dist/utils/InMemoryRevisionAcceptor.d.ts.map +1 -1
- package/dist/utils/InMemoryRevisionAcceptor.js +0 -1
- package/dist/utils/InMemoryRevisionAcceptor.js.map +1 -1
- package/dist/utils/RevisionAwareProcessor.d.ts +2 -2
- package/dist/utils/RevisionAwareProcessor.d.ts.map +1 -1
- package/dist/utils/RevisionAwareProcessor.js +2 -2
- package/dist/utils/RevisionAwareProcessor.js.map +1 -1
- package/dist/utils/SelectiveRevisionAcceptor.d.ts +0 -2
- package/dist/utils/SelectiveRevisionAcceptor.d.ts.map +1 -1
- package/dist/utils/SelectiveRevisionAcceptor.js +0 -26
- package/dist/utils/SelectiveRevisionAcceptor.js.map +1 -1
- package/dist/utils/ShadingResolver.d.ts.map +1 -1
- package/dist/utils/ShadingResolver.js.map +1 -1
- package/dist/utils/acceptRevisions.js +1 -1
- package/dist/utils/acceptRevisions.js.map +1 -1
- package/dist/utils/stripTrackedChanges.js +1 -1
- package/dist/utils/stripTrackedChanges.js.map +1 -1
- package/dist/utils/units.d.ts.map +1 -1
- package/dist/utils/units.js +1 -1
- package/dist/utils/units.js.map +1 -1
- package/dist/validation/RevisionAutoFixer.d.ts +2 -1
- package/dist/validation/RevisionAutoFixer.d.ts.map +1 -1
- package/dist/validation/RevisionAutoFixer.js.map +1 -1
- package/package.json +10 -1
- package/src/constants/CLAUDE.md +28 -0
- package/src/core/CLAUDE.md +4 -0
- package/src/core/Document.ts +1755 -85
- package/src/core/DocumentContent.ts +0 -11
- package/src/core/DocumentGenerator.ts +11 -12
- package/src/core/DocumentParser.ts +599 -138
- package/src/core/RelationshipManager.ts +6 -3
- package/src/elements/Bookmark.ts +39 -4
- package/src/elements/BookmarkManager.ts +4 -3
- package/src/elements/CLAUDE.md +18 -2
- package/src/elements/CommonTypes.ts +35 -8
- package/src/elements/Field.ts +1 -1
- package/src/elements/Footer.ts +23 -0
- package/src/elements/Header.ts +25 -0
- package/src/elements/Image.ts +5 -0
- package/src/elements/Paragraph.ts +1069 -41
- package/src/elements/Revision.ts +0 -19
- package/src/elements/RevisionManager.ts +1 -3
- package/src/elements/Run.ts +265 -35
- package/src/elements/Section.ts +214 -8
- package/src/elements/Shape.ts +1 -1
- package/src/elements/Table.ts +850 -61
- package/src/elements/TableCell.ts +84 -10
- package/src/elements/TableGridChange.ts +2 -16
- package/src/elements/TableRow.ts +94 -9
- package/src/formatting/AbstractNumbering.ts +42 -1
- package/src/formatting/CLAUDE.md +4 -0
- package/src/formatting/NumberingLevel.ts +11 -7
- package/src/formatting/Style.ts +39 -71
- package/src/formatting/StylesManager.ts +36 -0
- package/src/helpers/CleanupHelper.ts +1 -1
- package/src/images/ImageOptimizer.ts +0 -3
- package/src/index.ts +1 -1
- package/src/managers/DrawingManager.ts +5 -3
- package/src/tracking/CLAUDE.md +30 -0
- package/src/types/CLAUDE.md +39 -0
- package/src/types/formatting.ts +2 -2
- package/src/utils/CLAUDE.md +15 -0
- package/src/utils/ChangelogGenerator.ts +4 -5
- package/src/utils/InMemoryRevisionAcceptor.ts +0 -9
- package/src/utils/RevisionAwareProcessor.ts +2 -3
- package/src/utils/SelectiveRevisionAcceptor.ts +0 -39
- package/src/utils/ShadingResolver.ts +0 -1
- package/src/utils/acceptRevisions.ts +1 -1
- package/src/utils/stripTrackedChanges.ts +1 -1
- package/src/utils/units.ts +2 -1
- package/src/validation/CLAUDE.md +40 -0
- package/src/validation/RevisionAutoFixer.ts +2 -1
|
@@ -57,6 +57,7 @@ const Table_1 = require("../elements/Table");
|
|
|
57
57
|
const TableCell_1 = require("../elements/TableCell");
|
|
58
58
|
const TableOfContents_1 = require("../elements/TableOfContents");
|
|
59
59
|
const TableOfContentsElement_1 = require("../elements/TableOfContentsElement");
|
|
60
|
+
const TableGridChange_1 = require("../elements/TableGridChange");
|
|
60
61
|
const TableRow_1 = require("../elements/TableRow");
|
|
61
62
|
const AbstractNumbering_1 = require("../formatting/AbstractNumbering");
|
|
62
63
|
const NumberingInstance_1 = require("../formatting/NumberingInstance");
|
|
@@ -587,6 +588,10 @@ class DocumentParser {
|
|
|
587
588
|
if (paraId) {
|
|
588
589
|
paragraph.formatting.paraId = paraId;
|
|
589
590
|
}
|
|
591
|
+
const textId = pElement['w14:textId'];
|
|
592
|
+
if (textId) {
|
|
593
|
+
paragraph.formatting.textId = textId;
|
|
594
|
+
}
|
|
590
595
|
await this.parseOrderedParagraphChildren(paraXml, pElement, paragraph, relationshipManager, zipHandler, imageManager);
|
|
591
596
|
const runs = paragraph.getRuns();
|
|
592
597
|
const runData = runs.map((run) => ({
|
|
@@ -1286,10 +1291,14 @@ class DocumentParser {
|
|
|
1286
1291
|
return null;
|
|
1287
1292
|
}
|
|
1288
1293
|
const id = parseInt(idAttr, 10);
|
|
1294
|
+
const colFirstAttr = XMLParser_1.XMLParser.extractAttribute(bookmarkXml, 'w:colFirst');
|
|
1295
|
+
const colLastAttr = XMLParser_1.XMLParser.extractAttribute(bookmarkXml, 'w:colLast');
|
|
1289
1296
|
const bookmark = new Bookmark_1.Bookmark({
|
|
1290
1297
|
name: nameAttr,
|
|
1291
1298
|
id: id,
|
|
1292
1299
|
skipNormalization: true,
|
|
1300
|
+
colFirst: colFirstAttr ? parseInt(colFirstAttr, 10) : undefined,
|
|
1301
|
+
colLast: colLastAttr ? parseInt(colLastAttr, 10) : undefined,
|
|
1293
1302
|
});
|
|
1294
1303
|
if (this.bookmarkManager) {
|
|
1295
1304
|
try {
|
|
@@ -1335,6 +1344,10 @@ class DocumentParser {
|
|
|
1335
1344
|
if (paraId) {
|
|
1336
1345
|
paragraph.formatting.paraId = paraId;
|
|
1337
1346
|
}
|
|
1347
|
+
const textId = paraObj['w14:textId'];
|
|
1348
|
+
if (textId) {
|
|
1349
|
+
paragraph.formatting.textId = textId;
|
|
1350
|
+
}
|
|
1338
1351
|
this.parseParagraphPropertiesFromObject(paraObj['w:pPr'], paragraph);
|
|
1339
1352
|
const orderedChildren = paraObj._orderedChildren;
|
|
1340
1353
|
if (orderedChildren && orderedChildren.length > 0) {
|
|
@@ -1493,10 +1506,12 @@ class DocumentParser {
|
|
|
1493
1506
|
}
|
|
1494
1507
|
if (pPrObj['w:ind']) {
|
|
1495
1508
|
const ind = pPrObj['w:ind'];
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
if ((0, parsingHelpers_1.isExplicitlySet)(
|
|
1499
|
-
paragraph.
|
|
1509
|
+
const leftVal = ind['@_w:start'] ?? ind['@_w:left'];
|
|
1510
|
+
const rightVal = ind['@_w:end'] ?? ind['@_w:right'];
|
|
1511
|
+
if ((0, parsingHelpers_1.isExplicitlySet)(leftVal))
|
|
1512
|
+
paragraph.setLeftIndent((0, parsingHelpers_1.safeParseInt)(leftVal));
|
|
1513
|
+
if ((0, parsingHelpers_1.isExplicitlySet)(rightVal))
|
|
1514
|
+
paragraph.setRightIndent((0, parsingHelpers_1.safeParseInt)(rightVal));
|
|
1500
1515
|
if ((0, parsingHelpers_1.isExplicitlySet)(ind['@_w:firstLine']))
|
|
1501
1516
|
paragraph.setFirstLineIndent((0, parsingHelpers_1.safeParseInt)(ind['@_w:firstLine']));
|
|
1502
1517
|
if ((0, parsingHelpers_1.isExplicitlySet)(ind['@_w:hanging']))
|
|
@@ -1511,15 +1526,33 @@ class DocumentParser {
|
|
|
1511
1526
|
if ((0, parsingHelpers_1.isExplicitlySet)(spacing['@_w:line'])) {
|
|
1512
1527
|
paragraph.setLineSpacing((0, parsingHelpers_1.safeParseInt)(spacing['@_w:line']), spacing['@_w:lineRule']);
|
|
1513
1528
|
}
|
|
1529
|
+
if (!paragraph.formatting.spacing)
|
|
1530
|
+
paragraph.formatting.spacing = {};
|
|
1531
|
+
if ((0, parsingHelpers_1.isExplicitlySet)(spacing['@_w:beforeLines']))
|
|
1532
|
+
paragraph.formatting.spacing.beforeLines = (0, parsingHelpers_1.safeParseInt)(spacing['@_w:beforeLines']);
|
|
1533
|
+
if ((0, parsingHelpers_1.isExplicitlySet)(spacing['@_w:afterLines']))
|
|
1534
|
+
paragraph.formatting.spacing.afterLines = (0, parsingHelpers_1.safeParseInt)(spacing['@_w:afterLines']);
|
|
1535
|
+
const beforeAuto = spacing['@_w:beforeAutospacing'];
|
|
1536
|
+
if (beforeAuto !== undefined)
|
|
1537
|
+
paragraph.formatting.spacing.beforeAutospacing =
|
|
1538
|
+
String(beforeAuto) === '1' || String(beforeAuto) === 'true';
|
|
1539
|
+
const afterAuto = spacing['@_w:afterAutospacing'];
|
|
1540
|
+
if (afterAuto !== undefined)
|
|
1541
|
+
paragraph.formatting.spacing.afterAutospacing =
|
|
1542
|
+
String(afterAuto) === '1' || String(afterAuto) === 'true';
|
|
1543
|
+
}
|
|
1544
|
+
if (pPrObj['w:pageBreakBefore'] !== undefined) {
|
|
1545
|
+
paragraph.formatting.pageBreakBefore = (0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj['w:pageBreakBefore']);
|
|
1546
|
+
}
|
|
1547
|
+
if (pPrObj['w:keepNext'] !== undefined) {
|
|
1548
|
+
paragraph.setKeepNext((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj['w:keepNext']));
|
|
1549
|
+
}
|
|
1550
|
+
if (pPrObj['w:keepLines'] !== undefined) {
|
|
1551
|
+
paragraph.setKeepLines((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj['w:keepLines']));
|
|
1552
|
+
}
|
|
1553
|
+
if (pPrObj['w:contextualSpacing'] !== undefined) {
|
|
1554
|
+
paragraph.setContextualSpacing((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj['w:contextualSpacing']));
|
|
1514
1555
|
}
|
|
1515
|
-
if (pPrObj['w:pageBreakBefore'])
|
|
1516
|
-
paragraph.formatting.pageBreakBefore = true;
|
|
1517
|
-
if (pPrObj['w:keepNext'])
|
|
1518
|
-
paragraph.setKeepNext(true);
|
|
1519
|
-
if (pPrObj['w:keepLines'])
|
|
1520
|
-
paragraph.setKeepLines(true);
|
|
1521
|
-
if (pPrObj['w:contextualSpacing'])
|
|
1522
|
-
paragraph.setContextualSpacing(true);
|
|
1523
1556
|
if (pPrObj['w:numPr']) {
|
|
1524
1557
|
const numPrRaw = pPrObj['w:numPr'];
|
|
1525
1558
|
const numPr = Array.isArray(numPrRaw) ? numPrRaw[0] : numPrRaw;
|
|
@@ -1619,8 +1652,8 @@ class DocumentParser {
|
|
|
1619
1652
|
paragraph.setOutlineLevel(level);
|
|
1620
1653
|
}
|
|
1621
1654
|
}
|
|
1622
|
-
if (pPrObj['w:suppressLineNumbers']) {
|
|
1623
|
-
paragraph.setSuppressLineNumbers(
|
|
1655
|
+
if (pPrObj['w:suppressLineNumbers'] !== undefined) {
|
|
1656
|
+
paragraph.setSuppressLineNumbers((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj['w:suppressLineNumbers']));
|
|
1624
1657
|
}
|
|
1625
1658
|
if (pPrObj['w:bidi'] !== undefined) {
|
|
1626
1659
|
const bidiVal = pPrObj['w:bidi']?.['@_w:val'];
|
|
@@ -1637,8 +1670,8 @@ class DocumentParser {
|
|
|
1637
1670
|
if (pPrObj['w:textAlignment']?.['@_w:val']) {
|
|
1638
1671
|
paragraph.setTextAlignment(pPrObj['w:textAlignment']['@_w:val']);
|
|
1639
1672
|
}
|
|
1640
|
-
if (pPrObj['w:mirrorIndents']) {
|
|
1641
|
-
paragraph.setMirrorIndents(
|
|
1673
|
+
if (pPrObj['w:mirrorIndents'] !== undefined) {
|
|
1674
|
+
paragraph.setMirrorIndents((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj['w:mirrorIndents']));
|
|
1642
1675
|
}
|
|
1643
1676
|
if (pPrObj['w:adjustRightInd'] !== undefined) {
|
|
1644
1677
|
const adjustRightIndVal = pPrObj['w:adjustRightInd']?.['@_w:val'];
|
|
@@ -1692,8 +1725,8 @@ class DocumentParser {
|
|
|
1692
1725
|
paragraph.setFrameProperties(frameProps);
|
|
1693
1726
|
}
|
|
1694
1727
|
}
|
|
1695
|
-
if (pPrObj['w:suppressAutoHyphens']) {
|
|
1696
|
-
paragraph.setSuppressAutoHyphens(
|
|
1728
|
+
if (pPrObj['w:suppressAutoHyphens'] !== undefined) {
|
|
1729
|
+
paragraph.setSuppressAutoHyphens((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj['w:suppressAutoHyphens']));
|
|
1697
1730
|
}
|
|
1698
1731
|
if (pPrObj['w:kinsoku']) {
|
|
1699
1732
|
paragraph.setKinsoku((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj['w:kinsoku']));
|
|
@@ -1713,8 +1746,8 @@ class DocumentParser {
|
|
|
1713
1746
|
if (pPrObj['w:autoSpaceDN']) {
|
|
1714
1747
|
paragraph.setAutoSpaceDN((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj['w:autoSpaceDN']));
|
|
1715
1748
|
}
|
|
1716
|
-
if (pPrObj['w:suppressOverlap']) {
|
|
1717
|
-
paragraph.setSuppressOverlap(
|
|
1749
|
+
if (pPrObj['w:suppressOverlap'] !== undefined) {
|
|
1750
|
+
paragraph.setSuppressOverlap((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj['w:suppressOverlap']));
|
|
1718
1751
|
}
|
|
1719
1752
|
if (pPrObj['w:textboxTightWrap']) {
|
|
1720
1753
|
const wrapVal = pPrObj['w:textboxTightWrap']?.['@_w:val'];
|
|
@@ -1769,10 +1802,12 @@ class DocumentParser {
|
|
|
1769
1802
|
if (prevPPr['w:ind']) {
|
|
1770
1803
|
const ind = prevPPr['w:ind'];
|
|
1771
1804
|
previousProperties.indentation = {};
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
if (
|
|
1775
|
-
previousProperties.indentation.
|
|
1805
|
+
const leftVal = ind['@_w:start'] ?? ind['@_w:left'];
|
|
1806
|
+
const rightVal = ind['@_w:end'] ?? ind['@_w:right'];
|
|
1807
|
+
if (leftVal !== undefined)
|
|
1808
|
+
previousProperties.indentation.left = parseInt(leftVal, 10);
|
|
1809
|
+
if (rightVal !== undefined)
|
|
1810
|
+
previousProperties.indentation.right = parseInt(rightVal, 10);
|
|
1776
1811
|
if (ind['@_w:firstLine'] !== undefined)
|
|
1777
1812
|
previousProperties.indentation.firstLine = parseInt(ind['@_w:firstLine'], 10);
|
|
1778
1813
|
if (ind['@_w:hanging'] !== undefined)
|
|
@@ -1792,6 +1827,18 @@ class DocumentParser {
|
|
|
1792
1827
|
previousProperties.spacing.line = parseInt(spacing['@_w:line'], 10);
|
|
1793
1828
|
if (spacing['@_w:lineRule'])
|
|
1794
1829
|
previousProperties.spacing.lineRule = String(spacing['@_w:lineRule']);
|
|
1830
|
+
if (spacing['@_w:beforeLines'] !== undefined)
|
|
1831
|
+
previousProperties.spacing.beforeLines = parseInt(spacing['@_w:beforeLines'], 10);
|
|
1832
|
+
if (spacing['@_w:afterLines'] !== undefined)
|
|
1833
|
+
previousProperties.spacing.afterLines = parseInt(spacing['@_w:afterLines'], 10);
|
|
1834
|
+
const beforeAuto = spacing['@_w:beforeAutospacing'];
|
|
1835
|
+
if (beforeAuto !== undefined)
|
|
1836
|
+
previousProperties.spacing.beforeAutospacing =
|
|
1837
|
+
String(beforeAuto) === '1' || String(beforeAuto) === 'true';
|
|
1838
|
+
const afterAuto = spacing['@_w:afterAutospacing'];
|
|
1839
|
+
if (afterAuto !== undefined)
|
|
1840
|
+
previousProperties.spacing.afterAutospacing =
|
|
1841
|
+
String(afterAuto) === '1' || String(afterAuto) === 'true';
|
|
1795
1842
|
}
|
|
1796
1843
|
if (prevPPr['w:keepNext']) {
|
|
1797
1844
|
previousProperties.keepNext = prevPPr['w:keepNext']['@_w:val'] !== '0';
|
|
@@ -2876,7 +2923,8 @@ class DocumentParser {
|
|
|
2876
2923
|
const brElements = toArray(runObj['w:br']);
|
|
2877
2924
|
const brElement = brElements[elementIndex] || brElements[0];
|
|
2878
2925
|
const breakType = brElement?.['@_w:type'];
|
|
2879
|
-
|
|
2926
|
+
const breakClear = brElement?.['@_w:clear'];
|
|
2927
|
+
content.push({ type: 'break', breakType, breakClear });
|
|
2880
2928
|
break;
|
|
2881
2929
|
}
|
|
2882
2930
|
case 'w:cr':
|
|
@@ -3044,7 +3092,8 @@ class DocumentParser {
|
|
|
3044
3092
|
if (runObj['w:br'] !== undefined) {
|
|
3045
3093
|
const brElement = runObj['w:br'];
|
|
3046
3094
|
const breakType = brElement?.['@_w:type'];
|
|
3047
|
-
|
|
3095
|
+
const breakClear = brElement?.['@_w:clear'];
|
|
3096
|
+
content.push({ type: 'break', breakType, breakClear });
|
|
3048
3097
|
}
|
|
3049
3098
|
if (runObj['w:cr'] !== undefined) {
|
|
3050
3099
|
content.push({ type: 'carriageReturn' });
|
|
@@ -3239,14 +3288,8 @@ class DocumentParser {
|
|
|
3239
3288
|
}
|
|
3240
3289
|
}
|
|
3241
3290
|
}
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
if (url && anchor) {
|
|
3245
|
-
url = url + '#' + anchor;
|
|
3246
|
-
finalAnchor = undefined;
|
|
3247
|
-
finalRelationshipId = undefined;
|
|
3248
|
-
logger_1.defaultLogger.debug(`[DocumentParser] Combined external URL with anchor fragment: ${url}`);
|
|
3249
|
-
}
|
|
3291
|
+
const finalAnchor = anchor;
|
|
3292
|
+
const finalRelationshipId = relationshipId;
|
|
3250
3293
|
if (!url && !finalAnchor && !finalRelationshipId) {
|
|
3251
3294
|
logger_1.defaultLogger.debug(`[DocumentParser] Skipping hyperlink with no URL, anchor, or relationship ID. Text: "${text}"`);
|
|
3252
3295
|
return result;
|
|
@@ -3464,41 +3507,42 @@ class DocumentParser {
|
|
|
3464
3507
|
if (val)
|
|
3465
3508
|
run.setEmphasis(val);
|
|
3466
3509
|
}
|
|
3467
|
-
if (rPrObj['w:outline'])
|
|
3510
|
+
if ((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:outline']))
|
|
3468
3511
|
run.setOutline(true);
|
|
3469
|
-
if (rPrObj['w:shadow'])
|
|
3512
|
+
if ((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:shadow']))
|
|
3470
3513
|
run.setShadow(true);
|
|
3471
|
-
if (rPrObj['w:emboss'])
|
|
3514
|
+
if ((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:emboss']))
|
|
3472
3515
|
run.setEmboss(true);
|
|
3473
|
-
if (rPrObj['w:imprint'])
|
|
3516
|
+
if ((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:imprint']))
|
|
3474
3517
|
run.setImprint(true);
|
|
3475
|
-
if (rPrObj['w:noProof'])
|
|
3518
|
+
if ((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:noProof']))
|
|
3476
3519
|
run.setNoProof(true);
|
|
3477
|
-
if (rPrObj['w:snapToGrid'])
|
|
3478
|
-
run.setSnapToGrid(
|
|
3479
|
-
|
|
3520
|
+
if (rPrObj['w:snapToGrid'] !== undefined) {
|
|
3521
|
+
run.setSnapToGrid((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:snapToGrid']));
|
|
3522
|
+
}
|
|
3523
|
+
if ((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:vanish']))
|
|
3480
3524
|
run.setVanish(true);
|
|
3481
|
-
if (rPrObj['w:specVanish'])
|
|
3525
|
+
if ((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:specVanish']))
|
|
3482
3526
|
run.setSpecVanish(true);
|
|
3483
3527
|
if ((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:rtl']))
|
|
3484
3528
|
run.setRTL(true);
|
|
3485
|
-
if (
|
|
3486
|
-
run.setBold(
|
|
3487
|
-
if (
|
|
3488
|
-
run.setComplexScriptBold(
|
|
3489
|
-
if (
|
|
3490
|
-
run.setItalic(
|
|
3491
|
-
if (
|
|
3492
|
-
run.setComplexScriptItalic(
|
|
3493
|
-
if (
|
|
3494
|
-
run.setStrike(
|
|
3495
|
-
if (
|
|
3496
|
-
run.formatting.dstrike =
|
|
3497
|
-
}
|
|
3498
|
-
if (
|
|
3499
|
-
run.setSmallCaps(
|
|
3500
|
-
if (
|
|
3501
|
-
run.setAllCaps(
|
|
3529
|
+
if (rPrObj['w:b'] !== undefined)
|
|
3530
|
+
run.setBold((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:b']));
|
|
3531
|
+
if (rPrObj['w:bCs'] !== undefined)
|
|
3532
|
+
run.setComplexScriptBold((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:bCs']));
|
|
3533
|
+
if (rPrObj['w:i'] !== undefined)
|
|
3534
|
+
run.setItalic((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:i']));
|
|
3535
|
+
if (rPrObj['w:iCs'] !== undefined)
|
|
3536
|
+
run.setComplexScriptItalic((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:iCs']));
|
|
3537
|
+
if (rPrObj['w:strike'] !== undefined)
|
|
3538
|
+
run.setStrike((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:strike']));
|
|
3539
|
+
if (rPrObj['w:dstrike'] !== undefined) {
|
|
3540
|
+
run.formatting.dstrike = (0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:dstrike']);
|
|
3541
|
+
}
|
|
3542
|
+
if (rPrObj['w:smallCaps'] !== undefined)
|
|
3543
|
+
run.setSmallCaps((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:smallCaps']));
|
|
3544
|
+
if (rPrObj['w:caps'] !== undefined)
|
|
3545
|
+
run.setAllCaps((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:caps']));
|
|
3502
3546
|
if ((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:cs']))
|
|
3503
3547
|
run.setComplexScript(true);
|
|
3504
3548
|
if ((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:webHidden']))
|
|
@@ -3536,9 +3580,20 @@ class DocumentParser {
|
|
|
3536
3580
|
run.setKerning(parseInt(val, 10));
|
|
3537
3581
|
}
|
|
3538
3582
|
if (rPrObj['w:lang']) {
|
|
3539
|
-
const
|
|
3540
|
-
|
|
3541
|
-
|
|
3583
|
+
const langObj = rPrObj['w:lang'];
|
|
3584
|
+
const val = langObj['@_w:val'];
|
|
3585
|
+
const eastAsia = langObj['@_w:eastAsia'];
|
|
3586
|
+
const bidi = langObj['@_w:bidi'];
|
|
3587
|
+
if (eastAsia || bidi) {
|
|
3588
|
+
run.setLanguage({
|
|
3589
|
+
val: val ? String(val) : undefined,
|
|
3590
|
+
eastAsia: eastAsia ? String(eastAsia) : undefined,
|
|
3591
|
+
bidi: bidi ? String(bidi) : undefined,
|
|
3592
|
+
});
|
|
3593
|
+
}
|
|
3594
|
+
else if (val) {
|
|
3595
|
+
run.setLanguage(String(val));
|
|
3596
|
+
}
|
|
3542
3597
|
}
|
|
3543
3598
|
if (rPrObj['w:eastAsianLayout']) {
|
|
3544
3599
|
const layoutObj = rPrObj['w:eastAsianLayout'];
|
|
@@ -3571,8 +3626,10 @@ class DocumentParser {
|
|
|
3571
3626
|
const val = rPrObj['w:vertAlign']['@_w:val'];
|
|
3572
3627
|
if (val === 'subscript')
|
|
3573
3628
|
run.setSubscript(true);
|
|
3574
|
-
if (val === 'superscript')
|
|
3629
|
+
else if (val === 'superscript')
|
|
3575
3630
|
run.setSuperscript(true);
|
|
3631
|
+
else if (val === 'baseline')
|
|
3632
|
+
run.formatting.vertAlignBaseline = true;
|
|
3576
3633
|
}
|
|
3577
3634
|
if (rPrObj['w:rFonts']) {
|
|
3578
3635
|
const rFonts = rPrObj['w:rFonts'];
|
|
@@ -3610,8 +3667,13 @@ class DocumentParser {
|
|
|
3610
3667
|
if (rPrObj['w:color']) {
|
|
3611
3668
|
const colorObj = rPrObj['w:color'];
|
|
3612
3669
|
const colorVal = colorObj['@_w:val'];
|
|
3613
|
-
if (colorVal
|
|
3614
|
-
|
|
3670
|
+
if (colorVal) {
|
|
3671
|
+
if (colorVal === 'auto') {
|
|
3672
|
+
run.formatting.color = 'auto';
|
|
3673
|
+
}
|
|
3674
|
+
else {
|
|
3675
|
+
run.setColor(colorVal);
|
|
3676
|
+
}
|
|
3615
3677
|
}
|
|
3616
3678
|
if (colorObj['@_w:themeColor']) {
|
|
3617
3679
|
run.setThemeColor(colorObj['@_w:themeColor']);
|
|
@@ -3683,7 +3745,7 @@ class DocumentParser {
|
|
|
3683
3745
|
if (prevRPr['w:color']) {
|
|
3684
3746
|
const colorObj = prevRPr['w:color'];
|
|
3685
3747
|
const colorVal = colorObj['@_w:val'];
|
|
3686
|
-
if (colorVal
|
|
3748
|
+
if (colorVal) {
|
|
3687
3749
|
prevProps.color = colorVal;
|
|
3688
3750
|
}
|
|
3689
3751
|
if (colorObj['@_w:themeColor']) {
|
|
@@ -3703,8 +3765,10 @@ class DocumentParser {
|
|
|
3703
3765
|
const val = prevRPr['w:vertAlign']['@_w:val'];
|
|
3704
3766
|
if (val === 'subscript')
|
|
3705
3767
|
prevProps.subscript = true;
|
|
3706
|
-
if (val === 'superscript')
|
|
3768
|
+
else if (val === 'superscript')
|
|
3707
3769
|
prevProps.superscript = true;
|
|
3770
|
+
else if (val === 'baseline')
|
|
3771
|
+
prevProps.vertAlignBaseline = true;
|
|
3708
3772
|
}
|
|
3709
3773
|
if (prevRPr['w:smallCaps']) {
|
|
3710
3774
|
prevProps.smallCaps = (0, parsingHelpers_1.parseOoxmlBoolean)(prevRPr['w:smallCaps']);
|
|
@@ -3779,8 +3843,18 @@ class DocumentParser {
|
|
|
3779
3843
|
}
|
|
3780
3844
|
}
|
|
3781
3845
|
if (prevRPr['w:lang']) {
|
|
3782
|
-
const
|
|
3783
|
-
|
|
3846
|
+
const langObj = prevRPr['w:lang'];
|
|
3847
|
+
const langVal = langObj['@_w:val'];
|
|
3848
|
+
const langEastAsia = langObj['@_w:eastAsia'];
|
|
3849
|
+
const langBidi = langObj['@_w:bidi'];
|
|
3850
|
+
if (langEastAsia || langBidi) {
|
|
3851
|
+
prevProps.language = {
|
|
3852
|
+
val: langVal ? String(langVal) : undefined,
|
|
3853
|
+
eastAsia: langEastAsia ? String(langEastAsia) : undefined,
|
|
3854
|
+
bidi: langBidi ? String(langBidi) : undefined,
|
|
3855
|
+
};
|
|
3856
|
+
}
|
|
3857
|
+
else if (langVal) {
|
|
3784
3858
|
prevProps.language = String(langVal);
|
|
3785
3859
|
}
|
|
3786
3860
|
}
|
|
@@ -4481,6 +4555,18 @@ class DocumentParser {
|
|
|
4481
4555
|
table.setTableGrid(widths);
|
|
4482
4556
|
}
|
|
4483
4557
|
}
|
|
4558
|
+
if (tableObj['w:tblGrid']?.['w:tblGridChange']) {
|
|
4559
|
+
const changeObj = tableObj['w:tblGrid']['w:tblGridChange'];
|
|
4560
|
+
const prevGridCols = changeObj['w:tblGrid']?.['w:gridCol'];
|
|
4561
|
+
if (prevGridCols) {
|
|
4562
|
+
const prevArray = Array.isArray(prevGridCols) ? prevGridCols : [prevGridCols];
|
|
4563
|
+
const prevWidths = prevArray.map((col) => ({
|
|
4564
|
+
width: (0, parsingHelpers_1.isExplicitlySet)(col['@_w:w']) ? (0, parsingHelpers_1.safeParseInt)(col['@_w:w'], 2880) : 2880,
|
|
4565
|
+
}));
|
|
4566
|
+
const gridChange = TableGridChange_1.TableGridChange.create((0, parsingHelpers_1.safeParseInt)(changeObj['@_w:id'], 0), prevWidths, changeObj['@_w:author'] || undefined, changeObj['@_w:date'] ? new Date(changeObj['@_w:date']) : undefined);
|
|
4567
|
+
table.setTblGridChange(gridChange);
|
|
4568
|
+
}
|
|
4569
|
+
}
|
|
4484
4570
|
const rows = tableObj['w:tr'];
|
|
4485
4571
|
const rowChildren = Array.isArray(rows) ? rows : rows ? [rows] : [];
|
|
4486
4572
|
let rowXmls = [];
|
|
@@ -4637,6 +4723,10 @@ class DocumentParser {
|
|
|
4637
4723
|
if (tblPrObj['w:tblInd']) {
|
|
4638
4724
|
const indentVal = (0, parsingHelpers_1.safeParseInt)(tblPrObj['w:tblInd']['@_w:w'], 0);
|
|
4639
4725
|
table.setIndent(indentVal);
|
|
4726
|
+
const indentType = tblPrObj['w:tblInd']['@_w:type'];
|
|
4727
|
+
if (indentType) {
|
|
4728
|
+
table.setIndentType(indentType);
|
|
4729
|
+
}
|
|
4640
4730
|
}
|
|
4641
4731
|
if (tblPrObj['w:tblCellMar']) {
|
|
4642
4732
|
const cellMar = tblPrObj['w:tblCellMar'];
|
|
@@ -4651,13 +4741,15 @@ class DocumentParser {
|
|
|
4651
4741
|
if (w !== undefined)
|
|
4652
4742
|
margins.bottom = parseInt(w, 10);
|
|
4653
4743
|
}
|
|
4654
|
-
|
|
4655
|
-
|
|
4744
|
+
const leftSource = cellMar['w:start'] || cellMar['w:left'];
|
|
4745
|
+
if (leftSource) {
|
|
4746
|
+
const w = leftSource['@_w:w'];
|
|
4656
4747
|
if (w !== undefined)
|
|
4657
4748
|
margins.left = parseInt(w, 10);
|
|
4658
4749
|
}
|
|
4659
|
-
|
|
4660
|
-
|
|
4750
|
+
const rightSource = cellMar['w:end'] || cellMar['w:right'];
|
|
4751
|
+
if (rightSource) {
|
|
4752
|
+
const w = rightSource['@_w:w'];
|
|
4661
4753
|
if (w !== undefined)
|
|
4662
4754
|
margins.right = parseInt(w, 10);
|
|
4663
4755
|
}
|
|
@@ -4760,9 +4852,15 @@ class DocumentParser {
|
|
|
4760
4852
|
return;
|
|
4761
4853
|
if (trPrObj['w:trHeight']) {
|
|
4762
4854
|
const heightVal = parseInt(trPrObj['w:trHeight']['@_w:val'] || '0', 10);
|
|
4763
|
-
const heightRule = trPrObj['w:trHeight']['@_w:hRule']
|
|
4855
|
+
const heightRule = trPrObj['w:trHeight']['@_w:hRule'];
|
|
4764
4856
|
if (heightVal > 0) {
|
|
4765
|
-
row.setHeight(heightVal
|
|
4857
|
+
row.setHeight(heightVal);
|
|
4858
|
+
if (heightRule) {
|
|
4859
|
+
row.setHeightRule(heightRule);
|
|
4860
|
+
}
|
|
4861
|
+
else {
|
|
4862
|
+
row.setHeightRule(undefined);
|
|
4863
|
+
}
|
|
4766
4864
|
}
|
|
4767
4865
|
}
|
|
4768
4866
|
if (trPrObj['w:tblHeader']) {
|
|
@@ -4948,11 +5046,13 @@ class DocumentParser {
|
|
|
4948
5046
|
if (tcMar['w:bottom']) {
|
|
4949
5047
|
margins.bottom = parseInt(tcMar['w:bottom']['@_w:w'] || '0', 10);
|
|
4950
5048
|
}
|
|
4951
|
-
|
|
4952
|
-
|
|
5049
|
+
const leftSrc = tcMar['w:start'] || tcMar['w:left'];
|
|
5050
|
+
if (leftSrc) {
|
|
5051
|
+
margins.left = parseInt(leftSrc['@_w:w'] || '0', 10);
|
|
4953
5052
|
}
|
|
4954
|
-
|
|
4955
|
-
|
|
5053
|
+
const rightSrc = tcMar['w:end'] || tcMar['w:right'];
|
|
5054
|
+
if (rightSrc) {
|
|
5055
|
+
margins.right = parseInt(rightSrc['@_w:w'] || '0', 10);
|
|
4956
5056
|
}
|
|
4957
5057
|
if (Object.keys(margins).length > 0) {
|
|
4958
5058
|
cell.setMargins(margins);
|
|
@@ -5584,7 +5684,7 @@ class DocumentParser {
|
|
|
5584
5684
|
logger_1.defaultLogger.debug(`[TOC Parser] Normalized field instruction from "${instruction}" to "${normalized}"`);
|
|
5585
5685
|
return normalized;
|
|
5586
5686
|
}
|
|
5587
|
-
parseTOCFromSDTContent(content,
|
|
5687
|
+
parseTOCFromSDTContent(content, _properties, sdtContent) {
|
|
5588
5688
|
try {
|
|
5589
5689
|
let title;
|
|
5590
5690
|
let fieldInstruction;
|
|
@@ -5966,11 +6066,13 @@ class DocumentParser {
|
|
|
5966
6066
|
const width = XMLParser_1.XMLParser.extractAttribute(pgSz, 'w:w');
|
|
5967
6067
|
const height = XMLParser_1.XMLParser.extractAttribute(pgSz, 'w:h');
|
|
5968
6068
|
const orient = XMLParser_1.XMLParser.extractAttribute(pgSz, 'w:orient');
|
|
6069
|
+
const code = XMLParser_1.XMLParser.extractAttribute(pgSz, 'w:code');
|
|
5969
6070
|
if (width && height) {
|
|
5970
6071
|
sectionProps.pageSize = {
|
|
5971
6072
|
width: parseInt(width, 10),
|
|
5972
6073
|
height: parseInt(height, 10),
|
|
5973
6074
|
orientation: orient === 'landscape' ? 'landscape' : 'portrait',
|
|
6075
|
+
code: code ? parseInt(code, 10) : undefined,
|
|
5974
6076
|
};
|
|
5975
6077
|
}
|
|
5976
6078
|
}
|
|
@@ -6067,11 +6169,21 @@ class DocumentParser {
|
|
|
6067
6169
|
const sep = XMLParser_1.XMLParser.extractAttribute(cols, 'w:sep');
|
|
6068
6170
|
const colElements = XMLParser_1.XMLParser.extractElements(cols, 'w:col');
|
|
6069
6171
|
const columnWidths = [];
|
|
6172
|
+
const columnSpaces = [];
|
|
6173
|
+
let hasColumnSpaces = false;
|
|
6070
6174
|
for (const col of colElements) {
|
|
6071
6175
|
const width = XMLParser_1.XMLParser.extractAttribute(col, 'w:w');
|
|
6072
6176
|
if (width) {
|
|
6073
6177
|
columnWidths.push(parseInt(width.toString(), 10));
|
|
6074
6178
|
}
|
|
6179
|
+
const colSpace = XMLParser_1.XMLParser.extractAttribute(col, 'w:space');
|
|
6180
|
+
if (colSpace) {
|
|
6181
|
+
columnSpaces.push(parseInt(colSpace.toString(), 10));
|
|
6182
|
+
hasColumnSpaces = true;
|
|
6183
|
+
}
|
|
6184
|
+
else {
|
|
6185
|
+
columnSpaces.push(0);
|
|
6186
|
+
}
|
|
6075
6187
|
}
|
|
6076
6188
|
const toBool = (val) => val === '1' || val === 1 || val === 'true' || val === true;
|
|
6077
6189
|
if (num) {
|
|
@@ -6081,6 +6193,7 @@ class DocumentParser {
|
|
|
6081
6193
|
equalWidth: equalWidth ? toBool(equalWidth) : undefined,
|
|
6082
6194
|
separator: sep ? toBool(sep) : undefined,
|
|
6083
6195
|
columnWidths: columnWidths.length > 0 ? columnWidths : undefined,
|
|
6196
|
+
columnSpaces: hasColumnSpaces ? columnSpaces : undefined,
|
|
6084
6197
|
};
|
|
6085
6198
|
}
|
|
6086
6199
|
}
|
|
@@ -6445,10 +6558,15 @@ class DocumentParser {
|
|
|
6445
6558
|
}
|
|
6446
6559
|
const spacingElement = XMLParser_1.XMLParser.extractSelfClosingTag(pPrXml, 'w:spacing');
|
|
6447
6560
|
if (spacingElement) {
|
|
6448
|
-
const
|
|
6449
|
-
const
|
|
6450
|
-
const
|
|
6451
|
-
const
|
|
6561
|
+
const spacingTag = `<w:spacing${spacingElement}`;
|
|
6562
|
+
const before = XMLParser_1.XMLParser.extractAttribute(spacingTag, 'w:before');
|
|
6563
|
+
const after = XMLParser_1.XMLParser.extractAttribute(spacingTag, 'w:after');
|
|
6564
|
+
const line = XMLParser_1.XMLParser.extractAttribute(spacingTag, 'w:line');
|
|
6565
|
+
const lineRule = XMLParser_1.XMLParser.extractAttribute(spacingTag, 'w:lineRule');
|
|
6566
|
+
const beforeLines = XMLParser_1.XMLParser.extractAttribute(spacingTag, 'w:beforeLines');
|
|
6567
|
+
const afterLines = XMLParser_1.XMLParser.extractAttribute(spacingTag, 'w:afterLines');
|
|
6568
|
+
const beforeAutosp = XMLParser_1.XMLParser.extractAttribute(spacingTag, 'w:beforeAutospacing');
|
|
6569
|
+
const afterAutosp = XMLParser_1.XMLParser.extractAttribute(spacingTag, 'w:afterAutospacing');
|
|
6452
6570
|
let validatedLineRule;
|
|
6453
6571
|
if (lineRule) {
|
|
6454
6572
|
const validLineRules = ['auto', 'exact', 'atLeast'];
|
|
@@ -6461,17 +6579,28 @@ class DocumentParser {
|
|
|
6461
6579
|
after: after ? parseInt(after, 10) : undefined,
|
|
6462
6580
|
line: line ? parseInt(line, 10) : validatedLineRule ? 240 : undefined,
|
|
6463
6581
|
lineRule: validatedLineRule,
|
|
6582
|
+
beforeLines: beforeLines ? parseInt(beforeLines, 10) : undefined,
|
|
6583
|
+
afterLines: afterLines ? parseInt(afterLines, 10) : undefined,
|
|
6584
|
+
beforeAutospacing: beforeAutosp
|
|
6585
|
+
? beforeAutosp === '1' || beforeAutosp === 'true'
|
|
6586
|
+
: undefined,
|
|
6587
|
+
afterAutospacing: afterAutosp ? afterAutosp === '1' || afterAutosp === 'true' : undefined,
|
|
6464
6588
|
};
|
|
6465
6589
|
}
|
|
6466
6590
|
const indElement = XMLParser_1.XMLParser.extractSelfClosingTag(pPrXml, 'w:ind');
|
|
6467
6591
|
if (indElement) {
|
|
6468
|
-
const
|
|
6469
|
-
const
|
|
6470
|
-
const
|
|
6471
|
-
const
|
|
6592
|
+
const indTag = `<w:ind${indElement}`;
|
|
6593
|
+
const start = XMLParser_1.XMLParser.extractAttribute(indTag, 'w:start');
|
|
6594
|
+
const left = XMLParser_1.XMLParser.extractAttribute(indTag, 'w:left');
|
|
6595
|
+
const end = XMLParser_1.XMLParser.extractAttribute(indTag, 'w:end');
|
|
6596
|
+
const right = XMLParser_1.XMLParser.extractAttribute(indTag, 'w:right');
|
|
6597
|
+
const firstLine = XMLParser_1.XMLParser.extractAttribute(indTag, 'w:firstLine');
|
|
6598
|
+
const hanging = XMLParser_1.XMLParser.extractAttribute(indTag, 'w:hanging');
|
|
6599
|
+
const leftVal = start || left;
|
|
6600
|
+
const rightVal = end || right;
|
|
6472
6601
|
formatting.indentation = {
|
|
6473
|
-
left:
|
|
6474
|
-
right:
|
|
6602
|
+
left: leftVal ? parseInt(leftVal, 10) : undefined,
|
|
6603
|
+
right: rightVal ? parseInt(rightVal, 10) : undefined,
|
|
6475
6604
|
firstLine: firstLine ? parseInt(firstLine, 10) : undefined,
|
|
6476
6605
|
hanging: hanging ? parseInt(hanging, 10) : undefined,
|
|
6477
6606
|
};
|
|
@@ -6498,6 +6627,58 @@ class DocumentParser {
|
|
|
6498
6627
|
}
|
|
6499
6628
|
}
|
|
6500
6629
|
}
|
|
6630
|
+
const pBdrXml = XMLParser_1.XMLParser.extractBetweenTags(pPrXml, '<w:pBdr>', '</w:pBdr>');
|
|
6631
|
+
if (pBdrXml) {
|
|
6632
|
+
const borders = {};
|
|
6633
|
+
const borderTypes = ['top', 'left', 'bottom', 'right', 'between', 'bar'];
|
|
6634
|
+
for (const type of borderTypes) {
|
|
6635
|
+
if (pBdrXml.includes(`<w:${type}`)) {
|
|
6636
|
+
const tag = XMLParser_1.XMLParser.extractSelfClosingTag(pBdrXml, `w:${type}`);
|
|
6637
|
+
if (tag) {
|
|
6638
|
+
const bTag = `<w:${type}${tag}`;
|
|
6639
|
+
const style = XMLParser_1.XMLParser.extractAttribute(bTag, 'w:val');
|
|
6640
|
+
const size = XMLParser_1.XMLParser.extractAttribute(bTag, 'w:sz');
|
|
6641
|
+
const space = XMLParser_1.XMLParser.extractAttribute(bTag, 'w:space');
|
|
6642
|
+
const color = XMLParser_1.XMLParser.extractAttribute(bTag, 'w:color');
|
|
6643
|
+
const border = {};
|
|
6644
|
+
if (style)
|
|
6645
|
+
border.style = style;
|
|
6646
|
+
if (size)
|
|
6647
|
+
border.size = parseInt(size, 10);
|
|
6648
|
+
if (space)
|
|
6649
|
+
border.space = parseInt(space, 10);
|
|
6650
|
+
if (color)
|
|
6651
|
+
border.color = color;
|
|
6652
|
+
if (Object.keys(border).length > 0)
|
|
6653
|
+
borders[type] = border;
|
|
6654
|
+
}
|
|
6655
|
+
}
|
|
6656
|
+
}
|
|
6657
|
+
if (Object.keys(borders).length > 0)
|
|
6658
|
+
formatting.borders = borders;
|
|
6659
|
+
}
|
|
6660
|
+
const tabsXml = XMLParser_1.XMLParser.extractBetweenTags(pPrXml, '<w:tabs>', '</w:tabs>');
|
|
6661
|
+
if (tabsXml) {
|
|
6662
|
+
const tabs = [];
|
|
6663
|
+
const tabRegex = /<w:tab\s[^>]*\/>/g;
|
|
6664
|
+
let tabMatch;
|
|
6665
|
+
while ((tabMatch = tabRegex.exec(tabsXml)) !== null) {
|
|
6666
|
+
const tabTag = tabMatch[0];
|
|
6667
|
+
const pos = XMLParser_1.XMLParser.extractAttribute(tabTag, 'w:pos');
|
|
6668
|
+
const val = XMLParser_1.XMLParser.extractAttribute(tabTag, 'w:val');
|
|
6669
|
+
const leader = XMLParser_1.XMLParser.extractAttribute(tabTag, 'w:leader');
|
|
6670
|
+
if (pos) {
|
|
6671
|
+
const tab = { position: parseInt(pos, 10) };
|
|
6672
|
+
if (val)
|
|
6673
|
+
tab.val = val;
|
|
6674
|
+
if (leader)
|
|
6675
|
+
tab.leader = leader;
|
|
6676
|
+
tabs.push(tab);
|
|
6677
|
+
}
|
|
6678
|
+
}
|
|
6679
|
+
if (tabs.length > 0)
|
|
6680
|
+
formatting.tabs = tabs;
|
|
6681
|
+
}
|
|
6501
6682
|
const shading = this.parseShadingFromXml(pPrXml);
|
|
6502
6683
|
if (shading) {
|
|
6503
6684
|
formatting.shading = shading;
|
|
@@ -6523,7 +6704,8 @@ class DocumentParser {
|
|
|
6523
6704
|
}
|
|
6524
6705
|
const uElement = XMLParser_1.XMLParser.extractSelfClosingTag(rPrXml, 'w:u');
|
|
6525
6706
|
if (uElement) {
|
|
6526
|
-
const
|
|
6707
|
+
const uTag = `<w:u${uElement}`;
|
|
6708
|
+
const uVal = XMLParser_1.XMLParser.extractAttribute(uTag, 'w:val');
|
|
6527
6709
|
if (uVal === 'single' ||
|
|
6528
6710
|
uVal === 'double' ||
|
|
6529
6711
|
uVal === 'thick' ||
|
|
@@ -6535,6 +6717,19 @@ class DocumentParser {
|
|
|
6535
6717
|
else {
|
|
6536
6718
|
formatting.underline = true;
|
|
6537
6719
|
}
|
|
6720
|
+
const uColor = XMLParser_1.XMLParser.extractAttribute(uTag, 'w:color');
|
|
6721
|
+
if (uColor)
|
|
6722
|
+
formatting.underlineColor = uColor;
|
|
6723
|
+
const uThemeColor = XMLParser_1.XMLParser.extractAttribute(uTag, 'w:themeColor');
|
|
6724
|
+
if (uThemeColor) {
|
|
6725
|
+
formatting.underlineThemeColor = uThemeColor;
|
|
6726
|
+
}
|
|
6727
|
+
const uThemeTint = XMLParser_1.XMLParser.extractAttribute(uTag, 'w:themeTint');
|
|
6728
|
+
if (uThemeTint)
|
|
6729
|
+
formatting.underlineThemeTint = parseInt(uThemeTint, 16);
|
|
6730
|
+
const uThemeShade = XMLParser_1.XMLParser.extractAttribute(uTag, 'w:themeShade');
|
|
6731
|
+
if (uThemeShade)
|
|
6732
|
+
formatting.underlineThemeShade = parseInt(uThemeShade, 16);
|
|
6538
6733
|
}
|
|
6539
6734
|
const vertAlignElement = XMLParser_1.XMLParser.extractSelfClosingTag(rPrXml, 'w:vertAlign');
|
|
6540
6735
|
if (vertAlignElement) {
|
|
@@ -6545,13 +6740,40 @@ class DocumentParser {
|
|
|
6545
6740
|
else if (val === 'superscript') {
|
|
6546
6741
|
formatting.superscript = true;
|
|
6547
6742
|
}
|
|
6743
|
+
else if (val === 'baseline') {
|
|
6744
|
+
formatting.vertAlignBaseline = true;
|
|
6745
|
+
}
|
|
6548
6746
|
}
|
|
6549
6747
|
const rFontsElement = XMLParser_1.XMLParser.extractSelfClosingTag(rPrXml, 'w:rFonts');
|
|
6550
6748
|
if (rFontsElement) {
|
|
6551
|
-
const
|
|
6552
|
-
|
|
6749
|
+
const rFontsTag = `<w:rFonts${rFontsElement}`;
|
|
6750
|
+
const ascii = XMLParser_1.XMLParser.extractAttribute(rFontsTag, 'w:ascii');
|
|
6751
|
+
if (ascii)
|
|
6553
6752
|
formatting.font = ascii;
|
|
6554
|
-
|
|
6753
|
+
const hAnsi = XMLParser_1.XMLParser.extractAttribute(rFontsTag, 'w:hAnsi');
|
|
6754
|
+
if (hAnsi)
|
|
6755
|
+
formatting.fontHAnsi = hAnsi;
|
|
6756
|
+
const eastAsia = XMLParser_1.XMLParser.extractAttribute(rFontsTag, 'w:eastAsia');
|
|
6757
|
+
if (eastAsia)
|
|
6758
|
+
formatting.fontEastAsia = eastAsia;
|
|
6759
|
+
const cs = XMLParser_1.XMLParser.extractAttribute(rFontsTag, 'w:cs');
|
|
6760
|
+
if (cs)
|
|
6761
|
+
formatting.fontCs = cs;
|
|
6762
|
+
const hint = XMLParser_1.XMLParser.extractAttribute(rFontsTag, 'w:hint');
|
|
6763
|
+
if (hint)
|
|
6764
|
+
formatting.fontHint = hint;
|
|
6765
|
+
const asciiTheme = XMLParser_1.XMLParser.extractAttribute(rFontsTag, 'w:asciiTheme');
|
|
6766
|
+
if (asciiTheme)
|
|
6767
|
+
formatting.fontAsciiTheme = asciiTheme;
|
|
6768
|
+
const hAnsiTheme = XMLParser_1.XMLParser.extractAttribute(rFontsTag, 'w:hAnsiTheme');
|
|
6769
|
+
if (hAnsiTheme)
|
|
6770
|
+
formatting.fontHAnsiTheme = hAnsiTheme;
|
|
6771
|
+
const eastAsiaTheme = XMLParser_1.XMLParser.extractAttribute(rFontsTag, 'w:eastAsiaTheme');
|
|
6772
|
+
if (eastAsiaTheme)
|
|
6773
|
+
formatting.fontEastAsiaTheme = eastAsiaTheme;
|
|
6774
|
+
const cstheme = XMLParser_1.XMLParser.extractAttribute(rFontsTag, 'w:cstheme');
|
|
6775
|
+
if (cstheme)
|
|
6776
|
+
formatting.fontCsTheme = cstheme;
|
|
6555
6777
|
}
|
|
6556
6778
|
const szElement = XMLParser_1.XMLParser.extractSelfClosingTag(rPrXml, 'w:sz');
|
|
6557
6779
|
if (szElement) {
|
|
@@ -6560,12 +6782,35 @@ class DocumentParser {
|
|
|
6560
6782
|
formatting.size = (0, units_1.halfPointsToPoints)(parseInt(val, 10));
|
|
6561
6783
|
}
|
|
6562
6784
|
}
|
|
6785
|
+
const szCsElement = XMLParser_1.XMLParser.extractSelfClosingTag(rPrXml, 'w:szCs');
|
|
6786
|
+
if (szCsElement) {
|
|
6787
|
+
const val = XMLParser_1.XMLParser.extractAttribute(`<w:szCs${szCsElement}`, 'w:val');
|
|
6788
|
+
if (val) {
|
|
6789
|
+
const szCsVal = (0, units_1.halfPointsToPoints)(parseInt(val, 10));
|
|
6790
|
+
if (formatting.size === undefined || szCsVal !== formatting.size) {
|
|
6791
|
+
formatting.sizeCs = szCsVal;
|
|
6792
|
+
}
|
|
6793
|
+
}
|
|
6794
|
+
}
|
|
6563
6795
|
const colorElement = XMLParser_1.XMLParser.extractSelfClosingTag(rPrXml, 'w:color');
|
|
6564
6796
|
if (colorElement) {
|
|
6565
|
-
const
|
|
6797
|
+
const colorTag = `<w:color${colorElement}`;
|
|
6798
|
+
const val = XMLParser_1.XMLParser.extractAttribute(colorTag, 'w:val');
|
|
6566
6799
|
if (val && val !== 'auto') {
|
|
6567
6800
|
formatting.color = val;
|
|
6568
6801
|
}
|
|
6802
|
+
const themeColor = XMLParser_1.XMLParser.extractAttribute(colorTag, 'w:themeColor');
|
|
6803
|
+
if (themeColor) {
|
|
6804
|
+
formatting.themeColor = themeColor;
|
|
6805
|
+
}
|
|
6806
|
+
const themeTint = XMLParser_1.XMLParser.extractAttribute(colorTag, 'w:themeTint');
|
|
6807
|
+
if (themeTint) {
|
|
6808
|
+
formatting.themeTint = parseInt(themeTint, 16);
|
|
6809
|
+
}
|
|
6810
|
+
const themeShade = XMLParser_1.XMLParser.extractAttribute(colorTag, 'w:themeShade');
|
|
6811
|
+
if (themeShade) {
|
|
6812
|
+
formatting.themeShade = parseInt(themeShade, 16);
|
|
6813
|
+
}
|
|
6569
6814
|
}
|
|
6570
6815
|
const highlightElement = XMLParser_1.XMLParser.extractSelfClosingTag(rPrXml, 'w:highlight');
|
|
6571
6816
|
if (highlightElement) {
|
|
@@ -6588,6 +6833,7 @@ class DocumentParser {
|
|
|
6588
6833
|
'lightGray',
|
|
6589
6834
|
'black',
|
|
6590
6835
|
'white',
|
|
6836
|
+
'none',
|
|
6591
6837
|
];
|
|
6592
6838
|
if (validHighlights.includes(val)) {
|
|
6593
6839
|
formatting.highlight = val;
|
|
@@ -6640,10 +6886,15 @@ class DocumentParser {
|
|
|
6640
6886
|
if (tblPrXml.includes('<w:tblInd')) {
|
|
6641
6887
|
const tag = XMLParser_1.XMLParser.extractSelfClosingTag(tblPrXml, 'w:tblInd');
|
|
6642
6888
|
if (tag) {
|
|
6643
|
-
const
|
|
6889
|
+
const tblIndTag = `<w:tblInd${tag}`;
|
|
6890
|
+
const w = XMLParser_1.XMLParser.extractAttribute(tblIndTag, 'w:w');
|
|
6644
6891
|
if (w) {
|
|
6645
6892
|
formatting.indent = parseInt(w, 10);
|
|
6646
6893
|
}
|
|
6894
|
+
const type = XMLParser_1.XMLParser.extractAttribute(tblIndTag, 'w:type');
|
|
6895
|
+
if (type) {
|
|
6896
|
+
formatting.indentType = type;
|
|
6897
|
+
}
|
|
6647
6898
|
}
|
|
6648
6899
|
}
|
|
6649
6900
|
if (tblPrXml.includes('<w:jc')) {
|
|
@@ -6879,8 +7130,7 @@ class DocumentParser {
|
|
|
6879
7130
|
}
|
|
6880
7131
|
parseCellMarginsFromXml(marginXml) {
|
|
6881
7132
|
const margins = {};
|
|
6882
|
-
const
|
|
6883
|
-
for (const type of marginTypes) {
|
|
7133
|
+
for (const type of ['top', 'bottom']) {
|
|
6884
7134
|
if (marginXml.includes(`<w:${type}`)) {
|
|
6885
7135
|
const tag = XMLParser_1.XMLParser.extractSelfClosingTag(marginXml, `w:${type}`);
|
|
6886
7136
|
if (tag) {
|
|
@@ -6891,6 +7141,26 @@ class DocumentParser {
|
|
|
6891
7141
|
}
|
|
6892
7142
|
}
|
|
6893
7143
|
}
|
|
7144
|
+
const leftTag = marginXml.includes('<w:start')
|
|
7145
|
+
? XMLParser_1.XMLParser.extractSelfClosingTag(marginXml, 'w:start')
|
|
7146
|
+
: XMLParser_1.XMLParser.extractSelfClosingTag(marginXml, 'w:left');
|
|
7147
|
+
if (leftTag) {
|
|
7148
|
+
const tagName = marginXml.includes('<w:start') ? 'w:start' : 'w:left';
|
|
7149
|
+
const w = XMLParser_1.XMLParser.extractAttribute(`<${tagName}${leftTag}`, 'w:w');
|
|
7150
|
+
if (w) {
|
|
7151
|
+
margins.left = parseInt(w, 10);
|
|
7152
|
+
}
|
|
7153
|
+
}
|
|
7154
|
+
const rightTag = marginXml.includes('<w:end')
|
|
7155
|
+
? XMLParser_1.XMLParser.extractSelfClosingTag(marginXml, 'w:end')
|
|
7156
|
+
: XMLParser_1.XMLParser.extractSelfClosingTag(marginXml, 'w:right');
|
|
7157
|
+
if (rightTag) {
|
|
7158
|
+
const tagName = marginXml.includes('<w:end') ? 'w:end' : 'w:right';
|
|
7159
|
+
const w = XMLParser_1.XMLParser.extractAttribute(`<${tagName}${rightTag}`, 'w:w');
|
|
7160
|
+
if (w) {
|
|
7161
|
+
margins.right = parseInt(w, 10);
|
|
7162
|
+
}
|
|
7163
|
+
}
|
|
6894
7164
|
return Object.keys(margins).length > 0 ? margins : undefined;
|
|
6895
7165
|
}
|
|
6896
7166
|
static getRawXml(zipHandler, partName) {
|
|
@@ -7162,6 +7432,40 @@ class DocumentParser {
|
|
|
7162
7432
|
if (propsObj['w:tblStyle']) {
|
|
7163
7433
|
result.style = propsObj['w:tblStyle']['@_w:val'] || '';
|
|
7164
7434
|
}
|
|
7435
|
+
if (propsObj['w:tblpPr']) {
|
|
7436
|
+
const tblpPr = propsObj['w:tblpPr'];
|
|
7437
|
+
const pos = {};
|
|
7438
|
+
if (tblpPr['@_w:tblpX'])
|
|
7439
|
+
pos.x = parseInt(tblpPr['@_w:tblpX'], 10);
|
|
7440
|
+
if (tblpPr['@_w:tblpY'])
|
|
7441
|
+
pos.y = parseInt(tblpPr['@_w:tblpY'], 10);
|
|
7442
|
+
if (tblpPr['@_w:horzAnchor'])
|
|
7443
|
+
pos.horizontalAnchor = tblpPr['@_w:horzAnchor'];
|
|
7444
|
+
if (tblpPr['@_w:vertAnchor'])
|
|
7445
|
+
pos.verticalAnchor = tblpPr['@_w:vertAnchor'];
|
|
7446
|
+
if (tblpPr['@_w:leftFromText'])
|
|
7447
|
+
pos.leftFromText = parseInt(tblpPr['@_w:leftFromText'], 10);
|
|
7448
|
+
if (tblpPr['@_w:rightFromText'])
|
|
7449
|
+
pos.rightFromText = parseInt(tblpPr['@_w:rightFromText'], 10);
|
|
7450
|
+
if (tblpPr['@_w:topFromText'])
|
|
7451
|
+
pos.topFromText = parseInt(tblpPr['@_w:topFromText'], 10);
|
|
7452
|
+
if (tblpPr['@_w:bottomFromText'])
|
|
7453
|
+
pos.bottomFromText = parseInt(tblpPr['@_w:bottomFromText'], 10);
|
|
7454
|
+
if (Object.keys(pos).length > 0)
|
|
7455
|
+
result.position = pos;
|
|
7456
|
+
}
|
|
7457
|
+
if (propsObj['w:tblOverlap']) {
|
|
7458
|
+
result.overlap = propsObj['w:tblOverlap']['@_w:val'];
|
|
7459
|
+
}
|
|
7460
|
+
if (propsObj['w:bidiVisual']) {
|
|
7461
|
+
result.bidiVisual = true;
|
|
7462
|
+
}
|
|
7463
|
+
if (propsObj['w:tblStyleRowBandSize']) {
|
|
7464
|
+
result.tblStyleRowBandSize = parseInt(propsObj['w:tblStyleRowBandSize']['@_w:val'] || '1', 10);
|
|
7465
|
+
}
|
|
7466
|
+
if (propsObj['w:tblStyleColBandSize']) {
|
|
7467
|
+
result.tblStyleColBandSize = parseInt(propsObj['w:tblStyleColBandSize']['@_w:val'] || '1', 10);
|
|
7468
|
+
}
|
|
7165
7469
|
if (propsObj['w:tblW']) {
|
|
7166
7470
|
result.width = parseInt(propsObj['w:tblW']['@_w:w'] || '0', 10);
|
|
7167
7471
|
result.widthType = propsObj['w:tblW']['@_w:type'] || 'dxa';
|
|
@@ -7171,9 +7475,31 @@ class DocumentParser {
|
|
|
7171
7475
|
}
|
|
7172
7476
|
if (propsObj['w:tblInd']) {
|
|
7173
7477
|
result.indent = parseInt(propsObj['w:tblInd']['@_w:w'] || '0', 10);
|
|
7478
|
+
const indType = propsObj['w:tblInd']['@_w:type'];
|
|
7479
|
+
if (indType)
|
|
7480
|
+
result.indentType = indType;
|
|
7174
7481
|
}
|
|
7175
7482
|
if (propsObj['w:tblCellSpacing']) {
|
|
7176
7483
|
result.cellSpacing = parseInt(propsObj['w:tblCellSpacing']['@_w:w'] || '0', 10);
|
|
7484
|
+
const csType = propsObj['w:tblCellSpacing']['@_w:type'];
|
|
7485
|
+
if (csType)
|
|
7486
|
+
result.cellSpacingType = csType;
|
|
7487
|
+
}
|
|
7488
|
+
if (propsObj['w:tblCellMar']) {
|
|
7489
|
+
const cellMar = propsObj['w:tblCellMar'];
|
|
7490
|
+
const margins = {};
|
|
7491
|
+
if (cellMar['w:top'])
|
|
7492
|
+
margins.top = parseInt(cellMar['w:top']['@_w:w'] || '0', 10);
|
|
7493
|
+
if (cellMar['w:bottom'])
|
|
7494
|
+
margins.bottom = parseInt(cellMar['w:bottom']['@_w:w'] || '0', 10);
|
|
7495
|
+
const leftSrc = cellMar['w:start'] || cellMar['w:left'];
|
|
7496
|
+
if (leftSrc)
|
|
7497
|
+
margins.left = parseInt(leftSrc['@_w:w'] || '0', 10);
|
|
7498
|
+
const rightSrc = cellMar['w:end'] || cellMar['w:right'];
|
|
7499
|
+
if (rightSrc)
|
|
7500
|
+
margins.right = parseInt(rightSrc['@_w:w'] || '0', 10);
|
|
7501
|
+
if (Object.keys(margins).length > 0)
|
|
7502
|
+
result.cellMargins = margins;
|
|
7177
7503
|
}
|
|
7178
7504
|
if (propsObj['w:tblBorders']) {
|
|
7179
7505
|
const borders = {};
|
|
@@ -7186,6 +7512,40 @@ class DocumentParser {
|
|
|
7186
7512
|
if (Object.keys(borders).length > 0)
|
|
7187
7513
|
result.borders = borders;
|
|
7188
7514
|
}
|
|
7515
|
+
if (propsObj['w:tblLook']) {
|
|
7516
|
+
const look = propsObj['w:tblLook'];
|
|
7517
|
+
result.tblLook = look['@_w:val'] || '0000';
|
|
7518
|
+
}
|
|
7519
|
+
if (propsObj['w:tblCaption']) {
|
|
7520
|
+
result.caption = propsObj['w:tblCaption']['@_w:val'];
|
|
7521
|
+
}
|
|
7522
|
+
if (propsObj['w:tblDescription']) {
|
|
7523
|
+
result.description = propsObj['w:tblDescription']['@_w:val'];
|
|
7524
|
+
}
|
|
7525
|
+
if (propsObj['w:cnfStyle']) {
|
|
7526
|
+
result.cnfStyle = propsObj['w:cnfStyle']['@_w:val'];
|
|
7527
|
+
}
|
|
7528
|
+
if (propsObj['w:divId']) {
|
|
7529
|
+
result.divId = propsObj['w:divId']['@_w:val'];
|
|
7530
|
+
}
|
|
7531
|
+
if (propsObj['w:gridBefore']) {
|
|
7532
|
+
result.gridBefore = parseInt(propsObj['w:gridBefore']['@_w:val'] || '0', 10);
|
|
7533
|
+
}
|
|
7534
|
+
if (propsObj['w:gridAfter']) {
|
|
7535
|
+
result.gridAfter = parseInt(propsObj['w:gridAfter']['@_w:val'] || '0', 10);
|
|
7536
|
+
}
|
|
7537
|
+
if (propsObj['w:wBefore']) {
|
|
7538
|
+
result.wBefore = parseInt(propsObj['w:wBefore']['@_w:w'] || '0', 10);
|
|
7539
|
+
const wbType = propsObj['w:wBefore']['@_w:type'];
|
|
7540
|
+
if (wbType)
|
|
7541
|
+
result.wBeforeType = wbType;
|
|
7542
|
+
}
|
|
7543
|
+
if (propsObj['w:wAfter']) {
|
|
7544
|
+
result.wAfter = parseInt(propsObj['w:wAfter']['@_w:w'] || '0', 10);
|
|
7545
|
+
const waType = propsObj['w:wAfter']['@_w:type'];
|
|
7546
|
+
if (waType)
|
|
7547
|
+
result.wAfterType = waType;
|
|
7548
|
+
}
|
|
7189
7549
|
if (propsObj['w:trHeight']) {
|
|
7190
7550
|
result.height = parseInt(propsObj['w:trHeight']['@_w:val'] || '0', 10);
|
|
7191
7551
|
const rule = propsObj['w:trHeight']['@_w:hRule'];
|
|
@@ -7205,8 +7565,14 @@ class DocumentParser {
|
|
|
7205
7565
|
result.width = parseInt(propsObj['w:tcW']['@_w:w'] || '0', 10);
|
|
7206
7566
|
result.widthType = propsObj['w:tcW']['@_w:type'] || 'dxa';
|
|
7207
7567
|
}
|
|
7208
|
-
if (propsObj['w:
|
|
7209
|
-
result.
|
|
7568
|
+
if (propsObj['w:gridSpan']) {
|
|
7569
|
+
result.columnSpan = parseInt(propsObj['w:gridSpan']['@_w:val'] || '1', 10);
|
|
7570
|
+
}
|
|
7571
|
+
if (propsObj['w:hMerge']) {
|
|
7572
|
+
result.hMerge = propsObj['w:hMerge']['@_w:val'] || 'continue';
|
|
7573
|
+
}
|
|
7574
|
+
if (propsObj['w:vMerge']) {
|
|
7575
|
+
result.vMerge = propsObj['w:vMerge']['@_w:val'] || 'continue';
|
|
7210
7576
|
}
|
|
7211
7577
|
if (propsObj['w:tcBorders']) {
|
|
7212
7578
|
const borders = {};
|
|
@@ -7219,6 +7585,40 @@ class DocumentParser {
|
|
|
7219
7585
|
if (Object.keys(borders).length > 0)
|
|
7220
7586
|
result.borders = borders;
|
|
7221
7587
|
}
|
|
7588
|
+
if (propsObj['w:noWrap']) {
|
|
7589
|
+
result.noWrap = true;
|
|
7590
|
+
}
|
|
7591
|
+
if (propsObj['w:tcMar']) {
|
|
7592
|
+
const tcMar = propsObj['w:tcMar'];
|
|
7593
|
+
const margins = {};
|
|
7594
|
+
if (tcMar['w:top'])
|
|
7595
|
+
margins.top = parseInt(tcMar['w:top']['@_w:w'] || '0', 10);
|
|
7596
|
+
if (tcMar['w:bottom'])
|
|
7597
|
+
margins.bottom = parseInt(tcMar['w:bottom']['@_w:w'] || '0', 10);
|
|
7598
|
+
const leftSrc = tcMar['w:start'] || tcMar['w:left'];
|
|
7599
|
+
if (leftSrc)
|
|
7600
|
+
margins.left = parseInt(leftSrc['@_w:w'] || '0', 10);
|
|
7601
|
+
const rightSrc = tcMar['w:end'] || tcMar['w:right'];
|
|
7602
|
+
if (rightSrc)
|
|
7603
|
+
margins.right = parseInt(rightSrc['@_w:w'] || '0', 10);
|
|
7604
|
+
if (Object.keys(margins).length > 0)
|
|
7605
|
+
result.margins = margins;
|
|
7606
|
+
}
|
|
7607
|
+
if (propsObj['w:textDirection']) {
|
|
7608
|
+
result.textDirection = propsObj['w:textDirection']['@_w:val'];
|
|
7609
|
+
}
|
|
7610
|
+
if (propsObj['w:tcFitText']) {
|
|
7611
|
+
result.fitText = true;
|
|
7612
|
+
}
|
|
7613
|
+
if (propsObj['w:vAlign']) {
|
|
7614
|
+
result.verticalAlignment = propsObj['w:vAlign']['@_w:val'];
|
|
7615
|
+
}
|
|
7616
|
+
if (propsObj['w:hideMark']) {
|
|
7617
|
+
result.hideMark = true;
|
|
7618
|
+
}
|
|
7619
|
+
if (propsObj['w:cnfStyle']) {
|
|
7620
|
+
result.cnfStyle = propsObj['w:cnfStyle']['@_w:val'];
|
|
7621
|
+
}
|
|
7222
7622
|
if (propsObj['w:jc']) {
|
|
7223
7623
|
const val = propsObj['w:jc']['@_w:val'];
|
|
7224
7624
|
if (val) {
|
|
@@ -7243,11 +7643,13 @@ class DocumentParser {
|
|
|
7243
7643
|
const width = XMLParser_1.XMLParser.extractAttribute(pgSz, 'w:w');
|
|
7244
7644
|
const height = XMLParser_1.XMLParser.extractAttribute(pgSz, 'w:h');
|
|
7245
7645
|
const orient = XMLParser_1.XMLParser.extractAttribute(pgSz, 'w:orient');
|
|
7646
|
+
const code = XMLParser_1.XMLParser.extractAttribute(pgSz, 'w:code');
|
|
7246
7647
|
if (width || height) {
|
|
7247
7648
|
result.pageSize = {
|
|
7248
7649
|
width: width ? parseInt(width, 10) : undefined,
|
|
7249
7650
|
height: height ? parseInt(height, 10) : undefined,
|
|
7250
7651
|
orientation: orient === 'landscape' ? 'landscape' : 'portrait',
|
|
7652
|
+
code: code ? parseInt(code, 10) : undefined,
|
|
7251
7653
|
};
|
|
7252
7654
|
}
|
|
7253
7655
|
}
|
|
@@ -7282,6 +7684,38 @@ class DocumentParser {
|
|
|
7282
7684
|
if (val)
|
|
7283
7685
|
result.type = val;
|
|
7284
7686
|
}
|
|
7687
|
+
const lnNumElements = XMLParser_1.XMLParser.extractElements(sectPrXml, 'w:lnNumType');
|
|
7688
|
+
if (lnNumElements.length > 0 && lnNumElements[0]) {
|
|
7689
|
+
const ln = lnNumElements[0];
|
|
7690
|
+
const lnObj = {};
|
|
7691
|
+
const countBy = XMLParser_1.XMLParser.extractAttribute(ln, 'w:countBy');
|
|
7692
|
+
if (countBy)
|
|
7693
|
+
lnObj.countBy = parseInt(countBy, 10);
|
|
7694
|
+
const start = XMLParser_1.XMLParser.extractAttribute(ln, 'w:start');
|
|
7695
|
+
if (start)
|
|
7696
|
+
lnObj.start = parseInt(start, 10);
|
|
7697
|
+
const restart = XMLParser_1.XMLParser.extractAttribute(ln, 'w:restart');
|
|
7698
|
+
if (restart)
|
|
7699
|
+
lnObj.restart = restart;
|
|
7700
|
+
const distance = XMLParser_1.XMLParser.extractAttribute(ln, 'w:distance');
|
|
7701
|
+
if (distance)
|
|
7702
|
+
lnObj.distance = parseInt(distance, 10);
|
|
7703
|
+
if (Object.keys(lnObj).length > 0)
|
|
7704
|
+
result.lineNumbering = lnObj;
|
|
7705
|
+
}
|
|
7706
|
+
const pgNumElements = XMLParser_1.XMLParser.extractElements(sectPrXml, 'w:pgNumType');
|
|
7707
|
+
if (pgNumElements.length > 0 && pgNumElements[0]) {
|
|
7708
|
+
const pn = pgNumElements[0];
|
|
7709
|
+
const pnObj = {};
|
|
7710
|
+
const pnStart = XMLParser_1.XMLParser.extractAttribute(pn, 'w:start');
|
|
7711
|
+
if (pnStart)
|
|
7712
|
+
pnObj.start = parseInt(pnStart, 10);
|
|
7713
|
+
const fmt = XMLParser_1.XMLParser.extractAttribute(pn, 'w:fmt');
|
|
7714
|
+
if (fmt)
|
|
7715
|
+
pnObj.format = fmt;
|
|
7716
|
+
if (Object.keys(pnObj).length > 0)
|
|
7717
|
+
result.pageNumbering = pnObj;
|
|
7718
|
+
}
|
|
7285
7719
|
const colsElements = XMLParser_1.XMLParser.extractElements(sectPrXml, 'w:cols');
|
|
7286
7720
|
if (colsElements.length > 0 && colsElements[0]) {
|
|
7287
7721
|
const cols = colsElements[0];
|
|
@@ -7294,6 +7728,44 @@ class DocumentParser {
|
|
|
7294
7728
|
};
|
|
7295
7729
|
}
|
|
7296
7730
|
}
|
|
7731
|
+
if (sectPrXml.includes('<w:formProt'))
|
|
7732
|
+
result.formProt = true;
|
|
7733
|
+
const vAlignElements = XMLParser_1.XMLParser.extractElements(sectPrXml, 'w:vAlign');
|
|
7734
|
+
if (vAlignElements.length > 0 && vAlignElements[0]) {
|
|
7735
|
+
const val = XMLParser_1.XMLParser.extractAttribute(vAlignElements[0], 'w:val');
|
|
7736
|
+
if (val)
|
|
7737
|
+
result.verticalAlignment = val;
|
|
7738
|
+
}
|
|
7739
|
+
if (sectPrXml.includes('<w:noEndnote'))
|
|
7740
|
+
result.noEndnote = true;
|
|
7741
|
+
if (sectPrXml.includes('<w:titlePg'))
|
|
7742
|
+
result.titlePage = true;
|
|
7743
|
+
const textDirElements = XMLParser_1.XMLParser.extractElements(sectPrXml, 'w:textDirection');
|
|
7744
|
+
if (textDirElements.length > 0 && textDirElements[0]) {
|
|
7745
|
+
const val = XMLParser_1.XMLParser.extractAttribute(textDirElements[0], 'w:val');
|
|
7746
|
+
if (val)
|
|
7747
|
+
result.textDirection = val;
|
|
7748
|
+
}
|
|
7749
|
+
if (sectPrXml.includes('<w:bidi'))
|
|
7750
|
+
result.bidi = true;
|
|
7751
|
+
if (sectPrXml.includes('<w:rtlGutter'))
|
|
7752
|
+
result.rtlGutter = true;
|
|
7753
|
+
const docGridElements = XMLParser_1.XMLParser.extractElements(sectPrXml, 'w:docGrid');
|
|
7754
|
+
if (docGridElements.length > 0 && docGridElements[0]) {
|
|
7755
|
+
const dg = docGridElements[0];
|
|
7756
|
+
const dgObj = {};
|
|
7757
|
+
const dgType = XMLParser_1.XMLParser.extractAttribute(dg, 'w:type');
|
|
7758
|
+
if (dgType)
|
|
7759
|
+
dgObj.type = dgType;
|
|
7760
|
+
const linePitch = XMLParser_1.XMLParser.extractAttribute(dg, 'w:linePitch');
|
|
7761
|
+
if (linePitch)
|
|
7762
|
+
dgObj.linePitch = parseInt(linePitch, 10);
|
|
7763
|
+
const charSpace = XMLParser_1.XMLParser.extractAttribute(dg, 'w:charSpace');
|
|
7764
|
+
if (charSpace)
|
|
7765
|
+
dgObj.charSpace = parseInt(charSpace, 10);
|
|
7766
|
+
if (Object.keys(dgObj).length > 0)
|
|
7767
|
+
result.docGrid = dgObj;
|
|
7768
|
+
}
|
|
7297
7769
|
return result;
|
|
7298
7770
|
}
|
|
7299
7771
|
}
|