docxmlater 10.1.3 → 10.1.5
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 +759 -754
- package/dist/constants/legacyCompatFlags.js +1 -1
- package/dist/constants/legacyCompatFlags.js.map +1 -1
- package/dist/constants/limits.js.map +1 -1
- package/dist/core/Document.d.ts +50 -50
- package/dist/core/Document.d.ts.map +1 -1
- package/dist/core/Document.js +483 -471
- package/dist/core/Document.js.map +1 -1
- package/dist/core/DocumentContent.d.ts +9 -9
- package/dist/core/DocumentContent.d.ts.map +1 -1
- package/dist/core/DocumentContent.js +1 -1
- package/dist/core/DocumentContent.js.map +1 -1
- package/dist/core/DocumentGenerator.d.ts +11 -11
- package/dist/core/DocumentGenerator.d.ts.map +1 -1
- package/dist/core/DocumentGenerator.js +251 -251
- package/dist/core/DocumentGenerator.js.map +1 -1
- package/dist/core/DocumentIdManager.js.map +1 -1
- package/dist/core/DocumentParser.d.ts +15 -15
- package/dist/core/DocumentParser.d.ts.map +1 -1
- package/dist/core/DocumentParser.js +2123 -2155
- package/dist/core/DocumentParser.js.map +1 -1
- package/dist/core/DocumentValidator.d.ts.map +1 -1
- package/dist/core/DocumentValidator.js +2 -5
- package/dist/core/DocumentValidator.js.map +1 -1
- package/dist/core/Relationship.js.map +1 -1
- package/dist/core/RelationshipManager.d.ts.map +1 -1
- package/dist/core/RelationshipManager.js +3 -3
- package/dist/core/RelationshipManager.js.map +1 -1
- package/dist/elements/AlternateContent.js.map +1 -1
- package/dist/elements/Bookmark.d.ts.map +1 -1
- package/dist/elements/Bookmark.js +3 -1
- package/dist/elements/Bookmark.js.map +1 -1
- package/dist/elements/BookmarkManager.d.ts.map +1 -1
- package/dist/elements/BookmarkManager.js.map +1 -1
- package/dist/elements/Comment.d.ts.map +1 -1
- package/dist/elements/Comment.js +9 -6
- package/dist/elements/Comment.js.map +1 -1
- package/dist/elements/CommentManager.d.ts.map +1 -1
- package/dist/elements/CommentManager.js +18 -17
- package/dist/elements/CommentManager.js.map +1 -1
- package/dist/elements/CommonTypes.d.ts +21 -21
- package/dist/elements/CommonTypes.d.ts.map +1 -1
- package/dist/elements/CommonTypes.js +56 -56
- package/dist/elements/CommonTypes.js.map +1 -1
- package/dist/elements/CustomXml.js.map +1 -1
- package/dist/elements/Endnote.d.ts.map +1 -1
- package/dist/elements/Endnote.js +6 -6
- package/dist/elements/Endnote.js.map +1 -1
- package/dist/elements/EndnoteManager.d.ts.map +1 -1
- package/dist/elements/EndnoteManager.js +6 -7
- package/dist/elements/EndnoteManager.js.map +1 -1
- package/dist/elements/Field.d.ts.map +1 -1
- package/dist/elements/Field.js +82 -25
- package/dist/elements/Field.js.map +1 -1
- package/dist/elements/FieldHelpers.d.ts.map +1 -1
- package/dist/elements/FieldHelpers.js.map +1 -1
- package/dist/elements/FontManager.d.ts.map +1 -1
- package/dist/elements/FontManager.js +1 -1
- package/dist/elements/FontManager.js.map +1 -1
- package/dist/elements/Footer.js +2 -2
- package/dist/elements/Footer.js.map +1 -1
- package/dist/elements/Footnote.d.ts.map +1 -1
- package/dist/elements/Footnote.js +6 -6
- package/dist/elements/Footnote.js.map +1 -1
- package/dist/elements/FootnoteManager.d.ts.map +1 -1
- package/dist/elements/FootnoteManager.js +6 -7
- package/dist/elements/FootnoteManager.js.map +1 -1
- package/dist/elements/Header.js +2 -2
- package/dist/elements/Header.js.map +1 -1
- package/dist/elements/HeaderFooterManager.js.map +1 -1
- package/dist/elements/Hyperlink.d.ts +5 -3
- package/dist/elements/Hyperlink.d.ts.map +1 -1
- package/dist/elements/Hyperlink.js +134 -76
- package/dist/elements/Hyperlink.js.map +1 -1
- package/dist/elements/Image.d.ts.map +1 -1
- package/dist/elements/Image.js +238 -106
- package/dist/elements/Image.js.map +1 -1
- package/dist/elements/ImageManager.d.ts.map +1 -1
- package/dist/elements/ImageManager.js +1 -1
- package/dist/elements/ImageManager.js.map +1 -1
- package/dist/elements/ImageRun.js +1 -1
- package/dist/elements/ImageRun.js.map +1 -1
- package/dist/elements/MathElement.js.map +1 -1
- package/dist/elements/Paragraph.d.ts +24 -24
- package/dist/elements/Paragraph.d.ts.map +1 -1
- package/dist/elements/Paragraph.js +181 -188
- package/dist/elements/Paragraph.js.map +1 -1
- package/dist/elements/PreservedElement.js.map +1 -1
- package/dist/elements/PropertyChangeTypes.d.ts.map +1 -1
- package/dist/elements/PropertyChangeTypes.js +6 -6
- package/dist/elements/PropertyChangeTypes.js.map +1 -1
- package/dist/elements/RangeMarker.d.ts.map +1 -1
- package/dist/elements/RangeMarker.js.map +1 -1
- package/dist/elements/Revision.d.ts.map +1 -1
- package/dist/elements/Revision.js +4 -5
- package/dist/elements/Revision.js.map +1 -1
- package/dist/elements/RevisionContent.js.map +1 -1
- package/dist/elements/RevisionManager.d.ts.map +1 -1
- package/dist/elements/RevisionManager.js +40 -48
- package/dist/elements/RevisionManager.js.map +1 -1
- package/dist/elements/Run.d.ts +16 -16
- package/dist/elements/Run.d.ts.map +1 -1
- package/dist/elements/Run.js +256 -238
- package/dist/elements/Run.js.map +1 -1
- package/dist/elements/Section.d.ts.map +1 -1
- package/dist/elements/Section.js +36 -11
- package/dist/elements/Section.js.map +1 -1
- package/dist/elements/Shape.d.ts.map +1 -1
- package/dist/elements/Shape.js.map +1 -1
- package/dist/elements/StructuredDocumentTag.d.ts +6 -6
- package/dist/elements/StructuredDocumentTag.d.ts.map +1 -1
- package/dist/elements/StructuredDocumentTag.js +99 -104
- package/dist/elements/StructuredDocumentTag.js.map +1 -1
- package/dist/elements/Table.d.ts +11 -11
- package/dist/elements/Table.d.ts.map +1 -1
- package/dist/elements/Table.js +102 -107
- package/dist/elements/Table.js.map +1 -1
- package/dist/elements/TableCell.d.ts +10 -10
- package/dist/elements/TableCell.d.ts.map +1 -1
- package/dist/elements/TableCell.js +105 -106
- package/dist/elements/TableCell.js.map +1 -1
- package/dist/elements/TableGridChange.d.ts.map +1 -1
- package/dist/elements/TableGridChange.js.map +1 -1
- package/dist/elements/TableOfContents.d.ts.map +1 -1
- package/dist/elements/TableOfContents.js +4 -4
- package/dist/elements/TableOfContents.js.map +1 -1
- package/dist/elements/TableOfContentsElement.js.map +1 -1
- package/dist/elements/TableRow.d.ts.map +1 -1
- package/dist/elements/TableRow.js +13 -6
- package/dist/elements/TableRow.js.map +1 -1
- package/dist/elements/TextBox.d.ts.map +1 -1
- package/dist/elements/TextBox.js +3 -5
- package/dist/elements/TextBox.js.map +1 -1
- package/dist/formatting/AbstractNumbering.d.ts +4 -4
- package/dist/formatting/AbstractNumbering.d.ts.map +1 -1
- package/dist/formatting/AbstractNumbering.js +54 -49
- package/dist/formatting/AbstractNumbering.js.map +1 -1
- package/dist/formatting/NumberingInstance.d.ts.map +1 -1
- package/dist/formatting/NumberingInstance.js +1 -3
- package/dist/formatting/NumberingInstance.js.map +1 -1
- package/dist/formatting/NumberingLevel.d.ts +5 -5
- package/dist/formatting/NumberingLevel.d.ts.map +1 -1
- package/dist/formatting/NumberingLevel.js +119 -125
- package/dist/formatting/NumberingLevel.js.map +1 -1
- package/dist/formatting/NumberingManager.d.ts.map +1 -1
- package/dist/formatting/NumberingManager.js +9 -9
- package/dist/formatting/NumberingManager.js.map +1 -1
- package/dist/formatting/Style.d.ts +11 -11
- package/dist/formatting/Style.d.ts.map +1 -1
- package/dist/formatting/Style.js +219 -247
- package/dist/formatting/Style.js.map +1 -1
- package/dist/formatting/StylesManager.d.ts +2 -2
- package/dist/formatting/StylesManager.d.ts.map +1 -1
- package/dist/formatting/StylesManager.js +96 -102
- package/dist/formatting/StylesManager.js.map +1 -1
- package/dist/helpers/CleanupHelper.d.ts +1 -1
- package/dist/helpers/CleanupHelper.d.ts.map +1 -1
- package/dist/helpers/CleanupHelper.js +6 -6
- package/dist/helpers/CleanupHelper.js.map +1 -1
- package/dist/images/ImageOptimizer.js +7 -7
- package/dist/images/ImageOptimizer.js.map +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/managers/DrawingManager.js.map +1 -1
- package/dist/tracking/DocumentTrackingContext.d.ts.map +1 -1
- package/dist/tracking/DocumentTrackingContext.js +23 -7
- package/dist/tracking/DocumentTrackingContext.js.map +1 -1
- package/dist/tracking/TrackingContext.d.ts.map +1 -1
- package/dist/tracking/TrackingContext.js.map +1 -1
- package/dist/types/compatibility-types.js.map +1 -1
- package/dist/types/formatting.js.map +1 -1
- package/dist/types/list-types.d.ts +6 -6
- package/dist/types/list-types.js.map +1 -1
- package/dist/types/settings-types.js.map +1 -1
- package/dist/types/styleConfig.d.ts +2 -2
- package/dist/types/styleConfig.js.map +1 -1
- package/dist/utils/ChangelogGenerator.d.ts.map +1 -1
- package/dist/utils/ChangelogGenerator.js +97 -101
- package/dist/utils/ChangelogGenerator.js.map +1 -1
- package/dist/utils/CompatibilityUpgrader.d.ts.map +1 -1
- package/dist/utils/CompatibilityUpgrader.js +1 -1
- package/dist/utils/CompatibilityUpgrader.js.map +1 -1
- package/dist/utils/InMemoryRevisionAcceptor.d.ts.map +1 -1
- package/dist/utils/InMemoryRevisionAcceptor.js +1 -6
- package/dist/utils/InMemoryRevisionAcceptor.js.map +1 -1
- package/dist/utils/MoveOperationHelper.d.ts.map +1 -1
- package/dist/utils/MoveOperationHelper.js +1 -1
- package/dist/utils/MoveOperationHelper.js.map +1 -1
- package/dist/utils/RevisionAwareProcessor.d.ts.map +1 -1
- package/dist/utils/RevisionAwareProcessor.js +2 -4
- package/dist/utils/RevisionAwareProcessor.js.map +1 -1
- package/dist/utils/RevisionWalker.d.ts.map +1 -1
- package/dist/utils/RevisionWalker.js +4 -12
- package/dist/utils/RevisionWalker.js.map +1 -1
- package/dist/utils/SelectiveRevisionAcceptor.d.ts.map +1 -1
- package/dist/utils/SelectiveRevisionAcceptor.js +2 -6
- package/dist/utils/SelectiveRevisionAcceptor.js.map +1 -1
- package/dist/utils/ShadingResolver.d.ts.map +1 -1
- package/dist/utils/ShadingResolver.js +1 -1
- package/dist/utils/ShadingResolver.js.map +1 -1
- package/dist/utils/acceptRevisions.d.ts.map +1 -1
- package/dist/utils/acceptRevisions.js +23 -12
- package/dist/utils/acceptRevisions.js.map +1 -1
- package/dist/utils/cnfStyleDecoder.d.ts +1 -1
- package/dist/utils/cnfStyleDecoder.d.ts.map +1 -1
- package/dist/utils/cnfStyleDecoder.js +40 -40
- package/dist/utils/cnfStyleDecoder.js.map +1 -1
- package/dist/utils/corruptionDetection.d.ts.map +1 -1
- package/dist/utils/corruptionDetection.js.map +1 -1
- package/dist/utils/dateFormatting.js.map +1 -1
- package/dist/utils/deepClone.js +1 -1
- package/dist/utils/deepClone.js.map +1 -1
- package/dist/utils/diagnostics.d.ts.map +1 -1
- package/dist/utils/diagnostics.js +1 -1
- package/dist/utils/diagnostics.js.map +1 -1
- package/dist/utils/errorHandling.js.map +1 -1
- package/dist/utils/formatting.d.ts.map +1 -1
- package/dist/utils/formatting.js +10 -2
- package/dist/utils/formatting.js.map +1 -1
- package/dist/utils/list-detection.d.ts +2 -2
- package/dist/utils/list-detection.d.ts.map +1 -1
- package/dist/utils/list-detection.js +21 -23
- package/dist/utils/list-detection.js.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +12 -7
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/parsingHelpers.js.map +1 -1
- package/dist/utils/stripTrackedChanges.d.ts.map +1 -1
- package/dist/utils/stripTrackedChanges.js +3 -3
- package/dist/utils/stripTrackedChanges.js.map +1 -1
- package/dist/utils/textDiff.d.ts +1 -1
- package/dist/utils/textDiff.js +8 -8
- package/dist/utils/textDiff.js.map +1 -1
- package/dist/utils/units.js.map +1 -1
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +24 -7
- package/dist/utils/validation.js.map +1 -1
- package/dist/utils/xmlSanitization.d.ts.map +1 -1
- package/dist/utils/xmlSanitization.js +3 -3
- package/dist/utils/xmlSanitization.js.map +1 -1
- package/dist/validation/RevisionAutoFixer.d.ts.map +1 -1
- package/dist/validation/RevisionAutoFixer.js +5 -5
- package/dist/validation/RevisionAutoFixer.js.map +1 -1
- package/dist/validation/RevisionValidator.d.ts.map +1 -1
- package/dist/validation/RevisionValidator.js +7 -9
- package/dist/validation/RevisionValidator.js.map +1 -1
- package/dist/validation/ValidationRules.js +3 -3
- package/dist/validation/ValidationRules.js.map +1 -1
- package/dist/validation/index.js.map +1 -1
- package/dist/xml/XMLBuilder.d.ts +1 -1
- package/dist/xml/XMLBuilder.d.ts.map +1 -1
- package/dist/xml/XMLBuilder.js +98 -100
- package/dist/xml/XMLBuilder.js.map +1 -1
- package/dist/xml/XMLParser.d.ts.map +1 -1
- package/dist/xml/XMLParser.js +61 -66
- package/dist/xml/XMLParser.js.map +1 -1
- package/dist/zip/ZipHandler.d.ts.map +1 -1
- package/dist/zip/ZipHandler.js.map +1 -1
- package/dist/zip/ZipReader.d.ts.map +1 -1
- package/dist/zip/ZipReader.js +1 -3
- package/dist/zip/ZipReader.js.map +1 -1
- package/dist/zip/ZipWriter.d.ts +1 -1
- package/dist/zip/ZipWriter.d.ts.map +1 -1
- package/dist/zip/ZipWriter.js +28 -36
- package/dist/zip/ZipWriter.js.map +1 -1
- package/dist/zip/types.js +1 -1
- package/dist/zip/types.js.map +1 -1
- package/package.json +92 -92
- package/src/__tests__/helper-methods.test.ts +512 -512
- package/src/constants/legacyCompatFlags.ts +138 -138
- package/src/constants/limits.ts +50 -50
- package/src/core/Document.ts +985 -1145
- package/src/core/DocumentContent.ts +461 -467
- package/src/core/DocumentGenerator.ts +1133 -1104
- package/src/core/DocumentIdManager.ts +158 -158
- package/src/core/DocumentParser.ts +2347 -2716
- package/src/core/DocumentValidator.ts +363 -372
- package/src/core/Relationship.ts +367 -367
- package/src/core/RelationshipManager.ts +429 -428
- package/src/elements/AlternateContent.ts +42 -42
- package/src/elements/Bookmark.ts +212 -210
- package/src/elements/BookmarkManager.ts +247 -250
- package/src/elements/Comment.ts +356 -359
- package/src/elements/CommentManager.ts +499 -502
- package/src/elements/CommonTypes.ts +524 -549
- package/src/elements/CustomXml.ts +36 -36
- package/src/elements/Endnote.ts +221 -217
- package/src/elements/EndnoteManager.ts +246 -249
- package/src/elements/Field.ts +1292 -1233
- package/src/elements/FieldHelpers.ts +329 -333
- package/src/elements/FontManager.ts +336 -339
- package/src/elements/Footer.ts +269 -269
- package/src/elements/Footnote.ts +221 -217
- package/src/elements/FootnoteManager.ts +246 -249
- package/src/elements/Header.ts +269 -269
- package/src/elements/HeaderFooterManager.ts +219 -219
- package/src/elements/Hyperlink.ts +1288 -1193
- package/src/elements/Image.ts +1982 -1756
- package/src/elements/ImageManager.ts +437 -432
- package/src/elements/ImageRun.ts +59 -59
- package/src/elements/MathElement.ts +65 -65
- package/src/elements/Paragraph.ts +4347 -4287
- package/src/elements/PreservedElement.ts +53 -53
- package/src/elements/PropertyChangeTypes.ts +458 -442
- package/src/elements/RangeMarker.ts +382 -400
- package/src/elements/Revision.ts +1198 -1217
- package/src/elements/RevisionContent.ts +73 -73
- package/src/elements/RevisionManager.ts +1070 -1070
- package/src/elements/Run.ts +3103 -3073
- package/src/elements/Section.ts +1521 -1421
- package/src/elements/Shape.ts +884 -873
- package/src/elements/StructuredDocumentTag.ts +1176 -1207
- package/src/elements/Table.ts +2468 -2524
- package/src/elements/TableCell.ts +1617 -1621
- package/src/elements/TableGridChange.ts +149 -151
- package/src/elements/TableOfContents.ts +701 -691
- package/src/elements/TableOfContentsElement.ts +89 -89
- package/src/elements/TableRow.ts +960 -929
- package/src/elements/TextBox.ts +766 -768
- package/src/formatting/AbstractNumbering.ts +580 -579
- package/src/formatting/NumberingInstance.ts +295 -299
- package/src/formatting/NumberingLevel.ts +981 -1040
- package/src/formatting/NumberingManager.ts +833 -827
- package/src/formatting/Style.ts +1785 -1879
- package/src/formatting/StylesManager.ts +1090 -1130
- package/src/helpers/CleanupHelper.ts +524 -524
- package/src/images/ImageOptimizer.ts +274 -274
- package/src/index.ts +559 -554
- package/src/managers/DrawingManager.ts +319 -319
- package/src/tracking/DocumentTrackingContext.ts +687 -674
- package/src/tracking/TrackingContext.ts +175 -173
- package/src/types/compatibility-types.ts +49 -49
- package/src/types/formatting.ts +210 -210
- package/src/types/list-types.ts +14 -14
- package/src/types/settings-types.ts +59 -59
- package/src/types/styleConfig.ts +189 -189
- package/src/utils/ChangelogGenerator.ts +1583 -1581
- package/src/utils/CompatibilityUpgrader.ts +235 -237
- package/src/utils/InMemoryRevisionAcceptor.ts +691 -696
- package/src/utils/MoveOperationHelper.ts +233 -238
- package/src/utils/RevisionAwareProcessor.ts +518 -526
- package/src/utils/RevisionWalker.ts +427 -457
- package/src/utils/SelectiveRevisionAcceptor.ts +662 -683
- package/src/utils/ShadingResolver.ts +105 -107
- package/src/utils/acceptRevisions.ts +723 -714
- package/src/utils/cnfStyleDecoder.ts +212 -217
- package/src/utils/corruptionDetection.ts +346 -345
- package/src/utils/dateFormatting.ts +20 -20
- package/src/utils/deepClone.ts +77 -78
- package/src/utils/diagnostics.ts +125 -129
- package/src/utils/errorHandling.ts +80 -80
- package/src/utils/formatting.ts +220 -213
- package/src/utils/list-detection.ts +32 -42
- package/src/utils/logger.ts +412 -404
- package/src/utils/parsingHelpers.ts +190 -190
- package/src/utils/stripTrackedChanges.ts +356 -353
- package/src/utils/textDiff.ts +100 -100
- package/src/utils/units.ts +421 -421
- package/src/utils/validation.ts +553 -542
- package/src/utils/xmlSanitization.ts +179 -182
- package/src/validation/RevisionAutoFixer.ts +541 -542
- package/src/validation/RevisionValidator.ts +470 -460
- package/src/validation/ValidationRules.ts +338 -338
- package/src/validation/index.ts +30 -30
- package/src/xml/XMLBuilder.ts +857 -871
- package/src/xml/XMLParser.ts +877 -919
- package/src/zip/ZipHandler.ts +629 -637
- package/src/zip/ZipReader.ts +295 -299
- package/src/zip/ZipWriter.ts +374 -390
- package/src/zip/types.ts +116 -116
package/dist/elements/Run.js
CHANGED
|
@@ -20,64 +20,64 @@ class Run {
|
|
|
20
20
|
constructor(text, formatting = {}) {
|
|
21
21
|
if (text === undefined || text === null) {
|
|
22
22
|
logger_1.defaultLogger.warn(`DocXML Text Validation Warning [Run constructor]:\n` +
|
|
23
|
-
` - Received ${text === undefined ?
|
|
23
|
+
` - Received ${text === undefined ? 'undefined' : 'null'} text value\n` +
|
|
24
24
|
` - Converting to empty string for Word compatibility`);
|
|
25
25
|
}
|
|
26
26
|
const shouldClean = formatting.cleanXmlFromText !== false;
|
|
27
27
|
const validation = (0, validation_1.validateRunText)(text, {
|
|
28
|
-
context:
|
|
28
|
+
context: 'Run constructor',
|
|
29
29
|
autoClean: shouldClean,
|
|
30
30
|
warnToConsole: true,
|
|
31
31
|
});
|
|
32
32
|
const cleanedText = validation.cleanedText || text;
|
|
33
|
-
const normalizedText = cleanedText ??
|
|
33
|
+
const normalizedText = cleanedText ?? '';
|
|
34
34
|
this.content = this.parseTextWithSpecialCharacters(normalizedText);
|
|
35
35
|
const { cleanXmlFromText, ...displayFormatting } = formatting;
|
|
36
36
|
this.formatting = displayFormatting;
|
|
37
37
|
}
|
|
38
38
|
parseTextWithSpecialCharacters(text) {
|
|
39
39
|
if (!text) {
|
|
40
|
-
return [{ type:
|
|
40
|
+
return [{ type: 'text', value: '' }];
|
|
41
41
|
}
|
|
42
42
|
const content = [];
|
|
43
|
-
let currentText =
|
|
43
|
+
let currentText = '';
|
|
44
44
|
for (let i = 0; i < text.length; i++) {
|
|
45
45
|
const char = text[i];
|
|
46
46
|
switch (char) {
|
|
47
|
-
case
|
|
47
|
+
case '\t':
|
|
48
48
|
if (currentText) {
|
|
49
|
-
content.push({ type:
|
|
50
|
-
currentText =
|
|
49
|
+
content.push({ type: 'text', value: currentText });
|
|
50
|
+
currentText = '';
|
|
51
51
|
}
|
|
52
|
-
content.push({ type:
|
|
52
|
+
content.push({ type: 'tab' });
|
|
53
53
|
break;
|
|
54
|
-
case
|
|
54
|
+
case '\n':
|
|
55
55
|
if (currentText) {
|
|
56
|
-
content.push({ type:
|
|
57
|
-
currentText =
|
|
56
|
+
content.push({ type: 'text', value: currentText });
|
|
57
|
+
currentText = '';
|
|
58
58
|
}
|
|
59
|
-
content.push({ type:
|
|
59
|
+
content.push({ type: 'break' });
|
|
60
60
|
break;
|
|
61
|
-
case
|
|
61
|
+
case '\u2011':
|
|
62
62
|
if (currentText) {
|
|
63
|
-
content.push({ type:
|
|
64
|
-
currentText =
|
|
63
|
+
content.push({ type: 'text', value: currentText });
|
|
64
|
+
currentText = '';
|
|
65
65
|
}
|
|
66
|
-
content.push({ type:
|
|
66
|
+
content.push({ type: 'noBreakHyphen' });
|
|
67
67
|
break;
|
|
68
|
-
case
|
|
68
|
+
case '\r':
|
|
69
69
|
if (currentText) {
|
|
70
|
-
content.push({ type:
|
|
71
|
-
currentText =
|
|
70
|
+
content.push({ type: 'text', value: currentText });
|
|
71
|
+
currentText = '';
|
|
72
72
|
}
|
|
73
|
-
content.push({ type:
|
|
73
|
+
content.push({ type: 'carriageReturn' });
|
|
74
74
|
break;
|
|
75
|
-
case
|
|
75
|
+
case '\u00AD':
|
|
76
76
|
if (currentText) {
|
|
77
|
-
content.push({ type:
|
|
78
|
-
currentText =
|
|
77
|
+
content.push({ type: 'text', value: currentText });
|
|
78
|
+
currentText = '';
|
|
79
79
|
}
|
|
80
|
-
content.push({ type:
|
|
80
|
+
content.push({ type: 'softHyphen' });
|
|
81
81
|
break;
|
|
82
82
|
default:
|
|
83
83
|
currentText += char;
|
|
@@ -85,10 +85,10 @@ class Run {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
if (currentText) {
|
|
88
|
-
content.push({ type:
|
|
88
|
+
content.push({ type: 'text', value: currentText });
|
|
89
89
|
}
|
|
90
90
|
if (content.length === 0) {
|
|
91
|
-
content.push({ type:
|
|
91
|
+
content.push({ type: 'text', value: '' });
|
|
92
92
|
}
|
|
93
93
|
return content;
|
|
94
94
|
}
|
|
@@ -96,54 +96,59 @@ class Run {
|
|
|
96
96
|
return this.content
|
|
97
97
|
.map((c) => {
|
|
98
98
|
switch (c.type) {
|
|
99
|
-
case
|
|
100
|
-
return c.value ||
|
|
101
|
-
case
|
|
102
|
-
return
|
|
103
|
-
case
|
|
104
|
-
return
|
|
105
|
-
case
|
|
106
|
-
return
|
|
107
|
-
case
|
|
108
|
-
return
|
|
109
|
-
case
|
|
110
|
-
return
|
|
111
|
-
case
|
|
112
|
-
return
|
|
113
|
-
case
|
|
114
|
-
return
|
|
99
|
+
case 'text':
|
|
100
|
+
return c.value || '';
|
|
101
|
+
case 'tab':
|
|
102
|
+
return '\t';
|
|
103
|
+
case 'break':
|
|
104
|
+
return '\n';
|
|
105
|
+
case 'carriageReturn':
|
|
106
|
+
return '\r';
|
|
107
|
+
case 'softHyphen':
|
|
108
|
+
return '\u00AD';
|
|
109
|
+
case 'noBreakHyphen':
|
|
110
|
+
return '\u2011';
|
|
111
|
+
case 'instructionText':
|
|
112
|
+
return '';
|
|
113
|
+
case 'fieldChar':
|
|
114
|
+
return '';
|
|
115
115
|
default:
|
|
116
|
-
return
|
|
116
|
+
return '';
|
|
117
117
|
}
|
|
118
118
|
})
|
|
119
|
-
.join(
|
|
119
|
+
.join('');
|
|
120
120
|
}
|
|
121
121
|
setText(text) {
|
|
122
122
|
const oldText = this.getText();
|
|
123
123
|
const oldContent = [...this.content];
|
|
124
124
|
if (text === undefined || text === null) {
|
|
125
125
|
logger_1.defaultLogger.warn(`DocXML Text Validation Warning [Run.setText]:\n` +
|
|
126
|
-
` - Received ${text === undefined ?
|
|
126
|
+
` - Received ${text === undefined ? 'undefined' : 'null'} text value\n` +
|
|
127
127
|
` - Converting to empty string for Word compatibility`);
|
|
128
128
|
}
|
|
129
129
|
const shouldClean = this.formatting.cleanXmlFromText !== false;
|
|
130
130
|
const validation = (0, validation_1.validateRunText)(text, {
|
|
131
|
-
context:
|
|
131
|
+
context: 'Run.setText',
|
|
132
132
|
autoClean: shouldClean,
|
|
133
133
|
warnToConsole: true,
|
|
134
134
|
});
|
|
135
135
|
const cleanedText = validation.cleanedText || text;
|
|
136
|
-
const normalizedText = cleanedText ??
|
|
137
|
-
const isAllInstructionText = this.content.length > 0 &&
|
|
138
|
-
this.content.every(c => c.type === "instructionText");
|
|
136
|
+
const normalizedText = cleanedText ?? '';
|
|
137
|
+
const isAllInstructionText = this.content.length > 0 && this.content.every((c) => c.type === 'instructionText');
|
|
139
138
|
if (isAllInstructionText) {
|
|
140
|
-
this.content = [{ type:
|
|
139
|
+
this.content = [{ type: 'instructionText', value: normalizedText }];
|
|
141
140
|
}
|
|
142
141
|
else {
|
|
143
142
|
this.content = this.parseTextWithSpecialCharacters(normalizedText);
|
|
144
143
|
}
|
|
145
|
-
if (this.trackingContext?.isEnabled() &&
|
|
146
|
-
|
|
144
|
+
if (this.trackingContext?.isEnabled() &&
|
|
145
|
+
this._parentParagraph &&
|
|
146
|
+
oldText !== normalizedText &&
|
|
147
|
+
oldText) {
|
|
148
|
+
const hasNonTextContent = oldContent.some((c) => c.type === 'vml' ||
|
|
149
|
+
c.type === 'fieldChar' ||
|
|
150
|
+
c.type === 'symbol' ||
|
|
151
|
+
c.type === 'embeddedObject');
|
|
147
152
|
const segments = hasNonTextContent ? [] : (0, textDiff_1.diffText)(oldText, normalizedText);
|
|
148
153
|
const useGranular = !hasNonTextContent && (0, textDiff_1.diffHasUnchangedParts)(segments);
|
|
149
154
|
if (useGranular) {
|
|
@@ -234,34 +239,34 @@ class Run {
|
|
|
234
239
|
if (this.formatting.bold !== undefined) {
|
|
235
240
|
return this.formatting.bold;
|
|
236
241
|
}
|
|
237
|
-
return this.getConditionalFormattingProperty(
|
|
242
|
+
return this.getConditionalFormattingProperty('bold');
|
|
238
243
|
}
|
|
239
244
|
getEffectiveItalic() {
|
|
240
245
|
if (this.formatting.italic !== undefined) {
|
|
241
246
|
return this.formatting.italic;
|
|
242
247
|
}
|
|
243
|
-
return this.getConditionalFormattingProperty(
|
|
248
|
+
return this.getConditionalFormattingProperty('italic');
|
|
244
249
|
}
|
|
245
250
|
getEffectiveColor() {
|
|
246
251
|
if (this.formatting.color !== undefined) {
|
|
247
252
|
return this.formatting.color;
|
|
248
253
|
}
|
|
249
|
-
return this.getConditionalFormattingProperty(
|
|
254
|
+
return this.getConditionalFormattingProperty('color');
|
|
250
255
|
}
|
|
251
256
|
getEffectiveFont() {
|
|
252
257
|
if (this.formatting.font !== undefined) {
|
|
253
258
|
return this.formatting.font;
|
|
254
259
|
}
|
|
255
|
-
return this.getConditionalFormattingProperty(
|
|
260
|
+
return this.getConditionalFormattingProperty('font');
|
|
256
261
|
}
|
|
257
262
|
getEffectiveSize() {
|
|
258
263
|
if (this.formatting.size !== undefined) {
|
|
259
264
|
return this.formatting.size;
|
|
260
265
|
}
|
|
261
|
-
return this.getConditionalFormattingProperty(
|
|
266
|
+
return this.getConditionalFormattingProperty('size');
|
|
262
267
|
}
|
|
263
268
|
isHyperlinkStyled() {
|
|
264
|
-
return this.formatting.characterStyle ===
|
|
269
|
+
return this.formatting.characterStyle === 'Hyperlink';
|
|
265
270
|
}
|
|
266
271
|
getConditionalFormattingProperty(property) {
|
|
267
272
|
const para = this._parentParagraph;
|
|
@@ -287,25 +292,25 @@ class Run {
|
|
|
287
292
|
return conditional.runFormatting[property];
|
|
288
293
|
}
|
|
289
294
|
}
|
|
290
|
-
const wholeTable = tableStyleProps.conditionalFormatting.find((cf) => cf.type ===
|
|
295
|
+
const wholeTable = tableStyleProps.conditionalFormatting.find((cf) => cf.type === 'wholeTable');
|
|
291
296
|
if (wholeTable?.runFormatting?.[property] !== undefined) {
|
|
292
297
|
return wholeTable.runFormatting[property];
|
|
293
298
|
}
|
|
294
299
|
}
|
|
295
300
|
}
|
|
296
301
|
}
|
|
297
|
-
if (property ===
|
|
302
|
+
if (property === 'bold' && activeConditionals.length > 0) {
|
|
298
303
|
const table = cell._getParentRow()?._getParentTable();
|
|
299
304
|
if (table) {
|
|
300
305
|
const tblLookFlags = table.getTblLookFlags();
|
|
301
306
|
for (const conditionalType of activeConditionals) {
|
|
302
|
-
if (conditionalType ===
|
|
307
|
+
if (conditionalType === 'firstRow' && tblLookFlags.firstRow)
|
|
303
308
|
return true;
|
|
304
|
-
if (conditionalType ===
|
|
309
|
+
if (conditionalType === 'lastRow' && tblLookFlags.lastRow)
|
|
305
310
|
return true;
|
|
306
|
-
if (conditionalType ===
|
|
311
|
+
if (conditionalType === 'firstCol' && tblLookFlags.firstColumn)
|
|
307
312
|
return true;
|
|
308
|
-
if (conditionalType ===
|
|
313
|
+
if (conditionalType === 'lastCol' && tblLookFlags.lastColumn)
|
|
309
314
|
return true;
|
|
310
315
|
}
|
|
311
316
|
}
|
|
@@ -784,226 +789,228 @@ class Run {
|
|
|
784
789
|
}
|
|
785
790
|
for (const contentElement of this.content) {
|
|
786
791
|
switch (contentElement.type) {
|
|
787
|
-
case
|
|
788
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.w(
|
|
789
|
-
|
|
790
|
-
}, [contentElement.value ||
|
|
792
|
+
case 'text':
|
|
793
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.w('t', {
|
|
794
|
+
'xml:space': 'preserve',
|
|
795
|
+
}, [contentElement.value || '']));
|
|
791
796
|
break;
|
|
792
|
-
case
|
|
793
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
797
|
+
case 'tab':
|
|
798
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('tab'));
|
|
794
799
|
break;
|
|
795
|
-
case
|
|
800
|
+
case 'break':
|
|
796
801
|
{
|
|
797
802
|
const attrs = {};
|
|
798
803
|
if (contentElement.breakType) {
|
|
799
|
-
attrs[
|
|
804
|
+
attrs['w:type'] = contentElement.breakType;
|
|
800
805
|
}
|
|
801
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
806
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('br', Object.keys(attrs).length > 0 ? attrs : undefined));
|
|
802
807
|
}
|
|
803
808
|
break;
|
|
804
|
-
case
|
|
805
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
809
|
+
case 'carriageReturn':
|
|
810
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('cr'));
|
|
806
811
|
break;
|
|
807
|
-
case
|
|
808
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
812
|
+
case 'softHyphen':
|
|
813
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('softHyphen'));
|
|
809
814
|
break;
|
|
810
|
-
case
|
|
811
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
815
|
+
case 'noBreakHyphen':
|
|
816
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('noBreakHyphen'));
|
|
812
817
|
break;
|
|
813
|
-
case
|
|
814
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.w(
|
|
815
|
-
contentElement.value || "",
|
|
816
|
-
]));
|
|
818
|
+
case 'instructionText':
|
|
819
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.w('instrText', { 'xml:space': 'preserve' }, [contentElement.value || '']));
|
|
817
820
|
break;
|
|
818
|
-
case
|
|
821
|
+
case 'fieldChar': {
|
|
819
822
|
if (!contentElement.fieldCharType) {
|
|
820
823
|
break;
|
|
821
824
|
}
|
|
822
825
|
const fldCharAttrs = {
|
|
823
|
-
|
|
826
|
+
'w:fldCharType': contentElement.fieldCharType,
|
|
824
827
|
};
|
|
825
828
|
if (contentElement.fieldCharDirty !== undefined) {
|
|
826
|
-
fldCharAttrs[
|
|
829
|
+
fldCharAttrs['w:dirty'] = contentElement.fieldCharDirty ? '1' : '0';
|
|
827
830
|
}
|
|
828
831
|
if (contentElement.fieldCharLocked !== undefined) {
|
|
829
|
-
fldCharAttrs[
|
|
832
|
+
fldCharAttrs['w:fldLock'] = contentElement.fieldCharLocked ? '1' : '0';
|
|
830
833
|
}
|
|
831
|
-
if (contentElement.formFieldData && contentElement.fieldCharType ===
|
|
834
|
+
if (contentElement.formFieldData && contentElement.fieldCharType === 'begin') {
|
|
832
835
|
const ffDataChildren = [];
|
|
833
836
|
const ffd = contentElement.formFieldData;
|
|
834
837
|
if (ffd.name !== undefined) {
|
|
835
|
-
ffDataChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
838
|
+
ffDataChildren.push(XMLBuilder_1.XMLBuilder.wSelf('name', { 'w:val': ffd.name }));
|
|
836
839
|
}
|
|
837
840
|
if (ffd.enabled !== undefined) {
|
|
838
841
|
if (ffd.enabled) {
|
|
839
|
-
ffDataChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
842
|
+
ffDataChildren.push(XMLBuilder_1.XMLBuilder.wSelf('enabled'));
|
|
840
843
|
}
|
|
841
844
|
else {
|
|
842
|
-
ffDataChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
845
|
+
ffDataChildren.push(XMLBuilder_1.XMLBuilder.wSelf('enabled', { 'w:val': '0' }));
|
|
843
846
|
}
|
|
844
847
|
}
|
|
845
848
|
if (ffd.calcOnExit !== undefined) {
|
|
846
|
-
ffDataChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
849
|
+
ffDataChildren.push(XMLBuilder_1.XMLBuilder.wSelf('calcOnExit', { 'w:val': ffd.calcOnExit ? '1' : '0' }));
|
|
847
850
|
}
|
|
848
851
|
if (ffd.helpText) {
|
|
849
|
-
ffDataChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
852
|
+
ffDataChildren.push(XMLBuilder_1.XMLBuilder.wSelf('helpText', { 'w:type': 'text', 'w:val': ffd.helpText }));
|
|
850
853
|
}
|
|
851
854
|
if (ffd.statusText) {
|
|
852
|
-
ffDataChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
855
|
+
ffDataChildren.push(XMLBuilder_1.XMLBuilder.wSelf('statusText', { 'w:type': 'text', 'w:val': ffd.statusText }));
|
|
853
856
|
}
|
|
854
857
|
if (ffd.entryMacro) {
|
|
855
|
-
ffDataChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
858
|
+
ffDataChildren.push(XMLBuilder_1.XMLBuilder.wSelf('entryMacro', { 'w:val': ffd.entryMacro }));
|
|
856
859
|
}
|
|
857
860
|
if (ffd.exitMacro) {
|
|
858
|
-
ffDataChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
861
|
+
ffDataChildren.push(XMLBuilder_1.XMLBuilder.wSelf('exitMacro', { 'w:val': ffd.exitMacro }));
|
|
859
862
|
}
|
|
860
863
|
if (ffd.fieldType) {
|
|
861
864
|
switch (ffd.fieldType.type) {
|
|
862
865
|
case 'textInput': {
|
|
863
866
|
const tiChildren = [];
|
|
864
867
|
if (ffd.fieldType.inputType) {
|
|
865
|
-
tiChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
868
|
+
tiChildren.push(XMLBuilder_1.XMLBuilder.wSelf('type', { 'w:val': ffd.fieldType.inputType }));
|
|
866
869
|
}
|
|
867
870
|
if (ffd.fieldType.defaultValue !== undefined) {
|
|
868
|
-
tiChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
871
|
+
tiChildren.push(XMLBuilder_1.XMLBuilder.wSelf('default', { 'w:val': ffd.fieldType.defaultValue }));
|
|
869
872
|
}
|
|
870
873
|
if (ffd.fieldType.maxLength !== undefined) {
|
|
871
|
-
tiChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
874
|
+
tiChildren.push(XMLBuilder_1.XMLBuilder.wSelf('maxLength', { 'w:val': ffd.fieldType.maxLength.toString() }));
|
|
872
875
|
}
|
|
873
876
|
if (ffd.fieldType.format) {
|
|
874
|
-
tiChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
877
|
+
tiChildren.push(XMLBuilder_1.XMLBuilder.wSelf('format', { 'w:val': ffd.fieldType.format }));
|
|
875
878
|
}
|
|
876
|
-
ffDataChildren.push(XMLBuilder_1.XMLBuilder.w(
|
|
879
|
+
ffDataChildren.push(XMLBuilder_1.XMLBuilder.w('textInput', {}, tiChildren));
|
|
877
880
|
break;
|
|
878
881
|
}
|
|
879
882
|
case 'checkBox': {
|
|
880
883
|
const cbChildren = [];
|
|
881
884
|
if (ffd.fieldType.size !== undefined && ffd.fieldType.size !== 'auto') {
|
|
882
|
-
cbChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
885
|
+
cbChildren.push(XMLBuilder_1.XMLBuilder.wSelf('size', { 'w:val': ffd.fieldType.size.toString() }));
|
|
883
886
|
}
|
|
884
887
|
else {
|
|
885
|
-
cbChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
888
|
+
cbChildren.push(XMLBuilder_1.XMLBuilder.wSelf('sizeAuto'));
|
|
886
889
|
}
|
|
887
890
|
if (ffd.fieldType.defaultChecked !== undefined) {
|
|
888
|
-
cbChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
891
|
+
cbChildren.push(XMLBuilder_1.XMLBuilder.wSelf('default', {
|
|
892
|
+
'w:val': ffd.fieldType.defaultChecked ? '1' : '0',
|
|
893
|
+
}));
|
|
889
894
|
}
|
|
890
895
|
if (ffd.fieldType.checked !== undefined) {
|
|
891
|
-
cbChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
896
|
+
cbChildren.push(XMLBuilder_1.XMLBuilder.wSelf('checked', { 'w:val': ffd.fieldType.checked ? '1' : '0' }));
|
|
892
897
|
}
|
|
893
|
-
ffDataChildren.push(XMLBuilder_1.XMLBuilder.w(
|
|
898
|
+
ffDataChildren.push(XMLBuilder_1.XMLBuilder.w('checkBox', {}, cbChildren));
|
|
894
899
|
break;
|
|
895
900
|
}
|
|
896
901
|
case 'dropDownList': {
|
|
897
902
|
const ddChildren = [];
|
|
898
903
|
if (ffd.fieldType.result !== undefined) {
|
|
899
|
-
ddChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
904
|
+
ddChildren.push(XMLBuilder_1.XMLBuilder.wSelf('result', { 'w:val': ffd.fieldType.result.toString() }));
|
|
900
905
|
}
|
|
901
906
|
if (ffd.fieldType.defaultResult !== undefined) {
|
|
902
|
-
ddChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
907
|
+
ddChildren.push(XMLBuilder_1.XMLBuilder.wSelf('default', {
|
|
908
|
+
'w:val': ffd.fieldType.defaultResult.toString(),
|
|
909
|
+
}));
|
|
903
910
|
}
|
|
904
911
|
if (ffd.fieldType.listEntries) {
|
|
905
912
|
for (const entry of ffd.fieldType.listEntries) {
|
|
906
|
-
ddChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
913
|
+
ddChildren.push(XMLBuilder_1.XMLBuilder.wSelf('listEntry', { 'w:val': entry }));
|
|
907
914
|
}
|
|
908
915
|
}
|
|
909
|
-
ffDataChildren.push(XMLBuilder_1.XMLBuilder.w(
|
|
916
|
+
ffDataChildren.push(XMLBuilder_1.XMLBuilder.w('ddList', {}, ddChildren));
|
|
910
917
|
break;
|
|
911
918
|
}
|
|
912
919
|
}
|
|
913
920
|
}
|
|
914
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.w(
|
|
921
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.w('fldChar', fldCharAttrs, [XMLBuilder_1.XMLBuilder.w('ffData', {}, ffDataChildren)]));
|
|
915
922
|
}
|
|
916
923
|
else {
|
|
917
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
924
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('fldChar', Object.keys(fldCharAttrs).length > 0 ? fldCharAttrs : undefined));
|
|
918
925
|
}
|
|
919
926
|
break;
|
|
920
927
|
}
|
|
921
|
-
case
|
|
922
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
928
|
+
case 'lastRenderedPageBreak':
|
|
929
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('lastRenderedPageBreak'));
|
|
923
930
|
break;
|
|
924
|
-
case
|
|
925
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
931
|
+
case 'separator':
|
|
932
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('separator'));
|
|
926
933
|
break;
|
|
927
|
-
case
|
|
928
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
934
|
+
case 'continuationSeparator':
|
|
935
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('continuationSeparator'));
|
|
929
936
|
break;
|
|
930
|
-
case
|
|
931
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
937
|
+
case 'pageNumber':
|
|
938
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('pgNum'));
|
|
932
939
|
break;
|
|
933
|
-
case
|
|
934
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
940
|
+
case 'annotationRef':
|
|
941
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('annotationRef'));
|
|
935
942
|
break;
|
|
936
|
-
case
|
|
937
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
943
|
+
case 'dayShort':
|
|
944
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('dayShort'));
|
|
938
945
|
break;
|
|
939
|
-
case
|
|
940
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
946
|
+
case 'dayLong':
|
|
947
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('dayLong'));
|
|
941
948
|
break;
|
|
942
|
-
case
|
|
943
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
949
|
+
case 'monthShort':
|
|
950
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('monthShort'));
|
|
944
951
|
break;
|
|
945
|
-
case
|
|
946
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
952
|
+
case 'monthLong':
|
|
953
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('monthLong'));
|
|
947
954
|
break;
|
|
948
|
-
case
|
|
949
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
955
|
+
case 'yearShort':
|
|
956
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('yearShort'));
|
|
950
957
|
break;
|
|
951
|
-
case
|
|
952
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
958
|
+
case 'yearLong':
|
|
959
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('yearLong'));
|
|
953
960
|
break;
|
|
954
|
-
case
|
|
961
|
+
case 'symbol': {
|
|
955
962
|
const symAttrs = {};
|
|
956
963
|
if (contentElement.symbolFont)
|
|
957
|
-
symAttrs[
|
|
964
|
+
symAttrs['w:font'] = contentElement.symbolFont;
|
|
958
965
|
if (contentElement.symbolChar)
|
|
959
|
-
symAttrs[
|
|
960
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
966
|
+
symAttrs['w:char'] = contentElement.symbolChar;
|
|
967
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('sym', symAttrs));
|
|
961
968
|
break;
|
|
962
969
|
}
|
|
963
|
-
case
|
|
970
|
+
case 'positionTab': {
|
|
964
971
|
const ptabAttrs = {};
|
|
965
972
|
if (contentElement.ptabAlignment)
|
|
966
|
-
ptabAttrs[
|
|
973
|
+
ptabAttrs['w:alignment'] = contentElement.ptabAlignment;
|
|
967
974
|
if (contentElement.ptabRelativeTo)
|
|
968
|
-
ptabAttrs[
|
|
975
|
+
ptabAttrs['w:relativeTo'] = contentElement.ptabRelativeTo;
|
|
969
976
|
if (contentElement.ptabLeader)
|
|
970
|
-
ptabAttrs[
|
|
971
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
977
|
+
ptabAttrs['w:leader'] = contentElement.ptabLeader;
|
|
978
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('ptab', ptabAttrs));
|
|
972
979
|
break;
|
|
973
980
|
}
|
|
974
|
-
case
|
|
981
|
+
case 'footnoteReference': {
|
|
975
982
|
const fnAttrs = {};
|
|
976
983
|
if (contentElement.footnoteId !== undefined)
|
|
977
|
-
fnAttrs[
|
|
978
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
984
|
+
fnAttrs['w:id'] = contentElement.footnoteId;
|
|
985
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('footnoteReference', fnAttrs));
|
|
979
986
|
break;
|
|
980
987
|
}
|
|
981
|
-
case
|
|
988
|
+
case 'endnoteReference': {
|
|
982
989
|
const enAttrs = {};
|
|
983
990
|
if (contentElement.endnoteId !== undefined)
|
|
984
|
-
enAttrs[
|
|
985
|
-
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
991
|
+
enAttrs['w:id'] = contentElement.endnoteId;
|
|
992
|
+
runChildren.push(XMLBuilder_1.XMLBuilder.wSelf('endnoteReference', enAttrs));
|
|
986
993
|
break;
|
|
987
994
|
}
|
|
988
|
-
case
|
|
995
|
+
case 'embeddedObject':
|
|
989
996
|
if (contentElement.rawXml) {
|
|
990
997
|
runChildren.push({
|
|
991
|
-
name:
|
|
998
|
+
name: '__rawXml',
|
|
992
999
|
rawXml: contentElement.rawXml,
|
|
993
1000
|
});
|
|
994
1001
|
}
|
|
995
1002
|
break;
|
|
996
|
-
case
|
|
1003
|
+
case 'vml':
|
|
997
1004
|
if (contentElement.rawXml) {
|
|
998
1005
|
runChildren.push({
|
|
999
|
-
name:
|
|
1006
|
+
name: '__rawXml',
|
|
1000
1007
|
rawXml: contentElement.rawXml,
|
|
1001
1008
|
});
|
|
1002
1009
|
}
|
|
1003
1010
|
break;
|
|
1004
1011
|
}
|
|
1005
1012
|
}
|
|
1006
|
-
return XMLBuilder_1.XMLBuilder.w(
|
|
1013
|
+
return XMLBuilder_1.XMLBuilder.w('r', undefined, runChildren);
|
|
1007
1014
|
}
|
|
1008
1015
|
hasText() {
|
|
1009
1016
|
const text = this.getText();
|
|
@@ -1019,21 +1026,21 @@ class Run {
|
|
|
1019
1026
|
return [...this.content];
|
|
1020
1027
|
}
|
|
1021
1028
|
addTab() {
|
|
1022
|
-
this.content.push({ type:
|
|
1029
|
+
this.content.push({ type: 'tab' });
|
|
1023
1030
|
return this;
|
|
1024
1031
|
}
|
|
1025
1032
|
addBreak(breakType) {
|
|
1026
|
-
this.content.push({ type:
|
|
1033
|
+
this.content.push({ type: 'break', breakType });
|
|
1027
1034
|
return this;
|
|
1028
1035
|
}
|
|
1029
1036
|
appendText(text) {
|
|
1030
1037
|
if (text) {
|
|
1031
|
-
this.content.push({ type:
|
|
1038
|
+
this.content.push({ type: 'text', value: text });
|
|
1032
1039
|
}
|
|
1033
1040
|
return this;
|
|
1034
1041
|
}
|
|
1035
1042
|
addCarriageReturn() {
|
|
1036
|
-
this.content.push({ type:
|
|
1043
|
+
this.content.push({ type: 'carriageReturn' });
|
|
1037
1044
|
return this;
|
|
1038
1045
|
}
|
|
1039
1046
|
static createFromContent(content, formatting = {}) {
|
|
@@ -1046,221 +1053,232 @@ class Run {
|
|
|
1046
1053
|
static generateRunPropertiesXML(formatting) {
|
|
1047
1054
|
const rPrChildren = [];
|
|
1048
1055
|
if (formatting.characterStyle) {
|
|
1049
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1050
|
-
|
|
1056
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('rStyle', {
|
|
1057
|
+
'w:val': formatting.characterStyle,
|
|
1051
1058
|
}));
|
|
1052
1059
|
}
|
|
1053
|
-
if (formatting.font ||
|
|
1054
|
-
formatting.
|
|
1060
|
+
if (formatting.font ||
|
|
1061
|
+
formatting.fontHAnsi ||
|
|
1062
|
+
formatting.fontEastAsia ||
|
|
1063
|
+
formatting.fontCs ||
|
|
1064
|
+
formatting.fontHint ||
|
|
1065
|
+
formatting.fontAsciiTheme ||
|
|
1066
|
+
formatting.fontHAnsiTheme ||
|
|
1067
|
+
formatting.fontEastAsiaTheme ||
|
|
1068
|
+
formatting.fontCsTheme) {
|
|
1055
1069
|
const rFontsAttrs = {};
|
|
1056
1070
|
if (formatting.font)
|
|
1057
|
-
rFontsAttrs[
|
|
1058
|
-
rFontsAttrs[
|
|
1071
|
+
rFontsAttrs['w:ascii'] = formatting.font;
|
|
1072
|
+
rFontsAttrs['w:hAnsi'] = formatting.fontHAnsi || formatting.font || '';
|
|
1059
1073
|
if (formatting.fontEastAsia)
|
|
1060
|
-
rFontsAttrs[
|
|
1061
|
-
rFontsAttrs[
|
|
1074
|
+
rFontsAttrs['w:eastAsia'] = formatting.fontEastAsia;
|
|
1075
|
+
rFontsAttrs['w:cs'] = formatting.fontCs || formatting.font || '';
|
|
1062
1076
|
if (formatting.fontHint)
|
|
1063
|
-
rFontsAttrs[
|
|
1077
|
+
rFontsAttrs['w:hint'] = formatting.fontHint;
|
|
1064
1078
|
if (formatting.fontAsciiTheme)
|
|
1065
|
-
rFontsAttrs[
|
|
1079
|
+
rFontsAttrs['w:asciiTheme'] = formatting.fontAsciiTheme;
|
|
1066
1080
|
if (formatting.fontHAnsiTheme)
|
|
1067
|
-
rFontsAttrs[
|
|
1081
|
+
rFontsAttrs['w:hAnsiTheme'] = formatting.fontHAnsiTheme;
|
|
1068
1082
|
if (formatting.fontEastAsiaTheme)
|
|
1069
|
-
rFontsAttrs[
|
|
1083
|
+
rFontsAttrs['w:eastAsiaTheme'] = formatting.fontEastAsiaTheme;
|
|
1070
1084
|
if (formatting.fontCsTheme)
|
|
1071
|
-
rFontsAttrs[
|
|
1085
|
+
rFontsAttrs['w:cstheme'] = formatting.fontCsTheme;
|
|
1072
1086
|
for (const key of Object.keys(rFontsAttrs)) {
|
|
1073
|
-
if (rFontsAttrs[key] ===
|
|
1087
|
+
if (rFontsAttrs[key] === '')
|
|
1074
1088
|
delete rFontsAttrs[key];
|
|
1075
1089
|
}
|
|
1076
1090
|
if (Object.keys(rFontsAttrs).length > 0) {
|
|
1077
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1091
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('rFonts', rFontsAttrs));
|
|
1078
1092
|
}
|
|
1079
1093
|
}
|
|
1080
1094
|
if (formatting.bold) {
|
|
1081
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1095
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('b', { 'w:val': '1' }));
|
|
1082
1096
|
}
|
|
1083
1097
|
if (formatting.complexScriptBold) {
|
|
1084
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1098
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('bCs', { 'w:val': '1' }));
|
|
1085
1099
|
}
|
|
1086
1100
|
if (formatting.italic) {
|
|
1087
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1101
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('i', { 'w:val': '1' }));
|
|
1088
1102
|
}
|
|
1089
1103
|
if (formatting.complexScriptItalic) {
|
|
1090
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1104
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('iCs', { 'w:val': '1' }));
|
|
1091
1105
|
}
|
|
1092
1106
|
if (formatting.allCaps) {
|
|
1093
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1107
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('caps', { 'w:val': '1' }));
|
|
1094
1108
|
}
|
|
1095
1109
|
if (formatting.smallCaps) {
|
|
1096
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1110
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('smallCaps', { 'w:val': '1' }));
|
|
1097
1111
|
}
|
|
1098
1112
|
if (formatting.strike) {
|
|
1099
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1113
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('strike', { 'w:val': '1' }));
|
|
1100
1114
|
}
|
|
1101
1115
|
if (formatting.dstrike) {
|
|
1102
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1116
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('dstrike', { 'w:val': '1' }));
|
|
1103
1117
|
}
|
|
1104
1118
|
if (formatting.outline) {
|
|
1105
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1119
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('outline', { 'w:val': '1' }));
|
|
1106
1120
|
}
|
|
1107
1121
|
if (formatting.shadow) {
|
|
1108
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1122
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('shadow', { 'w:val': '1' }));
|
|
1109
1123
|
}
|
|
1110
1124
|
if (formatting.emboss) {
|
|
1111
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1125
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('emboss', { 'w:val': '1' }));
|
|
1112
1126
|
}
|
|
1113
1127
|
if (formatting.imprint) {
|
|
1114
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1128
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('imprint', { 'w:val': '1' }));
|
|
1115
1129
|
}
|
|
1116
1130
|
if (formatting.noProof) {
|
|
1117
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1131
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('noProof', { 'w:val': '1' }));
|
|
1118
1132
|
}
|
|
1119
1133
|
if (formatting.snapToGrid) {
|
|
1120
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1134
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('snapToGrid', { 'w:val': '1' }));
|
|
1121
1135
|
}
|
|
1122
1136
|
if (formatting.vanish) {
|
|
1123
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1137
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('vanish', { 'w:val': '1' }));
|
|
1124
1138
|
}
|
|
1125
1139
|
if (formatting.webHidden) {
|
|
1126
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1140
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('webHidden', { 'w:val': '1' }));
|
|
1127
1141
|
}
|
|
1128
1142
|
if (formatting.color || formatting.themeColor) {
|
|
1129
1143
|
const colorAttrs = {};
|
|
1130
|
-
colorAttrs[
|
|
1144
|
+
colorAttrs['w:val'] = formatting.color || '000000';
|
|
1131
1145
|
if (formatting.themeColor) {
|
|
1132
|
-
colorAttrs[
|
|
1146
|
+
colorAttrs['w:themeColor'] = formatting.themeColor;
|
|
1133
1147
|
}
|
|
1134
1148
|
if (formatting.themeTint !== undefined) {
|
|
1135
|
-
colorAttrs[
|
|
1149
|
+
colorAttrs['w:themeTint'] = formatting.themeTint
|
|
1136
1150
|
.toString(16)
|
|
1137
1151
|
.toUpperCase()
|
|
1138
|
-
.padStart(2,
|
|
1152
|
+
.padStart(2, '0');
|
|
1139
1153
|
}
|
|
1140
1154
|
if (formatting.themeShade !== undefined) {
|
|
1141
|
-
colorAttrs[
|
|
1155
|
+
colorAttrs['w:themeShade'] = formatting.themeShade
|
|
1142
1156
|
.toString(16)
|
|
1143
1157
|
.toUpperCase()
|
|
1144
|
-
.padStart(2,
|
|
1158
|
+
.padStart(2, '0');
|
|
1145
1159
|
}
|
|
1146
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1160
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('color', colorAttrs));
|
|
1147
1161
|
}
|
|
1148
1162
|
if (formatting.characterSpacing !== undefined) {
|
|
1149
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1163
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('spacing', { 'w:val': formatting.characterSpacing }));
|
|
1150
1164
|
}
|
|
1151
1165
|
if (formatting.scaling !== undefined) {
|
|
1152
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1166
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('w', { 'w:val': formatting.scaling }));
|
|
1153
1167
|
}
|
|
1154
1168
|
if (formatting.kerning !== undefined && formatting.kerning !== null) {
|
|
1155
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1169
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('kern', { 'w:val': formatting.kerning }));
|
|
1156
1170
|
}
|
|
1157
1171
|
if (formatting.position !== undefined) {
|
|
1158
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1172
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('position', { 'w:val': formatting.position }));
|
|
1159
1173
|
}
|
|
1160
1174
|
if (formatting.size !== undefined) {
|
|
1161
1175
|
const halfPoints = (0, units_1.pointsToHalfPoints)(formatting.size);
|
|
1162
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1176
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('sz', { 'w:val': halfPoints }));
|
|
1163
1177
|
const csHalfPoints = formatting.sizeCs !== undefined ? (0, units_1.pointsToHalfPoints)(formatting.sizeCs) : halfPoints;
|
|
1164
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1178
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('szCs', { 'w:val': csHalfPoints }));
|
|
1165
1179
|
}
|
|
1166
1180
|
else if (formatting.sizeCs !== undefined) {
|
|
1167
1181
|
const csHalfPoints = (0, units_1.pointsToHalfPoints)(formatting.sizeCs);
|
|
1168
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1182
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('szCs', { 'w:val': csHalfPoints }));
|
|
1169
1183
|
}
|
|
1170
1184
|
if (formatting.highlight) {
|
|
1171
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1185
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('highlight', { 'w:val': formatting.highlight }));
|
|
1172
1186
|
}
|
|
1173
1187
|
if (formatting.underline) {
|
|
1174
|
-
const underlineValue = typeof formatting.underline ===
|
|
1175
|
-
|
|
1176
|
-
: "single";
|
|
1177
|
-
const uAttrs = { "w:val": underlineValue };
|
|
1188
|
+
const underlineValue = typeof formatting.underline === 'string' ? formatting.underline : 'single';
|
|
1189
|
+
const uAttrs = { 'w:val': underlineValue };
|
|
1178
1190
|
if (formatting.underlineColor)
|
|
1179
|
-
uAttrs[
|
|
1191
|
+
uAttrs['w:color'] = formatting.underlineColor;
|
|
1180
1192
|
if (formatting.underlineThemeColor)
|
|
1181
|
-
uAttrs[
|
|
1193
|
+
uAttrs['w:themeColor'] = formatting.underlineThemeColor;
|
|
1182
1194
|
if (formatting.underlineThemeTint !== undefined)
|
|
1183
|
-
uAttrs[
|
|
1195
|
+
uAttrs['w:themeTint'] = formatting.underlineThemeTint
|
|
1196
|
+
.toString(16)
|
|
1197
|
+
.toUpperCase()
|
|
1198
|
+
.padStart(2, '0');
|
|
1184
1199
|
if (formatting.underlineThemeShade !== undefined)
|
|
1185
|
-
uAttrs[
|
|
1186
|
-
|
|
1200
|
+
uAttrs['w:themeShade'] = formatting.underlineThemeShade
|
|
1201
|
+
.toString(16)
|
|
1202
|
+
.toUpperCase()
|
|
1203
|
+
.padStart(2, '0');
|
|
1204
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('u', uAttrs));
|
|
1187
1205
|
}
|
|
1188
1206
|
else if (formatting.underline === false && formatting.characterStyle) {
|
|
1189
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1207
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('u', { 'w:val': 'none' }));
|
|
1190
1208
|
}
|
|
1191
1209
|
if (formatting.effect) {
|
|
1192
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1210
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('effect', { 'w:val': formatting.effect }));
|
|
1193
1211
|
}
|
|
1194
1212
|
if (formatting.border) {
|
|
1195
1213
|
const bdrAttrs = {};
|
|
1196
1214
|
if (formatting.border.style)
|
|
1197
|
-
bdrAttrs[
|
|
1215
|
+
bdrAttrs['w:val'] = formatting.border.style;
|
|
1198
1216
|
if (formatting.border.size !== undefined)
|
|
1199
|
-
bdrAttrs[
|
|
1217
|
+
bdrAttrs['w:sz'] = formatting.border.size;
|
|
1200
1218
|
if (formatting.border.color)
|
|
1201
|
-
bdrAttrs[
|
|
1219
|
+
bdrAttrs['w:color'] = formatting.border.color;
|
|
1202
1220
|
if (formatting.border.space !== undefined)
|
|
1203
|
-
bdrAttrs[
|
|
1221
|
+
bdrAttrs['w:space'] = formatting.border.space;
|
|
1204
1222
|
if (Object.keys(bdrAttrs).length > 0) {
|
|
1205
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1223
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('bdr', bdrAttrs));
|
|
1206
1224
|
}
|
|
1207
1225
|
}
|
|
1208
1226
|
if (formatting.shading) {
|
|
1209
1227
|
const shdAttrs = (0, CommonTypes_1.buildShadingAttributes)(formatting.shading);
|
|
1210
1228
|
if (Object.keys(shdAttrs).length > 0) {
|
|
1211
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1229
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('shd', shdAttrs));
|
|
1212
1230
|
}
|
|
1213
1231
|
}
|
|
1214
1232
|
if (formatting.fitText !== undefined) {
|
|
1215
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1233
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('fitText', { 'w:val': formatting.fitText }));
|
|
1216
1234
|
}
|
|
1217
1235
|
if (formatting.subscript) {
|
|
1218
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1236
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('vertAlign', { 'w:val': 'subscript' }));
|
|
1219
1237
|
}
|
|
1220
1238
|
if (formatting.superscript) {
|
|
1221
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1239
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('vertAlign', { 'w:val': 'superscript' }));
|
|
1222
1240
|
}
|
|
1223
1241
|
if (formatting.rtl) {
|
|
1224
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1242
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('rtl', { 'w:val': '1' }));
|
|
1225
1243
|
}
|
|
1226
1244
|
if (formatting.complexScript) {
|
|
1227
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1245
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('cs', { 'w:val': '1' }));
|
|
1228
1246
|
}
|
|
1229
1247
|
if (formatting.emphasis) {
|
|
1230
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1248
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('em', { 'w:val': formatting.emphasis }));
|
|
1231
1249
|
}
|
|
1232
1250
|
if (formatting.language) {
|
|
1233
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1251
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('lang', { 'w:val': formatting.language }));
|
|
1234
1252
|
}
|
|
1235
1253
|
if (formatting.eastAsianLayout) {
|
|
1236
1254
|
const layout = formatting.eastAsianLayout;
|
|
1237
1255
|
const attrs = {};
|
|
1238
1256
|
if (layout.id !== undefined)
|
|
1239
|
-
attrs[
|
|
1257
|
+
attrs['w:id'] = layout.id;
|
|
1240
1258
|
if (layout.vert)
|
|
1241
|
-
attrs[
|
|
1259
|
+
attrs['w:vert'] = '1';
|
|
1242
1260
|
if (layout.vertCompress)
|
|
1243
|
-
attrs[
|
|
1261
|
+
attrs['w:vertCompress'] = '1';
|
|
1244
1262
|
if (layout.combine)
|
|
1245
|
-
attrs[
|
|
1263
|
+
attrs['w:combine'] = '1';
|
|
1246
1264
|
if (layout.combineBrackets)
|
|
1247
|
-
attrs[
|
|
1265
|
+
attrs['w:combineBrackets'] = layout.combineBrackets;
|
|
1248
1266
|
if (Object.keys(attrs).length > 0) {
|
|
1249
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1267
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('eastAsianLayout', attrs));
|
|
1250
1268
|
}
|
|
1251
1269
|
}
|
|
1252
1270
|
if (formatting.specVanish) {
|
|
1253
|
-
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf(
|
|
1271
|
+
rPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('specVanish', { 'w:val': '1' }));
|
|
1254
1272
|
}
|
|
1255
1273
|
if (formatting.rawW14Properties && formatting.rawW14Properties.length > 0) {
|
|
1256
1274
|
for (const rawXml of formatting.rawW14Properties) {
|
|
1257
|
-
rPrChildren.push({ name:
|
|
1275
|
+
rPrChildren.push({ name: '__rawXml', rawXml });
|
|
1258
1276
|
}
|
|
1259
1277
|
}
|
|
1260
1278
|
if (rPrChildren.length === 0) {
|
|
1261
1279
|
return null;
|
|
1262
1280
|
}
|
|
1263
|
-
return XMLBuilder_1.XMLBuilder.w(
|
|
1281
|
+
return XMLBuilder_1.XMLBuilder.w('rPr', undefined, rPrChildren);
|
|
1264
1282
|
}
|
|
1265
1283
|
static create(text, formatting) {
|
|
1266
1284
|
return new Run(text, formatting);
|