@contrail/document-table 1.0.5-alpha → 1.0.5-alpha.0
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/lib/table-copy.service.js +9 -10
- package/package.json +4 -4
|
@@ -11,7 +11,7 @@ class TableCopyService {
|
|
|
11
11
|
static copy(tableElement, childElements) {
|
|
12
12
|
const copiedChildElementIds = new Map();
|
|
13
13
|
const childElementsMap = new Map();
|
|
14
|
-
childElements.forEach(element => {
|
|
14
|
+
childElements.forEach((element) => {
|
|
15
15
|
childElementsMap.set(element.id, element);
|
|
16
16
|
});
|
|
17
17
|
const rowIds = [];
|
|
@@ -55,16 +55,16 @@ class TableCopyService {
|
|
|
55
55
|
columnIds.push(newElement.id);
|
|
56
56
|
newChildElements.push(newElement);
|
|
57
57
|
}
|
|
58
|
-
const cellElements = childElements.filter(e => e.type === 'cell');
|
|
58
|
+
const cellElements = childElements.filter((e) => e.type === 'cell');
|
|
59
59
|
if (cellElements.length < tableElement.rowIds.length * tableElement.columnIds.length) {
|
|
60
60
|
for (let i = 0; i < tableElement.rowIds.length; i++) {
|
|
61
61
|
for (let j = 0; j < tableElement.columnIds.length; j++) {
|
|
62
62
|
const rowId = tableElement.rowIds[i];
|
|
63
63
|
const columnId = tableElement.columnIds[j];
|
|
64
|
-
const cellElement = cellElements.find(e => e.type === 'cell' && e.rowId === rowId && e.columnId === columnId);
|
|
64
|
+
const cellElement = cellElements.find((e) => e.type === 'cell' && e.rowId === rowId && e.columnId === columnId);
|
|
65
65
|
if (!cellElement) {
|
|
66
|
-
const row = childElements.find(e => e.id === rowId);
|
|
67
|
-
const column = childElements.find(e => e.id === columnId);
|
|
66
|
+
const row = childElements.find((e) => e.id === rowId);
|
|
67
|
+
const column = childElements.find((e) => e.id === columnId);
|
|
68
68
|
cellElements.push((0, table_service_1.createCell)({
|
|
69
69
|
rowId,
|
|
70
70
|
columnId,
|
|
@@ -110,7 +110,7 @@ class TableCopyService {
|
|
|
110
110
|
const tableId = (0, nanoid_1.nanoid)(16);
|
|
111
111
|
let width = 0, height = 0;
|
|
112
112
|
let startRow, endRow, startColumn, endColumn;
|
|
113
|
-
cells.forEach(cell => {
|
|
113
|
+
cells.forEach((cell) => {
|
|
114
114
|
const rowIndex = element.rowIds.indexOf(cell.rowId);
|
|
115
115
|
const columnIndex = element.columnIds.indexOf(cell.columnId);
|
|
116
116
|
const isNotSet = startRow == undefined;
|
|
@@ -124,8 +124,8 @@ class TableCopyService {
|
|
|
124
124
|
endColumn = columnIndex;
|
|
125
125
|
existingCellsMap.set(`${rowIndex}_${columnIndex}`, cell);
|
|
126
126
|
});
|
|
127
|
-
const skipRows = Array.from({ length: endRow - startRow + 1 }, (value, index) => startRow + index).filter(i => !Array.from(existingCellsMap.keys()).find(v => v.startsWith(`${i}_`)));
|
|
128
|
-
const skipColumns = Array.from({ length: endColumn - startColumn + 1 }, (value, index) => startColumn + index).filter(j => !Array.from(existingCellsMap.keys()).find(v => v.endsWith(`_${j}`)));
|
|
127
|
+
const skipRows = Array.from({ length: endRow - startRow + 1 }, (value, index) => startRow + index).filter((i) => !Array.from(existingCellsMap.keys()).find((v) => v.startsWith(`${i}_`)));
|
|
128
|
+
const skipColumns = Array.from({ length: endColumn - startColumn + 1 }, (value, index) => startColumn + index).filter((j) => !Array.from(existingCellsMap.keys()).find((v) => v.endsWith(`_${j}`)));
|
|
129
129
|
for (let i = startRow; i <= endRow; i++) {
|
|
130
130
|
if (skipRows.indexOf(i) !== -1)
|
|
131
131
|
continue;
|
|
@@ -275,8 +275,7 @@ class TableCopyService {
|
|
|
275
275
|
var _a, _b, _c, _d, _e, _f;
|
|
276
276
|
const fontFamily = `${(_c = (_b = (_a = cellElement.style) === null || _a === void 0 ? void 0 : _a.font) === null || _b === void 0 ? void 0 : _b.family) !== null && _c !== void 0 ? _c : table_constants_1.DEFAULT_TEXT_FONT_FAMILY}`;
|
|
277
277
|
const fontSize = `${(_f = (_e = (_d = cellElement.style) === null || _d === void 0 ? void 0 : _d.font) === null || _e === void 0 ? void 0 : _e.size) !== null && _f !== void 0 ? _f : table_constants_1.DEFAULT_TEXT_FONT_SIZE}pt`;
|
|
278
|
-
const size = table_service_1.TableService.getSize(cellElement.text, `width: ${cellElement.size.width -
|
|
279
|
-
table_constants_1.TABLE_TEXT_PADDING * 2}px; height: auto; font-family: ${fontFamily}; font-size: ${fontSize};`);
|
|
278
|
+
const size = table_service_1.TableService.getSize(cellElement.text, `width: ${cellElement.size.width - table_constants_1.TABLE_TEXT_PADDING * 2}px; height: auto; font-family: ${fontFamily}; font-size: ${fontSize};`);
|
|
280
279
|
const documentElement = {
|
|
281
280
|
isTextTool: true,
|
|
282
281
|
text: cellElement.text,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrail/document-table",
|
|
3
|
-
"version": "1.0.5-alpha",
|
|
3
|
+
"version": "1.0.5-alpha.0",
|
|
4
4
|
"description": "Library for document tables",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"testEnvironment": "node"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@contrail/actions": "^1.0.
|
|
41
|
+
"@contrail/actions": "^1.0.17-alpha.0",
|
|
42
42
|
"@contrail/documents": "^1.0.109",
|
|
43
|
-
"@contrail/types": "^3.0
|
|
44
|
-
"@contrail/util": "^1.1.
|
|
43
|
+
"@contrail/types": "^3.1.2-alpha.0",
|
|
44
|
+
"@contrail/util": "^1.1.17-alpha.0",
|
|
45
45
|
"reflect-metadata": "^0.1.13"
|
|
46
46
|
}
|
|
47
47
|
}
|