@contrail/documents 1.3.24 → 1.3.26

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.
@@ -13,8 +13,8 @@ class ItemComponentService {
13
13
  var _a;
14
14
  if (!((_a = element === null || element === void 0 ? void 0 : element.elements) === null || _a === void 0 ? void 0 : _a.length) || element.elements.length > 2)
15
15
  return false;
16
- const annotationElement = element.elements.find(e => e.type == 'annotation');
17
- const imageElement = element.elements.find(e => e.type == 'image');
16
+ const annotationElement = element.elements.find((e) => e.type == 'annotation');
17
+ const imageElement = element.elements.find((e) => e.type == 'image');
18
18
  return (!annotationElement || annotationElement.isHidden) && imageElement && !imageElement.isHidden;
19
19
  }
20
20
  static updateSizeAndPosition(propertyElements, componentElement, annotatedElements = []) {
@@ -22,7 +22,7 @@ class ItemComponentService {
22
22
  const newElements = [];
23
23
  let lastYPosition = 0;
24
24
  let width = 200;
25
- const imageElements = propertyElements.filter(element => {
25
+ const imageElements = propertyElements.filter((element) => {
26
26
  return element.type === 'image';
27
27
  });
28
28
  if (imageElements.length > 0) {
@@ -73,7 +73,7 @@ class ItemComponentService {
73
73
  newElements.push(element);
74
74
  });
75
75
  const cardWidth = (_a = componentElement === null || componentElement === void 0 ? void 0 : componentElement.size) === null || _a === void 0 ? void 0 : _a.width;
76
- const imageElement = newElements === null || newElements === void 0 ? void 0 : newElements.find(e => e.type === 'image');
76
+ const imageElement = newElements === null || newElements === void 0 ? void 0 : newElements.find((e) => e.type === 'image');
77
77
  const thumbnailWidth = ((_b = imageElement === null || imageElement === void 0 ? void 0 : imageElement.size) === null || _b === void 0 ? void 0 : _b.width) || exports.DEFAULT_THUMBNAIL_WIDTH;
78
78
  const align = ((_d = (_c = imageElement === null || imageElement === void 0 ? void 0 : imageElement.style) === null || _c === void 0 ? void 0 : _c.text) === null || _d === void 0 ? void 0 : _d.align) || 'center';
79
79
  if (cardWidth && cardWidth > thumbnailWidth) {
@@ -116,14 +116,14 @@ class ItemComponentService {
116
116
  const annotationSize = ((_b = (_a = element.style) === null || _a === void 0 ? void 0 : _a.font) === null || _b === void 0 ? void 0 : _b.size) || document_element_constants_1.ANNOTATION_IMG_SIZE;
117
117
  let height = annotationSize + document_element_constants_1.ANNOTATION_PADDING_Y;
118
118
  let xPos = 0;
119
- const annotatedElement = annotatedElements.find(elem => elem.id === componentElement.id);
119
+ const annotatedElement = annotatedElements.find((elem) => elem.id === componentElement.id);
120
120
  if (!annotatedElement || element.isHidden) {
121
121
  return height;
122
122
  }
123
- const annotations = annotatedElement.annotations.filter(annotation => annotation.category === 'property');
123
+ const annotations = annotatedElement.annotations.filter((annotation) => annotation.category === 'property');
124
124
  if (annotations.length > 0) {
125
125
  let count = 0;
126
- annotations === null || annotations === void 0 ? void 0 : annotations.forEach(annotation => {
126
+ annotations === null || annotations === void 0 ? void 0 : annotations.forEach((annotation) => {
127
127
  if ((count + 1) * annotationSize * 1.25 > width) {
128
128
  count = 0;
129
129
  xPos = -width * 0.5;
@@ -137,7 +137,7 @@ class ItemComponentService {
137
137
  }
138
138
  static getImageElement(element) {
139
139
  var _a;
140
- return (_a = element === null || element === void 0 ? void 0 : element.elements) === null || _a === void 0 ? void 0 : _a.find(e => e.type === 'image');
140
+ return (_a = element === null || element === void 0 ? void 0 : element.elements) === null || _a === void 0 ? void 0 : _a.find((e) => e.type === 'image');
141
141
  }
142
142
  static getItemCardDimensions(element, visualHeight) {
143
143
  var _a, _b, _c;
@@ -37,7 +37,7 @@ class DocumentElementFactory {
37
37
  let element = this.initNewElement(type);
38
38
  element = Object.assign(element, options);
39
39
  if (((_a = element === null || element === void 0 ? void 0 : element.elements) === null || _a === void 0 ? void 0 : _a.length) > 0) {
40
- element.elements = element.elements.map((e) => {
40
+ element.elements = element.elements.map(e => {
41
41
  e.id = (0, nanoid_1.nanoid)(16);
42
42
  return e;
43
43
  });
@@ -81,7 +81,7 @@ class DocumentElementFactory {
81
81
  element.elements = elements;
82
82
  element.modelBindings = modelBindings;
83
83
  if (((_a = element === null || element === void 0 ? void 0 : element.elements) === null || _a === void 0 ? void 0 : _a.length) > 0) {
84
- element.elements = element.elements.map((e) => {
84
+ element.elements = element.elements.map(e => {
85
85
  e.id = (0, nanoid_1.nanoid)(16);
86
86
  return e;
87
87
  });
@@ -114,18 +114,18 @@ class DocumentElementFactory {
114
114
  }
115
115
  const newInnerElements = [];
116
116
  if (newElement.type === 'table') {
117
- const oldChildElements = elements.filter((e) => e.tableId === element.id && ['cell', 'column', 'row'].indexOf(e.type) !== -1);
117
+ const oldChildElements = elements.filter(e => e.tableId === element.id && ['cell', 'column', 'row'].indexOf(e.type) !== -1);
118
118
  let newTableElement, newChildElements = [];
119
119
  try {
120
120
  [newTableElement, ...newChildElements] = document_table_1.TableCopyService.copy(newElement, oldChildElements);
121
121
  }
122
122
  catch (e) { }
123
- if (oldChildElements.length !== newChildElements.length || oldChildElements.length === 0) {
123
+ if (oldChildElements.length > newChildElements.length || oldChildElements.length === 0) {
124
124
  console.log(`Invalid table element to copy`, newElement, oldChildElements, newChildElements);
125
125
  continue;
126
126
  }
127
127
  newElement = newTableElement;
128
- newChildElements.forEach((newChildElement) => {
128
+ newChildElements.forEach(newChildElement => {
129
129
  var _a;
130
130
  let oldChildId;
131
131
  if (newChildElement.type === 'row') {
@@ -137,7 +137,7 @@ class DocumentElementFactory {
137
137
  else if (newChildElement.type === 'cell') {
138
138
  const oldRowId = element.rowIds[newTableElement.rowIds.indexOf(newChildElement.rowId)];
139
139
  const oldColumnId = element.columnIds[newTableElement.columnIds.indexOf(newChildElement.columnId)];
140
- oldChildId = (_a = elements.find((e) => e.type === 'cell' && e.rowId === oldRowId && e.columnId === oldColumnId)) === null || _a === void 0 ? void 0 : _a.id;
140
+ oldChildId = (_a = elements.find(e => e.type === 'cell' && e.rowId === oldRowId && e.columnId === oldColumnId)) === null || _a === void 0 ? void 0 : _a.id;
141
141
  }
142
142
  if (oldChildId) {
143
143
  newChildElement.documentId = documentId;
@@ -145,6 +145,9 @@ class DocumentElementFactory {
145
145
  oldIdToNewId.set(oldChildId, newChildElement.id);
146
146
  newInnerElements.push(newChildElement);
147
147
  }
148
+ else {
149
+ newInnerElements.push(newChildElement);
150
+ }
148
151
  });
149
152
  }
150
153
  if (positionOffset) {
@@ -175,18 +178,18 @@ class DocumentElementFactory {
175
178
  if (DocumentElementFactory.isMask(newElement))
176
179
  maskElements.push(newElement);
177
180
  }
178
- groupElements.forEach((groupElement) => {
181
+ groupElements.forEach(groupElement => {
179
182
  groupElement.elementIds = groupElement.elementIds
180
- .map((oldElementId) => oldIdToNewId.get(oldElementId))
181
- .filter((id) => !!id);
183
+ .map(oldElementId => oldIdToNewId.get(oldElementId))
184
+ .filter(id => !!id);
182
185
  });
183
- maskElements.forEach((maskElement) => {
186
+ maskElements.forEach(maskElement => {
184
187
  const newElementIds = maskElement.elementIds
185
- .map((oldElementId) => oldIdToNewId.get(oldElementId))
186
- .filter((id) => !!id);
188
+ .map(oldElementId => oldIdToNewId.get(oldElementId))
189
+ .filter(id => !!id);
187
190
  maskElement.elementIds = (newElementIds === null || newElementIds === void 0 ? void 0 : newElementIds.length) > 0 ? newElementIds : null;
188
191
  });
189
- calloutElements.forEach((calloutElement) => {
192
+ calloutElements.forEach(calloutElement => {
190
193
  if (calloutElement.start.id) {
191
194
  const startId = oldIdToNewId.get(calloutElement.start.id);
192
195
  if (startId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "1.3.24",
3
+ "version": "1.3.26",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -39,9 +39,9 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@contrail/actions": "^1.0.17",
42
- "@contrail/document-table": "^1.0.5",
42
+ "@contrail/document-table": "^1.0.19",
43
43
  "@contrail/types": "^3.1.4",
44
- "@contrail/document-util": "^1.0.9",
44
+ "@contrail/document-util": "^1.0.15",
45
45
  "reflect-metadata": "^0.1.13"
46
46
  }
47
47
  }