@contrail/document-util 1.0.3 → 1.0.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.
|
@@ -5,6 +5,8 @@ export declare const DEFAULT_LETTER_SPACING = 0.25;
|
|
|
5
5
|
export declare const DEFAULT_TEXT_VALIGN = "top";
|
|
6
6
|
export declare const DEFAULT_TEXT_ALIGN = "left";
|
|
7
7
|
export declare const DEFAULT_TEXT_FONT_COLOR = "#000000";
|
|
8
|
+
export declare const TEXT_TOOL_PADDING = 0;
|
|
9
|
+
export declare const TEXT_BOX_PADDING = 10;
|
|
8
10
|
export declare class DocumentStyleUtil {
|
|
9
11
|
static getFirstInlineStyleValue(text: string, pattern: string): string;
|
|
10
12
|
static getFirstFontSize(text: string, toPt?: boolean): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DocumentStyleUtil = exports.DEFAULT_TEXT_FONT_COLOR = exports.DEFAULT_TEXT_ALIGN = exports.DEFAULT_TEXT_VALIGN = exports.DEFAULT_LETTER_SPACING = exports.DEFAULT_LINE_HEIGHT = exports.DEFAULT_TEXT_FONT_SIZE = exports.DEFAULT_TEXT_FONT_FAMILY = void 0;
|
|
3
|
+
exports.DocumentStyleUtil = exports.TEXT_BOX_PADDING = exports.TEXT_TOOL_PADDING = exports.DEFAULT_TEXT_FONT_COLOR = exports.DEFAULT_TEXT_ALIGN = exports.DEFAULT_TEXT_VALIGN = exports.DEFAULT_LETTER_SPACING = exports.DEFAULT_LINE_HEIGHT = exports.DEFAULT_TEXT_FONT_SIZE = exports.DEFAULT_TEXT_FONT_FAMILY = void 0;
|
|
4
4
|
exports.DEFAULT_TEXT_FONT_FAMILY = 'Roboto';
|
|
5
5
|
exports.DEFAULT_TEXT_FONT_SIZE = 11;
|
|
6
6
|
exports.DEFAULT_LINE_HEIGHT = 1.2;
|
|
@@ -8,11 +8,13 @@ exports.DEFAULT_LETTER_SPACING = 0.25;
|
|
|
8
8
|
exports.DEFAULT_TEXT_VALIGN = 'top';
|
|
9
9
|
exports.DEFAULT_TEXT_ALIGN = 'left';
|
|
10
10
|
exports.DEFAULT_TEXT_FONT_COLOR = '#000000';
|
|
11
|
+
exports.TEXT_TOOL_PADDING = 0;
|
|
12
|
+
exports.TEXT_BOX_PADDING = 10;
|
|
11
13
|
class DocumentStyleUtil {
|
|
12
14
|
static getFirstInlineStyleValue(text, pattern) {
|
|
13
15
|
if (!text)
|
|
14
16
|
return null;
|
|
15
|
-
const regex = new RegExp('(?:\\b' + pattern + ':)\\s*([
|
|
17
|
+
const regex = new RegExp('(?:\\b' + pattern + ':)\\s*[\'"]*([^;\'"]*)[\'"]*[;"](?=[^>]*>)');
|
|
16
18
|
const found = text === null || text === void 0 ? void 0 : text.match(regex);
|
|
17
19
|
return (found === null || found === void 0 ? void 0 : found.length) > 1 ? found[1] : null;
|
|
18
20
|
}
|
|
@@ -34,7 +34,7 @@ class DocumentTextUtil {
|
|
|
34
34
|
const fixedWidth = settings.width ? (settings.width * 100) / fontSize : null;
|
|
35
35
|
words.forEach((word, index) => {
|
|
36
36
|
let wordWidth = 0;
|
|
37
|
-
word.split('').forEach(char => {
|
|
37
|
+
word.split('').forEach((char) => {
|
|
38
38
|
if (/[\x00-\x1F]/.test(char)) {
|
|
39
39
|
return true;
|
|
40
40
|
}
|