handsontable 0.0.0-next-827c165-20240604 → 0.0.0-next-7230ce6-20240605
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of handsontable might be problematic. Click here for more details.
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/dist/handsontable.css +2 -2
- package/dist/handsontable.full.css +2 -2
- package/dist/handsontable.full.js +184 -74
- package/dist/handsontable.full.min.css +2 -2
- package/dist/handsontable.full.min.js +6 -6
- package/dist/handsontable.js +184 -74
- package/dist/handsontable.min.css +2 -2
- package/dist/handsontable.min.js +7 -7
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/package.json +1 -1
- package/plugins/mergeCells/cellCoords.js +19 -1
- package/plugins/mergeCells/cellCoords.mjs +19 -1
- package/plugins/mergeCells/cellsCollection.js +120 -37
- package/plugins/mergeCells/cellsCollection.mjs +120 -37
- package/plugins/mergeCells/mergeCells.js +39 -31
- package/plugins/mergeCells/mergeCells.mjs +39 -31
- package/shortcuts/context.d.ts +1 -1
package/helpers/mixed.js
CHANGED
@@ -134,7 +134,7 @@ const domMessages = {
|
|
134
134
|
function _injectProductInfo(key, element) {
|
135
135
|
const hasValidType = !isEmpty(key);
|
136
136
|
const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
|
137
|
-
const hotVersion = "0.0.0-next-
|
137
|
+
const hotVersion = "0.0.0-next-7230ce6-20240605";
|
138
138
|
let keyValidityDate;
|
139
139
|
let consoleMessageState = 'invalid';
|
140
140
|
let domMessageState = 'invalid';
|
package/helpers/mixed.mjs
CHANGED
@@ -124,7 +124,7 @@ const domMessages = {
|
|
124
124
|
export function _injectProductInfo(key, element) {
|
125
125
|
const hasValidType = !isEmpty(key);
|
126
126
|
const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
|
127
|
-
const hotVersion = "0.0.0-next-
|
127
|
+
const hotVersion = "0.0.0-next-7230ce6-20240605";
|
128
128
|
let keyValidityDate;
|
129
129
|
let consoleMessageState = 'invalid';
|
130
130
|
let domMessageState = 'invalid';
|
package/package.json
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
"url": "https://github.com/handsontable/handsontable/issues"
|
11
11
|
},
|
12
12
|
"author": "Handsoncode <hello@handsontable.com>",
|
13
|
-
"version": "0.0.0-next-
|
13
|
+
"version": "0.0.0-next-7230ce6-20240605",
|
14
14
|
"main": "index",
|
15
15
|
"module": "index.mjs",
|
16
16
|
"jsnext:main": "index.mjs",
|
@@ -3,15 +3,21 @@
|
|
3
3
|
exports.__esModule = true;
|
4
4
|
require("core-js/modules/es.error.cause.js");
|
5
5
|
var _templateLiteralTag = require("../../helpers/templateLiteralTag");
|
6
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
7
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
6
8
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
7
9
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
8
10
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
11
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
12
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
13
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
9
14
|
/**
|
10
15
|
* The `MergedCellCoords` class represents a single merged cell.
|
11
16
|
*
|
12
17
|
* @private
|
13
18
|
* @class MergedCellCoords
|
14
19
|
*/
|
20
|
+
var _cellRange = /*#__PURE__*/new WeakMap();
|
15
21
|
class MergedCellCoords {
|
16
22
|
constructor(row, column, rowspan, colspan, cellCoordsFactory, cellRangeFactory) {
|
17
23
|
/**
|
@@ -56,6 +62,12 @@ class MergedCellCoords {
|
|
56
62
|
* @type {Function}
|
57
63
|
*/
|
58
64
|
_defineProperty(this, "cellRangeFactory", void 0);
|
65
|
+
/**
|
66
|
+
* The cached range coordinates of the merged cell.
|
67
|
+
*
|
68
|
+
* @type {CellRange}
|
69
|
+
*/
|
70
|
+
_classPrivateFieldInitSpec(this, _cellRange, null);
|
59
71
|
this.row = row;
|
60
72
|
this.col = column;
|
61
73
|
this.rowspan = rowspan;
|
@@ -177,6 +189,7 @@ class MergedCellCoords {
|
|
177
189
|
if (this.col + this.colspan > totalColumns - 1) {
|
178
190
|
this.colspan = totalColumns - this.col;
|
179
191
|
}
|
192
|
+
_classPrivateFieldSet(_cellRange, this, null);
|
180
193
|
}
|
181
194
|
|
182
195
|
/**
|
@@ -241,6 +254,7 @@ class MergedCellCoords {
|
|
241
254
|
// removing the whole merge
|
242
255
|
if (changeStart <= mergeStart && changeEnd >= mergeEnd) {
|
243
256
|
this.removed = true;
|
257
|
+
_classPrivateFieldSet(_cellRange, this, null);
|
244
258
|
return false;
|
245
259
|
|
246
260
|
// removing the merge partially, including the beginning
|
@@ -260,6 +274,7 @@ class MergedCellCoords {
|
|
260
274
|
this[span] -= removedPart;
|
261
275
|
}
|
262
276
|
}
|
277
|
+
_classPrivateFieldSet(_cellRange, this, null);
|
263
278
|
return true;
|
264
279
|
}
|
265
280
|
|
@@ -310,7 +325,10 @@ class MergedCellCoords {
|
|
310
325
|
* @returns {CellRange}
|
311
326
|
*/
|
312
327
|
getRange() {
|
313
|
-
|
328
|
+
if (!_classPrivateFieldGet(_cellRange, this)) {
|
329
|
+
_classPrivateFieldSet(_cellRange, this, this.cellRangeFactory(this.cellCoordsFactory(this.row, this.col), this.cellCoordsFactory(this.row, this.col), this.cellCoordsFactory(this.getLastRow(), this.getLastColumn())));
|
330
|
+
}
|
331
|
+
return _classPrivateFieldGet(_cellRange, this);
|
314
332
|
}
|
315
333
|
}
|
316
334
|
var _default = exports.default = MergedCellCoords;
|
@@ -1,7 +1,12 @@
|
|
1
1
|
import "core-js/modules/es.error.cause.js";
|
2
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
3
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
2
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
3
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
4
6
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
7
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
8
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
9
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
5
10
|
import { toSingleLine } from "../../helpers/templateLiteralTag.mjs";
|
6
11
|
/**
|
7
12
|
* The `MergedCellCoords` class represents a single merged cell.
|
@@ -9,6 +14,7 @@ import { toSingleLine } from "../../helpers/templateLiteralTag.mjs";
|
|
9
14
|
* @private
|
10
15
|
* @class MergedCellCoords
|
11
16
|
*/
|
17
|
+
var _cellRange = /*#__PURE__*/new WeakMap();
|
12
18
|
class MergedCellCoords {
|
13
19
|
constructor(row, column, rowspan, colspan, cellCoordsFactory, cellRangeFactory) {
|
14
20
|
/**
|
@@ -53,6 +59,12 @@ class MergedCellCoords {
|
|
53
59
|
* @type {Function}
|
54
60
|
*/
|
55
61
|
_defineProperty(this, "cellRangeFactory", void 0);
|
62
|
+
/**
|
63
|
+
* The cached range coordinates of the merged cell.
|
64
|
+
*
|
65
|
+
* @type {CellRange}
|
66
|
+
*/
|
67
|
+
_classPrivateFieldInitSpec(this, _cellRange, null);
|
56
68
|
this.row = row;
|
57
69
|
this.col = column;
|
58
70
|
this.rowspan = rowspan;
|
@@ -174,6 +186,7 @@ class MergedCellCoords {
|
|
174
186
|
if (this.col + this.colspan > totalColumns - 1) {
|
175
187
|
this.colspan = totalColumns - this.col;
|
176
188
|
}
|
189
|
+
_classPrivateFieldSet(_cellRange, this, null);
|
177
190
|
}
|
178
191
|
|
179
192
|
/**
|
@@ -238,6 +251,7 @@ class MergedCellCoords {
|
|
238
251
|
// removing the whole merge
|
239
252
|
if (changeStart <= mergeStart && changeEnd >= mergeEnd) {
|
240
253
|
this.removed = true;
|
254
|
+
_classPrivateFieldSet(_cellRange, this, null);
|
241
255
|
return false;
|
242
256
|
|
243
257
|
// removing the merge partially, including the beginning
|
@@ -257,6 +271,7 @@ class MergedCellCoords {
|
|
257
271
|
this[span] -= removedPart;
|
258
272
|
}
|
259
273
|
}
|
274
|
+
_classPrivateFieldSet(_cellRange, this, null);
|
260
275
|
return true;
|
261
276
|
}
|
262
277
|
|
@@ -307,7 +322,10 @@ class MergedCellCoords {
|
|
307
322
|
* @returns {CellRange}
|
308
323
|
*/
|
309
324
|
getRange() {
|
310
|
-
|
325
|
+
if (!_classPrivateFieldGet(_cellRange, this)) {
|
326
|
+
_classPrivateFieldSet(_cellRange, this, this.cellRangeFactory(this.cellCoordsFactory(this.row, this.col), this.cellCoordsFactory(this.row, this.col), this.cellCoordsFactory(this.getLastRow(), this.getLastColumn())));
|
327
|
+
}
|
328
|
+
return _classPrivateFieldGet(_cellRange, this);
|
311
329
|
}
|
312
330
|
}
|
313
331
|
export default MergedCellCoords;
|
@@ -51,9 +51,15 @@ class MergedCellsCollection {
|
|
51
51
|
/**
|
52
52
|
* Array of merged cells.
|
53
53
|
*
|
54
|
-
* @type {
|
54
|
+
* @type {MergedCellCoords[]}
|
55
55
|
*/
|
56
56
|
_defineProperty(this, "mergedCells", []);
|
57
|
+
/**
|
58
|
+
* Matrix of cells (row, col) that points to the instances of the MergedCellCoords objects.
|
59
|
+
*
|
60
|
+
* @type {Array}
|
61
|
+
*/
|
62
|
+
_defineProperty(this, "mergedCellsMatrix", new Map());
|
57
63
|
/**
|
58
64
|
* The Handsontable instance.
|
59
65
|
*
|
@@ -85,16 +91,11 @@ class MergedCellsCollection {
|
|
85
91
|
* @returns {MergedCellCoords|boolean} Returns a wanted merged cell on success and `false` on failure.
|
86
92
|
*/
|
87
93
|
get(row, column) {
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
return false;
|
94
|
-
}
|
95
|
-
return true;
|
96
|
-
});
|
97
|
-
return result;
|
94
|
+
var _this$mergedCellsMatr;
|
95
|
+
if (!this.mergedCellsMatrix.has(row)) {
|
96
|
+
return false;
|
97
|
+
}
|
98
|
+
return (_this$mergedCellsMatr = this.mergedCellsMatrix.get(row).get(column)) !== null && _this$mergedCellsMatr !== void 0 ? _this$mergedCellsMatr : false;
|
98
99
|
}
|
99
100
|
|
100
101
|
/**
|
@@ -104,9 +105,8 @@ class MergedCellsCollection {
|
|
104
105
|
* @returns {MergedCellCoords|boolean}
|
105
106
|
*/
|
106
107
|
getByRange(range) {
|
107
|
-
const mergedCells = this.mergedCells;
|
108
108
|
let result = false;
|
109
|
-
(0, _array.arrayEach)(mergedCells, mergedCell => {
|
109
|
+
(0, _array.arrayEach)(this.mergedCells, mergedCell => {
|
110
110
|
if (mergedCell.row <= range.from.row && mergedCell.row + mergedCell.rowspan - 1 >= range.to.row && mergedCell.col <= range.from.col && mergedCell.col + mergedCell.colspan - 1 >= range.to.col) {
|
111
111
|
result = mergedCell;
|
112
112
|
return result;
|
@@ -116,6 +116,59 @@ class MergedCellsCollection {
|
|
116
116
|
return result;
|
117
117
|
}
|
118
118
|
|
119
|
+
/**
|
120
|
+
* Filters merge cells objects provided by users from overlapping cells.
|
121
|
+
*
|
122
|
+
* @param {{ row: number, col: number, rowspan: number, colspan: number }} mergedCellsInfo The merged cell information object.
|
123
|
+
* Has to contain `row`, `col`, `colspan` and `rowspan` properties.
|
124
|
+
* @returns {Array<{ row: number, col: number, rowspan: number, colspan: number }>}
|
125
|
+
*/
|
126
|
+
filterOverlappingMergeCells(mergedCellsInfo) {
|
127
|
+
const occupiedCells = new Set();
|
128
|
+
this.mergedCells.forEach(mergedCell => {
|
129
|
+
const {
|
130
|
+
row,
|
131
|
+
col,
|
132
|
+
colspan,
|
133
|
+
rowspan
|
134
|
+
} = mergedCell;
|
135
|
+
for (let r = row; r < row + rowspan; r++) {
|
136
|
+
for (let c = col; c < col + colspan; c++) {
|
137
|
+
occupiedCells.add(`r${r},c${c}`);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
});
|
141
|
+
const filteredMergeCells = mergedCellsInfo.filter(mergedCell => {
|
142
|
+
const {
|
143
|
+
row,
|
144
|
+
col,
|
145
|
+
colspan,
|
146
|
+
rowspan
|
147
|
+
} = mergedCell;
|
148
|
+
const localOccupiedCells = new Set();
|
149
|
+
let isOverlapping = false;
|
150
|
+
for (let r = row; r < row + rowspan; r++) {
|
151
|
+
for (let c = col; c < col + colspan; c++) {
|
152
|
+
const cellId = `r${r},c${c}`;
|
153
|
+
if (occupiedCells.has(cellId)) {
|
154
|
+
(0, _console.warn)(MergedCellsCollection.IS_OVERLAPPING_WARNING(mergedCell));
|
155
|
+
isOverlapping = true;
|
156
|
+
break;
|
157
|
+
}
|
158
|
+
localOccupiedCells.add(cellId);
|
159
|
+
}
|
160
|
+
if (isOverlapping) {
|
161
|
+
break;
|
162
|
+
}
|
163
|
+
}
|
164
|
+
if (!isOverlapping) {
|
165
|
+
occupiedCells.add(...localOccupiedCells);
|
166
|
+
}
|
167
|
+
return !isOverlapping;
|
168
|
+
});
|
169
|
+
return filteredMergeCells;
|
170
|
+
}
|
171
|
+
|
119
172
|
/**
|
120
173
|
* Get a merged cell contained in the provided range.
|
121
174
|
*
|
@@ -125,7 +178,6 @@ class MergedCellsCollection {
|
|
125
178
|
*/
|
126
179
|
getWithinRange(range) {
|
127
180
|
let countPartials = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
128
|
-
const mergedCells = this.mergedCells;
|
129
181
|
const foundMergedCells = [];
|
130
182
|
let testedRange = range;
|
131
183
|
if (!testedRange.includesRange) {
|
@@ -133,7 +185,7 @@ class MergedCellsCollection {
|
|
133
185
|
const to = this.hot._createCellCoords(testedRange.to.row, testedRange.to.col);
|
134
186
|
testedRange = this.hot._createCellRange(from, from, to);
|
135
187
|
}
|
136
|
-
(0, _array.arrayEach)(mergedCells, mergedCell => {
|
188
|
+
(0, _array.arrayEach)(this.mergedCells, mergedCell => {
|
137
189
|
const mergedCellTopLeft = this.hot._createCellCoords(mergedCell.row, mergedCell.col);
|
138
190
|
const mergedCellBottomRight = this.hot._createCellCoords(mergedCell.row + mergedCell.rowspan - 1, mergedCell.col + mergedCell.colspan - 1);
|
139
191
|
const mergedCellRange = this.hot._createCellRange(mergedCellTopLeft, mergedCellTopLeft, mergedCellBottomRight);
|
@@ -152,22 +204,24 @@ class MergedCellsCollection {
|
|
152
204
|
* Add a merged cell to the container.
|
153
205
|
*
|
154
206
|
* @param {object} mergedCellInfo The merged cell information object. Has to contain `row`, `col`, `colspan` and `rowspan` properties.
|
207
|
+
* @param {boolean} [auto=false] `true` if called internally by the plugin (usually in batch).
|
155
208
|
* @returns {MergedCellCoords|boolean} Returns the new merged cell on success and `false` on failure.
|
156
209
|
*/
|
157
210
|
add(mergedCellInfo) {
|
158
|
-
|
211
|
+
let auto = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
159
212
|
const row = mergedCellInfo.row;
|
160
213
|
const column = mergedCellInfo.col;
|
161
214
|
const rowspan = mergedCellInfo.rowspan;
|
162
215
|
const colspan = mergedCellInfo.colspan;
|
163
216
|
const newMergedCell = new _cellCoords.default(row, column, rowspan, colspan, this.hot._createCellCoords, this.hot._createCellRange);
|
164
217
|
const alreadyExists = this.get(row, column);
|
165
|
-
const isOverlapping = this.isOverlapping(newMergedCell);
|
218
|
+
const isOverlapping = auto ? false : this.isOverlapping(newMergedCell);
|
166
219
|
if (!alreadyExists && !isOverlapping) {
|
167
220
|
if (this.hot) {
|
168
221
|
newMergedCell.normalize(this.hot);
|
169
222
|
}
|
170
|
-
mergedCells.push(newMergedCell);
|
223
|
+
this.mergedCells.push(newMergedCell);
|
224
|
+
_assertClassBrand(_MergedCellsCollection_brand, this, _addMergedCellToMatrix).call(this, newMergedCell);
|
171
225
|
return newMergedCell;
|
172
226
|
}
|
173
227
|
(0, _console.warn)(MergedCellsCollection.IS_OVERLAPPING_WARNING(newMergedCell));
|
@@ -183,12 +237,12 @@ class MergedCellsCollection {
|
|
183
237
|
* @returns {MergedCellCoords|boolean} Returns the removed merged cell on success and `false` on failure.
|
184
238
|
*/
|
185
239
|
remove(row, column) {
|
186
|
-
const
|
187
|
-
const
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
return
|
240
|
+
const mergedCell = this.get(row, column);
|
241
|
+
const mergedCellIndex = mergedCell ? this.mergedCells.indexOf(mergedCell) : -1;
|
242
|
+
if (mergedCell && mergedCellIndex !== -1) {
|
243
|
+
this.mergedCells.splice(mergedCellIndex, 1);
|
244
|
+
_assertClassBrand(_MergedCellsCollection_brand, this, _removeMergedCellFromMatrix).call(this, mergedCell);
|
245
|
+
return mergedCell;
|
192
246
|
}
|
193
247
|
return false;
|
194
248
|
}
|
@@ -197,16 +251,16 @@ class MergedCellsCollection {
|
|
197
251
|
* Clear all the merged cells.
|
198
252
|
*/
|
199
253
|
clear() {
|
200
|
-
const mergedCells = this.mergedCells;
|
201
254
|
const mergedCellParentsToClear = [];
|
202
255
|
const hiddenCollectionElements = [];
|
203
|
-
(0, _array.arrayEach)(mergedCells, mergedCell => {
|
256
|
+
(0, _array.arrayEach)(this.mergedCells, mergedCell => {
|
204
257
|
const TD = this.hot.getCell(mergedCell.row, mergedCell.col);
|
205
258
|
if (TD) {
|
206
259
|
mergedCellParentsToClear.push([TD, this.get(mergedCell.row, mergedCell.col), mergedCell.row, mergedCell.col]);
|
207
260
|
}
|
208
261
|
});
|
209
262
|
this.mergedCells.length = 0;
|
263
|
+
this.mergedCellsMatrix = new Map();
|
210
264
|
(0, _array.arrayEach)(mergedCellParentsToClear, (mergedCell, i) => {
|
211
265
|
(0, _number.rangeEach)(0, mergedCell.rowspan - 1, j => {
|
212
266
|
(0, _number.rangeEach)(0, mergedCell.colspan - 1, k => {
|
@@ -229,23 +283,21 @@ class MergedCellsCollection {
|
|
229
283
|
}
|
230
284
|
|
231
285
|
/**
|
232
|
-
* Check if the provided merged cell overlaps with the others
|
286
|
+
* Check if the provided merged cell overlaps with the others already added.
|
233
287
|
*
|
234
288
|
* @param {MergedCellCoords} mergedCell The merged cell to check against all others in the container.
|
235
289
|
* @returns {boolean} `true` if the provided merged cell overlaps with the others, `false` otherwise.
|
236
290
|
*/
|
237
291
|
isOverlapping(mergedCell) {
|
238
|
-
const mergedCellRange =
|
239
|
-
let
|
240
|
-
|
241
|
-
const
|
242
|
-
if (
|
243
|
-
|
244
|
-
return false;
|
292
|
+
const mergedCellRange = mergedCell.getRange();
|
293
|
+
for (let i = 0; i < this.mergedCells.length; i++) {
|
294
|
+
const otherMergedCell = this.mergedCells[i];
|
295
|
+
const otherMergedCellRange = otherMergedCell.getRange();
|
296
|
+
if (otherMergedCellRange.overlaps(mergedCellRange)) {
|
297
|
+
return true;
|
245
298
|
}
|
246
|
-
|
247
|
-
|
248
|
-
return result;
|
299
|
+
}
|
300
|
+
return false;
|
249
301
|
}
|
250
302
|
|
251
303
|
/**
|
@@ -380,15 +432,24 @@ class MergedCellsCollection {
|
|
380
432
|
default:
|
381
433
|
}
|
382
434
|
(0, _array.arrayEach)(this.mergedCells, currentMerge => {
|
435
|
+
_assertClassBrand(_MergedCellsCollection_brand, this, _removeMergedCellFromMatrix).call(this, currentMerge);
|
383
436
|
currentMerge.shift(shiftVector, index);
|
437
|
+
_assertClassBrand(_MergedCellsCollection_brand, this, _addMergedCellToMatrix).call(this, currentMerge);
|
384
438
|
});
|
385
439
|
(0, _number.rangeEachReverse)(this.mergedCells.length - 1, 0, i => {
|
386
440
|
const currentMerge = this.mergedCells[i];
|
387
441
|
if (currentMerge && currentMerge.removed) {
|
388
442
|
this.mergedCells.splice(this.mergedCells.indexOf(currentMerge), 1);
|
443
|
+
_assertClassBrand(_MergedCellsCollection_brand, this, _removeMergedCellFromMatrix).call(this, currentMerge);
|
389
444
|
}
|
390
445
|
});
|
391
446
|
}
|
447
|
+
|
448
|
+
/**
|
449
|
+
* Adds a merged cell to the matrix.
|
450
|
+
*
|
451
|
+
* @param {MergedCellCoords} mergedCell The merged cell to add.
|
452
|
+
*/
|
392
453
|
}
|
393
454
|
function _getNonIntersectingIndexes(range, axis) {
|
394
455
|
let scanDirection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
@@ -417,4 +478,26 @@ function _getNonIntersectingIndexes(range, axis) {
|
|
417
478
|
return Array.from(set);
|
418
479
|
})));
|
419
480
|
}
|
481
|
+
function _addMergedCellToMatrix(mergedCell) {
|
482
|
+
for (let row = mergedCell.row; row < mergedCell.row + mergedCell.rowspan; row++) {
|
483
|
+
for (let col = mergedCell.col; col < mergedCell.col + mergedCell.colspan; col++) {
|
484
|
+
if (!this.mergedCellsMatrix.has(row)) {
|
485
|
+
this.mergedCellsMatrix.set(row, new Map());
|
486
|
+
}
|
487
|
+
this.mergedCellsMatrix.get(row).set(col, mergedCell);
|
488
|
+
}
|
489
|
+
}
|
490
|
+
}
|
491
|
+
/**
|
492
|
+
* Removes a merged cell from the matrix.
|
493
|
+
*
|
494
|
+
* @param {MergedCellCoords} mergedCell The merged cell to remove.
|
495
|
+
*/
|
496
|
+
function _removeMergedCellFromMatrix(mergedCell) {
|
497
|
+
for (let row = mergedCell.row; row < mergedCell.row + mergedCell.rowspan; row++) {
|
498
|
+
for (let col = mergedCell.col; col < mergedCell.col + mergedCell.colspan; col++) {
|
499
|
+
this.mergedCellsMatrix.get(row).delete(col);
|
500
|
+
}
|
501
|
+
}
|
502
|
+
}
|
420
503
|
var _default = exports.default = MergedCellsCollection;
|