handsontable 0.0.0-next-69c01d0-20240613 → 0.0.0-next-f0353d0-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.

Files changed (47) hide show
  1. package/3rdparty/walkontable/src/core/core.js +16 -0
  2. package/3rdparty/walkontable/src/core/core.mjs +16 -0
  3. package/3rdparty/walkontable/src/facade/core.js +3 -0
  4. package/3rdparty/walkontable/src/facade/core.mjs +3 -0
  5. package/3rdparty/walkontable/src/renderer/index.js +11 -0
  6. package/3rdparty/walkontable/src/renderer/index.mjs +11 -0
  7. package/3rdparty/walkontable/src/renderer/table.js +16 -1
  8. package/3rdparty/walkontable/src/renderer/table.mjs +16 -1
  9. package/3rdparty/walkontable/src/settings.js +5 -1
  10. package/3rdparty/walkontable/src/settings.mjs +5 -1
  11. package/3rdparty/walkontable/src/table.js +1 -1
  12. package/3rdparty/walkontable/src/table.mjs +1 -1
  13. package/3rdparty/walkontable/src/utils/row.js +16 -0
  14. package/3rdparty/walkontable/src/utils/row.mjs +16 -0
  15. package/base.js +2 -2
  16. package/base.mjs +2 -2
  17. package/common.d.ts +3 -0
  18. package/core.js +0 -6
  19. package/core.mjs +0 -6
  20. package/dist/handsontable.css +2 -2
  21. package/dist/handsontable.full.css +2 -2
  22. package/dist/handsontable.full.js +504 -249
  23. package/dist/handsontable.full.min.css +2 -2
  24. package/dist/handsontable.full.min.js +80 -80
  25. package/dist/handsontable.js +504 -249
  26. package/dist/handsontable.min.css +2 -2
  27. package/dist/handsontable.min.js +14 -14
  28. package/helpers/mixed.js +1 -1
  29. package/helpers/mixed.mjs +1 -1
  30. package/package.json +1 -1
  31. package/pluginHooks.d.ts +3 -1
  32. package/pluginHooks.js +11 -0
  33. package/pluginHooks.mjs +11 -0
  34. package/plugins/mergeCells/calculations/autofill.js +1 -1
  35. package/plugins/mergeCells/calculations/autofill.mjs +1 -1
  36. package/plugins/mergeCells/cellCoords.js +61 -22
  37. package/plugins/mergeCells/cellCoords.mjs +61 -22
  38. package/plugins/mergeCells/cellsCollection.js +46 -53
  39. package/plugins/mergeCells/cellsCollection.mjs +46 -53
  40. package/plugins/mergeCells/mergeCells.js +133 -92
  41. package/plugins/mergeCells/mergeCells.mjs +134 -93
  42. package/plugins/mergeCells/renderer.js +70 -0
  43. package/plugins/mergeCells/renderer.mjs +66 -0
  44. package/tableView.js +92 -22
  45. package/tableView.mjs +92 -22
  46. package/plugins/mergeCells/utils.js +0 -28
  47. package/plugins/mergeCells/utils.mjs +0 -24
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-69c01d0-20240613";
137
+ const hotVersion = "0.0.0-next-f0353d0-20240614";
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-69c01d0-20240613";
127
+ const hotVersion = "0.0.0-next-f0353d0-20240614";
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-69c01d0-20240613",
13
+ "version": "0.0.0-next-f0353d0-20240614",
14
14
  "main": "index",
15
15
  "module": "index.mjs",
16
16
  "jsnext:main": "index.mjs",
package/pluginHooks.d.ts CHANGED
@@ -35,6 +35,7 @@ import {
35
35
  CellChange,
36
36
  ChangeSource,
37
37
  RangeType,
38
+ OverlayType,
38
39
  } from './common';
39
40
 
