@contrail/documents 2.1.0-alpha.4325cd8 → 2.1.0-alpha.517ae00
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
|
@@ -20,6 +20,12 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
20
20
|
- `SECTION_ELEMENT_TYPE`, `FRAME_ELEMENT_TYPE` and `SHAPE_ELEMENT_TYPES` in
|
|
21
21
|
`document-element-constants`, so the rule above has one definition rather than one per app.
|
|
22
22
|
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- `DocumentElementFactory.getBoundingClientRect` multiplies the measured size by the element's
|
|
26
|
+
`scale`. Scale grows an element from its top-left, so it widens the box and moves the centre; a
|
|
27
|
+
scaled element previously measured at its unscaled size and could resolve to the wrong container.
|
|
28
|
+
|
|
23
29
|
## [1.17.0] - 2026-09-09
|
|
24
30
|
|
|
25
31
|
### Added
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { PositionDefinition } from '../types';
|
|
1
|
+
import { DocumentElement, PositionDefinition } from '../types';
|
|
2
2
|
import { ContainerElementType } from './container-kind';
|
|
3
3
|
import { DocumentContainer } from './document-container';
|
|
4
4
|
export declare class DocumentContainerIndex {
|
|
5
5
|
private readonly data;
|
|
6
6
|
constructor(data: {
|
|
7
|
+
documentElementsById: Map<string, DocumentElement>;
|
|
7
8
|
containersById: Map<string, DocumentContainer>;
|
|
8
9
|
containerPathsByDocumentElementId: Map<string, Map<string, string[]>>;
|
|
9
10
|
memberIdsByContainerId: Map<string, string[]>;
|
|
@@ -14,6 +15,7 @@ export declare class DocumentContainerIndex {
|
|
|
14
15
|
containerIdsOf(documentElementId: string, elementType: ContainerElementType): string[];
|
|
15
16
|
innermostContainerIdOf(documentElementId: string, elementType: ContainerElementType): string | null;
|
|
16
17
|
memberIdsOf(containerId: string): string[];
|
|
18
|
+
memberDocumentElementsOf(containerId: string): DocumentElement[];
|
|
17
19
|
containerPathAtPoint(point: PositionDefinition, elementType: ContainerElementType): string[];
|
|
18
20
|
maxDepth(elementType: ContainerElementType): number;
|
|
19
21
|
private containersOfType;
|
|
@@ -26,6 +26,11 @@ class DocumentContainerIndex {
|
|
|
26
26
|
var _a;
|
|
27
27
|
return (_a = this.data.memberIdsByContainerId.get(containerId)) !== null && _a !== void 0 ? _a : [];
|
|
28
28
|
}
|
|
29
|
+
memberDocumentElementsOf(containerId) {
|
|
30
|
+
return this.memberIdsOf(containerId)
|
|
31
|
+
.map((memberId) => this.data.documentElementsById.get(memberId))
|
|
32
|
+
.filter(Boolean);
|
|
33
|
+
}
|
|
29
34
|
containerPathAtPoint(point, elementType) {
|
|
30
35
|
const covering = this.containersOfType(elementType).filter((container) => (0, document_container_1.containsPoint)(container.box, point));
|
|
31
36
|
return (0, document_container_1.topmostPerDepth)(covering).map((container) => container.id);
|
|
@@ -37,6 +37,7 @@ class DocumentContainerService {
|
|
|
37
37
|
containerPathsByDocumentElementId.set(documentElementId, pathsByElementType);
|
|
38
38
|
}
|
|
39
39
|
return new document_container_index_1.DocumentContainerIndex({
|
|
40
|
+
documentElementsById: new Map(measuredDocumentElements.map((measured) => [measured.documentElement.id, measured.documentElement])),
|
|
40
41
|
containersById,
|
|
41
42
|
containerPathsByDocumentElementId,
|
|
42
43
|
memberIdsByContainerId,
|
|
@@ -207,13 +207,14 @@ class DocumentElementFactory {
|
|
|
207
207
|
return ['rectangle', 'circle'].indexOf(element === null || element === void 0 ? void 0 : element.type) !== -1 && ((_a = element === null || element === void 0 ? void 0 : element.elementIds) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
208
208
|
}
|
|
209
209
|
static getBoundingClientRect(documentElement, startElement, endElement) {
|
|
210
|
+
var _a, _b, _c, _d;
|
|
210
211
|
const { x, y } = this.getPosition(documentElement, startElement, endElement);
|
|
211
212
|
const { width, height } = this.getSize(documentElement, startElement, endElement);
|
|
212
213
|
return {
|
|
213
214
|
x,
|
|
214
215
|
y,
|
|
215
|
-
width,
|
|
216
|
-
height,
|
|
216
|
+
width: width * ((_b = (_a = documentElement.scale) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : 1),
|
|
217
|
+
height: height * ((_d = (_c = documentElement.scale) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : 1),
|
|
217
218
|
};
|
|
218
219
|
}
|
|
219
220
|
static getPosition(documentElement, startElement, endElement) {
|