handsontable 19.0.0-rc8 → 19.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/3rdparty/walkontable/src/overlay/scrollbarProxies.js +3 -1
  2. package/3rdparty/walkontable/src/overlay/scrollbarProxies.mjs +3 -1
  3. package/CHANGELOG.md +5 -4
  4. package/README.md +11 -4
  5. package/base.js +2 -2
  6. package/base.mjs +2 -2
  7. package/core/hooks/constants.d.ts +2 -0
  8. package/core/hooks/constants.js +15 -6
  9. package/core/hooks/constants.mjs +15 -6
  10. package/core/license.js +2 -2
  11. package/core/license.mjs +2 -2
  12. package/core/types.d.ts +1 -0
  13. package/core.js +51 -4
  14. package/core.mjs +51 -4
  15. package/dataMap/metaManager/metaSchema.js +1 -0
  16. package/dataMap/metaManager/metaSchema.mjs +1 -0
  17. package/dist/handsontable.full.js +299 -121
  18. package/dist/handsontable.full.min.js +24 -24
  19. package/dist/handsontable.js +299 -121
  20. package/dist/handsontable.min.js +24 -24
  21. package/dist/handsontable.settings-schema.js +23 -13
  22. package/dist/handsontable.settings-schema.min.js +2 -2
  23. package/dist/manifest.json +1 -71
  24. package/dist/themes/classic.js +2 -2
  25. package/dist/themes/classic.min.js +2 -2
  26. package/dist/themes/horizon.js +2 -2
  27. package/dist/themes/horizon.min.js +2 -2
  28. package/dist/themes/main.js +2 -2
  29. package/dist/themes/main.min.js +2 -2
  30. package/dist/themes/static/variables/colors/ant.js +2 -2
  31. package/dist/themes/static/variables/colors/ant.min.js +2 -2
  32. package/dist/themes/static/variables/colors/classic.js +2 -2
  33. package/dist/themes/static/variables/colors/classic.min.js +2 -2
  34. package/dist/themes/static/variables/colors/horizon.js +2 -2
  35. package/dist/themes/static/variables/colors/horizon.min.js +2 -2
  36. package/dist/themes/static/variables/colors/main.js +2 -2
  37. package/dist/themes/static/variables/colors/main.min.js +2 -2
  38. package/dist/themes/static/variables/colors/material.js +2 -2
  39. package/dist/themes/static/variables/colors/material.min.js +2 -2
  40. package/dist/themes/static/variables/colors/shadcn.js +2 -2
  41. package/dist/themes/static/variables/colors/shadcn.min.js +2 -2
  42. package/dist/themes/static/variables/density.js +2 -2
  43. package/dist/themes/static/variables/density.min.js +2 -2
  44. package/dist/themes/static/variables/helpers/iconStyles.js +2 -2
  45. package/dist/themes/static/variables/helpers/iconStyles.min.js +2 -2
  46. package/dist/themes/static/variables/helpers/iconsMap.js +2 -2
  47. package/dist/themes/static/variables/helpers/iconsMap.min.js +2 -2
  48. package/dist/themes/static/variables/icons/horizon.js +2 -2
  49. package/dist/themes/static/variables/icons/horizon.min.js +2 -2
  50. package/dist/themes/static/variables/icons/main.js +2 -2
  51. package/dist/themes/static/variables/icons/main.min.js +2 -2
  52. package/dist/themes/static/variables/sizing.js +2 -2
  53. package/dist/themes/static/variables/sizing.min.js +2 -2
  54. package/dist/themes/static/variables/tokens/classic.js +2 -2
  55. package/dist/themes/static/variables/tokens/classic.min.js +2 -2
  56. package/dist/themes/static/variables/tokens/horizon.js +2 -2
  57. package/dist/themes/static/variables/tokens/horizon.min.js +2 -2
  58. package/dist/themes/static/variables/tokens/main.js +2 -2
  59. package/dist/themes/static/variables/tokens/main.min.js +2 -2
  60. package/helpers/mixed.js +5 -5
  61. package/helpers/mixed.mjs +5 -5
  62. package/package.json +1 -1
  63. package/plugins/asyncValues/feature.generated.js +0 -1
  64. package/plugins/asyncValues/feature.generated.mjs +0 -1
  65. package/plugins/autoColumnSize/autoColumnSize.js +3 -3
  66. package/plugins/autoColumnSize/autoColumnSize.mjs +3 -3
  67. package/plugins/autoColumnSize/feature.generated.js +0 -1
  68. package/plugins/autoColumnSize/feature.generated.mjs +0 -1
  69. package/plugins/autoLink/feature.generated.js +0 -1
  70. package/plugins/autoLink/feature.generated.mjs +0 -1
  71. package/plugins/autoRowHeaderSize/feature.generated.js +0 -1
  72. package/plugins/autoRowHeaderSize/feature.generated.mjs +0 -1
  73. package/plugins/autoRowSize/autoRowSize.js +5 -5
  74. package/plugins/autoRowSize/autoRowSize.mjs +5 -5
  75. package/plugins/autoRowSize/feature.generated.js +0 -1
  76. package/plugins/autoRowSize/feature.generated.mjs +0 -1
  77. package/plugins/autofill/feature.generated.js +0 -1
  78. package/plugins/autofill/feature.generated.mjs +0 -1
  79. package/plugins/base/base.d.ts +8 -1
  80. package/plugins/bindRowsWithHeaders/feature.generated.js +0 -1
  81. package/plugins/bindRowsWithHeaders/feature.generated.mjs +0 -1
  82. package/plugins/checkboxHeader/feature.generated.js +0 -1
  83. package/plugins/checkboxHeader/feature.generated.mjs +0 -1
  84. package/plugins/collapsibleColumns/feature.generated.js +0 -1
  85. package/plugins/collapsibleColumns/feature.generated.mjs +0 -1
  86. package/plugins/columnSorting/feature.generated.js +0 -1
  87. package/plugins/columnSorting/feature.generated.mjs +0 -1
  88. package/plugins/columnSummary/feature.generated.js +0 -1
  89. package/plugins/columnSummary/feature.generated.mjs +0 -1
  90. package/plugins/comments/feature.generated.js +0 -1
  91. package/plugins/comments/feature.generated.mjs +0 -1
  92. package/plugins/contextMenu/feature.generated.js +0 -1
  93. package/plugins/contextMenu/feature.generated.mjs +0 -1
  94. package/plugins/copyPaste/feature.generated.js +0 -1
  95. package/plugins/copyPaste/feature.generated.mjs +0 -1
  96. package/plugins/customBorders/feature.generated.js +0 -1
  97. package/plugins/customBorders/feature.generated.mjs +0 -1
  98. package/plugins/dataProvider/feature.generated.js +0 -1
  99. package/plugins/dataProvider/feature.generated.mjs +0 -1
  100. package/plugins/dialog/feature.generated.js +0 -1
  101. package/plugins/dialog/feature.generated.mjs +0 -1
  102. package/plugins/dragToScroll/feature.generated.js +0 -1
  103. package/plugins/dragToScroll/feature.generated.mjs +0 -1
  104. package/plugins/dropdownMenu/feature.generated.js +0 -1
  105. package/plugins/dropdownMenu/feature.generated.mjs +0 -1
  106. package/plugins/emptyDataState/feature.generated.js +0 -1
  107. package/plugins/emptyDataState/feature.generated.mjs +0 -1
  108. package/plugins/exportFile/feature.generated.js +0 -1
  109. package/plugins/exportFile/feature.generated.mjs +0 -1
  110. package/plugins/filters/feature.generated.js +0 -1
  111. package/plugins/filters/feature.generated.mjs +0 -1
  112. package/plugins/formulaBuilder/feature.generated.js +0 -1
  113. package/plugins/formulaBuilder/feature.generated.mjs +0 -1
  114. package/plugins/formulas/feature.generated.js +0 -1
  115. package/plugins/formulas/feature.generated.mjs +0 -1
  116. package/plugins/formulas/formulas.js +4 -4
  117. package/plugins/formulas/formulas.mjs +4 -4
  118. package/plugins/freezeBar/feature.generated.js +0 -1
  119. package/plugins/freezeBar/feature.generated.mjs +0 -1
  120. package/plugins/hiddenColumns/feature.generated.js +0 -1
  121. package/plugins/hiddenColumns/feature.generated.mjs +0 -1
  122. package/plugins/hiddenRows/feature.generated.js +0 -1
  123. package/plugins/hiddenRows/feature.generated.mjs +0 -1
  124. package/plugins/importFile/feature.generated.js +0 -1
  125. package/plugins/importFile/feature.generated.mjs +0 -1
  126. package/plugins/loading/feature.generated.js +0 -1
  127. package/plugins/loading/feature.generated.mjs +0 -1
  128. package/plugins/manualColumnFreeze/feature.generated.js +0 -1
  129. package/plugins/manualColumnFreeze/feature.generated.mjs +0 -1
  130. package/plugins/manualColumnMove/feature.generated.js +0 -1
  131. package/plugins/manualColumnMove/feature.generated.mjs +0 -1
  132. package/plugins/manualColumnResize/feature.generated.js +0 -1
  133. package/plugins/manualColumnResize/feature.generated.mjs +0 -1
  134. package/plugins/manualRowMove/feature.generated.js +0 -1
  135. package/plugins/manualRowMove/feature.generated.mjs +0 -1
  136. package/plugins/manualRowResize/feature.generated.js +0 -1
  137. package/plugins/manualRowResize/feature.generated.mjs +0 -1
  138. package/plugins/mergeCells/feature.generated.js +0 -1
  139. package/plugins/mergeCells/feature.generated.mjs +0 -1
  140. package/plugins/mergeCells/mergeCells.js +159 -16
  141. package/plugins/mergeCells/mergeCells.mjs +159 -16
  142. package/plugins/moveCells/feature.generated.js +0 -1
  143. package/plugins/moveCells/feature.generated.mjs +0 -1
  144. package/plugins/multiColumnSorting/feature.generated.js +0 -1
  145. package/plugins/multiColumnSorting/feature.generated.mjs +0 -1
  146. package/plugins/nestedHeaders/feature.generated.js +0 -1
  147. package/plugins/nestedHeaders/feature.generated.mjs +0 -1
  148. package/plugins/nestedRows/feature.generated.js +0 -1
  149. package/plugins/nestedRows/feature.generated.mjs +0 -1
  150. package/plugins/notification/feature.generated.js +0 -1
  151. package/plugins/notification/feature.generated.mjs +0 -1
  152. package/plugins/pagination/feature.generated.js +0 -1
  153. package/plugins/pagination/feature.generated.mjs +0 -1
  154. package/plugins/pagination/pagination.js +17 -4
  155. package/plugins/pagination/pagination.mjs +17 -4
  156. package/plugins/rowSelection/feature.generated.js +0 -1
  157. package/plugins/rowSelection/feature.generated.mjs +0 -1
  158. package/plugins/search/feature.generated.js +0 -1
  159. package/plugins/search/feature.generated.mjs +0 -1
  160. package/plugins/selectionHandles/feature.generated.js +0 -1
  161. package/plugins/selectionHandles/feature.generated.mjs +0 -1
  162. package/plugins/sheetsBar/feature.generated.js +0 -1
  163. package/plugins/sheetsBar/feature.generated.mjs +0 -1
  164. package/plugins/stretchColumns/feature.generated.js +0 -1
  165. package/plugins/stretchColumns/feature.generated.mjs +0 -1
  166. package/plugins/trimRows/feature.generated.js +0 -1
  167. package/plugins/trimRows/feature.generated.mjs +0 -1
  168. package/plugins/undoRedo/feature.generated.js +0 -1
  169. package/plugins/undoRedo/feature.generated.mjs +0 -1
  170. package/plugins/undoRedo/restore.js +20 -8
  171. package/plugins/undoRedo/restore.mjs +20 -8
  172. package/plugins/undoRedo/snapshot/gridState.d.ts +5 -1
  173. package/plugins/undoRedo/snapshot/gridState.js +5 -2
  174. package/plugins/undoRedo/snapshot/gridState.mjs +5 -2
  175. package/plugins/viewState/feature.generated.js +0 -1
  176. package/plugins/viewState/feature.generated.mjs +0 -1
  177. package/styles/handsontable.css +2 -2
  178. package/styles/handsontable.min.css +2 -2
  179. package/styles/handsontableStyles.d.ts +1 -1
  180. package/styles/handsontableStyles.js +1 -1
  181. package/styles/handsontableStyles.mjs +1 -1
  182. package/styles/ht-icons-horizon.min.css +2 -2
  183. package/styles/ht-icons-main.min.css +2 -2
  184. package/styles/ht-theme-classic-no-icons.min.css +2 -2
  185. package/styles/ht-theme-classic.min.css +2 -2
  186. package/styles/ht-theme-horizon-no-icons.min.css +2 -2
  187. package/styles/ht-theme-horizon.min.css +2 -2
  188. package/styles/ht-theme-main-no-icons.min.css +2 -2
  189. package/styles/ht-theme-main.min.css +2 -2
  190. package/utils/licenseBranding/index.js +5 -4
  191. package/utils/licenseBranding/index.mjs +5 -4
  192. package/utils/licenseNotification.js +2 -2
  193. package/utils/licenseNotification.mjs +2 -2
  194. package/utils/xlsxEngine/licenseCapabilities.generated.js +0 -4
  195. package/utils/xlsxEngine/licenseCapabilities.generated.mjs +0 -4
