docxmlater 1.3.0 → 1.3.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 +228 -31
- package/dist/core/BaseManager.d.ts +21 -0
- package/dist/core/BaseManager.d.ts.map +1 -0
- package/dist/core/BaseManager.js +86 -0
- package/dist/core/BaseManager.js.map +1 -0
- package/dist/core/Document.d.ts +18 -1
- package/dist/core/Document.d.ts.map +1 -1
- package/dist/core/Document.js +389 -0
- package/dist/core/Document.js.map +1 -1
- package/dist/core/DocumentParser.d.ts +4 -0
- package/dist/core/DocumentParser.d.ts.map +1 -1
- package/dist/core/DocumentParser.js +649 -103
- package/dist/core/DocumentParser.js.map +1 -1
- package/dist/elements/Comment.d.ts +1 -0
- package/dist/elements/Comment.d.ts.map +1 -1
- package/dist/elements/Comment.js +3 -0
- package/dist/elements/Comment.js.map +1 -1
- package/dist/elements/Field.d.ts +12 -0
- package/dist/elements/Field.d.ts.map +1 -1
- package/dist/elements/Field.js +34 -1
- package/dist/elements/Field.js.map +1 -1
- package/dist/elements/FieldHelpers.d.ts +7 -0
- package/dist/elements/FieldHelpers.d.ts.map +1 -0
- package/dist/elements/FieldHelpers.js +62 -0
- package/dist/elements/FieldHelpers.js.map +1 -0
- package/dist/elements/Hyperlink.d.ts +1 -0
- package/dist/elements/Hyperlink.d.ts.map +1 -1
- package/dist/elements/Hyperlink.js +6 -1
- package/dist/elements/Hyperlink.js.map +1 -1
- package/dist/elements/Paragraph.d.ts +6 -0
- package/dist/elements/Paragraph.d.ts.map +1 -1
- package/dist/elements/Paragraph.js +48 -2
- package/dist/elements/Paragraph.js.map +1 -1
- package/dist/elements/Run.d.ts +15 -3
- package/dist/elements/Run.d.ts.map +1 -1
- package/dist/elements/Run.js +122 -54
- package/dist/elements/Run.js.map +1 -1
- package/dist/elements/Section.d.ts +9 -0
- package/dist/elements/Section.d.ts.map +1 -1
- package/dist/elements/Section.js +21 -0
- package/dist/elements/Section.js.map +1 -1
- package/dist/elements/Table.d.ts +0 -1
- package/dist/elements/Table.d.ts.map +1 -1
- package/dist/elements/Table.js +18 -21
- package/dist/elements/Table.js.map +1 -1
- package/dist/elements/TableCell.d.ts +0 -1
- package/dist/elements/TableCell.d.ts.map +1 -1
- package/dist/elements/TableCell.js +4 -16
- package/dist/elements/TableCell.js.map +1 -1
- package/dist/elements/TableOfContents.d.ts +5 -0
- package/dist/elements/TableOfContents.d.ts.map +1 -1
- package/dist/elements/TableOfContents.js +31 -4
- package/dist/elements/TableOfContents.js.map +1 -1
- package/dist/formatting/NumberingLevel.d.ts +2 -0
- package/dist/formatting/NumberingLevel.d.ts.map +1 -1
- package/dist/formatting/NumberingLevel.js +8 -0
- package/dist/formatting/NumberingLevel.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -3
- package/dist/index.js.map +1 -1
- package/dist/utils/diagnostics.d.ts +20 -0
- package/dist/utils/diagnostics.d.ts.map +1 -0
- package/dist/utils/diagnostics.js +80 -0
- package/dist/utils/diagnostics.js.map +1 -0
- package/dist/utils/formatting.d.ts +7 -0
- package/dist/utils/formatting.d.ts.map +1 -0
- package/dist/utils/formatting.js +93 -0
- package/dist/utils/formatting.js.map +1 -0
- package/dist/utils/validation.d.ts +1 -0
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +12 -0
- package/dist/utils/validation.js.map +1 -1
- package/dist/xml/XMLBuilder.d.ts +25 -0
- package/dist/xml/XMLBuilder.d.ts.map +1 -1
- package/dist/xml/XMLBuilder.js +72 -0
- package/dist/xml/XMLBuilder.js.map +1 -1
- package/dist/xml/XMLParser.d.ts.map +1 -1
- package/dist/xml/XMLParser.js +15 -0
- package/dist/xml/XMLParser.js.map +1 -1
- package/package.json +1 -1
package/dist/core/Document.js
CHANGED
|
@@ -46,6 +46,7 @@ const HeaderFooterManager_1 = require("../elements/HeaderFooterManager");
|
|
|
46
46
|
const TableOfContents_1 = require("../elements/TableOfContents");
|
|
47
47
|
const TableOfContentsElement_1 = require("../elements/TableOfContentsElement");
|
|
48
48
|
const Bookmark_1 = require("../elements/Bookmark");
|
|
49
|
+
const StructuredDocumentTag_1 = require("../elements/StructuredDocumentTag");
|
|
49
50
|
const BookmarkManager_1 = require("../elements/BookmarkManager");
|
|
50
51
|
const Revision_1 = require("../elements/Revision");
|
|
51
52
|
const RevisionManager_1 = require("../elements/RevisionManager");
|
|
@@ -221,6 +222,52 @@ class Document {
|
|
|
221
222
|
getTables() {
|
|
222
223
|
return this.bodyElements.filter((el) => el instanceof Table_1.Table);
|
|
223
224
|
}
|
|
225
|
+
getAllParagraphs() {
|
|
226
|
+
const result = [];
|
|
227
|
+
for (const element of this.bodyElements) {
|
|
228
|
+
if (element instanceof Paragraph_1.Paragraph) {
|
|
229
|
+
result.push(element);
|
|
230
|
+
}
|
|
231
|
+
else if (element instanceof Table_1.Table) {
|
|
232
|
+
for (const row of element.getRows()) {
|
|
233
|
+
for (const cell of row.getCells()) {
|
|
234
|
+
result.push(...cell.getParagraphs());
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
else if (element instanceof StructuredDocumentTag_1.StructuredDocumentTag) {
|
|
239
|
+
for (const content of element.getContent()) {
|
|
240
|
+
if (content instanceof Paragraph_1.Paragraph) {
|
|
241
|
+
result.push(content);
|
|
242
|
+
}
|
|
243
|
+
else if (content instanceof Table_1.Table) {
|
|
244
|
+
for (const row of content.getRows()) {
|
|
245
|
+
for (const cell of row.getCells()) {
|
|
246
|
+
result.push(...cell.getParagraphs());
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
255
|
+
getAllTables() {
|
|
256
|
+
const result = [];
|
|
257
|
+
for (const element of this.bodyElements) {
|
|
258
|
+
if (element instanceof Table_1.Table) {
|
|
259
|
+
result.push(element);
|
|
260
|
+
}
|
|
261
|
+
else if (element instanceof StructuredDocumentTag_1.StructuredDocumentTag) {
|
|
262
|
+
for (const content of element.getContent()) {
|
|
263
|
+
if (content instanceof Table_1.Table) {
|
|
264
|
+
result.push(content);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return result;
|
|
270
|
+
}
|
|
224
271
|
getTableOfContentsElements() {
|
|
225
272
|
return this.bodyElements.filter((el) => el instanceof TableOfContentsElement_1.TableOfContentsElement);
|
|
226
273
|
}
|
|
@@ -598,6 +645,13 @@ class Document {
|
|
|
598
645
|
}
|
|
599
646
|
return tables.length;
|
|
600
647
|
}
|
|
648
|
+
applyBordersToAllTables(border) {
|
|
649
|
+
const tables = this.getAllTables();
|
|
650
|
+
for (const table of tables) {
|
|
651
|
+
table.setAllBorders(border);
|
|
652
|
+
}
|
|
653
|
+
return tables.length;
|
|
654
|
+
}
|
|
601
655
|
applyTableFormattingBySize(singleCellShading, multiCellFirstRowShading) {
|
|
602
656
|
const tables = this.getTables();
|
|
603
657
|
let singleCellCount = 0;
|
|
@@ -872,6 +926,341 @@ class Document {
|
|
|
872
926
|
normalizeAllListIndentation() {
|
|
873
927
|
return this.numberingManager.normalizeAllListIndentation();
|
|
874
928
|
}
|
|
929
|
+
applyStandardListFormatting() {
|
|
930
|
+
const instances = this.numberingManager.getAllInstances();
|
|
931
|
+
let count = 0;
|
|
932
|
+
for (const instance of instances) {
|
|
933
|
+
const abstractNumId = instance.getAbstractNumId();
|
|
934
|
+
const abstractNum = this.numberingManager.getAbstractNumbering(abstractNumId);
|
|
935
|
+
if (!abstractNum)
|
|
936
|
+
continue;
|
|
937
|
+
const level0 = abstractNum.getLevel(0);
|
|
938
|
+
if (!level0 || level0.getFormat() !== 'bullet')
|
|
939
|
+
continue;
|
|
940
|
+
for (let levelIndex = 0; levelIndex < 9; levelIndex++) {
|
|
941
|
+
const numLevel = abstractNum.getLevel(levelIndex);
|
|
942
|
+
if (!numLevel)
|
|
943
|
+
continue;
|
|
944
|
+
const bullet = levelIndex % 2 === 0 ? '•' : '○';
|
|
945
|
+
numLevel.setText(bullet);
|
|
946
|
+
numLevel.setFont('Arial');
|
|
947
|
+
numLevel.setFontSize(24);
|
|
948
|
+
numLevel.setLeftIndent(720 * (levelIndex + 1));
|
|
949
|
+
numLevel.setHangingIndent(360);
|
|
950
|
+
}
|
|
951
|
+
this.applyFormattingToListParagraphs(instance.getNumId());
|
|
952
|
+
count++;
|
|
953
|
+
}
|
|
954
|
+
return count;
|
|
955
|
+
}
|
|
956
|
+
applyFormattingToListParagraphs(numId) {
|
|
957
|
+
const paragraphs = this.getAllParagraphs();
|
|
958
|
+
for (const para of paragraphs) {
|
|
959
|
+
const numbering = para.getNumbering();
|
|
960
|
+
if (numbering?.numId === numId) {
|
|
961
|
+
const runs = para.getRuns();
|
|
962
|
+
for (const run of runs) {
|
|
963
|
+
run.setFont('Verdana', 12);
|
|
964
|
+
}
|
|
965
|
+
para.setSpaceBefore(0);
|
|
966
|
+
para.setSpaceAfter(60);
|
|
967
|
+
para.setContextualSpacing(true);
|
|
968
|
+
para.formatting.indentation = undefined;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
isParagraphInTable(para) {
|
|
973
|
+
const allTables = this.getAllTables();
|
|
974
|
+
for (const table of allTables) {
|
|
975
|
+
for (const row of table.getRows()) {
|
|
976
|
+
for (const cell of row.getCells()) {
|
|
977
|
+
const cellParas = cell.getParagraphs();
|
|
978
|
+
for (const cellPara of cellParas) {
|
|
979
|
+
if (cellPara === para) {
|
|
980
|
+
return { inTable: true, cell };
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
return { inTable: false };
|
|
987
|
+
}
|
|
988
|
+
wrapParagraphInTable(para, options) {
|
|
989
|
+
const paraIndex = this.bodyElements.indexOf(para);
|
|
990
|
+
if (paraIndex === -1) {
|
|
991
|
+
throw new Error('Paragraph not found in document body elements');
|
|
992
|
+
}
|
|
993
|
+
const table = new Table_1.Table(1, 1);
|
|
994
|
+
const cell = table.getCell(0, 0);
|
|
995
|
+
if (!cell) {
|
|
996
|
+
throw new Error('Failed to get cell from newly created table');
|
|
997
|
+
}
|
|
998
|
+
this.bodyElements.splice(paraIndex, 1);
|
|
999
|
+
cell.addParagraph(para);
|
|
1000
|
+
if (options.shading) {
|
|
1001
|
+
cell.setShading({ fill: options.shading });
|
|
1002
|
+
}
|
|
1003
|
+
if (options.marginTop !== undefined || options.marginBottom !== undefined ||
|
|
1004
|
+
options.marginLeft !== undefined || options.marginRight !== undefined) {
|
|
1005
|
+
cell.setMargins({
|
|
1006
|
+
top: options.marginTop ?? 100,
|
|
1007
|
+
bottom: options.marginBottom ?? 100,
|
|
1008
|
+
left: options.marginLeft ?? 100,
|
|
1009
|
+
right: options.marginRight ?? 100
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
if (options.tableWidthPercent !== undefined) {
|
|
1013
|
+
table.setWidth(options.tableWidthPercent);
|
|
1014
|
+
table.setWidthType('pct');
|
|
1015
|
+
}
|
|
1016
|
+
this.bodyElements.splice(paraIndex, 0, table);
|
|
1017
|
+
return table;
|
|
1018
|
+
}
|
|
1019
|
+
applyCustomStylesToDocument() {
|
|
1020
|
+
const counts = { heading1: 0, heading2: 0, normal: 0 };
|
|
1021
|
+
const header1Style = Style_1.Style.create({
|
|
1022
|
+
styleId: 'CustomHeader1',
|
|
1023
|
+
name: 'Custom Header 1',
|
|
1024
|
+
type: 'paragraph',
|
|
1025
|
+
basedOn: 'Normal',
|
|
1026
|
+
runFormatting: {
|
|
1027
|
+
font: 'Verdana',
|
|
1028
|
+
size: 18,
|
|
1029
|
+
bold: true,
|
|
1030
|
+
color: '000000'
|
|
1031
|
+
},
|
|
1032
|
+
paragraphFormatting: {
|
|
1033
|
+
alignment: 'left',
|
|
1034
|
+
spacing: {
|
|
1035
|
+
before: 0,
|
|
1036
|
+
after: 240
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
});
|
|
1040
|
+
const header2Style = Style_1.Style.create({
|
|
1041
|
+
styleId: 'CustomHeader2',
|
|
1042
|
+
name: 'Custom Header 2',
|
|
1043
|
+
type: 'paragraph',
|
|
1044
|
+
basedOn: 'Normal',
|
|
1045
|
+
runFormatting: {
|
|
1046
|
+
font: 'Verdana',
|
|
1047
|
+
size: 14,
|
|
1048
|
+
bold: true,
|
|
1049
|
+
color: '000000'
|
|
1050
|
+
},
|
|
1051
|
+
paragraphFormatting: {
|
|
1052
|
+
alignment: 'left',
|
|
1053
|
+
spacing: {
|
|
1054
|
+
before: 120,
|
|
1055
|
+
after: 120
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
});
|
|
1059
|
+
const normalStyle = Style_1.Style.create({
|
|
1060
|
+
styleId: 'CustomNormal',
|
|
1061
|
+
name: 'Custom Normal',
|
|
1062
|
+
type: 'paragraph',
|
|
1063
|
+
basedOn: 'Normal',
|
|
1064
|
+
runFormatting: {
|
|
1065
|
+
font: 'Verdana',
|
|
1066
|
+
size: 12,
|
|
1067
|
+
color: '000000'
|
|
1068
|
+
},
|
|
1069
|
+
paragraphFormatting: {
|
|
1070
|
+
alignment: 'left',
|
|
1071
|
+
spacing: {
|
|
1072
|
+
before: 60,
|
|
1073
|
+
after: 60
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
});
|
|
1077
|
+
this.addStyle(header1Style);
|
|
1078
|
+
this.addStyle(header2Style);
|
|
1079
|
+
this.addStyle(normalStyle);
|
|
1080
|
+
const allParagraphs = this.getAllParagraphs();
|
|
1081
|
+
for (const para of allParagraphs) {
|
|
1082
|
+
const currentStyle = para.getStyle();
|
|
1083
|
+
if (currentStyle === 'Heading1' || currentStyle === 'Heading 1') {
|
|
1084
|
+
para.setStyle('CustomHeader1');
|
|
1085
|
+
counts.heading1++;
|
|
1086
|
+
}
|
|
1087
|
+
else if (currentStyle === 'Heading2' || currentStyle === 'Heading 2') {
|
|
1088
|
+
para.setStyle('CustomHeader2');
|
|
1089
|
+
const { inTable, cell } = this.isParagraphInTable(para);
|
|
1090
|
+
if (inTable && cell) {
|
|
1091
|
+
cell.setShading({ fill: 'BFBFBF' });
|
|
1092
|
+
cell.setMargins({ top: 0, bottom: 0, left: 101, right: 101 });
|
|
1093
|
+
const table = this.getAllTables().find(t => {
|
|
1094
|
+
for (const row of t.getRows()) {
|
|
1095
|
+
for (const c of row.getCells()) {
|
|
1096
|
+
if (c === cell)
|
|
1097
|
+
return true;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
return false;
|
|
1101
|
+
});
|
|
1102
|
+
if (table) {
|
|
1103
|
+
table.setWidth(5000);
|
|
1104
|
+
table.setWidthType('pct');
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
else {
|
|
1108
|
+
this.wrapParagraphInTable(para, {
|
|
1109
|
+
shading: 'BFBFBF',
|
|
1110
|
+
marginTop: 0,
|
|
1111
|
+
marginBottom: 0,
|
|
1112
|
+
marginLeft: 101,
|
|
1113
|
+
marginRight: 101,
|
|
1114
|
+
tableWidthPercent: 5000
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
counts.heading2++;
|
|
1118
|
+
}
|
|
1119
|
+
else if (currentStyle === 'Normal' || currentStyle === undefined) {
|
|
1120
|
+
para.setStyle('CustomNormal');
|
|
1121
|
+
counts.normal++;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
return counts;
|
|
1125
|
+
}
|
|
1126
|
+
applyCustomFormattingToExistingStyles() {
|
|
1127
|
+
const results = { heading1: false, heading2: false, normal: false };
|
|
1128
|
+
const heading1 = this.stylesManager.getStyle('Heading1');
|
|
1129
|
+
const heading2 = this.stylesManager.getStyle('Heading2');
|
|
1130
|
+
const normal = this.stylesManager.getStyle('Normal');
|
|
1131
|
+
if (heading1) {
|
|
1132
|
+
heading1.setRunFormatting({
|
|
1133
|
+
font: 'Verdana',
|
|
1134
|
+
size: 18,
|
|
1135
|
+
bold: true,
|
|
1136
|
+
color: '000000'
|
|
1137
|
+
});
|
|
1138
|
+
heading1.setParagraphFormatting({
|
|
1139
|
+
alignment: 'left',
|
|
1140
|
+
spacing: { before: 0, after: 240, line: 240, lineRule: 'auto' }
|
|
1141
|
+
});
|
|
1142
|
+
results.heading1 = true;
|
|
1143
|
+
}
|
|
1144
|
+
if (heading2) {
|
|
1145
|
+
heading2.setRunFormatting({
|
|
1146
|
+
font: 'Verdana',
|
|
1147
|
+
size: 14,
|
|
1148
|
+
bold: true,
|
|
1149
|
+
color: '000000'
|
|
1150
|
+
});
|
|
1151
|
+
heading2.setParagraphFormatting({
|
|
1152
|
+
alignment: 'left',
|
|
1153
|
+
spacing: { before: 120, after: 120, line: 240, lineRule: 'auto' }
|
|
1154
|
+
});
|
|
1155
|
+
results.heading2 = true;
|
|
1156
|
+
}
|
|
1157
|
+
if (normal) {
|
|
1158
|
+
normal.setRunFormatting({
|
|
1159
|
+
font: 'Verdana',
|
|
1160
|
+
size: 12,
|
|
1161
|
+
color: '000000'
|
|
1162
|
+
});
|
|
1163
|
+
normal.setParagraphFormatting({
|
|
1164
|
+
alignment: 'left',
|
|
1165
|
+
spacing: { before: 60, after: 60, line: 240, lineRule: 'auto' }
|
|
1166
|
+
});
|
|
1167
|
+
results.normal = true;
|
|
1168
|
+
}
|
|
1169
|
+
const processedParagraphs = new Set();
|
|
1170
|
+
const allParas = this.getAllParagraphs();
|
|
1171
|
+
for (const para of allParas) {
|
|
1172
|
+
if (processedParagraphs.has(para)) {
|
|
1173
|
+
continue;
|
|
1174
|
+
}
|
|
1175
|
+
const styleId = para.getStyle();
|
|
1176
|
+
if (styleId === 'Heading1' && heading1) {
|
|
1177
|
+
para.clearDirectFormattingConflicts(heading1);
|
|
1178
|
+
for (const run of para.getRuns()) {
|
|
1179
|
+
run.setItalic(false);
|
|
1180
|
+
run.setUnderline(false);
|
|
1181
|
+
}
|
|
1182
|
+
if (para.formatting.paragraphMarkRunProperties) {
|
|
1183
|
+
delete para.formatting.paragraphMarkRunProperties.italic;
|
|
1184
|
+
delete para.formatting.paragraphMarkRunProperties.underline;
|
|
1185
|
+
}
|
|
1186
|
+
processedParagraphs.add(para);
|
|
1187
|
+
}
|
|
1188
|
+
else if (styleId === 'Heading2' && heading2) {
|
|
1189
|
+
const hasContent = para.getRuns().some(run => run.getText().trim().length > 0);
|
|
1190
|
+
if (!hasContent) {
|
|
1191
|
+
processedParagraphs.add(para);
|
|
1192
|
+
continue;
|
|
1193
|
+
}
|
|
1194
|
+
para.clearDirectFormattingConflicts(heading2);
|
|
1195
|
+
for (const run of para.getRuns()) {
|
|
1196
|
+
run.setItalic(false);
|
|
1197
|
+
run.setUnderline(false);
|
|
1198
|
+
}
|
|
1199
|
+
if (para.formatting.paragraphMarkRunProperties) {
|
|
1200
|
+
delete para.formatting.paragraphMarkRunProperties.italic;
|
|
1201
|
+
delete para.formatting.paragraphMarkRunProperties.underline;
|
|
1202
|
+
}
|
|
1203
|
+
const { inTable, cell } = this.isParagraphInTable(para);
|
|
1204
|
+
if (inTable && cell) {
|
|
1205
|
+
cell.setShading({ fill: 'BFBFBF' });
|
|
1206
|
+
cell.setMargins({ top: 0, bottom: 0, left: 101, right: 101 });
|
|
1207
|
+
const table = this.getAllTables().find(t => {
|
|
1208
|
+
for (const row of t.getRows()) {
|
|
1209
|
+
for (const c of row.getCells()) {
|
|
1210
|
+
if (c === cell)
|
|
1211
|
+
return true;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
return false;
|
|
1215
|
+
});
|
|
1216
|
+
if (table) {
|
|
1217
|
+
table.setWidth(5000);
|
|
1218
|
+
table.setWidthType('pct');
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
else {
|
|
1222
|
+
this.wrapParagraphInTable(para, {
|
|
1223
|
+
shading: 'BFBFBF',
|
|
1224
|
+
marginTop: 0,
|
|
1225
|
+
marginBottom: 0,
|
|
1226
|
+
marginLeft: 101,
|
|
1227
|
+
marginRight: 101,
|
|
1228
|
+
tableWidthPercent: 5000
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
processedParagraphs.add(para);
|
|
1232
|
+
}
|
|
1233
|
+
else if ((styleId === 'Normal' || styleId === undefined) && normal) {
|
|
1234
|
+
para.clearDirectFormattingConflicts(normal);
|
|
1235
|
+
for (const run of para.getRuns()) {
|
|
1236
|
+
run.setItalic(false);
|
|
1237
|
+
run.setUnderline(false);
|
|
1238
|
+
}
|
|
1239
|
+
if (para.formatting.paragraphMarkRunProperties) {
|
|
1240
|
+
delete para.formatting.paragraphMarkRunProperties.italic;
|
|
1241
|
+
delete para.formatting.paragraphMarkRunProperties.underline;
|
|
1242
|
+
}
|
|
1243
|
+
processedParagraphs.add(para);
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
const hyperlinks = this.getHyperlinks();
|
|
1247
|
+
for (const { hyperlink, paragraph } of hyperlinks) {
|
|
1248
|
+
const text = hyperlink.getText().trim();
|
|
1249
|
+
if (text === 'Top of the Document' || text === 'Top of Document') {
|
|
1250
|
+
paragraph.setAlignment('right');
|
|
1251
|
+
paragraph.setSpaceBefore(0);
|
|
1252
|
+
paragraph.setSpaceAfter(0);
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
this.updateAllHyperlinkColors('0000FF');
|
|
1256
|
+
const tocElements = this.getTableOfContentsElements();
|
|
1257
|
+
for (const tocElement of tocElements) {
|
|
1258
|
+
const toc = tocElement.getTableOfContents();
|
|
1259
|
+
toc.setShowPageNumbers(false);
|
|
1260
|
+
toc.setHideInWebLayout(true);
|
|
1261
|
+
}
|
|
1262
|
+
return results;
|
|
1263
|
+
}
|
|
875
1264
|
getSection() {
|
|
876
1265
|
return this.section;
|
|
877
1266
|
}
|