handsontable 0.0.0-next-e5dbebc-20240319 → 0.0.0-next-a7270c3-20240320
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.
Potentially problematic release.
This version of handsontable might be problematic. Click here for more details.
- package/3rdparty/walkontable/src/cell/range.d.ts +1 -2
- package/3rdparty/walkontable/src/cell/range.js +5 -22
- package/3rdparty/walkontable/src/cell/range.mjs +5 -22
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/core/viewportScroll/index.js +1 -4
- package/core/viewportScroll/index.mjs +1 -4
- package/core.d.ts +3 -4
- package/core.js +21 -76
- package/core.mjs +21 -76
- package/dist/handsontable.css +2 -2
- package/dist/handsontable.full.css +2 -2
- package/dist/handsontable.full.js +1357 -2619
- package/dist/handsontable.full.min.css +2 -2
- package/dist/handsontable.full.min.js +71 -71
- package/dist/handsontable.js +1361 -2623
- package/dist/handsontable.min.css +2 -2
- package/dist/handsontable.min.js +19 -19
- package/editorManager.js +8 -12
- package/editorManager.mjs +8 -12
- package/focusManager.js +1 -7
- package/focusManager.mjs +1 -7
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/package.json +1 -1
- package/pluginHooks.d.ts +0 -4
- package/pluginHooks.js +1 -69
- package/pluginHooks.mjs +1 -69
- package/plugins/collapsibleColumns/collapsibleColumns.js +3 -9
- package/plugins/collapsibleColumns/collapsibleColumns.mjs +3 -9
- package/plugins/columnSorting/columnSorting.js +2 -8
- package/plugins/columnSorting/columnSorting.mjs +2 -8
- package/plugins/contextMenu/menu/defaultShortcutsList.js +10 -26
- package/plugins/contextMenu/menu/defaultShortcutsList.mjs +10 -26
- package/plugins/mergeCells/calculations/selection.js +70 -1
- package/plugins/mergeCells/calculations/selection.mjs +70 -1
- package/plugins/mergeCells/cellsCollection.js +0 -116
- package/plugins/mergeCells/cellsCollection.mjs +0 -116
- package/plugins/mergeCells/contextMenuItem/toggleMerge.js +1 -11
- package/plugins/mergeCells/contextMenuItem/toggleMerge.mjs +1 -11
- package/plugins/mergeCells/mergeCells.js +196 -337
- package/plugins/mergeCells/mergeCells.mjs +196 -337
- package/plugins/multiColumnSorting/multiColumnSorting.js +2 -8
- package/plugins/multiColumnSorting/multiColumnSorting.mjs +2 -8
- package/plugins/nestedHeaders/nestedHeaders.js +0 -1
- package/plugins/nestedHeaders/nestedHeaders.mjs +0 -1
- package/plugins/nestedRows/nestedRows.js +3 -9
- package/plugins/nestedRows/nestedRows.mjs +3 -9
- package/renderers/checkboxRenderer/checkboxRenderer.js +5 -8
- package/renderers/checkboxRenderer/checkboxRenderer.mjs +5 -8
- package/selection/highlight/visualSelection.js +0 -2
- package/selection/highlight/visualSelection.mjs +0 -2
- package/selection/selection.js +40 -209
- package/selection/selection.mjs +39 -208
- package/selection/transformation.js +32 -83
- package/selection/transformation.mjs +32 -83
- package/shortcutContexts/commands/editor/closeAndSave.js +2 -2
- package/shortcutContexts/commands/editor/closeAndSave.mjs +2 -2
- package/shortcutContexts/commands/editor/open.js +3 -18
- package/shortcutContexts/commands/editor/open.mjs +3 -18
- package/shortcutContexts/commands/extendCellsSelection/down.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/down.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/left.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/left.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/right.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/right.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toColumns.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toColumns.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +1 -3
- package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +1 -3
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +3 -9
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +3 -9
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +3 -10
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +3 -10
- package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +1 -3
- package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +1 -3
- package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +1 -3
- package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +1 -3
- package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +1 -3
- package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +1 -3
- package/shortcutContexts/commands/extendCellsSelection/toRows.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toRows.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/up.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/up.mjs +1 -1
- package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +1 -6
- package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +1 -6
- package/shortcutContexts/commands/moveCellSelection/inlineStart.js +1 -6
- package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +1 -6
- package/shortcutContexts/grid.js +2 -2
- package/shortcutContexts/grid.mjs +2 -2
- package/shortcuts/context.js +1 -2
- package/shortcuts/context.mjs +1 -2
- package/utils/dataStructures/linkedList.js +1 -6
- package/utils/dataStructures/linkedList.mjs +1 -6
- package/core/viewportScroll/scrollStrategies/focusScroll.js +0 -15
- package/core/viewportScroll/scrollStrategies/focusScroll.mjs +0 -11
- package/plugins/mergeCells/focusOrder.js +0 -303
- package/plugins/mergeCells/focusOrder.mjs +0 -298
@@ -23,7 +23,6 @@ import { rangeEach } from "../../helpers/number.mjs";
|
|
23
23
|
import { applySpanProperties } from "./utils.mjs";
|
24
24
|
import { getStyle } from "../../helpers/dom/element.mjs";
|
25
25
|
import { isChrome } from "../../helpers/browser.mjs";
|
26
|
-
import { FocusOrder } from "./focusOrder.mjs";
|
27
26
|
Hooks.getSingleton().register('beforeMergeCells');
|
28
27
|
Hooks.getSingleton().register('afterMergeCells');
|
29
28
|
Hooks.getSingleton().register('beforeUnmergeCells');
|
@@ -69,9 +68,7 @@ const SHORTCUTS_GROUP = PLUGIN_KEY;
|
|
69
68
|
* ```
|
70
69
|
* :::
|
71
70
|
*/
|
72
|
-
var
|
73
|
-
var _lastFocusDelta = /*#__PURE__*/new WeakMap();
|
74
|
-
var _focusOrder = /*#__PURE__*/new WeakMap();
|
71
|
+
var _lastDesiredCoords = /*#__PURE__*/new WeakMap();
|
75
72
|
var _MergeCells_brand = /*#__PURE__*/new WeakSet();
|
76
73
|
export class MergeCells extends BasePlugin {
|
77
74
|
constructor() {
|
@@ -102,32 +99,9 @@ export class MergeCells extends BasePlugin {
|
|
102
99
|
*/
|
103
100
|
_defineProperty(this, "selectionCalculations", null);
|
104
101
|
/**
|
105
|
-
* The holder for the last selected focus coordinates. This allows keeping the correct coordinates in cases after the
|
106
|
-
* focus is moved out of the merged cell.
|
107
|
-
*
|
108
102
|
* @type {CellCoords}
|
109
103
|
*/
|
110
|
-
_classPrivateFieldInitSpec(this,
|
111
|
-
/**
|
112
|
-
* The last used transformation delta.
|
113
|
-
*
|
114
|
-
* @type {{ row: number, col: number }}
|
115
|
-
*/
|
116
|
-
_classPrivateFieldInitSpec(this, _lastFocusDelta, {
|
117
|
-
row: 0,
|
118
|
-
col: 0
|
119
|
-
});
|
120
|
-
/**
|
121
|
-
* The module responsible for providing the correct focus order (vertical and horizontal) within a selection that
|
122
|
-
* contains merged cells.
|
123
|
-
*
|
124
|
-
* @type {FocusOrder}
|
125
|
-
*/
|
126
|
-
_classPrivateFieldInitSpec(this, _focusOrder, new FocusOrder({
|
127
|
-
mergedCellsGetter: (row, column) => this.mergedCellsCollection.get(row, column),
|
128
|
-
rowIndexMapper: this.hot.rowIndexMapper,
|
129
|
-
columnIndexMapper: this.hot.columnIndexMapper
|
130
|
-
}));
|
104
|
+
_classPrivateFieldInitSpec(this, _lastDesiredCoords, null);
|
131
105
|
}
|
132
106
|
static get PLUGIN_KEY() {
|
133
107
|
return PLUGIN_KEY;
|
@@ -162,17 +136,17 @@ export class MergeCells extends BasePlugin {
|
|
162
136
|
}
|
163
137
|
return _assertClassBrand(_MergeCells_brand, _this, _onAfterInit).call(_this, ...args);
|
164
138
|
});
|
165
|
-
this.addHook('
|
139
|
+
this.addHook('modifyTransformStart', function () {
|
166
140
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
167
141
|
args[_key2] = arguments[_key2];
|
168
142
|
}
|
169
|
-
return _assertClassBrand(_MergeCells_brand, _this,
|
143
|
+
return _assertClassBrand(_MergeCells_brand, _this, _onModifyTransformStart).call(_this, ...args);
|
170
144
|
});
|
171
|
-
this.addHook('
|
145
|
+
this.addHook('afterModifyTransformStart', function () {
|
172
146
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
173
147
|
args[_key3] = arguments[_key3];
|
174
148
|
}
|
175
|
-
return _assertClassBrand(_MergeCells_brand, _this,
|
149
|
+
return _assertClassBrand(_MergeCells_brand, _this, _onAfterModifyTransformStart).call(_this, ...args);
|
176
150
|
});
|
177
151
|
this.addHook('modifyTransformEnd', function () {
|
178
152
|
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
@@ -180,11 +154,11 @@ export class MergeCells extends BasePlugin {
|
|
180
154
|
}
|
181
155
|
return _assertClassBrand(_MergeCells_brand, _this, _onModifyTransformEnd).call(_this, ...args);
|
182
156
|
});
|
183
|
-
this.addHook('
|
157
|
+
this.addHook('modifyGetCellCoords', function () {
|
184
158
|
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
185
159
|
args[_key5] = arguments[_key5];
|
186
160
|
}
|
187
|
-
return _assertClassBrand(_MergeCells_brand, _this,
|
161
|
+
return _assertClassBrand(_MergeCells_brand, _this, _onModifyGetCellCoords).call(_this, ...args);
|
188
162
|
});
|
189
163
|
this.addHook('beforeSetRangeStart', function () {
|
190
164
|
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
@@ -198,123 +172,105 @@ export class MergeCells extends BasePlugin {
|
|
198
172
|
}
|
199
173
|
return _assertClassBrand(_MergeCells_brand, _this, _onBeforeSetRangeStart).call(_this, ...args);
|
200
174
|
});
|
201
|
-
this.addHook('
|
175
|
+
this.addHook('beforeSetRangeEnd', function () {
|
202
176
|
for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
203
177
|
args[_key8] = arguments[_key8];
|
204
178
|
}
|
205
|
-
return _assertClassBrand(_MergeCells_brand, _this,
|
179
|
+
return _assertClassBrand(_MergeCells_brand, _this, _onBeforeSetRangeEnd).call(_this, ...args);
|
206
180
|
});
|
207
|
-
this.addHook('
|
181
|
+
this.addHook('afterIsMultipleSelection', function () {
|
208
182
|
for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
|
209
183
|
args[_key9] = arguments[_key9];
|
210
184
|
}
|
211
|
-
return _assertClassBrand(_MergeCells_brand, _this, _onAfterSelectionFocusSet).call(_this, ...args);
|
212
|
-
});
|
213
|
-
this.addHook('afterSelectionEnd', function () {
|
214
|
-
for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
|
215
|
-
args[_key10] = arguments[_key10];
|
216
|
-
}
|
217
|
-
return _assertClassBrand(_MergeCells_brand, _this, _onAfterSelectionEnd).call(_this, ...args);
|
218
|
-
});
|
219
|
-
this.addHook('modifyGetCellCoords', function () {
|
220
|
-
for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
|
221
|
-
args[_key11] = arguments[_key11];
|
222
|
-
}
|
223
|
-
return _assertClassBrand(_MergeCells_brand, _this, _onModifyGetCellCoords).call(_this, ...args);
|
224
|
-
});
|
225
|
-
this.addHook('afterIsMultipleSelection', function () {
|
226
|
-
for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
|
227
|
-
args[_key12] = arguments[_key12];
|
228
|
-
}
|
229
185
|
return _assertClassBrand(_MergeCells_brand, _this, _onAfterIsMultipleSelection).call(_this, ...args);
|
230
186
|
});
|
231
187
|
this.addHook('afterRenderer', function () {
|
232
|
-
for (var
|
233
|
-
args[
|
188
|
+
for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
|
189
|
+
args[_key10] = arguments[_key10];
|
234
190
|
}
|
235
191
|
return _assertClassBrand(_MergeCells_brand, _this, _onAfterRenderer).call(_this, ...args);
|
236
192
|
});
|
237
193
|
this.addHook('afterContextMenuDefaultOptions', function () {
|
238
|
-
for (var
|
239
|
-
args[
|
194
|
+
for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
|
195
|
+
args[_key11] = arguments[_key11];
|
240
196
|
}
|
241
197
|
return _assertClassBrand(_MergeCells_brand, _this, _addMergeActionsToContextMenu).call(_this, ...args);
|
242
198
|
});
|
243
199
|
this.addHook('afterGetCellMeta', function () {
|
244
|
-
for (var
|
245
|
-
args[
|
200
|
+
for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
|
201
|
+
args[_key12] = arguments[_key12];
|
246
202
|
}
|
247
203
|
return _assertClassBrand(_MergeCells_brand, _this, _onAfterGetCellMeta).call(_this, ...args);
|
248
204
|
});
|
249
205
|
this.addHook('afterViewportRowCalculatorOverride', function () {
|
250
|
-
for (var
|
251
|
-
args[
|
206
|
+
for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
|
207
|
+
args[_key13] = arguments[_key13];
|
252
208
|
}
|
253
209
|
return _assertClassBrand(_MergeCells_brand, _this, _onAfterViewportRowCalculatorOverride).call(_this, ...args);
|
254
210
|
});
|
255
211
|
this.addHook('afterViewportColumnCalculatorOverride', function () {
|
256
|
-
for (var
|
257
|
-
args[
|
212
|
+
for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {
|
213
|
+
args[_key14] = arguments[_key14];
|
258
214
|
}
|
259
215
|
return _assertClassBrand(_MergeCells_brand, _this, _onAfterViewportColumnCalculatorOverride).call(_this, ...args);
|
260
216
|
});
|
261
217
|
this.addHook('modifyAutofillRange', function () {
|
262
|
-
for (var
|
263
|
-
args[
|
218
|
+
for (var _len15 = arguments.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) {
|
219
|
+
args[_key15] = arguments[_key15];
|
264
220
|
}
|
265
221
|
return _assertClassBrand(_MergeCells_brand, _this, _onModifyAutofillRange).call(_this, ...args);
|
266
222
|
});
|
267
223
|
this.addHook('afterCreateCol', function () {
|
268
|
-
for (var
|
269
|
-
args[
|
224
|
+
for (var _len16 = arguments.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) {
|
225
|
+
args[_key16] = arguments[_key16];
|
270
226
|
}
|
271
227
|
return _assertClassBrand(_MergeCells_brand, _this, _onAfterCreateCol).call(_this, ...args);
|
272
228
|
});
|
273
229
|
this.addHook('afterRemoveCol', function () {
|
274
|
-
for (var
|
275
|
-
args[
|
230
|
+
for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) {
|
231
|
+
args[_key17] = arguments[_key17];
|
276
232
|
}
|
277
233
|
return _assertClassBrand(_MergeCells_brand, _this, _onAfterRemoveCol).call(_this, ...args);
|
278
234
|
});
|
279
235
|
this.addHook('afterCreateRow', function () {
|
280
|
-
for (var
|
281
|
-
args[
|
236
|
+
for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) {
|
237
|
+
args[_key18] = arguments[_key18];
|
282
238
|
}
|
283
239
|
return _assertClassBrand(_MergeCells_brand, _this, _onAfterCreateRow).call(_this, ...args);
|
284
240
|
});
|
285
241
|
this.addHook('afterRemoveRow', function () {
|
286
|
-
for (var
|
287
|
-
args[
|
242
|
+
for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
|
243
|
+
args[_key19] = arguments[_key19];
|
288
244
|
}
|
289
245
|
return _assertClassBrand(_MergeCells_brand, _this, _onAfterRemoveRow).call(_this, ...args);
|
290
246
|
});
|
291
247
|
this.addHook('afterChange', function () {
|
292
|
-
for (var
|
293
|
-
args[
|
248
|
+
for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
|
249
|
+
args[_key20] = arguments[_key20];
|
294
250
|
}
|
295
251
|
return _assertClassBrand(_MergeCells_brand, _this, _onAfterChange).call(_this, ...args);
|
296
252
|
});
|
297
253
|
this.addHook('beforeDrawBorders', function () {
|
298
|
-
for (var
|
299
|
-
args[
|
254
|
+
for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
|
255
|
+
args[_key21] = arguments[_key21];
|
300
256
|
}
|
301
257
|
return _assertClassBrand(_MergeCells_brand, _this, _onBeforeDrawAreaBorders).call(_this, ...args);
|
302
258
|
});
|
303
259
|
this.addHook('afterDrawSelection', function () {
|
304
|
-
for (var
|
305
|
-
args[
|
260
|
+
for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
|
261
|
+
args[_key22] = arguments[_key22];
|
306
262
|
}
|
307
263
|
return _assertClassBrand(_MergeCells_brand, _this, _onAfterDrawSelection).call(_this, ...args);
|
308
264
|
});
|
309
265
|
this.addHook('beforeRemoveCellClassNames', function () {
|
310
|
-
for (var
|
311
|
-
args[
|
266
|
+
for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
|
267
|
+
args[_key23] = arguments[_key23];
|
312
268
|
}
|
313
269
|
return _assertClassBrand(_MergeCells_brand, _this, _onBeforeRemoveCellClassNames).call(_this, ...args);
|
314
270
|
});
|
315
271
|
this.addHook('beforeBeginEditing', function () {
|
316
|
-
for (var
|
317
|
-
args[
|
272
|
+
for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
|
273
|
+
args[_key24] = arguments[_key24];
|
318
274
|
}
|
319
275
|
return _assertClassBrand(_MergeCells_brand, _this, _onBeforeBeginEditing).call(_this, ...args);
|
320
276
|
});
|
@@ -460,7 +416,9 @@ export class MergeCells extends BasePlugin {
|
|
460
416
|
if (populatedNulls.length === 0) {
|
461
417
|
return;
|
462
418
|
}
|
463
|
-
|
419
|
+
|
420
|
+
// TODO: Change the `source` argument to a more meaningful value, e.g. `${this.pluginName}.clearCells`.
|
421
|
+
this.hot.setDataAtCell(populatedNulls, undefined, undefined, this.pluginName);
|
464
422
|
}
|
465
423
|
}
|
466
424
|
|
@@ -484,6 +442,25 @@ export class MergeCells extends BasePlugin {
|
|
484
442
|
return auto ? true : this.validateSetting(newMergedCellInfo);
|
485
443
|
}
|
486
444
|
|
445
|
+
/**
|
446
|
+
* Merge or unmerge, based on last selected range.
|
447
|
+
*
|
448
|
+
* @private
|
449
|
+
*/
|
450
|
+
toggleMergeOnSelection() {
|
451
|
+
const currentRange = this.hot.getSelectedRangeLast();
|
452
|
+
if (!currentRange) {
|
453
|
+
return;
|
454
|
+
}
|
455
|
+
currentRange.setDirection(this.hot.isRtl() ? 'NE-SW' : 'NW-SE');
|
456
|
+
const {
|
457
|
+
from,
|
458
|
+
to
|
459
|
+
} = currentRange;
|
460
|
+
this.toggleMerge(currentRange);
|
461
|
+
this.hot.selectCell(from.row, from.col, to.row, to.col, false);
|
462
|
+
}
|
463
|
+
|
487
464
|
/**
|
488
465
|
* Merges the selection provided as a cell range.
|
489
466
|
*
|
@@ -572,6 +549,7 @@ export class MergeCells extends BasePlugin {
|
|
572
549
|
if (preventPopulation) {
|
573
550
|
populationInfo = [mergeParent.row, mergeParent.col, clearedData];
|
574
551
|
} else {
|
552
|
+
// TODO: Change the `source` argument to a more meaningful value, e.g. `${this.pluginName}.clearCells`.
|
575
553
|
this.hot.populateFromArray(mergeParent.row, mergeParent.col, clearedData, undefined, undefined, this.pluginName);
|
576
554
|
}
|
577
555
|
if (!auto) {
|
@@ -877,191 +855,94 @@ function _onAfterIsMultipleSelection(isMultiple) {
|
|
877
855
|
if (isMultiple) {
|
878
856
|
const mergedCells = this.mergedCellsCollection.mergedCells;
|
879
857
|
const selectionRange = this.hot.getSelectedRangeLast();
|
880
|
-
const topStartCoords = selectionRange.getTopStartCorner();
|
881
|
-
const bottomEndCoords = selectionRange.getBottomEndCorner();
|
882
858
|
for (let group = 0; group < mergedCells.length; group += 1) {
|
883
|
-
if (
|
859
|
+
if (selectionRange.from.row === mergedCells[group].row && selectionRange.from.col === mergedCells[group].col && selectionRange.to.row === mergedCells[group].row + mergedCells[group].rowspan - 1 && selectionRange.to.col === mergedCells[group].col + mergedCells[group].colspan - 1) {
|
884
860
|
return false;
|
885
861
|
}
|
886
862
|
}
|
887
863
|
}
|
888
864
|
return isMultiple;
|
889
865
|
}
|
890
|
-
/**
|
891
|
-
* `modifyTransformFocus` hook callback.
|
892
|
-
*
|
893
|
-
* @param {object} delta The transformation delta.
|
894
|
-
*/
|
895
|
-
function _onModifyTransformFocus(delta) {
|
896
|
-
_classPrivateFieldGet(_lastFocusDelta, this).row = delta.row;
|
897
|
-
_classPrivateFieldGet(_lastFocusDelta, this).col = delta.col;
|
898
|
-
}
|
899
866
|
/**
|
900
867
|
* `modifyTransformStart` hook callback.
|
901
868
|
*
|
902
869
|
* @param {object} delta The transformation delta.
|
903
870
|
*/
|
904
871
|
function _onModifyTransformStart(delta) {
|
905
|
-
const
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
if (_classPrivateFieldGet(
|
914
|
-
|
915
|
-
|
872
|
+
const currentlySelectedRange = this.hot.getSelectedRangeLast();
|
873
|
+
let newDelta = {
|
874
|
+
row: delta.row,
|
875
|
+
col: delta.col
|
876
|
+
};
|
877
|
+
let nextPosition = null;
|
878
|
+
const currentPosition = this.hot._createCellCoords(currentlySelectedRange.highlight.row, currentlySelectedRange.highlight.col);
|
879
|
+
const mergedParent = this.mergedCellsCollection.get(currentPosition.row, currentPosition.col);
|
880
|
+
if (!_classPrivateFieldGet(_lastDesiredCoords, this)) {
|
881
|
+
_classPrivateFieldSet(_lastDesiredCoords, this, this.hot._createCellCoords(null, null));
|
882
|
+
}
|
883
|
+
if (mergedParent) {
|
884
|
+
// only merge selected
|
885
|
+
const mergeTopLeft = this.hot._createCellCoords(mergedParent.row, mergedParent.col);
|
886
|
+
const mergeBottomRight = this.hot._createCellCoords(mergedParent.row + mergedParent.rowspan - 1, mergedParent.col + mergedParent.colspan - 1);
|
887
|
+
const mergeRange = this.hot._createCellRange(mergeTopLeft, mergeTopLeft, mergeBottomRight);
|
888
|
+
if (!mergeRange.includes(_classPrivateFieldGet(_lastDesiredCoords, this))) {
|
889
|
+
_classPrivateFieldSet(_lastDesiredCoords, this, this.hot._createCellCoords(null, null)); // reset outdated version of lastDesiredCoords
|
916
890
|
}
|
917
|
-
|
918
|
-
|
891
|
+
newDelta.row = _classPrivateFieldGet(_lastDesiredCoords, this).row ? _classPrivateFieldGet(_lastDesiredCoords, this).row - currentPosition.row : newDelta.row;
|
892
|
+
newDelta.col = _classPrivateFieldGet(_lastDesiredCoords, this).col ? _classPrivateFieldGet(_lastDesiredCoords, this).col - currentPosition.col : newDelta.col;
|
893
|
+
if (delta.row > 0) {
|
894
|
+
// moving down
|
895
|
+
newDelta.row = mergedParent.row + mergedParent.rowspan - 1 - currentPosition.row + delta.row;
|
896
|
+
} else if (delta.row < 0) {
|
897
|
+
// moving up
|
898
|
+
newDelta.row = currentPosition.row - mergedParent.row + delta.row;
|
899
|
+
}
|
900
|
+
if (delta.col > 0) {
|
901
|
+
// moving right
|
902
|
+
newDelta.col = mergedParent.col + mergedParent.colspan - 1 - currentPosition.col + delta.col;
|
903
|
+
} else if (delta.col < 0) {
|
904
|
+
// moving left
|
905
|
+
newDelta.col = currentPosition.col - mergedParent.col + delta.col;
|
919
906
|
}
|
920
|
-
_classPrivateFieldSet(_lastSelectedFocus, this, null);
|
921
907
|
}
|
922
|
-
|
923
|
-
|
924
|
-
|
908
|
+
nextPosition = this.hot._createCellCoords(currentlySelectedRange.highlight.row + newDelta.row, currentlySelectedRange.highlight.col + newDelta.col);
|
909
|
+
const nextPositionMergedCell = this.mergedCellsCollection.get(nextPosition.row, nextPosition.col);
|
910
|
+
if (nextPositionMergedCell) {
|
911
|
+
// skipping the invisible cells in the merge range
|
912
|
+
const firstRenderableCoords = this.mergedCellsCollection.getFirstRenderableCoords(nextPositionMergedCell.row, nextPositionMergedCell.col);
|
913
|
+
_classPrivateFieldSet(_lastDesiredCoords, this, nextPosition);
|
914
|
+
newDelta = {
|
915
|
+
row: firstRenderableCoords.row - currentPosition.row,
|
916
|
+
col: firstRenderableCoords.col - currentPosition.col
|
917
|
+
};
|
925
918
|
}
|
926
|
-
|
927
|
-
|
928
|
-
if (delta.col < 0) {
|
929
|
-
const nextColumn = highlight.col >= visualColumnIndexStart && highlight.col <= visualColumnIndexEnd ? visualColumnIndexStart - 1 : visualColumnIndexEnd;
|
930
|
-
const notHiddenColumnIndex = columnIndexMapper.getNearestNotHiddenIndex(nextColumn, -1);
|
931
|
-
if (notHiddenColumnIndex === null) {
|
932
|
-
// There are no visible columns anymore, so move the selection out of the table edge. This will
|
933
|
-
// be processed by the selection Transformer class as a move selection to the previous row (if autoWrapRow is enabled).
|
934
|
-
delta.col = -this.hot.view.countRenderableColumnsInRange(0, highlight.col);
|
935
|
-
} else {
|
936
|
-
delta.col = -Math.max(this.hot.view.countRenderableColumnsInRange(notHiddenColumnIndex, highlight.col) - 1, 1);
|
937
|
-
}
|
938
|
-
} else if (delta.col > 0) {
|
939
|
-
const nextColumn = highlight.col >= visualColumnIndexStart && highlight.col <= visualColumnIndexEnd ? visualColumnIndexEnd + 1 : visualColumnIndexStart;
|
940
|
-
const notHiddenColumnIndex = columnIndexMapper.getNearestNotHiddenIndex(nextColumn, 1);
|
941
|
-
if (notHiddenColumnIndex === null) {
|
942
|
-
// There are no visible columns anymore, so move the selection out of the table edge. This will
|
943
|
-
// be processed by the selection Transformer class as a move selection to the next row (if autoWrapRow is enabled).
|
944
|
-
delta.col = this.hot.view.countRenderableColumnsInRange(highlight.col, this.hot.countCols());
|
945
|
-
} else {
|
946
|
-
delta.col = Math.max(this.hot.view.countRenderableColumnsInRange(highlight.col, notHiddenColumnIndex) - 1, 1);
|
947
|
-
}
|
919
|
+
if (newDelta.row !== 0) {
|
920
|
+
delta.row = newDelta.row;
|
948
921
|
}
|
949
|
-
|
950
|
-
|
951
|
-
if (delta.row < 0) {
|
952
|
-
const nextRow = highlight.row >= visualRowIndexStart && highlight.row <= visualRowIndexEnd ? visualRowIndexStart - 1 : visualRowIndexEnd;
|
953
|
-
const notHiddenRowIndex = rowIndexMapper.getNearestNotHiddenIndex(nextRow, -1);
|
954
|
-
if (notHiddenRowIndex === null) {
|
955
|
-
// There are no visible rows anymore, so move the selection out of the table edge. This will
|
956
|
-
// be processed by the selection Transformer class as a move selection to the previous column (if autoWrapCol is enabled).
|
957
|
-
delta.row = -this.hot.view.countRenderableRowsInRange(0, highlight.row);
|
958
|
-
} else {
|
959
|
-
delta.row = -Math.max(this.hot.view.countRenderableRowsInRange(notHiddenRowIndex, highlight.row) - 1, 1);
|
960
|
-
}
|
961
|
-
} else if (delta.row > 0) {
|
962
|
-
const nextRow = highlight.row >= visualRowIndexStart && highlight.row <= visualRowIndexEnd ? visualRowIndexEnd + 1 : visualRowIndexStart;
|
963
|
-
const notHiddenRowIndex = rowIndexMapper.getNearestNotHiddenIndex(nextRow, 1);
|
964
|
-
if (notHiddenRowIndex === null) {
|
965
|
-
// There are no visible rows anymore, so move the selection out of the table edge. This will
|
966
|
-
// be processed by the selection Transformer class as a move selection to the next column (if autoWrapCol is enabled).
|
967
|
-
delta.row = this.hot.view.countRenderableRowsInRange(highlight.row, this.hot.countRows());
|
968
|
-
} else {
|
969
|
-
delta.row = Math.max(this.hot.view.countRenderableRowsInRange(highlight.row, notHiddenRowIndex) - 1, 1);
|
970
|
-
}
|
922
|
+
if (newDelta.col !== 0) {
|
923
|
+
delta.col = newDelta.col;
|
971
924
|
}
|
972
925
|
}
|
973
926
|
/**
|
974
|
-
*
|
975
|
-
* The logic here handles "jumping over" merged merged cells, while selecting.
|
927
|
+
* `modifyTransformEnd` hook callback. Needed to handle "jumping over" merged merged cells, while selecting.
|
976
928
|
*
|
977
|
-
* @param {
|
929
|
+
* @param {object} delta The transformation delta.
|
978
930
|
*/
|
979
931
|
function _onModifyTransformEnd(delta) {
|
980
|
-
const
|
981
|
-
const
|
982
|
-
const
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
};
|
995
|
-
if (delta.col < 0) {
|
996
|
-
let nextColumn = this.mergedCellsCollection.getStartMostColumnIndex(selectedRange, to.col) + delta.col;
|
997
|
-
expandCloneRange(to.row, nextColumn);
|
998
|
-
if (selectedRange.getHorizontalDirection() === 'E-W' && cloneRange.getHorizontalDirection() === 'E-W') {
|
999
|
-
nextColumn = cloneRange.getTopStartCorner().col;
|
1000
|
-
}
|
1001
|
-
const notHiddenColumnIndex = columnIndexMapper.getNearestNotHiddenIndex(nextColumn, 1);
|
1002
|
-
if (notHiddenColumnIndex !== null) {
|
1003
|
-
delta.col = -Math.max(this.hot.view.countRenderableColumnsInRange(notHiddenColumnIndex, to.col) - 1, 1);
|
1004
|
-
}
|
1005
|
-
} else if (delta.col > 0) {
|
1006
|
-
let nextColumn = this.mergedCellsCollection.getEndMostColumnIndex(selectedRange, to.col) + delta.col;
|
1007
|
-
expandCloneRange(to.row, nextColumn);
|
1008
|
-
if (selectedRange.getHorizontalDirection() === 'W-E' && cloneRange.getHorizontalDirection() === 'W-E') {
|
1009
|
-
nextColumn = cloneRange.getBottomEndCorner().col;
|
1010
|
-
}
|
1011
|
-
const notHiddenColumnIndex = columnIndexMapper.getNearestNotHiddenIndex(nextColumn, -1);
|
1012
|
-
if (notHiddenColumnIndex !== null) {
|
1013
|
-
delta.col = Math.max(this.hot.view.countRenderableColumnsInRange(to.col, notHiddenColumnIndex) - 1, 1);
|
1014
|
-
}
|
1015
|
-
}
|
1016
|
-
if (delta.row < 0) {
|
1017
|
-
let nextRow = this.mergedCellsCollection.getTopMostRowIndex(selectedRange, to.row) + delta.row;
|
1018
|
-
expandCloneRange(nextRow, to.col);
|
1019
|
-
if (selectedRange.getVerticalDirection() === 'S-N' && cloneRange.getVerticalDirection() === 'S-N') {
|
1020
|
-
nextRow = cloneRange.getTopStartCorner().row;
|
1021
|
-
}
|
1022
|
-
const notHiddenRowIndex = rowIndexMapper.getNearestNotHiddenIndex(nextRow, 1);
|
1023
|
-
if (notHiddenRowIndex !== null) {
|
1024
|
-
delta.row = -Math.max(this.hot.view.countRenderableRowsInRange(notHiddenRowIndex, to.row) - 1, 1);
|
1025
|
-
}
|
1026
|
-
} else if (delta.row > 0) {
|
1027
|
-
let nextRow = this.mergedCellsCollection.getBottomMostRowIndex(selectedRange, to.row) + delta.row;
|
1028
|
-
expandCloneRange(nextRow, to.col);
|
1029
|
-
if (selectedRange.getVerticalDirection() === 'N-S' && cloneRange.getVerticalDirection() === 'N-S') {
|
1030
|
-
nextRow = cloneRange.getBottomStartCorner().row;
|
1031
|
-
}
|
1032
|
-
const notHiddenRowIndex = rowIndexMapper.getNearestNotHiddenIndex(nextRow, -1);
|
1033
|
-
if (notHiddenRowIndex !== null) {
|
1034
|
-
delta.row = Math.max(this.hot.view.countRenderableRowsInRange(to.row, notHiddenRowIndex) - 1, 1);
|
1035
|
-
}
|
1036
|
-
}
|
1037
|
-
}
|
1038
|
-
/**
|
1039
|
-
* The hook corrects the range (before drawing it) after the selection was made on the merged cells.
|
1040
|
-
* It expands the range to cover the entire area of the selected merged cells.
|
1041
|
-
*/
|
1042
|
-
function _onBeforeSelectionHighlightSet() {
|
1043
|
-
const selectedRange = this.hot.getSelectedRangeLast();
|
1044
|
-
const {
|
1045
|
-
highlight
|
1046
|
-
} = selectedRange;
|
1047
|
-
if (this.hot.selection.isSelectedByColumnHeader() || this.hot.selection.isSelectedByRowHeader()) {
|
1048
|
-
_classPrivateFieldSet(_lastSelectedFocus, this, highlight.clone());
|
1049
|
-
return;
|
1050
|
-
}
|
1051
|
-
for (let i = 0; i < this.mergedCellsCollection.mergedCells.length; i += 1) {
|
1052
|
-
selectedRange.expandByRange(this.mergedCellsCollection.mergedCells[i].getRange(), false);
|
1053
|
-
}
|
1054
|
-
// TODO: This is a workaround for an issue with the selection not being extended properly.
|
1055
|
-
// In some cases when the merge cells are defined in random order the selection is not
|
1056
|
-
// extended in that way that it covers all overlapped merge cells.
|
1057
|
-
for (let i = 0; i < this.mergedCellsCollection.mergedCells.length; i += 1) {
|
1058
|
-
selectedRange.expandByRange(this.mergedCellsCollection.mergedCells[i].getRange(), false);
|
1059
|
-
}
|
1060
|
-
const mergedParent = this.mergedCellsCollection.get(highlight.row, highlight.col);
|
1061
|
-
_classPrivateFieldSet(_lastSelectedFocus, this, highlight.clone());
|
1062
|
-
if (mergedParent) {
|
1063
|
-
highlight.assign(mergedParent);
|
1064
|
-
}
|
932
|
+
const currentSelectionRange = this.hot.getSelectedRangeLast();
|
933
|
+
const newDelta = clone(delta);
|
934
|
+
const newSelectionRange = this.selectionCalculations.getUpdatedSelectionRange(currentSelectionRange, delta);
|
935
|
+
let tempDelta = clone(newDelta);
|
936
|
+
const mergedCellsWithinRange = this.mergedCellsCollection.getWithinRange(newSelectionRange, true);
|
937
|
+
do {
|
938
|
+
tempDelta = clone(newDelta);
|
939
|
+
this.selectionCalculations.getUpdatedSelectionRange(currentSelectionRange, newDelta);
|
940
|
+
arrayEach(mergedCellsWithinRange, mergedCell => {
|
941
|
+
this.selectionCalculations.snapDelta(newDelta, currentSelectionRange, mergedCell);
|
942
|
+
});
|
943
|
+
} while (newDelta.row !== tempDelta.row || newDelta.col !== tempDelta.col);
|
944
|
+
delta.row = newDelta.row;
|
945
|
+
delta.col = newDelta.col;
|
1065
946
|
}
|
1066
947
|
/**
|
1067
948
|
* `modifyGetCellCoords` hook callback. Swaps the `getCell` coords with the merged parent coords.
|
@@ -1140,104 +1021,51 @@ function _onAfterRenderer(TD, row, col) {
|
|
1140
1021
|
applySpanProperties(TD, mergedCellCopy, row, col);
|
1141
1022
|
}
|
1142
1023
|
/**
|
1143
|
-
*
|
1144
|
-
|
1145
|
-
function _onBeforeSetRangeStart() {
|
1146
|
-
_classPrivateFieldSet(_lastSelectedFocus, this, null);
|
1147
|
-
}
|
1148
|
-
/**
|
1149
|
-
* Detects if the last selected cell was a header cell if so update the order list active node for further
|
1150
|
-
* computations.
|
1151
|
-
*/
|
1152
|
-
function _onBeforeSelectionFocusSet() {
|
1153
|
-
if (_classPrivateFieldGet(_lastSelectedFocus, this).isCell()) {
|
1154
|
-
return;
|
1155
|
-
}
|
1156
|
-
const selectedRange = this.hot.getSelectedRangeLast();
|
1157
|
-
const verticalDir = selectedRange.getVerticalDirection();
|
1158
|
-
const horizontalDir = selectedRange.getHorizontalDirection();
|
1159
|
-
const focusCoords = _classPrivateFieldGet(_lastSelectedFocus, this).clone().normalize();
|
1160
|
-
_classPrivateFieldGet(_focusOrder, this).setActiveNode(focusCoords.row, focusCoords.col);
|
1161
|
-
if (_classPrivateFieldGet(_lastFocusDelta, this).row > 0 || _classPrivateFieldGet(_lastFocusDelta, this).col > 0) {
|
1162
|
-
_classPrivateFieldGet(_focusOrder, this).setPrevNodeAsActive();
|
1163
|
-
} else if (horizontalDir === 'E-W' && _classPrivateFieldGet(_lastFocusDelta, this).col < 0 || verticalDir === 'S-N' && _classPrivateFieldGet(_lastFocusDelta, this).row < 0) {
|
1164
|
-
_classPrivateFieldGet(_focusOrder, this).setNextNodeAsActive();
|
1165
|
-
}
|
1166
|
-
}
|
1167
|
-
/**
|
1168
|
-
* Changes the focus selection to the next or previous cell or merged cell position.
|
1024
|
+
* `beforeSetRangeStart` and `beforeSetRangeStartOnly` hook callback.
|
1025
|
+
* A selection within merge area should be rewritten to the start of merge area.
|
1169
1026
|
*
|
1170
|
-
* @param {
|
1171
|
-
* @param {number} column The visual column index.
|
1027
|
+
* @param {object} coords Cell coords.
|
1172
1028
|
*/
|
1173
|
-
function
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
let notHiddenColumnIndex = null;
|
1181
|
-
if (_classPrivateFieldGet(_lastFocusDelta, this).col < 0) {
|
1182
|
-
const {
|
1183
|
-
rowEnd,
|
1184
|
-
colEnd
|
1185
|
-
} = _classPrivateFieldGet(_focusOrder, this).getPrevHorizontalNode();
|
1186
|
-
notHiddenColumnIndex = columnIndexMapper.getNearestNotHiddenIndex(colEnd, -1);
|
1187
|
-
notHiddenRowIndex = rowIndexMapper.getNearestNotHiddenIndex(rowEnd, -1);
|
1188
|
-
} else if (_classPrivateFieldGet(_lastFocusDelta, this).col > 0) {
|
1189
|
-
const {
|
1190
|
-
rowStart,
|
1191
|
-
colStart
|
1192
|
-
} = _classPrivateFieldGet(_focusOrder, this).getNextHorizontalNode();
|
1193
|
-
notHiddenColumnIndex = columnIndexMapper.getNearestNotHiddenIndex(colStart, 1);
|
1194
|
-
notHiddenRowIndex = rowIndexMapper.getNearestNotHiddenIndex(rowStart, 1);
|
1195
|
-
} else if (_classPrivateFieldGet(_lastFocusDelta, this).row < 0) {
|
1196
|
-
const {
|
1197
|
-
rowEnd,
|
1198
|
-
colEnd
|
1199
|
-
} = _classPrivateFieldGet(_focusOrder, this).getPrevVerticalNode();
|
1200
|
-
notHiddenColumnIndex = columnIndexMapper.getNearestNotHiddenIndex(colEnd, -1);
|
1201
|
-
notHiddenRowIndex = rowIndexMapper.getNearestNotHiddenIndex(rowEnd, -1);
|
1202
|
-
} else if (_classPrivateFieldGet(_lastFocusDelta, this).row > 0) {
|
1203
|
-
const {
|
1204
|
-
rowStart,
|
1205
|
-
colStart
|
1206
|
-
} = _classPrivateFieldGet(_focusOrder, this).getNextVerticalNode();
|
1207
|
-
notHiddenColumnIndex = columnIndexMapper.getNearestNotHiddenIndex(colStart, 1);
|
1208
|
-
notHiddenRowIndex = rowIndexMapper.getNearestNotHiddenIndex(rowStart, 1);
|
1209
|
-
}
|
1210
|
-
if (notHiddenRowIndex !== null || notHiddenColumnIndex !== null) {
|
1211
|
-
const coords = this.hot._createCellCoords(notHiddenRowIndex, notHiddenColumnIndex);
|
1029
|
+
function _onBeforeSetRangeStart(coords) {
|
1030
|
+
// TODO: It is a workaround, but probably this hook may be needed. Every selection on the merge area
|
1031
|
+
// could set start point of the selection to the start of the merge area. However, logic inside `expandByRange` need
|
1032
|
+
// an initial start point. Click on the merge cell when there are some hidden indexes break the logic in some cases.
|
1033
|
+
// Please take a look at #7010 for more information. I'm not sure if selection directions are calculated properly
|
1034
|
+
// and what was idea for flipping direction inside `expandByRange` method.
|
1035
|
+
if (this.mergedCellsCollection.isFirstRenderableMergedCell(coords.row, coords.col)) {
|
1212
1036
|
const mergeParent = this.mergedCellsCollection.get(coords.row, coords.col);
|
1213
|
-
|
1214
|
-
row = coords.row;
|
1215
|
-
column = coords.col;
|
1216
|
-
if (mergeParent) {
|
1217
|
-
selectedRange.highlight.assign({
|
1218
|
-
row: this.hot.rowIndexMapper.getNearestNotHiddenIndex(mergeParent.row, 1),
|
1219
|
-
col: this.hot.columnIndexMapper.getNearestNotHiddenIndex(mergeParent.col, 1)
|
1220
|
-
});
|
1221
|
-
} else {
|
1222
|
-
selectedRange.highlight.assign(coords);
|
1223
|
-
}
|
1224
|
-
focusHighlight.clear();
|
1225
|
-
focusHighlight.add(coords).commit();
|
1037
|
+
[coords.row, coords.col] = [mergeParent.row, mergeParent.col];
|
1226
1038
|
}
|
1227
|
-
_classPrivateFieldGet(_focusOrder, this).setActiveNode(row, column);
|
1228
|
-
_classPrivateFieldSet(_lastFocusDelta, this, {
|
1229
|
-
row: 0,
|
1230
|
-
col: 0
|
1231
|
-
});
|
1232
1039
|
}
|
1233
1040
|
/**
|
1234
|
-
*
|
1041
|
+
* `beforeSetRangeEnd` hook callback.
|
1042
|
+
* While selecting cells with keyboard or mouse, make sure that rectangular area is expanded to the extent of the
|
1043
|
+
* merged cell.
|
1044
|
+
*
|
1045
|
+
* Note: Please keep in mind that callback may modify both start and end range coordinates by the reference.
|
1046
|
+
*
|
1047
|
+
* @param {object} coords Cell coords.
|
1235
1048
|
*/
|
1236
|
-
function
|
1237
|
-
const
|
1238
|
-
|
1239
|
-
|
1049
|
+
function _onBeforeSetRangeEnd(coords) {
|
1050
|
+
const selRange = this.hot.getSelectedRangeLast();
|
1051
|
+
selRange.highlight = this.hot._createCellCoords(selRange.highlight.row, selRange.highlight.col); // clone in case we will modify its reference
|
1052
|
+
selRange.to = coords;
|
1053
|
+
let rangeExpanded = false;
|
1054
|
+
if (this.hot.selection.isSelectedByColumnHeader() || this.hot.selection.isSelectedByRowHeader()) {
|
1055
|
+
return;
|
1240
1056
|
}
|
1057
|
+
do {
|
1058
|
+
rangeExpanded = false;
|
1059
|
+
for (let i = 0; i < this.mergedCellsCollection.mergedCells.length; i += 1) {
|
1060
|
+
const cellInfo = this.mergedCellsCollection.mergedCells[i];
|
1061
|
+
const mergedCellRange = cellInfo.getRange();
|
1062
|
+
if (selRange.expandByRange(mergedCellRange)) {
|
1063
|
+
coords.row = selRange.to.row;
|
1064
|
+
coords.col = selRange.to.col;
|
1065
|
+
rangeExpanded = true;
|
1066
|
+
}
|
1067
|
+
}
|
1068
|
+
} while (rangeExpanded);
|
1241
1069
|
}
|
1242
1070
|
/**
|
1243
1071
|
* The `afterGetCellMeta` hook callback.
|
@@ -1366,6 +1194,37 @@ function _onBeforeDrawAreaBorders(corners, className) {
|
|
1366
1194
|
});
|
1367
1195
|
}
|
1368
1196
|
}
|
1197
|
+
/**
|
1198
|
+
* `afterModifyTransformStart` hook callback. Fixes a problem with navigating through merged cells at the edges of
|
1199
|
+
* the table with the <kbd>**Enter**</kbd>/<kbd>**Shift**</kbd>+<kbd>**Enter**</kbd>/<kbd>**Tab**</kbd>/<kbd>**Shift**</kbd>+<kbd>**Tab**</kbd> keys.
|
1200
|
+
*
|
1201
|
+
* @param {CellCoords} coords Coordinates of the to-be-selected cell.
|
1202
|
+
* @param {number} rowTransformDir Row transformation direction (negative value = up, 0 = none, positive value =
|
1203
|
+
* down).
|
1204
|
+
* @param {number} colTransformDir Column transformation direction (negative value = up, 0 = none, positive value =
|
1205
|
+
* down).
|
1206
|
+
*/
|
1207
|
+
function _onAfterModifyTransformStart(coords, rowTransformDir, colTransformDir) {
|
1208
|
+
if (!this.enabled) {
|
1209
|
+
return;
|
1210
|
+
}
|
1211
|
+
const mergedCellAtCoords = this.mergedCellsCollection.get(coords.row, coords.col);
|
1212
|
+
if (!mergedCellAtCoords) {
|
1213
|
+
return;
|
1214
|
+
}
|
1215
|
+
const goingDown = rowTransformDir > 0;
|
1216
|
+
const goingUp = rowTransformDir < 0;
|
1217
|
+
const goingLeft = colTransformDir < 0;
|
1218
|
+
const goingRight = colTransformDir > 0;
|
1219
|
+
const mergedCellOnBottomEdge = mergedCellAtCoords.row + mergedCellAtCoords.rowspan - 1 === this.hot.countRows() - 1;
|
1220
|
+
const mergedCellOnTopEdge = mergedCellAtCoords.row === 0;
|
1221
|
+
const mergedCellOnRightEdge = mergedCellAtCoords.col + mergedCellAtCoords.colspan - 1 === this.hot.countCols() - 1;
|
1222
|
+
const mergedCellOnLeftEdge = mergedCellAtCoords.col === 0;
|
1223
|
+
if (goingDown && mergedCellOnBottomEdge || goingUp && mergedCellOnTopEdge || goingRight && mergedCellOnRightEdge || goingLeft && mergedCellOnLeftEdge) {
|
1224
|
+
coords.row = mergedCellAtCoords.row;
|
1225
|
+
coords.col = mergedCellAtCoords.col;
|
1226
|
+
}
|
1227
|
+
}
|
1369
1228
|
/**
|
1370
1229
|
* `afterDrawSelection` hook callback. Used to add the additional class name for the entirely-selected merged cells.
|
1371
1230
|
*
|