@@ -156,6 +156,47 @@ const SHORTCUTS_GROUP = PLUGIN_KEY;
156
156
  */ function isMergeState(value) {
157
157
  return Array.isArray(value);
158
158
  }
159
+ /**
160
+ * Maps the physical cells a captured merge names to another numbering of the rows and columns. A row or
161
+ * column that does not exist there is dropped. The anchor keeps its own column, mapped, or takes the first
162
+ * recorded column that is left when its own does not exist there. A merge with no row or no column left has
163
+ * no anchor.
164
+ *
165
+ * @param {object} entry The captured merge.
166
+ * @param {Function} toIndex Maps a physical index, or answers `null` for one that does not exist there.
167
+ * @returns {object} The merge with its anchor and `physicalColumns` mapped.
168
+ */ function mapRecordedMerge(entry, toIndex) {
169
+ const physicalColumns = entry.physicalColumns?.map((column)=>column === null ? null : toIndex(column, 'column'));
170
+ if (entry.anchor === null) {
171
+ return {
172
+ ...entry,
173
+ physicalColumns
174
+ };
175
+ }
176
+ const physicalRows = entry.anchor.physicalRows.map((row)=>toIndex(row, 'row')).filter((row)=>row !== null);
177
+ const physicalColumn = toIndex(entry.anchor.physicalColumn, 'column') ?? physicalColumns?.find((column)=>column !== null) ?? null;
178
+ return {
179
+ ...entry,
180
+ anchor: physicalRows.length === 0 || physicalColumn === null ? null : {
181
+ physicalRows,
182
+ physicalColumn
183
+ },
184
+ physicalColumns
185
+ };
186
+ }
187
+ /**
188
+ * Returns a key for the physical cells a captured merge names (its anchor rows, its anchor column and its
189
+ * columns), so two merges with the same key name the same cells. A merge with no anchor or no recorded columns
190
+ * has none.
191
+ *
192
+ * @param {object} entry The captured merge.
193
+ * @returns {string | null}
194
+ */ function getFootprintKey(entry) {
195
+ if (entry.anchor === null || entry.physicalColumns === undefined) {
196
+ return null;
197
+ }
198
+ return `${entry.anchor.physicalRows.join(',')}|${entry.anchor.physicalColumn}|${entry.physicalColumns.join(',')}`;
199
+ }
159
200
  /**
160
201
  * Counts how many of the ascending `values` are smaller than `value`.
161
202
  *
@@ -464,12 +505,49 @@ var /**
464
505
  * restored side does not. `restoreState()` runs after UndoRedo restored the index maps, so the visual columns
465
506
  * of a live merge name the wrong physical columns and a set built from them cannot see the cell a redo takes
466
507
  * out of a merge. The recorded merges carry their physical columns, so the two sides are compared by those.
467
- * A cell the restored side's changed merges cover is left alone. One an unchanged merge covers may be
468
- * cleaned, and `afterGetCellMeta` stores the flags again on the next read.
508
+ * A cell the restored side's changed merges cover keeps what they put on it. The cell one of them is drawn
509
+ * from loses `hidden` and `copyable` and keeps its span keys, because `afterGetCellMeta` never writes
510
+ * `copyable` back on a top-left. A covered cell a merge of the other side was drawn from loses its span keys
511
+ * and keeps its covered flags, because the hook never takes a span off a covered cell. One an unchanged merge
512
+ * covers may be cleaned, and `afterGetCellMeta` stores the flags again on the next read.
513
+ *
514
+ * The span keys go too, and neither removal waits for the `hidden` or `spanned` mark. The merge stored both
515
+ * marks through `setCellMeta()`, so on the undo of a merge the UndoRedo journal has already taken them back,
516
+ * while the `copyable`, `rowspan` and `colspan` the hook wrote are not in the journal. The recorded other side
517
+ * is the proof that a merge covered the cell. A recorded `copyable`, `rowspan` or `colspan` still stays.
469
518
  *
470
519
  * @param {Array} state The merges on the restored side of the step.
471
520
  * @param {Array} other The merges on the other side of the step.
472
521
  */ _clearCoveredFlagsOfCellsReleasedByStep = /*#__PURE__*/ new WeakSet(), /**
522
+ * Does what {@link MergeCells#clearCoveredFlagsOfCellsReleasedByStep} does, after a replay that inserted or
523
+ * removed rows or columns. The physical indexes the other side records are numbered like the grid before that
524
+ * replay, so each merge's anchor rows and recorded columns are first mapped to the restored grid through the
525
+ * rows and columns the step inserted or removed. Neither the live merges nor their visual columns can stand in:
526
+ * the replay runs in the physical order and the column order is restored before this runs. A merge whose
527
+ * mapped cells equal those of a restored merge is one the step left alone, and both are left out.
528
+ *
529
+ * @param {Array} state The merges on the restored side of the step.
530
+ * @param {Array} other The merges on the other side of the step.
531
+ * @param {Function} toRestoredIndex Maps a physical index of `other` to the restored grid.
532
+ */ _clearMergeKeysOfCellsReleasedByReplay = /*#__PURE__*/ new WeakSet(), /**
533
+ * Removes the merge keys from cells a merge covered on the other side of an undo step. A cell the restored
534
+ * side covers keeps what its merge put on it, except the cell a restored merge is drawn from: it loses `hidden`
535
+ * and `copyable` and keeps its span keys, because `afterGetCellMeta` never writes `copyable` back on a top-left.
536
+ * A covered cell a merge of the other side was drawn from loses its span keys and keeps its covered flags,
537
+ * because the hook never takes a span off a covered cell. Neither removal waits for the `hidden` or `spanned`
538
+ * mark (see {@link MergeCells#clearCoveredFlagsOfCellsReleasedByStep}).
539
+ *
540
+ * @param {Set<number>} released The cells a merge covered on the other side of the step.
541
+ * @param {Set<number>} leftTopLefts The cells the merges of the other side were drawn from.
542
+ * @param {Set<number>} covered The cells the restored merges cover.
543
+ * @param {Set<number>} restoredTopLefts The cells the restored merges are drawn from.
544
+ */ _clearMergeKeysOfReleasedCells = /*#__PURE__*/ new WeakSet(), /**
545
+ * Collects the physical cell each recorded merge is drawn from (`#getTopLeftPhysicalRow()` in the anchor's
546
+ * column). A merge with no anchor, or with no visible top-left, is left out.
547
+ *
548
+ * @param {Array} entries The recorded merges.
549
+ * @returns {Set<number>} The cells, packed as `physicalRow * DRAWN_CELL_COLUMN_STRIDE + physicalColumn`.
550
+ */ _collectRecordedTopLeftCells = /*#__PURE__*/ new WeakSet(), /**
473
551
  * Takes out the live merges the step made and puts back the ones it took, leaving every other live
474
552
  * merge alone.
475
553
  *
@@ -849,8 +927,12 @@ var /**
849
927
  * applies it again on the next read.
850
928
  * The meta is removed through the meta manager, by physical index and without the remove-meta hooks.
851
929
  *
930
+ * A caller that knows from a recorded undo step that a merge covered the cell skips the `spanned` check: the
931
+ * UndoRedo journal takes `spanned` back before `restoreState()` runs, and it never held `rowspan` or `colspan`.
932
+ *
852
933
  * @param {number} physicalRow The physical row of the cell.
853
934
  * @param {number} physicalColumn The physical column of the cell.
935
+ * @param {boolean} [wasInMerge=false] `true` when a recorded undo step shows that a merge covered the cell.
854
936
  */ _clearSpanKeysOfCell = /*#__PURE__*/ new WeakSet(), /**
855
937
  * Returns the physical cell a merge is drawn from, packed into one number, or `null` when none is: every
856
938
  * row of the merge is trimmed, or its column is. It is the first row of the merge's anchor that has
@@ -913,8 +995,12 @@ var /**
913
995
  * The meta is removed through the meta manager, by physical index and without the remove-meta hooks.
914
996
  * The check costs one meta lookup per merge and no lookup in the merge collection.
915
997
  *
998
+ * A caller that knows from a recorded undo step that a merge covered the cell skips the `hidden` check: the
999
+ * UndoRedo journal takes `hidden` back before `restoreState()` runs, and it never held `copyable`.
1000
+ *
916
1001
  * @param {number} physicalRow The physical row of the cell the merge is drawn from.
917
1002
  * @param {number} physicalColumn The physical column of the cell the merge is drawn from.
1003
+ * @param {boolean} [wasInMerge=false] `true` when a recorded undo step shows that a merge covered the cell.
918
1004
  */ _clearCoveredFlagsOfTopLeftCell = /*#__PURE__*/ new WeakSet(), /**
919
1005
  * The area highlight was committed for the old merges. The next view render recomputes it once,
920
1006
  * before this draw paints. Selection-change hooks do not run. `afterIsMultipleSelection` does,
@@ -1887,9 +1973,10 @@ class MergeCells extends _base.BasePlugin {
1887
1973
  return;
1888
1974
  }
1889
1975
  const other = context?.other;
1976
+ const isReplayed = context?.reordered === true;
1890
1977
  // The restore replaces merges, and a step can leave the cell a merge was drawn from in no merge.
1891
1978
  const drawnFromBefore = _class_private_method_get(this, _snapshotDrawnFromCells, snapshotDrawnFromCells).call(this);
1892
- if (!isMergeState(other) || context?.reordered === true || !_class_private_method_get(this, _restoreChangedMerges, restoreChangedMerges).call(this, state, other)) {
1979
+ if (!isMergeState(other) || isReplayed || !_class_private_method_get(this, _restoreChangedMerges, restoreChangedMerges).call(this, state, other)) {
1893
1980
  this.mergedCellsCollection.clear();
1894
1981
  _class_private_field_set(this, _mergeAnchors, new WeakMap());
1895
1982
  _class_private_field_set(this, _purgedMerges, new WeakSet());
@@ -1897,9 +1984,11 @@ class MergeCells extends _base.BasePlugin {
1897
1984
  }
1898
1985
  _class_private_method_get(this, _reanchorMergesToVisibleRows, reanchorMergesToVisibleRows).call(this);
1899
1986
  _class_private_method_get(this, _clearSpanKeysOfCellsNoLongerDrawnFrom, clearSpanKeysOfCellsNoLongerDrawnFrom).call(this, drawnFromBefore);
1900
- // A replay that inserted or removed columns renumbered the physical indexes the recorded merges name.
1901
- if (isMergeState(other) && context?.reordered !== true) {
1987
+ if (isMergeState(other) && !isReplayed) {
1902
1988
  _class_private_method_get(this, _clearCoveredFlagsOfCellsReleasedByStep, clearCoveredFlagsOfCellsReleasedByStep).call(this, state, other);
1989
+ } else if (isMergeState(other) && context?.toRestoredIndex) {
1990
+ // A replay that inserted or removed rows or columns renumbered the physical indexes the other side records.
1991
+ _class_private_method_get(this, _clearMergeKeysOfCellsReleasedByReplay, clearMergeKeysOfCellsReleasedByReplay).call(this, state, other, context.toRestoredIndex);
1903
1992
  }
1904
1993
  this.hot.markAllCellsChanged();
1905
1994
  }
@@ -2111,7 +2200,7 @@ class MergeCells extends _base.BasePlugin {
2111
2200
  ];
2112
2201
  }
2113
2202
  constructor(...args){
2114
- super(...args), _class_private_method_init(this, _takeKeptMerges), _class_private_method_init(this, _hasGrownArea), _class_private_method_init(this, _keepAreasReachingKeptMerges), _class_private_method_init(this, _adoptRecreatedMerges), _class_private_method_init(this, _hasGrownPastArea), _class_private_method_init(this, _restoreKeptMerges), _class_private_method_init(this, _getAnchorFootprint), _class_private_method_init(this, _getStoredValueAt), _class_private_method_init(this, _getCellDrawnOn), _class_private_method_init(this, _restoreAnchoredArea), _class_private_method_init(this, _placeAnchoredArea), _class_private_method_init(this, _canMergeSelection), _class_private_method_init(this, _describeMerge), _class_private_method_init(this, _mergeRange), _class_private_method_init(this, _removeRefusedMergeMeta), _class_private_method_init(this, _resetMergedCellMeta), _class_private_method_init(this, _getLeftColumnKeys), _class_private_method_init(this, _collectForeignDrawnRows), _class_private_method_init(this, _clearRowsLeftBehind), _class_private_method_init(this, _getDrawnPhysicalRows), _class_private_method_init(this, _getCellMetaRemover), _class_private_method_init(this, _matchesMerges), _class_private_method_init(this, _collectRecordedCoveredCells), _class_private_method_init(this, _clearCoveredFlagsOfCellsReleasedByStep), _class_private_method_init(this, _restoreChangedMerges), _class_private_method_init(this, _addRecordedMerge), _class_private_method_init(this, _hasVisibleTopLeft), _class_private_method_init(this, _getTopLeftPhysicalRow), _class_private_method_init(this, _unmergeRange), _class_private_method_init(this, _captureAnchorOf), _class_private_method_init(this, _fillTrimmedGaps), _class_private_method_init(this, _getRowsOwnedBesides), _class_private_method_init(this, _captureMergeAnchors), _class_private_method_init(this, _captureMissingMergeAnchors), _class_private_method_init(this, _remapRowAnchorsAfterInsert), _class_private_method_init(this, _remapRowAnchorsAfterRemove), _class_private_method_init(this, _dropMergesWithoutRows), _class_private_method_init(this, _remapAnchors), _class_private_method_init(this, _buildRowSequencePositions), _class_private_method_init(this, _groupRowsBySequenceRuns), _class_private_method_init(this, _attributeTrimmedRows), _class_private_method_init(this, _describesOwnRows), _class_private_method_init(this, _countVisualRuns), _class_private_method_init(this, _planRowMoveTranslation), _class_private_method_init(this, _planColumnMoveRetention), _class_private_method_init(this, _carrierRowsOf), _class_private_method_init(this, _reanchorFragmentsAfterSplit), _class_private_method_init(this, _transferAnchorsAfterAxisMove), _class_private_method_init(this, _sortVisibleRowsByVisualOrder), _class_private_method_init(this, _isRowTrimmingActive), _class_private_method_init(this, _reanchorMergesToVisibleRows), _class_private_method_init(this, _settleMergesAfterAxisMove), _class_private_method_init(this, _cleanReleasedCells), _class_private_method_init(this, _clearReleasedCell), _class_private_method_init(this, _clearSpanKeysOfCell), _class_private_method_init(this, _getDrawnFromCellKey), _class_private_method_init(this, _snapshotDrawnFromCells), _class_private_method_init(this, _isOutsideMoveWindow), _class_private_method_init(this, _snapshotCoveredCells), _class_private_method_init(this, _clearCoveredFlagsOfCellsNoLongerCovered), _class_private_method_init(this, _clearSpanKeysOfCellsNoLongerDrawnFrom), _class_private_method_init(this, _clearCoveredFlagsOfTopLeftCell), _class_private_method_init(this, _recommitSelectionHighlight), _class_private_method_init(this, _captureDrawnFromBeforeMove), _class_private_method_init(this, _getMoveWindow), _class_private_method_init(this, _resetPasteState), _class_private_method_init(this, _mergeAtChange), _class_private_method_init(this, _collectMergesFromChanges), _class_private_method_init(this, _discardChangesOnCoveredCells), _class_private_method_init(this, _unmergeAfterPaste), _class_private_method_init(this, _markBlocksCrossingFrozenColumnsChanged), _class_private_method_init(this, _getFirstRenderedColumnOfTable), _class_private_method_init(this, _getSpanCarrierRow), _class_private_field_init(this, _cellBlockProvider, {
2203
+ super(...args), _class_private_method_init(this, _takeKeptMerges), _class_private_method_init(this, _hasGrownArea), _class_private_method_init(this, _keepAreasReachingKeptMerges), _class_private_method_init(this, _adoptRecreatedMerges), _class_private_method_init(this, _hasGrownPastArea), _class_private_method_init(this, _restoreKeptMerges), _class_private_method_init(this, _getAnchorFootprint), _class_private_method_init(this, _getStoredValueAt), _class_private_method_init(this, _getCellDrawnOn), _class_private_method_init(this, _restoreAnchoredArea), _class_private_method_init(this, _placeAnchoredArea), _class_private_method_init(this, _canMergeSelection), _class_private_method_init(this, _describeMerge), _class_private_method_init(this, _mergeRange), _class_private_method_init(this, _removeRefusedMergeMeta), _class_private_method_init(this, _resetMergedCellMeta), _class_private_method_init(this, _getLeftColumnKeys), _class_private_method_init(this, _collectForeignDrawnRows), _class_private_method_init(this, _clearRowsLeftBehind), _class_private_method_init(this, _getDrawnPhysicalRows), _class_private_method_init(this, _getCellMetaRemover), _class_private_method_init(this, _matchesMerges), _class_private_method_init(this, _collectRecordedCoveredCells), _class_private_method_init(this, _clearCoveredFlagsOfCellsReleasedByStep), _class_private_method_init(this, _clearMergeKeysOfCellsReleasedByReplay), _class_private_method_init(this, _clearMergeKeysOfReleasedCells), _class_private_method_init(this, _collectRecordedTopLeftCells), _class_private_method_init(this, _restoreChangedMerges), _class_private_method_init(this, _addRecordedMerge), _class_private_method_init(this, _hasVisibleTopLeft), _class_private_method_init(this, _getTopLeftPhysicalRow), _class_private_method_init(this, _unmergeRange), _class_private_method_init(this, _captureAnchorOf), _class_private_method_init(this, _fillTrimmedGaps), _class_private_method_init(this, _getRowsOwnedBesides), _class_private_method_init(this, _captureMergeAnchors), _class_private_method_init(this, _captureMissingMergeAnchors), _class_private_method_init(this, _remapRowAnchorsAfterInsert), _class_private_method_init(this, _remapRowAnchorsAfterRemove), _class_private_method_init(this, _dropMergesWithoutRows), _class_private_method_init(this, _remapAnchors), _class_private_method_init(this, _buildRowSequencePositions), _class_private_method_init(this, _groupRowsBySequenceRuns), _class_private_method_init(this, _attributeTrimmedRows), _class_private_method_init(this, _describesOwnRows), _class_private_method_init(this, _countVisualRuns), _class_private_method_init(this, _planRowMoveTranslation), _class_private_method_init(this, _planColumnMoveRetention), _class_private_method_init(this, _carrierRowsOf), _class_private_method_init(this, _reanchorFragmentsAfterSplit), _class_private_method_init(this, _transferAnchorsAfterAxisMove), _class_private_method_init(this, _sortVisibleRowsByVisualOrder), _class_private_method_init(this, _isRowTrimmingActive), _class_private_method_init(this, _reanchorMergesToVisibleRows), _class_private_method_init(this, _settleMergesAfterAxisMove), _class_private_method_init(this, _cleanReleasedCells), _class_private_method_init(this, _clearReleasedCell), _class_private_method_init(this, _clearSpanKeysOfCell), _class_private_method_init(this, _getDrawnFromCellKey), _class_private_method_init(this, _snapshotDrawnFromCells), _class_private_method_init(this, _isOutsideMoveWindow), _class_private_method_init(this, _snapshotCoveredCells), _class_private_method_init(this, _clearCoveredFlagsOfCellsNoLongerCovered), _class_private_method_init(this, _clearSpanKeysOfCellsNoLongerDrawnFrom), _class_private_method_init(this, _clearCoveredFlagsOfTopLeftCell), _class_private_method_init(this, _recommitSelectionHighlight), _class_private_method_init(this, _captureDrawnFromBeforeMove), _class_private_method_init(this, _getMoveWindow), _class_private_method_init(this, _resetPasteState), _class_private_method_init(this, _mergeAtChange), _class_private_method_init(this, _collectMergesFromChanges), _class_private_method_init(this, _discardChangesOnCoveredCells), _class_private_method_init(this, _unmergeAfterPaste), _class_private_method_init(this, _markBlocksCrossingFrozenColumnsChanged), _class_private_method_init(this, _getFirstRenderedColumnOfTable), _class_private_method_init(this, _getSpanCarrierRow), _class_private_field_init(this, _cellBlockProvider, {
2115
2204
  writable: true,
2116
2205
  value: void 0
2117
2206
  }), _class_private_field_init(this, _cellRenderer, {
@@ -3023,13 +3112,61 @@ function clearCoveredFlagsOfCellsReleasedByStep(state, other) {
3023
3112
  if (left.length === 0) {
3024
3113
  return;
3025
3114
  }
3026
- const covered = _class_private_method_get(this, _collectRecordedCoveredCells, collectRecordedCoveredCells).call(this, state.filter((entry)=>!isMergeListed(other, entry)));
3027
- _class_private_method_get(this, _collectRecordedCoveredCells, collectRecordedCoveredCells).call(this, left).forEach((key)=>{
3028
- if (covered.has(key)) {
3115
+ const restored = state.filter((entry)=>!isMergeListed(other, entry));
3116
+ _class_private_method_get(this, _clearMergeKeysOfReleasedCells, clearMergeKeysOfReleasedCells).call(this, _class_private_method_get(this, _collectRecordedCoveredCells, collectRecordedCoveredCells).call(this, left), _class_private_method_get(this, _collectRecordedTopLeftCells, collectRecordedTopLeftCells).call(this, left), _class_private_method_get(this, _collectRecordedCoveredCells, collectRecordedCoveredCells).call(this, restored), _class_private_method_get(this, _collectRecordedTopLeftCells, collectRecordedTopLeftCells).call(this, restored));
3117
+ }
3118
+ function clearMergeKeysOfCellsReleasedByReplay(state, other, toRestoredIndex) {
3119
+ const mapped = other.map((entry)=>{
3120
+ const mappedEntry = mapRecordedMerge(entry, toRestoredIndex);
3121
+ // A merge that lost a row or a column to the mapping covered a cell the restored grid lacks, so it is
3122
+ // not the same merge as one of the restored side with the cells that are left.
3123
+ const isWhole = mappedEntry.anchor?.physicalRows.length === entry.anchor?.physicalRows.length && !mappedEntry.physicalColumns?.includes(null);
3124
+ return {
3125
+ entry: mappedEntry,
3126
+ key: isWhole ? getFootprintKey(mappedEntry) : null
3127
+ };
3128
+ });
3129
+ const restoredKeys = new Set(state.map(getFootprintKey));
3130
+ const left = mapped.filter(({ key })=>key === null || !restoredKeys.has(key)).map(({ entry })=>entry);
3131
+ if (left.length === 0) {
3132
+ return;
3133
+ }
3134
+ const mappedKeys = new Set(mapped.map(({ key })=>key));
3135
+ const restored = state.filter((entry)=>{
3136
+ const key = getFootprintKey(entry);
3137
+ return key === null || !mappedKeys.has(key);
3138
+ });
3139
+ _class_private_method_get(this, _clearMergeKeysOfReleasedCells, clearMergeKeysOfReleasedCells).call(this, _class_private_method_get(this, _collectRecordedCoveredCells, collectRecordedCoveredCells).call(this, left), _class_private_method_get(this, _collectRecordedTopLeftCells, collectRecordedTopLeftCells).call(this, left), _class_private_method_get(this, _collectRecordedCoveredCells, collectRecordedCoveredCells).call(this, restored), _class_private_method_get(this, _collectRecordedTopLeftCells, collectRecordedTopLeftCells).call(this, restored));
3140
+ }
3141
+ function clearMergeKeysOfReleasedCells(released, leftTopLefts, covered, restoredTopLefts) {
3142
+ released.forEach((key)=>{
3143
+ const isRestoredTopLeft = restoredTopLefts.has(key);
3144
+ const isCovered = covered.has(key);
3145
+ // A restored merge drawn from the cell keeps its span keys; one that covers it keeps its covered flags.
3146
+ const clearsCoveredFlags = !isCovered || isRestoredTopLeft;
3147
+ const clearsSpanKeys = !isRestoredTopLeft && (!isCovered || leftTopLefts.has(key));
3148
+ if (!clearsCoveredFlags && !clearsSpanKeys) {
3029
3149
  return;
3030
3150
  }
3031
- _class_private_method_get(this, _clearCoveredFlagsOfTopLeftCell, clearCoveredFlagsOfTopLeftCell).call(this, Math.trunc(key / DRAWN_CELL_COLUMN_STRIDE), key % DRAWN_CELL_COLUMN_STRIDE);
3151
+ const physicalRow = Math.trunc(key / DRAWN_CELL_COLUMN_STRIDE);
3152
+ const physicalColumn = key % DRAWN_CELL_COLUMN_STRIDE;
3153
+ if (clearsCoveredFlags) {
3154
+ _class_private_method_get(this, _clearCoveredFlagsOfTopLeftCell, clearCoveredFlagsOfTopLeftCell).call(this, physicalRow, physicalColumn, true);
3155
+ }
3156
+ if (clearsSpanKeys) {
3157
+ _class_private_method_get(this, _clearSpanKeysOfCell, clearSpanKeysOfCell).call(this, physicalRow, physicalColumn, true);
3158
+ }
3159
+ });
3160
+ }
3161
+ function collectRecordedTopLeftCells(entries) {
3162
+ const cells = new Set();
3163
+ entries.forEach(({ anchor })=>{
3164
+ const physicalRow = anchor === null ? null : _class_private_method_get(this, _getTopLeftPhysicalRow, getTopLeftPhysicalRow).call(this, anchor);
3165
+ if (anchor !== null && physicalRow !== null) {
3166
+ cells.add(physicalRow * DRAWN_CELL_COLUMN_STRIDE + anchor.physicalColumn);
3167
+ }
3032
3168
  });
3169
+ return cells;
3033
3170
  }
3034
3171
  function restoreChangedMerges(target, from) {
3035
3172
  const liveToRemove = from.filter((entry)=>!isMergeListed(target, entry)).map((entry)=>this.mergedCellsCollection.mergedCells.find((merge)=>merge.row === entry.row && merge.col === entry.col && merge.rowspan === entry.rowspan && merge.colspan === entry.colspan && areAnchorsEqual(entry.anchor, _class_private_field_get(this, _mergeAnchors).get(merge))));
@@ -3563,13 +3700,16 @@ function clearReleasedCell(physicalRow, physicalColumn) {
3563
3700
  _class_private_method_get(this, _clearSpanKeysOfCell, clearSpanKeysOfCell).call(this, physicalRow, physicalColumn);
3564
3701
  }
3565
3702
  }
3566
- function clearSpanKeysOfCell(physicalRow, physicalColumn) {
3703
+ function clearSpanKeysOfCell(physicalRow, physicalColumn, wasInMerge = false) {
3567
3704
  const metaManager = this.hot._getMetaManager();
3568
3705
  const storedMeta = metaManager.getCellMetaIfExists(physicalRow, physicalColumn);
3569
- if (!storedMeta || !(0, _object.hasOwnProperty)(storedMeta, 'spanned')) {
3706
+ const hasMark = !!storedMeta && (0, _object.hasOwnProperty)(storedMeta, 'spanned');
3707
+ if (!storedMeta || !wasInMerge && !hasMark) {
3570
3708
  return;
3571
3709
  }
3572
- metaManager.removeCellMeta(physicalRow, physicalColumn, 'spanned');
3710
+ if (hasMark) {
3711
+ metaManager.removeCellMeta(physicalRow, physicalColumn, 'spanned');
3712
+ }
3573
3713
  [
3574
3714
  'rowspan',
3575
3715
  'colspan'
@@ -3657,13 +3797,16 @@ function clearSpanKeysOfCellsNoLongerDrawnFrom(before) {
3657
3797
  }
3658
3798
  });
3659
3799
  }
3660
- function clearCoveredFlagsOfTopLeftCell(physicalRow, physicalColumn) {
3800
+ function clearCoveredFlagsOfTopLeftCell(physicalRow, physicalColumn, wasInMerge = false) {
3661
3801
  const metaManager = this.hot._getMetaManager();
3662
3802
  const storedMeta = metaManager.getCellMetaIfExists(physicalRow, physicalColumn);
3663
- if (!storedMeta || !(0, _object.hasOwnProperty)(storedMeta, 'hidden')) {
3803
+ const hasMark = !!storedMeta && (0, _object.hasOwnProperty)(storedMeta, 'hidden');
3804
+ if (!storedMeta || !wasInMerge && !hasMark) {
3664
3805
  return;
3665
3806
  }
3666
- metaManager.removeCellMeta(physicalRow, physicalColumn, 'hidden');
3807
+ if (hasMark) {
3808
+ metaManager.removeCellMeta(physicalRow, physicalColumn, 'hidden');
3809
+ }
3667
3810
  // The merge stores `hidden` through `setCellMeta()`, but the hook writes `copyable` straight onto the stored
3668
3811
  // object and never records it. A recorded `copyable` is left alone (a recorded `true` was already overwritten by the hook).
3669
3812
  if (!metaManager.getCellMetaKeyState(physicalRow, physicalColumn, 'copyable').hadOwn) {
@@ -130,6 +130,47 @@ const SHORTCUTS_GROUP = PLUGIN_KEY;
130
130
  */ function isMergeState(value) {
131
131
  return Array.isArray(value);
132
132
  }
