@contrail/documents 1.21.0-alpha.3614d20 → 1.21.0-alpha.4368075
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 +3 -7
- package/lib/containers/document-container-index.d.ts +0 -1
- package/lib/containers/document-container-index.js +2 -5
- package/lib/containers/document-container.d.ts +0 -4
- package/lib/containers/document-container.js +3 -12
- package/lib/containers/document-container.service.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -22,16 +22,12 @@ Maintenance release on the 1.x line; the same change ships on 2.x as 2.4.0.
|
|
|
22
22
|
element, so a frame can be in a section and a section drawn above a frame is in that frame. The
|
|
23
23
|
rule is written out in `src/containers/DOCUMENT_CONTAINERS_SPEC.md`, which the code is measured
|
|
24
24
|
against.
|
|
25
|
-
- `SECTION_ELEMENT_TYPE` and `
|
|
26
|
-
above has one definition rather than one per app.
|
|
27
|
-
container rule reads it, and it is exported for the board's own shape handling.
|
|
28
|
-
- `DocumentContainerUtil.resizeKeepingAnchor` — the size a value needs and the position that keeps
|
|
29
|
-
the element's anchor where it is, returned together. Applying one without the other drags the
|
|
30
|
-
drawn corner that membership reads, and `calculateSize` alone let a caller do exactly that.
|
|
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.
|
|
31
27
|
- `DocumentContainerUtil` — the container geometry as statics, with `anchorFor` for a caller
|
|
32
28
|
holding an element rather than a measured box.
|
|
33
29
|
- `positionKeepingAnchor` — where an element has to sit for its drawn corner to land where it did
|
|
34
|
-
before a resize.
|
|
30
|
+
before a resize. Rotation turns about the centre and the centre moves with the size, so a rotated
|
|
35
31
|
element resized about its stored position drags its corner along with it. The board already makes
|
|
36
32
|
this move; a server recomputing a dynamic text has to make the same one, or the corner is not the
|
|
37
33
|
fixed point the anchor rule needs.
|
|
@@ -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.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 = [];
|
|
@@ -69,8 +69,5 @@ 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
|
-
}
|
|
75
72
|
}
|
|
76
73
|
exports.DocumentContainerIndex = DocumentContainerIndex;
|
|
@@ -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]));
|