@contrail/documents 1.1.23 → 1.1.25
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.
|
@@ -6,7 +6,7 @@ const common_1 = require("./types/common");
|
|
|
6
6
|
const util_1 = require("@contrail/util");
|
|
7
7
|
class DocumentElementPropertyBindingHandler {
|
|
8
8
|
static bindPropertiesToElements(elements, model) {
|
|
9
|
-
elements.map(
|
|
9
|
+
elements.map(el => {
|
|
10
10
|
this.bindPropertiesToElement(el, model);
|
|
11
11
|
});
|
|
12
12
|
}
|
|
@@ -20,7 +20,12 @@ class DocumentElementPropertyBindingHandler {
|
|
|
20
20
|
}
|
|
21
21
|
for (const propertyKey of Object.keys(element.propertyBindings)) {
|
|
22
22
|
const modelIndex = element.propertyBindings[propertyKey];
|
|
23
|
+
const pathParts = modelIndex.split('.');
|
|
24
|
+
const isNestedPropertyAccess = pathParts.length > 2;
|
|
23
25
|
let propertyValue = util_1.ObjectUtil.getByPath(localModel, modelIndex);
|
|
26
|
+
if ((propertyValue === null || propertyValue === void 0 ? void 0 : propertyValue.name) && !isNestedPropertyAccess) {
|
|
27
|
+
propertyValue = propertyValue.name;
|
|
28
|
+
}
|
|
24
29
|
if (propertyValue === null || propertyValue === undefined) {
|
|
25
30
|
propertyValue = '';
|
|
26
31
|
}
|
|
@@ -34,7 +39,7 @@ class DocumentElementPropertyBindingHandler {
|
|
|
34
39
|
let viewableObject;
|
|
35
40
|
const content = (_e = model === null || model === void 0 ? void 0 : model.viewable) === null || _e === void 0 ? void 0 : _e.content;
|
|
36
41
|
if ((content === null || content === void 0 ? void 0 : content.length) > 0) {
|
|
37
|
-
const primaryContent = content.find(
|
|
42
|
+
const primaryContent = content.find(c => { var _a; return (c === null || c === void 0 ? void 0 : c.id) === ((_a = model === null || model === void 0 ? void 0 : model.viewable) === null || _a === void 0 ? void 0 : _a.primaryViewableId); });
|
|
38
43
|
viewableObject = primaryContent;
|
|
39
44
|
}
|
|
40
45
|
else {
|
|
@@ -133,13 +133,16 @@ class DynamicTextUtil {
|
|
|
133
133
|
var _a, _b, _c, _d;
|
|
134
134
|
let size = dynamicTextElement.size;
|
|
135
135
|
const fontFamily = (_a = document_util_1.DocumentStyleUtil.getFirstFontFamily(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text)) !== null && _a !== void 0 ? _a : document_util_1.DEFAULT_TEXT_FONT_FAMILY;
|
|
136
|
-
const fontSize =
|
|
136
|
+
const fontSize = (_d = (dynamicTextElement.isTextTool
|
|
137
|
+
? (_c = (_b = dynamicTextElement.style) === null || _b === void 0 ? void 0 : _b.font) === null || _c === void 0 ? void 0 : _c.size
|
|
138
|
+
: document_util_1.DocumentStyleUtil.getFirstFontSize(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text, true))) !== null && _d !== void 0 ? _d : document_util_1.DEFAULT_TEXT_FONT_SIZE;
|
|
139
|
+
const fontSizePx = document_util_1.DocumentStyleUtil.toPx(fontSize, 4);
|
|
137
140
|
const padding = dynamicTextElement.isTextTool ? document_util_1.TEXT_TOOL_PADDING : document_util_1.TEXT_BOX_PADDING;
|
|
138
141
|
const bold = document_util_1.DocumentStyleUtil.isBold(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text, fontFamily);
|
|
139
142
|
const italic = document_util_1.DocumentStyleUtil.isItalic(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text);
|
|
140
143
|
const measureTextSettings = {
|
|
141
144
|
fontFamily,
|
|
142
|
-
fontSize,
|
|
145
|
+
fontSize: fontSizePx,
|
|
143
146
|
fallbackFontFamily: document_util_1.DEFAULT_TEXT_FONT_FAMILY,
|
|
144
147
|
letterSpacing: document_util_1.DEFAULT_LETTER_SPACING,
|
|
145
148
|
bold,
|