@contrail/documents 2.4.0-alpha.a5c4d62 → 2.4.0-alpha.bce8caa
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
CHANGED
|
@@ -13,54 +13,80 @@ 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
|
-
|
|
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.
|
|
25
|
+
- `SECTION_ELEMENT_TYPE`, `FRAME_ELEMENT_TYPE` and `SHAPE_ELEMENT_TYPES` in
|
|
26
|
+
`document-element-constants`, so the rule above has one definition rather than one per app.
|
|
27
|
+
- `DocumentContainerUtil` — the container geometry as statics, with `anchorFor` for a caller
|
|
28
|
+
holding an element rather than a measured box.
|
|
29
|
+
- `positionKeepingAnchor` — where an element has to sit for its drawn corner to land where it did
|
|
30
|
+
before a resize. Rotation turns about the centre and the centre moves with the size, so a rotated
|
|
31
|
+
element resized about its stored position drags its corner along with it. The board already makes
|
|
32
|
+
this move; a server recomputing a dynamic text has to make the same one, or the corner is not the
|
|
33
|
+
fixed point the anchor rule needs.
|
|
25
34
|
- `DocumentElementFactory.getBoundingClientRectScaled` — the space an element covers on the canvas,
|
|
26
|
-
with `scale` applied. `getBoundingClientRect`
|
|
27
|
-
works in: `@contrail/document-table` places table members from it, and
|
|
28
|
-
member into a different cell. Anything deciding what an element overlaps
|
|
29
|
-
scaled one.
|
|
35
|
+
with `scale` applied. `getBoundingClientRect` keeps returning the element's own box before scale,
|
|
36
|
+
which is what layout works in: `@contrail/document-table` places table members from it, and
|
|
37
|
+
scaling it moves a scaled member into a different cell. Anything deciding what an element overlaps
|
|
38
|
+
or sits on wants the scaled one.
|
|
30
39
|
|
|
31
40
|
### Deprecated
|
|
32
41
|
|
|
33
42
|
- `isContainerBinding()` in favour of `DynamicTextUtil.takesValueFromContainer()`. Same rule, named
|
|
34
|
-
for what it decides
|
|
43
|
+
for what it decides: whether the binding's value comes from the container rather than a type
|
|
44
|
+
property. The old name still works and delegates to the new one.
|
|
35
45
|
|
|
36
46
|
### Fixed
|
|
37
47
|
|
|
38
|
-
- A dynamic text is anchored at its drawn top-left corner rather than its centre
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
- A dynamic text is now anchored at its drawn top-left corner rather than its centre when deciding
|
|
49
|
+
which container it belongs to, and `DynamicTextUtil.isDynamicText` is the shared test for one. Its
|
|
50
|
+
size comes from the value it resolves to, and that value depends on the container, so letting its
|
|
51
|
+
width feed membership meant its own text could choose its container: near an edge the two answers
|
|
52
|
+
disagreed indefinitely, flipping between a value and "Move to a frame" on every read. Everything
|
|
53
|
+
else still resolves on its centre.
|
|
54
|
+
- The corner is the rotated one (VIBE-9567). A 200x20 text turned on its side draws as a 20x200
|
|
55
|
+
column, and its unrotated `position` can sit well clear of the frame it is visibly on, which
|
|
56
|
+
reported "Move to a frame" for a vertical text the user could see was placed correctly.
|
|
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.
|
|
68
|
+
- `min` and `max` rendered an infinity sign when every member value was empty. The early return
|
|
69
|
+
checked the list length before the empty values were filtered out, so `Math.min` of nothing
|
|
70
|
+
reached the formatter. Both now fall through to `n/a`.
|
|
71
|
+
- `DynamicTextUtil.calculateSize` threw on an element that reached it without a `size`, which on
|
|
72
|
+
the server failed the read for the whole document. It now measures from a zero size instead.
|
|
54
73
|
|
|
55
74
|
### Changed
|
|
56
75
|
|
|
57
|
-
-
|
|
58
|
-
|
|
59
|
-
is
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
76
|
+
- Container membership measures a scaled element from its scaled box, through the new
|
|
77
|
+
`getBoundingClientRectScaled` above. Only a sticky note, a regular iframe, a text-tool text or a
|
|
78
|
+
table carries `scale` at all; for this work the one that matters is a text-tool dynamic text,
|
|
79
|
+
which previously measured at its unscaled size and could resolve to the wrong container.
|
|
80
|
+
- `DocumentContainerUtil.anchorFor` measures through the same factory call the index uses, so a
|
|
81
|
+
caller holding an element gets the answer the index would give it. Reading `size` directly
|
|
82
|
+
disagreed for the types whose box is not position plus size: a component's box is built from the
|
|
83
|
+
rows it draws, and a line's comes from its `lineDefinition`.
|
|
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.
|
|
64
90
|
|
|
65
91
|
## [2.3.0] - 2026-09-21
|
|
66
92
|
|
|
@@ -23,7 +23,7 @@ class DocumentContainerIndex {
|
|
|
23
23
|
return this.resolveAll(this.containerIdsOf(documentElementId, elementType));
|
|
24
24
|
}
|
|
25
25
|
containerIdsOf(documentElementId, elementType) {
|
|
26
|
-
return
|
|
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
|
|
34
|
+
return (_a = this.data.memberIdsByContainerId.get(containerId)) !== null && _a !== void 0 ? _a : [];
|
|
35
35
|
}
|
|
36
36
|
memberDocumentElementsOf(containerId) {
|
|
37
37
|
const members = [];
|
|
@@ -17,10 +17,6 @@ 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
|
-
};
|
|
24
20
|
static anchorFor(documentElement: DocumentElement, position?: PositionDefinition, startElement?: DocumentElement, endElement?: DocumentElement): PositionDefinition;
|
|
25
21
|
static containsPoint(box: CoordinateBox, point: PositionDefinition): boolean;
|
|
26
22
|
static encloses(outer: CoordinateBox, inner: CoordinateBox): boolean;
|
|
@@ -38,23 +38,14 @@ class DocumentContainerUtil {
|
|
|
38
38
|
const after = cornerOffset(newSize);
|
|
39
39
|
return { x: position.x + before.x - after.x, y: position.y + before.y - after.y };
|
|
40
40
|
}
|
|
41
|
-
static resizeKeepingAnchor(dynamicTextElement, entityType, text) {
|
|
42
|
-
const size = dynamic_text_util_1.DynamicTextUtil.calculateSize(dynamicTextElement, entityType, text);
|
|
43
|
-
return { size, position: DocumentContainerUtil.positionKeepingAnchor(dynamicTextElement, size) };
|
|
44
|
-
}
|
|
45
41
|
static anchorFor(documentElement, position, startElement, endElement) {
|
|
46
42
|
const at = position !== null && position !== void 0 ? position : documentElement === null || documentElement === void 0 ? void 0 : documentElement.position;
|
|
47
43
|
if (!at) {
|
|
48
44
|
return null;
|
|
49
45
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return DocumentContainerUtil.anchorOf(documentElement, box);
|
|
54
|
-
}
|
|
55
|
-
catch (_a) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
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);
|
|
58
49
|
}
|
|
59
50
|
static containsPoint(box, point) {
|
|
60
51
|
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 =
|
|
11
|
+
const elements = documentElements !== null && documentElements !== void 0 ? documentElements : [];
|
|
12
12
|
const containerElementTypes = new Set(kinds.map((kind) => kind.elementType));
|
|
13
|
-
if (!elements.some((element) => containerElementTypes.has(element.type))) {
|
|
13
|
+
if (!elements.some((element) => containerElementTypes.has(element === null || element === void 0 ? void 0 : 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]));
|