@elisra-devops/docgen-skins 0.10.3 → 0.10.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.
@@ -1,74 +1,339 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const JSONHtml_1 = __importDefault(require("../html/JSONHtml"));
7
- const JSONParagraph_1 = __importDefault(require("./JSONParagraph"));
8
- const JSONTable_1 = __importDefault(require("../table/JSONTable"));
9
- const logger_1 = __importDefault(require("../../../services/logger"));
10
3
  class JSONRichTextParagraph {
11
4
  constructor(field, paragraphStyles, wiId, headingLevel, skipImageFormat = false) {
12
5
  this.paragraphStyles = paragraphStyles;
13
6
  this.wiId = wiId;
14
- this.paragraphTemplate = this.generateJsonRichTextParagraphs(field, this.paragraphStyles, skipImageFormat);
15
- if (headingLevel && field.name === 'Title: ') {
16
- this.paragraphTemplate.headingLevel = headingLevel;
7
+ this.paragraphTemplate = this.buildDocFromNodes(field.richTextNodes);
8
+ } //constructor
9
+ getJSONRichTextParagraph() {
10
+ return this.paragraphTemplate;
11
+ } //getJSONTable
12
+ /**
13
+ * Parses a given RichNode and returns a corresponding Paragraph, Table, List,
14
+ * an array of these types, or null if the node type is not recognized.
15
+ *
16
+ * @param node - The RichNode to be parsed.
17
+ * @returns A Paragraph, Table, List, an array of these types, or null.
18
+ *
19
+ * The function handles different node types as follows:
20
+ * - 'paragraph': Parses the node as a paragraph.
21
+ * - 'table': Parses the node as a table.
22
+ * - 'list': Parses the node as a list.
23
+ * - 'text', 'image', 'break': Converts the node to a paragraph with a single run.
24
+ * - 'other': Recursively parses child nodes and returns an array of results.
25
+ * - Default: Returns null for unrecognized node types.
26
+ */
27
+ parseNode(node) {
28
+ switch (node.type) {
29
+ case 'paragraph':
30
+ return this.parseParagraphNode(node);
31
+ case 'table':
32
+ return this.parseTableNode(node);
33
+ case 'list':
34
+ return this.parseList(node);
35
+ case 'text':
36
+ case 'image':
37
+ case 'break':
38
+ return { type: 'paragraph', runs: [this.nodeToRun(node)] };
39
+ case 'other':
40
+ let childrenResults = [];
41
+ for (const child of node.children) {
42
+ const childResult = this.parseNode(child);
43
+ if (Array.isArray(childResult)) {
44
+ childrenResults.push(...childResult);
45
+ }
46
+ else if (childResult) {
47
+ childrenResults.push(childResult);
48
+ }
49
+ }
50
+ return childrenResults.length > 0 ? childrenResults : null;
51
+ default:
52
+ return null;
53
+ }
54
+ }
55
+ /**
56
+ * Parses a paragraph node and converts it into a Paragraph object.
57
+ *
58
+ * @param node - The node to parse, expected to have a `children` property.
59
+ * @returns A Paragraph object containing the parsed runs.
60
+ */
61
+ parseParagraphNode(node) {
62
+ const runs = this.gatherRuns(node.children);
63
+ return { type: 'paragraph', runs };
64
+ }
65
+ /**
66
+ * Gathers runs from the provided children nodes.
67
+ *
68
+ * This method processes an array of child nodes and converts them into an array of `Run` objects.
69
+ * It handles different types of nodes such as text, image, break, paragraph, table, list, and other.
70
+ *
71
+ * - For `text`, `image`, and `break` nodes, it directly converts them to `Run` objects.
72
+ * - For `paragraph` nodes, it recursively gathers runs from the child paragraphs.
73
+ * - For `table` and `list` nodes, it adds a placeholder `Run` object indicating the embedded type.
74
+ * - For `other` nodes, it recursively gathers runs from the child nodes.
75
+ *
76
+ * @param children - An array of child nodes to process.
77
+ * @returns An array of `Run` objects representing the gathered runs.
78
+ */
79
+ gatherRuns(children) {
80
+ const runs = [];
81
+ for (const child of children || []) {
82
+ if (child.type === 'text' || child.type === 'image' || child.type === 'break') {
83
+ runs.push(this.nodeToRun(child));
84
+ }
85
+ else if (child.type === 'paragraph') {
86
+ // Recursively gather runs from child paragraphs
87
+ runs.push(...this.gatherRuns(child.children));
88
+ }
89
+ else if (child.type === 'table' || child.type === 'list') {
90
+ // Not supported in this context, so we'll just add a placeholder
91
+ runs.push({ type: 'other', value: `[Embedded ${child.type}]` });
92
+ }
93
+ else if (child.type === 'other') {
94
+ // Recursively gather runs from inside <span> or <b>, etc.
95
+ // TODO: Handle b and i, u tags and more relevant tags for text styling
96
+ runs.push(...this.gatherRuns(child.children));
97
+ }
98
+ }
99
+ return runs;
100
+ }
101
+ /**
102
+ * Converts a node object to a Run object based on its type and text styling.
103
+ *
104
+ * @param node - The node object to be converted. It can be of type 'text', 'image', or 'break'.
105
+ * @returns A Run object with the appropriate type and properties based on the input node.
106
+ *
107
+ * The Run object can have the following structure:
108
+ * - For 'text' nodes: { type: 'text', value: string, textStyling: object }
109
+ * - For 'image' nodes: { type: 'image', value: '', src: string }
110
+ * - For 'break' nodes: { type: 'break' }
111
+ * - For other types: { type: 'other', value: '' }
112
+ *
113
+ * The textStyling object includes:
114
+ * - Bold: boolean
115
+ * - Italic: boolean
116
+ * - Underline: boolean
117
+ * - Size: number
118
+ * - Uri: string | null
119
+ * - Font: string
120
+ * - InsertLineBreak: boolean
121
+ * - InsertSpace: boolean
122
+ */
123
+ nodeToRun(node) {
124
+ var _a, _b, _c, _d;
125
+ const textStyling = {
126
+ Bold: ((_a = node.textStyling) === null || _a === void 0 ? void 0 : _a.Bold) || this.paragraphStyles.isBold,
127
+ Italic: ((_b = node.textStyling) === null || _b === void 0 ? void 0 : _b.Italic) || this.paragraphStyles.IsItalic,
128
+ Underline: ((_c = node.textStyling) === null || _c === void 0 ? void 0 : _c.Underline) || this.paragraphStyles.IsUnderline,
129
+ Size: this.paragraphStyles.Size || 12,
130
+ Uri: this.paragraphStyles.Uri || null,
131
+ Font: this.paragraphStyles.Font || 'Arial',
132
+ InsertLineBreak: this.paragraphStyles.InsertLineBreak || false,
133
+ InsertSpace: ((_d = node.textStyling) === null || _d === void 0 ? void 0 : _d.InsertSpace) || this.paragraphStyles.InsertSpace,
134
+ };
135
+ if (node.type === 'text') {
136
+ return { type: 'text', value: node.value, textStyling: textStyling };
137
+ }
138
+ else if (node.type === 'image') {
139
+ return { type: 'image', value: '', src: node.src || '' };
140
+ }
141
+ else if (node.type === 'break') {
142
+ return { type: 'break' };
17
143
  }
18
144
  else {
19
- this.paragraphTemplate.headingLevel = 0;
145
+ return { type: 'other', value: '' };
20
146
  }
21
- } //constructor
22
- generateJsonRichTextParagraphs(field, paragraphStyles, skipImageFormat = false) {
23
- let titleStyle = JSON.parse(JSON.stringify(paragraphStyles));
24
- titleStyle.isBold = true;
25
- titleStyle.IsUnderline = true;
26
- titleStyle.InsertSpace = true;
27
- titleStyle.InsertLineBreak = false;
28
- let richTextSkin = [];
29
- //handle rich text
30
- try {
31
- field.richText.forEach((content) => {
32
- switch (content.type) {
33
- case 'paragraph':
34
- content.data.fields.forEach((richTextField) => {
35
- if (/<\/?[a-z][\s\S]*>/.test(richTextField.value)) {
36
- let html = new JSONHtml_1.default(richTextField.value);
37
- richTextSkin.push(html.getJSONHtml());
38
- }
39
- else {
40
- //making sure ID is not printed
41
- let paragraphSkin = new JSONParagraph_1.default(richTextField, paragraphStyles, 0, 0);
42
- richTextSkin.push(paragraphSkin.getJSONParagraph());
43
- }
44
- });
45
- break;
46
- case 'picture':
47
- if (!skipImageFormat) {
48
- richTextSkin.push({
49
- type: 'picture',
50
- Path: content.data,
51
- });
52
- }
53
- break;
54
- case 'table':
55
- if (content.data) {
56
- let tableSkin = new JSONTable_1.default(content.data, undefined, paragraphStyles, 0);
57
- richTextSkin.push(tableSkin.getJSONTable());
58
- }
59
- break;
147
+ }
148
+ /**
149
+ * Converts a given node object into a Table structure.
150
+ *
151
+ * @remarks
152
+ * This function processes the children of the specified node and
153
+ * transforms them into a table representation, adding default properties
154
+ * such as heading level, page break insertion, and an empty rows array.
155
+ *
156
+ * @param node - The node object containing the structural details needed
157
+ * to create a table.
158
+ * @returns A fully constructed Table object with the parsed node data.
159
+ */
160
+ parseTableNode(node) {
161
+ const table = {
162
+ type: 'table',
163
+ headingLevel: 0,
164
+ insertPageBreak: false,
165
+ Rows: [],
166
+ };
167
+ this.parseTableChildren(node.children, table);
168
+ return table;
169
+ }
170
+ /**
171
+ * Parses child elements of a table structure and updates the provided Table instance accordingly.
172
+ *
173
+ * @param children - An array of child nodes to be evaluated for table content.
174
+ * @param table - The Table object to which parsed rows and nested structures will be appended.
175
+ *
176
+ * @remarks
177
+ * This method recursively traverses and identifies relevant table elements (e.g., <tr>, <thead>, <tbody>, etc.)
178
+ * to generate the final row data for the given Table instance.
179
+ */
180
+ parseTableChildren(children, table) {
181
+ for (const child of children || []) {
182
+ if (child.type === 'other') {
183
+ const tn = (child.tagName || '').toLowerCase();
184
+ if (tn === 'tr') {
185
+ // Parse a table row
186
+ const row = this.parseTableRow(child);
187
+ table.Rows.push(row);
60
188
  }
61
- });
62
- return richTextSkin;
189
+ else if (tn === 'thead' || tn === 'tbody' || tn === 'tfoot') {
190
+ // Recurse into thead/tbody/tfoot
191
+ this.parseTableChildren(child.children, table);
192
+ }
193
+ else {
194
+ // Recurse into other nodes
195
+ this.parseTableChildren(child.children, table);
196
+ }
197
+ }
198
+ else if (child.type === 'table') {
199
+ this.parseTableChildren(child.children, table);
200
+ }
201
+ else {
202
+ //skip
203
+ continue;
204
+ }
63
205
  }
64
- catch (e) {
65
- logger_1.default.warn(e);
66
- return [];
206
+ }
207
+ /**
208
+ * Parses the given table row node and extracts its cells by iterating through its child elements.
209
+ * Each child element that is recognized as a table cell (td or th) is converted into a corresponding cell object.
210
+ *
211
+ * @param trNode - An AST node representing the table row, containing possible table cell or header elements.
212
+ * @returns A TableRow object containing an array of processed cells.
213
+ */
214
+ parseTableRow(trNode) {
215
+ const row = { Cells: [] };
216
+ // parse <td> or <th> inside this <tr>
217
+ for (const child of trNode.children || []) {
218
+ if (child.type === 'other' && (child.tagName === 'td' || child.tagName === 'th')) {
219
+ row.Cells.push(this.parseTableCell(child));
220
+ }
221
+ else {
222
+ // skip or recurse
223
+ }
67
224
  }
68
- } //generateJsonRichTextParagraphs
69
- getJSONRichTextParagraph() {
70
- return this.paragraphTemplate;
71
- } //getJSONTable
225
+ return row;
226
+ }
227
+ /**
228
+ * Build one TableCell from <td> node
229
+ */
230
+ parseTableCell(tdNode) {
231
+ // We'll collect everything in one paragraph
232
+ const cellParagraphRuns = this.gatherRunsFromAllParagraphs(tdNode.children);
233
+ return {
234
+ Paragraphs: [
235
+ {
236
+ Runs: cellParagraphRuns,
237
+ },
238
+ ],
239
+ };
240
+ }
241
+ /**
242
+ * Gather runs from any text/image/paragraph in <td>
243
+ * (including nested <other> tags).
244
+ */
245
+ gatherRunsFromAllParagraphs(children) {
246
+ const runs = [];
247
+ for (const child of children || []) {
248
+ if (child.type === 'text' || child.type === 'image') {
249
+ runs.push(this.nodeToRun(child));
250
+ }
251
+ else if (child.type === 'paragraph') {
252
+ runs.push(...this.gatherRuns(child.children));
253
+ }
254
+ else if (child.type === 'other' || child.type === 'table' || child.type === 'list') {
255
+ // recursively gather
256
+ runs.push(...this.gatherRunsFromAllParagraphs(child.children));
257
+ }
258
+ }
259
+ return runs;
260
+ }
261
+ /**
262
+ * Parses a given node to create a List object.
263
+ *
264
+ * @param node - The node to parse, expected to have properties `isOrdered` and `children`.
265
+ * @returns A List object with the parsed data.
266
+ */
267
+ parseList(node) {
268
+ const list = {
269
+ type: 'list',
270
+ isOrdered: node.isOrdered,
271
+ listItems: [],
272
+ };
273
+ this.parseListChildren(node.children, list);
274
+ return list;
275
+ }
276
+ /**
277
+ * Parses the children of a list and adds them to the provided list object.
278
+ *
279
+ * @param children - An array of child nodes to be parsed.
280
+ * @param list - The list object to which parsed items will be added.
281
+ * @param level - The current depth level of the list (default is 0).
282
+ */
283
+ parseListChildren(children, list, level = 0) {
284
+ for (const child of children || []) {
285
+ if (child.type === 'other') {
286
+ const tn = (child.tagName || '').toLowerCase();
287
+ if (tn === 'li') {
288
+ // Parse a list item
289
+ const item = this.parseListItem(child, level);
290
+ list.listItems.push(item);
291
+ }
292
+ else {
293
+ // Recurse into other nodes
294
+ this.parseListChildren(child.children, list, level + 1);
295
+ }
296
+ }
297
+ else {
298
+ //skip
299
+ continue;
300
+ }
301
+ }
302
+ }
303
+ /**
304
+ * Parses a list item node and converts it into a `ListItem` object.
305
+ *
306
+ * @param liNode - The list item node to parse.
307
+ * @param level - The nesting level of the list item.
308
+ * @returns A `ListItem` object containing the parsed list item data.
309
+ */
310
+ parseListItem(liNode, level) {
311
+ const items = this.gatherRunsFromAllParagraphs(liNode.children);
312
+ return {
313
+ Runs: items,
314
+ level: level,
315
+ };
316
+ }
317
+ /**
318
+ * Builds an array of document elements (Paragraph, Table, or List) from an array of RichNode objects.
319
+ *
320
+ * @param nodes - An array of RichNode objects to be parsed into document elements.
321
+ * @returns An array of Paragraph, Table, or List elements.
322
+ */
323
+ buildDocFromNodes(nodes) {
324
+ const results = [];
325
+ for (const node of nodes) {
326
+ const items = this.parseNode(node);
327
+ // parseNode might return a single Paragraph/Table or an array
328
+ if (Array.isArray(items)) {
329
+ results.push(...items);
330
+ }
331
+ else if (items) {
332
+ results.push(items);
333
+ }
334
+ }
335
+ return results;
336
+ }
72
337
  } //class
73
338
  exports.default = JSONRichTextParagraph;
74
339
  //# sourceMappingURL=JSONRichTextParagraph.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"JSONRichTextParagraph.js","sourceRoot":"","sources":["../../../../src/models/json/paragraph/JSONRichTextParagraph.ts"],"names":[],"mappings":";;;;;AACA,gEAAwC;AACxC,oEAA4C;AAC5C,mEAA2C;AAC3C,sEAA8C;AAE9C,MAAqB,qBAAqB;IAIxC,YACE,KAAiB,EACjB,eAA6B,EAC7B,IAAY,EACZ,YAAoB,EACpB,eAAe,GAAG,KAAK;QAEvB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,8BAA8B,CAC1D,KAAK,EACL,IAAI,CAAC,eAAe,EACpB,eAAe,CAChB,CAAC;QACF,IAAI,YAAY,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE;YAC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,IAAI,CAAC,eAAe,EAAE;4BACpB,YAAY,CAAC,IAAI,CAAC;gCAChB,IAAI,EAAE,SAAS;gCACf,IAAI,EAAE,OAAO,CAAC,IAAI;6BACnB,CAAC,CAAC;yBACJ;wBAED,MAAM;oBACR,KAAK,OAAO;wBACV,IAAI,OAAO,CAAC,IAAI,EAAE;4BAChB,IAAI,SAAS,GAAG,IAAI,mBAAS,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC;4BAC3E,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC,CAAC;yBAC7C;wBACD,MAAM;iBACT;YACH,CAAC,CAAC,CAAC;YACH,OAAO,YAAY,CAAC;SACrB;QAAC,OAAO,CAAC,EAAE;YACV,gBAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACf,OAAO,EAAE,CAAC;SACX;IACH,CAAC,CAAC,gCAAgC;IAElC,wBAAwB;QACtB,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC,CAAC,cAAc;CACjB,CAAC,OAAO;AA7ET,wCA6EC"}
1
+ {"version":3,"file":"JSONRichTextParagraph.js","sourceRoot":"","sources":["../../../../src/models/json/paragraph/JSONRichTextParagraph.ts"],"names":[],"mappings":";;AAaA,MAAqB,qBAAqB;IAIxC,YACE,KAAiB,EACjB,eAA6B,EAC7B,IAAY,EACZ,YAAoB,EACpB,eAAe,GAAG,KAAK;QAEvB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACvE,CAAC,CAAC,aAAa;IAEf,wBAAwB;QACtB,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC,CAAC,cAAc;IAEhB;;;;;;;;;;;;;;OAcG;IACK,SAAS,CAAC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C,IAAI,CAAC,CAAC;YACnC,8DAA8D;YAC9D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBACxB,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;aACxB;iBAAM,IAAI,KAAK,EAAE;gBAChB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACrB;SACF;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAC,OAAO;AA7VT,wCA6VC"}
@@ -53,8 +53,7 @@ export interface Attachment {
53
53
  isLinkedFile?: boolean;
54
54
  IsFlattened?: boolean;
55
55
  }
56
- export interface Run {
57
- text: string;
56
+ interface TextStyle {
58
57
  Bold: boolean;
59
58
  Italic: boolean;
60
59
  Underline: boolean;
@@ -64,6 +63,12 @@ export interface Run {
64
63
  InsertLineBreak: boolean;
65
64
  InsertSpace: boolean;
66
65
  }
66
+ export interface Run {
67
+ type: 'text' | 'image' | 'break' | 'other';
68
+ value?: string;
69
+ src?: string;
70
+ textStyling?: TextStyle;
71
+ }
67
72
  export interface WorkItemData {
68
73
  }
69
74
  export interface Table {
@@ -72,6 +77,15 @@ export interface Table {
72
77
  Rows: TableRow[];
73
78
  insertPageBreak: boolean;
74
79
  }
80
+ export interface List {
81
+ type: string;
82
+ listItems: ListItem[];
83
+ isOrdered: boolean;
84
+ }
85
+ export interface ListItem {
86
+ Runs: Run[];
87
+ level: number;
88
+ }
75
89
  export interface WIQueryResults {
76
90
  columns: WIColumns[];
77
91
  workItems: WIData[];
@@ -95,7 +109,7 @@ export interface WIProperty {
95
109
  attachmentLink?: string;
96
110
  attachmentType?: string;
97
111
  relativeAttachmentLink?: string;
98
- richText?: any[];
112
+ richTextNodes?: any[];
99
113
  }
100
114
  export interface MultipeValuesWIProperty {
101
115
  name: string;
@@ -107,10 +121,42 @@ export interface MultipeValuesWIProperty {
107
121
  attachmentLink?: string;
108
122
  attachmentType?: string;
109
123
  relativeAttachmentLink?: string;
110
- richText?: any[];
124
+ richTextNodes?: any[];
111
125
  }
112
126
  export interface WIColumns {
113
127
  name: string;
114
128
  referenceName: string;
115
129
  url: string;
116
130
  }
131
+ export type RichNode = ParagraphNode | TextNode | ImageNode | TableNode | ListNode | BreakNode | OtherNode;
132
+ export interface ParagraphNode {
133
+ type: 'paragraph';
134
+ children: RichNode[];
135
+ }
136
+ export interface TextNode {
137
+ type: 'text';
138
+ value: string;
139
+ }
140
+ export interface ImageNode {
141
+ type: 'image';
142
+ src: string;
143
+ alt?: string;
144
+ }
145
+ export interface BreakNode {
146
+ type: 'break';
147
+ }
148
+ export interface TableNode {
149
+ type: 'table';
150
+ children: RichNode[];
151
+ }
152
+ export interface ListNode {
153
+ type: 'list';
154
+ isOrdered: boolean;
155
+ children: RichNode[];
156
+ }
157
+ export interface OtherNode {
158
+ type: 'other';
159
+ tagName: string;
160
+ children: RichNode[];
161
+ }
162
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elisra-devops/docgen-skins",
3
- "version": "0.10.3",
3
+ "version": "0.10.5",
4
4
  "description": "Can be outputed in various types:",
5
5
  "main": "./bin/index.js",
6
6
  "types": "./bin/index.d.ts",
package/src/index.ts CHANGED
@@ -287,21 +287,7 @@ export default class Skins {
287
287
  let wiSkin = new JSONHeaderParagraph(wiHeaderFields, headerStyle, element.id || 0, element.level);
288
288
  testSkins.push(wiSkin.getJSONParagraph());
289
289
 
290
- let wiDescTitleSkin = new JSONParagraph(
291
- { name: 'Title', value: 'WI Description' },
292
- DescriptionandProcedureStyle,
293
- element.id || 0,
294
- 0
295
- );
296
- testSkins.push(wiDescTitleSkin.getJSONParagraph());
297
-
298
- let wiDescriptionParagraph = new JSONRichTextParagraph(
299
- element.fields[2],
300
- styles,
301
- element.id || 0,
302
- 0,
303
- true
304
- );
290
+ let wiDescriptionParagraph = new JSONRichTextParagraph(element.fields[2], styles, element.id || 0, 0);
305
291
  let richTextDecsSkin: any[] = wiDescriptionParagraph.getJSONRichTextParagraph();
306
292
  testSkins.push(...richTextDecsSkin);
307
293
  }
@@ -441,9 +427,10 @@ export default class Skins {
441
427
  0
442
428
  );
443
429
  testSkin.push(testDescriptionTitleParagraph.getJSONParagraph());
430
+
444
431
  let testDescriptionParagraph = new JSONRichTextParagraph(
445
432
  testcase.testCaseHeaderSkinData.fields[2],
446
- styles,
433
+ { ...styles, Size: 12, Font: 'Arial' },
447
434
  testcase.id || 0,
448
435
  0
449
436
  );
@@ -504,7 +491,7 @@ export default class Skins {
504
491
  let tableSkin = new JSONTable(
505
492
  testcase.testCaseStepsSkinData,
506
493
  headerStyles,
507
- styles,
494
+ { ...styles, Font: 'Arial' },
508
495
  headingLvl,
509
496
  undefined,
510
497
  undefined,
@@ -535,7 +522,7 @@ export default class Skins {
535
522
  let tableSkin = new JSONTable(
536
523
  testcase.testCaseAttachments,
537
524
  headerStyles,
538
- styles,
525
+ { ...styles, Font: 'Arial' },
539
526
  headingLvl,
540
527
  true
541
528
  );