@contrail/document-table 1.0.6 → 1.0.12

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.
@@ -173,7 +173,10 @@ class TableMergeService {
173
173
  }
174
174
  for (const [rowId, height] of rowHeightsToUpdate) {
175
175
  const updatedRow = table_service_1.TableService.resizeRow(tableElement, childElements, rowId, height).elementsToUpdate[1];
176
+ const updatedColumnAndCells = table_service_1.TableService.autoFitColumns(tableElement, childElements, rowId).elementsToUpdate;
177
+ const uniqueUpdatedColumnAndCells = (0, documents_1.uniqueElementsToUpdate)(updatedColumnAndCells, elementsToUpdate);
176
178
  elementsToUpdate.push(updatedRow);
179
+ elementsToUpdate.push(...uniqueUpdatedColumnAndCells);
177
180
  }
178
181
  return {
179
182
  elementsToUpdate: [
@@ -24,6 +24,8 @@ class TablePasteService {
24
24
  const existingCells = childElements.filter((e) => e.type === 'cell');
25
25
  const elementsToCreate = [];
26
26
  const elementsToUpdate = [];
27
+ const columnWidthsToUpdate = new Map();
28
+ const rowHeightsToUpdate = new Map();
27
29
  let existingMergedRanges = table_merge_service_1.TableMergeService.getMergedRanges(tableElement, childElements);
28
30
  for (let rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
29
31
  const rowToPaste = rowsToPaste[rowIndex - targetRow];
@@ -38,10 +40,9 @@ class TablePasteService {
38
40
  existingRow = newRow;
39
41
  this.log('added row', rowIndex, existingRowId, existingRow);
40
42
  }
41
- if (rowToPaste.size.height > existingRow.size.height) {
42
- this.log('resized row', rowIndex, existingRowId, existingRow);
43
- elementsToUpdate.push(table_service_1.TableService.resizeRow(tableElement, childElements, existingRowId, rowToPaste.size.height)
44
- .elementsToUpdate[1]);
43
+ if (rowToPaste.size.height > existingRow.size.height &&
44
+ (!rowHeightsToUpdate.has(existingRowId) || rowHeightsToUpdate.get(existingRowId) < rowToPaste.size.height)) {
45
+ rowHeightsToUpdate.set(existingRowId, rowToPaste.size.height);
45
46
  }
46
47
  for (let columnIndex = startColumn; columnIndex <= endColumn; columnIndex++) {
47
48
  const columnToPaste = columnsToPaste[columnIndex - targetColumn];
@@ -56,14 +57,10 @@ class TablePasteService {
56
57
  existingColumn = newColumn;
57
58
  this.log('added column', columnIndex, existingColumnId, existingColumn);
58
59
  }
59
- if (columnToPaste.size.width > existingColumn.size.width) {
60
- const updatedColumn = table_service_1.TableService.resizeColumn(tableElement, childElements, existingColumnId, columnToPaste.size.width).elementsToUpdate[1];
61
- const updatedRowAndCells = table_service_1.TableService.autoFitRows(tableElement, childElements, existingColumnId).elementsToUpdate;
62
- const uniqueUpdatedRowAndCells = (0, documents_1.uniqueElementsToUpdate)(updatedRowAndCells, elementsToUpdate);
63
- elementsToUpdate.push(updatedColumn);
64
- elementsToUpdate.push(...uniqueUpdatedRowAndCells);
65
- this.log('resized column', columnIndex, existingColumnId, existingColumn);
66
- this.log('resized column cells and row', uniqueUpdatedRowAndCells, uniqueUpdatedRowAndCells);
60
+ if (columnToPaste.size.width > existingColumn.size.width &&
61
+ (!columnWidthsToUpdate.has(existingColumnId) ||
62
+ columnWidthsToUpdate.get(existingColumnId) < columnToPaste.size.width)) {
63
+ columnWidthsToUpdate.set(existingColumnId, columnToPaste.size.width);
67
64
  }
68
65
  const cellToPaste = cellsToPaste.find((e) => e.rowId === rowToPaste.id && e.columnId === columnToPaste.id);
69
66
  if (!cellToPaste)
@@ -82,6 +79,20 @@ class TablePasteService {
82
79
  }
83
80
  }
84
81
  }
82
+ for (const [columnId, width] of columnWidthsToUpdate) {
83
+ const updatedColumn = table_service_1.TableService.resizeColumn(tableElement, childElements, columnId, width).elementsToUpdate[1];
84
+ const updatedRowAndCells = table_service_1.TableService.autoFitRows(tableElement, childElements, columnId).elementsToUpdate;
85
+ const uniqueUpdatedRowAndCells = (0, documents_1.uniqueElementsToUpdate)(updatedRowAndCells, elementsToUpdate);
86
+ elementsToUpdate.push(updatedColumn);
87
+ elementsToUpdate.push(...uniqueUpdatedRowAndCells);
88
+ }
89
+ for (const [rowId, height] of rowHeightsToUpdate) {
90
+ const updatedRow = table_service_1.TableService.resizeRow(tableElement, childElements, rowId, height).elementsToUpdate[1];
91
+ const updatedColumnAndCells = table_service_1.TableService.autoFitColumns(tableElement, childElements, rowId).elementsToUpdate;
92
+ const uniqueUpdatedColumnAndCells = (0, documents_1.uniqueElementsToUpdate)(updatedColumnAndCells, elementsToUpdate);
93
+ elementsToUpdate.push(updatedRow);
94
+ elementsToUpdate.push(...uniqueUpdatedColumnAndCells);
95
+ }
85
96
  return { elementsToCreate, elementsToUpdate };
86
97
  }
87
98
  static pasteTableCells(tableElement, childElements, elementsToPaste, targetRow, targetColumn) {
@@ -17,6 +17,7 @@ class TableRotateService {
17
17
  const cellUndo = util_1.ObjectUtil.cloneDeep(cell);
18
18
  cell.rotate = { angle };
19
19
  if (angle === 270) {
20
+ cellUndo.rotate = cellUndo.rotate || { angle: 0 };
20
21
  cell.size.height = row.size.height;
21
22
  cell.size.width = table_service_1.TableService.getCellSize(cell).height;
22
23
  if (cell.size.width > column.size.width) {
@@ -26,6 +27,7 @@ class TableRotateService {
26
27
  }
27
28
  }
28
29
  else {
30
+ cellUndo.rotate = cellUndo.rotate || { angle: 270 };
29
31
  cell.size.width = column.size.width;
30
32
  cell.size.height = table_service_1.TableService.getCellSize(cell).height;
31
33
  if (cell.size.height > row.size.height) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/document-table",
3
- "version": "1.0.6",
3
+ "version": "1.0.12",
4
4
  "description": "Library for document tables",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",