@contrail/documents 1.21.0-alpha.294740f → 1.21.0-alpha.3614d20

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
@@ -22,12 +22,16 @@ 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`, `FRAME_ELEMENT_TYPE` and `SHAPE_ELEMENT_TYPES` in
26
- `document-element-constants`, so the rule above has one definition rather than one per app.
25
+ - `SECTION_ELEMENT_TYPE` and `FRAME_ELEMENT_TYPE` in `document-element-constants`, so the rule
26
+ above has one definition rather than one per app. `SHAPE_ELEMENT_TYPES` moved here with them; no
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.
27
31
  - `DocumentContainerUtil` — the container geometry as statics, with `anchorFor` for a caller
28
32
  holding an element rather than a measured box.
29
33
  - `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
34
+ before a resize. Prefer `resizeKeepingAnchor` above, which pairs it with the size. Rotation turns about the centre and the centre moves with the size, so a rotated
31
35
  element resized about its stored position drags its corner along with it. The board already makes
32
36
  this move; a server recomputing a dynamic text has to make the same one, or the corner is not the
33
37
  fixed point the anchor rule needs.
@@ -17,6 +17,10 @@ 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
+ };
20
24
  static anchorFor(documentElement: DocumentElement, position?: PositionDefinition, startElement?: DocumentElement, endElement?: DocumentElement): PositionDefinition;
21
25
  static containsPoint(box: CoordinateBox, point: PositionDefinition): boolean;
22
26
  static encloses(outer: CoordinateBox, inner: CoordinateBox): boolean;
@@ -38,6 +38,10 @@ 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
+ }
41
45
  static anchorFor(documentElement, position, startElement, endElement) {
42
46
  const at = position !== null && position !== void 0 ? position : documentElement === null || documentElement === void 0 ? void 0 : documentElement.position;
43
47
  if (!at) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "1.21.0-alpha.294740f",
3
+ "version": "1.21.0-alpha.3614d20",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",