@contrail/documents 2.4.0-alpha.2f408d6 → 2.4.0-alpha.3c4c83d
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/containers/document-container-index.d.ts +1 -0
- package/lib/containers/document-container-index.js +5 -2
- package/lib/containers/document-container.js +8 -3
- package/lib/containers/document-container.service.js +4 -8
- package/lib/util/dynamic-text/dynamic-text-util.js +1 -1
- package/package.json +1 -1
|
@@ -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.
|
|
26
|
+
return this.containerPathCopy(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 = [];
|
|
@@ -69,5 +69,8 @@ class DocumentContainerIndex {
|
|
|
69
69
|
var _a, _b;
|
|
70
70
|
return (_b = (_a = this.data.containerPathsByDocumentElementId.get(documentElementId)) === null || _a === void 0 ? void 0 : _a.get(elementType)) !== null && _b !== void 0 ? _b : [];
|
|
71
71
|
}
|
|
72
|
+
containerPathCopy(documentElementId, elementType) {
|
|
73
|
+
return [...this.containerPath(documentElementId, elementType)];
|
|
74
|
+
}
|
|
72
75
|
}
|
|
73
76
|
exports.DocumentContainerIndex = DocumentContainerIndex;
|
|
@@ -43,9 +43,14 @@ class DocumentContainerUtil {
|
|
|
43
43
|
if (!at) {
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
try {
|
|
47
|
+
const measured = document_element_factory_1.DocumentElementFactory.getBoundingClientRectScaled(Object.assign(Object.assign({}, documentElement), { position: at }), startElement, endElement);
|
|
48
|
+
const box = DocumentContainerUtil.toCoordinateBox(measured.x, measured.y, measured.width, measured.height);
|
|
49
|
+
return DocumentContainerUtil.anchorOf(documentElement, box);
|
|
50
|
+
}
|
|
51
|
+
catch (_a) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
49
54
|
}
|
|
50
55
|
static containsPoint(box, point) {
|
|
51
56
|
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]));
|
|
@@ -69,13 +69,9 @@ class DocumentContainerService {
|
|
|
69
69
|
}
|
|
70
70
|
static measure(documentElement, documentElementsById) {
|
|
71
71
|
var _a, _b;
|
|
72
|
-
const isDerivedFromEndpoints = (documentElement === null || documentElement === void 0 ? void 0 : documentElement.type) === 'line' || (documentElement === null || documentElement === void 0 ? void 0 : documentElement.type) === 'callout';
|
|
73
|
-
if (!(documentElement === null || documentElement === void 0 ? void 0 : documentElement.position) && !isDerivedFromEndpoints) {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
72
|
try {
|
|
77
|
-
const start = ((_a = documentElement.start) === null || _a === void 0 ? void 0 : _a.id) ? documentElementsById.get(documentElement.start.id) : undefined;
|
|
78
|
-
const end = ((_b = documentElement.end) === null || _b === void 0 ? void 0 : _b.id) ? documentElementsById.get(documentElement.end.id) : undefined;
|
|
73
|
+
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;
|
|
74
|
+
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;
|
|
79
75
|
const { x, y, width, height } = document_element_factory_1.DocumentElementFactory.getBoundingClientRectScaled(documentElement, start, end);
|
|
80
76
|
return document_container_1.DocumentContainerUtil.toCoordinateBox(x, y, width, height);
|
|
81
77
|
}
|
|
@@ -209,7 +209,7 @@ class DynamicTextUtil {
|
|
|
209
209
|
}
|
|
210
210
|
else if (displayFunction === DynamicTextDisplayFunction.UNIQUE_ARRAY) {
|
|
211
211
|
text = Array.from(new Set(memberValues
|
|
212
|
-
.filter((e) => e !== null && e !== undefined)
|
|
212
|
+
.filter((e) => e !== null && e !== undefined && e !== '')
|
|
213
213
|
.flat()
|
|
214
214
|
.map((e) => formatter.formatValueForProperty(e, property))))
|
|
215
215
|
.sort()
|