40
41
  type Bucket = {
@@ -250,7 +251,8 @@ export interface Events {
250
251
  modifyRowData?: (row: number) => void;
251
252
  modifyRowHeader?: (row: number) => void;
252
253
  modifyRowHeaderWidth?: (rowHeaderWidth: number) => void;
253
- modifyRowHeight?: (height: number, row: number) => void;
254
+ modifyRowHeight?: (height: number, row: number) => void | number;
255
+ modifyRowHeightByOverlayName?: (height: number, row: number, overlayType: OverlayType) => void | number;
254
256
  modifySourceData?: (row: number, column: number, valueHolder: { value: CellValue }, ioMode: 'get' | 'set') => void;
255
257
  modifyTransformEnd?: (delta: CellCoords) => void;
256
258
  modifyTransformFocus?: (delta: CellCoords) => void;
package/pluginHooks.js CHANGED
@@ -1420,6 +1420,17 @@ const REGISTERED_HOOKS = [/* eslint-disable jsdoc/require-description-complete-s
1420
1420
  * @param {number} row Visual row index.
1421
1421
  */
1422
1422
  'modifyRowHeight',
1423
+ /**
1424
+ * Fired when a row height is about to be modified by a callback function. The hook allows to change the row height
1425
+ * for the specified overlay type.
1426
+ *
1427
+ * @since 14.5.0
1428
+ * @event Hooks#modifyRowHeightByOverlayName
1429
+ * @param {number} height Row height.
1430
+ * @param {number} row Visual row index.
1431
+ * @param {'inline_start'|'top'|'top_inline_start_corner'|'bottom'|'bottom_inline_start_corner'|'master'} overlayName Overlay name.
1432
+ */
1433
+ 'modifyRowHeightByOverlayName',
1423
1434
  /**
1424
1435
  * Fired when a data was retrieved or modified.
1425
1436
  *
package/pluginHooks.mjs CHANGED
@@ -1416,6 +1416,17 @@ const REGISTERED_HOOKS = [/* eslint-disable jsdoc/require-description-complete-s
1416
1416
  * @param {number} row Visual row index.
1417
1417
  */
1418
1418
  'modifyRowHeight',
1419
+ /**
1420
+ * Fired when a row height is about to be modified by a callback function. The hook allows to change the row height
1421
+ * for the specified overlay type.
1422
+ *
1423
+ * @since 14.5.0
1424
+ * @event Hooks#modifyRowHeightByOverlayName
1425
+ * @param {number} height Row height.
1426
+ * @param {number} row Visual row index.
1427
+ * @param {'inline_start'|'top'|'top_inline_start_corner'|'bottom'|'bottom_inline_start_corner'|'master'} overlayName Overlay name.
1428
+ */
1429
+ 'modifyRowHeightByOverlayName',
1419
1430
  /**
1420
1431
  * Fired when a data was retrieved or modified.
1421
1432
  *
@@ -392,7 +392,7 @@ class AutofillCalculations {
392
392
  const topLeft = this.plugin.hot._createCellCoords(dragAreaStartRow, dragAreaStartColumn);
393
393
  const bottomRight = this.plugin.hot._createCellCoords(dragAreaEndRow, dragAreaEndColumn);
394
394
  const dragRange = this.plugin.hot._createCellRange(topLeft, topLeft, bottomRight);
395
- return !!this.mergedCellsCollection.getWithinRange(dragRange, true);
395
+ return this.mergedCellsCollection.getWithinRange(dragRange, true).length > 0;
396
396
  }
397
397
  }
398
398
  var _default = exports.default = AutofillCalculations;
@@ -389,7 +389,7 @@ class AutofillCalculations {
389
389
  const topLeft = this.plugin.hot._createCellCoords(dragAreaStartRow, dragAreaStartColumn);
390
390
  const bottomRight = this.plugin.hot._createCellCoords(dragAreaEndRow, dragAreaEndColumn);
391
391
  const dragRange = this.plugin.hot._createCellRange(topLeft, topLeft, bottomRight);
392
- return !!this.mergedCellsCollection.getWithinRange(dragRange, true);
392
+ return this.mergedCellsCollection.getWithinRange(dragRange, true).length > 0;
393
393
  }
394
394
  }
395
395
  export default AutofillCalculations;
@@ -79,78 +79,117 @@ class MergedCellCoords {
79
79
  /**
80
80
  * Get a warning message for when the declared merged cell data contains negative values.
81
81
  *
82
- * @param {object} newMergedCell Object containg information about the merged cells that was about to be added.
82
+ * @param {{ row: number, col: number, rowspan: number, colspan: number }} mergedCell Object containing information
83
+ * about the merged cells that was about to be added.
83
84
  * @returns {string}
84
85
  */
85
- static NEGATIVE_VALUES_WARNING(newMergedCell) {
86
- return (0, _templateLiteralTag.toSingleLine)`The merged cell declared with {row: ${newMergedCell.row}, col: ${newMergedCell.col},\x20
87
- rowspan: ${newMergedCell.rowspan}, colspan: ${newMergedCell.colspan}} contains negative values, which is\x20
86
+ static NEGATIVE_VALUES_WARNING(_ref) {
87
+ let {
88
+ row,
89
+ col,
90
+ rowspan,
91
+ colspan
92
+ } = _ref;
93
+ return (0, _templateLiteralTag.toSingleLine)`The merged cell declared with {row: ${row}, col: ${col},\x20
94
+ rowspan: ${rowspan}, colspan: ${colspan}} contains negative values, which is\x20
88
95
  not supported. It will not be added to the collection.`;
89
96
  }
90
97
 
91
98
  /**
92
99
  * Get a warning message for when the declared merged cell data contains values exceeding the table limits.
93
100
  *
94
- * @param {object} newMergedCell Object containg information about the merged cells that was about to be added.
101
+ * @param {{ row: number, col: number, rowspan: number, colspan: number }} mergedCell Object containing information
102
+ * about the merged cells that was about to be added.
95
103
  * @returns {string}
96
104
  */
97
- static IS_OUT_OF_BOUNDS_WARNING(newMergedCell) {
98
- return (0, _templateLiteralTag.toSingleLine)`The merged cell declared at [${newMergedCell.row}, ${newMergedCell.col}] is positioned\x20
105
+ static IS_OUT_OF_BOUNDS_WARNING(_ref2) {
106
+ let {
107
+ row,
108
+ col
109
+ } = _ref2;
110
+ return (0, _templateLiteralTag.toSingleLine)`The merged cell declared at [${row}, ${col}] is positioned\x20
99
111
  (or positioned partially) outside of the table range. It was not added to the table, please fix your setup.`;
100
112
  }
101
113
 
102
114
  /**
103
115
  * Get a warning message for when the declared merged cell data represents a single cell.
104
116
  *
105
- * @param {object} newMergedCell Object containg information about the merged cells that was about to be added.
117
+ * @param {{ row: number, col: number, rowspan: number, colspan: number }} mergedCell Object containing information
118
+ * about the merged cells that was about to be added.
106
119
  * @returns {string}
107
120
  */
108
- static IS_SINGLE_CELL(newMergedCell) {
109
- return (0, _templateLiteralTag.toSingleLine)`The merged cell declared at [${newMergedCell.row}, ${newMergedCell.col}] has both "rowspan"\x20
121
+ static IS_SINGLE_CELL(_ref3) {
122
+ let {
123
+ row,
124
+ col
125
+ } = _ref3;
126
+ return (0, _templateLiteralTag.toSingleLine)`The merged cell declared at [${row}, ${col}] has both "rowspan"\x20
110
127
  and "colspan" declared as "1", which makes it a single cell. It cannot be added to the collection.`;
111
128
  }
112
129
 
113
130
  /**
114
131
  * Get a warning message for when the declared merged cell data contains "colspan" or "rowspan", that equals 0.
115
132
  *
116
- * @param {object} newMergedCell Object containg information about the merged cells that was about to be added.
133
+ * @param {{ row: number, col: number, rowspan: number, colspan: number }} mergedCell Object containing information
134
+ * about the merged cells that was about to be added.
117
135
  * @returns {string}
118
136
  */
119
- static ZERO_SPAN_WARNING(newMergedCell) {
120
- return (0, _templateLiteralTag.toSingleLine)`The merged cell declared at [${newMergedCell.row}, ${newMergedCell.col}] has "rowspan"\x20
137
+ static ZERO_SPAN_WARNING(_ref4) {
138
+ let {
139
+ row,
140
+ col
141
+ } = _ref4;
142
+ return (0, _templateLiteralTag.toSingleLine)`The merged cell declared at [${row}, ${col}] has "rowspan"\x20
121
143
  or "colspan" declared as "0", which is not supported. It cannot be added to the collection.`;
122
144
  }
123
145
 
124
146
  /**
125
147
  * Check whether the values provided for a merged cell contain any negative values.
126
148
  *
127
- * @param {object} mergedCellInfo Object containing the `row`, `col`, `rowspan` and `colspan` properties.
149
+ * @param {{ row: number, col: number, rowspan: number, colspan: number }} mergedCell Object containing information
150
+ * about the merged cells that was about to be added.
128
151
  * @returns {boolean}
129
152
  */
130
- static containsNegativeValues(mergedCellInfo) {
131
- return mergedCellInfo.row < 0 || mergedCellInfo.col < 0 || mergedCellInfo.rowspan < 0 || mergedCellInfo.colspan < 0;
153
+ static containsNegativeValues(_ref5) {
154
+ let {
155
+ row,
156
+ col,
157
+ rowspan,
158
+ colspan
159
+ } = _ref5;
160
+ return row < 0 || col < 0 || rowspan < 0 || colspan < 0;
132
161
  }
133
162
 
134
163
  /**
135
164
  * Check whether the provided merged cell information object represents a single cell.
136
165
  *
137
166
  * @private
138
- * @param {object} mergedCellInfo An object with `row`, `col`, `rowspan` and `colspan` properties.
167
+ * @param {{ row: number, col: number, rowspan: number, colspan: number }} mergedCell Object containing information
168
+ * about the merged cells that was about to be added.
139
169
  * @returns {boolean}
140
170
  */
141
- static isSingleCell(mergedCellInfo) {
142
- return mergedCellInfo.colspan === 1 && mergedCellInfo.rowspan === 1;
171
+ static isSingleCell(_ref6) {
172
+ let {
173
+ rowspan,
174
+ colspan
175
+ } = _ref6;
176
+ return colspan === 1 && rowspan === 1;
143
177
  }
144
178
 
145
179
  /**
146
180
  * Check whether the provided merged cell information object contains a rowspan or colspan of 0.
147
181
  *
148
182
  * @private
149
- * @param {object} mergedCellInfo An object with `row`, `col`, `rowspan` and `colspan` properties.
183
+ * @param {{ row: number, col: number, rowspan: number, colspan: number }} mergedCell Object containing information
184
+ * about the merged cells that was about to be added.
150
185
  * @returns {boolean}
151
186
  */
152
- static containsZeroSpan(mergedCellInfo) {
153
- return mergedCellInfo.colspan === 0 || mergedCellInfo.rowspan === 0;
187
+ static containsZeroSpan(_ref7) {
188
+ let {
189
+ rowspan,
190
+ colspan
191
+ } = _ref7;
192
+ return colspan === 0 || rowspan === 0;
154
193
  }
155
194
 
156
195
  /**
@@ -76,78 +76,117 @@ class MergedCellCoords {
76
76
  /**
77
77
  * Get a warning message for when the declared merged cell data contains negative values.
78
78
  *
79
- * @param {object} newMergedCell Object containg information about the merged cells that was about to be added.
79
+ * @param {{ row: number, col: number, rowspan: number, colspan: number }} mergedCell Object containing information
80
+ * about the merged cells that was about to be added.
80
81
  * @returns {string}
81
82
  */
82
- static NEGATIVE_VALUES_WARNING(newMergedCell) {
83
- return toSingleLine`The merged cell declared with {row: ${newMergedCell.row}, col: ${newMergedCell.col},\x20
84
- rowspan: ${newMergedCell.rowspan}, colspan: ${newMergedCell.colspan}} contains negative values, which is\x20
83
+ static NEGATIVE_VALUES_WARNING(_ref) {
84
+ let {
85
+ row,
86
+ col,
87
+ rowspan,
88
+ colspan
89
+ } = _ref;
90
+ return toSingleLine`The merged cell declared with {row: ${row}, col: ${col},\x20
91
+ rowspan: ${rowspan}, colspan: ${colspan}} contains negative values, which is\x20
85
92
  not supported. It will not be added to the collection.`;
86
93
  }
87
94
 
88
95
  /**
89
96
  * Get a warning message for when the declared merged cell data contains values exceeding the table limits.
90
97
  *
91
- * @param {object} newMergedCell Object containg information about the merged cells that was about to be added.
98
+ * @param {{ row: number, col: number, rowspan: number, colspan: number }} mergedCell Object containing information
99
+ * about the merged cells that was about to be added.
92
100
  * @returns {string}
93
101
  */
94
- static IS_OUT_OF_BOUNDS_WARNING(newMergedCell) {
95
- return toSingleLine`The merged cell declared at [${newMergedCell.row}, ${newMergedCell.col}] is positioned\x20
102
+ static IS_OUT_OF_BOUNDS_WARNING(_ref2) {
103
+ let {
104
+ row,
105
+ col
106
+ } = _ref2;
107
+ return toSingleLine`The merged cell declared at [${row}, ${col}] is positioned\x20
96
108
  (or positioned partially) outside of the table range. It was not added to the table, please fix your setup.`;
97
109
  }
98
110
 
99
111
  /**
100
112
  * Get a warning message for when the declared merged cell data represents a single cell.
101
113
  *
102
- * @param {object} newMergedCell Object containg information about the merged cells that was about to be added.
114
+ * @param {{ row: number, col: number, rowspan: number, colspan: number }} mergedCell Object containing information
115
+ * about the merged cells that was about to be added.
103
116
  * @returns {string}
104
117
  */
105
- static IS_SINGLE_CELL(newMergedCell) {
106
- return toSingleLine`The merged cell declared at [${newMergedCell.row}, ${newMergedCell.col}] has both "rowspan"\x20
118
+ static IS_SINGLE_CELL(_ref3) {
119
+ let {
120
+ row,
121
+ col
122
+ } = _ref3;
123
+ return toSingleLine`The merged cell declared at [${row}, ${col}] has both "rowspan"\x20
107
124
  and "colspan" declared as "1", which makes it a single cell. It cannot be added to the collection.`;
108
125
  }
109
126
 
110
127
  /**
111
128
  * Get a warning message for when the declared merged cell data contains "colspan" or "rowspan", that equals 0.
112
129
  *
113
- * @param {object} newMergedCell Object containg information about the merged cells that was about to be added.
130
+ * @param {{ row: number, col: number, rowspan: number, colspan: number }} mergedCell Object containing information
131
+ * about the merged cells that was about to be added.
114
132
  * @returns {string}
115
133
  */
116
- static ZERO_SPAN_WARNING(newMergedCell) {
117
- return toSingleLine`The merged cell declared at [${newMergedCell.row}, ${newMergedCell.col}] has "rowspan"\x20
134
+ static ZERO_SPAN_WARNING(_ref4) {
135
+ let {
136
+ row,
137
+ col
138
+ } = _ref4;
139
+ return toSingleLine`The merged cell declared at [${row}, ${col}] has "rowspan"\x20
118
140
  or "colspan" declared as "0", which is not supported. It cannot be added to the collection.`;
119
141
  }
120
142
 
121
143
  /**
122
144
  * Check whether the values provided for a merged cell contain any negative values.
123
145
  *
124
- * @param {object} mergedCellInfo Object containing the `row`, `col`, `rowspan` and `colspan` properties.
146
+ * @param {{ row: number, col: number, rowspan: number, colspan: number }} mergedCell Object containing information
147
+ * about the merged cells that was about to be added.
125
148
  * @returns {boolean}
126
149
  */
127
- static containsNegativeValues(mergedCellInfo) {
128
- return mergedCellInfo.row < 0 || mergedCellInfo.col < 0 || mergedCellInfo.rowspan < 0 || mergedCellInfo.colspan < 0;
150
+ static containsNegativeValues(_ref5) {
151
+ let {
152
+ row,
153
+ col,
154
+ rowspan,
155
+ colspan
156
+ } = _ref5;
157
+ return row < 0 || col < 0 || rowspan < 0 || colspan < 0;
129
158
  }
130
159
 
131
160
  /**
132
161
  * Check whether the provided merged cell information object represents a single cell.
133
162
  *
134
163
  * @private
135
- * @param {object} mergedCellInfo An object with `row`, `col`, `rowspan` and `colspan` properties.
164
+ * @param {{ row: number, col: number, rowspan: number, colspan: number }} mergedCell Object containing information
165
+ * about the merged cells that was about to be added.
136
166
  * @returns {boolean}
137
167
  */
138
- static isSingleCell(mergedCellInfo) {
139
- return mergedCellInfo.colspan === 1 && mergedCellInfo.rowspan === 1;
168
+ static isSingleCell(_ref6) {
169
+ let {
170
+ rowspan,
171
+ colspan
172
+ } = _ref6;
173
+ return colspan === 1 && rowspan === 1;
140
174
  }
141
175
 
142
176
  /**
143
177
  * Check whether the provided merged cell information object contains a rowspan or colspan of 0.
144
178
  *
145
179
  * @private
146
- * @param {object} mergedCellInfo An object with `row`, `col`, `rowspan` and `colspan` properties.
180
+ * @param {{ row: number, col: number, rowspan: number, colspan: number }} mergedCell Object containing information
181
+ * about the merged cells that was about to be added.
147
182
  * @returns {boolean}
148
183
  */
149
- static containsZeroSpan(mergedCellInfo) {
150
- return mergedCellInfo.colspan === 0 || mergedCellInfo.rowspan === 0;
184
+ static containsZeroSpan(_ref7) {
185
+ let {
186
+ rowspan,
187
+ colspan
188
+ } = _ref7;
189
+ return colspan === 0 || rowspan === 0;
151
190
  }
152
191
 
153
192
  /**
@@ -15,7 +15,6 @@ var _cellCoords = _interopRequireDefault(require("./cellCoords"));
15
15
  var _number = require("../../helpers/number");
16
16
  var _console = require("../../helpers/console");
17
17
  var _array = require("../../helpers/array");
18
- var _utils = require("./utils");
19
18
  var _templateLiteralTag = require("../../helpers/templateLiteralTag");
20
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
20
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
@@ -73,11 +72,16 @@ class MergedCellsCollection {
73
72
  /**
74
73
  * Get a warning message for when the declared merged cell data overlaps already existing merged cells.
75
74
  *
76
- * @param {object} newMergedCell Object containg information about the merged cells that was about to be added.
75
+ * @param {{ row: number, col: number, rowspan: number, colspan: number }} mergedCell Object containing information
76
+ * about the merged cells that was about to be added.
77
77
  * @returns {string}
78
78
  */
79
- static IS_OVERLAPPING_WARNING(newMergedCell) {
80
- return (0, _templateLiteralTag.toSingleLine)`The merged cell declared at [${newMergedCell.row}, ${newMergedCell.col}], overlaps\x20
79
+ static IS_OVERLAPPING_WARNING(_ref) {
80
+ let {
81
+ row,
82
+ col
83
+ } = _ref;
84
+ return (0, _templateLiteralTag.toSingleLine)`The merged cell declared at [${row}, ${col}], overlaps\x20
81
85
  with the other declared merged cell. The overlapping merged cell was not added to the table, please\x20
82
86
  fix your setup.`;
83
87
  }
@@ -172,32 +176,30 @@ class MergedCellsCollection {
172
176
  /**
173
177
  * Get a merged cell contained in the provided range.
174
178
  *
175
- * @param {CellRange|object} range The range to search merged cells in.
179
+ * @param {CellRange} range The range to search merged cells in.
176
180
  * @param {boolean} [countPartials=false] If set to `true`, all the merged cells overlapping the range will be taken into calculation.
177
- * @returns {Array|boolean} Array of found merged cells of `false` if none were found.
181
+ * @returns {MergedCellCoords[]} Array of found merged cells.
178
182
  */
179
183
  getWithinRange(range) {
180
184
  let countPartials = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
181
- const foundMergedCells = [];
182
- let testedRange = range;
183
- if (!testedRange.includesRange) {
184
- const from = this.hot._createCellCoords(testedRange.from.row, testedRange.from.col);
185
- const to = this.hot._createCellCoords(testedRange.to.row, testedRange.to.col);
186
- testedRange = this.hot._createCellRange(from, from, to);
187
- }
188
- (0, _array.arrayEach)(this.mergedCells, mergedCell => {
189
- const mergedCellTopLeft = this.hot._createCellCoords(mergedCell.row, mergedCell.col);
190
- const mergedCellBottomRight = this.hot._createCellCoords(mergedCell.row + mergedCell.rowspan - 1, mergedCell.col + mergedCell.colspan - 1);
191
- const mergedCellRange = this.hot._createCellRange(mergedCellTopLeft, mergedCellTopLeft, mergedCellBottomRight);
192
- if (countPartials) {
193
- if (testedRange.overlaps(mergedCellRange)) {
194
- foundMergedCells.push(mergedCell);
185
+ const {
186
+ row: rowStart,
187
+ col: columnStart
188
+ } = range.getTopStartCorner();
189
+ const {
190
+ row: rowEnd,
191
+ col: columnEnd
192
+ } = range.getBottomEndCorner();
193
+ const result = [];
194
+ for (let row = rowStart; row <= rowEnd; row++) {
195
+ for (let column = columnStart; column <= columnEnd; column++) {
196
+ const mergedCell = this.get(row, column);
197
+ if (mergedCell && (countPartials || !countPartials && mergedCell.row === row && mergedCell.col === column)) {
198
+ result.push(mergedCell);
195
199
  }
196
- } else if (testedRange.includesRange(mergedCellRange)) {
197
- foundMergedCells.push(mergedCell);
198
200
  }
199
- });
200
- return foundMergedCells.length ? foundMergedCells : false;
201
+ }
202
+ return result;
201
203
  }
202
204
 
203
205
  /**
@@ -251,35 +253,26 @@ class MergedCellsCollection {
251
253
  * Clear all the merged cells.
252
254
  */
253
255
  clear() {
254
- const mergedCellParentsToClear = [];
255
- const hiddenCollectionElements = [];
256
- (0, _array.arrayEach)(this.mergedCells, mergedCell => {
257
- const TD = this.hot.getCell(mergedCell.row, mergedCell.col);
258
- if (TD) {
259
- mergedCellParentsToClear.push([TD, this.get(mergedCell.row, mergedCell.col), mergedCell.row, mergedCell.col]);
260
- }
261
- });
262
- this.mergedCells.length = 0;
263
- this.mergedCellsMatrix = new Map();
264
- (0, _array.arrayEach)(mergedCellParentsToClear, (mergedCell, i) => {
265
- (0, _number.rangeEach)(0, mergedCell.rowspan - 1, j => {
266
- (0, _number.rangeEach)(0, mergedCell.colspan - 1, k => {
267
- if (k !== 0 || j !== 0) {
268
- const TD = this.hot.getCell(mergedCell.row + j, mergedCell.col + k);
269
- if (TD) {
270
- hiddenCollectionElements.push([TD, null, null, null]);
271
- }
256
+ (0, _array.arrayEach)(this.mergedCells, _ref2 => {
257
+ let {
258
+ row,
259
+ col,
260
+ rowspan,
261
+ colspan
262
+ } = _ref2;
263
+ (0, _number.rangeEach)(row, row + rowspan, r => {
264
+ (0, _number.rangeEach)(col, col + colspan, c => {
265
+ const TD = this.hot.getCell(r, c);
266
+ if (TD) {
267
+ TD.removeAttribute('rowspan');
268
+ TD.removeAttribute('colspan');
269
+ TD.style.display = '';
272
270
  }
273
271
  });
274
272
  });
275
- mergedCellParentsToClear[i][1] = null;
276
- });
277
- (0, _array.arrayEach)(mergedCellParentsToClear, mergedCellParents => {
278
- (0, _utils.applySpanProperties)(...mergedCellParents);
279
- });
280
- (0, _array.arrayEach)(hiddenCollectionElements, hiddenCollectionElement => {
281
- (0, _utils.applySpanProperties)(...hiddenCollectionElement);
282
273
  });
274
+ this.mergedCells.length = 0;
275
+ this.mergedCellsMatrix = new Map();
283
276
  }
284
277
 
285
278
  /**
@@ -470,11 +463,11 @@ function _getNonIntersectingIndexes(range, axis) {
470
463
  indexes.get(index).add(lastIndex);
471
464
  }
472
465
  }
473
- return Array.from(new Set(Array.from(indexes.entries()).filter(_ref => {
474
- let [, set] = _ref;
466
+ return Array.from(new Set(Array.from(indexes.entries()).filter(_ref3 => {
467
+ let [, set] = _ref3;
475
468
  return set.size === 1;
476
- }).flatMap(_ref2 => {
477
- let [, set] = _ref2;
469
+ }).flatMap(_ref4 => {
470
+ let [, set] = _ref4;
478
471
  return Array.from(set);
479
472
  })));
480
473
  }