@contrail/document-generation 1.0.27 → 1.0.29

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/lib/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export * from './document-generator';
2
2
  export * from './interfaces';
3
- export * from './util';
package/lib/index.js CHANGED
@@ -16,4 +16,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./document-generator"), exports);
18
18
  __exportStar(require("./interfaces"), exports);
19
- __exportStar(require("./util"), exports);
@@ -6,4 +6,5 @@ export declare class DocumentTextElementUtil {
6
6
  static extractFontSizeFromHTML(text: any): number;
7
7
  static extractColorFromHTML(text: any): string;
8
8
  static extractTextDecorationFromHTML(text: any): string;
9
+ static extractFontFromHTML(text: any): any;
9
10
  }
@@ -31,7 +31,7 @@ class DocumentTextElementUtil {
31
31
  return element;
32
32
  }
33
33
  static applyInLineStyling(text, style) {
34
- var _a, _b;
34
+ var _a, _b, _c;
35
35
  let formattedText = text;
36
36
  if ((style === null || style === void 0 ? void 0 : style.font.weight) === 'bold') {
37
37
  formattedText = `<strong>${formattedText}</strong>`;
@@ -46,6 +46,9 @@ class DocumentTextElementUtil {
46
46
  if (style === null || style === void 0 ? void 0 : style.color) {
47
47
  fontStyles += `color: ${style.color}; `;
48
48
  }
49
+ if ((_c = style === null || style === void 0 ? void 0 : style.font) === null || _c === void 0 ? void 0 : _c.family) {
50
+ fontStyles += `font-family: '${style.font.family}'; `;
51
+ }
49
52
  if (fontStyles.length) {
50
53
  formattedText = `<span style="${fontStyles}">${formattedText}</span>`;
51
54
  }
@@ -72,6 +75,10 @@ class DocumentTextElementUtil {
72
75
  if (decoration) {
73
76
  style.text.decoration = decoration;
74
77
  }
78
+ const font = this.extractFontFromHTML(text);
79
+ if (font) {
80
+ style.font.family = font;
81
+ }
75
82
  return style;
76
83
  }
77
84
  static extractFontSizeFromHTML(text) {
@@ -99,5 +106,14 @@ class DocumentTextElementUtil {
99
106
  return decoration;
100
107
  }
101
108
  }
109
+ static extractFontFromHTML(text) {
110
+ let regex = /font-family: (.*?);/;
111
+ let match = text.match(regex);
112
+ if (match === null || match === void 0 ? void 0 : match.length) {
113
+ let font = match[1];
114
+ font = font.replace(/['"]+/g, '');
115
+ return font;
116
+ }
117
+ }
102
118
  }
103
119
  exports.DocumentTextElementUtil = DocumentTextElementUtil;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/document-generation",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "Utilities for automatic generation of documents.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -1,3 +0,0 @@
1
- export * from './document-property-util';
2
- export * from './document-text-element-util';
3
- export * from './document-util';
package/lib/util/index.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./document-property-util"), exports);
18
- __exportStar(require("./document-text-element-util"), exports);
19
- __exportStar(require("./document-util"), exports);