handsontable 0.0.0-next-6d7bdba-20230620 → 0.0.0-next-06a64be-20230621

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 (281) hide show
  1. package/3rdparty/walkontable/src/{selection/border/border.js → border.js} +12 -7
  2. package/3rdparty/walkontable/src/{selection/border/border.mjs → border.mjs} +12 -7
  3. package/3rdparty/walkontable/src/cell/coords.d.ts +1 -6
  4. package/3rdparty/walkontable/src/cell/coords.js +12 -61
  5. package/3rdparty/walkontable/src/cell/coords.mjs +12 -61
  6. package/3rdparty/walkontable/src/cell/range.d.ts +2 -9
  7. package/3rdparty/walkontable/src/cell/range.js +7 -44
  8. package/3rdparty/walkontable/src/cell/range.mjs +7 -44
  9. package/3rdparty/walkontable/src/core/_base.js +3 -9
  10. package/3rdparty/walkontable/src/core/_base.mjs +3 -9
  11. package/3rdparty/walkontable/src/core/clone.js +2 -2
  12. package/3rdparty/walkontable/src/core/clone.mjs +2 -2
  13. package/3rdparty/walkontable/src/core/core.js +2 -3
  14. package/3rdparty/walkontable/src/core/core.mjs +2 -3
  15. package/3rdparty/walkontable/src/event.js +7 -7
  16. package/3rdparty/walkontable/src/event.mjs +7 -7
  17. package/3rdparty/walkontable/src/facade/core.js +2 -2
  18. package/3rdparty/walkontable/src/facade/core.mjs +2 -2
  19. package/3rdparty/walkontable/src/index.js +2 -10
  20. package/3rdparty/walkontable/src/index.mjs +2 -2
  21. package/3rdparty/walkontable/src/overlay/_base.js +1 -1
  22. package/3rdparty/walkontable/src/overlay/_base.mjs +1 -1
  23. package/3rdparty/walkontable/src/overlay/inlineStart.js +4 -2
  24. package/3rdparty/walkontable/src/overlay/inlineStart.mjs +4 -2
  25. package/3rdparty/walkontable/src/overlay/top.js +4 -2
  26. package/3rdparty/walkontable/src/overlay/top.mjs +4 -2
  27. package/3rdparty/walkontable/src/selection.js +355 -0
  28. package/3rdparty/walkontable/src/selection.mjs +349 -0
  29. package/3rdparty/walkontable/src/table/mixin/calculatedColumns.js +0 -9
  30. package/3rdparty/walkontable/src/table/mixin/calculatedColumns.mjs +0 -9
  31. package/3rdparty/walkontable/src/table/mixin/calculatedRows.js +0 -9
  32. package/3rdparty/walkontable/src/table/mixin/calculatedRows.mjs +0 -9
  33. package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.js +0 -9
  34. package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.mjs +0 -9
  35. package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.js +0 -9
  36. package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.mjs +0 -9
  37. package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.js +0 -9
  38. package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.mjs +0 -9
  39. package/3rdparty/walkontable/src/table.js +79 -7
  40. package/3rdparty/walkontable/src/table.mjs +80 -8
  41. package/base.js +2 -2
  42. package/base.mjs +2 -2
  43. package/core.d.ts +3 -5
  44. package/core.js +309 -127
  45. package/core.mjs +309 -127
  46. package/dataMap/metaManager/metaSchema.js +0 -19
  47. package/dataMap/metaManager/metaSchema.mjs +0 -19
  48. package/dist/handsontable.css +3 -8
  49. package/dist/handsontable.full.css +3 -8
  50. package/dist/handsontable.full.js +10685 -13607
  51. package/dist/handsontable.full.min.css +3 -3
  52. package/dist/handsontable.full.min.js +112 -112
  53. package/dist/handsontable.js +13664 -16586
  54. package/dist/handsontable.min.css +3 -3
  55. package/dist/handsontable.min.js +4 -4
  56. package/editorManager.js +94 -21
  57. package/editorManager.mjs +98 -26
  58. package/editors/textEditor/textEditor.js +11 -3
  59. package/editors/textEditor/textEditor.mjs +12 -4
  60. package/helpers/mixed.js +1 -1
  61. package/helpers/mixed.mjs +1 -1
  62. package/helpers/number.d.ts +0 -1
  63. package/helpers/number.js +0 -18
  64. package/helpers/number.mjs +0 -17
  65. package/package.json +1 -1
  66. package/pluginHooks.d.ts +1 -5
  67. package/pluginHooks.js +1 -89
  68. package/pluginHooks.mjs +1 -89
  69. package/plugins/collapsibleColumns/collapsibleColumns.js +24 -81
  70. package/plugins/collapsibleColumns/collapsibleColumns.mjs +24 -81
  71. package/plugins/columnSorting/columnSorting.js +8 -50
  72. package/plugins/columnSorting/columnSorting.mjs +9 -49
  73. package/plugins/columnSorting/index.js +2 -4
  74. package/plugins/columnSorting/index.mjs +1 -1
  75. package/plugins/comments/comments.js +4 -11
  76. package/plugins/comments/comments.mjs +4 -11
  77. package/plugins/contextMenu/contextMenu.d.ts +1 -1
  78. package/plugins/contextMenu/contextMenu.js +29 -80
  79. package/plugins/contextMenu/contextMenu.mjs +30 -81
  80. package/plugins/contextMenu/predefinedItems/alignment.js +0 -7
  81. package/plugins/contextMenu/predefinedItems/alignment.mjs +0 -7
  82. package/plugins/contextMenu/predefinedItems/clearColumn.js +3 -5
  83. package/plugins/contextMenu/predefinedItems/clearColumn.mjs +3 -5
  84. package/plugins/contextMenu/predefinedItems/columnLeft.js +3 -5
  85. package/plugins/contextMenu/predefinedItems/columnLeft.mjs +3 -5
  86. package/plugins/contextMenu/predefinedItems/columnRight.js +3 -5
  87. package/plugins/contextMenu/predefinedItems/columnRight.mjs +3 -5
  88. package/plugins/contextMenu/predefinedItems/readOnly.js +0 -7
  89. package/plugins/contextMenu/predefinedItems/readOnly.mjs +0 -7
  90. package/plugins/contextMenu/predefinedItems/removeColumn.js +5 -7
  91. package/plugins/contextMenu/predefinedItems/removeColumn.mjs +3 -5
  92. package/plugins/contextMenu/predefinedItems/removeRow.js +5 -7
  93. package/plugins/contextMenu/predefinedItems/removeRow.mjs +3 -5
  94. package/plugins/contextMenu/predefinedItems/rowAbove.js +3 -5
  95. package/plugins/contextMenu/predefinedItems/rowAbove.mjs +3 -5
  96. package/plugins/contextMenu/predefinedItems/rowBelow.js +3 -5
  97. package/plugins/contextMenu/predefinedItems/rowBelow.mjs +3 -5
  98. package/plugins/contextMenu/utils.js +16 -25
  99. package/plugins/contextMenu/utils.mjs +15 -24
  100. package/plugins/copyPaste/contextMenuItem/copy.js +0 -7
  101. package/plugins/copyPaste/contextMenuItem/copy.mjs +0 -7
  102. package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.js +1 -9
  103. package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.mjs +1 -9
  104. package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.js +1 -9
  105. package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.mjs +1 -9
  106. package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.js +1 -9
  107. package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.mjs +1 -9
  108. package/plugins/copyPaste/contextMenuItem/cut.js +0 -7
  109. package/plugins/copyPaste/contextMenuItem/cut.mjs +0 -7
  110. package/plugins/copyPaste/copyPaste.js +1 -5
  111. package/plugins/copyPaste/copyPaste.mjs +1 -5
  112. package/plugins/customBorders/customBorders.js +53 -25
  113. package/plugins/customBorders/customBorders.mjs +54 -26
  114. package/plugins/dropdownMenu/dropdownMenu.d.ts +1 -1
  115. package/plugins/dropdownMenu/dropdownMenu.js +30 -94
  116. package/plugins/dropdownMenu/dropdownMenu.mjs +30 -94
  117. package/plugins/manualColumnResize/manualColumnResize.js +36 -5
  118. package/plugins/manualColumnResize/manualColumnResize.mjs +36 -5
  119. package/plugins/manualRowResize/manualRowResize.js +40 -9
  120. package/plugins/manualRowResize/manualRowResize.mjs +40 -9
  121. package/plugins/mergeCells/mergeCells.js +18 -5
  122. package/plugins/mergeCells/mergeCells.mjs +18 -5
  123. package/plugins/multiColumnSorting/multiColumnSorting.js +3 -42
  124. package/plugins/multiColumnSorting/multiColumnSorting.mjs +3 -42
  125. package/plugins/nestedHeaders/nestedHeaders.js +10 -132
  126. package/plugins/nestedHeaders/nestedHeaders.mjs +10 -132
  127. package/plugins/nestedHeaders/stateManager/index.js +0 -37
  128. package/plugins/nestedHeaders/stateManager/index.mjs +0 -37
  129. package/plugins/nestedRows/nestedRows.js +7 -52
  130. package/plugins/nestedRows/nestedRows.mjs +7 -52
  131. package/renderers/checkboxRenderer/checkboxRenderer.js +2 -2
  132. package/renderers/checkboxRenderer/checkboxRenderer.mjs +1 -1
  133. package/selection/highlight/constants.js +16 -0
  134. package/selection/highlight/constants.mjs +6 -0
  135. package/selection/highlight/highlight.js +89 -312
  136. package/selection/highlight/highlight.mjs +85 -302
  137. package/selection/highlight/types/activeHeader.js +9 -10
  138. package/selection/highlight/types/activeHeader.mjs +8 -10
  139. package/selection/highlight/types/area.js +27 -12
  140. package/selection/highlight/types/area.mjs +30 -16
  141. package/selection/highlight/types/{focus.js → cell.js} +8 -5
  142. package/selection/highlight/types/{focus.mjs → cell.mjs} +7 -5
  143. package/selection/highlight/types/customSelection.js +10 -7
  144. package/selection/highlight/types/customSelection.mjs +9 -7
  145. package/selection/highlight/types/fill.js +8 -5
  146. package/selection/highlight/types/fill.mjs +7 -5
  147. package/selection/highlight/types/header.js +20 -10
  148. package/selection/highlight/types/header.mjs +19 -10
  149. package/selection/highlight/types/{row.js → index.js} +31 -27
  150. package/selection/highlight/types/{row.mjs → index.mjs} +29 -24
  151. package/selection/highlight/visualSelection.js +27 -31
  152. package/selection/highlight/visualSelection.mjs +27 -31
  153. package/selection/index.js +7 -4
  154. package/selection/index.mjs +3 -2
  155. package/selection/mouseEventHandler.js +1 -1
  156. package/selection/mouseEventHandler.mjs +1 -1
  157. package/selection/range.js +8 -8
  158. package/selection/range.mjs +8 -8
  159. package/selection/selection.js +181 -315
  160. package/selection/selection.mjs +180 -310
  161. package/selection/transformation.js +96 -233
  162. package/selection/transformation.mjs +93 -230
  163. package/selection/utils.js +36 -12
  164. package/selection/utils.mjs +36 -13
  165. package/settings.d.ts +0 -1
  166. package/shortcuts/manager.js +0 -2
  167. package/shortcuts/manager.mjs +0 -2
  168. package/shortcuts/recorder.js +2 -2
  169. package/shortcuts/recorder.mjs +2 -2
  170. package/shortcuts/utils.js +5 -21
  171. package/shortcuts/utils.mjs +4 -20
  172. package/tableView.js +9 -58
  173. package/tableView.mjs +9 -58
  174. package/translations/indexMapper.js +9 -8
  175. package/translations/indexMapper.mjs +9 -8
  176. package/3rdparty/walkontable/src/selection/border/constants.js +0 -18
  177. package/3rdparty/walkontable/src/selection/border/constants.mjs +0 -13
  178. package/3rdparty/walkontable/src/selection/constants.js +0 -63
  179. package/3rdparty/walkontable/src/selection/constants.mjs +0 -51
  180. package/3rdparty/walkontable/src/selection/index.js +0 -30
  181. package/3rdparty/walkontable/src/selection/index.mjs +0 -5
  182. package/3rdparty/walkontable/src/selection/manager.js +0 -329
  183. package/3rdparty/walkontable/src/selection/manager.mjs +0 -323
  184. package/3rdparty/walkontable/src/selection/scanner.js +0 -364
  185. package/3rdparty/walkontable/src/selection/scanner.mjs +0 -360
  186. package/3rdparty/walkontable/src/selection/selection.js +0 -133
  187. package/3rdparty/walkontable/src/selection/selection.mjs +0 -127
  188. package/selection/highlight/types/areaLayered.js +0 -54
  189. package/selection/highlight/types/areaLayered.mjs +0 -49
  190. package/selection/highlight/types/column.js +0 -50
  191. package/selection/highlight/types/column.mjs +0 -45
  192. package/shortcutContexts/commands/editor/closeAndSave.js +0 -15
  193. package/shortcutContexts/commands/editor/closeAndSave.mjs +0 -10
  194. package/shortcutContexts/commands/editor/closeWithoutSaving.js +0 -13
  195. package/shortcutContexts/commands/editor/closeWithoutSaving.mjs +0 -8
  196. package/shortcutContexts/commands/editor/fastOpen.js +0 -16
  197. package/shortcutContexts/commands/editor/fastOpen.mjs +0 -11
  198. package/shortcutContexts/commands/editor/index.js +0 -16
  199. package/shortcutContexts/commands/editor/index.mjs +0 -12
  200. package/shortcutContexts/commands/editor/open.js +0 -29
  201. package/shortcutContexts/commands/editor/open.mjs +0 -24
  202. package/shortcutContexts/commands/emptySelectedCells.js +0 -12
  203. package/shortcutContexts/commands/emptySelectedCells.mjs +0 -7
  204. package/shortcutContexts/commands/extendCellsSelection/down.js +0 -15
  205. package/shortcutContexts/commands/extendCellsSelection/down.mjs +0 -10
  206. package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.js +0 -21
  207. package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.mjs +0 -16
  208. package/shortcutContexts/commands/extendCellsSelection/index.js +0 -26
  209. package/shortcutContexts/commands/extendCellsSelection/index.mjs +0 -22
  210. package/shortcutContexts/commands/extendCellsSelection/left.js +0 -15
  211. package/shortcutContexts/commands/extendCellsSelection/left.mjs +0 -10
  212. package/shortcutContexts/commands/extendCellsSelection/right.js +0 -15
  213. package/shortcutContexts/commands/extendCellsSelection/right.mjs +0 -10
  214. package/shortcutContexts/commands/extendCellsSelection/toColumns.js +0 -19
  215. package/shortcutContexts/commands/extendCellsSelection/toColumns.mjs +0 -14
  216. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +0 -22
  217. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +0 -17
  218. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +0 -17
  219. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +0 -12
  220. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +0 -17
  221. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +0 -12
  222. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +0 -40
  223. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +0 -35
  224. package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +0 -40
  225. package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +0 -35
  226. package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +0 -22
  227. package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +0 -17
  228. package/shortcutContexts/commands/extendCellsSelection/toRows.js +0 -19
  229. package/shortcutContexts/commands/extendCellsSelection/toRows.mjs +0 -14
  230. package/shortcutContexts/commands/extendCellsSelection/up.js +0 -15
  231. package/shortcutContexts/commands/extendCellsSelection/up.mjs +0 -10
  232. package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.js +0 -21
  233. package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.mjs +0 -16
  234. package/shortcutContexts/commands/index.js +0 -52
  235. package/shortcutContexts/commands/index.mjs +0 -48
  236. package/shortcutContexts/commands/moveCellSelection/down.js +0 -12
  237. package/shortcutContexts/commands/moveCellSelection/down.mjs +0 -7
  238. package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.js +0 -29
  239. package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.mjs +0 -24
  240. package/shortcutContexts/commands/moveCellSelection/index.js +0 -28
  241. package/shortcutContexts/commands/moveCellSelection/index.mjs +0 -24
  242. package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +0 -13
  243. package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +0 -8
  244. package/shortcutContexts/commands/moveCellSelection/inlineStart.js +0 -13
  245. package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +0 -8
  246. package/shortcutContexts/commands/moveCellSelection/left.js +0 -11
  247. package/shortcutContexts/commands/moveCellSelection/left.mjs +0 -6
  248. package/shortcutContexts/commands/moveCellSelection/right.js +0 -11
  249. package/shortcutContexts/commands/moveCellSelection/right.mjs +0 -6
  250. package/shortcutContexts/commands/moveCellSelection/toMostBottom.js +0 -16
  251. package/shortcutContexts/commands/moveCellSelection/toMostBottom.mjs +0 -11
  252. package/shortcutContexts/commands/moveCellSelection/toMostBottomInlineEnd.js +0 -17
  253. package/shortcutContexts/commands/moveCellSelection/toMostBottomInlineEnd.mjs +0 -12
  254. package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.js +0 -13
  255. package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.mjs +0 -8
  256. package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.js +0 -16
  257. package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.mjs +0 -11
  258. package/shortcutContexts/commands/moveCellSelection/toMostLeft.js +0 -36
  259. package/shortcutContexts/commands/moveCellSelection/toMostLeft.mjs +0 -31
  260. package/shortcutContexts/commands/moveCellSelection/toMostRight.js +0 -36
  261. package/shortcutContexts/commands/moveCellSelection/toMostRight.mjs +0 -31
  262. package/shortcutContexts/commands/moveCellSelection/toMostTop.js +0 -16
  263. package/shortcutContexts/commands/moveCellSelection/toMostTop.mjs +0 -11
  264. package/shortcutContexts/commands/moveCellSelection/toMostTopInlineStart.js +0 -18
  265. package/shortcutContexts/commands/moveCellSelection/toMostTopInlineStart.mjs +0 -13
  266. package/shortcutContexts/commands/moveCellSelection/up.js +0 -12
  267. package/shortcutContexts/commands/moveCellSelection/up.mjs +0 -7
  268. package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.js +0 -29
  269. package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.mjs +0 -24
  270. package/shortcutContexts/commands/populateSelectedCellsData.js +0 -35
  271. package/shortcutContexts/commands/populateSelectedCellsData.mjs +0 -30
  272. package/shortcutContexts/commands/selectAll.js +0 -11
  273. package/shortcutContexts/commands/selectAll.mjs +0 -6
  274. package/shortcutContexts/constants.js +0 -19
  275. package/shortcutContexts/constants.mjs +0 -12
  276. package/shortcutContexts/editor.js +0 -29
  277. package/shortcutContexts/editor.mjs +0 -25
  278. package/shortcutContexts/grid.js +0 -244
  279. package/shortcutContexts/grid.mjs +0 -240
  280. package/shortcutContexts/index.js +0 -29
  281. package/shortcutContexts/index.mjs +0 -15
