handsontable 0.0.0-next-baf2fcf-20230809 → 0.0.0-next-be16baf-20230809

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 (299) hide show
  1. package/3rdparty/walkontable/src/cell/coords.d.ts +6 -1
  2. package/3rdparty/walkontable/src/cell/coords.js +50 -11
  3. package/3rdparty/walkontable/src/cell/coords.mjs +50 -11
  4. package/3rdparty/walkontable/src/cell/range.d.ts +9 -2
  5. package/3rdparty/walkontable/src/cell/range.js +38 -7
  6. package/3rdparty/walkontable/src/cell/range.mjs +38 -7
  7. package/3rdparty/walkontable/src/core/_base.js +9 -3
  8. package/3rdparty/walkontable/src/core/_base.mjs +9 -3
  9. package/3rdparty/walkontable/src/core/clone.js +2 -2
  10. package/3rdparty/walkontable/src/core/clone.mjs +2 -2
  11. package/3rdparty/walkontable/src/core/core.js +3 -2
  12. package/3rdparty/walkontable/src/core/core.mjs +3 -2
  13. package/3rdparty/walkontable/src/event.js +7 -7
  14. package/3rdparty/walkontable/src/event.mjs +7 -7
  15. package/3rdparty/walkontable/src/facade/core.js +2 -2
  16. package/3rdparty/walkontable/src/facade/core.mjs +2 -2
  17. package/3rdparty/walkontable/src/index.js +10 -2
  18. package/3rdparty/walkontable/src/index.mjs +2 -2
  19. package/3rdparty/walkontable/src/overlay/_base.js +1 -1
  20. package/3rdparty/walkontable/src/overlay/_base.mjs +1 -1
  21. package/3rdparty/walkontable/src/overlay/inlineStart.js +2 -6
  22. package/3rdparty/walkontable/src/overlay/inlineStart.mjs +2 -6
  23. package/3rdparty/walkontable/src/overlay/top.js +2 -6
  24. package/3rdparty/walkontable/src/overlay/top.mjs +2 -6
  25. package/3rdparty/walkontable/src/{border.js → selection/border/border.js} +7 -12
  26. package/3rdparty/walkontable/src/{border.mjs → selection/border/border.mjs} +7 -12
  27. package/3rdparty/walkontable/src/selection/border/constants.js +16 -0
  28. package/3rdparty/walkontable/src/selection/border/constants.mjs +12 -0
  29. package/3rdparty/walkontable/src/selection/constants.js +62 -0
  30. package/3rdparty/walkontable/src/selection/constants.mjs +51 -0
  31. package/3rdparty/walkontable/src/selection/index.js +26 -0
  32. package/3rdparty/walkontable/src/selection/index.mjs +5 -0
  33. package/3rdparty/walkontable/src/selection/manager.js +259 -0
  34. package/3rdparty/walkontable/src/selection/manager.mjs +254 -0
  35. package/3rdparty/walkontable/src/selection/scanner.js +270 -0
  36. package/3rdparty/walkontable/src/selection/scanner.mjs +267 -0
  37. package/3rdparty/walkontable/src/selection/selection.js +101 -0
  38. package/3rdparty/walkontable/src/selection/selection.mjs +96 -0
  39. package/3rdparty/walkontable/src/table/mixin/calculatedColumns.js +9 -0
  40. package/3rdparty/walkontable/src/table/mixin/calculatedColumns.mjs +9 -0
  41. package/3rdparty/walkontable/src/table/mixin/calculatedRows.js +9 -0
  42. package/3rdparty/walkontable/src/table/mixin/calculatedRows.mjs +9 -0
  43. package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.js +9 -0
  44. package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.mjs +9 -0
  45. package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.js +9 -0
  46. package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.mjs +9 -0
  47. package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.js +9 -0
  48. package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.mjs +9 -0
  49. package/3rdparty/walkontable/src/table.js +6 -78
  50. package/3rdparty/walkontable/src/table.mjs +7 -79
  51. package/base.js +2 -2
  52. package/base.mjs +2 -2
  53. package/common.d.ts +1 -1
  54. package/core/focusCatcher/focusDetector.js +58 -0
  55. package/core/focusCatcher/focusDetector.mjs +54 -0
  56. package/core/focusCatcher/index.js +142 -0
  57. package/core/focusCatcher/index.mjs +138 -0
  58. package/core/index.js +9 -0
  59. package/core/index.mjs +1 -0
  60. package/core.d.ts +6 -3
  61. package/core.js +176 -293
  62. package/core.mjs +176 -293
  63. package/dataMap/metaManager/metaSchema.js +41 -0
  64. package/dataMap/metaManager/metaSchema.mjs +41 -0
  65. package/dist/handsontable.css +24 -4
  66. package/dist/handsontable.full.css +24 -4
  67. package/dist/handsontable.full.js +8682 -5384
  68. package/dist/handsontable.full.min.css +3 -3
  69. package/dist/handsontable.full.min.js +25 -25
  70. package/dist/handsontable.js +10989 -7691
  71. package/dist/handsontable.min.css +3 -3
  72. package/dist/handsontable.min.js +19 -19
  73. package/editorManager.js +11 -75
  74. package/editorManager.mjs +11 -74
  75. package/editors/baseEditor/baseEditor.d.ts +0 -1
  76. package/editors/textEditor/textEditor.js +3 -11
  77. package/editors/textEditor/textEditor.mjs +4 -12
  78. package/helpers/mixed.js +1 -1
  79. package/helpers/mixed.mjs +1 -1
  80. package/helpers/number.d.ts +1 -0
  81. package/helpers/number.js +18 -0
  82. package/helpers/number.mjs +17 -0
  83. package/package.json +1 -1
  84. package/pluginHooks.d.ts +7 -1
  85. package/pluginHooks.js +106 -1
  86. package/pluginHooks.mjs +106 -1
  87. package/plugins/collapsibleColumns/collapsibleColumns.js +58 -4
  88. package/plugins/collapsibleColumns/collapsibleColumns.mjs +58 -4
  89. package/plugins/columnSorting/columnSorting.js +38 -0
  90. package/plugins/columnSorting/columnSorting.mjs +38 -2
  91. package/plugins/columnSorting/index.js +3 -1
  92. package/plugins/columnSorting/index.mjs +1 -1
  93. package/plugins/comments/commentEditor.js +1 -0
  94. package/plugins/comments/commentEditor.mjs +1 -0
  95. package/plugins/comments/comments.js +251 -189
  96. package/plugins/comments/comments.mjs +250 -190
  97. package/plugins/comments/contextMenuItem/addEditComment.js +41 -0
  98. package/plugins/comments/contextMenuItem/addEditComment.mjs +35 -0
  99. package/plugins/comments/contextMenuItem/readOnlyComment.js +49 -0
  100. package/plugins/comments/contextMenuItem/readOnlyComment.mjs +43 -0
  101. package/plugins/comments/contextMenuItem/removeComment.js +38 -0
  102. package/plugins/comments/contextMenuItem/removeComment.mjs +32 -0
  103. package/plugins/contextMenu/contextMenu.d.ts +1 -1
  104. package/plugins/contextMenu/contextMenu.js +72 -30
  105. package/plugins/contextMenu/contextMenu.mjs +73 -31
  106. package/plugins/contextMenu/predefinedItems/alignment.js +7 -0
  107. package/plugins/contextMenu/predefinedItems/alignment.mjs +7 -0
  108. package/plugins/contextMenu/predefinedItems/clearColumn.js +5 -3
  109. package/plugins/contextMenu/predefinedItems/clearColumn.mjs +5 -3
  110. package/plugins/contextMenu/predefinedItems/columnLeft.js +5 -3
  111. package/plugins/contextMenu/predefinedItems/columnLeft.mjs +5 -3
  112. package/plugins/contextMenu/predefinedItems/columnRight.js +5 -3
  113. package/plugins/contextMenu/predefinedItems/columnRight.mjs +5 -3
  114. package/plugins/contextMenu/predefinedItems/readOnly.js +7 -0
  115. package/plugins/contextMenu/predefinedItems/readOnly.mjs +7 -0
  116. package/plugins/contextMenu/predefinedItems/removeColumn.js +7 -5
  117. package/plugins/contextMenu/predefinedItems/removeColumn.mjs +5 -3
  118. package/plugins/contextMenu/predefinedItems/removeRow.js +7 -5
  119. package/plugins/contextMenu/predefinedItems/removeRow.mjs +5 -3
  120. package/plugins/contextMenu/predefinedItems/rowAbove.js +5 -3
  121. package/plugins/contextMenu/predefinedItems/rowAbove.mjs +5 -3
  122. package/plugins/contextMenu/predefinedItems/rowBelow.js +5 -3
  123. package/plugins/contextMenu/predefinedItems/rowBelow.mjs +5 -3
  124. package/plugins/contextMenu/utils.js +28 -16
  125. package/plugins/contextMenu/utils.mjs +27 -15
  126. package/plugins/copyPaste/contextMenuItem/copy.js +7 -0
  127. package/plugins/copyPaste/contextMenuItem/copy.mjs +7 -0
  128. package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.js +9 -1
  129. package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.mjs +9 -1
  130. package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.js +9 -1
  131. package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.mjs +9 -1
  132. package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.js +9 -1
  133. package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.mjs +9 -1
  134. package/plugins/copyPaste/contextMenuItem/cut.js +7 -0
  135. package/plugins/copyPaste/contextMenuItem/cut.mjs +7 -0
  136. package/plugins/copyPaste/copyPaste.js +14 -10
  137. package/plugins/copyPaste/copyPaste.mjs +14 -10
  138. package/plugins/customBorders/customBorders.js +23 -20
  139. package/plugins/customBorders/customBorders.mjs +24 -21
  140. package/plugins/dropdownMenu/dropdownMenu.d.ts +1 -1
  141. package/plugins/dropdownMenu/dropdownMenu.js +89 -32
  142. package/plugins/dropdownMenu/dropdownMenu.mjs +89 -32
  143. package/plugins/filters/filters.js +31 -14
  144. package/plugins/filters/filters.mjs +30 -13
  145. package/plugins/manualColumnResize/manualColumnResize.js +0 -6
  146. package/plugins/manualColumnResize/manualColumnResize.mjs +1 -7
  147. package/plugins/mergeCells/mergeCells.js +5 -17
  148. package/plugins/mergeCells/mergeCells.mjs +5 -17
  149. package/plugins/multiColumnSorting/multiColumnSorting.js +37 -2
  150. package/plugins/multiColumnSorting/multiColumnSorting.mjs +37 -2
  151. package/plugins/nestedHeaders/nestedHeaders.js +121 -8
  152. package/plugins/nestedHeaders/nestedHeaders.mjs +121 -8
  153. package/plugins/nestedHeaders/stateManager/index.js +37 -0
  154. package/plugins/nestedHeaders/stateManager/index.mjs +37 -0
  155. package/plugins/nestedRows/nestedRows.js +41 -0
  156. package/plugins/nestedRows/nestedRows.mjs +41 -0
  157. package/renderers/checkboxRenderer/checkboxRenderer.js +2 -2
  158. package/renderers/checkboxRenderer/checkboxRenderer.mjs +1 -1
  159. package/selection/highlight/highlight.js +256 -71
  160. package/selection/highlight/highlight.mjs +250 -71
  161. package/selection/highlight/types/activeHeader.js +10 -8
  162. package/selection/highlight/types/activeHeader.mjs +10 -8
  163. package/selection/highlight/types/area.js +6 -18
  164. package/selection/highlight/types/area.mjs +6 -18
  165. package/selection/highlight/types/areaLayered.js +31 -0
  166. package/selection/highlight/types/areaLayered.mjs +26 -0
  167. package/selection/highlight/types/column.js +27 -0
  168. package/selection/highlight/types/column.mjs +22 -0
  169. package/selection/highlight/types/customSelection.js +7 -9
  170. package/selection/highlight/types/customSelection.mjs +7 -9
  171. package/selection/highlight/types/fill.js +5 -7
  172. package/selection/highlight/types/fill.mjs +5 -7
  173. package/selection/highlight/types/{cell.js → focus.js} +5 -7
  174. package/selection/highlight/types/{cell.mjs → focus.mjs} +5 -7
  175. package/selection/highlight/types/header.js +9 -18
  176. package/selection/highlight/types/header.mjs +9 -18
  177. package/selection/highlight/types/row.js +27 -0
  178. package/selection/highlight/types/row.mjs +22 -0
  179. package/selection/highlight/visualSelection.js +31 -27
  180. package/selection/highlight/visualSelection.mjs +31 -27
  181. package/selection/index.js +4 -7
  182. package/selection/index.mjs +2 -3
  183. package/selection/mouseEventHandler.js +1 -1
  184. package/selection/mouseEventHandler.mjs +1 -1
  185. package/selection/range.js +8 -8
  186. package/selection/range.mjs +8 -8
  187. package/selection/selection.js +293 -154
  188. package/selection/selection.mjs +290 -153
  189. package/selection/transformation.js +232 -90
  190. package/selection/transformation.mjs +232 -90
  191. package/selection/utils.js +15 -21
  192. package/selection/utils.mjs +16 -21
  193. package/settings.d.ts +2 -0
  194. package/shortcutContexts/commands/editor/closeAndSave.js +12 -0
  195. package/shortcutContexts/commands/editor/closeAndSave.mjs +8 -0
  196. package/shortcutContexts/commands/editor/closeWithoutSaving.js +12 -0
  197. package/shortcutContexts/commands/editor/closeWithoutSaving.mjs +8 -0
  198. package/shortcutContexts/commands/editor/fastOpen.js +16 -0
  199. package/shortcutContexts/commands/editor/fastOpen.mjs +12 -0
  200. package/shortcutContexts/commands/editor/index.js +16 -0
  201. package/shortcutContexts/commands/editor/index.mjs +12 -0
  202. package/shortcutContexts/commands/editor/open.js +27 -0
  203. package/shortcutContexts/commands/editor/open.mjs +23 -0
  204. package/shortcutContexts/commands/emptySelectedCells.js +11 -0
  205. package/shortcutContexts/commands/emptySelectedCells.mjs +7 -0
  206. package/shortcutContexts/commands/extendCellsSelection/down.js +15 -0
  207. package/shortcutContexts/commands/extendCellsSelection/down.mjs +11 -0
  208. package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.js +21 -0
  209. package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.mjs +17 -0
  210. package/shortcutContexts/commands/extendCellsSelection/index.js +26 -0
  211. package/shortcutContexts/commands/extendCellsSelection/index.mjs +22 -0
  212. package/shortcutContexts/commands/extendCellsSelection/left.js +15 -0
  213. package/shortcutContexts/commands/extendCellsSelection/left.mjs +11 -0
  214. package/shortcutContexts/commands/extendCellsSelection/right.js +15 -0
  215. package/shortcutContexts/commands/extendCellsSelection/right.mjs +11 -0
  216. package/shortcutContexts/commands/extendCellsSelection/toColumns.js +19 -0
  217. package/shortcutContexts/commands/extendCellsSelection/toColumns.mjs +15 -0
  218. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +29 -0
  219. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +25 -0
  220. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +19 -0
  221. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +15 -0
  222. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +19 -0
  223. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +15 -0
  224. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +29 -0
  225. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +25 -0
  226. package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +29 -0
  227. package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +25 -0
  228. package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +29 -0
  229. package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +25 -0
  230. package/shortcutContexts/commands/extendCellsSelection/toRows.js +19 -0
  231. package/shortcutContexts/commands/extendCellsSelection/toRows.mjs +15 -0
  232. package/shortcutContexts/commands/extendCellsSelection/up.js +15 -0
  233. package/shortcutContexts/commands/extendCellsSelection/up.mjs +11 -0
  234. package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.js +21 -0
  235. package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.mjs +17 -0
  236. package/shortcutContexts/commands/index.js +35 -0
  237. package/shortcutContexts/commands/index.mjs +31 -0
  238. package/shortcutContexts/commands/moveCellSelection/down.js +13 -0
  239. package/shortcutContexts/commands/moveCellSelection/down.mjs +9 -0
  240. package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.js +31 -0
  241. package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.mjs +27 -0
  242. package/shortcutContexts/commands/moveCellSelection/index.js +28 -0
  243. package/shortcutContexts/commands/moveCellSelection/index.mjs +24 -0
  244. package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +12 -0
  245. package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +8 -0
  246. package/shortcutContexts/commands/moveCellSelection/inlineStart.js +12 -0
  247. package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +8 -0
  248. package/shortcutContexts/commands/moveCellSelection/left.js +10 -0
  249. package/shortcutContexts/commands/moveCellSelection/left.mjs +6 -0
  250. package/shortcutContexts/commands/moveCellSelection/right.js +10 -0
  251. package/shortcutContexts/commands/moveCellSelection/right.mjs +6 -0
  252. package/shortcutContexts/commands/moveCellSelection/toMostBottom.js +17 -0
  253. package/shortcutContexts/commands/moveCellSelection/toMostBottom.mjs +13 -0
  254. package/shortcutContexts/commands/moveCellSelection/toMostBottomInlineEnd.js +18 -0
  255. package/shortcutContexts/commands/moveCellSelection/toMostBottomInlineEnd.mjs +14 -0
  256. package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.js +14 -0
  257. package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.mjs +10 -0
  258. package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.js +17 -0
  259. package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.mjs +13 -0
  260. package/shortcutContexts/commands/moveCellSelection/toMostLeft.js +19 -0
  261. package/shortcutContexts/commands/moveCellSelection/toMostLeft.mjs +15 -0
  262. package/shortcutContexts/commands/moveCellSelection/toMostRight.js +21 -0
  263. package/shortcutContexts/commands/moveCellSelection/toMostRight.mjs +17 -0
  264. package/shortcutContexts/commands/moveCellSelection/toMostTop.js +17 -0
  265. package/shortcutContexts/commands/moveCellSelection/toMostTop.mjs +13 -0
  266. package/shortcutContexts/commands/moveCellSelection/toMostTopInlineStart.js +19 -0
  267. package/shortcutContexts/commands/moveCellSelection/toMostTopInlineStart.mjs +15 -0
  268. package/shortcutContexts/commands/moveCellSelection/up.js +13 -0
  269. package/shortcutContexts/commands/moveCellSelection/up.mjs +9 -0
  270. package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.js +31 -0
  271. package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.mjs +27 -0
  272. package/shortcutContexts/commands/populateSelectedCellsData.js +29 -0
  273. package/shortcutContexts/commands/populateSelectedCellsData.mjs +25 -0
  274. package/shortcutContexts/commands/scrollToFocusedCell.js +36 -0
  275. package/shortcutContexts/commands/scrollToFocusedCell.mjs +32 -0
  276. package/shortcutContexts/commands/selectAll.js +10 -0
  277. package/shortcutContexts/commands/selectAll.mjs +6 -0
  278. package/shortcutContexts/constants.js +13 -0
  279. package/shortcutContexts/constants.mjs +8 -0
  280. package/shortcutContexts/editor.js +25 -0
  281. package/shortcutContexts/editor.mjs +21 -0
  282. package/shortcutContexts/grid.js +163 -0
  283. package/shortcutContexts/grid.mjs +159 -0
  284. package/shortcutContexts/index.js +24 -0
  285. package/shortcutContexts/index.mjs +11 -0
  286. package/shortcuts/manager.js +2 -0
  287. package/shortcuts/manager.mjs +2 -0
  288. package/shortcuts/recorder.js +2 -2
  289. package/shortcuts/recorder.mjs +2 -2
  290. package/shortcuts/utils.js +19 -5
  291. package/shortcuts/utils.mjs +18 -4
  292. package/tableView.js +67 -13
  293. package/tableView.mjs +67 -13
  294. package/3rdparty/walkontable/src/selection.js +0 -295
  295. package/3rdparty/walkontable/src/selection.mjs +0 -290
  296. package/selection/highlight/constants.js +0 -15
  297. package/selection/highlight/constants.mjs +0 -6
  298. package/selection/highlight/types/index.js +0 -35
  299. package/selection/highlight/types/index.mjs +0 -31
