@contrail/document-generation
Advanced tools
Comparing version 1.0.27 to 1.0.28
@@ -9,2 +9,3 @@ import { DocumentElement, StyleDefinition } from "@contrail/documents"; | ||
static extractTextDecorationFromHTML(text: any): string; | ||
static extractFontFromHTML(text: any): any; | ||
} |
@@ -34,3 +34,3 @@ "use strict"; | ||
static applyInLineStyling(text, style) { | ||
var _a, _b; | ||
var _a, _b, _c; | ||
let formattedText = text; | ||
@@ -50,2 +50,5 @@ if ((style === null || style === void 0 ? void 0 : style.font.weight) === 'bold') { | ||
} | ||
if ((_c = style === null || style === void 0 ? void 0 : style.font) === null || _c === void 0 ? void 0 : _c.family) { | ||
fontStyles += `font-family: '${style.font.family}'; `; | ||
} | ||
if (fontStyles.length) { | ||
@@ -77,2 +80,6 @@ formattedText = `<span style="${fontStyles}">${formattedText}</span>`; | ||
} | ||
const font = this.extractFontFromHTML(text); | ||
if (font) { | ||
style.font.family = font; | ||
} | ||
return style; | ||
@@ -105,3 +112,12 @@ } | ||
} | ||
static extractFontFromHTML(text) { | ||
let regex = /font-family: (.*?);/; | ||
let match = text.match(regex); | ||
if (match === null || match === void 0 ? void 0 : match.length) { | ||
let font = match[1]; | ||
font = font.replace(/['"]+/g, ''); | ||
return font; | ||
} | ||
} | ||
} | ||
exports.DocumentTextElementUtil = DocumentTextElementUtil; |
{ | ||
"name": "@contrail/document-generation", | ||
"version": "1.0.27", | ||
"version": "1.0.28", | ||
"description": "Utilities for automatic generation of documents.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
762125
1273