@@ -32,17 +32,14 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
32
32
  import { BasePlugin } from "../base/index.mjs";
33
33
  import Hooks from "../../pluginHooks.mjs";
34
34
  import { arrayEach } from "../../helpers/array.mjs";
35
- import { objectEach } from "../../helpers/object.mjs";
36
35
  import CommandExecutor from "./commandExecutor.mjs";
37
36
  import EventManager from "../../eventManager.mjs";
38
37
  import ItemsFactory from "./itemsFactory.mjs";
39
38
  import Menu from "./menu.mjs";
40
- import { getDocumentOffsetByElement } from "./utils.mjs";
41
- import { hasClass } from "../../helpers/dom/element.mjs";
39
+ import { getWindowScrollLeft, getWindowScrollTop, hasClass } from "../../helpers/dom/element.mjs";
42
40
  import { ROW_ABOVE, ROW_BELOW, COLUMN_LEFT, COLUMN_RIGHT, REMOVE_ROW, REMOVE_COLUMN, UNDO, REDO, READ_ONLY, ALIGNMENT, SEPARATOR } from "./predefinedItems.mjs";
43
41
  export var PLUGIN_KEY = 'contextMenu';
44
42
  export var PLUGIN_PRIORITY = 70;
45
- var SHORTCUTS_GROUP = PLUGIN_KEY;
46
43
  Hooks.getSingleton().register('afterContextMenuDefaultOptions');
