handsontable 0.0.0-next-03bda88-20230622 → 0.0.0-next-c3d199b-20230626

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 (284) hide show
  1. package/3rdparty/walkontable/src/cell/coords.d.ts +6 -1
  2. package/3rdparty/walkontable/src/cell/coords.js +61 -12
  3. package/3rdparty/walkontable/src/cell/coords.mjs +61 -12
  4. package/3rdparty/walkontable/src/cell/range.d.ts +9 -2
  5. package/3rdparty/walkontable/src/cell/range.js +44 -7
  6. package/3rdparty/walkontable/src/cell/range.mjs +44 -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 -4
  22. package/3rdparty/walkontable/src/overlay/inlineStart.mjs +2 -4
  23. package/3rdparty/walkontable/src/overlay/top.js +2 -4
  24. package/3rdparty/walkontable/src/overlay/top.mjs +2 -4
  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 +18 -0
  28. package/3rdparty/walkontable/src/selection/border/constants.mjs +13 -0
  29. package/3rdparty/walkontable/src/selection/constants.js +63 -0
  30. package/3rdparty/walkontable/src/selection/constants.mjs +51 -0
  31. package/3rdparty/walkontable/src/selection/index.js +30 -0
  32. package/3rdparty/walkontable/src/selection/index.mjs +5 -0
  33. package/3rdparty/walkontable/src/selection/manager.js +329 -0
  34. package/3rdparty/walkontable/src/selection/manager.mjs +323 -0
  35. package/3rdparty/walkontable/src/selection/scanner.js +364 -0
  36. package/3rdparty/walkontable/src/selection/scanner.mjs +360 -0
  37. package/3rdparty/walkontable/src/selection/selection.js +133 -0
  38. package/3rdparty/walkontable/src/selection/selection.mjs +127 -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 +7 -79
  50. package/3rdparty/walkontable/src/table.mjs +8 -80
  51. package/CHANGELOG.md +0 -31
  52. package/base.js +2 -2
  53. package/base.mjs +2 -2
  54. package/core.d.ts +5 -3
  55. package/core.js +127 -309
  56. package/core.mjs +127 -309
  57. package/dataMap/metaManager/metaSchema.js +19 -0
  58. package/dataMap/metaManager/metaSchema.mjs +19 -0
  59. package/dist/handsontable.css +8 -3
  60. package/dist/handsontable.full.css +8 -3
  61. package/dist/handsontable.full.js +15283 -12109
  62. package/dist/handsontable.full.min.css +3 -3
  63. package/dist/handsontable.full.min.js +115 -115
  64. package/dist/handsontable.js +23364 -20190
  65. package/dist/handsontable.min.css +3 -3
  66. package/dist/handsontable.min.js +4 -4
  67. package/editorManager.js +21 -94
  68. package/editorManager.mjs +26 -98
  69. package/editors/textEditor/textEditor.js +3 -11
  70. package/editors/textEditor/textEditor.mjs +4 -12
  71. package/helpers/mixed.js +2 -2
  72. package/helpers/mixed.mjs +2 -2
  73. package/helpers/number.d.ts +1 -0
  74. package/helpers/number.js +18 -0
  75. package/helpers/number.mjs +17 -0
  76. package/package.json +1 -1
  77. package/pluginHooks.d.ts +5 -1
  78. package/pluginHooks.js +89 -1
  79. package/pluginHooks.mjs +89 -1
  80. package/plugins/collapsibleColumns/collapsibleColumns.js +81 -24
  81. package/plugins/collapsibleColumns/collapsibleColumns.mjs +81 -24
  82. package/plugins/columnSorting/columnSorting.js +50 -8
  83. package/plugins/columnSorting/columnSorting.mjs +49 -9
  84. package/plugins/columnSorting/index.js +4 -2
  85. package/plugins/columnSorting/index.mjs +1 -1
  86. package/plugins/comments/commentEditor.js +1 -0
  87. package/plugins/comments/commentEditor.mjs +1 -0
  88. package/plugins/comments/comments.js +263 -224
  89. package/plugins/comments/comments.mjs +271 -234
  90. package/plugins/comments/contextMenuItem/addEditComment.js +51 -0
  91. package/plugins/comments/contextMenuItem/addEditComment.mjs +35 -0
  92. package/plugins/comments/contextMenuItem/readOnlyComment.js +63 -0
  93. package/plugins/comments/contextMenuItem/readOnlyComment.mjs +55 -0
  94. package/plugins/comments/contextMenuItem/removeComment.js +48 -0
  95. package/plugins/comments/contextMenuItem/removeComment.mjs +32 -0
  96. package/plugins/contextMenu/contextMenu.d.ts +1 -1
  97. package/plugins/contextMenu/contextMenu.js +80 -29
  98. package/plugins/contextMenu/contextMenu.mjs +81 -30
  99. package/plugins/contextMenu/predefinedItems/alignment.js +7 -0
  100. package/plugins/contextMenu/predefinedItems/alignment.mjs +7 -0
  101. package/plugins/contextMenu/predefinedItems/clearColumn.js +5 -3
  102. package/plugins/contextMenu/predefinedItems/clearColumn.mjs +5 -3
  103. package/plugins/contextMenu/predefinedItems/columnLeft.js +5 -3
  104. package/plugins/contextMenu/predefinedItems/columnLeft.mjs +5 -3
  105. package/plugins/contextMenu/predefinedItems/columnRight.js +5 -3
  106. package/plugins/contextMenu/predefinedItems/columnRight.mjs +5 -3
  107. package/plugins/contextMenu/predefinedItems/readOnly.js +7 -0
  108. package/plugins/contextMenu/predefinedItems/readOnly.mjs +7 -0
  109. package/plugins/contextMenu/predefinedItems/removeColumn.js +7 -5
  110. package/plugins/contextMenu/predefinedItems/removeColumn.mjs +5 -3
  111. package/plugins/contextMenu/predefinedItems/removeRow.js +7 -5
  112. package/plugins/contextMenu/predefinedItems/removeRow.mjs +5 -3
  113. package/plugins/contextMenu/predefinedItems/rowAbove.js +5 -3
  114. package/plugins/contextMenu/predefinedItems/rowAbove.mjs +5 -3
  115. package/plugins/contextMenu/predefinedItems/rowBelow.js +5 -3
  116. package/plugins/contextMenu/predefinedItems/rowBelow.mjs +5 -3
  117. package/plugins/contextMenu/utils.js +25 -16
  118. package/plugins/contextMenu/utils.mjs +24 -15
  119. package/plugins/copyPaste/contextMenuItem/copy.js +7 -0
  120. package/plugins/copyPaste/contextMenuItem/copy.mjs +7 -0
  121. package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.js +9 -1
  122. package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.mjs +9 -1
  123. package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.js +9 -1
  124. package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.mjs +9 -1
  125. package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.js +9 -1
  126. package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.mjs +9 -1
  127. package/plugins/copyPaste/contextMenuItem/cut.js +7 -0
  128. package/plugins/copyPaste/contextMenuItem/cut.mjs +7 -0
  129. package/plugins/copyPaste/copyPaste.js +6 -2
  130. package/plugins/copyPaste/copyPaste.mjs +6 -2
  131. package/plugins/customBorders/customBorders.js +25 -53
  132. package/plugins/customBorders/customBorders.mjs +26 -54
  133. package/plugins/dropdownMenu/dropdownMenu.d.ts +1 -1
  134. package/plugins/dropdownMenu/dropdownMenu.js +94 -30
  135. package/plugins/dropdownMenu/dropdownMenu.mjs +94 -30
  136. package/plugins/mergeCells/mergeCells.js +5 -18
  137. package/plugins/mergeCells/mergeCells.mjs +5 -18
  138. package/plugins/multiColumnSorting/multiColumnSorting.js +42 -3
  139. package/plugins/multiColumnSorting/multiColumnSorting.mjs +42 -3
  140. package/plugins/nestedHeaders/nestedHeaders.js +132 -10
  141. package/plugins/nestedHeaders/nestedHeaders.mjs +132 -10
  142. package/plugins/nestedHeaders/stateManager/index.js +37 -0
  143. package/plugins/nestedHeaders/stateManager/index.mjs +37 -0
  144. package/plugins/nestedRows/nestedRows.js +52 -7
  145. package/plugins/nestedRows/nestedRows.mjs +52 -7
  146. package/renderers/checkboxRenderer/checkboxRenderer.js +2 -2
  147. package/renderers/checkboxRenderer/checkboxRenderer.mjs +1 -1
  148. package/selection/highlight/highlight.js +312 -89
  149. package/selection/highlight/highlight.mjs +302 -85
  150. package/selection/highlight/types/activeHeader.js +10 -9
  151. package/selection/highlight/types/activeHeader.mjs +10 -8
  152. package/selection/highlight/types/area.js +12 -27
  153. package/selection/highlight/types/area.mjs +16 -30
  154. package/selection/highlight/types/areaLayered.js +54 -0
  155. package/selection/highlight/types/areaLayered.mjs +49 -0
  156. package/selection/highlight/types/column.js +50 -0
  157. package/selection/highlight/types/column.mjs +45 -0
  158. package/selection/highlight/types/customSelection.js +7 -10
  159. package/selection/highlight/types/customSelection.mjs +7 -9
  160. package/selection/highlight/types/fill.js +5 -8
  161. package/selection/highlight/types/fill.mjs +5 -7
  162. package/selection/highlight/types/{cell.js → focus.js} +5 -8
  163. package/selection/highlight/types/{cell.mjs → focus.mjs} +5 -7
  164. package/selection/highlight/types/header.js +10 -20
  165. package/selection/highlight/types/header.mjs +10 -19
  166. package/selection/highlight/types/{index.js → row.js} +27 -31
  167. package/selection/highlight/types/{index.mjs → row.mjs} +24 -29
  168. package/selection/highlight/visualSelection.js +31 -27
  169. package/selection/highlight/visualSelection.mjs +31 -27
  170. package/selection/index.js +4 -7
  171. package/selection/index.mjs +2 -3
  172. package/selection/mouseEventHandler.js +1 -1
  173. package/selection/mouseEventHandler.mjs +1 -1
  174. package/selection/range.js +8 -8
  175. package/selection/range.mjs +8 -8
  176. package/selection/selection.js +315 -181
  177. package/selection/selection.mjs +310 -180
  178. package/selection/transformation.js +233 -96
  179. package/selection/transformation.mjs +230 -93
  180. package/selection/utils.js +12 -36
  181. package/selection/utils.mjs +13 -36
  182. package/settings.d.ts +1 -0
  183. package/shortcutContexts/commands/editor/closeAndSave.js +15 -0
  184. package/shortcutContexts/commands/editor/closeAndSave.mjs +10 -0
  185. package/shortcutContexts/commands/editor/closeWithoutSaving.js +13 -0
  186. package/shortcutContexts/commands/editor/closeWithoutSaving.mjs +8 -0
  187. package/shortcutContexts/commands/editor/fastOpen.js +16 -0
  188. package/shortcutContexts/commands/editor/fastOpen.mjs +11 -0
  189. package/shortcutContexts/commands/editor/index.js +16 -0
  190. package/shortcutContexts/commands/editor/index.mjs +12 -0
  191. package/shortcutContexts/commands/editor/open.js +29 -0
  192. package/shortcutContexts/commands/editor/open.mjs +24 -0
  193. package/shortcutContexts/commands/emptySelectedCells.js +12 -0
  194. package/shortcutContexts/commands/emptySelectedCells.mjs +7 -0
  195. package/shortcutContexts/commands/extendCellsSelection/down.js +15 -0
  196. package/shortcutContexts/commands/extendCellsSelection/down.mjs +10 -0
  197. package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.js +21 -0
  198. package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.mjs +16 -0
  199. package/shortcutContexts/commands/extendCellsSelection/index.js +26 -0
  200. package/shortcutContexts/commands/extendCellsSelection/index.mjs +22 -0
  201. package/shortcutContexts/commands/extendCellsSelection/left.js +15 -0
  202. package/shortcutContexts/commands/extendCellsSelection/left.mjs +10 -0
  203. package/shortcutContexts/commands/extendCellsSelection/right.js +15 -0
  204. package/shortcutContexts/commands/extendCellsSelection/right.mjs +10 -0
  205. package/shortcutContexts/commands/extendCellsSelection/toColumns.js +19 -0
  206. package/shortcutContexts/commands/extendCellsSelection/toColumns.mjs +14 -0
  207. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +22 -0
  208. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +17 -0
  209. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +17 -0
  210. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +12 -0
  211. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +17 -0
  212. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +12 -0
  213. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +40 -0
  214. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +35 -0
  215. package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +40 -0
  216. package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +35 -0
  217. package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +22 -0
  218. package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +17 -0
  219. package/shortcutContexts/commands/extendCellsSelection/toRows.js +19 -0
  220. package/shortcutContexts/commands/extendCellsSelection/toRows.mjs +14 -0
  221. package/shortcutContexts/commands/extendCellsSelection/up.js +15 -0
  222. package/shortcutContexts/commands/extendCellsSelection/up.mjs +10 -0
  223. package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.js +21 -0
  224. package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.mjs +16 -0
  225. package/shortcutContexts/commands/index.js +52 -0
  226. package/shortcutContexts/commands/index.mjs +48 -0
  227. package/shortcutContexts/commands/moveCellSelection/down.js +12 -0
  228. package/shortcutContexts/commands/moveCellSelection/down.mjs +7 -0
  229. package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.js +29 -0
  230. package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.mjs +24 -0
  231. package/shortcutContexts/commands/moveCellSelection/index.js +28 -0
  232. package/shortcutContexts/commands/moveCellSelection/index.mjs +24 -0
  233. package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +13 -0
  234. package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +8 -0
  235. package/shortcutContexts/commands/moveCellSelection/inlineStart.js +13 -0
  236. package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +8 -0
  237. package/shortcutContexts/commands/moveCellSelection/left.js +11 -0
  238. package/shortcutContexts/commands/moveCellSelection/left.mjs +6 -0
  239. package/shortcutContexts/commands/moveCellSelection/right.js +11 -0
  240. package/shortcutContexts/commands/moveCellSelection/right.mjs +6 -0
  241. package/shortcutContexts/commands/moveCellSelection/toMostBottom.js +16 -0
  242. package/shortcutContexts/commands/moveCellSelection/toMostBottom.mjs +11 -0
  243. package/shortcutContexts/commands/moveCellSelection/toMostBottomInlineEnd.js +17 -0
  244. package/shortcutContexts/commands/moveCellSelection/toMostBottomInlineEnd.mjs +12 -0
  245. package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.js +13 -0
  246. package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.mjs +8 -0
  247. package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.js +16 -0
  248. package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.mjs +11 -0
  249. package/shortcutContexts/commands/moveCellSelection/toMostLeft.js +36 -0
  250. package/shortcutContexts/commands/moveCellSelection/toMostLeft.mjs +31 -0
  251. package/shortcutContexts/commands/moveCellSelection/toMostRight.js +36 -0
  252. package/shortcutContexts/commands/moveCellSelection/toMostRight.mjs +31 -0
  253. package/shortcutContexts/commands/moveCellSelection/toMostTop.js +16 -0
  254. package/shortcutContexts/commands/moveCellSelection/toMostTop.mjs +11 -0
  255. package/shortcutContexts/commands/moveCellSelection/toMostTopInlineStart.js +18 -0
  256. package/shortcutContexts/commands/moveCellSelection/toMostTopInlineStart.mjs +13 -0
  257. package/shortcutContexts/commands/moveCellSelection/up.js +12 -0
  258. package/shortcutContexts/commands/moveCellSelection/up.mjs +7 -0
  259. package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.js +29 -0
  260. package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.mjs +24 -0
  261. package/shortcutContexts/commands/populateSelectedCellsData.js +35 -0
  262. package/shortcutContexts/commands/populateSelectedCellsData.mjs +30 -0
  263. package/shortcutContexts/commands/selectAll.js +11 -0
  264. package/shortcutContexts/commands/selectAll.mjs +6 -0
  265. package/shortcutContexts/constants.js +19 -0
  266. package/shortcutContexts/constants.mjs +12 -0
  267. package/shortcutContexts/editor.js +29 -0
  268. package/shortcutContexts/editor.mjs +25 -0
  269. package/shortcutContexts/grid.js +247 -0
  270. package/shortcutContexts/grid.mjs +243 -0
  271. package/shortcutContexts/index.js +29 -0
  272. package/shortcutContexts/index.mjs +15 -0
  273. package/shortcuts/manager.js +2 -0
  274. package/shortcuts/manager.mjs +2 -0
  275. package/shortcuts/recorder.js +2 -2
  276. package/shortcuts/recorder.mjs +2 -2
  277. package/shortcuts/utils.js +21 -5
  278. package/shortcuts/utils.mjs +20 -4
  279. package/tableView.js +63 -11
  280. package/tableView.mjs +63 -11
  281. package/3rdparty/walkontable/src/selection.js +0 -355
  282. package/3rdparty/walkontable/src/selection.mjs +0 -349
  283. package/selection/highlight/constants.js +0 -16
  284. package/selection/highlight/constants.mjs +0 -6
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+ require("core-js/modules/es.array.iterator.js");
5
+ require("core-js/modules/es.object.to-string.js");
6
+ require("core-js/modules/es.string.iterator.js");
7
+ require("core-js/modules/es.weak-map.js");
8
+ require("core-js/modules/web.dom-collections.iterator.js");
9
+ require("core-js/modules/es.object.get-own-property-descriptor.js");
10
+ require("core-js/modules/es.symbol.js");
11
+ require("core-js/modules/es.symbol.description.js");
12
+ require("core-js/modules/es.symbol.iterator.js");
13
+ exports.__esModule = true;
14
+ exports.default = addEditCommentItem;
15
+ var C = _interopRequireWildcard(require("../../../i18n/constants"));
16
+ 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); }
17
+ 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; }
18
+ /**
19
+ * @param {Comments} plugin The Comments plugin instance.
20
+ * @returns {object}
21
+ */
22
+ function addEditCommentItem(plugin) {
23
+ return {
24
+ key: 'commentsAddEdit',
25
+ name: function name() {
26
+ var _this$getSelectedRang;
27
+ var highlight = (_this$getSelectedRang = this.getSelectedRangeLast()) === null || _this$getSelectedRang === void 0 ? void 0 : _this$getSelectedRang.highlight;
28
+ if (highlight && highlight.isCell() && plugin.getCommentAtCell(highlight.row, highlight.col)) {
29
+ return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_EDIT_COMMENT);
30
+ }
31
+ return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ADD_COMMENT);
32
+ },
33
+ callback: function callback() {
34
+ var range = this.getSelectedRangeLast();
35
+ this.deselectCell();
36
+ plugin.setRange(range);
37
+ plugin.show();
38
+ plugin.focusEditor();
39
+ },
40
+ disabled: function disabled() {
41
+ var range = this.getSelectedRangeLast();
42
+ if (!range) {
43
+ return true;
44
+ }
45
+ if (range.highlight.isHeader()) {
46
+ return true;
47
+ }
48
+ return this.countRenderedRows() === 0 || this.countRenderedCols() === 0;
49
+ }
50
+ };
51
+ }
@@ -0,0 +1,35 @@
1
+ import * as C from "../../../i18n/constants.mjs";
2
+ /**
3
+ * @param {Comments} plugin The Comments plugin instance.
4
+ * @returns {object}
5
+ */
6
+ export default function addEditCommentItem(plugin) {
7
+ return {
8
+ key: 'commentsAddEdit',
9
+ name: function name() {
10
+ var _this$getSelectedRang;
11
+ var highlight = (_this$getSelectedRang = this.getSelectedRangeLast()) === null || _this$getSelectedRang === void 0 ? void 0 : _this$getSelectedRang.highlight;
12
+ if (highlight && highlight.isCell() && plugin.getCommentAtCell(highlight.row, highlight.col)) {
13
+ return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_EDIT_COMMENT);
14
+ }
15
+ return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ADD_COMMENT);
16
+ },
17
+ callback: function callback() {
18
+ var range = this.getSelectedRangeLast();
19
+ this.deselectCell();
20
+ plugin.setRange(range);
21
+ plugin.show();
22
+ plugin.focusEditor();
23
+ },
24
+ disabled: function disabled() {
25
+ var range = this.getSelectedRangeLast();
26
+ if (!range) {
27
+ return true;
28
+ }
29
+ if (range.highlight.isHeader()) {
30
+ return true;
31
+ }
32
+ return this.countRenderedRows() === 0 || this.countRenderedCols() === 0;
33
+ }
34
+ };
35
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.symbol.iterator.js");
4
+ require("core-js/modules/es.array.iterator.js");
5
+ require("core-js/modules/es.string.iterator.js");
6
+ require("core-js/modules/web.dom-collections.iterator.js");
7
+ require("core-js/modules/es.weak-map.js");
8
+ require("core-js/modules/es.object.get-own-property-descriptor.js");
9
+ exports.__esModule = true;
10
+ exports.default = readOnlyCommentItem;
11
+ require("core-js/modules/es.symbol.to-primitive.js");
12
+ require("core-js/modules/es.date.to-primitive.js");
13
+ require("core-js/modules/es.symbol.js");
14
+ require("core-js/modules/es.symbol.description.js");
15
+ require("core-js/modules/es.object.to-string.js");
16
+ require("core-js/modules/es.number.constructor.js");
17
+ var C = _interopRequireWildcard(require("../../../i18n/constants"));
18
+ var _utils = require("../../contextMenu/utils");
19
+ var _comments = require("../comments");
20
+ 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); }
21
+ 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; }
22
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
23
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
24
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
25
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
26
+ /**
27
+ * @param {Comments} plugin The Comments plugin instance.
28
+ * @returns {object}
29
+ */
30
+ function readOnlyCommentItem(plugin) {
31
+ return {
32
+ key: 'commentsReadOnly',
33
+ name: function name() {
34
+ var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_READ_ONLY_COMMENT);
35
+ var areReadOnly = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
36
+ return plugin.getCommentMeta(row, col, _comments.META_READONLY);
37
+ });
38
+ return areReadOnly ? (0, _utils.markLabelAsSelected)(label) : label;
39
+ },
40
+ callback: function callback() {
41
+ var range = this.getSelectedRangeLast();
42
+ range.forAll(function (row, column) {
43
+ if (row >= 0 && column >= 0) {
44
+ var currentState = !!plugin.getCommentMeta(row, column, _comments.META_READONLY);
45
+ plugin.updateCommentMeta(row, column, _defineProperty({}, _comments.META_READONLY, !currentState));
46
+ }
47
+ });
48
+ },
49
+ disabled: function disabled() {
50
+ var range = this.getSelectedRangeLast();
51
+ if (!range) {
52
+ return true;
53
+ }
54
+ if (range.highlight.isHeader()) {
55
+ return true;
56
+ }
57
+ if (!plugin.getCommentAtCell(range.highlight.row, range.highlight.col)) {
58
+ return true;
59
+ }
60
+ return this.countRenderedRows() === 0 || this.countRenderedCols() === 0;
61
+ }
62
+ };
63
+ }
@@ -0,0 +1,55 @@
1
+ import "core-js/modules/es.symbol.to-primitive.js";
2
+ import "core-js/modules/es.date.to-primitive.js";
3
+ import "core-js/modules/es.symbol.js";
4
+ import "core-js/modules/es.symbol.description.js";
5
+ import "core-js/modules/es.object.to-string.js";
6
+ import "core-js/modules/es.number.constructor.js";
7
+ import "core-js/modules/es.symbol.iterator.js";
8
+ import "core-js/modules/es.array.iterator.js";
9
+ import "core-js/modules/es.string.iterator.js";
10
+ import "core-js/modules/web.dom-collections.iterator.js";
11
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
12
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
14
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
15
+ import * as C from "../../../i18n/constants.mjs";
16
+ import { checkSelectionConsistency, markLabelAsSelected } from "../../contextMenu/utils.mjs";
17
+ import { META_READONLY } from "../comments.mjs";
18
+ /**
19
+ * @param {Comments} plugin The Comments plugin instance.
20
+ * @returns {object}
21
+ */
22
+ export default function readOnlyCommentItem(plugin) {
23
+ return {
24
+ key: 'commentsReadOnly',
25
+ name: function name() {
26
+ var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_READ_ONLY_COMMENT);
27
+ var areReadOnly = checkSelectionConsistency(this.getSelectedRange(), function (row, col) {
28
+ return plugin.getCommentMeta(row, col, META_READONLY);
29
+ });
30
+ return areReadOnly ? markLabelAsSelected(label) : label;
31
+ },
32
+ callback: function callback() {
33
+ var range = this.getSelectedRangeLast();
34
+ range.forAll(function (row, column) {
35
+ if (row >= 0 && column >= 0) {
36
+ var currentState = !!plugin.getCommentMeta(row, column, META_READONLY);
37
+ plugin.updateCommentMeta(row, column, _defineProperty({}, META_READONLY, !currentState));
38
+ }
39
+ });
40
+ },
41
+ disabled: function disabled() {
42
+ var range = this.getSelectedRangeLast();
43
+ if (!range) {
44
+ return true;
45
+ }
46
+ if (range.highlight.isHeader()) {
47
+ return true;
48
+ }
49
+ if (!plugin.getCommentAtCell(range.highlight.row, range.highlight.col)) {
50
+ return true;
51
+ }
52
+ return this.countRenderedRows() === 0 || this.countRenderedCols() === 0;
53
+ }
54
+ };
55
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+ require("core-js/modules/es.array.iterator.js");
5
+ require("core-js/modules/es.object.to-string.js");
6
+ require("core-js/modules/es.string.iterator.js");
7
+ require("core-js/modules/es.weak-map.js");
8
+ require("core-js/modules/web.dom-collections.iterator.js");
9
+ require("core-js/modules/es.object.get-own-property-descriptor.js");
10
+ require("core-js/modules/es.symbol.js");
11
+ require("core-js/modules/es.symbol.description.js");
12
+ require("core-js/modules/es.symbol.iterator.js");
13
+ exports.__esModule = true;
14
+ exports.default = removeCommentItem;
15
+ var C = _interopRequireWildcard(require("../../../i18n/constants"));
16
+ 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); }
17
+ 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; }
18
+ /**
19
+ * @param {Comments} plugin The Comments plugin instance.
20
+ * @returns {object}
21
+ */
22
+ function removeCommentItem(plugin) {
23
+ return {
24
+ key: 'commentsRemove',
25
+ name: function name() {
26
+ return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_REMOVE_COMMENT);
27
+ },
28
+ callback: function callback() {
29
+ var range = this.getSelectedRangeLast();
30
+ range.forAll(function (row, column) {
31
+ if (row >= 0 && column >= 0) {
32
+ plugin.removeCommentAtCell(row, column, false);
33
+ }
34
+ });
35
+ this.render();
36
+ },
37
+ disabled: function disabled() {
38
+ var range = this.getSelectedRangeLast();
39
+ if (!range) {
40
+ return true;
41
+ }
42
+ if (range.highlight.isHeader()) {
43
+ return true;
44
+ }
45
+ return this.countRenderedRows() === 0 || this.countRenderedCols() === 0;
46
+ }
47
+ };
48
+ }
@@ -0,0 +1,32 @@
1
+ import * as C from "../../../i18n/constants.mjs";
2
+ /**
3
+ * @param {Comments} plugin The Comments plugin instance.
4
+ * @returns {object}
5
+ */
6
+ export default function removeCommentItem(plugin) {
7
+ return {
8
+ key: 'commentsRemove',
9
+ name: function name() {
10
+ return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_REMOVE_COMMENT);
11
+ },
12
+ callback: function callback() {
13
+ var range = this.getSelectedRangeLast();
14
+ range.forAll(function (row, column) {
15
+ if (row >= 0 && column >= 0) {
16
+ plugin.removeCommentAtCell(row, column, false);
17
+ }
18
+ });
19
+ this.render();
20
+ },
21
+ disabled: function disabled() {
22
+ var range = this.getSelectedRangeLast();
23
+ if (!range) {
24
+ return true;
25
+ }
26
+ if (range.highlight.isHeader()) {
27
+ return true;
28
+ }
29
+ return this.countRenderedRows() === 0 || this.countRenderedCols() === 0;
30
+ }
31
+ };
32
+ }
@@ -60,7 +60,7 @@ export class ContextMenu extends BasePlugin {
60
60
 
61
61
  constructor(hotInstance: Core);
62
62
  isEnabled(): boolean;
63
- open(event: Event): void;
63
+ open(position: { left: number, top: number } | Event, offset?: { above?: number, below?: number, left?: number, right?: number }): void;
64
64
  close(): void;
65
65
  executeCommand(commandName: string, ...params: any): void;
66
66
  }
