@contrail/documents 2.4.0-alpha.a01d866 → 2.4.0-alpha.a27dfea
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 +26 -13
- package/lib/containers/container-kind.d.ts +0 -1
- package/lib/containers/container-kind.js +2 -2
- package/lib/containers/document-container-index.d.ts +1 -1
- package/lib/containers/document-container-index.js +15 -5
- package/lib/containers/document-container.d.ts +2 -4
- package/lib/containers/document-container.js +19 -22
- package/lib/containers/document-container.service.d.ts +3 -4
- package/lib/containers/document-container.service.js +44 -72
- package/lib/util/dynamic-text/dynamic-text-util.js +10 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -13,12 +13,15 @@ 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, described by a `ContainerKind` carrying `elementType
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
section, described by a `ContainerKind` carrying `elementType` and `nests`. An element belongs to
|
|
17
|
+
the container whose box covers its anchor point and which is drawn below it, unless the element's
|
|
18
|
+
own box encloses that container or the element is a group holding it. `nests` decides the shape of
|
|
19
|
+
the answer: sections nest, so an element in a section inside another is in both, and the chain
|
|
20
|
+
requires the inner container to be drawn above the outer; frames do not, so an element covered by
|
|
21
|
+
two frames is in the topmost. A container of another kind is placed by the same rules as any
|
|
22
|
+
element, so a frame can be in a section and a section drawn above a frame is in that frame. The
|
|
23
|
+
rule is written out in `src/containers/DOCUMENT_CONTAINERS_SPEC.md`, which the code is measured
|
|
24
|
+
against.
|
|
22
25
|
- `SECTION_ELEMENT_TYPE`, `FRAME_ELEMENT_TYPE` and `SHAPE_ELEMENT_TYPES` in
|
|
23
26
|
`document-element-constants`, so the rule above has one definition rather than one per app.
|
|
24
27
|
- `DocumentContainerUtil` — the container geometry as statics, with `anchorFor` for a caller
|
|
@@ -51,10 +54,17 @@ Also shipped on the 1.x line as 1.21.0.
|
|
|
51
54
|
- The corner is the rotated one (VIBE-9567). A 200x20 text turned on its side draws as a 20x200
|
|
52
55
|
column, and its unrotated `position` can sit well clear of the frame it is visibly on, which
|
|
53
56
|
reported "Move to a frame" for a vertical text the user could see was placed correctly.
|
|
54
|
-
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
- An element covering a container is not inside it, whatever its type. This replaces a rule that
|
|
58
|
+
excluded only shapes wider and taller than the container, which let a background image join the
|
|
59
|
+
frame it covered and needed an exemption for dynamic text, whose size the container decides. An
|
|
60
|
+
unrotated dynamic text cannot be excluded by enclosure, since its anchor is the corner of the box
|
|
61
|
+
it would have to cover with.
|
|
62
|
+
- `isDynamicText` requires a `propertyBindings.text` binding, which is the one the value is read
|
|
63
|
+
from. The text tool creates an element with empty `propertyBindings` and `propertyBindingsMetaData`
|
|
64
|
+
and both are truthy, so an unconfigured text was anchored at its corner while the canvas centred
|
|
65
|
+
it.
|
|
66
|
+
- A line or callout is measured from the elements it connects even with no stored `position` of its
|
|
67
|
+
own, where it was previously left out of the index entirely.
|
|
58
68
|
- `min` and `max` rendered an infinity sign when every member value was empty. The early return
|
|
59
69
|
checked the list length before the empty values were filtered out, so `Math.min` of nothing
|
|
60
70
|
reached the formatter. Both now fall through to `n/a`.
|
|
@@ -71,9 +81,12 @@ Also shipped on the 1.x line as 1.21.0.
|
|
|
71
81
|
caller holding an element gets the answer the index would give it. Reading `size` directly
|
|
72
82
|
disagreed for the types whose box is not position plus size: a component's box is built from the
|
|
73
83
|
rows it draws, and a line's comes from its `lineDefinition`.
|
|
74
|
-
-
|
|
75
|
-
|
|
76
|
-
|
|
84
|
+
- A container path is a containment chain, walked outward from the container the element sits on.
|
|
85
|
+
Two containers that merely cross are not a chain, so the later-drawn one takes the element rather
|
|
86
|
+
than both claiming it. `containerPathAtPoint` walks the same chain, so a drop preview agrees with
|
|
87
|
+
the drop; it applies only the anchor rule, having no element to compare against a container.
|
|
88
|
+
- `buildIndex` scans element types before measuring anything, so a document holding no containers
|
|
89
|
+
of the kinds asked for returns an empty index without a geometry pass.
|
|
77
90
|
|
|
78
91
|
## [2.3.0] - 2026-09-21
|
|
79
92
|
|
|
@@ -3,7 +3,6 @@ export type ContainerElementType = typeof FRAME_ELEMENT_TYPE | typeof SECTION_EL
|
|
|
3
3
|
export interface ContainerKind {
|
|
4
4
|
elementType: ContainerElementType;
|
|
5
5
|
nests: boolean;
|
|
6
|
-
layer: number;
|
|
7
6
|
}
|
|
8
7
|
export declare const SECTION_KIND: ContainerKind;
|
|
9
8
|
export declare const FRAME_KIND: ContainerKind;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CONTAINER_KINDS = exports.FRAME_KIND = exports.SECTION_KIND = void 0;
|
|
4
4
|
const document_element_constants_1 = require("../document-element-constants");
|
|
5
|
-
exports.SECTION_KIND = { elementType: document_element_constants_1.SECTION_ELEMENT_TYPE, nests: true
|
|
6
|
-
exports.FRAME_KIND = { elementType: document_element_constants_1.FRAME_ELEMENT_TYPE, nests: false
|
|
5
|
+
exports.SECTION_KIND = { elementType: document_element_constants_1.SECTION_ELEMENT_TYPE, nests: true };
|
|
6
|
+
exports.FRAME_KIND = { elementType: document_element_constants_1.FRAME_ELEMENT_TYPE, nests: false };
|
|
7
7
|
exports.CONTAINER_KINDS = [exports.SECTION_KIND, exports.FRAME_KIND];
|
|
@@ -10,6 +10,7 @@ export declare class DocumentContainerIndex {
|
|
|
10
10
|
memberIdsByContainerId: Map<string, string[]>;
|
|
11
11
|
containerIdsByElementType: Map<string, string[]>;
|
|
12
12
|
});
|
|
13
|
+
static empty(): DocumentContainerIndex;
|
|
13
14
|
getContainer(containerId: string): DocumentContainer | null;
|
|
14
15
|
containersOf(documentElementId: string, elementType: ContainerElementType): DocumentContainer[];
|
|
15
16
|
containerIdsOf(documentElementId: string, elementType: ContainerElementType): readonly string[];
|
|
@@ -17,7 +18,6 @@ export declare class DocumentContainerIndex {
|
|
|
17
18
|
memberIdsOf(containerId: string): readonly string[];
|
|
18
19
|
memberDocumentElementsOf(containerId: string): DocumentElement[];
|
|
19
20
|
containerPathAtPoint(point: PositionDefinition, elementType: ContainerElementType): readonly string[];
|
|
20
|
-
maxDepth(elementType: ContainerElementType): number;
|
|
21
21
|
private containersOfType;
|
|
22
22
|
private resolveAll;
|
|
23
23
|
private containerPath;
|
|
@@ -6,6 +6,15 @@ class DocumentContainerIndex {
|
|
|
6
6
|
constructor(data) {
|
|
7
7
|
this.data = data;
|
|
8
8
|
}
|
|
9
|
+
static empty() {
|
|
10
|
+
return new DocumentContainerIndex({
|
|
11
|
+
documentElementsById: new Map(),
|
|
12
|
+
containersById: new Map(),
|
|
13
|
+
containerPathsByDocumentElementId: new Map(),
|
|
14
|
+
memberIdsByContainerId: new Map(),
|
|
15
|
+
containerIdsByElementType: new Map(),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
9
18
|
getContainer(containerId) {
|
|
10
19
|
var _a;
|
|
11
20
|
return (_a = this.data.containersById.get(containerId)) !== null && _a !== void 0 ? _a : null;
|
|
@@ -35,11 +44,12 @@ class DocumentContainerIndex {
|
|
|
35
44
|
return members;
|
|
36
45
|
}
|
|
37
46
|
containerPathAtPoint(point, elementType) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
var _a, _b;
|
|
48
|
+
const containers = this.containersOfType(elementType);
|
|
49
|
+
const covering = containers.filter((container) => document_container_1.DocumentContainerUtil.containsPoint(container.box, point));
|
|
50
|
+
const nests = (_b = (_a = containers[0]) === null || _a === void 0 ? void 0 : _a.kind.nests) !== null && _b !== void 0 ? _b : true;
|
|
51
|
+
const path = nests ? document_container_1.DocumentContainerUtil.chain(covering) : document_container_1.DocumentContainerUtil.topmost(covering);
|
|
52
|
+
return path.map((container) => container.id);
|
|
43
53
|
}
|
|
44
54
|
containersOfType(elementType) {
|
|
45
55
|
var _a;
|
|
@@ -3,10 +3,8 @@ import { ContainerKind } from './container-kind';
|
|
|
3
3
|
export interface DocumentContainer {
|
|
4
4
|
id: string;
|
|
5
5
|
kind: ContainerKind;
|
|
6
|
-
name: string;
|
|
7
6
|
documentElement: DocumentElement;
|
|
8
7
|
box: CoordinateBox;
|
|
9
|
-
depth: number;
|
|
10
8
|
drawOrder: number;
|
|
11
9
|
}
|
|
12
10
|
export interface MeasuredDocumentElement {
|
|
@@ -22,6 +20,6 @@ export declare class DocumentContainerUtil {
|
|
|
22
20
|
static anchorFor(documentElement: DocumentElement, position?: PositionDefinition, startElement?: DocumentElement, endElement?: DocumentElement): PositionDefinition;
|
|
23
21
|
static containsPoint(box: CoordinateBox, point: PositionDefinition): boolean;
|
|
24
22
|
static encloses(outer: CoordinateBox, inner: CoordinateBox): boolean;
|
|
25
|
-
static
|
|
26
|
-
static
|
|
23
|
+
static chain(candidates: DocumentContainer[]): DocumentContainer[];
|
|
24
|
+
static topmost(containers: DocumentContainer[]): DocumentContainer[];
|
|
27
25
|
}
|
|
@@ -39,22 +39,12 @@ class DocumentContainerUtil {
|
|
|
39
39
|
return { x: position.x + before.x - after.x, y: position.y + before.y - after.y };
|
|
40
40
|
}
|
|
41
41
|
static anchorFor(documentElement, position, startElement, endElement) {
|
|
42
|
-
var _a, _b, _c, _d, _e;
|
|
43
42
|
const at = position !== null && position !== void 0 ? position : documentElement === null || documentElement === void 0 ? void 0 : documentElement.position;
|
|
44
43
|
if (!at) {
|
|
45
44
|
return null;
|
|
46
45
|
}
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
let height = size.height * ((_e = (_d = documentElement === null || documentElement === void 0 ? void 0 : documentElement.scale) === null || _d === void 0 ? void 0 : _d.y) !== null && _e !== void 0 ? _e : 1);
|
|
50
|
-
try {
|
|
51
|
-
const measured = document_element_factory_1.DocumentElementFactory.getBoundingClientRectScaled(Object.assign(Object.assign({}, documentElement), { position: at }), startElement, endElement);
|
|
52
|
-
width = measured.width;
|
|
53
|
-
height = measured.height;
|
|
54
|
-
}
|
|
55
|
-
catch (_f) {
|
|
56
|
-
}
|
|
57
|
-
const box = DocumentContainerUtil.toCoordinateBox(at.x, at.y, width, height);
|
|
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);
|
|
58
48
|
return DocumentContainerUtil.anchorOf(documentElement, box);
|
|
59
49
|
}
|
|
60
50
|
static containsPoint(box, point) {
|
|
@@ -68,18 +58,25 @@ class DocumentContainerUtil {
|
|
|
68
58
|
outer.bottom === inner.bottom;
|
|
69
59
|
return covers && !identical;
|
|
70
60
|
}
|
|
71
|
-
static
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
61
|
+
static chain(candidates) {
|
|
62
|
+
if (!candidates.length) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
const topmostOf = (of) => of.reduce((topmost, container) => (container.drawOrder > topmost.drawOrder ? container : topmost));
|
|
66
|
+
const path = [topmostOf(candidates)];
|
|
67
|
+
for (;;) {
|
|
68
|
+
const current = path[0];
|
|
69
|
+
const enclosing = candidates.filter((container) => !path.includes(container) && this.encloses(container.box, current.box));
|
|
70
|
+
if (!enclosing.length) {
|
|
71
|
+
return path;
|
|
80
72
|
}
|
|
73
|
+
path.unshift(topmostOf(enclosing));
|
|
81
74
|
}
|
|
82
|
-
|
|
75
|
+
}
|
|
76
|
+
static topmost(containers) {
|
|
77
|
+
return containers.length
|
|
78
|
+
? [containers.reduce((topmost, container) => (container.drawOrder > topmost.drawOrder ? container : topmost))]
|
|
79
|
+
: [];
|
|
83
80
|
}
|
|
84
81
|
}
|
|
85
82
|
exports.DocumentContainerUtil = DocumentContainerUtil;
|
|
@@ -6,9 +6,8 @@ export declare class DocumentContainerService {
|
|
|
6
6
|
static isContainer(documentElement: DocumentElement, kinds?: ContainerKind[]): boolean;
|
|
7
7
|
private static measureDocumentElements;
|
|
8
8
|
private static measure;
|
|
9
|
-
private static
|
|
10
|
-
private static
|
|
11
|
-
private static
|
|
12
|
-
private static toContainerPath;
|
|
9
|
+
private static collectContainers;
|
|
10
|
+
private static resolvePath;
|
|
11
|
+
private static enclosersOf;
|
|
13
12
|
private static candidateContainers;
|
|
14
13
|
}
|
|
@@ -2,29 +2,41 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DocumentContainerService = void 0;
|
|
4
4
|
const document_element_factory_1 = require("../document-element-factory");
|
|
5
|
-
const dynamic_text_util_1 = require("../util/dynamic-text/dynamic-text-util");
|
|
6
|
-
const document_element_constants_1 = require("../document-element-constants");
|
|
7
5
|
const container_kind_1 = require("./container-kind");
|
|
8
6
|
const document_container_index_1 = require("./document-container-index");
|
|
9
7
|
const document_container_1 = require("./document-container");
|
|
10
8
|
class DocumentContainerService {
|
|
11
9
|
static buildIndex(documentElements, kinds = container_kind_1.CONTAINER_KINDS) {
|
|
12
|
-
|
|
13
|
-
const
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const elements = documentElements !== null && documentElements !== void 0 ? documentElements : [];
|
|
12
|
+
const containerElementTypes = new Set(kinds.map((kind) => kind.elementType));
|
|
13
|
+
if (!elements.some((element) => containerElementTypes.has(element === null || element === void 0 ? void 0 : element.type))) {
|
|
14
|
+
return document_container_index_1.DocumentContainerIndex.empty();
|
|
15
|
+
}
|
|
16
|
+
const documentElementsById = new Map(elements.map((element) => [element.id, element]));
|
|
17
|
+
const measuredDocumentElements = this.measureDocumentElements(elements, documentElementsById);
|
|
18
|
+
const containersByElementType = new Map(kinds.map((kind) => [kind.elementType, this.collectContainers(measuredDocumentElements, kind)]));
|
|
14
19
|
const containersById = new Map();
|
|
15
20
|
const containerIdsByElementType = new Map();
|
|
16
|
-
|
|
17
|
-
containerIdsByElementType.set(elementType,
|
|
18
|
-
|
|
21
|
+
containersByElementType.forEach((containers, elementType) => {
|
|
22
|
+
containerIdsByElementType.set(elementType, containers.map((container) => container.id));
|
|
23
|
+
containers.forEach((container) => containersById.set(container.id, container));
|
|
19
24
|
});
|
|
25
|
+
const pathsByMeasured = new Map();
|
|
26
|
+
for (const measured of measuredDocumentElements) {
|
|
27
|
+
const byElementType = new Map();
|
|
28
|
+
for (const kind of kinds) {
|
|
29
|
+
byElementType.set(kind.elementType, this.resolvePath(measured, kind, (_a = containersByElementType.get(kind.elementType)) !== null && _a !== void 0 ? _a : []));
|
|
30
|
+
}
|
|
31
|
+
pathsByMeasured.set(measured, byElementType);
|
|
32
|
+
}
|
|
20
33
|
const containerPathsByDocumentElementId = new Map();
|
|
21
34
|
const memberIdsByContainerId = new Map();
|
|
22
35
|
for (const measured of measuredDocumentElements) {
|
|
23
36
|
const documentElementId = measured.documentElement.id;
|
|
24
37
|
const pathsByElementType = new Map();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
pathsByElementType.set(kind.elementType, path);
|
|
38
|
+
((_b = pathsByMeasured.get(measured)) !== null && _b !== void 0 ? _b : new Map()).forEach((path, elementType) => pathsByElementType.set(elementType, path.map((container) => container.id)));
|
|
39
|
+
for (const path of pathsByElementType.values()) {
|
|
28
40
|
for (const containerId of path) {
|
|
29
41
|
const members = memberIdsByContainerId.get(containerId);
|
|
30
42
|
if (members) {
|
|
@@ -38,7 +50,7 @@ class DocumentContainerService {
|
|
|
38
50
|
containerPathsByDocumentElementId.set(documentElementId, pathsByElementType);
|
|
39
51
|
}
|
|
40
52
|
return new document_container_index_1.DocumentContainerIndex({
|
|
41
|
-
documentElementsById
|
|
53
|
+
documentElementsById,
|
|
42
54
|
containersById,
|
|
43
55
|
containerPathsByDocumentElementId,
|
|
44
56
|
memberIdsByContainerId,
|
|
@@ -48,8 +60,7 @@ class DocumentContainerService {
|
|
|
48
60
|
static isContainer(documentElement, kinds = container_kind_1.CONTAINER_KINDS) {
|
|
49
61
|
return kinds.some((kind) => kind.elementType === (documentElement === null || documentElement === void 0 ? void 0 : documentElement.type));
|
|
50
62
|
}
|
|
51
|
-
static measureDocumentElements(documentElements) {
|
|
52
|
-
const documentElementsById = new Map(documentElements.map((documentElement) => [documentElement.id, documentElement]));
|
|
63
|
+
static measureDocumentElements(documentElements, documentElementsById) {
|
|
53
64
|
return documentElements.map((documentElement, drawOrder) => ({
|
|
54
65
|
documentElement,
|
|
55
66
|
drawOrder,
|
|
@@ -58,7 +69,8 @@ class DocumentContainerService {
|
|
|
58
69
|
}
|
|
59
70
|
static measure(documentElement, documentElementsById) {
|
|
60
71
|
var _a, _b;
|
|
61
|
-
|
|
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) {
|
|
62
74
|
return null;
|
|
63
75
|
}
|
|
64
76
|
try {
|
|
@@ -71,87 +83,47 @@ class DocumentContainerService {
|
|
|
71
83
|
return null;
|
|
72
84
|
}
|
|
73
85
|
}
|
|
74
|
-
static
|
|
75
|
-
|
|
86
|
+
static collectContainers(measuredDocumentElements, kind) {
|
|
87
|
+
return measuredDocumentElements
|
|
76
88
|
.filter((measured) => measured.documentElement.type === kind.elementType && measured.box)
|
|
77
89
|
.map((measured) => ({
|
|
78
90
|
id: measured.documentElement.id,
|
|
79
91
|
kind,
|
|
80
|
-
name: measured.documentElement.name,
|
|
81
92
|
documentElement: measured.documentElement,
|
|
82
93
|
box: measured.box,
|
|
83
|
-
depth: 0,
|
|
84
94
|
drawOrder: measured.drawOrder,
|
|
85
95
|
}));
|
|
86
|
-
const ancestorsById = new Map();
|
|
87
|
-
for (const container of containers) {
|
|
88
|
-
const ancestors = kind.nests
|
|
89
|
-
? containers.filter((other) => other !== container && document_container_1.DocumentContainerUtil.encloses(other.box, container.box))
|
|
90
|
-
: [];
|
|
91
|
-
ancestorsById.set(container.id, ancestors);
|
|
92
|
-
}
|
|
93
|
-
const depths = new Map();
|
|
94
|
-
const depthOf = (container) => {
|
|
95
|
-
var _a;
|
|
96
|
-
const cached = depths.get(container.id);
|
|
97
|
-
if (cached !== undefined) {
|
|
98
|
-
return cached;
|
|
99
|
-
}
|
|
100
|
-
const ancestors = (_a = ancestorsById.get(container.id)) !== null && _a !== void 0 ? _a : [];
|
|
101
|
-
const depth = ancestors.length ? 1 + Math.max(...ancestors.map(depthOf)) : 0;
|
|
102
|
-
depths.set(container.id, depth);
|
|
103
|
-
return depth;
|
|
104
|
-
};
|
|
105
|
-
for (const container of containers) {
|
|
106
|
-
container.depth = depthOf(container);
|
|
107
|
-
}
|
|
108
|
-
return { containers, ancestorsById };
|
|
109
96
|
}
|
|
110
|
-
static
|
|
111
|
-
|
|
112
|
-
if (!(nesting === null || nesting === void 0 ? void 0 : nesting.containers.length) || !measured.box) {
|
|
97
|
+
static resolvePath(measured, kind, containers) {
|
|
98
|
+
if (!containers.length || !measured.box) {
|
|
113
99
|
return [];
|
|
114
100
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (ownKind.elementType === kind.elementType) {
|
|
118
|
-
return kind.nests ? this.toContainerPath((_a = nesting.ancestorsById.get(measured.documentElement.id)) !== null && _a !== void 0 ? _a : []) : [];
|
|
119
|
-
}
|
|
120
|
-
if (kind.layer > ownKind.layer) {
|
|
121
|
-
return [];
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
const candidates = this.candidateContainers(measured, nesting.containers);
|
|
125
|
-
if (!candidates.length) {
|
|
126
|
-
return [];
|
|
101
|
+
if (measured.documentElement.type === kind.elementType) {
|
|
102
|
+
return kind.nests ? document_container_1.DocumentContainerUtil.chain(this.enclosersOf(measured, containers)) : [];
|
|
127
103
|
}
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
const ancestors = ((_b = nesting.ancestorsById.get(innermostOnTop.id)) !== null && _b !== void 0 ? _b : []).filter((container) => candidateIds.has(container.id));
|
|
131
|
-
return this.toContainerPath([...ancestors, innermostOnTop]);
|
|
132
|
-
}
|
|
133
|
-
static resolveInnermostOnTop(candidates, nesting) {
|
|
134
|
-
const enclosingIds = new Set(candidates.flatMap((container) => { var _a; return (_a = nesting.ancestorsById.get(container.id)) !== null && _a !== void 0 ? _a : []; }).map((ancestor) => ancestor.id));
|
|
135
|
-
return candidates
|
|
136
|
-
.filter((container) => !enclosingIds.has(container.id))
|
|
137
|
-
.reduce((topmost, container) => (container.drawOrder > topmost.drawOrder ? container : topmost));
|
|
104
|
+
const candidates = this.candidateContainers(measured, containers);
|
|
105
|
+
return kind.nests ? document_container_1.DocumentContainerUtil.chain(candidates) : document_container_1.DocumentContainerUtil.topmost(candidates);
|
|
138
106
|
}
|
|
139
|
-
static
|
|
140
|
-
return
|
|
107
|
+
static enclosersOf(measured, containers) {
|
|
108
|
+
return containers.filter((container) => {
|
|
109
|
+
var _a;
|
|
110
|
+
return container.documentElement !== measured.documentElement &&
|
|
111
|
+
document_container_1.DocumentContainerUtil.encloses(container.box, measured.box) &&
|
|
112
|
+
measured.drawOrder > container.drawOrder &&
|
|
113
|
+
!((_a = measured.documentElement.elementIds) === null || _a === void 0 ? void 0 : _a.includes(container.id));
|
|
114
|
+
});
|
|
141
115
|
}
|
|
142
116
|
static candidateContainers(measured, containers) {
|
|
143
117
|
const anchor = document_container_1.DocumentContainerUtil.anchorOf(measured.documentElement, measured.box);
|
|
144
|
-
const isShape = document_element_constants_1.SHAPE_ELEMENT_TYPES.includes(measured.documentElement.type) &&
|
|
145
|
-
!dynamic_text_util_1.DynamicTextUtil.isDynamicText(measured.documentElement);
|
|
146
118
|
return containers.filter((container) => {
|
|
147
119
|
var _a;
|
|
148
|
-
if (container.
|
|
120
|
+
if (container.documentElement === measured.documentElement || measured.drawOrder <= container.drawOrder) {
|
|
149
121
|
return false;
|
|
150
122
|
}
|
|
151
123
|
if (!document_container_1.DocumentContainerUtil.containsPoint(container.box, anchor)) {
|
|
152
124
|
return false;
|
|
153
125
|
}
|
|
154
|
-
if (
|
|
126
|
+
if (document_container_1.DocumentContainerUtil.encloses(measured.box, container.box)) {
|
|
155
127
|
return false;
|
|
156
128
|
}
|
|
157
129
|
return !((_a = measured.documentElement.elementIds) === null || _a === void 0 ? void 0 : _a.includes(container.id));
|
|
@@ -56,8 +56,9 @@ function isContainerBinding(bindingProperty) {
|
|
|
56
56
|
}
|
|
57
57
|
class DynamicTextUtil {
|
|
58
58
|
static isDynamicText(documentElement) {
|
|
59
|
+
var _a;
|
|
59
60
|
return ((documentElement === null || documentElement === void 0 ? void 0 : documentElement.type) === 'text' &&
|
|
60
|
-
!!documentElement.propertyBindings &&
|
|
61
|
+
!!((_a = documentElement.propertyBindings) === null || _a === void 0 ? void 0 : _a.text) &&
|
|
61
62
|
!!documentElement.propertyBindingsMetaData);
|
|
62
63
|
}
|
|
63
64
|
static takesValueFromContainer(bindingProperty) {
|
|
@@ -176,8 +177,9 @@ class DynamicTextUtil {
|
|
|
176
177
|
bold,
|
|
177
178
|
italic,
|
|
178
179
|
};
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
const fixedWidth = size.width - padding * 2;
|
|
181
|
+
if (!dynamicTextElement.isTextTool && fixedWidth > 0) {
|
|
182
|
+
measureTextSettings.width = fixedWidth;
|
|
181
183
|
}
|
|
182
184
|
try {
|
|
183
185
|
const dimensions = document_util_1.DocumentTextUtil.measureText(text, measureTextSettings);
|
|
@@ -207,7 +209,7 @@ class DynamicTextUtil {
|
|
|
207
209
|
}
|
|
208
210
|
else if (displayFunction === DynamicTextDisplayFunction.UNIQUE_ARRAY) {
|
|
209
211
|
text = Array.from(new Set(memberValues
|
|
210
|
-
.filter((e) => e !== null && e !== undefined)
|
|
212
|
+
.filter((e) => e !== null && e !== undefined && e !== '')
|
|
211
213
|
.flat()
|
|
212
214
|
.map((e) => formatter.formatValueForProperty(e, property))))
|
|
213
215
|
.sort()
|
|
@@ -222,7 +224,10 @@ class DynamicTextUtil {
|
|
|
222
224
|
}
|
|
223
225
|
else if (displayFunction === DynamicTextDisplayFunction.MIN ||
|
|
224
226
|
displayFunction === DynamicTextDisplayFunction.MAX) {
|
|
225
|
-
const present = memberValues
|
|
227
|
+
const present = memberValues
|
|
228
|
+
.filter((e) => e !== null && e !== undefined && e !== '')
|
|
229
|
+
.map(Number)
|
|
230
|
+
.filter((e) => !Number.isNaN(e));
|
|
226
231
|
if (!present.length) {
|
|
227
232
|
return '';
|
|
228
233
|
}
|