47
44
  Hooks.getSingleton().register('beforeContextMenuShow');
48
45
  Hooks.getSingleton().register('afterContextMenuShow');
@@ -164,7 +161,6 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
164
161
  this.addHook('afterOnCellContextMenu', function (event) {
165
162
  return _this2.onAfterOnCellContextMenu(event);
166
163
  });
167
- this.registerShortcuts();
168
164
  _get(_getPrototypeOf(ContextMenu.prototype), "enablePlugin", this).call(this);
169
165
  }
170
166
 
@@ -179,7 +175,6 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
179
175
  value: function updatePlugin() {
180
176
  this.disablePlugin();
181
177
  this.enablePlugin();
182
- this.unregisterShortcuts();
183
178
  _get(_getPrototypeOf(ContextMenu.prototype), "updatePlugin", this).call(this);
184
179
  }
185
180
 
@@ -197,83 +192,39 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
197
192
  _get(_getPrototypeOf(ContextMenu.prototype), "disablePlugin", this).call(this);
198
193
  }
199
194
 
200
- /**
201
- * Register shortcuts responsible for toggling context menu.
202
- *
203
- * @private
204
- */
205
- }, {
206
- key: "registerShortcuts",
207
- value: function registerShortcuts() {
208
- var _this3 = this;
209
- this.hot.getShortcutManager().getContext('grid').addShortcut({
210
- keys: [['Control/Meta', 'Shift', '\\'], ['Shift', 'F10']],
211
- callback: function callback() {
212
- var _this3$hot$getSelecte = _this3.hot.getSelectedRangeLast(),
213
- highlight = _this3$hot$getSelecte.highlight;
214
- var rect = _this3.hot.getCell(highlight.row, highlight.col, true).getBoundingClientRect();
215
- var offset = getDocumentOffsetByElement(_this3.menu.container, _this3.hot.rootDocument);
216
- _this3.open({
217
- left: rect.left + offset.left,
218
- top: rect.top + offset.top - 1 + rect.height
219
- }, {
220
- left: rect.width,
221
- above: -rect.height
222
- });
223
- _this3.hot._registerTimeout(function () {
224
- _this3.menu.selectFirstCell();
225
- });
226
- },
227
- runOnlyIf: function runOnlyIf() {
228
- return _this3.hot.getSelectedRangeLast() && !_this3.menu.isOpened();
229
- },
230
- group: SHORTCUTS_GROUP
231
- });
232
- }
233
-
234
- /**
235
- * Unregister shortcuts responsible for toggling context menu.
236
- *
237
- * @private
238
- */
239
- }, {
240
- key: "unregisterShortcuts",
241
- value: function unregisterShortcuts() {
242
- this.hot.getShortcutManager().getContext('grid').removeShortcutsByGroup(SHORTCUTS_GROUP);
243
- }
244
-
245
195
  /**
246
196
  * Opens menu and re-position it based on the passed coordinates.
247
197
  *
248
- * @param {{ top: number, left: number }|Event} position An object with `top` and `left` properties
249
- * which contains coordinates relative to the browsers viewport (without included scroll offsets).
250
- * Or if the native event is passed the menu will be positioned based on the `pageX` and `pageY`
251
- * coordinates.
252
- * @param {{ above?: number, below?: number, left?: number, right?: number }} offset An object allows applying
253
- * the offset to the menu position.
254
- * @fires Hooks#beforeContextMenuShow
255
- * @fires Hooks#afterContextMenuShow
198
+ * @param {Event} event The mouse event object.
256
199
  */
257
200
  }, {
258
201
  key: "open",
259
- value: function open(position) {
260
- var _this$menu,
261
- _this4 = this;
262
- var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
263
- above: 0,
264
- below: 0,
265
- left: 0,
266
- right: 0
267
- };
268
- if ((_this$menu = this.menu) !== null && _this$menu !== void 0 && _this$menu.isOpened()) {
202
+ value: function open(event) {
203
+ if (!this.menu) {
269
204
  return;
270
205
  }
271
206
  this.prepareMenuItems();
272
207
  this.menu.open();
273
- objectEach(offset, function (value, key) {
274
- _this4.menu.setOffset(key, value);
208
+ if (!this.menu.isOpened()) {
209
+ return;
210
+ }
211
+ var offsetTop = 0;
212
+ var offsetLeft = 0;
213
+ if (this.hot.rootDocument !== this.menu.container.ownerDocument) {
214
+ var frameElement = this.hot.rootWindow.frameElement;
215
+ var _frameElement$getBoun = frameElement.getBoundingClientRect(),
216
+ top = _frameElement$getBoun.top,
217
+ left = _frameElement$getBoun.left;
218
+ offsetTop = top - getWindowScrollTop(event.view);
219
+ offsetLeft = left - getWindowScrollLeft(event.view);
220
+ } else {
221
+ offsetTop = -1 * getWindowScrollTop(this.menu.hotMenu.rootWindow);
222
+ offsetLeft = -1 * getWindowScrollLeft(this.menu.hotMenu.rootWindow);
223
+ }
224
+ this.menu.setPosition({
225
+ top: parseInt(event.pageY, 10) + offsetTop,
226
+ left: parseInt(event.pageX, 10) + offsetLeft
275
227
  });
276
- this.menu.setPosition(position);
277
228
  }
278
229
 
279
230
  /**
@@ -282,8 +233,10 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
282
233
  }, {
283
234
  key: "close",
284
235
  value: function close() {
285
- var _this$menu2;
286
- (_this$menu2 = this.menu) === null || _this$menu2 === void 0 ? void 0 : _this$menu2.close();
236
+ if (!this.menu) {
237
+ return;
238
+ }
239
+ this.menu.close();
287
240
  this.itemsFactory = null;
288
241
  }
289
242
 
@@ -340,7 +293,7 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
340
293
  }, {
341
294
  key: "prepareMenuItems",
342
295
  value: function prepareMenuItems() {
343
- var _this5 = this;
296
+ var _this3 = this;
344
297
  this.itemsFactory = new ItemsFactory(this.hot, ContextMenu.DEFAULT_ITEMS);
345
298
  var settings = this.hot.getSettings()[PLUGIN_KEY];
346
299
  var predefinedItems = {
@@ -354,7 +307,7 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
354
307
 
355
308
  // Register all commands. Predefined and added by user or by plugins
356
309
  arrayEach(menuItems, function (command) {
357
- return _this5.commandExecutor.registerCommand(command.key, command);
310
+ return _this3.commandExecutor.registerCommand(command.key, command);
358
311
  });
359
312
  }
360
313
 
@@ -391,11 +344,7 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
391
344
  return;
392
345
  }
393
346
  }
394
- var offset = getDocumentOffsetByElement(this.menu.container, this.hot.rootDocument);
395
- this.open({
396
- top: event.clientY + offset.top,
397
- left: event.clientX + offset.left
398
- });
347
+ this.open(event);
399
348
  }
400
349
 
401
350
  /**
@@ -35,13 +35,6 @@ function alignmentItem() {
35
35
  if (this.countRows() === 0 || this.countCols() === 0) {
36
36
  return true;
37
37
  }
38
- var range = this.getSelectedRangeLast();
39
- if (!range) {
40
- return true;
41
- }
42
- if (range.isSingleHeader()) {
43
- return true;
44
- }
45
38
  return !(this.getSelectedRange() && !this.selection.isSelectedByCorner());
46
39
  },
47
40
  submenu: {
@@ -17,13 +17,6 @@ export default function alignmentItem() {
17
17
  if (this.countRows() === 0 || this.countCols() === 0) {
18
18
  return true;
19
19
  }
20
- var range = this.getSelectedRangeLast();
21
- if (!range) {
22
- return true;
23
- }
24
- if (range.isSingleHeader()) {
25
- return true;
26
- }
27
20
  return !(this.getSelectedRange() && !this.selection.isSelectedByCorner());
28
21
  },
29
22
  submenu: {
@@ -13,6 +13,7 @@ require("core-js/modules/es.symbol.iterator.js");
13
13
  exports.__esModule = true;
14
14
  exports.KEY = void 0;
15
15
  exports.default = clearColumnItem;
16
+ var _utils = require("../utils");
16
17
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
17
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
19
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -36,11 +37,8 @@ function clearColumnItem() {
36
37
  }
37
38
  },
38
39
  disabled: function disabled() {
39
- var range = this.getSelectedRangeLast();
40
- if (!range) {
41
- return true;
42
- }
43
- if (range.isSingleHeader() && range.highlight.col < 0) {
40
+ var selected = (0, _utils.getValidSelection)(this);
41
+ if (!selected) {
44
42
  return true;
45
43
  }
46
44
  return !this.selection.isSelectedByColumnHeader();
@@ -1,3 +1,4 @@
1
+ import { getValidSelection } from "../utils.mjs";
1
2
  import * as C from "../../../i18n/constants.mjs";
2
3
  export var KEY = 'clear_column';
3
4
 
@@ -18,11 +19,8 @@ export default function clearColumnItem() {
18
19
  }
19
20
  },
20
21
  disabled: function disabled() {
21
- var range = this.getSelectedRangeLast();
22
- if (!range) {
23
- return true;
24
- }
25
- if (range.isSingleHeader() && range.highlight.col < 0) {
22
+ var selected = getValidSelection(this);
23
+ if (!selected) {
26
24
  return true;
27
25
  }
28
26
  return !this.selection.isSelectedByColumnHeader();
@@ -13,6 +13,7 @@ require("core-js/modules/es.symbol.iterator.js");
13
13
  exports.__esModule = true;
14
14
  exports.KEY = void 0;
15
15
  exports.default = columnLeftItem;
16
+ var _utils = require("../utils");
16
17
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
17
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
19
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -37,11 +38,8 @@ function columnLeftItem() {
37
38
  if (!this.isColumnModificationAllowed()) {
38
39
  return true;
39
40
  }
40
- var range = this.getSelectedRangeLast();
41
- if (!range) {
42
- return true;
43
- }
44
- if (range.isSingleHeader() && range.highlight.col < 0) {
41
+ var selected = (0, _utils.getValidSelection)(this);
42
+ if (!selected) {
45
43
  return true;
46
44
  }
47
45
  if (this.selection.isSelectedByCorner()) {
@@ -1,3 +1,4 @@
1
+ import { getValidSelection } from "../utils.mjs";
1
2
  import * as C from "../../../i18n/constants.mjs";
2
3
  export var KEY = 'col_left';
3
4
 
@@ -19,11 +20,8 @@ export default function columnLeftItem() {
19
20
  if (!this.isColumnModificationAllowed()) {
20
21
  return true;
21
22
  }
22
- var range = this.getSelectedRangeLast();
23
- if (!range) {
24
- return true;
25
- }
26
- if (range.isSingleHeader() && range.highlight.col < 0) {
23
+ var selected = getValidSelection(this);
24
+ if (!selected) {
27
25
  return true;
28
26
  }
29
27
  if (this.selection.isSelectedByCorner()) {
@@ -13,6 +13,7 @@ require("core-js/modules/es.symbol.iterator.js");
13
13
  exports.__esModule = true;
14
14
  exports.KEY = void 0;
15
15
  exports.default = columnRightItem;
16
+ var _utils = require("../utils");
16
17
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
17
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
19
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -37,11 +38,8 @@ function columnRightItem() {
37
38
  if (!this.isColumnModificationAllowed()) {
38
39
  return true;
39
40
  }
40
- var range = this.getSelectedRangeLast();
41
- if (!range) {
42
- return true;
43
- }
44
- if (range.isSingleHeader() && range.highlight.col < 0) {
41
+ var selected = (0, _utils.getValidSelection)(this);
42
+ if (!selected) {
45
43
  return true;
46
44
  }
47
45
  if (this.selection.isSelectedByCorner()) {
@@ -1,3 +1,4 @@
1
+ import { getValidSelection } from "../utils.mjs";
1
2
  import * as C from "../../../i18n/constants.mjs";
2
3
  export var KEY = 'col_right';
3
4
 
@@ -19,11 +20,8 @@ export default function columnRightItem() {
19
20
  if (!this.isColumnModificationAllowed()) {
20
21
  return true;
21
22
  }
22
- var range = this.getSelectedRangeLast();
23
- if (!range) {
24
- return true;
25
- }
26
- if (range.isSingleHeader() && range.highlight.col < 0) {
23
+ var selected = getValidSelection(this);
24
+ if (!selected) {
27
25
  return true;
28
26
  }
29
27
  if (this.selection.isSelectedByCorner()) {
@@ -54,13 +54,6 @@ function readOnlyItem() {
54
54
  this.render();
55
55
  },
56
56
  disabled: function disabled() {
57
- var range = this.getSelectedRangeLast();
58
- if (!range) {
59
- return true;
60
- }
61
- if (range.isSingleHeader()) {
62
- return true;
63
- }
64
57
  if (this.selection.isSelectedByCorner()) {
65
58
  return true;
66
59
  }
@@ -36,13 +36,6 @@ export default function readOnlyItem() {
36
36
  this.render();
37
37
  },
38
38
  disabled: function disabled() {
39
- var range = this.getSelectedRangeLast();
40
- if (!range) {
41
- return true;
42
- }
43
- if (range.isSingleHeader()) {
44
- return true;
45
- }
46
39
  if (this.selection.isSelectedByCorner()) {
47
40
  return true;
48
41
  }
@@ -18,7 +18,8 @@ require("core-js/modules/es.object.get-own-property-descriptor.js");
18
18
  exports.__esModule = true;
19
19
  exports.KEY = void 0;
20
20
  exports.default = removeColumnItem;
21
- var _utils = require("../../../selection/utils");
21
+ var _utils = require("../utils");
22
+ var _utils2 = require("../../../selection/utils");
22
23
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
23
24
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
24
25
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -55,17 +56,14 @@ function removeColumnItem() {
55
56
  return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_REMOVE_COLUMN, pluralForm);
56
57
  },
57
58
  callback: function callback() {
58
- this.alter('remove_col', (0, _utils.transformSelectionToColumnDistance)(this.getSelected()), null, 'ContextMenu.removeColumn');
59
+ this.alter('remove_col', (0, _utils2.transformSelectionToColumnDistance)(this.getSelected()), null, 'ContextMenu.removeColumn');
59
60
  },
60
61
  disabled: function disabled() {
61
62
  if (!this.isColumnModificationAllowed()) {
62
63
  return true;
63
64
  }
64
- var range = this.getSelectedRangeLast();
65
- if (!range) {
66
- return true;
67
- }
68
- if (range.isSingleHeader() && range.highlight.col < 0) {
65
+ var selected = (0, _utils.getValidSelection)(this);
66
+ if (!selected) {
69
67
  return true;
70
68
  }
71
69
  var totalColumns = this.countCols();
@@ -16,6 +16,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
16
16
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
17
17
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
18
18
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
+ import { getValidSelection } from "../utils.mjs";
19
20
  import { transformSelectionToColumnDistance } from "../../../selection/utils.mjs";
20
21
  import * as C from "../../../i18n/constants.mjs";
21
22
  export var KEY = 'remove_col';
@@ -50,11 +51,8 @@ export default function removeColumnItem() {
50
51
  if (!this.isColumnModificationAllowed()) {
51
52
  return true;
52
53
  }
53
- var range = this.getSelectedRangeLast();
54
- if (!range) {
55
- return true;
56
- }
57
- if (range.isSingleHeader() && range.highlight.col < 0) {
54
+ var selected = getValidSelection(this);
55
+ if (!selected) {
58
56
  return true;
59
57
  }
60
58
  var totalColumns = this.countCols();
@@ -18,7 +18,8 @@ require("core-js/modules/es.object.get-own-property-descriptor.js");
18
18
  exports.__esModule = true;
19
19
  exports.KEY = void 0;
20
20
  exports.default = removeRowItem;
21
- var _utils = require("../../../selection/utils");
21
+ var _utils = require("../utils");
22
+ var _utils2 = require("../../../selection/utils");
22
23
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
23
24
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
24
25
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -57,14 +58,11 @@ function removeRowItem() {
57
58
  callback: function callback() {
58
59
  // TODO: Please keep in mind that below `1` may be improper. The table's way of work, before change `f1747b3912ea3b21fe423fd102ca94c87db81379` was restored.
59
60
  // There is still problem when removing more than one row.
60
- this.alter('remove_row', (0, _utils.transformSelectionToRowDistance)(this.getSelected()), 1, 'ContextMenu.removeRow');
61
+ this.alter('remove_row', (0, _utils2.transformSelectionToRowDistance)(this.getSelected()), 1, 'ContextMenu.removeRow');
61
62
  },
62
63
  disabled: function disabled() {
63
- var range = this.getSelectedRangeLast();
64
- if (!range) {
65
- return true;
66
- }
67
- if (range.isSingleHeader() && range.highlight.row < 0) {
64
+ var selected = (0, _utils.getValidSelection)(this);
65
+ if (!selected) {
68
66
  return true;
69
67
  }
70
68
  var totalRows = this.countRows();
@@ -16,6 +16,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
16
16
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
17
17
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
18
18
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
+ import { getValidSelection } from "../utils.mjs";
19
20
  import { transformSelectionToRowDistance } from "../../../selection/utils.mjs";
20
21
  import * as C from "../../../i18n/constants.mjs";
21
22
  export var KEY = 'remove_row';
@@ -49,11 +50,8 @@ export default function removeRowItem() {
49
50
  this.alter('remove_row', transformSelectionToRowDistance(this.getSelected()), 1, 'ContextMenu.removeRow');
50
51
  },
51
52
  disabled: function disabled() {
52
- var range = this.getSelectedRangeLast();
53
- if (!range) {
54
- return true;
55
- }
56
- if (range.isSingleHeader() && range.highlight.row < 0) {
53
+ var selected = getValidSelection(this);
54
+ if (!selected) {
57
55
  return true;
58
56
  }
59
57
  var totalRows = this.countRows();
@@ -13,6 +13,7 @@ require("core-js/modules/es.symbol.iterator.js");
13
13
  exports.__esModule = true;
14
14
  exports.KEY = void 0;
15
15
  exports.default = rowAboveItem;
16
+ var _utils = require("../utils");
16
17
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
17
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
19
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -33,11 +34,8 @@ function rowAboveItem() {
33
34
  this.alter('insert_row_above', latestSelection.row, 1, 'ContextMenu.rowAbove');
34
35
  },
35
36
  disabled: function disabled() {
36
- var range = this.getSelectedRangeLast();
37
- if (!range) {
38
- return true;
39
- }
40
- if (range.isSingleHeader() && range.highlight.row < 0) {
37
+ var selected = (0, _utils.getValidSelection)(this);
38
+ if (!selected) {
41
39
  return true;
42
40
  }
43
41
  if (this.selection.isSelectedByCorner()) {
@@ -1,3 +1,4 @@
1
+ import { getValidSelection } from "../utils.mjs";
1
2
  import * as C from "../../../i18n/constants.mjs";
2
3
  export var KEY = 'row_above';
3
4
 
@@ -15,11 +16,8 @@ export default function rowAboveItem() {
15
16
  this.alter('insert_row_above', latestSelection.row, 1, 'ContextMenu.rowAbove');
16
17
  },
17
18
  disabled: function disabled() {
18
- var range = this.getSelectedRangeLast();
19
- if (!range) {
20
- return true;
21
- }
22
- if (range.isSingleHeader() && range.highlight.row < 0) {
19
+ var selected = getValidSelection(this);
20
+ if (!selected) {
23
21
  return true;
24
22
  }
25
23
  if (this.selection.isSelectedByCorner()) {
@@ -13,6 +13,7 @@ require("core-js/modules/es.symbol.iterator.js");
13
13
  exports.__esModule = true;
14
14
  exports.KEY = void 0;
15
15
  exports.default = rowBelowItem;
16
+ var _utils = require("../utils");
16
17
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
17
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
19
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -33,11 +34,8 @@ function rowBelowItem() {
33
34
  this.alter('insert_row_below', latestSelection.row, 1, 'ContextMenu.rowBelow');
34
35
  },
35
36
  disabled: function disabled() {
36
- var range = this.getSelectedRangeLast();
37
- if (!range) {
38
- return true;
39
- }
40
- if (range.isSingleHeader() && range.highlight.row < 0) {
37
+ var selected = (0, _utils.getValidSelection)(this);
38
+ if (!selected) {
41
39
  return true;
42
40
  }
43
41
  if (this.selection.isSelectedByCorner()) {
@@ -1,3 +1,4 @@
1
+ import { getValidSelection } from "../utils.mjs";
1
2
  import * as C from "../../../i18n/constants.mjs";
2
3
  export var KEY = 'row_below';
3
4
 
@@ -15,11 +16,8 @@ export default function rowBelowItem() {
15
16
  this.alter('insert_row_below', latestSelection.row, 1, 'ContextMenu.rowBelow');
16
17
  },
17
18
  disabled: function disabled() {
18
- var range = this.getSelectedRangeLast();
19
- if (!range) {
20
- return true;
21
- }
22
- if (range.isSingleHeader() && range.highlight.row < 0) {
19
+ var selected = getValidSelection(this);
20
+ if (!selected) {
23
21
  return true;
24
22
  }
25
23
  if (this.selection.isSelectedByCorner()) {
@@ -5,7 +5,7 @@ exports.align = align;
5
5
  exports.checkSelectionConsistency = checkSelectionConsistency;
6
6
  exports.filterSeparators = filterSeparators;
7
7
  exports.getAlignmentClasses = getAlignmentClasses;
8
- exports.getDocumentOffsetByElement = getDocumentOffsetByElement;
8
+ exports.getValidSelection = getValidSelection;
9
9
  exports.hasSubMenu = hasSubMenu;
10
10
  exports.isDisabled = isDisabled;
11
11
  exports.isItemHidden = isItemHidden;
@@ -70,6 +70,21 @@ function isSelectionDisabled(cell) {
70
70
  return (0, _element.hasClass)(cell, 'htSelectionDisabled');
71
71
  }
72
72
 
73
+ /**
74
+ * @param {Core} hot The Handsontable instance.
75
+ * @returns {Array[]|null}
76
+ */
77
+ function getValidSelection(hot) {
78
+ var selected = hot.getSelected();
79
+ if (!selected) {
80
+ return null;
81
+ }
82
+ if (selected[0] < 0) {
83
+ return null;
84
+ }
85
+ return selected;
86
+ }
87
+
73
88
  /**
74
89
  * @param {string} className The full element class name to process.
75
90
  * @param {string} alignment The slignment class name to compare with.
@@ -260,28 +275,4 @@ function filterSeparators(items) {
260
275
  result = popSeparators(result, separator);
261
276
  result = removeDuplicatedSeparators(result);
262
277
  return result;
263
- }
264
-
265
- /**
266
- * Returns document offset based on the passed element. If the document objects between element and the
267
- * base document are not the same the offset as top and left properties will be returned.
268
- *
269
- * @param {Element} elementToCheck The element to compare with Document object.
270
- * @param {Document} baseDocument The base Document object.
271
- * @returns {{ top: number, left: number }}
272
- */
273
- function getDocumentOffsetByElement(elementToCheck, baseDocument) {
274
- var offset = {
275
- top: 0,
276
- left: 0
277
- };
278
- if (baseDocument !== elementToCheck.ownerDocument) {
279
- var frameElement = baseDocument.defaultView.frameElement;
280
- var _frameElement$getBoun = frameElement.getBoundingClientRect(),
281
- top = _frameElement$getBoun.top,
282
- left = _frameElement$getBoun.left;
283
- offset.top = top;
284
- offset.left = left;
285
- }
286
- return offset;
287
278
  }