@contrail/documents 1.14.0-alpha.fad0c9c → 1.14.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.
@@ -38,7 +38,7 @@ class DocumentElementFactory {
38
38
  let element = this.initNewElement(type);
39
39
  element = Object.assign(element, options);
40
40
  if (((_a = element === null || element === void 0 ? void 0 : element.elements) === null || _a === void 0 ? void 0 : _a.length) > 0) {
41
- element.elements = element.elements.map((e) => {
41
+ element.elements = element.elements.map(e => {
42
42
  e.id = (0, nanoid_1.nanoid)(16);
43
43
  return e;
44
44
  });
@@ -82,7 +82,7 @@ class DocumentElementFactory {
82
82
  element.elements = elements;
83
83
  element.modelBindings = modelBindings;
84
84
  if (((_a = element === null || element === void 0 ? void 0 : element.elements) === null || _a === void 0 ? void 0 : _a.length) > 0) {
85
- element.elements = element.elements.map((e) => {
85
+ element.elements = element.elements.map(e => {
86
86
  e.id = (0, nanoid_1.nanoid)(16);
87
87
  return e;
88
88
  });
@@ -90,7 +90,7 @@ class DocumentElementFactory {
90
90
  return element;
91
91
  }
92
92
  static copyElements(elements, documentId, commonOptions = {}, positionOffset, lastFrameNumber) {
93
- var _a, _b;
93
+ var _a, _b, _c;
94
94
  const oldIdToNewId = new Map();
95
95
  const newElements = [];
96
96
  const groupElements = [];
@@ -115,18 +115,17 @@ class DocumentElementFactory {
115
115
  }
116
116
  const newInnerElements = [];
117
117
  if (newElement.type === 'table') {
118
- const oldChildElements = elements.filter((e) => e.tableId === element.id && ['cell', 'column', 'row'].indexOf(e.type) !== -1);
118
+ const oldChildElements = elements.filter(e => e.tableId === element.id && ['cell', 'column', 'row'].indexOf(e.type) !== -1);
119
119
  let newTableElement, newChildElements = [];
120
120
  try {
121
- [newTableElement, ...newChildElements] = document_table_1.TableCopyService.copy(newElement, oldChildElements);
121
+ [newTableElement, ...newChildElements] = document_table_1.TableCopyService.copy(element, oldChildElements);
122
122
  }
123
- catch (e) { }
124
- if (oldChildElements.length > newChildElements.length || oldChildElements.length === 0) {
125
- telemetry_1.logger.warn({ newElement, oldChildElements, newChildElements }, 'Invalid table element to copy');
123
+ catch (e) {
124
+ telemetry_1.logger.warn({ element, oldChildElements, newChildElements }, (_b = e === null || e === void 0 ? void 0 : e.message) !== null && _b !== void 0 ? _b : 'Invalid table element to copy');
126
125
  continue;
127
126
  }
128
127
  newElement = newTableElement;
129
- newChildElements.forEach((newChildElement) => {
128
+ newChildElements.forEach(newChildElement => {
130
129
  var _a;
131
130
  let oldChildId;
132
131
  if (newChildElement.type === 'row') {
@@ -138,7 +137,7 @@ class DocumentElementFactory {
138
137
  else if (newChildElement.type === 'cell') {
139
138
  const oldRowId = element.rowIds[newTableElement.rowIds.indexOf(newChildElement.rowId)];
140
139
  const oldColumnId = element.columnIds[newTableElement.columnIds.indexOf(newChildElement.columnId)];
141
- 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;
142
141
  }
143
142
  newChildElement.documentId = documentId;
144
143
  newChildElement.specifiedId = newChildElement.id;
@@ -159,7 +158,7 @@ class DocumentElementFactory {
159
158
  newElement.position.x = newElement.position.x + positionOffset.x;
160
159
  newElement.position.y = newElement.position.y + positionOffset.y;
161
160
  }
162
- if (['line', 'callout'].includes(newElement.type) && ((_b = newElement.points) === null || _b === void 0 ? void 0 : _b.length) > 0) {
161
+ if (['line', 'callout'].includes(newElement.type) && ((_c = newElement.points) === null || _c === void 0 ? void 0 : _c.length) > 0) {
163
162
  newElement.points = newElement.points.map(([x, y]) => [x + positionOffset.x, y + positionOffset.y]);
164
163
  }
165
164
  }
@@ -176,18 +175,18 @@ class DocumentElementFactory {
176
175
  if (DocumentElementFactory.isMask(newElement))
177
176
  maskElements.push(newElement);
178
177
  }
179
- groupElements.forEach((groupElement) => {
178
+ groupElements.forEach(groupElement => {
180
179
  groupElement.elementIds = groupElement.elementIds
181
- .map((oldElementId) => oldIdToNewId.get(oldElementId))
182
- .filter((id) => !!id);
180
+ .map(oldElementId => oldIdToNewId.get(oldElementId))
181
+ .filter(id => !!id);
183
182
  });
184
- maskElements.forEach((maskElement) => {
183
+ maskElements.forEach(maskElement => {
185
184
  const newElementIds = maskElement.elementIds
186
- .map((oldElementId) => oldIdToNewId.get(oldElementId))
187
- .filter((id) => !!id);
185
+ .map(oldElementId => oldIdToNewId.get(oldElementId))
186
+ .filter(id => !!id);
188
187
  maskElement.elementIds = (newElementIds === null || newElementIds === void 0 ? void 0 : newElementIds.length) > 0 ? newElementIds : null;
189
188
  });
190
- calloutElements.forEach((calloutElement) => {
189
+ calloutElements.forEach(calloutElement => {
191
190
  if (calloutElement.start.id) {
192
191
  const startId = oldIdToNewId.get(calloutElement.start.id);
193
192
  if (startId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "1.14.0-alpha.fad0c9c",
3
+ "version": "1.14.1",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@contrail/actions": "^1.0.18",
43
- "@contrail/document-table": "^1.1.0",
43
+ "@contrail/document-table": "^1.2.3",
44
44
  "@contrail/document-util": "^1.2.0",
45
45
  "@contrail/types": "^3.4.0",
46
46
  "fractional-indexing": "^2.1.0",