handsontable 0.0.0-next-2ae8e35-20240613 → 0.0.0-next-fd8b2aa-20240614
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/3rdparty/walkontable/src/core/core.js +16 -0
- package/3rdparty/walkontable/src/core/core.mjs +16 -0
- package/3rdparty/walkontable/src/facade/core.js +3 -0
- package/3rdparty/walkontable/src/facade/core.mjs +3 -0
- package/3rdparty/walkontable/src/renderer/index.js +11 -0
- package/3rdparty/walkontable/src/renderer/index.mjs +11 -0
- package/3rdparty/walkontable/src/renderer/table.js +16 -1
- package/3rdparty/walkontable/src/renderer/table.mjs +16 -1
- package/3rdparty/walkontable/src/settings.js +5 -1
- package/3rdparty/walkontable/src/settings.mjs +5 -1
- package/3rdparty/walkontable/src/table.js +1 -1
- package/3rdparty/walkontable/src/table.mjs +1 -1
- package/3rdparty/walkontable/src/utils/row.js +16 -0
- package/3rdparty/walkontable/src/utils/row.mjs +16 -0
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/common.d.ts +3 -0
- package/core.js +0 -6
- package/core.mjs +0 -6
- package/dist/handsontable.css +2 -2
- package/dist/handsontable.full.css +2 -2
- package/dist/handsontable.full.js +504 -249
- package/dist/handsontable.full.min.css +2 -2
- package/dist/handsontable.full.min.js +80 -80
- package/dist/handsontable.js +504 -249
- package/dist/handsontable.min.css +2 -2
- package/dist/handsontable.min.js +14 -14
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/package.json +1 -1
- package/pluginHooks.d.ts +3 -1
- package/pluginHooks.js +11 -0
- package/pluginHooks.mjs +11 -0
- package/plugins/mergeCells/calculations/autofill.js +1 -1
- package/plugins/mergeCells/calculations/autofill.mjs +1 -1
- package/plugins/mergeCells/cellCoords.js +61 -22
- package/plugins/mergeCells/cellCoords.mjs +61 -22
- package/plugins/mergeCells/cellsCollection.js +46 -53
- package/plugins/mergeCells/cellsCollection.mjs +46 -53
- package/plugins/mergeCells/mergeCells.js +133 -92
- package/plugins/mergeCells/mergeCells.mjs +134 -93
- package/plugins/mergeCells/renderer.js +70 -0
- package/plugins/mergeCells/renderer.mjs +66 -0
- package/tableView.js +92 -22
- package/tableView.mjs +92 -22
- package/plugins/mergeCells/utils.js +0 -28
- package/plugins/mergeCells/utils.mjs +0 -24
@@ -18,7 +18,6 @@ import MergedCellCoords from "./cellCoords.mjs";
|
|
18
18
|
import { rangeEach, rangeEachReverse } from "../../helpers/number.mjs";
|
19
19
|
import { warn } from "../../helpers/console.mjs";
|
20
20
|
import { arrayEach } from "../../helpers/array.mjs";
|
21
|
-
import { applySpanProperties } from "./utils.mjs";
|
22
21
|
import { toSingleLine } from "../../helpers/templateLiteralTag.mjs";
|
23
22
|
/**
|
24
23
|
* Defines a container object for the merged cells.
|
@@ -69,11 +68,16 @@ class MergedCellsCollection {
|
|
69
68
|
/**
|
70
69
|
* Get a warning message for when the declared merged cell data overlaps already existing merged cells.
|
71
70
|
*
|
72
|
-
* @param {
|
71
|
+
* @param {{ row: number, col: number, rowspan: number, colspan: number }} mergedCell Object containing information
|
72
|
+
* about the merged cells that was about to be added.
|
73
73
|
* @returns {string}
|
74
74
|
*/
|
75
|
-
static IS_OVERLAPPING_WARNING(
|
76
|
-
|
75
|
+
static IS_OVERLAPPING_WARNING(_ref) {
|
76
|
+
let {
|
77
|
+
row,
|
78
|
+
col
|
79
|
+
} = _ref;
|
80
|
+
return toSingleLine`The merged cell declared at [${row}, ${col}], overlaps\x20
|
77
81
|
with the other declared merged cell. The overlapping merged cell was not added to the table, please\x20
|
78
82
|
fix your setup.`;
|
79
83
|
}
|
@@ -168,32 +172,30 @@ class MergedCellsCollection {
|
|
168
172
|
/**
|
169
173
|
* Get a merged cell contained in the provided range.
|
170
174
|
*
|
171
|
-
* @param {CellRange
|
175
|
+
* @param {CellRange} range The range to search merged cells in.
|
172
176
|
* @param {boolean} [countPartials=false] If set to `true`, all the merged cells overlapping the range will be taken into calculation.
|
173
|
-
* @returns {
|
177
|
+
* @returns {MergedCellCoords[]} Array of found merged cells.
|
174
178
|
*/
|
175
179
|
getWithinRange(range) {
|
176
180
|
let countPartials = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
177
|
-
const
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
if (
|
190
|
-
|
181
|
+
const {
|
182
|
+
row: rowStart,
|
183
|
+
col: columnStart
|
184
|
+
} = range.getTopStartCorner();
|
185
|
+
const {
|
186
|
+
row: rowEnd,
|
187
|
+
col: columnEnd
|
188
|
+
} = range.getBottomEndCorner();
|
189
|
+
const result = [];
|
190
|
+
for (let row = rowStart; row <= rowEnd; row++) {
|
191
|
+
for (let column = columnStart; column <= columnEnd; column++) {
|
192
|
+
const mergedCell = this.get(row, column);
|
193
|
+
if (mergedCell && (countPartials || !countPartials && mergedCell.row === row && mergedCell.col === column)) {
|
194
|
+
result.push(mergedCell);
|
191
195
|
}
|
192
|
-
} else if (testedRange.includesRange(mergedCellRange)) {
|
193
|
-
foundMergedCells.push(mergedCell);
|
194
196
|
}
|
195
|
-
}
|
196
|
-
return
|
197
|
+
}
|
198
|
+
return result;
|
197
199
|
}
|
198
200
|
|
199
201
|
/**
|
@@ -247,35 +249,26 @@ class MergedCellsCollection {
|
|
247
249
|
* Clear all the merged cells.
|
248
250
|
*/
|
249
251
|
clear() {
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
}
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
const TD = this.hot.getCell(mergedCell.row + j, mergedCell.col + k);
|
265
|
-
if (TD) {
|
266
|
-
hiddenCollectionElements.push([TD, null, null, null]);
|
267
|
-
}
|
252
|
+
arrayEach(this.mergedCells, _ref2 => {
|
253
|
+
let {
|
254
|
+
row,
|
255
|
+
col,
|
256
|
+
rowspan,
|
257
|
+
colspan
|
258
|
+
} = _ref2;
|
259
|
+
rangeEach(row, row + rowspan, r => {
|
260
|
+
rangeEach(col, col + colspan, c => {
|
261
|
+
const TD = this.hot.getCell(r, c);
|
262
|
+
if (TD) {
|
263
|
+
TD.removeAttribute('rowspan');
|
264
|
+
TD.removeAttribute('colspan');
|
265
|
+
TD.style.display = '';
|
268
266
|
}
|
269
267
|
});
|
270
268
|
});
|
271
|
-
mergedCellParentsToClear[i][1] = null;
|
272
|
-
});
|
273
|
-
arrayEach(mergedCellParentsToClear, mergedCellParents => {
|
274
|
-
applySpanProperties(...mergedCellParents);
|
275
|
-
});
|
276
|
-
arrayEach(hiddenCollectionElements, hiddenCollectionElement => {
|
277
|
-
applySpanProperties(...hiddenCollectionElement);
|
278
269
|
});
|
270
|
+
this.mergedCells.length = 0;
|
271
|
+
this.mergedCellsMatrix = new Map();
|
279
272
|
}
|
280
273
|
|
281
274
|
/**
|
@@ -466,11 +459,11 @@ function _getNonIntersectingIndexes(range, axis) {
|
|
466
459
|
indexes.get(index).add(lastIndex);
|
467
460
|
}
|
468
461
|
}
|
469
|
-
return Array.from(new Set(Array.from(indexes.entries()).filter(
|
470
|
-
let [, set] =
|
462
|
+
return Array.from(new Set(Array.from(indexes.entries()).filter(_ref3 => {
|
463
|
+
let [, set] = _ref3;
|
471
464
|
return set.size === 1;
|
472
|
-
}).flatMap(
|
473
|
-
let [, set] =
|
465
|
+
}).flatMap(_ref4 => {
|
466
|
+
let [, set] = _ref4;
|
474
467
|
return Array.from(set);
|
475
468
|
})));
|
476
469
|
}
|
@@ -21,10 +21,10 @@ var _array = require("../../helpers/array");
|
|
21
21
|
var _object = require("../../helpers/object");
|
22
22
|
var _console = require("../../helpers/console");
|
23
23
|
var _number = require("../../helpers/number");
|
24
|
-
var _utils = require("./utils");
|
25
24
|
var _element = require("../../helpers/dom/element");
|
26
25
|
var _browser = require("../../helpers/browser");
|
27
26
|
var _focusOrder2 = require("./focusOrder");
|
27
|
+
var _renderer = require("./renderer");
|
28
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
29
29
|
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
30
30
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
@@ -83,6 +83,7 @@ const SHORTCUTS_GROUP = PLUGIN_KEY;
|
|
83
83
|
var _lastSelectedFocus = /*#__PURE__*/new WeakMap();
|
84
84
|
var _lastFocusDelta = /*#__PURE__*/new WeakMap();
|
85
85
|
var _focusOrder = /*#__PURE__*/new WeakMap();
|
86
|
+
var _cellRenderer = /*#__PURE__*/new WeakMap();
|
86
87
|
var _MergeCells_brand = /*#__PURE__*/new WeakSet();
|
87
88
|
class MergeCells extends _base.BasePlugin {
|
88
89
|
constructor() {
|
@@ -139,6 +140,12 @@ class MergeCells extends _base.BasePlugin {
|
|
139
140
|
rowIndexMapper: this.hot.rowIndexMapper,
|
140
141
|
columnIndexMapper: this.hot.columnIndexMapper
|
141
142
|
}));
|
143
|
+
/**
|
144
|
+
* The cell renderer responsible for rendering the merged cells.
|
145
|
+
*
|
146
|
+
* @type {{before: Function, after: Function}}
|
147
|
+
*/
|
148
|
+
_classPrivateFieldInitSpec(this, _cellRenderer, (0, _renderer.createMergeCellRenderer)(this));
|
142
149
|
}
|
143
150
|
static get PLUGIN_KEY() {
|
144
151
|
return PLUGIN_KEY;
|
@@ -240,94 +247,97 @@ class MergeCells extends _base.BasePlugin {
|
|
240
247
|
return _assertClassBrand(_MergeCells_brand, _this, _onAfterIsMultipleSelection).call(_this, ...args);
|
241
248
|
});
|
242
249
|
this.addHook('afterRenderer', function () {
|
250
|
+
return _classPrivateFieldGet(_cellRenderer, _this).after(...arguments);
|
251
|
+
});
|
252
|
+
this.addHook('afterContextMenuDefaultOptions', function () {
|
243
253
|
for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
|
244
254
|
args[_key13] = arguments[_key13];
|
245
255
|
}
|
246
|
-
return _assertClassBrand(_MergeCells_brand, _this,
|
256
|
+
return _assertClassBrand(_MergeCells_brand, _this, _addMergeActionsToContextMenu).call(_this, ...args);
|
247
257
|
});
|
248
|
-
this.addHook('
|
258
|
+
this.addHook('afterGetCellMeta', function () {
|
249
259
|
for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {
|
250
260
|
args[_key14] = arguments[_key14];
|
251
261
|
}
|
252
|
-
return _assertClassBrand(_MergeCells_brand, _this,
|
262
|
+
return _assertClassBrand(_MergeCells_brand, _this, _onAfterGetCellMeta).call(_this, ...args);
|
253
263
|
});
|
254
|
-
this.addHook('
|
264
|
+
this.addHook('afterViewportRowCalculatorOverride', function () {
|
255
265
|
for (var _len15 = arguments.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) {
|
256
266
|
args[_key15] = arguments[_key15];
|
257
267
|
}
|
258
|
-
return _assertClassBrand(_MergeCells_brand, _this,
|
268
|
+
return _assertClassBrand(_MergeCells_brand, _this, _onAfterViewportRowCalculatorOverride).call(_this, ...args);
|
259
269
|
});
|
260
|
-
this.addHook('
|
270
|
+
this.addHook('afterViewportColumnCalculatorOverride', function () {
|
261
271
|
for (var _len16 = arguments.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) {
|
262
272
|
args[_key16] = arguments[_key16];
|
263
273
|
}
|
264
|
-
return _assertClassBrand(_MergeCells_brand, _this,
|
274
|
+
return _assertClassBrand(_MergeCells_brand, _this, _onAfterViewportColumnCalculatorOverride).call(_this, ...args);
|
265
275
|
});
|
266
|
-
this.addHook('
|
276
|
+
this.addHook('modifyAutofillRange', function () {
|
267
277
|
for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) {
|
268
278
|
args[_key17] = arguments[_key17];
|
269
279
|
}
|
270
|
-
return _assertClassBrand(_MergeCells_brand, _this,
|
280
|
+
return _assertClassBrand(_MergeCells_brand, _this, _onModifyAutofillRange).call(_this, ...args);
|
271
281
|
});
|
272
|
-
this.addHook('
|
282
|
+
this.addHook('afterCreateCol', function () {
|
273
283
|
for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) {
|
274
284
|
args[_key18] = arguments[_key18];
|
275
285
|
}
|
276
|
-
return _assertClassBrand(_MergeCells_brand, _this,
|
286
|
+
return _assertClassBrand(_MergeCells_brand, _this, _onAfterCreateCol).call(_this, ...args);
|
277
287
|
});
|
278
|
-
this.addHook('
|
288
|
+
this.addHook('afterRemoveCol', function () {
|
279
289
|
for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
|
280
290
|
args[_key19] = arguments[_key19];
|
281
291
|
}
|
282
|
-
return _assertClassBrand(_MergeCells_brand, _this,
|
292
|
+
return _assertClassBrand(_MergeCells_brand, _this, _onAfterRemoveCol).call(_this, ...args);
|
283
293
|
});
|
284
|
-
this.addHook('
|
294
|
+
this.addHook('afterCreateRow', function () {
|
285
295
|
for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
|
286
296
|
args[_key20] = arguments[_key20];
|
287
297
|
}
|
288
|
-
return _assertClassBrand(_MergeCells_brand, _this,
|
298
|
+
return _assertClassBrand(_MergeCells_brand, _this, _onAfterCreateRow).call(_this, ...args);
|
289
299
|
});
|
290
|
-
this.addHook('
|
300
|
+
this.addHook('afterRemoveRow', function () {
|
291
301
|
for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
|
292
302
|
args[_key21] = arguments[_key21];
|
293
303
|
}
|
294
|
-
return _assertClassBrand(_MergeCells_brand, _this,
|
304
|
+
return _assertClassBrand(_MergeCells_brand, _this, _onAfterRemoveRow).call(_this, ...args);
|
295
305
|
});
|
296
|
-
this.addHook('
|
306
|
+
this.addHook('afterChange', function () {
|
297
307
|
for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
|
298
308
|
args[_key22] = arguments[_key22];
|
299
309
|
}
|
300
|
-
return _assertClassBrand(_MergeCells_brand, _this,
|
310
|
+
return _assertClassBrand(_MergeCells_brand, _this, _onAfterChange).call(_this, ...args);
|
301
311
|
});
|
302
|
-
this.addHook('
|
312
|
+
this.addHook('beforeDrawBorders', function () {
|
303
313
|
for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
|
304
314
|
args[_key23] = arguments[_key23];
|
305
315
|
}
|
306
|
-
return _assertClassBrand(_MergeCells_brand, _this,
|
316
|
+
return _assertClassBrand(_MergeCells_brand, _this, _onBeforeDrawAreaBorders).call(_this, ...args);
|
307
317
|
});
|
308
|
-
this.addHook('
|
318
|
+
this.addHook('afterDrawSelection', function () {
|
309
319
|
for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
|
310
320
|
args[_key24] = arguments[_key24];
|
311
321
|
}
|
312
|
-
return _assertClassBrand(_MergeCells_brand, _this,
|
322
|
+
return _assertClassBrand(_MergeCells_brand, _this, _onAfterDrawSelection).call(_this, ...args);
|
313
323
|
});
|
314
|
-
this.addHook('
|
324
|
+
this.addHook('beforeRemoveCellClassNames', function () {
|
315
325
|
for (var _len25 = arguments.length, args = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) {
|
316
326
|
args[_key25] = arguments[_key25];
|
317
327
|
}
|
318
|
-
return _assertClassBrand(_MergeCells_brand, _this,
|
328
|
+
return _assertClassBrand(_MergeCells_brand, _this, _onBeforeRemoveCellClassNames).call(_this, ...args);
|
319
329
|
});
|
320
|
-
this.addHook('
|
330
|
+
this.addHook('beforeBeginEditing', function () {
|
321
331
|
for (var _len26 = arguments.length, args = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) {
|
322
332
|
args[_key26] = arguments[_key26];
|
323
333
|
}
|
324
|
-
return _assertClassBrand(_MergeCells_brand, _this,
|
334
|
+
return _assertClassBrand(_MergeCells_brand, _this, _onBeforeBeginEditing).call(_this, ...args);
|
325
335
|
});
|
326
|
-
this.addHook('
|
336
|
+
this.addHook('modifyRowHeightByOverlayName', function () {
|
327
337
|
for (var _len27 = arguments.length, args = new Array(_len27), _key27 = 0; _key27 < _len27; _key27++) {
|
328
338
|
args[_key27] = arguments[_key27];
|
329
339
|
}
|
330
|
-
return _assertClassBrand(_MergeCells_brand, _this,
|
340
|
+
return _assertClassBrand(_MergeCells_brand, _this, _onModifyRowHeightByOverlayName).call(_this, ...args);
|
331
341
|
});
|
332
342
|
this.addHook('beforeUndoStackChange', (action, source) => {
|
333
343
|
if (source === 'MergeCells') {
|
@@ -418,24 +428,26 @@ class MergeCells extends _base.BasePlugin {
|
|
418
428
|
* @returns {boolean}
|
419
429
|
*/
|
420
430
|
validateSetting(setting) {
|
421
|
-
let valid = true;
|
422
431
|
if (!setting) {
|
423
432
|
return false;
|
424
433
|
}
|
425
434
|
if (_cellCoords.default.containsNegativeValues(setting)) {
|
426
435
|
(0, _console.warn)(_cellCoords.default.NEGATIVE_VALUES_WARNING(setting));
|
427
|
-
|
428
|
-
}
|
436
|
+
return false;
|
437
|
+
}
|
438
|
+
if (_cellCoords.default.isOutOfBounds(setting, this.hot.countRows(), this.hot.countCols())) {
|
429
439
|
(0, _console.warn)(_cellCoords.default.IS_OUT_OF_BOUNDS_WARNING(setting));
|
430
|
-
|
431
|
-
}
|
440
|
+
return false;
|
441
|
+
}
|
442
|
+
if (_cellCoords.default.isSingleCell(setting)) {
|
432
443
|
(0, _console.warn)(_cellCoords.default.IS_SINGLE_CELL(setting));
|
433
|
-
|
434
|
-
}
|
444
|
+
return false;
|
445
|
+
}
|
446
|
+
if (_cellCoords.default.containsZeroSpan(setting)) {
|
435
447
|
(0, _console.warn)(_cellCoords.default.ZERO_SPAN_WARNING(setting));
|
436
|
-
|
448
|
+
return false;
|
437
449
|
}
|
438
|
-
return
|
450
|
+
return true;
|
439
451
|
}
|
440
452
|
|
441
453
|
/**
|
@@ -616,7 +628,7 @@ class MergeCells extends _base.BasePlugin {
|
|
616
628
|
unmergeRange(cellRange) {
|
617
629
|
let auto = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
618
630
|
const mergedCells = this.mergedCellsCollection.getWithinRange(cellRange);
|
619
|
-
if (
|
631
|
+
if (mergedCells.length === 0) {
|
620
632
|
return;
|
621
633
|
}
|
622
634
|
this.hot.runHooks('beforeUnmergeCells', cellRange, auto);
|
@@ -1121,47 +1133,6 @@ function _addMergeActionsToContextMenu(defaultOptions) {
|
|
1121
1133
|
name: '---------'
|
1122
1134
|
}, (0, _toggleMerge.default)(this));
|
1123
1135
|
}
|
1124
|
-
/**
|
1125
|
-
* `afterRenderer` hook callback.
|
1126
|
-
*
|
1127
|
-
* @param {HTMLElement} TD The cell to be modified.
|
1128
|
-
* @param {number} row Row index.
|
1129
|
-
* @param {number} col Visual column index.
|
1130
|
-
*/
|
1131
|
-
function _onAfterRenderer(TD, row, col) {
|
1132
|
-
const mergedCell = this.mergedCellsCollection.get(row, col);
|
1133
|
-
if ((0, _object.isObject)(mergedCell)) {
|
1134
|
-
// We shouldn't override data in the collection.
|
1135
|
-
const mergedCellCopy = (0, _object.clone)(mergedCell);
|
1136
|
-
const {
|
1137
|
-
rowIndexMapper: rowMapper,
|
1138
|
-
columnIndexMapper: columnMapper
|
1139
|
-
} = this.hot;
|
1140
|
-
const {
|
1141
|
-
row: mergeRow,
|
1142
|
-
col: mergeColumn,
|
1143
|
-
colspan,
|
1144
|
-
rowspan
|
1145
|
-
} = mergedCellCopy;
|
1146
|
-
const [lastMergedRowIndex, lastMergedColumnIndex] = this.translateMergedCellToRenderable(mergeRow, rowspan, mergeColumn, colspan);
|
1147
|
-
const renderedRowIndex = rowMapper.getRenderableFromVisualIndex(row);
|
1148
|
-
const renderedColumnIndex = columnMapper.getRenderableFromVisualIndex(col);
|
1149
|
-
const maxRowSpan = lastMergedRowIndex - renderedRowIndex + 1; // Number of rendered columns.
|
1150
|
-
const maxColSpan = lastMergedColumnIndex - renderedColumnIndex + 1; // Number of rendered columns.
|
1151
|
-
|
1152
|
-
// We just try to determine some values basing on the actual number of rendered indexes (some columns may be hidden).
|
1153
|
-
mergedCellCopy.row = rowMapper.getNearestNotHiddenIndex(mergedCellCopy.row, 1);
|
1154
|
-
// We just try to determine some values basing on the actual number of rendered indexes (some columns may be hidden).
|
1155
|
-
mergedCellCopy.col = columnMapper.getNearestNotHiddenIndex(mergedCellCopy.col, 1);
|
1156
|
-
// The `rowSpan` property for a `TD` element should be at most equal to number of rendered rows in the merge area.
|
1157
|
-
mergedCellCopy.rowspan = Math.min(mergedCellCopy.rowspan, maxRowSpan);
|
1158
|
-
// The `colSpan` property for a `TD` element should be at most equal to number of rendered columns in the merge area.
|
1159
|
-
mergedCellCopy.colspan = Math.min(mergedCellCopy.colspan, maxColSpan);
|
1160
|
-
(0, _utils.applySpanProperties)(TD, mergedCellCopy, row, col);
|
1161
|
-
} else {
|
1162
|
-
(0, _utils.applySpanProperties)(TD, null, row, col);
|
1163
|
-
}
|
1164
|
-
}
|
1165
1136
|
/**
|
1166
1137
|
* Clears the last selected coordinates before setting a new selection range.
|
1167
1138
|
*/
|
@@ -1303,17 +1274,11 @@ function _onModifyAutofillRange(drag, select) {
|
|
1303
1274
|
dragArea = select;
|
1304
1275
|
return dragArea;
|
1305
1276
|
}
|
1306
|
-
const
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
to: {
|
1312
|
-
row: select[2],
|
1313
|
-
col: select[3]
|
1314
|
-
}
|
1315
|
-
});
|
1316
|
-
if (!mergedCellsWithinSelectionArea) {
|
1277
|
+
const from = this.hot._createCellCoords(select[0], select[1]);
|
1278
|
+
const to = this.hot._createCellCoords(select[2], select[3]);
|
1279
|
+
const range = this.hot._createCellRange(from, from, to);
|
1280
|
+
const mergedCellsWithinSelectionArea = this.mergedCellsCollection.getWithinRange(range);
|
1281
|
+
if (mergedCellsWithinSelectionArea.length === 0) {
|
1317
1282
|
return dragArea;
|
1318
1283
|
}
|
1319
1284
|
dragArea = this.autofillCalculations.snapDragArea(select, dragArea, dragDirection, mergedCellsWithinSelectionArea);
|
@@ -1437,4 +1402,80 @@ function _onBeforeBeginEditing(row, column, initialValue, event) {
|
|
1437
1402
|
const from = this.hot._createCellCoords(mergeCell.row, mergeCell.col);
|
1438
1403
|
const to = this.hot._createCellCoords(mergeCell.row + mergeCell.rowspan - 1, mergeCell.col + mergeCell.colspan - 1);
|
1439
1404
|
return this.hot.selection.getLayerLevel() === 0 && selection.isEqual(this.hot._createCellRange(from, from, to));
|
1405
|
+
}
|
1406
|
+
/**
|
1407
|
+
* Hook used to modify the row height depends on the merged cells in the row.
|
1408
|
+
*
|
1409
|
+
* @param {number} height The row height value provided by the Core.
|
1410
|
+
* @param {number} row The visual row index.
|
1411
|
+
* @param {string} overlayType The overlay type that is currently rendered.
|
1412
|
+
* @returns {number}
|
1413
|
+
*/
|
1414
|
+
function _onModifyRowHeightByOverlayName(height, row, overlayType) {
|
1415
|
+
if (this.hot.getSettings().rowHeaders ||
|
1416
|
+
// merged cells do not work with the bottom overlays
|
1417
|
+
overlayType === 'bottom' || overlayType === 'bottom_inline_start_corner') {
|
1418
|
+
return height;
|
1419
|
+
}
|
1420
|
+
let firstColumn;
|
1421
|
+
let lastColumn;
|
1422
|
+
if (overlayType === 'master') {
|
1423
|
+
firstColumn = this.hot.view.getFirstRenderedVisibleColumn();
|
1424
|
+
lastColumn = this.hot.view.getLastRenderedVisibleColumn();
|
1425
|
+
} else {
|
1426
|
+
const activeOverlay = this.hot.view.getOverlayByName(overlayType);
|
1427
|
+
firstColumn = this.hot.columnIndexMapper.getVisualFromRenderableIndex(activeOverlay.clone.wtTable.getFirstRenderedColumn());
|
1428
|
+
lastColumn = this.hot.columnIndexMapper.getVisualFromRenderableIndex(activeOverlay.clone.wtTable.getLastRenderedColumn());
|
1429
|
+
}
|
1430
|
+
const firstMergedCellInRow = this.mergedCellsCollection.get(row, firstColumn);
|
1431
|
+
if (!firstMergedCellInRow) {
|
1432
|
+
return height;
|
1433
|
+
}
|
1434
|
+
const from = this.hot._createCellCoords(row, firstColumn);
|
1435
|
+
const to = this.hot._createCellCoords(row, lastColumn);
|
1436
|
+
const viewportRange = this.hot._createCellRange(from, from, to);
|
1437
|
+
const mergedCellsWithinRange = this.mergedCellsCollection.getWithinRange(viewportRange);
|
1438
|
+
const maxRowspan = mergedCellsWithinRange.reduce((acc, _ref) => {
|
1439
|
+
let {
|
1440
|
+
rowspan
|
1441
|
+
} = _ref;
|
1442
|
+
return Math.max(acc, rowspan);
|
1443
|
+
}, 1);
|
1444
|
+
let rowspanCorrection = 0;
|
1445
|
+
if (mergedCellsWithinRange.length > 1 && mergedCellsWithinRange[0].rowspan < maxRowspan) {
|
1446
|
+
rowspanCorrection = maxRowspan - mergedCellsWithinRange[0].rowspan;
|
1447
|
+
}
|
1448
|
+
mergedCellsWithinRange.forEach(_ref2 => {
|
1449
|
+
var _height;
|
1450
|
+
let {
|
1451
|
+
rowspan
|
1452
|
+
} = _ref2;
|
1453
|
+
let rowspanAfterCorrection = 0;
|
1454
|
+
if (overlayType === 'top' || overlayType === 'top_inline_start_corner') {
|
1455
|
+
rowspanAfterCorrection = Math.min(maxRowspan, this.hot.view.countNotHiddenFixedRowsTop() - row);
|
1456
|
+
} else {
|
1457
|
+
rowspanAfterCorrection = rowspan - rowspanCorrection;
|
1458
|
+
}
|
1459
|
+
height = Math.max((_height = height) !== null && _height !== void 0 ? _height : 0, _assertClassBrand(_MergeCells_brand, this, _sumCellsHeights).call(this, row, rowspanAfterCorrection));
|
1460
|
+
});
|
1461
|
+
return height;
|
1462
|
+
}
|
1463
|
+
/**
|
1464
|
+
* Sums the heights of the all cells that the merge cell consists of.
|
1465
|
+
*
|
1466
|
+
* @param {number} row The visual row index of the merged cell.
|
1467
|
+
* @param {number} rowspan The rowspan value of the merged cell.
|
1468
|
+
* @returns {number}
|
1469
|
+
*/
|
1470
|
+
function _sumCellsHeights(row, rowspan) {
|
1471
|
+
const defaultHeight = this.hot.view._wt.wtSettings.getSettingPure('defaultRowHeight');
|
1472
|
+
const autoRowSizePlugin = this.hot.getPlugin('autoRowSize');
|
1473
|
+
let height = 0;
|
1474
|
+
for (let i = row; i < row + rowspan; i++) {
|
1475
|
+
if (!this.hot.rowIndexMapper.isHidden(i)) {
|
1476
|
+
var _autoRowSizePlugin$ge;
|
1477
|
+
height += (_autoRowSizePlugin$ge = autoRowSizePlugin === null || autoRowSizePlugin === void 0 ? void 0 : autoRowSizePlugin.getRowHeight(i)) !== null && _autoRowSizePlugin$ge !== void 0 ? _autoRowSizePlugin$ge : defaultHeight;
|
1478
|
+
}
|
1479
|
+
}
|
1480
|
+
return height;
|
1440
1481
|
}
|