@@ -22,10 +22,12 @@ require("core-js/modules/es.object.get-prototype-of.js");
22
22
  var _base = require("../base");
23
23
  var _pluginHooks = _interopRequireDefault(require("../../pluginHooks"));
24
24
  var _array = require("../../helpers/array");
25
+ var _object = require("../../helpers/object");
25
26
  var _commandExecutor = _interopRequireDefault(require("./commandExecutor"));
26
27
  var _eventManager = _interopRequireDefault(require("../../eventManager"));
27
28
  var _itemsFactory = _interopRequireDefault(require("./itemsFactory"));
28
29
  var _menu = _interopRequireDefault(require("./menu"));
30
+ var _utils = require("./utils");
29
31
  var _element = require("../../helpers/dom/element");
30
32
  var _predefinedItems = require("./predefinedItems");
31
33
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -47,6 +49,7 @@ var PLUGIN_KEY = 'contextMenu';
47
49
  exports.PLUGIN_KEY = PLUGIN_KEY;
48
50
  var PLUGIN_PRIORITY = 70;
49
51
  exports.PLUGIN_PRIORITY = PLUGIN_PRIORITY;
52
+ var SHORTCUTS_GROUP = PLUGIN_KEY;
50
53
  _pluginHooks.default.getSingleton().register('afterContextMenuDefaultOptions');
