@contrail/documents 1.5.0 → 1.5.1

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
@@ -7,6 +7,10 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.4.2] - 2026-03-31
11
+
12
+ - Publish new patch to include 1.3.29 changes and 1.4.0 minor update.
13
+
10
14
  ## [1.3.29] - 2026-03-30
11
15
 
12
16
  - Added `imageSize` and `imagePosition` to the `DocumentElement` interface to support the canvas thumbnail crop feature.
@@ -3,6 +3,8 @@ export declare class ColorComponentService {
3
3
  static isColorComponent(element: DocumentElement): boolean;
4
4
  static isColorHexComponent(element: DocumentElement): boolean;
5
5
  static isColorImageComponent(element: DocumentElement): boolean;
6
+ static isThumbnailOnlyComponent(element: DocumentElement): boolean;
7
+ static setThumbnailOnlyProperties(elements: any): void;
6
8
  static getColorRectangle(elements: DocumentElement[]): DocumentElement;
7
9
  static getColorContainer(elements: DocumentElement[]): DocumentElement;
8
10
  static updateSizeAndPosition(elements: any, size?: SizeDefinition): any;
@@ -17,6 +17,29 @@ class ColorComponentService {
17
17
  return (ColorComponentService.isColorComponent(element) &&
18
18
  ((_a = ColorComponentService.getColorRectangle(element.elements)) === null || _a === void 0 ? void 0 : _a.type) === 'image');
19
19
  }
20
+ static isThumbnailOnlyComponent(element) {
21
+ var _a;
22
+ const hasTextProperties = (_a = element.elements) === null || _a === void 0 ? void 0 : _a.some((e) => e.type === 'text');
23
+ return !hasTextProperties;
24
+ }
25
+ static setThumbnailOnlyProperties(elements) {
26
+ const isThumbnailOnlyComponent = this.isThumbnailOnlyComponent({ elements });
27
+ const container = elements === null || elements === void 0 ? void 0 : elements.find((e) => e.type === 'rectangle' && (!e.propertyBindings || Object.keys(e.propertyBindings).length === 0));
28
+ if (isThumbnailOnlyComponent && elements) {
29
+ const colorRect = elements.find((e) => (e.type === 'rectangle' || e.type === 'image') &&
30
+ e.propertyBindings &&
31
+ Object.keys(e.propertyBindings).length > 0);
32
+ if (colorRect && container) {
33
+ colorRect.position = { x: 0, y: 0 };
34
+ container.size = Object.assign({}, colorRect.size);
35
+ container.position = { x: 0, y: 0 };
36
+ container.style = Object.assign(Object.assign({}, container.style), { backgroundColor: 'transparent' });
37
+ }
38
+ }
39
+ else if (!isThumbnailOnlyComponent && container) {
40
+ container.style = Object.assign(Object.assign({}, container.style), { backgroundColor: '#FFFFFF' });
41
+ }
42
+ }
20
43
  static getColorRectangle(elements) {
21
44
  return elements === null || elements === void 0 ? void 0 : elements.find((e) => ['rectangle', 'image'].indexOf(e.type) !== -1 && e.propertyBindings);
22
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",