@@ -1,4 +1,3 @@
1
- import { getValidSelection } from "../utils.mjs";
2
1
  import * as C from "../../../i18n/constants.mjs";
3
2
  export const KEY = 'col_left';
4
3
 
@@ -20,8 +19,11 @@ export default function columnLeftItem() {
20
19
  if (!this.isColumnModificationAllowed()) {
21
20
  return true;
22
21
  }
23
- const selected = getValidSelection(this);
24
- if (!selected) {
22
+ const range = this.getSelectedRangeLast();
23
+ if (!range) {
24
+ return true;
25
+ }
26
+ if (range.isSingleHeader() && range.highlight.col < 0) {
25
27
  return true;
26
28
  }
27
29
  if (this.selection.isSelectedByCorner()) {
@@ -2,7 +2,6 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.default = columnRightItem;
5
- var _utils = require("../utils");
6
5
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
7
6
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
8
7
  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; }
@@ -27,8 +26,11 @@ function columnRightItem() {
27
26
  if (!this.isColumnModificationAllowed()) {
28
27
  return true;
29
28
  }
30
- const selected = (0, _utils.getValidSelection)(this);
31
- if (!selected) {
29
+ const range = this.getSelectedRangeLast();
30
+ if (!range) {
31
+ return true;
32
+ }
33
+ if (range.isSingleHeader() && range.highlight.col < 0) {
32
34
  return true;
33
35
  }
34
36
  if (this.selection.isSelectedByCorner()) {
@@ -1,4 +1,3 @@
1
- import { getValidSelection } from "../utils.mjs";
2
1
  import * as C from "../../../i18n/constants.mjs";
3
2
  export const KEY = 'col_right';
4
3
 
@@ -20,8 +19,11 @@ export default function columnRightItem() {
20
19
  if (!this.isColumnModificationAllowed()) {
21
20
  return true;
22
21
  }
23
- const selected = getValidSelection(this);
24
- if (!selected) {
22
+ const range = this.getSelectedRangeLast();
23
+ if (!range) {
24
+ return true;
25
+ }
26
+ if (range.isSingleHeader() && range.highlight.col < 0) {
25
27
  return true;
26
28
  }
27
29
  if (this.selection.isSelectedByCorner()) {
@@ -37,6 +37,13 @@ function readOnlyItem() {
37
37
  this.render();
38
38
  },
39
39
  disabled() {
40
+ const range = this.getSelectedRangeLast();
41
+ if (!range) {
42
+ return true;
43
+ }
44
+ if (range.isSingleHeader()) {
45
+ return true;
46
+ }
40
47
  if (this.selection.isSelectedByCorner()) {
41
48
  return true;
42
49
  }
@@ -30,6 +30,13 @@ export default function readOnlyItem() {
30
30
  this.render();
31
31
  },
32
32
  disabled() {
33
+ const range = this.getSelectedRangeLast();
34
+ if (!range) {
35
+ return true;
36
+ }
37
+ if (range.isSingleHeader()) {
38
+ return true;
39
+ }
33
40
  if (this.selection.isSelectedByCorner()) {
34
41
  return true;
35
42
  }
@@ -2,8 +2,7 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.default = removeColumnItem;
5
- var _utils = require("../utils");
6
- var _utils2 = require("../../../selection/utils");
5
+ var _utils = require("../../../selection/utils");
7
6
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
8
7
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
9
8
  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; }
@@ -32,14 +31,17 @@ function removeColumnItem() {
32
31
  return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_REMOVE_COLUMN, pluralForm);
33
32
  },
34
33
  callback() {
35
- this.alter('remove_col', (0, _utils2.transformSelectionToColumnDistance)(this.getSelected()), null, 'ContextMenu.removeColumn');
34
+ this.alter('remove_col', (0, _utils.transformSelectionToColumnDistance)(this.getSelected()), null, 'ContextMenu.removeColumn');
36
35
  },
37
36
  disabled() {
38
37
  if (!this.isColumnModificationAllowed()) {
39
38
  return true;
40
39
  }
41
- const selected = (0, _utils.getValidSelection)(this);
42
- if (!selected) {
40
+ const range = this.getSelectedRangeLast();
41
+ if (!range) {
42
+ return true;
43
+ }
44
+ if (range.isSingleHeader() && range.highlight.col < 0) {
43
45
  return true;
44
46
  }
45
47
  const totalColumns = this.countCols();
@@ -1,4 +1,3 @@
1
- import { getValidSelection } from "../utils.mjs";
2
1
  import { transformSelectionToColumnDistance } from "../../../selection/utils.mjs";
3
2
  import * as C from "../../../i18n/constants.mjs";
4
3
  export const KEY = 'remove_col';
@@ -31,8 +30,11 @@ export default function removeColumnItem() {
31
30
  if (!this.isColumnModificationAllowed()) {
32
31
  return true;
33
32
  }
34
- const selected = getValidSelection(this);
35
- if (!selected) {
33
+ const range = this.getSelectedRangeLast();
34
+ if (!range) {
35
+ return true;
36
+ }
37
+ if (range.isSingleHeader() && range.highlight.col < 0) {
36
38
  return true;
37
39
  }
38
40
  const totalColumns = this.countCols();
@@ -2,8 +2,7 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.default = removeRowItem;
5
- var _utils = require("../utils");
6
- var _utils2 = require("../../../selection/utils");
5
+ var _utils = require("../../../selection/utils");
7
6
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
8
7
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
9
8
  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; }
@@ -34,11 +33,14 @@ function removeRowItem() {
34
33
  callback() {
35
34
  // TODO: Please keep in mind that below `1` may be improper. The table's way of work, before change `f1747b3912ea3b21fe423fd102ca94c87db81379` was restored.
36
35
  // There is still problem when removing more than one row.
37
- this.alter('remove_row', (0, _utils2.transformSelectionToRowDistance)(this.getSelected()), 1, 'ContextMenu.removeRow');
36
+ this.alter('remove_row', (0, _utils.transformSelectionToRowDistance)(this.getSelected()), 1, 'ContextMenu.removeRow');
38
37
  },
39
38
  disabled() {
40
- const selected = (0, _utils.getValidSelection)(this);
41
- if (!selected) {
39
+ const range = this.getSelectedRangeLast();
40
+ if (!range) {
41
+ return true;
42
+ }
43
+ if (range.isSingleHeader() && range.highlight.row < 0) {
42
44
  return true;
43
45
  }
44
46
  const totalRows = this.countRows();
@@ -1,4 +1,3 @@
1
- import { getValidSelection } from "../utils.mjs";
2
1
  import { transformSelectionToRowDistance } from "../../../selection/utils.mjs";
3
2
  import * as C from "../../../i18n/constants.mjs";
4
3
  export const KEY = 'remove_row';
@@ -30,8 +29,11 @@ export default function removeRowItem() {
30
29
  this.alter('remove_row', transformSelectionToRowDistance(this.getSelected()), 1, 'ContextMenu.removeRow');
31
30
  },
32
31
  disabled() {
33
- const selected = getValidSelection(this);
34
- if (!selected) {
32
+ const range = this.getSelectedRangeLast();
33
+ if (!range) {
34
+ return true;
35
+ }
36
+ if (range.isSingleHeader() && range.highlight.row < 0) {
35
37
  return true;
36
38
  }
37
39
  const totalRows = this.countRows();
@@ -2,7 +2,6 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.default = rowAboveItem;
5
- var _utils = require("../utils");
6
5
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
7
6
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
8
7
  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; }
@@ -23,8 +22,11 @@ function rowAboveItem() {
23
22
  this.alter('insert_row_above', latestSelection.row, 1, 'ContextMenu.rowAbove');
24
23
  },
25
24
  disabled() {
26
- const selected = (0, _utils.getValidSelection)(this);
27
- if (!selected) {
25
+ const range = this.getSelectedRangeLast();
26
+ if (!range) {
27
+ return true;
28
+ }
29
+ if (range.isSingleHeader() && range.highlight.row < 0) {
28
30
  return true;
29
31
  }
30
32
  if (this.selection.isSelectedByCorner()) {
@@ -1,4 +1,3 @@
1
- import { getValidSelection } from "../utils.mjs";
2
1
  import * as C from "../../../i18n/constants.mjs";
3
2
  export const KEY = 'row_above';
4
3
 
@@ -16,8 +15,11 @@ export default function rowAboveItem() {
16
15
  this.alter('insert_row_above', latestSelection.row, 1, 'ContextMenu.rowAbove');
17
16
  },
18
17
  disabled() {
19
- const selected = getValidSelection(this);
20
- if (!selected) {
18
+ const range = this.getSelectedRangeLast();
19
+ if (!range) {
20
+ return true;
21
+ }
22
+ if (range.isSingleHeader() && range.highlight.row < 0) {
21
23
  return true;
22
24
  }
23
25
  if (this.selection.isSelectedByCorner()) {
@@ -2,7 +2,6 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.default = rowBelowItem;
5
- var _utils = require("../utils");
6
5
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
7
6
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
8
7
  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; }
@@ -23,8 +22,11 @@ function rowBelowItem() {
23
22
  this.alter('insert_row_below', latestSelection.row, 1, 'ContextMenu.rowBelow');
24
23
  },
25
24
  disabled() {
26
- const selected = (0, _utils.getValidSelection)(this);
27
- if (!selected) {
25
+ const range = this.getSelectedRangeLast();
26
+ if (!range) {
27
+ return true;
28
+ }
29
+ if (range.isSingleHeader() && range.highlight.row < 0) {
28
30
  return true;
29
31
  }
30
32
  if (this.selection.isSelectedByCorner()) {
@@ -1,4 +1,3 @@
1
- import { getValidSelection } from "../utils.mjs";
2
1
  import * as C from "../../../i18n/constants.mjs";
3
2
  export const KEY = 'row_below';
4
3
 
@@ -16,8 +15,11 @@ export default function rowBelowItem() {
16
15
  this.alter('insert_row_below', latestSelection.row, 1, 'ContextMenu.rowBelow');
17
16
  },
18
17
  disabled() {
19
- const selected = getValidSelection(this);
20
- if (!selected) {
18
+ const range = this.getSelectedRangeLast();
19
+ if (!range) {
20
+ return true;
21
+ }
22
+ if (range.isSingleHeader() && range.highlight.row < 0) {
21
23
  return true;
22
24
  }
23
25
  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.getValidSelection = getValidSelection;
8
+ exports.getDocumentOffsetByElement = getDocumentOffsetByElement;
9
9
  exports.hasSubMenu = hasSubMenu;
10
10
  exports.isDisabled = isDisabled;
11
11
  exports.isItemHidden = isItemHidden;
@@ -62,21 +62,6 @@ function isSelectionDisabled(cell) {
62
62
  return (0, _element.hasClass)(cell, 'htSelectionDisabled');
63
63
  }
64
64
 
65
- /**
66
- * @param {Core} hot The Handsontable instance.
67
- * @returns {Array[]|null}
68
- */
69
- function getValidSelection(hot) {
70
- const selected = hot.getSelected();
71
- if (!selected) {
72
- return null;
73
- }
74
- if (selected[0] < 0) {
75
- return null;
76
- }
77
- return selected;
78
- }
79
-
80
65
  /**
81
66
  * @param {string} className The full element class name to process.
82
67
  * @param {string} alignment The slignment class name to compare with.
@@ -267,4 +252,31 @@ function filterSeparators(items) {
267
252
  result = popSeparators(result, separator);
268
253
  result = removeDuplicatedSeparators(result);
269
254
  return result;
255
+ }
256
+
257
+ /**
258
+ * Returns document offset based on the passed element. If the document objects between element and the
259
+ * base document are not the same the offset as top and left properties will be returned.
260
+ *
261
+ * @param {Element} elementToCheck The element to compare with Document object.
262
+ * @param {Document} baseDocument The base Document object.
263
+ * @returns {{ top: number, left: number }}
264
+ */
265
+ function getDocumentOffsetByElement(elementToCheck, baseDocument) {
266
+ const offset = {
267
+ top: 0,
268
+ left: 0
269
+ };
270
+ if (baseDocument !== elementToCheck.ownerDocument) {
271
+ const {
272
+ frameElement
273
+ } = baseDocument.defaultView;
274
+ const {
275
+ top,
276
+ left
277
+ } = frameElement.getBoundingClientRect();
278
+ offset.top = top;
279
+ offset.left = left;
280
+ }
281
+ return offset;
270
282
  }
@@ -45,21 +45,6 @@ export function isSelectionDisabled(cell) {
45
45
  return hasClass(cell, 'htSelectionDisabled');
46
46
  }
47
47
 
48
- /**
49
- * @param {Core} hot The Handsontable instance.
50
- * @returns {Array[]|null}
51
- */
52
- export function getValidSelection(hot) {
53
- const selected = hot.getSelected();
54
- if (!selected) {
55
- return null;
56
- }
57
- if (selected[0] < 0) {
58
- return null;
59
- }
60
- return selected;
61
- }
62
-
63
48
  /**
64
49
  * @param {string} className The full element class name to process.
65
50
  * @param {string} alignment The slignment class name to compare with.
@@ -250,4 +235,31 @@ export function filterSeparators(items) {
250
235
  result = popSeparators(result, separator);
251
236
  result = removeDuplicatedSeparators(result);
252
237
  return result;
238
+ }
239
+
240
+ /**
241
+ * Returns document offset based on the passed element. If the document objects between element and the
242
+ * base document are not the same the offset as top and left properties will be returned.
243
+ *
244
+ * @param {Element} elementToCheck The element to compare with Document object.
245
+ * @param {Document} baseDocument The base Document object.
246
+ * @returns {{ top: number, left: number }}
247
+ */
248
+ export function getDocumentOffsetByElement(elementToCheck, baseDocument) {
249
+ const offset = {
250
+ top: 0,
251
+ left: 0
252
+ };
253
+ if (baseDocument !== elementToCheck.ownerDocument) {
254
+ const {
255
+ frameElement
256
+ } = baseDocument.defaultView;
257
+ const {
258
+ top,
259
+ left
260
+ } = frameElement.getBoundingClientRect();
261
+ offset.top = top;
262
+ offset.left = left;
263
+ }
264
+ return offset;
253
265
  }
@@ -20,6 +20,13 @@ function copyItem(copyPastePlugin) {
20
20
  if (this.countRows() === 0 || this.countCols() === 0) {
21
21
  return true;
22
22
  }
23
+ const range = this.getSelectedRangeLast();
24
+ if (!range) {
25
+ return true;
26
+ }
27
+ if (range.isSingleHeader()) {
28
+ return true;
29
+ }
23
30
  const selected = this.getSelected();
24
31
 
25
32
  // Disable for no selection or for non-contiguous selection.
@@ -16,6 +16,13 @@ export default function copyItem(copyPastePlugin) {
16
16
  if (this.countRows() === 0 || this.countCols() === 0) {
17
17
  return true;
18
18
  }
19
+ const range = this.getSelectedRangeLast();
20
+ if (!range) {
21
+ return true;
22
+ }
23
+ if (range.isSingleHeader()) {
24
+ return true;
25
+ }
19
26
  const selected = this.getSelected();
20
27
 
21
28
  // Disable for no selection or for non-contiguous selection.
@@ -3,6 +3,7 @@
3
3
  exports.__esModule = true;
4
4
  exports.default = copyColumnHeadersOnlyItem;
5
5
  var _constants = require("../../../i18n/constants");
6
+ var _number = require("../../../helpers/number");
6
7
  /**
7
8
  * @param {CopyPaste} copyPastePlugin The plugin instance.
8
9
  * @returns {object}
@@ -12,7 +13,7 @@ function copyColumnHeadersOnlyItem(copyPastePlugin) {
12
13
  key: 'copy_column_headers_only',
13
14
  name() {
14
15
  const selectedRange = this.getSelectedRangeLast();
15
- const nounForm = selectedRange ? Math.min(selectedRange.getWidth() - 1, 1) : 0;
16
+ const nounForm = selectedRange ? (0, _number.clamp)(selectedRange.getWidth() - 1, 0, 1) : 0;
16
17
  return this.getTranslatedPhrase(_constants.CONTEXTMENU_ITEMS_COPY_COLUMN_HEADERS_ONLY, nounForm);
17
18
  },
18
19
  callback() {
@@ -22,6 +23,13 @@ function copyColumnHeadersOnlyItem(copyPastePlugin) {
22
23
  if (!this.hasColHeaders()) {
23
24
  return true;
24
25
  }
26
+ const range = this.getSelectedRangeLast();
27
+ if (!range) {
28
+ return true;
29
+ }
30
+ if (range.isSingleHeader()) {
31
+ return true;
32
+ }
25
33
  const selected = this.getSelected();
26
34
 
27
35
  // Disable for no selection or for non-contiguous selection.
@@ -1,4 +1,5 @@
1
1
  import { CONTEXTMENU_ITEMS_COPY_COLUMN_HEADERS_ONLY } from "../../../i18n/constants.mjs";
2
+ import { clamp } from "../../../helpers/number.mjs";
2
3
  /**
3
4
  * @param {CopyPaste} copyPastePlugin The plugin instance.
4
5
  * @returns {object}
@@ -8,7 +9,7 @@ export default function copyColumnHeadersOnlyItem(copyPastePlugin) {
8
9
  key: 'copy_column_headers_only',
9
10
  name() {
10
11
  const selectedRange = this.getSelectedRangeLast();
11
- const nounForm = selectedRange ? Math.min(selectedRange.getWidth() - 1, 1) : 0;
12
+ const nounForm = selectedRange ? clamp(selectedRange.getWidth() - 1, 0, 1) : 0;
12
13
  return this.getTranslatedPhrase(CONTEXTMENU_ITEMS_COPY_COLUMN_HEADERS_ONLY, nounForm);
13
14
  },
14
15
  callback() {
@@ -18,6 +19,13 @@ export default function copyColumnHeadersOnlyItem(copyPastePlugin) {
18
19
  if (!this.hasColHeaders()) {
19
20
  return true;
20
21
  }
22
+ const range = this.getSelectedRangeLast();
23
+ if (!range) {
24
+ return true;
25
+ }
26
+ if (range.isSingleHeader()) {
27
+ return true;
28
+ }
21
29
  const selected = this.getSelected();
22
30
 
23
31
  // Disable for no selection or for non-contiguous selection.
@@ -3,6 +3,7 @@
3
3
  exports.__esModule = true;
4
4
  exports.default = copyWithColumnGroupHeadersItem;
5
5
  var _constants = require("../../../i18n/constants");
6
+ var _number = require("../../../helpers/number");
6
7
  /**
7
8
  * @param {CopyPaste} copyPastePlugin The plugin instance.
8
9
  * @returns {object}
@@ -12,7 +13,7 @@ function copyWithColumnGroupHeadersItem(copyPastePlugin) {
12
13
  key: 'copy_with_column_group_headers',
13
14
  name() {
14
15
  const selectedRange = this.getSelectedRangeLast();
15
- const nounForm = selectedRange ? Math.min(selectedRange.getWidth() - 1, 1) : 0;
16
+ const nounForm = selectedRange ? (0, _number.clamp)(selectedRange.getWidth() - 1, 0, 1) : 0;
16
17
  return this.getTranslatedPhrase(_constants.CONTEXTMENU_ITEMS_COPY_WITH_COLUMN_GROUP_HEADERS, nounForm);
17
18
  },
18
19
  callback() {
@@ -22,6 +23,13 @@ function copyWithColumnGroupHeadersItem(copyPastePlugin) {
22
23
  if (!this.hasColHeaders() || !this.getSettings().nestedHeaders) {
23
24
  return true;
24
25
  }
26
+ const range = this.getSelectedRangeLast();
27
+ if (!range) {
28
+ return true;
29
+ }
30
+ if (range.isSingleHeader()) {
31
+ return true;
32
+ }
25
33
  const selected = this.getSelected();
26
34
 
27
35
  // Disable for no selection or for non-contiguous selection.
@@ -1,4 +1,5 @@
1
1
  import { CONTEXTMENU_ITEMS_COPY_WITH_COLUMN_GROUP_HEADERS } from "../../../i18n/constants.mjs";
2
+ import { clamp } from "../../../helpers/number.mjs";
2
3
  /**
3
4
  * @param {CopyPaste} copyPastePlugin The plugin instance.
4
5
  * @returns {object}
@@ -8,7 +9,7 @@ export default function copyWithColumnGroupHeadersItem(copyPastePlugin) {
8
9
  key: 'copy_with_column_group_headers',
9
10
  name() {
10
11
  const selectedRange = this.getSelectedRangeLast();
11
- const nounForm = selectedRange ? Math.min(selectedRange.getWidth() - 1, 1) : 0;
12
+ const nounForm = selectedRange ? clamp(selectedRange.getWidth() - 1, 0, 1) : 0;
12
13
  return this.getTranslatedPhrase(CONTEXTMENU_ITEMS_COPY_WITH_COLUMN_GROUP_HEADERS, nounForm);
13
14
  },
14
15
  callback() {
@@ -18,6 +19,13 @@ export default function copyWithColumnGroupHeadersItem(copyPastePlugin) {
18
19
  if (!this.hasColHeaders() || !this.getSettings().nestedHeaders) {
19
20
  return true;
20
21
  }
22
+ const range = this.getSelectedRangeLast();
23
+ if (!range) {
24
+ return true;
25
+ }
26
+ if (range.isSingleHeader()) {
27
+ return true;
28
+ }
21
29
  const selected = this.getSelected();
22
30
 
23
31
  // Disable for no selection or for non-contiguous selection.
@@ -3,6 +3,7 @@
3
3
  exports.__esModule = true;
4
4
  exports.default = copyWithColumnHeadersItem;
5
5
  var _constants = require("../../../i18n/constants");
6
+ var _number = require("../../../helpers/number");
6
7
  /**
7
8
  * @param {CopyPaste} copyPastePlugin The plugin instance.
8
9
  * @returns {object}
@@ -12,7 +13,7 @@ function copyWithColumnHeadersItem(copyPastePlugin) {
12
13
  key: 'copy_with_column_headers',
13
14
  name() {
14
15
  const selectedRange = this.getSelectedRangeLast();
15
- const nounForm = selectedRange ? Math.min(selectedRange.getWidth() - 1, 1) : 0;
16
+ const nounForm = selectedRange ? (0, _number.clamp)(selectedRange.getWidth() - 1, 0, 1) : 0;
16
17
  return this.getTranslatedPhrase(_constants.CONTEXTMENU_ITEMS_COPY_WITH_COLUMN_HEADERS, nounForm);
17
18
  },
18
19
  callback() {
@@ -22,6 +23,13 @@ function copyWithColumnHeadersItem(copyPastePlugin) {
22
23
  if (!this.hasColHeaders()) {
23
24
  return true;
24
25
  }
26
+ const range = this.getSelectedRangeLast();
27
+ if (!range) {
28
+ return true;
29
+ }
30
+ if (range.isSingleHeader()) {
31
+ return true;
32
+ }
25
33
  const selected = this.getSelected();
26
34
 
27
35
  // Disable for no selection or for non-contiguous selection.
@@ -1,4 +1,5 @@
1
1
  import { CONTEXTMENU_ITEMS_COPY_WITH_COLUMN_HEADERS } from "../../../i18n/constants.mjs";
2
+ import { clamp } from "../../../helpers/number.mjs";
2
3
  /**
3
4
  * @param {CopyPaste} copyPastePlugin The plugin instance.
4
5
  * @returns {object}
@@ -8,7 +9,7 @@ export default function copyWithColumnHeadersItem(copyPastePlugin) {
8
9
  key: 'copy_with_column_headers',
9
10
  name() {
10
11
  const selectedRange = this.getSelectedRangeLast();
11
- const nounForm = selectedRange ? Math.min(selectedRange.getWidth() - 1, 1) : 0;
12
+ const nounForm = selectedRange ? clamp(selectedRange.getWidth() - 1, 0, 1) : 0;
12
13
  return this.getTranslatedPhrase(CONTEXTMENU_ITEMS_COPY_WITH_COLUMN_HEADERS, nounForm);
13
14
  },
14
15
  callback() {
@@ -18,6 +19,13 @@ export default function copyWithColumnHeadersItem(copyPastePlugin) {
18
19
  if (!this.hasColHeaders()) {
19
20
  return true;
20
21
  }
22
+ const range = this.getSelectedRangeLast();
23
+ if (!range) {
24
+ return true;
25
+ }
26
+ if (range.isSingleHeader()) {
27
+ return true;
28
+ }
21
29
  const selected = this.getSelected();
22
30
 
23
31
  // Disable for no selection or for non-contiguous selection.
@@ -22,6 +22,13 @@ function cutItem(copyPastePlugin) {
22
22
  if (this.countRows() === 0 || this.countCols() === 0) {
23
23
  return true;
24
24
  }
25
+ const range = this.getSelectedRangeLast();
26
+ if (!range) {
27
+ return true;
28
+ }
29
+ if (range.isSingleHeader()) {
30
+ return true;
31
+ }
25
32
  const selected = this.getSelected();
26
33
 
27
34
  // Disable for no selection or for non-contiquous selection.
@@ -16,6 +16,13 @@ export default function cutItem(copyPastePlugin) {
16
16
  if (this.countRows() === 0 || this.countCols() === 0) {
17
17
  return true;
18
18
  }
19
+ const range = this.getSelectedRangeLast();
20
+ if (!range) {
21
+ return true;
22
+ }
23
+ if (range.isSingleHeader()) {
24
+ return true;
25
+ }
19
26
  const selected = this.getSelected();
20
27
 
21
28
  // Disable for no selection or for non-contiquous selection.