51
54
  _pluginHooks.default.getSingleton().register('beforeContextMenuShow');
52
55
  _pluginHooks.default.getSingleton().register('afterContextMenuShow');
@@ -168,6 +171,7 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
168
171
  this.addHook('afterOnCellContextMenu', function (event) {
169
172
  return _this2.onAfterOnCellContextMenu(event);
170
173
  });
174
+ this.registerShortcuts();
171
175
  _get(_getPrototypeOf(ContextMenu.prototype), "enablePlugin", this).call(this);
172
176
  }
173
177
 
@@ -182,6 +186,7 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
182
186
  value: function updatePlugin() {
183
187
  this.disablePlugin();
184
188
  this.enablePlugin();
189
+ this.unregisterShortcuts();
185
190
  _get(_getPrototypeOf(ContextMenu.prototype), "updatePlugin", this).call(this);
186
191
  }
187
192
 
@@ -199,39 +204,83 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
199
204
  _get(_getPrototypeOf(ContextMenu.prototype), "disablePlugin", this).call(this);
200
205
  }
201
206
 
207
+ /**
208
+ * Register shortcuts responsible for toggling context menu.
209
+ *
210
+ * @private
211
+ */
212
+ }, {
213
+ key: "registerShortcuts",
214
+ value: function registerShortcuts() {
215
+ var _this3 = this;
216
+ this.hot.getShortcutManager().getContext('grid').addShortcut({
217
+ keys: [['Control/Meta', 'Shift', '\\'], ['Shift', 'F10']],
218
+ callback: function callback() {
219
+ var _this3$hot$getSelecte = _this3.hot.getSelectedRangeLast(),
220
+ highlight = _this3$hot$getSelecte.highlight;
221
+ var rect = _this3.hot.getCell(highlight.row, highlight.col, true).getBoundingClientRect();
222
+ var offset = (0, _utils.getDocumentOffsetByElement)(_this3.menu.container, _this3.hot.rootDocument);
223
+ _this3.open({
224
+ left: rect.left + offset.left,
225
+ top: rect.top + offset.top - 1 + rect.height
226
+ }, {
227
+ left: rect.width,
228
+ above: -rect.height
229
+ });
230
+ _this3.hot._registerTimeout(function () {
231
+ _this3.menu.selectFirstCell();
232
+ });
233
+ },
234
+ runOnlyIf: function runOnlyIf() {
235
+ return _this3.hot.getSelectedRangeLast() && !_this3.menu.isOpened();
236
+ },
237
+ group: SHORTCUTS_GROUP
238
+ });
239
+ }
240
+
241
+ /**
242
+ * Unregister shortcuts responsible for toggling context menu.
243
+ *
244
+ * @private
245
+ */
246
+ }, {
247
+ key: "unregisterShortcuts",
248
+ value: function unregisterShortcuts() {
249
+ this.hot.getShortcutManager().getContext('grid').removeShortcutsByGroup(SHORTCUTS_GROUP);
250
+ }
251
+
202
252
  /**
203
253
  * Opens menu and re-position it based on the passed coordinates.
204
254
  *
205
- * @param {Event} event The mouse event object.
255
+ * @param {{ top: number, left: number }|Event} position An object with `top` and `left` properties
256
+ * which contains coordinates relative to the browsers viewport (without included scroll offsets).
257
+ * Or if the native event is passed the menu will be positioned based on the `pageX` and `pageY`
258
+ * coordinates.
259
+ * @param {{ above: number, below: number, left: number, right: number }} offset An object allows applying
260
+ * the offset to the menu position.
261
+ * @fires Hooks#beforeContextMenuShow
262
+ * @fires Hooks#afterContextMenuShow
206
263
  */
207
264
  }, {
208
265
  key: "open",
209
- value: function open(event) {
210
- if (!this.menu) {
266
+ value: function open(position) {
267
+ var _this$menu,
268
+ _this4 = this;
269
+ var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
270
+ above: 0,
271
+ below: 0,
272
+ left: 0,
273
+ right: 0
274
+ };
275
+ if ((_this$menu = this.menu) !== null && _this$menu !== void 0 && _this$menu.isOpened()) {
211
276
  return;
212
277
  }
213
278
  this.prepareMenuItems();
214
279
  this.menu.open();
215
- if (!this.menu.isOpened()) {
216
- return;
217
- }
218
- var offsetTop = 0;
219
- var offsetLeft = 0;
220
- if (this.hot.rootDocument !== this.menu.container.ownerDocument) {
221
- var frameElement = this.hot.rootWindow.frameElement;
222
- var _frameElement$getBoun = frameElement.getBoundingClientRect(),
223
- top = _frameElement$getBoun.top,
224
- left = _frameElement$getBoun.left;
225
- offsetTop = top - (0, _element.getWindowScrollTop)(event.view);
226
- offsetLeft = left - (0, _element.getWindowScrollLeft)(event.view);
227
- } else {
228
- offsetTop = -1 * (0, _element.getWindowScrollTop)(this.menu.hotMenu.rootWindow);
229
- offsetLeft = -1 * (0, _element.getWindowScrollLeft)(this.menu.hotMenu.rootWindow);
230
- }
231
- this.menu.setPosition({
232
- top: parseInt(event.pageY, 10) + offsetTop,
233
- left: parseInt(event.pageX, 10) + offsetLeft
280
+ (0, _object.objectEach)(offset, function (value, key) {
281
+ _this4.menu.setOffset(key, value);
234
282
  });
283
+ this.menu.setPosition(position);
235
284
  }
236
285
 
237
286
  /**
@@ -240,10 +289,8 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
240
289
  }, {
241
290
  key: "close",
242
291
  value: function close() {
243
- if (!this.menu) {
244
- return;
245
- }
246
- this.menu.close();
292
+ var _this$menu2;
293
+ (_this$menu2 = this.menu) === null || _this$menu2 === void 0 ? void 0 : _this$menu2.close();
247
294
  this.itemsFactory = null;
248
295
  }
249
296
 
@@ -300,7 +347,7 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
300
347
  }, {
301
348
  key: "prepareMenuItems",
302
349
  value: function prepareMenuItems() {
303
- var _this3 = this;
350
+ var _this5 = this;
304
351
  this.itemsFactory = new _itemsFactory.default(this.hot, ContextMenu.DEFAULT_ITEMS);
305
352
  var settings = this.hot.getSettings()[PLUGIN_KEY];
306
353
  var predefinedItems = {
@@ -314,7 +361,7 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
314
361
 
315
362
  // Register all commands. Predefined and added by user or by plugins
316
363
  (0, _array.arrayEach)(menuItems, function (command) {
317
- return _this3.commandExecutor.registerCommand(command.key, command);
364
+ return _this5.commandExecutor.registerCommand(command.key, command);
318
365
  });
319
366
  }
320
367
 
@@ -351,7 +398,11 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
351
398
  return;
352
399
  }
353
400
  }
354
- this.open(event);
401
+ var offset = (0, _utils.getDocumentOffsetByElement)(this.menu.container, this.hot.rootDocument);
402
+ this.open({
403
+ top: event.clientY + offset.top,
404
+ left: event.clientX + offset.left
405
+ });
355
406
  }
356
407
 
357
408
  /**
@@ -32,14 +32,17 @@ 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";
35
36
  import CommandExecutor from "./commandExecutor.mjs";
36
37
  import EventManager from "../../eventManager.mjs";
37
38
  import ItemsFactory from "./itemsFactory.mjs";
38
39
  import Menu from "./menu.mjs";
39
- import { getWindowScrollLeft, getWindowScrollTop, hasClass } from "../../helpers/dom/element.mjs";
40
+ import { getDocumentOffsetByElement } from "./utils.mjs";
41
+ import { hasClass } from "../../helpers/dom/element.mjs";
40
42
  import { ROW_ABOVE, ROW_BELOW, COLUMN_LEFT, COLUMN_RIGHT, REMOVE_ROW, REMOVE_COLUMN, UNDO, REDO, READ_ONLY, ALIGNMENT, SEPARATOR } from "./predefinedItems.mjs";
41
43
  export var PLUGIN_KEY = 'contextMenu';
42
44
  export var PLUGIN_PRIORITY = 70;
45
+ var SHORTCUTS_GROUP = PLUGIN_KEY;
43
46
  Hooks.getSingleton().register('afterContextMenuDefaultOptions');
44
47
  Hooks.getSingleton().register('beforeContextMenuShow');
45
48
  Hooks.getSingleton().register('afterContextMenuShow');
@@ -161,6 +164,7 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
161
164
  this.addHook('afterOnCellContextMenu', function (event) {
162
165
  return _this2.onAfterOnCellContextMenu(event);
163
166
  });
167
+ this.registerShortcuts();
164
168
  _get(_getPrototypeOf(ContextMenu.prototype), "enablePlugin", this).call(this);
165
169
  }
166
170
 
@@ -175,6 +179,7 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
175
179
  value: function updatePlugin() {
176
180
  this.disablePlugin();
177
181
  this.enablePlugin();
182
+ this.unregisterShortcuts();
178
183
  _get(_getPrototypeOf(ContextMenu.prototype), "updatePlugin", this).call(this);
179
184
  }
180
185
 
@@ -192,39 +197,83 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
192
197
  _get(_getPrototypeOf(ContextMenu.prototype), "disablePlugin", this).call(this);
193
198
  }
194
199
 
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
+
195
245
  /**
196
246
  * Opens menu and re-position it based on the passed coordinates.
197
247
  *
198
- * @param {Event} event The mouse event object.
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
199
256
  */
200
257
  }, {
201
258
  key: "open",
202
- value: function open(event) {
203
- if (!this.menu) {
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()) {
204
269
  return;
205
270
  }
206
271
  this.prepareMenuItems();
207
272
  this.menu.open();
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
273
+ objectEach(offset, function (value, key) {
274
+ _this4.menu.setOffset(key, value);
227
275
  });
276
+ this.menu.setPosition(position);
228
277
  }
229
278
 
230
279
  /**
@@ -233,10 +282,8 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
233
282
  }, {
234
283
  key: "close",
235
284
  value: function close() {
236
- if (!this.menu) {
237
- return;
238
- }
239
- this.menu.close();
285
+ var _this$menu2;
286
+ (_this$menu2 = this.menu) === null || _this$menu2 === void 0 ? void 0 : _this$menu2.close();
240
287
  this.itemsFactory = null;
241
288
  }
242
289
 
@@ -293,7 +340,7 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
293
340
  }, {
294
341
  key: "prepareMenuItems",
295
342
  value: function prepareMenuItems() {
296
- var _this3 = this;
343
+ var _this5 = this;
297
344
  this.itemsFactory = new ItemsFactory(this.hot, ContextMenu.DEFAULT_ITEMS);
298
345
  var settings = this.hot.getSettings()[PLUGIN_KEY];
299
346
  var predefinedItems = {
@@ -307,7 +354,7 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
307
354
 
308
355
  // Register all commands. Predefined and added by user or by plugins
309
356
  arrayEach(menuItems, function (command) {
310
- return _this3.commandExecutor.registerCommand(command.key, command);
357
+ return _this5.commandExecutor.registerCommand(command.key, command);
311
358
  });
312
359
  }
313
360
 
@@ -344,7 +391,11 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
344
391
  return;
345
392
  }
346
393
  }
347
- this.open(event);
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
+ });
348
399
  }
349
400
 
350
401
  /**