133
+ /**
134
+ * Maps the physical cells a captured merge names to another numbering of the rows and columns. A row or
135
+ * column that does not exist there is dropped. The anchor keeps its own column, mapped, or takes the first
136
+ * recorded column that is left when its own does not exist there. A merge with no row or no column left has
137
+ * no anchor.
138
+ *
139
+ * @param {object} entry The captured merge.
140
+ * @param {Function} toIndex Maps a physical index, or answers `null` for one that does not exist there.
141
+ * @returns {object} The merge with its anchor and `physicalColumns` mapped.
142
+ */ function mapRecordedMerge(entry, toIndex) {
143
+ const physicalColumns = entry.physicalColumns?.map((column)=>column === null ? null : toIndex(column, 'column'));
144
+ if (entry.anchor === null) {
145
+ return {
146
+ ...entry,
147
+ physicalColumns
148
+ };
149
+ }
150
+ const physicalRows = entry.anchor.physicalRows.map((row)=>toIndex(row, 'row')).filter((row)=>row !== null);
151
+ const physicalColumn = toIndex(entry.anchor.physicalColumn, 'column') ?? physicalColumns?.find((column)=>column !== null) ?? null;
152
+ return {
153
+ ...entry,
154
+ anchor: physicalRows.length === 0 || physicalColumn === null ? null : {
155
+ physicalRows,
156
+ physicalColumn
157
+ },
158
+ physicalColumns
159
+ };
160
+ }
161
+ /**
162
+ * Returns a key for the physical cells a captured merge names (its anchor rows, its anchor column and its
163
+ * columns), so two merges with the same key name the same cells. A merge with no anchor or no recorded columns
164
+ * has none.
165
+ *
166
+ * @param {object} entry The captured merge.
167
+ * @returns {string | null}
168
+ */ function getFootprintKey(entry) {
169
+ if (entry.anchor === null || entry.physicalColumns === undefined) {
170
+ return null;
171
+ }
172
+ return `${entry.anchor.physicalRows.join(',')}|${entry.anchor.physicalColumn}|${entry.physicalColumns.join(',')}`;
173
+ }
133
174
  /**
134
175
  * Counts how many of the ascending `values` are smaller than `value`.
135
176
  *
@@ -438,12 +479,49 @@ var /**
438
479
  * restored side does not. `restoreState()` runs after UndoRedo restored the index maps, so the visual columns
439
480
  * of a live merge name the wrong physical columns and a set built from them cannot see the cell a redo takes
440
481
  * out of a merge. The recorded merges carry their physical columns, so the two sides are compared by those.
441
- * A cell the restored side's changed merges cover is left alone. One an unchanged merge covers may be
442
- * cleaned, and `afterGetCellMeta` stores the flags again on the next read.
482
+ * A cell the restored side's changed merges cover keeps what they put on it. The cell one of them is drawn
483
+ * from loses `hidden` and `copyable` and keeps its span keys, because `afterGetCellMeta` never writes
484
+ * `copyable` back on a top-left. A covered cell a merge of the other side was drawn from loses its span keys
485
+ * and keeps its covered flags, because the hook never takes a span off a covered cell. One an unchanged merge
486
+ * covers may be cleaned, and `afterGetCellMeta` stores the flags again on the next read.
487
+ *
488
+ * The span keys go too, and neither removal waits for the `hidden` or `spanned` mark. The merge stored both
489
+ * marks through `setCellMeta()`, so on the undo of a merge the UndoRedo journal has already taken them back,
490
+ * while the `copyable`, `rowspan` and `colspan` the hook wrote are not in the journal. The recorded other side
491
+ * is the proof that a merge covered the cell. A recorded `copyable`, `rowspan` or `colspan` still stays.
443
492
  *
444
493
  * @param {Array} state The merges on the restored side of the step.
445
494
  * @param {Array} other The merges on the other side of the step.
446
495
  */ _clearCoveredFlagsOfCellsReleasedByStep = /*#__PURE__*/ new WeakSet(), /**
496
+ * Does what {@link MergeCells#clearCoveredFlagsOfCellsReleasedByStep} does, after a replay that inserted or
497
+ * removed rows or columns. The physical indexes the other side records are numbered like the grid before that
498
+ * replay, so each merge's anchor rows and recorded columns are first mapped to the restored grid through the
499
+ * rows and columns the step inserted or removed. Neither the live merges nor their visual columns can stand in:
500
+ * the replay runs in the physical order and the column order is restored before this runs. A merge whose
501
+ * mapped cells equal those of a restored merge is one the step left alone, and both are left out.
502
+ *
503
+ * @param {Array} state The merges on the restored side of the step.
504
+ * @param {Array} other The merges on the other side of the step.
505
+ * @param {Function} toRestoredIndex Maps a physical index of `other` to the restored grid.
506
+ */ _clearMergeKeysOfCellsReleasedByReplay = /*#__PURE__*/ new WeakSet(), /**
507
+ * Removes the merge keys from cells a merge covered on the other side of an undo step. A cell the restored
508
+ * side covers keeps what its merge put on it, except the cell a restored merge is drawn from: it loses `hidden`
509
+ * and `copyable` and keeps its span keys, because `afterGetCellMeta` never writes `copyable` back on a top-left.
510
+ * A covered cell a merge of the other side was drawn from loses its span keys and keeps its covered flags,
511
+ * because the hook never takes a span off a covered cell. Neither removal waits for the `hidden` or `spanned`
512
+ * mark (see {@link MergeCells#clearCoveredFlagsOfCellsReleasedByStep}).
513
+ *
514
+ * @param {Set<number>} released The cells a merge covered on the other side of the step.
515
+ * @param {Set<number>} leftTopLefts The cells the merges of the other side were drawn from.
516
+ * @param {Set<number>} covered The cells the restored merges cover.
517
+ * @param {Set<number>} restoredTopLefts The cells the restored merges are drawn from.
518
+ */ _clearMergeKeysOfReleasedCells = /*#__PURE__*/ new WeakSet(), /**
519
+ * Collects the physical cell each recorded merge is drawn from (`#getTopLeftPhysicalRow()` in the anchor's
520
+ * column). A merge with no anchor, or with no visible top-left, is left out.
521
+ *
522
+ * @param {Array} entries The recorded merges.
523
+ * @returns {Set<number>} The cells, packed as `physicalRow * DRAWN_CELL_COLUMN_STRIDE + physicalColumn`.
524
+ */ _collectRecordedTopLeftCells = /*#__PURE__*/ new WeakSet(), /**
447
525
  * Takes out the live merges the step made and puts back the ones it took, leaving every other live
448
526
  * merge alone.
449
527
  *
@@ -823,8 +901,12 @@ var /**
823
901
  * applies it again on the next read.
824
902
  * The meta is removed through the meta manager, by physical index and without the remove-meta hooks.
825
903
  *
904
+ * A caller that knows from a recorded undo step that a merge covered the cell skips the `spanned` check: the
905
+ * UndoRedo journal takes `spanned` back before `restoreState()` runs, and it never held `rowspan` or `colspan`.
906
+ *
826
907
  * @param {number} physicalRow The physical row of the cell.
827
908
  * @param {number} physicalColumn The physical column of the cell.
909
+ * @param {boolean} [wasInMerge=false] `true` when a recorded undo step shows that a merge covered the cell.
828
910
  */ _clearSpanKeysOfCell = /*#__PURE__*/ new WeakSet(), /**
829
911
  * Returns the physical cell a merge is drawn from, packed into one number, or `null` when none is: every
830
912
  * row of the merge is trimmed, or its column is. It is the first row of the merge's anchor that has
@@ -887,8 +969,12 @@ var /**
887
969
  * The meta is removed through the meta manager, by physical index and without the remove-meta hooks.
888
970
  * The check costs one meta lookup per merge and no lookup in the merge collection.
889
971
  *
972
+ * A caller that knows from a recorded undo step that a merge covered the cell skips the `hidden` check: the
973
+ * UndoRedo journal takes `hidden` back before `restoreState()` runs, and it never held `copyable`.
974
+ *
890
975
  * @param {number} physicalRow The physical row of the cell the merge is drawn from.
891
976
  * @param {number} physicalColumn The physical column of the cell the merge is drawn from.
977
+ * @param {boolean} [wasInMerge=false] `true` when a recorded undo step shows that a merge covered the cell.
892
978
  */ _clearCoveredFlagsOfTopLeftCell = /*#__PURE__*/ new WeakSet(), /**
893
979
  * The area highlight was committed for the old merges. The next view render recomputes it once,
894
980
  * before this draw paints. Selection-change hooks do not run. `afterIsMultipleSelection` does,
@@ -1913,9 +1999,10 @@ var /**
1913
1999
  return;
1914
2000
  }
1915
2001
  const other = context?.other;
2002
+ const isReplayed = context?.reordered === true;
1916
2003
  // The restore replaces merges, and a step can leave the cell a merge was drawn from in no merge.
1917
2004
  const drawnFromBefore = _class_private_method_get(this, _snapshotDrawnFromCells, snapshotDrawnFromCells).call(this);
1918
- if (!isMergeState(other) || context?.reordered === true || !_class_private_method_get(this, _restoreChangedMerges, restoreChangedMerges).call(this, state, other)) {
2005
+ if (!isMergeState(other) || isReplayed || !_class_private_method_get(this, _restoreChangedMerges, restoreChangedMerges).call(this, state, other)) {
1919
2006
  this.mergedCellsCollection.clear();
1920
2007
  _class_private_field_set(this, _mergeAnchors, new WeakMap());
1921
2008
  _class_private_field_set(this, _purgedMerges, new WeakSet());
@@ -1923,9 +2010,11 @@ var /**
1923
2010
  }
1924
2011
  _class_private_method_get(this, _reanchorMergesToVisibleRows, reanchorMergesToVisibleRows).call(this);
1925
2012
  _class_private_method_get(this, _clearSpanKeysOfCellsNoLongerDrawnFrom, clearSpanKeysOfCellsNoLongerDrawnFrom).call(this, drawnFromBefore);
1926
- // A replay that inserted or removed columns renumbered the physical indexes the recorded merges name.
1927
- if (isMergeState(other) && context?.reordered !== true) {
2013
+ if (isMergeState(other) && !isReplayed) {
1928
2014
  _class_private_method_get(this, _clearCoveredFlagsOfCellsReleasedByStep, clearCoveredFlagsOfCellsReleasedByStep).call(this, state, other);
2015
+ } else if (isMergeState(other) && context?.toRestoredIndex) {
2016
+ // A replay that inserted or removed rows or columns renumbered the physical indexes the other side records.
2017
+ _class_private_method_get(this, _clearMergeKeysOfCellsReleasedByReplay, clearMergeKeysOfCellsReleasedByReplay).call(this, state, other, context.toRestoredIndex);
1929
2018
  }
1930
2019
  this.hot.markAllCellsChanged();
1931
2020
  }
@@ -2137,7 +2226,7 @@ var /**
2137
2226
  ];
2138
2227
  }
2139
2228
  constructor(...args){
2140
- super(...args), _class_private_method_init(this, _takeKeptMerges), _class_private_method_init(this, _hasGrownArea), _class_private_method_init(this, _keepAreasReachingKeptMerges), _class_private_method_init(this, _adoptRecreatedMerges), _class_private_method_init(this, _hasGrownPastArea), _class_private_method_init(this, _restoreKeptMerges), _class_private_method_init(this, _getAnchorFootprint), _class_private_method_init(this, _getStoredValueAt), _class_private_method_init(this, _getCellDrawnOn), _class_private_method_init(this, _restoreAnchoredArea), _class_private_method_init(this, _placeAnchoredArea), _class_private_method_init(this, _canMergeSelection), _class_private_method_init(this, _describeMerge), _class_private_method_init(this, _mergeRange), _class_private_method_init(this, _removeRefusedMergeMeta), _class_private_method_init(this, _resetMergedCellMeta), _class_private_method_init(this, _getLeftColumnKeys), _class_private_method_init(this, _collectForeignDrawnRows), _class_private_method_init(this, _clearRowsLeftBehind), _class_private_method_init(this, _getDrawnPhysicalRows), _class_private_method_init(this, _getCellMetaRemover), _class_private_method_init(this, _matchesMerges), _class_private_method_init(this, _collectRecordedCoveredCells), _class_private_method_init(this, _clearCoveredFlagsOfCellsReleasedByStep), _class_private_method_init(this, _restoreChangedMerges), _class_private_method_init(this, _addRecordedMerge), _class_private_method_init(this, _hasVisibleTopLeft), _class_private_method_init(this, _getTopLeftPhysicalRow), _class_private_method_init(this, _unmergeRange), _class_private_method_init(this, _captureAnchorOf), _class_private_method_init(this, _fillTrimmedGaps), _class_private_method_init(this, _getRowsOwnedBesides), _class_private_method_init(this, _captureMergeAnchors), _class_private_method_init(this, _captureMissingMergeAnchors), _class_private_method_init(this, _remapRowAnchorsAfterInsert), _class_private_method_init(this, _remapRowAnchorsAfterRemove), _class_private_method_init(this, _dropMergesWithoutRows), _class_private_method_init(this, _remapAnchors), _class_private_method_init(this, _buildRowSequencePositions), _class_private_method_init(this, _groupRowsBySequenceRuns), _class_private_method_init(this, _attributeTrimmedRows), _class_private_method_init(this, _describesOwnRows), _class_private_method_init(this, _countVisualRuns), _class_private_method_init(this, _planRowMoveTranslation), _class_private_method_init(this, _planColumnMoveRetention), _class_private_method_init(this, _carrierRowsOf), _class_private_method_init(this, _reanchorFragmentsAfterSplit), _class_private_method_init(this, _transferAnchorsAfterAxisMove), _class_private_method_init(this, _sortVisibleRowsByVisualOrder), _class_private_method_init(this, _isRowTrimmingActive), _class_private_method_init(this, _reanchorMergesToVisibleRows), _class_private_method_init(this, _settleMergesAfterAxisMove), _class_private_method_init(this, _cleanReleasedCells), _class_private_method_init(this, _clearReleasedCell), _class_private_method_init(this, _clearSpanKeysOfCell), _class_private_method_init(this, _getDrawnFromCellKey), _class_private_method_init(this, _snapshotDrawnFromCells), _class_private_method_init(this, _isOutsideMoveWindow), _class_private_method_init(this, _snapshotCoveredCells), _class_private_method_init(this, _clearCoveredFlagsOfCellsNoLongerCovered), _class_private_method_init(this, _clearSpanKeysOfCellsNoLongerDrawnFrom), _class_private_method_init(this, _clearCoveredFlagsOfTopLeftCell), _class_private_method_init(this, _recommitSelectionHighlight), _class_private_method_init(this, _captureDrawnFromBeforeMove), _class_private_method_init(this, _getMoveWindow), _class_private_method_init(this, _resetPasteState), _class_private_method_init(this, _mergeAtChange), _class_private_method_init(this, _collectMergesFromChanges), _class_private_method_init(this, _discardChangesOnCoveredCells), _class_private_method_init(this, _unmergeAfterPaste), _class_private_method_init(this, _markBlocksCrossingFrozenColumnsChanged), _class_private_method_init(this, _getFirstRenderedColumnOfTable), _class_private_method_init(this, _getSpanCarrierRow), _class_private_field_init(this, _cellBlockProvider, {
2229
+ super(...args), _class_private_method_init(this, _takeKeptMerges), _class_private_method_init(this, _hasGrownArea), _class_private_method_init(this, _keepAreasReachingKeptMerges), _class_private_method_init(this, _adoptRecreatedMerges), _class_private_method_init(this, _hasGrownPastArea), _class_private_method_init(this, _restoreKeptMerges), _class_private_method_init(this, _getAnchorFootprint), _class_private_method_init(this, _getStoredValueAt), _class_private_method_init(this, _getCellDrawnOn), _class_private_method_init(this, _restoreAnchoredArea), _class_private_method_init(this, _placeAnchoredArea), _class_private_method_init(this, _canMergeSelection), _class_private_method_init(this, _describeMerge), _class_private_method_init(this, _mergeRange), _class_private_method_init(this, _removeRefusedMergeMeta), _class_private_method_init(this, _resetMergedCellMeta), _class_private_method_init(this, _getLeftColumnKeys), _class_private_method_init(this, _collectForeignDrawnRows), _class_private_method_init(this, _clearRowsLeftBehind), _class_private_method_init(this, _getDrawnPhysicalRows), _class_private_method_init(this, _getCellMetaRemover), _class_private_method_init(this, _matchesMerges), _class_private_method_init(this, _collectRecordedCoveredCells), _class_private_method_init(this, _clearCoveredFlagsOfCellsReleasedByStep), _class_private_method_init(this, _clearMergeKeysOfCellsReleasedByReplay), _class_private_method_init(this, _clearMergeKeysOfReleasedCells), _class_private_method_init(this, _collectRecordedTopLeftCells), _class_private_method_init(this, _restoreChangedMerges), _class_private_method_init(this, _addRecordedMerge), _class_private_method_init(this, _hasVisibleTopLeft), _class_private_method_init(this, _getTopLeftPhysicalRow), _class_private_method_init(this, _unmergeRange), _class_private_method_init(this, _captureAnchorOf), _class_private_method_init(this, _fillTrimmedGaps), _class_private_method_init(this, _getRowsOwnedBesides), _class_private_method_init(this, _captureMergeAnchors), _class_private_method_init(this, _captureMissingMergeAnchors), _class_private_method_init(this, _remapRowAnchorsAfterInsert), _class_private_method_init(this, _remapRowAnchorsAfterRemove), _class_private_method_init(this, _dropMergesWithoutRows), _class_private_method_init(this, _remapAnchors), _class_private_method_init(this, _buildRowSequencePositions), _class_private_method_init(this, _groupRowsBySequenceRuns), _class_private_method_init(this, _attributeTrimmedRows), _class_private_method_init(this, _describesOwnRows), _class_private_method_init(this, _countVisualRuns), _class_private_method_init(this, _planRowMoveTranslation), _class_private_method_init(this, _planColumnMoveRetention), _class_private_method_init(this, _carrierRowsOf), _class_private_method_init(this, _reanchorFragmentsAfterSplit), _class_private_method_init(this, _transferAnchorsAfterAxisMove), _class_private_method_init(this, _sortVisibleRowsByVisualOrder), _class_private_method_init(this, _isRowTrimmingActive), _class_private_method_init(this, _reanchorMergesToVisibleRows), _class_private_method_init(this, _settleMergesAfterAxisMove), _class_private_method_init(this, _cleanReleasedCells), _class_private_method_init(this, _clearReleasedCell), _class_private_method_init(this, _clearSpanKeysOfCell), _class_private_method_init(this, _getDrawnFromCellKey), _class_private_method_init(this, _snapshotDrawnFromCells), _class_private_method_init(this, _isOutsideMoveWindow), _class_private_method_init(this, _snapshotCoveredCells), _class_private_method_init(this, _clearCoveredFlagsOfCellsNoLongerCovered), _class_private_method_init(this, _clearSpanKeysOfCellsNoLongerDrawnFrom), _class_private_method_init(this, _clearCoveredFlagsOfTopLeftCell), _class_private_method_init(this, _recommitSelectionHighlight), _class_private_method_init(this, _captureDrawnFromBeforeMove), _class_private_method_init(this, _getMoveWindow), _class_private_method_init(this, _resetPasteState), _class_private_method_init(this, _mergeAtChange), _class_private_method_init(this, _collectMergesFromChanges), _class_private_method_init(this, _discardChangesOnCoveredCells), _class_private_method_init(this, _unmergeAfterPaste), _class_private_method_init(this, _markBlocksCrossingFrozenColumnsChanged), _class_private_method_init(this, _getFirstRenderedColumnOfTable), _class_private_method_init(this, _getSpanCarrierRow), _class_private_field_init(this, _cellBlockProvider, {
2141
2230
  writable: true,
2142
2231
  value: void 0
2143
2232
  }), _class_private_field_init(this, _cellRenderer, {
@@ -3049,13 +3138,61 @@ function clearCoveredFlagsOfCellsReleasedByStep(state, other) {
3049
3138
  if (left.length === 0) {
3050
3139
  return;
3051
3140
  }
3052
- const covered = _class_private_method_get(this, _collectRecordedCoveredCells, collectRecordedCoveredCells).call(this, state.filter((entry)=>!isMergeListed(other, entry)));
3053
- _class_private_method_get(this, _collectRecordedCoveredCells, collectRecordedCoveredCells).call(this, left).forEach((key)=>{
3054
- if (covered.has(key)) {
3141
+ const restored = state.filter((entry)=>!isMergeListed(other, entry));
3142
+ _class_private_method_get(this, _clearMergeKeysOfReleasedCells, clearMergeKeysOfReleasedCells).call(this, _class_private_method_get(this, _collectRecordedCoveredCells, collectRecordedCoveredCells).call(this, left), _class_private_method_get(this, _collectRecordedTopLeftCells, collectRecordedTopLeftCells).call(this, left), _class_private_method_get(this, _collectRecordedCoveredCells, collectRecordedCoveredCells).call(this, restored), _class_private_method_get(this, _collectRecordedTopLeftCells, collectRecordedTopLeftCells).call(this, restored));
3143
+ }
3144
+ function clearMergeKeysOfCellsReleasedByReplay(state, other, toRestoredIndex) {
3145
+ const mapped = other.map((entry)=>{
3146
+ const mappedEntry = mapRecordedMerge(entry, toRestoredIndex);
3147
+ // A merge that lost a row or a column to the mapping covered a cell the restored grid lacks, so it is
3148
+ // not the same merge as one of the restored side with the cells that are left.
3149
+ const isWhole = mappedEntry.anchor?.physicalRows.length === entry.anchor?.physicalRows.length && !mappedEntry.physicalColumns?.includes(null);
3150
+ return {
3151
+ entry: mappedEntry,
3152
+ key: isWhole ? getFootprintKey(mappedEntry) : null
3153
+ };
3154
+ });
3155
+ const restoredKeys = new Set(state.map(getFootprintKey));
3156
+ const left = mapped.filter(({ key })=>key === null || !restoredKeys.has(key)).map(({ entry })=>entry);
3157
+ if (left.length === 0) {
3158
+ return;
3159
+ }
3160
+ const mappedKeys = new Set(mapped.map(({ key })=>key));
3161
+ const restored = state.filter((entry)=>{
3162
+ const key = getFootprintKey(entry);
3163
+ return key === null || !mappedKeys.has(key);
3164
+ });
3165
+ _class_private_method_get(this, _clearMergeKeysOfReleasedCells, clearMergeKeysOfReleasedCells).call(this, _class_private_method_get(this, _collectRecordedCoveredCells, collectRecordedCoveredCells).call(this, left), _class_private_method_get(this, _collectRecordedTopLeftCells, collectRecordedTopLeftCells).call(this, left), _class_private_method_get(this, _collectRecordedCoveredCells, collectRecordedCoveredCells).call(this, restored), _class_private_method_get(this, _collectRecordedTopLeftCells, collectRecordedTopLeftCells).call(this, restored));
3166
+ }
3167
+ function clearMergeKeysOfReleasedCells(released, leftTopLefts, covered, restoredTopLefts) {
3168
+ released.forEach((key)=>{
3169
+ const isRestoredTopLeft = restoredTopLefts.has(key);
3170
+ const isCovered = covered.has(key);
3171
+ // A restored merge drawn from the cell keeps its span keys; one that covers it keeps its covered flags.
3172
+ const clearsCoveredFlags = !isCovered || isRestoredTopLeft;
3173
+ const clearsSpanKeys = !isRestoredTopLeft && (!isCovered || leftTopLefts.has(key));
3174
+ if (!clearsCoveredFlags && !clearsSpanKeys) {
3055
3175
  return;
3056
3176
  }
3057
- _class_private_method_get(this, _clearCoveredFlagsOfTopLeftCell, clearCoveredFlagsOfTopLeftCell).call(this, Math.trunc(key / DRAWN_CELL_COLUMN_STRIDE), key % DRAWN_CELL_COLUMN_STRIDE);
3177
+ const physicalRow = Math.trunc(key / DRAWN_CELL_COLUMN_STRIDE);
3178
+ const physicalColumn = key % DRAWN_CELL_COLUMN_STRIDE;
3179
+ if (clearsCoveredFlags) {
3180
+ _class_private_method_get(this, _clearCoveredFlagsOfTopLeftCell, clearCoveredFlagsOfTopLeftCell).call(this, physicalRow, physicalColumn, true);
3181
+ }
3182
+ if (clearsSpanKeys) {
3183
+ _class_private_method_get(this, _clearSpanKeysOfCell, clearSpanKeysOfCell).call(this, physicalRow, physicalColumn, true);
3184
+ }
3185
+ });
3186
+ }
3187
+ function collectRecordedTopLeftCells(entries) {
3188
+ const cells = new Set();
3189
+ entries.forEach(({ anchor })=>{
3190
+ const physicalRow = anchor === null ? null : _class_private_method_get(this, _getTopLeftPhysicalRow, getTopLeftPhysicalRow).call(this, anchor);
3191
+ if (anchor !== null && physicalRow !== null) {
3192
+ cells.add(physicalRow * DRAWN_CELL_COLUMN_STRIDE + anchor.physicalColumn);
3193
+ }
3058
3194
  });
3195
+ return cells;
3059
3196
  }
3060
3197
  function restoreChangedMerges(target, from) {
3061
3198
  const liveToRemove = from.filter((entry)=>!isMergeListed(target, entry)).map((entry)=>this.mergedCellsCollection.mergedCells.find((merge)=>merge.row === entry.row && merge.col === entry.col && merge.rowspan === entry.rowspan && merge.colspan === entry.colspan && areAnchorsEqual(entry.anchor, _class_private_field_get(this, _mergeAnchors).get(merge))));
@@ -3589,13 +3726,16 @@ function clearReleasedCell(physicalRow, physicalColumn) {
3589
3726
  _class_private_method_get(this, _clearSpanKeysOfCell, clearSpanKeysOfCell).call(this, physicalRow, physicalColumn);
3590
3727
  }
3591
3728
  }
3592
- function clearSpanKeysOfCell(physicalRow, physicalColumn) {
3729
+ function clearSpanKeysOfCell(physicalRow, physicalColumn, wasInMerge = false) {
3593
3730
  const metaManager = this.hot._getMetaManager();
3594
3731
  const storedMeta = metaManager.getCellMetaIfExists(physicalRow, physicalColumn);
3595
- if (!storedMeta || !hasOwnProperty(storedMeta, 'spanned')) {
3732
+ const hasMark = !!storedMeta && hasOwnProperty(storedMeta, 'spanned');
3733
+ if (!storedMeta || !wasInMerge && !hasMark) {
3596
3734
  return;
3597
3735
  }
3598
- metaManager.removeCellMeta(physicalRow, physicalColumn, 'spanned');
3736
+ if (hasMark) {
3737
+ metaManager.removeCellMeta(physicalRow, physicalColumn, 'spanned');
3738
+ }
3599
3739
  [
3600
3740
  'rowspan',
3601
3741
  'colspan'
@@ -3683,13 +3823,16 @@ function clearSpanKeysOfCellsNoLongerDrawnFrom(before) {
3683
3823
  }
3684
3824
  });
3685
3825
  }
3686
- function clearCoveredFlagsOfTopLeftCell(physicalRow, physicalColumn) {
3826
+ function clearCoveredFlagsOfTopLeftCell(physicalRow, physicalColumn, wasInMerge = false) {
3687
3827
  const metaManager = this.hot._getMetaManager();
3688
3828
  const storedMeta = metaManager.getCellMetaIfExists(physicalRow, physicalColumn);
3689
- if (!storedMeta || !hasOwnProperty(storedMeta, 'hidden')) {
3829
+ const hasMark = !!storedMeta && hasOwnProperty(storedMeta, 'hidden');
3830
+ if (!storedMeta || !wasInMerge && !hasMark) {
3690
3831
  return;
3691
3832
  }
3692
- metaManager.removeCellMeta(physicalRow, physicalColumn, 'hidden');
3833
+ if (hasMark) {
3834
+ metaManager.removeCellMeta(physicalRow, physicalColumn, 'hidden');
3835
+ }
3693
3836
  // The merge stores `hidden` through `setCellMeta()`, but the hook writes `copyable` straight onto the stored
3694
3837
  // object and never records it. A recorded `copyable` is left alone (a recorded `true` was already overwritten by the hook).
3695
3838
  if (!metaManager.getCellMetaKeyState(physicalRow, physicalColumn, 'copyable').hadOwn) {
@@ -14,7 +14,6 @@ const LICENSE = Object.freeze({
14
14
  name: 'Move cells',
15
15
  gate: 'enable',
16
16
  tiers: Object.freeze([
17
- 'standard',
18
17
  'professional'
19
18
  ])
20
19
  });
@@ -6,7 +6,6 @@ export const LICENSE = Object.freeze({
6
6
  name: 'Move cells',
7
7
  gate: 'enable',
8
8
  tiers: Object.freeze([
9
- 'standard',
10
9
  'professional'
11
10
  ])
12
11
  });
@@ -14,7 +14,6 @@ const LICENSE = Object.freeze({
14
14
  name: 'Multi-column sorting',
15
15
  gate: 'enable',
16
16
  tiers: Object.freeze([
17
- 'standard',
18
17
  'professional'
19
18
  ])
20
19
  });
@@ -6,7 +6,6 @@ export const LICENSE = Object.freeze({
6
6
  name: 'Multi-column sorting',
7
7
  gate: 'enable',
8
8
  tiers: Object.freeze([
9
- 'standard',
10
9
  'professional'
11
10
  ])
12
11
  });
@@ -14,7 +14,6 @@ const LICENSE = Object.freeze({
14
14
  name: 'Nested headers',
15
15
  gate: 'enable',
16
16
  tiers: Object.freeze([
17
- 'standard',
18
17
  'professional'
19
18
  ])
20
19
  });
@@ -6,7 +6,6 @@ export const LICENSE = Object.freeze({
6
6
  name: 'Nested headers',
7
7
  gate: 'enable',
8
8
  tiers: Object.freeze([
9
- 'standard',
10
9
  'professional'
11
10
  ])
12
11
  });
@@ -14,7 +14,6 @@ const LICENSE = Object.freeze({
14
14
  name: 'Nested rows',
15
15
  gate: 'enable',
16
16
  tiers: Object.freeze([
17
- 'standard',
18
17
  'professional'
19
18
  ])
20
19
  });