@contrail/documents 2.4.0-alpha.66cee0e → 2.4.0-alpha.6b52702
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/CHANGELOG.md +37 -50
- package/lib/containers/document-container-index.js +2 -2
- package/lib/containers/document-container.d.ts +4 -0
- package/lib/containers/document-container.js +16 -6
- package/lib/containers/document-container.service.js +17 -14
- package/lib/util/dynamic-text/dynamic-text-util.d.ts +6 -1
- package/lib/util/dynamic-text/dynamic-text-util.js +25 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -13,67 +13,54 @@ Also shipped on the 1.x line as 1.21.0.
|
|
|
13
13
|
|
|
14
14
|
- `DocumentContainerService.buildIndex` and `DocumentContainerIndex` — which containers hold which
|
|
15
15
|
elements, for one document, resolved once and read back by lookup. A container is a frame or a
|
|
16
|
-
section,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
holding an element rather than a measured box.
|
|
26
|
-
- `positionKeepingAnchor` — where an element has to sit for its drawn corner to land where it did
|
|
27
|
-
before a resize. Rotation turns about the centre and the centre moves with the size, so a rotated
|
|
28
|
-
element resized about its stored position drags its corner along with it. The board already makes
|
|
29
|
-
this move; a server recomputing a dynamic text has to make the same one, or the corner is not the
|
|
30
|
-
fixed point the anchor rule needs.
|
|
16
|
+
section; membership is geometry, draw order and kind, with nothing inherited and nothing stored.
|
|
17
|
+
The rule is written out in `src/containers/DOCUMENT_CONTAINERS_SPEC.md`, which the code is
|
|
18
|
+
measured against.
|
|
19
|
+
- `DocumentContainerUtil` — the container geometry as statics. `anchorFor` answers "which point is
|
|
20
|
+
this element placed by" for a caller holding an element rather than a measured box, and
|
|
21
|
+
`resizeKeepingAnchor` returns the size a new value needs with the position that keeps that point
|
|
22
|
+
still. Applying one without the other drags the corner membership reads.
|
|
23
|
+
- `SECTION_ELEMENT_TYPE` and `FRAME_ELEMENT_TYPE` in `document-element-constants`, alongside
|
|
24
|
+
`SHAPE_ELEMENT_TYPES`, which moved here for the board's shape handling.
|
|
31
25
|
- `DocumentElementFactory.getBoundingClientRectScaled` — the space an element covers on the canvas,
|
|
32
|
-
with `scale` applied. `getBoundingClientRect`
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
with `scale` applied. `getBoundingClientRect` still returns the unscaled box, which is what layout
|
|
27
|
+
works in: `@contrail/document-table` places table members from it, and scaling it moves a scaled
|
|
28
|
+
member into a different cell. Anything deciding what an element overlaps or sits on wants the
|
|
29
|
+
scaled one.
|
|
36
30
|
|
|
37
31
|
### Deprecated
|
|
38
32
|
|
|
39
33
|
- `isContainerBinding()` in favour of `DynamicTextUtil.takesValueFromContainer()`. Same rule, named
|
|
40
|
-
for what it decides
|
|
41
|
-
property. The old name still works and delegates to the new one.
|
|
34
|
+
for what it decides. The old name still works and delegates to the new one.
|
|
42
35
|
|
|
43
36
|
### Fixed
|
|
44
37
|
|
|
45
|
-
- A dynamic text is
|
|
46
|
-
|
|
47
|
-
size
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
- `min` and `max` rendered an infinity sign when every member value was empty
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
- `DynamicTextUtil.calculateSize` threw on an element that reached it without a `size`, which on
|
|
62
|
-
the server failed the read for the whole document. It now measures from a zero size instead.
|
|
38
|
+
- A dynamic text is anchored at its drawn top-left corner rather than its centre. Its size comes
|
|
39
|
+
from the value it resolves to and that value comes from its container, so an anchor that moved
|
|
40
|
+
with the size let the two choose each other: near an edge they never settled, flipping between a
|
|
41
|
+
value and "Move to a frame" on every read. The corner is the rotated one, so a text turned on its
|
|
42
|
+
side anchors where it appears (VIBE-9567).
|
|
43
|
+
- `isDynamicText` requires a `propertyBindings.text` binding, the one the value is read from. The
|
|
44
|
+
text tool creates an element with empty bindings and empty metadata, both truthy, so an
|
|
45
|
+
unconfigured text was anchored at its corner while the canvas centred it.
|
|
46
|
+
- An element covering a container is not inside it, whatever its type. The rule it replaces looked
|
|
47
|
+
only at shapes wider and taller than the container, so a background image joined the frame it
|
|
48
|
+
covered.
|
|
49
|
+
- A line or callout is measured from the elements it connects even with no stored `position`, where
|
|
50
|
+
it was previously left out of the index entirely.
|
|
51
|
+
- `min` and `max` rendered an infinity sign when every member value was empty; both fall through to
|
|
52
|
+
`n/a`. `calculateSize` no longer throws on an element that reaches it without a `size`, which on
|
|
53
|
+
the server failed the read for the whole document.
|
|
63
54
|
|
|
64
55
|
### Changed
|
|
65
56
|
|
|
66
|
-
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
rows it draws, and a line's comes from its `lineDefinition`.
|
|
74
|
-
- Container depth counts nesting levels rather than enclosing boxes. Two containers that merely
|
|
75
|
-
cross both enclose anything inside the overlap, so counting ancestors put that inner container a
|
|
76
|
-
level too deep and made `maxDepth` report a level no path could reach.
|
|
57
|
+
- `anchorFor` and the index measure through the same factory call, so a caller holding an element
|
|
58
|
+
gets the answer the index would give it. Reading `size` directly disagreed for the types whose box
|
|
59
|
+
is not position plus size.
|
|
60
|
+
- A container path is a containment chain, walked outward from the container the element sits on, so
|
|
61
|
+
two containers that merely cross no longer both claim it.
|
|
62
|
+
- `buildIndex` scans element types before measuring, so a document with no containers of the kinds
|
|
63
|
+
asked for returns an empty index without a geometry pass.
|
|
77
64
|
|
|
78
65
|
## [2.3.0] - 2026-09-21
|
|
79
66
|
|
|
@@ -23,7 +23,7 @@ class DocumentContainerIndex {
|
|
|
23
23
|
return this.resolveAll(this.containerIdsOf(documentElementId, elementType));
|
|
24
24
|
}
|
|
25
25
|
containerIdsOf(documentElementId, elementType) {
|
|
26
|
-
return this.containerPath(documentElementId, elementType);
|
|
26
|
+
return [...this.containerPath(documentElementId, elementType)];
|
|
27
27
|
}
|
|
28
28
|
innermostContainerIdOf(documentElementId, elementType) {
|
|
29
29
|
const path = this.containerPath(documentElementId, elementType);
|
|
@@ -31,7 +31,7 @@ class DocumentContainerIndex {
|
|
|
31
31
|
}
|
|
32
32
|
memberIdsOf(containerId) {
|
|
33
33
|
var _a;
|
|
34
|
-
return (_a = this.data.memberIdsByContainerId.get(containerId)) !== null && _a !== void 0 ? _a : [];
|
|
34
|
+
return [...((_a = this.data.memberIdsByContainerId.get(containerId)) !== null && _a !== void 0 ? _a : [])];
|
|
35
35
|
}
|
|
36
36
|
memberDocumentElementsOf(containerId) {
|
|
37
37
|
const members = [];
|
|
@@ -17,6 +17,10 @@ export declare class DocumentContainerUtil {
|
|
|
17
17
|
static centerOf(box: CoordinateBox): PositionDefinition;
|
|
18
18
|
static anchorOf(documentElement: DocumentElement, box: CoordinateBox): PositionDefinition;
|
|
19
19
|
static positionKeepingAnchor(documentElement: DocumentElement, newSize: SizeDefinition): PositionDefinition;
|
|
20
|
+
static resizeKeepingAnchor(dynamicTextElement: DocumentElement, entityType: any, text: string): {
|
|
21
|
+
size: SizeDefinition;
|
|
22
|
+
position: PositionDefinition;
|
|
23
|
+
};
|
|
20
24
|
static anchorFor(documentElement: DocumentElement, position?: PositionDefinition, startElement?: DocumentElement, endElement?: DocumentElement): PositionDefinition;
|
|
21
25
|
static containsPoint(box: CoordinateBox, point: PositionDefinition): boolean;
|
|
22
26
|
static encloses(outer: CoordinateBox, inner: CoordinateBox): boolean;
|
|
@@ -24,9 +24,12 @@ class DocumentContainerUtil {
|
|
|
24
24
|
var _a, _b, _c, _d, _e;
|
|
25
25
|
const position = documentElement === null || documentElement === void 0 ? void 0 : documentElement.position;
|
|
26
26
|
const angle = (_a = documentElement === null || documentElement === void 0 ? void 0 : documentElement.rotate) === null || _a === void 0 ? void 0 : _a.angle;
|
|
27
|
-
if (!position
|
|
27
|
+
if (!position) {
|
|
28
28
|
return position;
|
|
29
29
|
}
|
|
30
|
+
if (!angle || !newSize || !documentElement.size) {
|
|
31
|
+
return Object.assign({}, position);
|
|
32
|
+
}
|
|
30
33
|
const scaleX = (_c = (_b = documentElement.scale) === null || _b === void 0 ? void 0 : _b.x) !== null && _c !== void 0 ? _c : 1;
|
|
31
34
|
const scaleY = (_e = (_d = documentElement.scale) === null || _d === void 0 ? void 0 : _d.y) !== null && _e !== void 0 ? _e : 1;
|
|
32
35
|
const cornerOffset = (size) => {
|
|
@@ -36,16 +39,23 @@ class DocumentContainerUtil {
|
|
|
36
39
|
};
|
|
37
40
|
const before = cornerOffset(documentElement.size);
|
|
38
41
|
const after = cornerOffset(newSize);
|
|
39
|
-
|
|
42
|
+
const moved = { x: position.x + before.x - after.x, y: position.y + before.y - after.y };
|
|
43
|
+
return Number.isFinite(moved.x) && Number.isFinite(moved.y) ? moved : Object.assign({}, position);
|
|
44
|
+
}
|
|
45
|
+
static resizeKeepingAnchor(dynamicTextElement, entityType, text) {
|
|
46
|
+
const size = dynamic_text_util_1.DynamicTextUtil.calculateSize(dynamicTextElement, entityType, text);
|
|
47
|
+
return { size, position: DocumentContainerUtil.positionKeepingAnchor(dynamicTextElement, size) };
|
|
40
48
|
}
|
|
41
49
|
static anchorFor(documentElement, position, startElement, endElement) {
|
|
42
50
|
const at = position !== null && position !== void 0 ? position : documentElement === null || documentElement === void 0 ? void 0 : documentElement.position;
|
|
43
|
-
|
|
51
|
+
try {
|
|
52
|
+
const measured = document_element_factory_1.DocumentElementFactory.getBoundingClientRectScaled(at ? Object.assign(Object.assign({}, documentElement), { position: at }) : documentElement, startElement, endElement);
|
|
53
|
+
const box = DocumentContainerUtil.toCoordinateBox(measured.x, measured.y, measured.width, measured.height);
|
|
54
|
+
return DocumentContainerUtil.anchorOf(documentElement, box);
|
|
55
|
+
}
|
|
56
|
+
catch (_a) {
|
|
44
57
|
return null;
|
|
45
58
|
}
|
|
46
|
-
const measured = document_element_factory_1.DocumentElementFactory.getBoundingClientRectScaled(Object.assign(Object.assign({}, documentElement), { position: at }), startElement, endElement);
|
|
47
|
-
const box = DocumentContainerUtil.toCoordinateBox(measured.x, measured.y, measured.width, measured.height);
|
|
48
|
-
return DocumentContainerUtil.anchorOf(documentElement, box);
|
|
49
59
|
}
|
|
50
60
|
static containsPoint(box, point) {
|
|
51
61
|
return point.x >= box.left && point.x <= box.right && point.y >= box.top && point.y <= box.bottom;
|
|
@@ -8,9 +8,9 @@ const document_container_1 = require("./document-container");
|
|
|
8
8
|
class DocumentContainerService {
|
|
9
9
|
static buildIndex(documentElements, kinds = container_kind_1.CONTAINER_KINDS) {
|
|
10
10
|
var _a, _b;
|
|
11
|
-
const elements = documentElements !== null && documentElements !== void 0 ? documentElements : [];
|
|
11
|
+
const elements = (documentElements !== null && documentElements !== void 0 ? documentElements : []).filter((element) => !!element);
|
|
12
12
|
const containerElementTypes = new Set(kinds.map((kind) => kind.elementType));
|
|
13
|
-
if (!elements.some((element) => containerElementTypes.has(element
|
|
13
|
+
if (!elements.some((element) => containerElementTypes.has(element.type))) {
|
|
14
14
|
return document_container_index_1.DocumentContainerIndex.empty();
|
|
15
15
|
}
|
|
16
16
|
const documentElementsById = new Map(elements.map((element) => [element.id, element]));
|
|
@@ -32,19 +32,22 @@ class DocumentContainerService {
|
|
|
32
32
|
}
|
|
33
33
|
const containerPathsByDocumentElementId = new Map();
|
|
34
34
|
const memberIdsByContainerId = new Map();
|
|
35
|
+
const memberIdsSeen = new Map();
|
|
35
36
|
for (const measured of measuredDocumentElements) {
|
|
36
37
|
const documentElementId = measured.documentElement.id;
|
|
37
38
|
const pathsByElementType = new Map();
|
|
38
39
|
((_b = pathsByMeasured.get(measured)) !== null && _b !== void 0 ? _b : new Map()).forEach((path, elementType) => pathsByElementType.set(elementType, path.map((container) => container.id)));
|
|
39
40
|
for (const path of pathsByElementType.values()) {
|
|
40
41
|
for (const containerId of path) {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
42
|
+
const seen = memberIdsSeen.get(containerId);
|
|
43
|
+
if (!seen) {
|
|
44
|
+
memberIdsSeen.set(containerId, new Set([documentElementId]));
|
|
46
45
|
memberIdsByContainerId.set(containerId, [documentElementId]);
|
|
47
46
|
}
|
|
47
|
+
else if (!seen.has(documentElementId)) {
|
|
48
|
+
seen.add(documentElementId);
|
|
49
|
+
memberIdsByContainerId.get(containerId).push(documentElementId);
|
|
50
|
+
}
|
|
48
51
|
}
|
|
49
52
|
}
|
|
50
53
|
containerPathsByDocumentElementId.set(documentElementId, pathsByElementType);
|
|
@@ -69,13 +72,13 @@ class DocumentContainerService {
|
|
|
69
72
|
}
|
|
70
73
|
static measure(documentElement, documentElementsById) {
|
|
71
74
|
var _a, _b;
|
|
72
|
-
if (!(documentElement === null || documentElement === void 0 ? void 0 : documentElement.position)) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
75
|
try {
|
|
76
|
-
const start = ((_a = documentElement.start) === null || _a === void 0 ? void 0 : _a.id) ? documentElementsById.get(documentElement.start.id) : undefined;
|
|
77
|
-
const end = ((_b = documentElement.end) === null || _b === void 0 ? void 0 : _b.id) ? documentElementsById.get(documentElement.end.id) : undefined;
|
|
76
|
+
const start = ((_a = documentElement === null || documentElement === void 0 ? void 0 : documentElement.start) === null || _a === void 0 ? void 0 : _a.id) ? documentElementsById.get(documentElement.start.id) : undefined;
|
|
77
|
+
const end = ((_b = documentElement === null || documentElement === void 0 ? void 0 : documentElement.end) === null || _b === void 0 ? void 0 : _b.id) ? documentElementsById.get(documentElement.end.id) : undefined;
|
|
78
78
|
const { x, y, width, height } = document_element_factory_1.DocumentElementFactory.getBoundingClientRectScaled(documentElement, start, end);
|
|
79
|
+
if (!width && !height && !documentElement.position) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
79
82
|
return document_container_1.DocumentContainerUtil.toCoordinateBox(x, y, width, height);
|
|
80
83
|
}
|
|
81
84
|
catch (_c) {
|
|
@@ -106,7 +109,7 @@ class DocumentContainerService {
|
|
|
106
109
|
static enclosersOf(measured, containers) {
|
|
107
110
|
return containers.filter((container) => {
|
|
108
111
|
var _a;
|
|
109
|
-
return container.
|
|
112
|
+
return container.id !== measured.documentElement.id &&
|
|
110
113
|
document_container_1.DocumentContainerUtil.encloses(container.box, measured.box) &&
|
|
111
114
|
measured.drawOrder > container.drawOrder &&
|
|
112
115
|
!((_a = measured.documentElement.elementIds) === null || _a === void 0 ? void 0 : _a.includes(container.id));
|
|
@@ -116,7 +119,7 @@ class DocumentContainerService {
|
|
|
116
119
|
const anchor = document_container_1.DocumentContainerUtil.anchorOf(measured.documentElement, measured.box);
|
|
117
120
|
return containers.filter((container) => {
|
|
118
121
|
var _a;
|
|
119
|
-
if (container.
|
|
122
|
+
if (container.id === measured.documentElement.id || measured.drawOrder <= container.drawOrder) {
|
|
120
123
|
return false;
|
|
121
124
|
}
|
|
122
125
|
if (!document_container_1.DocumentContainerUtil.containsPoint(container.box, anchor)) {
|
|
@@ -27,6 +27,8 @@ export declare enum DynamicTextDisplayFunction {
|
|
|
27
27
|
export declare const MOVE_TO_FRAME_TEXT = "Move to a frame";
|
|
28
28
|
export declare const MOVE_TO_SECTION_TEXT = "Move to a section";
|
|
29
29
|
export declare const CLICK_TO_CONFIGURE = "Click to configure";
|
|
30
|
+
export declare function placeholderForMissingContainer(entityType: string): string;
|
|
31
|
+
export declare function isPlaceholderText(text: string): boolean;
|
|
30
32
|
export declare const HARD_CODED_TEXT: {
|
|
31
33
|
'project.name': string;
|
|
32
34
|
'project.createdBy.email': string;
|
|
@@ -53,7 +55,10 @@ export declare class DynamicTextUtil {
|
|
|
53
55
|
static isDynamicText(documentElement: DocumentElement): boolean;
|
|
54
56
|
static takesValueFromContainer(bindingProperty: string | null | undefined): boolean;
|
|
55
57
|
static getDynamicTextValue(dynamicTextElement: DocumentElement, property: TypeProperty, propertyLevel: PropertyLevel, container: DynamicTextContainer | null, componentModels: any[], ownerReferenceModel?: any): string;
|
|
56
|
-
static calculateSize(dynamicTextElement: DocumentElement, entityType: any, text: string):
|
|
58
|
+
static calculateSize(dynamicTextElement: DocumentElement, entityType: any, text: string): {
|
|
59
|
+
width: number;
|
|
60
|
+
height: number;
|
|
61
|
+
};
|
|
57
62
|
static getTextFromFrameMemberValues(displayFunction: string, property: any, memberValues: any[]): string;
|
|
58
63
|
private static getItemCount;
|
|
59
64
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DynamicTextUtil = exports.HARD_CODED_TEXT = exports.CLICK_TO_CONFIGURE = exports.MOVE_TO_SECTION_TEXT = exports.MOVE_TO_FRAME_TEXT = exports.DynamicTextDisplayFunction = exports.DYNAMIC_TEXT_DATA_SOURCE = void 0;
|
|
4
|
+
exports.placeholderForMissingContainer = placeholderForMissingContainer;
|
|
5
|
+
exports.isPlaceholderText = isPlaceholderText;
|
|
4
6
|
exports.isContainerBinding = isContainerBinding;
|
|
5
7
|
const types_1 = require("@contrail/types");
|
|
6
8
|
const util_1 = require("@contrail/util");
|
|
@@ -28,6 +30,12 @@ var DynamicTextDisplayFunction;
|
|
|
28
30
|
exports.MOVE_TO_FRAME_TEXT = 'Move to a frame';
|
|
29
31
|
exports.MOVE_TO_SECTION_TEXT = 'Move to a section';
|
|
30
32
|
exports.CLICK_TO_CONFIGURE = 'Click to configure';
|
|
33
|
+
function placeholderForMissingContainer(entityType) {
|
|
34
|
+
return entityType === DYNAMIC_TEXT_DATA_SOURCE.SECTION ? exports.MOVE_TO_SECTION_TEXT : exports.MOVE_TO_FRAME_TEXT;
|
|
35
|
+
}
|
|
36
|
+
function isPlaceholderText(text) {
|
|
37
|
+
return text === exports.MOVE_TO_FRAME_TEXT || text === exports.MOVE_TO_SECTION_TEXT || text === exports.CLICK_TO_CONFIGURE;
|
|
38
|
+
}
|
|
31
39
|
exports.HARD_CODED_TEXT = {
|
|
32
40
|
'project.name': 'Project name',
|
|
33
41
|
'project.createdBy.email': 'Project created by',
|
|
@@ -56,8 +64,9 @@ function isContainerBinding(bindingProperty) {
|
|
|
56
64
|
}
|
|
57
65
|
class DynamicTextUtil {
|
|
58
66
|
static isDynamicText(documentElement) {
|
|
67
|
+
var _a;
|
|
59
68
|
return ((documentElement === null || documentElement === void 0 ? void 0 : documentElement.type) === 'text' &&
|
|
60
|
-
!!documentElement.propertyBindings &&
|
|
69
|
+
!!((_a = documentElement.propertyBindings) === null || _a === void 0 ? void 0 : _a.text) &&
|
|
61
70
|
!!documentElement.propertyBindingsMetaData);
|
|
62
71
|
}
|
|
63
72
|
static takesValueFromContainer(bindingProperty) {
|
|
@@ -97,7 +106,7 @@ class DynamicTextUtil {
|
|
|
97
106
|
}
|
|
98
107
|
else {
|
|
99
108
|
if (!container && !isSpecRelated) {
|
|
100
|
-
text = entityType
|
|
109
|
+
text = placeholderForMissingContainer(entityType);
|
|
101
110
|
}
|
|
102
111
|
else {
|
|
103
112
|
if (CONTAINER_SOURCES.includes(entityType)) {
|
|
@@ -140,7 +149,7 @@ class DynamicTextUtil {
|
|
|
140
149
|
text = exports.HARD_CODED_TEXT[bindingProperty] || (property === null || property === void 0 ? void 0 : property.label);
|
|
141
150
|
}
|
|
142
151
|
else if (!container) {
|
|
143
|
-
text =
|
|
152
|
+
text = placeholderForMissingContainer(entityType);
|
|
144
153
|
}
|
|
145
154
|
else {
|
|
146
155
|
text = property === null || property === void 0 ? void 0 : property.label;
|
|
@@ -150,7 +159,7 @@ class DynamicTextUtil {
|
|
|
150
159
|
text = 'n/a';
|
|
151
160
|
}
|
|
152
161
|
if (displayLabel &&
|
|
153
|
-
!
|
|
162
|
+
!isPlaceholderText(text) &&
|
|
154
163
|
displayFunction !== DynamicTextDisplayFunction.LABEL &&
|
|
155
164
|
text !== bindingProperty) {
|
|
156
165
|
text = `${exports.HARD_CODED_TEXT[bindingProperty] || (property === null || property === void 0 ? void 0 : property.label) || ''}: ${text}`;
|
|
@@ -158,16 +167,19 @@ class DynamicTextUtil {
|
|
|
158
167
|
return text;
|
|
159
168
|
}
|
|
160
169
|
static calculateSize(dynamicTextElement, entityType, text) {
|
|
161
|
-
var _a, _b, _c, _d, _e;
|
|
162
|
-
let size =
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
170
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
171
|
+
let size = {
|
|
172
|
+
width: (_b = (_a = dynamicTextElement.size) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : 0,
|
|
173
|
+
height: (_d = (_c = dynamicTextElement.size) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 0,
|
|
174
|
+
};
|
|
175
|
+
const fontFamily = (_f = document_util_1.DocumentStyleUtil.getFirstFontFamily((_e = dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text) !== null && _e !== void 0 ? _e : '')) !== null && _f !== void 0 ? _f : document_util_1.DEFAULT_TEXT_FONT_FAMILY;
|
|
176
|
+
const fontSize = (_j = (dynamicTextElement.isTextTool
|
|
177
|
+
? (_h = (_g = dynamicTextElement.style) === null || _g === void 0 ? void 0 : _g.font) === null || _h === void 0 ? void 0 : _h.size
|
|
178
|
+
: document_util_1.DocumentStyleUtil.getFirstFontSize(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text, true))) !== null && _j !== void 0 ? _j : document_util_1.DEFAULT_TEXT_FONT_SIZE;
|
|
167
179
|
const fontSizePx = document_util_1.DocumentStyleUtil.toPx(fontSize, 4);
|
|
168
180
|
const padding = dynamicTextElement.isTextTool ? document_util_1.TEXT_TOOL_PADDING : document_util_1.TEXT_BOX_PADDING;
|
|
169
|
-
const bold = document_util_1.DocumentStyleUtil.isBold(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text, fontFamily);
|
|
170
|
-
const italic = document_util_1.DocumentStyleUtil.isItalic(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text);
|
|
181
|
+
const bold = document_util_1.DocumentStyleUtil.isBold((_k = dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text) !== null && _k !== void 0 ? _k : '', fontFamily);
|
|
182
|
+
const italic = document_util_1.DocumentStyleUtil.isItalic((_l = dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text) !== null && _l !== void 0 ? _l : '');
|
|
171
183
|
const measureTextSettings = {
|
|
172
184
|
fontFamily,
|
|
173
185
|
fontSize: fontSizePx,
|
|
@@ -208,7 +220,7 @@ class DynamicTextUtil {
|
|
|
208
220
|
}
|
|
209
221
|
else if (displayFunction === DynamicTextDisplayFunction.UNIQUE_ARRAY) {
|
|
210
222
|
text = Array.from(new Set(memberValues
|
|
211
|
-
.filter((e) => e !== null && e !== undefined)
|
|
223
|
+
.filter((e) => e !== null && e !== undefined && e !== '')
|
|
212
224
|
.flat()
|
|
213
225
|
.map((e) => formatter.formatValueForProperty(e, property))))
|
|
214
226
|
.sort()
|