docxmlater 10.3.6 → 10.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +158 -7
- package/dist/core/Document.d.ts +98 -3
- package/dist/core/Document.d.ts.map +1 -1
- package/dist/core/Document.js +740 -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 +617 -104
- 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 +1770 -83
- package/src/core/DocumentContent.ts +0 -11
- package/src/core/DocumentGenerator.ts +11 -12
- package/src/core/DocumentParser.ts +654 -141
- 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) => ({
|
|
@@ -918,9 +923,50 @@ class DocumentParser {
|
|
|
918
923
|
hyperlinkObj['w:moveFrom'] ||
|
|
919
924
|
hyperlinkObj['w:moveTo'];
|
|
920
925
|
if (hasRevisionChildren) {
|
|
921
|
-
const
|
|
922
|
-
|
|
923
|
-
|
|
926
|
+
const flattenedObj = { ...hyperlinkObj };
|
|
927
|
+
const allRuns = [];
|
|
928
|
+
if (flattenedObj['w:r']) {
|
|
929
|
+
const directRuns = Array.isArray(flattenedObj['w:r'])
|
|
930
|
+
? flattenedObj['w:r']
|
|
931
|
+
: [flattenedObj['w:r']];
|
|
932
|
+
allRuns.push(...directRuns);
|
|
933
|
+
}
|
|
934
|
+
if (flattenedObj['w:ins']) {
|
|
935
|
+
const insArr = Array.isArray(flattenedObj['w:ins'])
|
|
936
|
+
? flattenedObj['w:ins']
|
|
937
|
+
: [flattenedObj['w:ins']];
|
|
938
|
+
for (const ins of insArr) {
|
|
939
|
+
if (ins['w:r']) {
|
|
940
|
+
const insRuns = Array.isArray(ins['w:r']) ? ins['w:r'] : [ins['w:r']];
|
|
941
|
+
allRuns.push(...insRuns);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
if (flattenedObj['w:moveTo']) {
|
|
946
|
+
const moveToArr = Array.isArray(flattenedObj['w:moveTo'])
|
|
947
|
+
? flattenedObj['w:moveTo']
|
|
948
|
+
: [flattenedObj['w:moveTo']];
|
|
949
|
+
for (const mt of moveToArr) {
|
|
950
|
+
if (mt['w:r']) {
|
|
951
|
+
const mtRuns = Array.isArray(mt['w:r']) ? mt['w:r'] : [mt['w:r']];
|
|
952
|
+
allRuns.push(...mtRuns);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
flattenedObj['w:r'] = allRuns.length > 0 ? allRuns : undefined;
|
|
957
|
+
delete flattenedObj['w:del'];
|
|
958
|
+
delete flattenedObj['w:ins'];
|
|
959
|
+
delete flattenedObj['w:moveFrom'];
|
|
960
|
+
delete flattenedObj['w:moveTo'];
|
|
961
|
+
const result = this.parseHyperlinkFromObject(flattenedObj, relationshipManager);
|
|
962
|
+
if (result.hyperlink) {
|
|
963
|
+
paragraph.addHyperlink(result.hyperlink);
|
|
964
|
+
}
|
|
965
|
+
for (const bookmark of result.bookmarkStarts) {
|
|
966
|
+
paragraph.addBookmarkStart(bookmark);
|
|
967
|
+
}
|
|
968
|
+
for (const bookmark of result.bookmarkEnds) {
|
|
969
|
+
paragraph.addBookmarkEnd(bookmark);
|
|
924
970
|
}
|
|
925
971
|
}
|
|
926
972
|
else {
|
|
@@ -1286,10 +1332,14 @@ class DocumentParser {
|
|
|
1286
1332
|
return null;
|
|
1287
1333
|
}
|
|
1288
1334
|
const id = parseInt(idAttr, 10);
|
|
1335
|
+
const colFirstAttr = XMLParser_1.XMLParser.extractAttribute(bookmarkXml, 'w:colFirst');
|
|
1336
|
+
const colLastAttr = XMLParser_1.XMLParser.extractAttribute(bookmarkXml, 'w:colLast');
|
|
1289
1337
|
const bookmark = new Bookmark_1.Bookmark({
|
|
1290
1338
|
name: nameAttr,
|
|
1291
1339
|
id: id,
|
|
1292
1340
|
skipNormalization: true,
|
|
1341
|
+
colFirst: colFirstAttr ? parseInt(colFirstAttr, 10) : undefined,
|
|
1342
|
+
colLast: colLastAttr ? parseInt(colLastAttr, 10) : undefined,
|
|
1293
1343
|
});
|
|
1294
1344
|
if (this.bookmarkManager) {
|
|
1295
1345
|
try {
|
|
@@ -1335,6 +1385,10 @@ class DocumentParser {
|
|
|
1335
1385
|
if (paraId) {
|
|
1336
1386
|
paragraph.formatting.paraId = paraId;
|
|
1337
1387
|
}
|
|
1388
|
+
const textId = paraObj['w14:textId'];
|
|
1389
|
+
if (textId) {
|
|
1390
|
+
paragraph.formatting.textId = textId;
|
|
1391
|
+
}
|
|
1338
1392
|
this.parseParagraphPropertiesFromObject(paraObj['w:pPr'], paragraph);
|
|
1339
1393
|
const orderedChildren = paraObj._orderedChildren;
|
|
1340
1394
|
if (orderedChildren && orderedChildren.length > 0) {
|
|
@@ -1493,10 +1547,12 @@ class DocumentParser {
|
|
|
1493
1547
|
}
|
|
1494
1548
|
if (pPrObj['w:ind']) {
|
|
1495
1549
|
const ind = pPrObj['w:ind'];
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
if ((0, parsingHelpers_1.isExplicitlySet)(
|
|
1499
|
-
paragraph.
|
|
1550
|
+
const leftVal = ind['@_w:start'] ?? ind['@_w:left'];
|
|
1551
|
+
const rightVal = ind['@_w:end'] ?? ind['@_w:right'];
|
|
1552
|
+
if ((0, parsingHelpers_1.isExplicitlySet)(leftVal))
|
|
1553
|
+
paragraph.setLeftIndent((0, parsingHelpers_1.safeParseInt)(leftVal));
|
|
1554
|
+
if ((0, parsingHelpers_1.isExplicitlySet)(rightVal))
|
|
1555
|
+
paragraph.setRightIndent((0, parsingHelpers_1.safeParseInt)(rightVal));
|
|
1500
1556
|
if ((0, parsingHelpers_1.isExplicitlySet)(ind['@_w:firstLine']))
|
|
1501
1557
|
paragraph.setFirstLineIndent((0, parsingHelpers_1.safeParseInt)(ind['@_w:firstLine']));
|
|
1502
1558
|
if ((0, parsingHelpers_1.isExplicitlySet)(ind['@_w:hanging']))
|
|
@@ -1511,15 +1567,33 @@ class DocumentParser {
|
|
|
1511
1567
|
if ((0, parsingHelpers_1.isExplicitlySet)(spacing['@_w:line'])) {
|
|
1512
1568
|
paragraph.setLineSpacing((0, parsingHelpers_1.safeParseInt)(spacing['@_w:line']), spacing['@_w:lineRule']);
|
|
1513
1569
|
}
|
|
1570
|
+
if (!paragraph.formatting.spacing)
|
|
1571
|
+
paragraph.formatting.spacing = {};
|
|
1572
|
+
if ((0, parsingHelpers_1.isExplicitlySet)(spacing['@_w:beforeLines']))
|
|
1573
|
+
paragraph.formatting.spacing.beforeLines = (0, parsingHelpers_1.safeParseInt)(spacing['@_w:beforeLines']);
|
|
1574
|
+
if ((0, parsingHelpers_1.isExplicitlySet)(spacing['@_w:afterLines']))
|
|
1575
|
+
paragraph.formatting.spacing.afterLines = (0, parsingHelpers_1.safeParseInt)(spacing['@_w:afterLines']);
|
|
1576
|
+
const beforeAuto = spacing['@_w:beforeAutospacing'];
|
|
1577
|
+
if (beforeAuto !== undefined)
|
|
1578
|
+
paragraph.formatting.spacing.beforeAutospacing =
|
|
1579
|
+
String(beforeAuto) === '1' || String(beforeAuto) === 'true';
|
|
1580
|
+
const afterAuto = spacing['@_w:afterAutospacing'];
|
|
1581
|
+
if (afterAuto !== undefined)
|
|
1582
|
+
paragraph.formatting.spacing.afterAutospacing =
|
|
1583
|
+
String(afterAuto) === '1' || String(afterAuto) === 'true';
|
|
1584
|
+
}
|
|
1585
|
+
if (pPrObj['w:pageBreakBefore'] !== undefined) {
|
|
1586
|
+
paragraph.formatting.pageBreakBefore = (0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj['w:pageBreakBefore']);
|
|
1587
|
+
}
|
|
1588
|
+
if (pPrObj['w:keepNext'] !== undefined) {
|
|
1589
|
+
paragraph.setKeepNext((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj['w:keepNext']));
|
|
1590
|
+
}
|
|
1591
|
+
if (pPrObj['w:keepLines'] !== undefined) {
|
|
1592
|
+
paragraph.setKeepLines((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj['w:keepLines']));
|
|
1593
|
+
}
|
|
1594
|
+
if (pPrObj['w:contextualSpacing'] !== undefined) {
|
|
1595
|
+
paragraph.setContextualSpacing((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj['w:contextualSpacing']));
|
|
1514
1596
|
}
|
|
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
1597
|
if (pPrObj['w:numPr']) {
|
|
1524
1598
|
const numPrRaw = pPrObj['w:numPr'];
|
|
1525
1599
|
const numPr = Array.isArray(numPrRaw) ? numPrRaw[0] : numPrRaw;
|
|
@@ -1619,8 +1693,8 @@ class DocumentParser {
|
|
|
1619
1693
|
paragraph.setOutlineLevel(level);
|
|
1620
1694
|
}
|
|
1621
1695
|
}
|
|
1622
|
-
if (pPrObj['w:suppressLineNumbers']) {
|
|
1623
|
-
paragraph.setSuppressLineNumbers(
|
|
1696
|
+
if (pPrObj['w:suppressLineNumbers'] !== undefined) {
|
|
1697
|
+
paragraph.setSuppressLineNumbers((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj['w:suppressLineNumbers']));
|
|
1624
1698
|
}
|
|
1625
1699
|
if (pPrObj['w:bidi'] !== undefined) {
|
|
1626
1700
|
const bidiVal = pPrObj['w:bidi']?.['@_w:val'];
|
|
@@ -1637,8 +1711,8 @@ class DocumentParser {
|
|
|
1637
1711
|
if (pPrObj['w:textAlignment']?.['@_w:val']) {
|
|
1638
1712
|
paragraph.setTextAlignment(pPrObj['w:textAlignment']['@_w:val']);
|
|
1639
1713
|
}
|
|
1640
|
-
if (pPrObj['w:mirrorIndents']) {
|
|
1641
|
-
paragraph.setMirrorIndents(
|
|
1714
|
+
if (pPrObj['w:mirrorIndents'] !== undefined) {
|
|
1715
|
+
paragraph.setMirrorIndents((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj['w:mirrorIndents']));
|
|
1642
1716
|
}
|
|
1643
1717
|
if (pPrObj['w:adjustRightInd'] !== undefined) {
|
|
1644
1718
|
const adjustRightIndVal = pPrObj['w:adjustRightInd']?.['@_w:val'];
|
|
@@ -1692,8 +1766,8 @@ class DocumentParser {
|
|
|
1692
1766
|
paragraph.setFrameProperties(frameProps);
|
|
1693
1767
|
}
|
|
1694
1768
|
}
|
|
1695
|
-
if (pPrObj['w:suppressAutoHyphens']) {
|
|
1696
|
-
paragraph.setSuppressAutoHyphens(
|
|
1769
|
+
if (pPrObj['w:suppressAutoHyphens'] !== undefined) {
|
|
1770
|
+
paragraph.setSuppressAutoHyphens((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj['w:suppressAutoHyphens']));
|
|
1697
1771
|
}
|
|
1698
1772
|
if (pPrObj['w:kinsoku']) {
|
|
1699
1773
|
paragraph.setKinsoku((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj['w:kinsoku']));
|
|
@@ -1713,8 +1787,8 @@ class DocumentParser {
|
|
|
1713
1787
|
if (pPrObj['w:autoSpaceDN']) {
|
|
1714
1788
|
paragraph.setAutoSpaceDN((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj['w:autoSpaceDN']));
|
|
1715
1789
|
}
|
|
1716
|
-
if (pPrObj['w:suppressOverlap']) {
|
|
1717
|
-
paragraph.setSuppressOverlap(
|
|
1790
|
+
if (pPrObj['w:suppressOverlap'] !== undefined) {
|
|
1791
|
+
paragraph.setSuppressOverlap((0, parsingHelpers_1.parseOoxmlBoolean)(pPrObj['w:suppressOverlap']));
|
|
1718
1792
|
}
|
|
1719
1793
|
if (pPrObj['w:textboxTightWrap']) {
|
|
1720
1794
|
const wrapVal = pPrObj['w:textboxTightWrap']?.['@_w:val'];
|
|
@@ -1769,10 +1843,12 @@ class DocumentParser {
|
|
|
1769
1843
|
if (prevPPr['w:ind']) {
|
|
1770
1844
|
const ind = prevPPr['w:ind'];
|
|
1771
1845
|
previousProperties.indentation = {};
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
if (
|
|
1775
|
-
previousProperties.indentation.
|
|
1846
|
+
const leftVal = ind['@_w:start'] ?? ind['@_w:left'];
|
|
1847
|
+
const rightVal = ind['@_w:end'] ?? ind['@_w:right'];
|
|
1848
|
+
if (leftVal !== undefined)
|
|
1849
|
+
previousProperties.indentation.left = parseInt(leftVal, 10);
|
|
1850
|
+
if (rightVal !== undefined)
|
|
1851
|
+
previousProperties.indentation.right = parseInt(rightVal, 10);
|
|
1776
1852
|
if (ind['@_w:firstLine'] !== undefined)
|
|
1777
1853
|
previousProperties.indentation.firstLine = parseInt(ind['@_w:firstLine'], 10);
|
|
1778
1854
|
if (ind['@_w:hanging'] !== undefined)
|
|
@@ -1792,6 +1868,18 @@ class DocumentParser {
|
|
|
1792
1868
|
previousProperties.spacing.line = parseInt(spacing['@_w:line'], 10);
|
|
1793
1869
|
if (spacing['@_w:lineRule'])
|
|
1794
1870
|
previousProperties.spacing.lineRule = String(spacing['@_w:lineRule']);
|
|
1871
|
+
if (spacing['@_w:beforeLines'] !== undefined)
|
|
1872
|
+
previousProperties.spacing.beforeLines = parseInt(spacing['@_w:beforeLines'], 10);
|
|
1873
|
+
if (spacing['@_w:afterLines'] !== undefined)
|
|
1874
|
+
previousProperties.spacing.afterLines = parseInt(spacing['@_w:afterLines'], 10);
|
|
1875
|
+
const beforeAuto = spacing['@_w:beforeAutospacing'];
|
|
1876
|
+
if (beforeAuto !== undefined)
|
|
1877
|
+
previousProperties.spacing.beforeAutospacing =
|
|
1878
|
+
String(beforeAuto) === '1' || String(beforeAuto) === 'true';
|
|
1879
|
+
const afterAuto = spacing['@_w:afterAutospacing'];
|
|
1880
|
+
if (afterAuto !== undefined)
|
|
1881
|
+
previousProperties.spacing.afterAutospacing =
|
|
1882
|
+
String(afterAuto) === '1' || String(afterAuto) === 'true';
|
|
1795
1883
|
}
|
|
1796
1884
|
if (prevPPr['w:keepNext']) {
|
|
1797
1885
|
previousProperties.keepNext = prevPPr['w:keepNext']['@_w:val'] !== '0';
|
|
@@ -2876,7 +2964,8 @@ class DocumentParser {
|
|
|
2876
2964
|
const brElements = toArray(runObj['w:br']);
|
|
2877
2965
|
const brElement = brElements[elementIndex] || brElements[0];
|
|
2878
2966
|
const breakType = brElement?.['@_w:type'];
|
|
2879
|
-
|
|
2967
|
+
const breakClear = brElement?.['@_w:clear'];
|
|
2968
|
+
content.push({ type: 'break', breakType, breakClear });
|
|
2880
2969
|
break;
|
|
2881
2970
|
}
|
|
2882
2971
|
case 'w:cr':
|
|
@@ -3044,7 +3133,8 @@ class DocumentParser {
|
|
|
3044
3133
|
if (runObj['w:br'] !== undefined) {
|
|
3045
3134
|
const brElement = runObj['w:br'];
|
|
3046
3135
|
const breakType = brElement?.['@_w:type'];
|
|
3047
|
-
|
|
3136
|
+
const breakClear = brElement?.['@_w:clear'];
|
|
3137
|
+
content.push({ type: 'break', breakType, breakClear });
|
|
3048
3138
|
}
|
|
3049
3139
|
if (runObj['w:cr'] !== undefined) {
|
|
3050
3140
|
content.push({ type: 'carriageReturn' });
|
|
@@ -3239,14 +3329,8 @@ class DocumentParser {
|
|
|
3239
3329
|
}
|
|
3240
3330
|
}
|
|
3241
3331
|
}
|
|
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
|
-
}
|
|
3332
|
+
const finalAnchor = anchor;
|
|
3333
|
+
const finalRelationshipId = relationshipId;
|
|
3250
3334
|
if (!url && !finalAnchor && !finalRelationshipId) {
|
|
3251
3335
|
logger_1.defaultLogger.debug(`[DocumentParser] Skipping hyperlink with no URL, anchor, or relationship ID. Text: "${text}"`);
|
|
3252
3336
|
return result;
|
|
@@ -3464,41 +3548,42 @@ class DocumentParser {
|
|
|
3464
3548
|
if (val)
|
|
3465
3549
|
run.setEmphasis(val);
|
|
3466
3550
|
}
|
|
3467
|
-
if (rPrObj['w:outline'])
|
|
3551
|
+
if ((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:outline']))
|
|
3468
3552
|
run.setOutline(true);
|
|
3469
|
-
if (rPrObj['w:shadow'])
|
|
3553
|
+
if ((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:shadow']))
|
|
3470
3554
|
run.setShadow(true);
|
|
3471
|
-
if (rPrObj['w:emboss'])
|
|
3555
|
+
if ((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:emboss']))
|
|
3472
3556
|
run.setEmboss(true);
|
|
3473
|
-
if (rPrObj['w:imprint'])
|
|
3557
|
+
if ((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:imprint']))
|
|
3474
3558
|
run.setImprint(true);
|
|
3475
|
-
if (rPrObj['w:noProof'])
|
|
3559
|
+
if ((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:noProof']))
|
|
3476
3560
|
run.setNoProof(true);
|
|
3477
|
-
if (rPrObj['w:snapToGrid'])
|
|
3478
|
-
run.setSnapToGrid(
|
|
3479
|
-
|
|
3561
|
+
if (rPrObj['w:snapToGrid'] !== undefined) {
|
|
3562
|
+
run.setSnapToGrid((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:snapToGrid']));
|
|
3563
|
+
}
|
|
3564
|
+
if ((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:vanish']))
|
|
3480
3565
|
run.setVanish(true);
|
|
3481
|
-
if (rPrObj['w:specVanish'])
|
|
3566
|
+
if ((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:specVanish']))
|
|
3482
3567
|
run.setSpecVanish(true);
|
|
3483
3568
|
if ((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:rtl']))
|
|
3484
3569
|
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(
|
|
3570
|
+
if (rPrObj['w:b'] !== undefined)
|
|
3571
|
+
run.setBold((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:b']));
|
|
3572
|
+
if (rPrObj['w:bCs'] !== undefined)
|
|
3573
|
+
run.setComplexScriptBold((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:bCs']));
|
|
3574
|
+
if (rPrObj['w:i'] !== undefined)
|
|
3575
|
+
run.setItalic((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:i']));
|
|
3576
|
+
if (rPrObj['w:iCs'] !== undefined)
|
|
3577
|
+
run.setComplexScriptItalic((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:iCs']));
|
|
3578
|
+
if (rPrObj['w:strike'] !== undefined)
|
|
3579
|
+
run.setStrike((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:strike']));
|
|
3580
|
+
if (rPrObj['w:dstrike'] !== undefined) {
|
|
3581
|
+
run.formatting.dstrike = (0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:dstrike']);
|
|
3582
|
+
}
|
|
3583
|
+
if (rPrObj['w:smallCaps'] !== undefined)
|
|
3584
|
+
run.setSmallCaps((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:smallCaps']));
|
|
3585
|
+
if (rPrObj['w:caps'] !== undefined)
|
|
3586
|
+
run.setAllCaps((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:caps']));
|
|
3502
3587
|
if ((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:cs']))
|
|
3503
3588
|
run.setComplexScript(true);
|
|
3504
3589
|
if ((0, parsingHelpers_1.parseOoxmlBoolean)(rPrObj['w:webHidden']))
|
|
@@ -3536,9 +3621,20 @@ class DocumentParser {
|
|
|
3536
3621
|
run.setKerning(parseInt(val, 10));
|
|
3537
3622
|
}
|
|
3538
3623
|
if (rPrObj['w:lang']) {
|
|
3539
|
-
const
|
|
3540
|
-
|
|
3541
|
-
|
|
3624
|
+
const langObj = rPrObj['w:lang'];
|
|
3625
|
+
const val = langObj['@_w:val'];
|
|
3626
|
+
const eastAsia = langObj['@_w:eastAsia'];
|
|
3627
|
+
const bidi = langObj['@_w:bidi'];
|
|
3628
|
+
if (eastAsia || bidi) {
|
|
3629
|
+
run.setLanguage({
|
|
3630
|
+
val: val ? String(val) : undefined,
|
|
3631
|
+
eastAsia: eastAsia ? String(eastAsia) : undefined,
|
|
3632
|
+
bidi: bidi ? String(bidi) : undefined,
|
|
3633
|
+
});
|
|
3634
|
+
}
|
|
3635
|
+
else if (val) {
|
|
3636
|
+
run.setLanguage(String(val));
|
|
3637
|
+
}
|
|
3542
3638
|
}
|
|
3543
3639
|
if (rPrObj['w:eastAsianLayout']) {
|
|
3544
3640
|
const layoutObj = rPrObj['w:eastAsianLayout'];
|
|
@@ -3571,8 +3667,10 @@ class DocumentParser {
|
|
|
3571
3667
|
const val = rPrObj['w:vertAlign']['@_w:val'];
|
|
3572
3668
|
if (val === 'subscript')
|
|
3573
3669
|
run.setSubscript(true);
|
|
3574
|
-
if (val === 'superscript')
|
|
3670
|
+
else if (val === 'superscript')
|
|
3575
3671
|
run.setSuperscript(true);
|
|
3672
|
+
else if (val === 'baseline')
|
|
3673
|
+
run.formatting.vertAlignBaseline = true;
|
|
3576
3674
|
}
|
|
3577
3675
|
if (rPrObj['w:rFonts']) {
|
|
3578
3676
|
const rFonts = rPrObj['w:rFonts'];
|
|
@@ -3610,8 +3708,13 @@ class DocumentParser {
|
|
|
3610
3708
|
if (rPrObj['w:color']) {
|
|
3611
3709
|
const colorObj = rPrObj['w:color'];
|
|
3612
3710
|
const colorVal = colorObj['@_w:val'];
|
|
3613
|
-
if (colorVal
|
|
3614
|
-
|
|
3711
|
+
if (colorVal) {
|
|
3712
|
+
if (colorVal === 'auto') {
|
|
3713
|
+
run.formatting.color = 'auto';
|
|
3714
|
+
}
|
|
3715
|
+
else {
|
|
3716
|
+
run.setColor(colorVal);
|
|
3717
|
+
}
|
|
3615
3718
|
}
|
|
3616
3719
|
if (colorObj['@_w:themeColor']) {
|
|
3617
3720
|
run.setThemeColor(colorObj['@_w:themeColor']);
|
|
@@ -3683,7 +3786,7 @@ class DocumentParser {
|
|
|
3683
3786
|
if (prevRPr['w:color']) {
|
|
3684
3787
|
const colorObj = prevRPr['w:color'];
|
|
3685
3788
|
const colorVal = colorObj['@_w:val'];
|
|
3686
|
-
if (colorVal
|
|
3789
|
+
if (colorVal) {
|
|
3687
3790
|
prevProps.color = colorVal;
|
|
3688
3791
|
}
|
|
3689
3792
|
if (colorObj['@_w:themeColor']) {
|
|
@@ -3703,8 +3806,10 @@ class DocumentParser {
|
|
|
3703
3806
|
const val = prevRPr['w:vertAlign']['@_w:val'];
|
|
3704
3807
|
if (val === 'subscript')
|
|
3705
3808
|
prevProps.subscript = true;
|
|
3706
|
-
if (val === 'superscript')
|
|
3809
|
+
else if (val === 'superscript')
|
|
3707
3810
|
prevProps.superscript = true;
|
|
3811
|
+
else if (val === 'baseline')
|
|
3812
|
+
prevProps.vertAlignBaseline = true;
|
|
3708
3813
|
}
|
|
3709
3814
|
if (prevRPr['w:smallCaps']) {
|
|
3710
3815
|
prevProps.smallCaps = (0, parsingHelpers_1.parseOoxmlBoolean)(prevRPr['w:smallCaps']);
|
|
@@ -3779,8 +3884,18 @@ class DocumentParser {
|
|
|
3779
3884
|
}
|
|
3780
3885
|
}
|
|
3781
3886
|
if (prevRPr['w:lang']) {
|
|
3782
|
-
const
|
|
3783
|
-
|
|
3887
|
+
const langObj = prevRPr['w:lang'];
|
|
3888
|
+
const langVal = langObj['@_w:val'];
|
|
3889
|
+
const langEastAsia = langObj['@_w:eastAsia'];
|
|
3890
|
+
const langBidi = langObj['@_w:bidi'];
|
|
3891
|
+
if (langEastAsia || langBidi) {
|
|
3892
|
+
prevProps.language = {
|
|
3893
|
+
val: langVal ? String(langVal) : undefined,
|
|
3894
|
+
eastAsia: langEastAsia ? String(langEastAsia) : undefined,
|
|
3895
|
+
bidi: langBidi ? String(langBidi) : undefined,
|
|
3896
|
+
};
|
|
3897
|
+
}
|
|
3898
|
+
else if (langVal) {
|
|
3784
3899
|
prevProps.language = String(langVal);
|
|
3785
3900
|
}
|
|
3786
3901
|
}
|
|
@@ -4481,6 +4596,18 @@ class DocumentParser {
|
|
|
4481
4596
|
table.setTableGrid(widths);
|
|
4482
4597
|
}
|
|
4483
4598
|
}
|
|
4599
|
+
if (tableObj['w:tblGrid']?.['w:tblGridChange']) {
|
|
4600
|
+
const changeObj = tableObj['w:tblGrid']['w:tblGridChange'];
|
|
4601
|
+
const prevGridCols = changeObj['w:tblGrid']?.['w:gridCol'];
|
|
4602
|
+
if (prevGridCols) {
|
|
4603
|
+
const prevArray = Array.isArray(prevGridCols) ? prevGridCols : [prevGridCols];
|
|
4604
|
+
const prevWidths = prevArray.map((col) => ({
|
|
4605
|
+
width: (0, parsingHelpers_1.isExplicitlySet)(col['@_w:w']) ? (0, parsingHelpers_1.safeParseInt)(col['@_w:w'], 2880) : 2880,
|
|
4606
|
+
}));
|
|
4607
|
+
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);
|
|
4608
|
+
table.setTblGridChange(gridChange);
|
|
4609
|
+
}
|
|
4610
|
+
}
|
|
4484
4611
|
const rows = tableObj['w:tr'];
|
|
4485
4612
|
const rowChildren = Array.isArray(rows) ? rows : rows ? [rows] : [];
|
|
4486
4613
|
let rowXmls = [];
|
|
@@ -4637,6 +4764,10 @@ class DocumentParser {
|
|
|
4637
4764
|
if (tblPrObj['w:tblInd']) {
|
|
4638
4765
|
const indentVal = (0, parsingHelpers_1.safeParseInt)(tblPrObj['w:tblInd']['@_w:w'], 0);
|
|
4639
4766
|
table.setIndent(indentVal);
|
|
4767
|
+
const indentType = tblPrObj['w:tblInd']['@_w:type'];
|
|
4768
|
+
if (indentType) {
|
|
4769
|
+
table.setIndentType(indentType);
|
|
4770
|
+
}
|
|
4640
4771
|
}
|
|
4641
4772
|
if (tblPrObj['w:tblCellMar']) {
|
|
4642
4773
|
const cellMar = tblPrObj['w:tblCellMar'];
|
|
@@ -4651,13 +4782,15 @@ class DocumentParser {
|
|
|
4651
4782
|
if (w !== undefined)
|
|
4652
4783
|
margins.bottom = parseInt(w, 10);
|
|
4653
4784
|
}
|
|
4654
|
-
|
|
4655
|
-
|
|
4785
|
+
const leftSource = cellMar['w:start'] || cellMar['w:left'];
|
|
4786
|
+
if (leftSource) {
|
|
4787
|
+
const w = leftSource['@_w:w'];
|
|
4656
4788
|
if (w !== undefined)
|
|
4657
4789
|
margins.left = parseInt(w, 10);
|
|
4658
4790
|
}
|
|
4659
|
-
|
|
4660
|
-
|
|
4791
|
+
const rightSource = cellMar['w:end'] || cellMar['w:right'];
|
|
4792
|
+
if (rightSource) {
|
|
4793
|
+
const w = rightSource['@_w:w'];
|
|
4661
4794
|
if (w !== undefined)
|
|
4662
4795
|
margins.right = parseInt(w, 10);
|
|
4663
4796
|
}
|
|
@@ -4760,9 +4893,15 @@ class DocumentParser {
|
|
|
4760
4893
|
return;
|
|
4761
4894
|
if (trPrObj['w:trHeight']) {
|
|
4762
4895
|
const heightVal = parseInt(trPrObj['w:trHeight']['@_w:val'] || '0', 10);
|
|
4763
|
-
const heightRule = trPrObj['w:trHeight']['@_w:hRule']
|
|
4896
|
+
const heightRule = trPrObj['w:trHeight']['@_w:hRule'];
|
|
4764
4897
|
if (heightVal > 0) {
|
|
4765
|
-
row.setHeight(heightVal
|
|
4898
|
+
row.setHeight(heightVal);
|
|
4899
|
+
if (heightRule) {
|
|
4900
|
+
row.setHeightRule(heightRule);
|
|
4901
|
+
}
|
|
4902
|
+
else {
|
|
4903
|
+
row.setHeightRule(undefined);
|
|
4904
|
+
}
|
|
4766
4905
|
}
|
|
4767
4906
|
}
|
|
4768
4907
|
if (trPrObj['w:tblHeader']) {
|
|
@@ -4948,11 +5087,13 @@ class DocumentParser {
|
|
|
4948
5087
|
if (tcMar['w:bottom']) {
|
|
4949
5088
|
margins.bottom = parseInt(tcMar['w:bottom']['@_w:w'] || '0', 10);
|
|
4950
5089
|
}
|
|
4951
|
-
|
|
4952
|
-
|
|
5090
|
+
const leftSrc = tcMar['w:start'] || tcMar['w:left'];
|
|
5091
|
+
if (leftSrc) {
|
|
5092
|
+
margins.left = parseInt(leftSrc['@_w:w'] || '0', 10);
|
|
4953
5093
|
}
|
|
4954
|
-
|
|
4955
|
-
|
|
5094
|
+
const rightSrc = tcMar['w:end'] || tcMar['w:right'];
|
|
5095
|
+
if (rightSrc) {
|
|
5096
|
+
margins.right = parseInt(rightSrc['@_w:w'] || '0', 10);
|
|
4956
5097
|
}
|
|
4957
5098
|
if (Object.keys(margins).length > 0) {
|
|
4958
5099
|
cell.setMargins(margins);
|
|
@@ -5584,7 +5725,7 @@ class DocumentParser {
|
|
|
5584
5725
|
logger_1.defaultLogger.debug(`[TOC Parser] Normalized field instruction from "${instruction}" to "${normalized}"`);
|
|
5585
5726
|
return normalized;
|
|
5586
5727
|
}
|
|
5587
|
-
parseTOCFromSDTContent(content,
|
|
5728
|
+
parseTOCFromSDTContent(content, _properties, sdtContent) {
|
|
5588
5729
|
try {
|
|
5589
5730
|
let title;
|
|
5590
5731
|
let fieldInstruction;
|
|
@@ -5966,11 +6107,13 @@ class DocumentParser {
|
|
|
5966
6107
|
const width = XMLParser_1.XMLParser.extractAttribute(pgSz, 'w:w');
|
|
5967
6108
|
const height = XMLParser_1.XMLParser.extractAttribute(pgSz, 'w:h');
|
|
5968
6109
|
const orient = XMLParser_1.XMLParser.extractAttribute(pgSz, 'w:orient');
|
|
6110
|
+
const code = XMLParser_1.XMLParser.extractAttribute(pgSz, 'w:code');
|
|
5969
6111
|
if (width && height) {
|
|
5970
6112
|
sectionProps.pageSize = {
|
|
5971
6113
|
width: parseInt(width, 10),
|
|
5972
6114
|
height: parseInt(height, 10),
|
|
5973
6115
|
orientation: orient === 'landscape' ? 'landscape' : 'portrait',
|
|
6116
|
+
code: code ? parseInt(code, 10) : undefined,
|
|
5974
6117
|
};
|
|
5975
6118
|
}
|
|
5976
6119
|
}
|
|
@@ -6067,11 +6210,21 @@ class DocumentParser {
|
|
|
6067
6210
|
const sep = XMLParser_1.XMLParser.extractAttribute(cols, 'w:sep');
|
|
6068
6211
|
const colElements = XMLParser_1.XMLParser.extractElements(cols, 'w:col');
|
|
6069
6212
|
const columnWidths = [];
|
|
6213
|
+
const columnSpaces = [];
|
|
6214
|
+
let hasColumnSpaces = false;
|
|
6070
6215
|
for (const col of colElements) {
|
|
6071
6216
|
const width = XMLParser_1.XMLParser.extractAttribute(col, 'w:w');
|
|
6072
6217
|
if (width) {
|
|
6073
6218
|
columnWidths.push(parseInt(width.toString(), 10));
|
|
6074
6219
|
}
|
|
6220
|
+
const colSpace = XMLParser_1.XMLParser.extractAttribute(col, 'w:space');
|
|
6221
|
+
if (colSpace) {
|
|
6222
|
+
columnSpaces.push(parseInt(colSpace.toString(), 10));
|
|
6223
|
+
hasColumnSpaces = true;
|
|
6224
|
+
}
|
|
6225
|
+
else {
|
|
6226
|
+
columnSpaces.push(0);
|
|
6227
|
+
}
|
|
6075
6228
|
}
|
|
6076
6229
|
const toBool = (val) => val === '1' || val === 1 || val === 'true' || val === true;
|
|
6077
6230
|
if (num) {
|
|
@@ -6081,6 +6234,7 @@ class DocumentParser {
|
|
|
6081
6234
|
equalWidth: equalWidth ? toBool(equalWidth) : undefined,
|
|
6082
6235
|
separator: sep ? toBool(sep) : undefined,
|
|
6083
6236
|
columnWidths: columnWidths.length > 0 ? columnWidths : undefined,
|
|
6237
|
+
columnSpaces: hasColumnSpaces ? columnSpaces : undefined,
|
|
6084
6238
|
};
|
|
6085
6239
|
}
|
|
6086
6240
|
}
|
|
@@ -6445,10 +6599,15 @@ class DocumentParser {
|
|
|
6445
6599
|
}
|
|
6446
6600
|
const spacingElement = XMLParser_1.XMLParser.extractSelfClosingTag(pPrXml, 'w:spacing');
|
|
6447
6601
|
if (spacingElement) {
|
|
6448
|
-
const
|
|
6449
|
-
const
|
|
6450
|
-
const
|
|
6451
|
-
const
|
|
6602
|
+
const spacingTag = `<w:spacing${spacingElement}`;
|
|
6603
|
+
const before = XMLParser_1.XMLParser.extractAttribute(spacingTag, 'w:before');
|
|
6604
|
+
const after = XMLParser_1.XMLParser.extractAttribute(spacingTag, 'w:after');
|
|
6605
|
+
const line = XMLParser_1.XMLParser.extractAttribute(spacingTag, 'w:line');
|
|
6606
|
+
const lineRule = XMLParser_1.XMLParser.extractAttribute(spacingTag, 'w:lineRule');
|
|
6607
|
+
const beforeLines = XMLParser_1.XMLParser.extractAttribute(spacingTag, 'w:beforeLines');
|
|
6608
|
+
const afterLines = XMLParser_1.XMLParser.extractAttribute(spacingTag, 'w:afterLines');
|
|
6609
|
+
const beforeAutosp = XMLParser_1.XMLParser.extractAttribute(spacingTag, 'w:beforeAutospacing');
|
|
6610
|
+
const afterAutosp = XMLParser_1.XMLParser.extractAttribute(spacingTag, 'w:afterAutospacing');
|
|
6452
6611
|
let validatedLineRule;
|
|
6453
6612
|
if (lineRule) {
|
|
6454
6613
|
const validLineRules = ['auto', 'exact', 'atLeast'];
|
|
@@ -6461,17 +6620,28 @@ class DocumentParser {
|
|
|
6461
6620
|
after: after ? parseInt(after, 10) : undefined,
|
|
6462
6621
|
line: line ? parseInt(line, 10) : validatedLineRule ? 240 : undefined,
|
|
6463
6622
|
lineRule: validatedLineRule,
|
|
6623
|
+
beforeLines: beforeLines ? parseInt(beforeLines, 10) : undefined,
|
|
6624
|
+
afterLines: afterLines ? parseInt(afterLines, 10) : undefined,
|
|
6625
|
+
beforeAutospacing: beforeAutosp
|
|
6626
|
+
? beforeAutosp === '1' || beforeAutosp === 'true'
|
|
6627
|
+
: undefined,
|
|
6628
|
+
afterAutospacing: afterAutosp ? afterAutosp === '1' || afterAutosp === 'true' : undefined,
|
|
6464
6629
|
};
|
|
6465
6630
|
}
|
|
6466
6631
|
const indElement = XMLParser_1.XMLParser.extractSelfClosingTag(pPrXml, 'w:ind');
|
|
6467
6632
|
if (indElement) {
|
|
6468
|
-
const
|
|
6469
|
-
const
|
|
6470
|
-
const
|
|
6471
|
-
const
|
|
6633
|
+
const indTag = `<w:ind${indElement}`;
|
|
6634
|
+
const start = XMLParser_1.XMLParser.extractAttribute(indTag, 'w:start');
|
|
6635
|
+
const left = XMLParser_1.XMLParser.extractAttribute(indTag, 'w:left');
|
|
6636
|
+
const end = XMLParser_1.XMLParser.extractAttribute(indTag, 'w:end');
|
|
6637
|
+
const right = XMLParser_1.XMLParser.extractAttribute(indTag, 'w:right');
|
|
6638
|
+
const firstLine = XMLParser_1.XMLParser.extractAttribute(indTag, 'w:firstLine');
|
|
6639
|
+
const hanging = XMLParser_1.XMLParser.extractAttribute(indTag, 'w:hanging');
|
|
6640
|
+
const leftVal = start || left;
|
|
6641
|
+
const rightVal = end || right;
|
|
6472
6642
|
formatting.indentation = {
|
|
6473
|
-
left:
|
|
6474
|
-
right:
|
|
6643
|
+
left: leftVal ? parseInt(leftVal, 10) : undefined,
|
|
6644
|
+
right: rightVal ? parseInt(rightVal, 10) : undefined,
|
|
6475
6645
|
firstLine: firstLine ? parseInt(firstLine, 10) : undefined,
|
|
6476
6646
|
hanging: hanging ? parseInt(hanging, 10) : undefined,
|
|
6477
6647
|
};
|
|
@@ -6498,6 +6668,58 @@ class DocumentParser {
|
|
|
6498
6668
|
}
|
|
6499
6669
|
}
|
|
6500
6670
|
}
|
|
6671
|
+
const pBdrXml = XMLParser_1.XMLParser.extractBetweenTags(pPrXml, '<w:pBdr>', '</w:pBdr>');
|
|
6672
|
+
if (pBdrXml) {
|
|
6673
|
+
const borders = {};
|
|
6674
|
+
const borderTypes = ['top', 'left', 'bottom', 'right', 'between', 'bar'];
|
|
6675
|
+
for (const type of borderTypes) {
|
|
6676
|
+
if (pBdrXml.includes(`<w:${type}`)) {
|
|
6677
|
+
const tag = XMLParser_1.XMLParser.extractSelfClosingTag(pBdrXml, `w:${type}`);
|
|
6678
|
+
if (tag) {
|
|
6679
|
+
const bTag = `<w:${type}${tag}`;
|
|
6680
|
+
const style = XMLParser_1.XMLParser.extractAttribute(bTag, 'w:val');
|
|
6681
|
+
const size = XMLParser_1.XMLParser.extractAttribute(bTag, 'w:sz');
|
|
6682
|
+
const space = XMLParser_1.XMLParser.extractAttribute(bTag, 'w:space');
|
|
6683
|
+
const color = XMLParser_1.XMLParser.extractAttribute(bTag, 'w:color');
|
|
6684
|
+
const border = {};
|
|
6685
|
+
if (style)
|
|
6686
|
+
border.style = style;
|
|
6687
|
+
if (size)
|
|
6688
|
+
border.size = parseInt(size, 10);
|
|
6689
|
+
if (space)
|
|
6690
|
+
border.space = parseInt(space, 10);
|
|
6691
|
+
if (color)
|
|
6692
|
+
border.color = color;
|
|
6693
|
+
if (Object.keys(border).length > 0)
|
|
6694
|
+
borders[type] = border;
|
|
6695
|
+
}
|
|
6696
|
+
}
|
|
6697
|
+
}
|
|
6698
|
+
if (Object.keys(borders).length > 0)
|
|
6699
|
+
formatting.borders = borders;
|
|
6700
|
+
}
|
|
6701
|
+
const tabsXml = XMLParser_1.XMLParser.extractBetweenTags(pPrXml, '<w:tabs>', '</w:tabs>');
|
|
6702
|
+
if (tabsXml) {
|
|
6703
|
+
const tabs = [];
|
|
6704
|
+
const tabRegex = /<w:tab\s[^>]*\/>/g;
|
|
6705
|
+
let tabMatch;
|
|
6706
|
+
while ((tabMatch = tabRegex.exec(tabsXml)) !== null) {
|
|
6707
|
+
const tabTag = tabMatch[0];
|
|
6708
|
+
const pos = XMLParser_1.XMLParser.extractAttribute(tabTag, 'w:pos');
|
|
6709
|
+
const val = XMLParser_1.XMLParser.extractAttribute(tabTag, 'w:val');
|
|
6710
|
+
const leader = XMLParser_1.XMLParser.extractAttribute(tabTag, 'w:leader');
|
|
6711
|
+
if (pos) {
|
|
6712
|
+
const tab = { position: parseInt(pos, 10) };
|
|
6713
|
+
if (val)
|
|
6714
|
+
tab.val = val;
|
|
6715
|
+
if (leader)
|
|
6716
|
+
tab.leader = leader;
|
|
6717
|
+
tabs.push(tab);
|
|
6718
|
+
}
|
|
6719
|
+
}
|
|
6720
|
+
if (tabs.length > 0)
|
|
6721
|
+
formatting.tabs = tabs;
|
|
6722
|
+
}
|
|
6501
6723
|
const shading = this.parseShadingFromXml(pPrXml);
|
|
6502
6724
|
if (shading) {
|
|
6503
6725
|
formatting.shading = shading;
|
|
@@ -6523,7 +6745,8 @@ class DocumentParser {
|
|
|
6523
6745
|
}
|
|
6524
6746
|
const uElement = XMLParser_1.XMLParser.extractSelfClosingTag(rPrXml, 'w:u');
|
|
6525
6747
|
if (uElement) {
|
|
6526
|
-
const
|
|
6748
|
+
const uTag = `<w:u${uElement}`;
|
|
6749
|
+
const uVal = XMLParser_1.XMLParser.extractAttribute(uTag, 'w:val');
|
|
6527
6750
|
if (uVal === 'single' ||
|
|
6528
6751
|
uVal === 'double' ||
|
|
6529
6752
|
uVal === 'thick' ||
|
|
@@ -6535,6 +6758,19 @@ class DocumentParser {
|
|
|
6535
6758
|
else {
|
|
6536
6759
|
formatting.underline = true;
|
|
6537
6760
|
}
|
|
6761
|
+
const uColor = XMLParser_1.XMLParser.extractAttribute(uTag, 'w:color');
|
|
6762
|
+
if (uColor)
|
|
6763
|
+
formatting.underlineColor = uColor;
|
|
6764
|
+
const uThemeColor = XMLParser_1.XMLParser.extractAttribute(uTag, 'w:themeColor');
|
|
6765
|
+
if (uThemeColor) {
|
|
6766
|
+
formatting.underlineThemeColor = uThemeColor;
|
|
6767
|
+
}
|
|
6768
|
+
const uThemeTint = XMLParser_1.XMLParser.extractAttribute(uTag, 'w:themeTint');
|
|
6769
|
+
if (uThemeTint)
|
|
6770
|
+
formatting.underlineThemeTint = parseInt(uThemeTint, 16);
|
|
6771
|
+
const uThemeShade = XMLParser_1.XMLParser.extractAttribute(uTag, 'w:themeShade');
|
|
6772
|
+
if (uThemeShade)
|
|
6773
|
+
formatting.underlineThemeShade = parseInt(uThemeShade, 16);
|
|
6538
6774
|
}
|
|
6539
6775
|
const vertAlignElement = XMLParser_1.XMLParser.extractSelfClosingTag(rPrXml, 'w:vertAlign');
|
|
6540
6776
|
if (vertAlignElement) {
|
|
@@ -6545,13 +6781,40 @@ class DocumentParser {
|
|
|
6545
6781
|
else if (val === 'superscript') {
|
|
6546
6782
|
formatting.superscript = true;
|
|
6547
6783
|
}
|
|
6784
|
+
else if (val === 'baseline') {
|
|
6785
|
+
formatting.vertAlignBaseline = true;
|
|
6786
|
+
}
|
|
6548
6787
|
}
|
|
6549
6788
|
const rFontsElement = XMLParser_1.XMLParser.extractSelfClosingTag(rPrXml, 'w:rFonts');
|
|
6550
6789
|
if (rFontsElement) {
|
|
6551
|
-
const
|
|
6552
|
-
|
|
6790
|
+
const rFontsTag = `<w:rFonts${rFontsElement}`;
|
|
6791
|
+
const ascii = XMLParser_1.XMLParser.extractAttribute(rFontsTag, 'w:ascii');
|
|
6792
|
+
if (ascii)
|
|
6553
6793
|
formatting.font = ascii;
|
|
6554
|
-
|
|
6794
|
+
const hAnsi = XMLParser_1.XMLParser.extractAttribute(rFontsTag, 'w:hAnsi');
|
|
6795
|
+
if (hAnsi)
|
|
6796
|
+
formatting.fontHAnsi = hAnsi;
|
|
6797
|
+
const eastAsia = XMLParser_1.XMLParser.extractAttribute(rFontsTag, 'w:eastAsia');
|
|
6798
|
+
if (eastAsia)
|
|
6799
|
+
formatting.fontEastAsia = eastAsia;
|
|
6800
|
+
const cs = XMLParser_1.XMLParser.extractAttribute(rFontsTag, 'w:cs');
|
|
6801
|
+
if (cs)
|
|
6802
|
+
formatting.fontCs = cs;
|
|
6803
|
+
const hint = XMLParser_1.XMLParser.extractAttribute(rFontsTag, 'w:hint');
|
|
6804
|
+
if (hint)
|
|
6805
|
+
formatting.fontHint = hint;
|
|
6806
|
+
const asciiTheme = XMLParser_1.XMLParser.extractAttribute(rFontsTag, 'w:asciiTheme');
|
|
6807
|
+
if (asciiTheme)
|
|
6808
|
+
formatting.fontAsciiTheme = asciiTheme;
|
|
6809
|
+
const hAnsiTheme = XMLParser_1.XMLParser.extractAttribute(rFontsTag, 'w:hAnsiTheme');
|
|
6810
|
+
if (hAnsiTheme)
|
|
6811
|
+
formatting.fontHAnsiTheme = hAnsiTheme;
|
|
6812
|
+
const eastAsiaTheme = XMLParser_1.XMLParser.extractAttribute(rFontsTag, 'w:eastAsiaTheme');
|
|
6813
|
+
if (eastAsiaTheme)
|
|
6814
|
+
formatting.fontEastAsiaTheme = eastAsiaTheme;
|
|
6815
|
+
const cstheme = XMLParser_1.XMLParser.extractAttribute(rFontsTag, 'w:cstheme');
|
|
6816
|
+
if (cstheme)
|
|
6817
|
+
formatting.fontCsTheme = cstheme;
|
|
6555
6818
|
}
|
|
6556
6819
|
const szElement = XMLParser_1.XMLParser.extractSelfClosingTag(rPrXml, 'w:sz');
|
|
6557
6820
|
if (szElement) {
|
|
@@ -6560,12 +6823,35 @@ class DocumentParser {
|
|
|
6560
6823
|
formatting.size = (0, units_1.halfPointsToPoints)(parseInt(val, 10));
|
|
6561
6824
|
}
|
|
6562
6825
|
}
|
|
6826
|
+
const szCsElement = XMLParser_1.XMLParser.extractSelfClosingTag(rPrXml, 'w:szCs');
|
|
6827
|
+
if (szCsElement) {
|
|
6828
|
+
const val = XMLParser_1.XMLParser.extractAttribute(`<w:szCs${szCsElement}`, 'w:val');
|
|
6829
|
+
if (val) {
|
|
6830
|
+
const szCsVal = (0, units_1.halfPointsToPoints)(parseInt(val, 10));
|
|
6831
|
+
if (formatting.size === undefined || szCsVal !== formatting.size) {
|
|
6832
|
+
formatting.sizeCs = szCsVal;
|
|
6833
|
+
}
|
|
6834
|
+
}
|
|
6835
|
+
}
|
|
6563
6836
|
const colorElement = XMLParser_1.XMLParser.extractSelfClosingTag(rPrXml, 'w:color');
|
|
6564
6837
|
if (colorElement) {
|
|
6565
|
-
const
|
|
6838
|
+
const colorTag = `<w:color${colorElement}`;
|
|
6839
|
+
const val = XMLParser_1.XMLParser.extractAttribute(colorTag, 'w:val');
|
|
6566
6840
|
if (val && val !== 'auto') {
|
|
6567
6841
|
formatting.color = val;
|
|
6568
6842
|
}
|
|
6843
|
+
const themeColor = XMLParser_1.XMLParser.extractAttribute(colorTag, 'w:themeColor');
|
|
6844
|
+
if (themeColor) {
|
|
6845
|
+
formatting.themeColor = themeColor;
|
|
6846
|
+
}
|
|
6847
|
+
const themeTint = XMLParser_1.XMLParser.extractAttribute(colorTag, 'w:themeTint');
|
|
6848
|
+
if (themeTint) {
|
|
6849
|
+
formatting.themeTint = parseInt(themeTint, 16);
|
|
6850
|
+
}
|
|
6851
|
+
const themeShade = XMLParser_1.XMLParser.extractAttribute(colorTag, 'w:themeShade');
|
|
6852
|
+
if (themeShade) {
|
|
6853
|
+
formatting.themeShade = parseInt(themeShade, 16);
|
|
6854
|
+
}
|
|
6569
6855
|
}
|
|
6570
6856
|
const highlightElement = XMLParser_1.XMLParser.extractSelfClosingTag(rPrXml, 'w:highlight');
|
|
6571
6857
|
if (highlightElement) {
|
|
@@ -6588,6 +6874,7 @@ class DocumentParser {
|
|
|
6588
6874
|
'lightGray',
|
|
6589
6875
|
'black',
|
|
6590
6876
|
'white',
|
|
6877
|
+
'none',
|
|
6591
6878
|
];
|
|
6592
6879
|
if (validHighlights.includes(val)) {
|
|
6593
6880
|
formatting.highlight = val;
|
|
@@ -6640,10 +6927,15 @@ class DocumentParser {
|
|
|
6640
6927
|
if (tblPrXml.includes('<w:tblInd')) {
|
|
6641
6928
|
const tag = XMLParser_1.XMLParser.extractSelfClosingTag(tblPrXml, 'w:tblInd');
|
|
6642
6929
|
if (tag) {
|
|
6643
|
-
const
|
|
6930
|
+
const tblIndTag = `<w:tblInd${tag}`;
|
|
6931
|
+
const w = XMLParser_1.XMLParser.extractAttribute(tblIndTag, 'w:w');
|
|
6644
6932
|
if (w) {
|
|
6645
6933
|
formatting.indent = parseInt(w, 10);
|
|
6646
6934
|
}
|
|
6935
|
+
const type = XMLParser_1.XMLParser.extractAttribute(tblIndTag, 'w:type');
|
|
6936
|
+
if (type) {
|
|
6937
|
+
formatting.indentType = type;
|
|
6938
|
+
}
|
|
6647
6939
|
}
|
|
6648
6940
|
}
|
|
6649
6941
|
if (tblPrXml.includes('<w:jc')) {
|
|
@@ -6879,8 +7171,7 @@ class DocumentParser {
|
|
|
6879
7171
|
}
|
|
6880
7172
|
parseCellMarginsFromXml(marginXml) {
|
|
6881
7173
|
const margins = {};
|
|
6882
|
-
const
|
|
6883
|
-
for (const type of marginTypes) {
|
|
7174
|
+
for (const type of ['top', 'bottom']) {
|
|
6884
7175
|
if (marginXml.includes(`<w:${type}`)) {
|
|
6885
7176
|
const tag = XMLParser_1.XMLParser.extractSelfClosingTag(marginXml, `w:${type}`);
|
|
6886
7177
|
if (tag) {
|
|
@@ -6891,6 +7182,26 @@ class DocumentParser {
|
|
|
6891
7182
|
}
|
|
6892
7183
|
}
|
|
6893
7184
|
}
|
|
7185
|
+
const leftTag = marginXml.includes('<w:start')
|
|
7186
|
+
? XMLParser_1.XMLParser.extractSelfClosingTag(marginXml, 'w:start')
|
|
7187
|
+
: XMLParser_1.XMLParser.extractSelfClosingTag(marginXml, 'w:left');
|
|
7188
|
+
if (leftTag) {
|
|
7189
|
+
const tagName = marginXml.includes('<w:start') ? 'w:start' : 'w:left';
|
|
7190
|
+
const w = XMLParser_1.XMLParser.extractAttribute(`<${tagName}${leftTag}`, 'w:w');
|
|
7191
|
+
if (w) {
|
|
7192
|
+
margins.left = parseInt(w, 10);
|
|
7193
|
+
}
|
|
7194
|
+
}
|
|
7195
|
+
const rightTag = marginXml.includes('<w:end')
|
|
7196
|
+
? XMLParser_1.XMLParser.extractSelfClosingTag(marginXml, 'w:end')
|
|
7197
|
+
: XMLParser_1.XMLParser.extractSelfClosingTag(marginXml, 'w:right');
|
|
7198
|
+
if (rightTag) {
|
|
7199
|
+
const tagName = marginXml.includes('<w:end') ? 'w:end' : 'w:right';
|
|
7200
|
+
const w = XMLParser_1.XMLParser.extractAttribute(`<${tagName}${rightTag}`, 'w:w');
|
|
7201
|
+
if (w) {
|
|
7202
|
+
margins.right = parseInt(w, 10);
|
|
7203
|
+
}
|
|
7204
|
+
}
|
|
6894
7205
|
return Object.keys(margins).length > 0 ? margins : undefined;
|
|
6895
7206
|
}
|
|
6896
7207
|
static getRawXml(zipHandler, partName) {
|
|
@@ -7162,6 +7473,40 @@ class DocumentParser {
|
|
|
7162
7473
|
if (propsObj['w:tblStyle']) {
|
|
7163
7474
|
result.style = propsObj['w:tblStyle']['@_w:val'] || '';
|
|
7164
7475
|
}
|
|
7476
|
+
if (propsObj['w:tblpPr']) {
|
|
7477
|
+
const tblpPr = propsObj['w:tblpPr'];
|
|
7478
|
+
const pos = {};
|
|
7479
|
+
if (tblpPr['@_w:tblpX'])
|
|
7480
|
+
pos.x = parseInt(tblpPr['@_w:tblpX'], 10);
|
|
7481
|
+
if (tblpPr['@_w:tblpY'])
|
|
7482
|
+
pos.y = parseInt(tblpPr['@_w:tblpY'], 10);
|
|
7483
|
+
if (tblpPr['@_w:horzAnchor'])
|
|
7484
|
+
pos.horizontalAnchor = tblpPr['@_w:horzAnchor'];
|
|
7485
|
+
if (tblpPr['@_w:vertAnchor'])
|
|
7486
|
+
pos.verticalAnchor = tblpPr['@_w:vertAnchor'];
|
|
7487
|
+
if (tblpPr['@_w:leftFromText'])
|
|
7488
|
+
pos.leftFromText = parseInt(tblpPr['@_w:leftFromText'], 10);
|
|
7489
|
+
if (tblpPr['@_w:rightFromText'])
|
|
7490
|
+
pos.rightFromText = parseInt(tblpPr['@_w:rightFromText'], 10);
|
|
7491
|
+
if (tblpPr['@_w:topFromText'])
|
|
7492
|
+
pos.topFromText = parseInt(tblpPr['@_w:topFromText'], 10);
|
|
7493
|
+
if (tblpPr['@_w:bottomFromText'])
|
|
7494
|
+
pos.bottomFromText = parseInt(tblpPr['@_w:bottomFromText'], 10);
|
|
7495
|
+
if (Object.keys(pos).length > 0)
|
|
7496
|
+
result.position = pos;
|
|
7497
|
+
}
|
|
7498
|
+
if (propsObj['w:tblOverlap']) {
|
|
7499
|
+
result.overlap = propsObj['w:tblOverlap']['@_w:val'];
|
|
7500
|
+
}
|
|
7501
|
+
if (propsObj['w:bidiVisual']) {
|
|
7502
|
+
result.bidiVisual = true;
|
|
7503
|
+
}
|
|
7504
|
+
if (propsObj['w:tblStyleRowBandSize']) {
|
|
7505
|
+
result.tblStyleRowBandSize = parseInt(propsObj['w:tblStyleRowBandSize']['@_w:val'] || '1', 10);
|
|
7506
|
+
}
|
|
7507
|
+
if (propsObj['w:tblStyleColBandSize']) {
|
|
7508
|
+
result.tblStyleColBandSize = parseInt(propsObj['w:tblStyleColBandSize']['@_w:val'] || '1', 10);
|
|
7509
|
+
}
|
|
7165
7510
|
if (propsObj['w:tblW']) {
|
|
7166
7511
|
result.width = parseInt(propsObj['w:tblW']['@_w:w'] || '0', 10);
|
|
7167
7512
|
result.widthType = propsObj['w:tblW']['@_w:type'] || 'dxa';
|
|
@@ -7171,9 +7516,31 @@ class DocumentParser {
|
|
|
7171
7516
|
}
|
|
7172
7517
|
if (propsObj['w:tblInd']) {
|
|
7173
7518
|
result.indent = parseInt(propsObj['w:tblInd']['@_w:w'] || '0', 10);
|
|
7519
|
+
const indType = propsObj['w:tblInd']['@_w:type'];
|
|
7520
|
+
if (indType)
|
|
7521
|
+
result.indentType = indType;
|
|
7174
7522
|
}
|
|
7175
7523
|
if (propsObj['w:tblCellSpacing']) {
|
|
7176
7524
|
result.cellSpacing = parseInt(propsObj['w:tblCellSpacing']['@_w:w'] || '0', 10);
|
|
7525
|
+
const csType = propsObj['w:tblCellSpacing']['@_w:type'];
|
|
7526
|
+
if (csType)
|
|
7527
|
+
result.cellSpacingType = csType;
|
|
7528
|
+
}
|
|
7529
|
+
if (propsObj['w:tblCellMar']) {
|
|
7530
|
+
const cellMar = propsObj['w:tblCellMar'];
|
|
7531
|
+
const margins = {};
|
|
7532
|
+
if (cellMar['w:top'])
|
|
7533
|
+
margins.top = parseInt(cellMar['w:top']['@_w:w'] || '0', 10);
|
|
7534
|
+
if (cellMar['w:bottom'])
|
|
7535
|
+
margins.bottom = parseInt(cellMar['w:bottom']['@_w:w'] || '0', 10);
|
|
7536
|
+
const leftSrc = cellMar['w:start'] || cellMar['w:left'];
|
|
7537
|
+
if (leftSrc)
|
|
7538
|
+
margins.left = parseInt(leftSrc['@_w:w'] || '0', 10);
|
|
7539
|
+
const rightSrc = cellMar['w:end'] || cellMar['w:right'];
|
|
7540
|
+
if (rightSrc)
|
|
7541
|
+
margins.right = parseInt(rightSrc['@_w:w'] || '0', 10);
|
|
7542
|
+
if (Object.keys(margins).length > 0)
|
|
7543
|
+
result.cellMargins = margins;
|
|
7177
7544
|
}
|
|
7178
7545
|
if (propsObj['w:tblBorders']) {
|
|
7179
7546
|
const borders = {};
|
|
@@ -7186,6 +7553,40 @@ class DocumentParser {
|
|
|
7186
7553
|
if (Object.keys(borders).length > 0)
|
|
7187
7554
|
result.borders = borders;
|
|
7188
7555
|
}
|
|
7556
|
+
if (propsObj['w:tblLook']) {
|
|
7557
|
+
const look = propsObj['w:tblLook'];
|
|
7558
|
+
result.tblLook = look['@_w:val'] || '0000';
|
|
7559
|
+
}
|
|
7560
|
+
if (propsObj['w:tblCaption']) {
|
|
7561
|
+
result.caption = propsObj['w:tblCaption']['@_w:val'];
|
|
7562
|
+
}
|
|
7563
|
+
if (propsObj['w:tblDescription']) {
|
|
7564
|
+
result.description = propsObj['w:tblDescription']['@_w:val'];
|
|
7565
|
+
}
|
|
7566
|
+
if (propsObj['w:cnfStyle']) {
|
|
7567
|
+
result.cnfStyle = propsObj['w:cnfStyle']['@_w:val'];
|
|
7568
|
+
}
|
|
7569
|
+
if (propsObj['w:divId']) {
|
|
7570
|
+
result.divId = propsObj['w:divId']['@_w:val'];
|
|
7571
|
+
}
|
|
7572
|
+
if (propsObj['w:gridBefore']) {
|
|
7573
|
+
result.gridBefore = parseInt(propsObj['w:gridBefore']['@_w:val'] || '0', 10);
|
|
7574
|
+
}
|
|
7575
|
+
if (propsObj['w:gridAfter']) {
|
|
7576
|
+
result.gridAfter = parseInt(propsObj['w:gridAfter']['@_w:val'] || '0', 10);
|
|
7577
|
+
}
|
|
7578
|
+
if (propsObj['w:wBefore']) {
|
|
7579
|
+
result.wBefore = parseInt(propsObj['w:wBefore']['@_w:w'] || '0', 10);
|
|
7580
|
+
const wbType = propsObj['w:wBefore']['@_w:type'];
|
|
7581
|
+
if (wbType)
|
|
7582
|
+
result.wBeforeType = wbType;
|
|
7583
|
+
}
|
|
7584
|
+
if (propsObj['w:wAfter']) {
|
|
7585
|
+
result.wAfter = parseInt(propsObj['w:wAfter']['@_w:w'] || '0', 10);
|
|
7586
|
+
const waType = propsObj['w:wAfter']['@_w:type'];
|
|
7587
|
+
if (waType)
|
|
7588
|
+
result.wAfterType = waType;
|
|
7589
|
+
}
|
|
7189
7590
|
if (propsObj['w:trHeight']) {
|
|
7190
7591
|
result.height = parseInt(propsObj['w:trHeight']['@_w:val'] || '0', 10);
|
|
7191
7592
|
const rule = propsObj['w:trHeight']['@_w:hRule'];
|
|
@@ -7205,8 +7606,14 @@ class DocumentParser {
|
|
|
7205
7606
|
result.width = parseInt(propsObj['w:tcW']['@_w:w'] || '0', 10);
|
|
7206
7607
|
result.widthType = propsObj['w:tcW']['@_w:type'] || 'dxa';
|
|
7207
7608
|
}
|
|
7208
|
-
if (propsObj['w:
|
|
7209
|
-
result.
|
|
7609
|
+
if (propsObj['w:gridSpan']) {
|
|
7610
|
+
result.columnSpan = parseInt(propsObj['w:gridSpan']['@_w:val'] || '1', 10);
|
|
7611
|
+
}
|
|
7612
|
+
if (propsObj['w:hMerge']) {
|
|
7613
|
+
result.hMerge = propsObj['w:hMerge']['@_w:val'] || 'continue';
|
|
7614
|
+
}
|
|
7615
|
+
if (propsObj['w:vMerge']) {
|
|
7616
|
+
result.vMerge = propsObj['w:vMerge']['@_w:val'] || 'continue';
|
|
7210
7617
|
}
|
|
7211
7618
|
if (propsObj['w:tcBorders']) {
|
|
7212
7619
|
const borders = {};
|
|
@@ -7219,6 +7626,40 @@ class DocumentParser {
|
|
|
7219
7626
|
if (Object.keys(borders).length > 0)
|
|
7220
7627
|
result.borders = borders;
|
|
7221
7628
|
}
|
|
7629
|
+
if (propsObj['w:noWrap']) {
|
|
7630
|
+
result.noWrap = true;
|
|
7631
|
+
}
|
|
7632
|
+
if (propsObj['w:tcMar']) {
|
|
7633
|
+
const tcMar = propsObj['w:tcMar'];
|
|
7634
|
+
const margins = {};
|
|
7635
|
+
if (tcMar['w:top'])
|
|
7636
|
+
margins.top = parseInt(tcMar['w:top']['@_w:w'] || '0', 10);
|
|
7637
|
+
if (tcMar['w:bottom'])
|
|
7638
|
+
margins.bottom = parseInt(tcMar['w:bottom']['@_w:w'] || '0', 10);
|
|
7639
|
+
const leftSrc = tcMar['w:start'] || tcMar['w:left'];
|
|
7640
|
+
if (leftSrc)
|
|
7641
|
+
margins.left = parseInt(leftSrc['@_w:w'] || '0', 10);
|
|
7642
|
+
const rightSrc = tcMar['w:end'] || tcMar['w:right'];
|
|
7643
|
+
if (rightSrc)
|
|
7644
|
+
margins.right = parseInt(rightSrc['@_w:w'] || '0', 10);
|
|
7645
|
+
if (Object.keys(margins).length > 0)
|
|
7646
|
+
result.margins = margins;
|
|
7647
|
+
}
|
|
7648
|
+
if (propsObj['w:textDirection']) {
|
|
7649
|
+
result.textDirection = propsObj['w:textDirection']['@_w:val'];
|
|
7650
|
+
}
|
|
7651
|
+
if (propsObj['w:tcFitText']) {
|
|
7652
|
+
result.fitText = true;
|
|
7653
|
+
}
|
|
7654
|
+
if (propsObj['w:vAlign']) {
|
|
7655
|
+
result.verticalAlignment = propsObj['w:vAlign']['@_w:val'];
|
|
7656
|
+
}
|
|
7657
|
+
if (propsObj['w:hideMark']) {
|
|
7658
|
+
result.hideMark = true;
|
|
7659
|
+
}
|
|
7660
|
+
if (propsObj['w:cnfStyle']) {
|
|
7661
|
+
result.cnfStyle = propsObj['w:cnfStyle']['@_w:val'];
|
|
7662
|
+
}
|
|
7222
7663
|
if (propsObj['w:jc']) {
|
|
7223
7664
|
const val = propsObj['w:jc']['@_w:val'];
|
|
7224
7665
|
if (val) {
|
|
@@ -7243,11 +7684,13 @@ class DocumentParser {
|
|
|
7243
7684
|
const width = XMLParser_1.XMLParser.extractAttribute(pgSz, 'w:w');
|
|
7244
7685
|
const height = XMLParser_1.XMLParser.extractAttribute(pgSz, 'w:h');
|
|
7245
7686
|
const orient = XMLParser_1.XMLParser.extractAttribute(pgSz, 'w:orient');
|
|
7687
|
+
const code = XMLParser_1.XMLParser.extractAttribute(pgSz, 'w:code');
|
|
7246
7688
|
if (width || height) {
|
|
7247
7689
|
result.pageSize = {
|
|
7248
7690
|
width: width ? parseInt(width, 10) : undefined,
|
|
7249
7691
|
height: height ? parseInt(height, 10) : undefined,
|
|
7250
7692
|
orientation: orient === 'landscape' ? 'landscape' : 'portrait',
|
|
7693
|
+
code: code ? parseInt(code, 10) : undefined,
|
|
7251
7694
|
};
|
|
7252
7695
|
}
|
|
7253
7696
|
}
|
|
@@ -7282,6 +7725,38 @@ class DocumentParser {
|
|
|
7282
7725
|
if (val)
|
|
7283
7726
|
result.type = val;
|
|
7284
7727
|
}
|
|
7728
|
+
const lnNumElements = XMLParser_1.XMLParser.extractElements(sectPrXml, 'w:lnNumType');
|
|
7729
|
+
if (lnNumElements.length > 0 && lnNumElements[0]) {
|
|
7730
|
+
const ln = lnNumElements[0];
|
|
7731
|
+
const lnObj = {};
|
|
7732
|
+
const countBy = XMLParser_1.XMLParser.extractAttribute(ln, 'w:countBy');
|
|
7733
|
+
if (countBy)
|
|
7734
|
+
lnObj.countBy = parseInt(countBy, 10);
|
|
7735
|
+
const start = XMLParser_1.XMLParser.extractAttribute(ln, 'w:start');
|
|
7736
|
+
if (start)
|
|
7737
|
+
lnObj.start = parseInt(start, 10);
|
|
7738
|
+
const restart = XMLParser_1.XMLParser.extractAttribute(ln, 'w:restart');
|
|
7739
|
+
if (restart)
|
|
7740
|
+
lnObj.restart = restart;
|
|
7741
|
+
const distance = XMLParser_1.XMLParser.extractAttribute(ln, 'w:distance');
|
|
7742
|
+
if (distance)
|
|
7743
|
+
lnObj.distance = parseInt(distance, 10);
|
|
7744
|
+
if (Object.keys(lnObj).length > 0)
|
|
7745
|
+
result.lineNumbering = lnObj;
|
|
7746
|
+
}
|
|
7747
|
+
const pgNumElements = XMLParser_1.XMLParser.extractElements(sectPrXml, 'w:pgNumType');
|
|
7748
|
+
if (pgNumElements.length > 0 && pgNumElements[0]) {
|
|
7749
|
+
const pn = pgNumElements[0];
|
|
7750
|
+
const pnObj = {};
|
|
7751
|
+
const pnStart = XMLParser_1.XMLParser.extractAttribute(pn, 'w:start');
|
|
7752
|
+
if (pnStart)
|
|
7753
|
+
pnObj.start = parseInt(pnStart, 10);
|
|
7754
|
+
const fmt = XMLParser_1.XMLParser.extractAttribute(pn, 'w:fmt');
|
|
7755
|
+
if (fmt)
|
|
7756
|
+
pnObj.format = fmt;
|
|
7757
|
+
if (Object.keys(pnObj).length > 0)
|
|
7758
|
+
result.pageNumbering = pnObj;
|
|
7759
|
+
}
|
|
7285
7760
|
const colsElements = XMLParser_1.XMLParser.extractElements(sectPrXml, 'w:cols');
|
|
7286
7761
|
if (colsElements.length > 0 && colsElements[0]) {
|
|
7287
7762
|
const cols = colsElements[0];
|
|
@@ -7294,6 +7769,44 @@ class DocumentParser {
|
|
|
7294
7769
|
};
|
|
7295
7770
|
}
|
|
7296
7771
|
}
|
|
7772
|
+
if (sectPrXml.includes('<w:formProt'))
|
|
7773
|
+
result.formProt = true;
|
|
7774
|
+
const vAlignElements = XMLParser_1.XMLParser.extractElements(sectPrXml, 'w:vAlign');
|
|
7775
|
+
if (vAlignElements.length > 0 && vAlignElements[0]) {
|
|
7776
|
+
const val = XMLParser_1.XMLParser.extractAttribute(vAlignElements[0], 'w:val');
|
|
7777
|
+
if (val)
|
|
7778
|
+
result.verticalAlignment = val;
|
|
7779
|
+
}
|
|
7780
|
+
if (sectPrXml.includes('<w:noEndnote'))
|
|
7781
|
+
result.noEndnote = true;
|
|
7782
|
+
if (sectPrXml.includes('<w:titlePg'))
|
|
7783
|
+
result.titlePage = true;
|
|
7784
|
+
const textDirElements = XMLParser_1.XMLParser.extractElements(sectPrXml, 'w:textDirection');
|
|
7785
|
+
if (textDirElements.length > 0 && textDirElements[0]) {
|
|
7786
|
+
const val = XMLParser_1.XMLParser.extractAttribute(textDirElements[0], 'w:val');
|
|
7787
|
+
if (val)
|
|
7788
|
+
result.textDirection = val;
|
|
7789
|
+
}
|
|
7790
|
+
if (sectPrXml.includes('<w:bidi'))
|
|
7791
|
+
result.bidi = true;
|
|
7792
|
+
if (sectPrXml.includes('<w:rtlGutter'))
|
|
7793
|
+
result.rtlGutter = true;
|
|
7794
|
+
const docGridElements = XMLParser_1.XMLParser.extractElements(sectPrXml, 'w:docGrid');
|
|
7795
|
+
if (docGridElements.length > 0 && docGridElements[0]) {
|
|
7796
|
+
const dg = docGridElements[0];
|
|
7797
|
+
const dgObj = {};
|
|
7798
|
+
const dgType = XMLParser_1.XMLParser.extractAttribute(dg, 'w:type');
|
|
7799
|
+
if (dgType)
|
|
7800
|
+
dgObj.type = dgType;
|
|
7801
|
+
const linePitch = XMLParser_1.XMLParser.extractAttribute(dg, 'w:linePitch');
|
|
7802
|
+
if (linePitch)
|
|
7803
|
+
dgObj.linePitch = parseInt(linePitch, 10);
|
|
7804
|
+
const charSpace = XMLParser_1.XMLParser.extractAttribute(dg, 'w:charSpace');
|
|
7805
|
+
if (charSpace)
|
|
7806
|
+
dgObj.charSpace = parseInt(charSpace, 10);
|
|
7807
|
+
if (Object.keys(dgObj).length > 0)
|
|
7808
|
+
result.docGrid = dgObj;
|
|
7809
|
+
}
|
|
7297
7810
|
return result;
|
|
7298
7811
|
}
|
|
7299
7812
|
}
|