handsontable 0.0.0-next-2b3d6d8-20230623 → 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 (285) 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/translations/indexMapper.d.ts +2 -0
  282. package/3rdparty/walkontable/src/selection.js +0 -355
  283. package/3rdparty/walkontable/src/selection.mjs +0 -349
  284. package/selection/highlight/constants.js +0 -16
  285. package/selection/highlight/constants.mjs +0 -6
@@ -1,10 +1,24 @@
1
1
  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); }
2
- 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; }
2
+ import "core-js/modules/es.array.concat.js";
3
+ import "core-js/modules/es.array.iterator.js";
4
+ import "core-js/modules/es.object.to-string.js";
5
+ import "core-js/modules/es.string.iterator.js";
6
+ import "core-js/modules/es.weak-map.js";
7
+ import "core-js/modules/web.dom-collections.iterator.js";
8
+ import "core-js/modules/es.symbol.to-primitive.js";
9
+ import "core-js/modules/es.date.to-primitive.js";
10
+ import "core-js/modules/es.symbol.js";
11
+ import "core-js/modules/es.symbol.description.js";
12
+ import "core-js/modules/es.number.constructor.js";
13
+ import "core-js/modules/es.object.set-prototype-of.js";
14
+ import "core-js/modules/es.object.get-prototype-of.js";
15
+ import "core-js/modules/es.reflect.construct.js";
16
+ import "core-js/modules/es.reflect.get.js";
17
+ import "core-js/modules/es.object.get-own-property-descriptor.js";
18
+ import "core-js/modules/es.symbol.iterator.js";
3
19
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
20
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
5
21
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
6
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
- 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); }
8
22
  function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
9
23
  function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
10
24
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
@@ -14,37 +28,35 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
14
28
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
15
29
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
16
30
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17
- import "core-js/modules/es.array.iterator.js";
18
- import "core-js/modules/es.object.to-string.js";
19
- import "core-js/modules/es.string.iterator.js";
20
- import "core-js/modules/es.weak-map.js";
21
- import "core-js/modules/web.dom-collections.iterator.js";
22
- import "core-js/modules/es.object.set-prototype-of.js";
23
- import "core-js/modules/es.object.get-prototype-of.js";
24
- import "core-js/modules/es.reflect.construct.js";
25
- import "core-js/modules/es.reflect.get.js";
26
- import "core-js/modules/es.object.get-own-property-descriptor.js";
27
- import "core-js/modules/es.symbol.to-primitive.js";
28
- import "core-js/modules/es.date.to-primitive.js";
29
- import "core-js/modules/es.symbol.js";
30
- import "core-js/modules/es.symbol.description.js";
31
- import "core-js/modules/es.number.constructor.js";
32
- import "core-js/modules/es.symbol.iterator.js";
31
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
32
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
33
+ 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; }
34
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
35
+ 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); }
36
+ function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
37
+ function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
38
+ function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
39
+ function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
40
+ function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
33
41
  import { addClass, closest, isChildOf, hasClass, outerWidth, outerHeight } from "../../helpers/dom/element.mjs";
42
+ import { stopImmediatePropagation } from "../../helpers/dom/event.mjs";
34
43
  import { deepClone, deepExtend, isObject } from "../../helpers/object.mjs";
35
44
  import EventManager from "../../eventManager.mjs";
36
45
  import { BasePlugin } from "../base/index.mjs";
37
46
  import CommentEditor from "./commentEditor.mjs";
38
- import { checkSelectionConsistency, markLabelAsSelected } from "../contextMenu/utils.mjs";
39
47
  import DisplaySwitch from "./displaySwitch.mjs";
40
- import * as C from "../../i18n/constants.mjs";
48
+ import { SEPARATOR } from "../contextMenu/predefinedItems.mjs";
49
+ import addEditCommentItem from "./contextMenuItem/addEditComment.mjs";
50
+ import removeCommentItem from "./contextMenuItem/removeComment.mjs";
51
+ import readOnlyCommentItem from "./contextMenuItem/readOnlyComment.mjs";
41
52
  export var PLUGIN_KEY = 'comments';
42
53
  export var PLUGIN_PRIORITY = 60;
43
- var privatePool = new WeakMap();
44
- var META_COMMENT = 'comment';
45
- var META_COMMENT_VALUE = 'value';
46
- var META_STYLE = 'style';
47
- var META_READONLY = 'readOnly';
54
+ export var META_COMMENT = 'comment';
55
+ export var META_COMMENT_VALUE = 'value';
56
+ export var META_STYLE = 'style';
57
+ export var META_READONLY = 'readOnly';
58
+ var SHORTCUTS_GROUP = PLUGIN_KEY;
59
+ var SHORTCUTS_CONTEXT_NAME = "plugin:".concat(PLUGIN_KEY);
48
60
 
49
61
  /* eslint-disable jsdoc/require-description-complete-sentence */
50
62
  /**
@@ -136,63 +148,107 @@ var META_READONLY = 'readOnly';
136
148
  * ```
137
149
  * :::
138
150
  */
151
+ var _editor = /*#__PURE__*/new WeakMap();
152
+ var _displaySwitch = /*#__PURE__*/new WeakMap();
153
+ var _preventEditorAutoSwitch = /*#__PURE__*/new WeakMap();
154
+ var _tempEditorDimensions = /*#__PURE__*/new WeakMap();
155
+ var _cellBelowCursor = /*#__PURE__*/new WeakMap();
156
+ var _commentValueBeforeSave = /*#__PURE__*/new WeakMap();
139
157
  export var Comments = /*#__PURE__*/function (_BasePlugin) {
140
158
  _inherits(Comments, _BasePlugin);
141
159
  var _super = _createSuper(Comments);
142
- function Comments(hotInstance) {
160
+ function Comments() {
143
161
  var _this;
144
162
  _classCallCheck(this, Comments);
145
- _this = _super.call(this, hotInstance);
163
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
164
+ args[_key] = arguments[_key];
165
+ }
166
+ _this = _super.call.apply(_super, [this].concat(args));
167
+ /**
168
+ * Current cell range, an object with `from` property, with `row` and `col` properties (e.q. `{from: {row: 1, col: 6}}`).
169
+ *
170
+ * @type {object}
171
+ */
172
+ _defineProperty(_assertThisInitialized(_this), "range", {});
173
+ /**
174
+ * Instance of {@link EventManager}.
175
+ *
176
+ * @protected
177
+ * @type {EventManager}
178
+ */
179
+ _defineProperty(_assertThisInitialized(_this), "eventManager", null);
146
180
  /**
147
181
  * Instance of {@link CommentEditor}.
148
182
  *
149
183
  * @private
150
184
  * @type {CommentEditor}
151
185
  */
152
- _this.editor = null;
186
+ _classPrivateFieldInitSpec(_assertThisInitialized(_this), _editor, {
187
+ writable: true,
188
+ value: null
189
+ });
153
190
  /**
154
191
  * Instance of {@link DisplaySwitch}.
155
192
  *
156
193
  * @private
157
194
  * @type {DisplaySwitch}
158
195
  */
159
- _this.displaySwitch = null;
196
+ _classPrivateFieldInitSpec(_assertThisInitialized(_this), _displaySwitch, {
197
+ writable: true,
198
+ value: null
199
+ });
160
200
  /**
161
- * Instance of {@link EventManager}.
201
+ * Prevents showing/hiding editor that reacts on the logic triggered by the "mouseover" events.
162
202
  *
163
203
  * @private
164
- * @type {EventManager}
204
+ * @type {boolean}
165
205
  */
166
- _this.eventManager = null;
206
+ _classPrivateFieldInitSpec(_assertThisInitialized(_this), _preventEditorAutoSwitch, {
207
+ writable: true,
208
+ value: false
209
+ });
167
210
  /**
168
- * Current cell range, an object with `from` property, with `row` and `col` properties (e.q. `{from: {row: 1, col: 6}}`).
211
+ * The property for holding editor dimensions for further processing.
169
212
  *
213
+ * @private
170
214
  * @type {object}
171
215
  */
172
- _this.range = {};
216
+ _classPrivateFieldInitSpec(_assertThisInitialized(_this), _tempEditorDimensions, {
217
+ writable: true,
218
+ value: {}
219
+ });
173
220
  /**
174
- * Prevents showing/hiding editor that reacts on the logic triggered by the "mouseover" events.
221
+ * The flag that allows processing mousedown event correctly when comments editor is triggered.
175
222
  *
176
223
  * @private
177
224
  * @type {boolean}
178
225
  */
179
- _this.preventEditorAutoSwitch = false;
180
- privatePool.set(_assertThisInitialized(_this), {
181
- tempEditorDimensions: {},
182
- cellBelowCursor: null
226
+ _classPrivateFieldInitSpec(_assertThisInitialized(_this), _cellBelowCursor, {
227
+ writable: true,
228
+ value: null
229
+ });
230
+ /**
231
+ * Holds the comment value before it's actually saved to the cell meta.
232
+ *
233
+ * @private
234
+ * @type {string}
235
+ */
236
+ _classPrivateFieldInitSpec(_assertThisInitialized(_this), _commentValueBeforeSave, {
237
+ writable: true,
238
+ value: ''
183
239
  });
184
240
  return _this;
185
241
  }
186
-
187
- /**
188
- * Checks if the plugin is enabled in the handsontable settings. This method is executed in {@link Hooks#beforeInit}
189
- * hook and if it returns `true` then the {@link Comments#enablePlugin} method is called.
190
- *
191
- * @returns {boolean}
192
- */
193
242
  _createClass(Comments, [{
194
243
  key: "isEnabled",
195
- value: function isEnabled() {
244
+ value:
245
+ /**
246
+ * Checks if the plugin is enabled in the handsontable settings. This method is executed in {@link Hooks#beforeInit}
247
+ * hook and if it returns `true` then the {@link Comments#enablePlugin} method is called.
248
+ *
249
+ * @returns {boolean}
250
+ */
251
+ function isEnabled() {
196
252
  return !!this.hot.getSettings()[PLUGIN_KEY];
197
253
  }
198
254
 
@@ -206,14 +262,14 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
206
262
  if (this.enabled) {
207
263
  return;
208
264
  }
209
- if (!this.editor) {
210
- this.editor = new CommentEditor(this.hot.rootDocument, this.hot.isRtl());
265
+ if (!_classPrivateFieldGet(this, _editor)) {
266
+ _classPrivateFieldSet(this, _editor, new CommentEditor(this.hot.rootDocument, this.hot.isRtl()));
211
267
  }
212
268
  if (!this.eventManager) {
213
269
  this.eventManager = new EventManager(this);
214
270
  }
215
- if (!this.displaySwitch) {
216
- this.displaySwitch = new DisplaySwitch(this.getDisplayDelaySetting());
271
+ if (!_classPrivateFieldGet(this, _displaySwitch)) {
272
+ _classPrivateFieldSet(this, _displaySwitch, new DisplaySwitch(this.getDisplayDelaySetting()));
217
273
  }
218
274
  this.addHook('afterContextMenuDefaultOptions', function (options) {
219
275
  return _this2.addToContextMenu(options);
@@ -230,12 +286,16 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
230
286
  this.addHook('afterBeginEditing', function () {
231
287
  return _this2.hide();
232
288
  });
233
- this.displaySwitch.addLocalHook('hide', function () {
289
+ this.addHook('afterDocumentKeyDown', function (event) {
290
+ return _this2.onAfterDocumentKeyDown(event);
291
+ });
292
+ _classPrivateFieldGet(this, _displaySwitch).addLocalHook('hide', function () {
234
293
  return _this2.hide();
235
294
  });
236
- this.displaySwitch.addLocalHook('show', function (row, col) {
295
+ _classPrivateFieldGet(this, _displaySwitch).addLocalHook('show', function (row, col) {
237
296
  return _this2.showAtCell(row, col);
238
297
  });
298
+ this.registerShortcuts();
239
299
  this.registerListeners();
240
300
  _get(_getPrototypeOf(Comments.prototype), "enablePlugin", this).call(this);
241
301
  }
@@ -249,10 +309,8 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
249
309
  }, {
250
310
  key: "updatePlugin",
251
311
  value: function updatePlugin() {
252
- this.disablePlugin();
253
- this.enablePlugin();
312
+ _classPrivateFieldGet(this, _displaySwitch).updateDelay(this.getDisplayDelaySetting());
254
313
  _get(_getPrototypeOf(Comments.prototype), "updatePlugin", this).call(this);
255
- this.displaySwitch.updateDelay(this.getDisplayDelaySetting());
256
314
  }
257
315
 
258
316
  /**
@@ -261,9 +319,76 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
261
319
  }, {
262
320
  key: "disablePlugin",
263
321
  value: function disablePlugin() {
322
+ this.unregisterShortcuts();
264
323
  _get(_getPrototypeOf(Comments.prototype), "disablePlugin", this).call(this);
265
324
  }
266
325
 
326
+ /**
327
+ * Register shortcuts responsible for toggling context menu.
328
+ *
329
+ * @private
330
+ */
331
+ }, {
332
+ key: "registerShortcuts",
333
+ value: function registerShortcuts() {
334
+ var _this3 = this;
335
+ var manager = this.hot.getShortcutManager();
336
+ var gridContext = manager.getContext('grid');
337
+ var pluginContext = manager.addContext(SHORTCUTS_CONTEXT_NAME);
338
+ gridContext.addShortcut({
339
+ keys: [['Control', 'Alt', 'M']],
340
+ callback: function callback() {
341
+ var range = _this3.hot.getSelectedRangeLast();
342
+ _this3.setRange(range);
343
+ _this3.show();
344
+ _this3.focusEditor();
345
+ manager.setActiveContextName(SHORTCUTS_CONTEXT_NAME);
346
+ },
347
+ stopPropagation: true,
348
+ runOnlyIf: function runOnlyIf() {
349
+ var _this3$hot$getSelecte;
350
+ return ((_this3$hot$getSelecte = _this3.hot.getSelectedRangeLast()) === null || _this3$hot$getSelecte === void 0 ? void 0 : _this3$hot$getSelecte.highlight.isCell()) && !_classPrivateFieldGet(_this3, _editor).isVisible();
351
+ },
352
+ group: SHORTCUTS_GROUP
353
+ });
354
+ pluginContext.addShortcut({
355
+ keys: [['Escape']],
356
+ callback: function callback() {
357
+ _classPrivateFieldGet(_this3, _editor).setValue(_classPrivateFieldGet(_this3, _commentValueBeforeSave));
358
+ _this3.hide();
359
+ manager.setActiveContextName('grid');
360
+ },
361
+ runOnlyIf: function runOnlyIf() {
362
+ var _this3$hot$getSelecte2;
363
+ return ((_this3$hot$getSelecte2 = _this3.hot.getSelectedRangeLast()) === null || _this3$hot$getSelecte2 === void 0 ? void 0 : _this3$hot$getSelecte2.highlight.isCell()) && _classPrivateFieldGet(_this3, _editor).isVisible();
364
+ },
365
+ group: SHORTCUTS_GROUP
366
+ });
367
+ pluginContext.addShortcut({
368
+ keys: [['Control/Meta', 'Enter']],
369
+ callback: function callback() {
370
+ _this3.hide();
371
+ manager.setActiveContextName('grid');
372
+ },
373
+ runOnlyIf: function runOnlyIf() {
374
+ var _this3$hot$getSelecte3;
375
+ return ((_this3$hot$getSelecte3 = _this3.hot.getSelectedRangeLast()) === null || _this3$hot$getSelecte3 === void 0 ? void 0 : _this3$hot$getSelecte3.highlight.isCell()) && _classPrivateFieldGet(_this3, _editor).isVisible();
376
+ },
377
+ group: SHORTCUTS_GROUP
378
+ });
379
+ }
380
+
381
+ /**
382
+ * Unregister shortcuts responsible for toggling context menu.
383
+ *
384
+ * @private
385
+ */
386
+ }, {
387
+ key: "unregisterShortcuts",
388
+ value: function unregisterShortcuts() {
389
+ this.hot.getShortcutManager().getContext('grid').removeShortcutsByGroup(SHORTCUTS_GROUP);
390
+ }
391
+
267
392
  /**
268
393
  * Registers all necessary DOM listeners.
269
394
  *
@@ -272,25 +397,29 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
272
397
  }, {
273
398
  key: "registerListeners",
274
399
  value: function registerListeners() {
275
- var _this3 = this;
400
+ var _this4 = this;
276
401
  var rootDocument = this.hot.rootDocument;
402
+ var editorElement = this.getEditorInputElement();
277
403
  this.eventManager.addEventListener(rootDocument, 'mouseover', function (event) {
278
- return _this3.onMouseOver(event);
404
+ return _this4.onMouseOver(event);
279
405
  });
280
406
  this.eventManager.addEventListener(rootDocument, 'mousedown', function (event) {
281
- return _this3.onMouseDown(event);
407
+ return _this4.onMouseDown(event);
282
408
  });
283
409
  this.eventManager.addEventListener(rootDocument, 'mouseup', function () {
284
- return _this3.onMouseUp();
410
+ return _this4.onMouseUp();
285
411
  });
286
- this.eventManager.addEventListener(this.editor.getInputElement(), 'blur', function () {
287
- return _this3.onEditorBlur();
412
+ this.eventManager.addEventListener(editorElement, 'focus', function () {
413
+ return _this4.onEditorFocus();
288
414
  });
289
- this.eventManager.addEventListener(this.editor.getInputElement(), 'mousedown', function (event) {
290
- return _this3.onEditorMouseDown(event);
415
+ this.eventManager.addEventListener(editorElement, 'blur', function () {
416
+ return _this4.onEditorBlur();
291
417
  });
292
- this.eventManager.addEventListener(this.editor.getInputElement(), 'mouseup', function (event) {
293
- return _this3.onEditorMouseUp(event);
418
+ this.eventManager.addEventListener(editorElement, 'mousedown', function (event) {
419
+ return _this4.onEditorMouseDown(event);
420
+ });
421
+ this.eventManager.addEventListener(editorElement, 'mouseup', function (event) {
422
+ return _this4.onEditorMouseUp(event);
294
423
  });
295
424
  }
296
425
 
@@ -338,7 +467,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
338
467
  }, {
339
468
  key: "targetIsCommentTextArea",
340
469
  value: function targetIsCommentTextArea(event) {
341
- return this.editor.getInputElement() === event.target;
470
+ return this.getEditorInputElement() === event.target;
342
471
  }
343
472
 
344
473
  /**
@@ -352,7 +481,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
352
481
  if (!this.range.from) {
353
482
  throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
354
483
  }
355
- var editorValue = this.editor.getValue();
484
+ var editorValue = _classPrivateFieldGet(this, _editor).getValue();
356
485
  var comment = '';
357
486
  if (value !== null && value !== void 0) {
358
487
  comment = value;
@@ -461,8 +590,9 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
461
590
  return false;
462
591
  }
463
592
  var meta = this.hot.getCellMeta(this.range.from.row, this.range.from.col);
464
- this.editor.setValue(meta[META_COMMENT] ? meta[META_COMMENT][META_COMMENT_VALUE] : null || '');
465
- this.editor.show();
593
+ _classPrivateFieldGet(this, _displaySwitch).cancelHiding();
594
+ _classPrivateFieldGet(this, _editor).setValue(meta[META_COMMENT] ? meta[META_COMMENT][META_COMMENT_VALUE] : null || '');
595
+ _classPrivateFieldGet(this, _editor).show();
466
596
  this.refreshEditor(true);
467
597
  return true;
468
598
  }
@@ -489,7 +619,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
489
619
  }, {
490
620
  key: "hide",
491
621
  value: function hide() {
492
- this.editor.hide();
622
+ _classPrivateFieldGet(this, _editor).hide();
493
623
  }
494
624
 
495
625
  /**
@@ -502,7 +632,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
502
632
  value: function refreshEditor() {
503
633
  var _renderableRow, _renderableColumn;
504
634
  var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
505
- if (!force && (!this.range.from || !this.editor.isVisible())) {
635
+ if (!force && (!this.range.from || !_classPrivateFieldGet(this, _editor).isVisible())) {
506
636
  return;
507
637
  }
508
638
  var _this$hot = this.hot,
@@ -518,7 +648,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
518
648
 
519
649
  // Reset the editor position to (0, 0) so the opening direction calculation wouldn't be influenced by its
520
650
  // previous position
521
- this.editor.setPosition(0, 0);
651
+ _classPrivateFieldGet(this, _editor).setPosition(0, 0);
522
652
  if (renderableRow === null) {
523
653
  renderableRow = rowIndexMapper.getRenderableFromVisualIndex(rowIndexMapper.getNearestNotHiddenIndex(visualRow, -1));
524
654
  }
@@ -541,9 +671,9 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
541
671
  }, true);
542
672
  var commentStyle = this.getCommentMeta(visualRow, visualColumn, META_STYLE);
543
673
  if (commentStyle) {
544
- this.editor.setSize(commentStyle.width, commentStyle.height);
674
+ _classPrivateFieldGet(this, _editor).setSize(commentStyle.width, commentStyle.height);
545
675
  } else {
546
- this.editor.resetSize();
676
+ _classPrivateFieldGet(this, _editor).resetSize();
547
677
  }
548
678
  var lastColWidth = isBeforeRenderedColumns ? 0 : wtTable.getStretchedColumnWidth(renderableColumn);
549
679
  var lastRowHeight = targetingPreviousRow && !isBeforeRenderedRows ? outerHeight(TD) : 0;
@@ -552,9 +682,9 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
552
682
  top = _TD$getBoundingClient.top,
553
683
  cellWidth = _TD$getBoundingClient.width,
554
684
  cellHeight = _TD$getBoundingClient.height;
555
- var _this$editor$getSize = this.editor.getSize(),
556
- editorWidth = _this$editor$getSize.width,
557
- editorHeight = _this$editor$getSize.height;
685
+ var _classPrivateFieldGet2 = _classPrivateFieldGet(this, _editor).getSize(),
686
+ editorWidth = _classPrivateFieldGet2.width,
687
+ editorHeight = _classPrivateFieldGet2.height;
558
688
  var _this$hot$rootWindow = this.hot.rootWindow,
559
689
  innerWidth = _this$hot$rootWindow.innerWidth,
560
690
  innerHeight = _this$hot$rootWindow.innerHeight;
@@ -574,30 +704,17 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
574
704
  if (top + editorHeight > innerHeight) {
575
705
  y -= editorHeight - cellHeight + 1;
576
706
  }
577
- this.editor.setPosition(x, y);
578
- this.editor.setReadOnlyState(this.getCommentMeta(visualRow, visualColumn, META_READONLY));
707
+ _classPrivateFieldGet(this, _editor).setPosition(x, y);
708
+ _classPrivateFieldGet(this, _editor).setReadOnlyState(this.getCommentMeta(visualRow, visualColumn, META_READONLY));
579
709
  }
580
710
 
581
711
  /**
582
- * Checks if there is a comment for selected range.
583
- *
584
- * @private
585
- * @returns {boolean}
712
+ * Focuses the comments editor element.
586
713
  */
587
714
  }, {
588
- key: "checkSelectionCommentsConsistency",
589
- value: function checkSelectionCommentsConsistency() {
590
- var selected = this.hot.getSelectedRangeLast();
591
- if (!selected) {
592
- return false;
593
- }
594
- var hasComment = false;
595
- var cell = selected.getTopStartCorner(); // IN EXCEL THERE IS COMMENT ONLY FOR TOP LEFT CELL IN SELECTION
596
-
597
- if (this.getCommentMeta(cell.row, cell.col, META_COMMENT_VALUE)) {
598
- hasComment = true;
599
- }
600
- return hasComment;
715
+ key: "focusEditor",
716
+ value: function focusEditor() {
717
+ _classPrivateFieldGet(this, _editor).focus();
601
718
  }
602
719
 
603
720
  /**
@@ -651,7 +768,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
651
768
  if (!this.hot.view || !this.hot.view._wt) {
652
769
  return;
653
770
  }
654
- if (!this.preventEditorAutoSwitch && !this.targetIsCommentTextArea(event)) {
771
+ if (!_classPrivateFieldGet(this, _preventEditorAutoSwitch) && !this.targetIsCommentTextArea(event)) {
655
772
  var eventCell = closest(event.target, 'TD', 'TBODY');
656
773
  var coordinates = null;
657
774
  if (eventCell) {
@@ -672,17 +789,16 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
672
789
  }, {
673
790
  key: "onMouseOver",
674
791
  value: function onMouseOver(event) {
675
- var priv = privatePool.get(this);
676
792
  var rootDocument = this.hot.rootDocument;
677
- if (this.preventEditorAutoSwitch || this.editor.isFocused() || hasClass(event.target, 'wtBorder') || priv.cellBelowCursor === event.target || !this.editor) {
793
+ if (_classPrivateFieldGet(this, _preventEditorAutoSwitch) || _classPrivateFieldGet(this, _editor).isFocused() || hasClass(event.target, 'wtBorder') || _classPrivateFieldGet(this, _cellBelowCursor) === event.target || !_classPrivateFieldGet(this, _editor)) {
678
794
  return;
679
795
  }
680
- priv.cellBelowCursor = rootDocument.elementFromPoint(event.clientX, event.clientY);
796
+ _classPrivateFieldSet(this, _cellBelowCursor, rootDocument.elementFromPoint(event.clientX, event.clientY));
681
797
  if (this.targetIsCellWithComment(event)) {
682
798
  var range = this.hot._createCellRange(this.hot.getCoords(event.target));
683
- this.displaySwitch.show(range);
799
+ _classPrivateFieldGet(this, _displaySwitch).show(range);
684
800
  } else if (isChildOf(event.target, rootDocument) && !this.targetIsCommentTextArea(event)) {
685
- this.displaySwitch.hide();
801
+ _classPrivateFieldGet(this, _displaySwitch).hide();
686
802
  }
687
803
  }
688
804
 
@@ -694,7 +810,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
694
810
  }, {
695
811
  key: "onMouseUp",
696
812
  value: function onMouseUp() {
697
- this.preventEditorAutoSwitch = false;
813
+ _classPrivateFieldSet(this, _preventEditorAutoSwitch, false);
698
814
  }
699
815
 
700
816
  /**
@@ -713,16 +829,33 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
713
829
  }
714
830
 
715
831
  /**
716
- * `blur` event callback for the comment editor.
832
+ * Hook observer the "blur" event from the comments editor element. The hook clears the
833
+ * editor content and gives back the keyboard shortcuts control by switching to the "grid" context.
717
834
  *
718
835
  * @private
719
836
  */
720
837
  }, {
721
838
  key: "onEditorBlur",
722
839
  value: function onEditorBlur() {
840
+ _classPrivateFieldSet(this, _commentValueBeforeSave, '');
841
+ this.hot.getShortcutManager().setActiveContextName('grid');
723
842
  this.setComment();
724
843
  }
725
844
 
845
+ /**
846
+ * Hook observer the "focus" event from the comments editor element. The hook takes the control of
847
+ * the keyboard shortcuts by switching the context to plugins one.
848
+ *
849
+ * @private
850
+ */
851
+ }, {
852
+ key: "onEditorFocus",
853
+ value: function onEditorFocus() {
854
+ _classPrivateFieldSet(this, _commentValueBeforeSave, this.getComment());
855
+ this.hot.listen();
856
+ this.hot.getShortcutManager().setActiveContextName(SHORTCUTS_CONTEXT_NAME);
857
+ }
858
+
726
859
  /**
727
860
  * `mousedown` hook. Along with `onEditorMouseUp` used to simulate the textarea resizing event.
728
861
  *
@@ -732,11 +865,10 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
732
865
  }, {
733
866
  key: "onEditorMouseDown",
734
867
  value: function onEditorMouseDown(event) {
735
- var priv = privatePool.get(this);
736
- priv.tempEditorDimensions = {
868
+ _classPrivateFieldSet(this, _tempEditorDimensions, {
737
869
  width: outerWidth(event.target),
738
870
  height: outerHeight(event.target)
739
- };
871
+ });
740
872
  }
741
873
 
742
874
  /**
@@ -748,10 +880,9 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
748
880
  }, {
749
881
  key: "onEditorMouseUp",
750
882
  value: function onEditorMouseUp(event) {
751
- var priv = privatePool.get(this);
752
883
  var currentWidth = outerWidth(event.target);
753
884
  var currentHeight = outerHeight(event.target);
754
- if (currentWidth !== priv.tempEditorDimensions.width + 1 || currentHeight !== priv.tempEditorDimensions.height + 2) {
885
+ if (currentWidth !== _classPrivateFieldGet(this, _tempEditorDimensions).width + 1 || currentHeight !== _classPrivateFieldGet(this, _tempEditorDimensions).height + 2) {
755
886
  this.updateCommentMeta(this.range.from.row, this.range.from.col, _defineProperty({}, META_STYLE, {
756
887
  width: currentWidth,
757
888
  height: currentHeight
@@ -760,137 +891,31 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
760
891
  }
761
892
 
762
893
  /**
763
- * Context Menu's "Add comment" callback. Results in showing the comment editor.
764
- *
765
- * @private
766
- */
767
- }, {
768
- key: "onContextMenuAddComment",
769
- value: function onContextMenuAddComment() {
770
- var coords = this.hot.getSelectedRangeLast();
771
- this.preventEditorAutoSwitch = true;
772
- this.displaySwitch.cancelHiding();
773
- this.setRange({
774
- from: coords.highlight
775
- });
776
- this.show();
777
- this.hot.deselectCell();
778
- this.editor.focus();
779
- }
780
-
781
- /**
782
- * Context Menu's "remove comment" callback.
783
- *
784
- * @private
785
- */
786
- }, {
787
- key: "onContextMenuRemoveComment",
788
- value: function onContextMenuRemoveComment() {
789
- var _this4 = this;
790
- var coords = this.hot.getSelectedRangeLast();
791
- this.preventEditorAutoSwitch = true;
792
- coords.forAll(function (row, column) {
793
- if (row >= 0 && column >= 0) {
794
- _this4.removeCommentAtCell(row, column, false);
795
- }
796
- });
797
- this.hot.render();
798
- }
799
-
800
- /**
801
- * Context Menu's "make comment read-only" callback.
894
+ * Observes the pressed keys and if there is already opened the comment editor prevents open
895
+ * the table editor into the fast edit mode.
802
896
  *
803
- * @private
897
+ * @param {Event} event The keydown event.
804
898
  */
805
899
  }, {
806
- key: "onContextMenuMakeReadOnly",
807
- value: function onContextMenuMakeReadOnly() {
808
- var _this5 = this;
809
- var coords = this.hot.getSelectedRangeLast();
810
- this.preventEditorAutoSwitch = true;
811
- coords.forAll(function (row, column) {
812
- if (row >= 0 && column >= 0) {
813
- var currentState = !!_this5.getCommentMeta(row, column, META_READONLY);
814
- _this5.updateCommentMeta(row, column, _defineProperty({}, META_READONLY, !currentState));
815
- }
816
- });
900
+ key: "onAfterDocumentKeyDown",
901
+ value: function onAfterDocumentKeyDown(event) {
902
+ if (_classPrivateFieldGet(this, _editor).isVisible()) {
903
+ stopImmediatePropagation(event);
904
+ }
817
905
  }
818
906
 
819
907
  /**
820
908
  * Add Comments plugin options to the Context Menu.
821
909
  *
822
910
  * @private
823
- * @param {object} defaultOptions The menu options.
911
+ * @param {object} options The menu options.
824
912
  */
825
913
  }, {
826
914
  key: "addToContextMenu",
827
- value: function addToContextMenu(defaultOptions) {
828
- var _this6 = this;
829
- var isThereAnyCellRendered = function isThereAnyCellRendered() {
830
- return _this6.hot.rowIndexMapper.getRenderableIndexesLength() > 0 && _this6.hot.columnIndexMapper.getRenderableIndexesLength() > 0;
831
- };
832
- defaultOptions.items.push({
833
- name: '---------'
834
- }, {
835
- key: 'commentsAddEdit',
836
- name: function name() {
837
- if (_this6.checkSelectionCommentsConsistency()) {
838
- return _this6.hot.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_EDIT_COMMENT);
839
- }
840
- return _this6.hot.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ADD_COMMENT);
841
- },
842
- callback: function callback() {
843
- return _this6.onContextMenuAddComment();
844
- },
845
- disabled: function disabled() {
846
- if (!isThereAnyCellRendered()) {
847
- return true;
848
- }
849
- return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner());
850
- }
851
- }, {
852
- key: 'commentsRemove',
853
- name: function name() {
854
- return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_REMOVE_COMMENT);
855
- },
856
- callback: function callback() {
857
- return _this6.onContextMenuRemoveComment();
858
- },
859
- disabled: function disabled() {
860
- if (!isThereAnyCellRendered()) {
861
- return true;
862
- }
863
- return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner());
864
- }
865
- }, {
866
- key: 'commentsReadOnly',
867
- name: function name() {
868
- var _this7 = this;
869
- var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_READ_ONLY_COMMENT);
870
- var hasProperty = checkSelectionConsistency(this.getSelectedRangeLast(), function (row, col) {
871
- var readOnlyProperty = _this7.getCellMeta(row, col)[META_COMMENT];
872
- if (readOnlyProperty) {
873
- readOnlyProperty = readOnlyProperty[META_READONLY];
874
- }
875
- if (readOnlyProperty) {
876
- return true;
877
- }
878
- });
879
- if (hasProperty) {
880
- label = markLabelAsSelected(label);
881
- }
882
- return label;
883
- },
884
- callback: function callback() {
885
- return _this6.onContextMenuMakeReadOnly();
886
- },
887
- disabled: function disabled() {
888
- if (!isThereAnyCellRendered()) {
889
- return true;
890
- }
891
- return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner()) || !_this6.checkSelectionCommentsConsistency();
892
- }
893
- });
915
+ value: function addToContextMenu(options) {
916
+ options.items.push({
917
+ name: SEPARATOR
918
+ }, addEditCommentItem(this), removeCommentItem(this), readOnlyCommentItem(this));
894
919
  }
895
920
 
896
921
  /**
@@ -908,17 +933,29 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
908
933
  }
909
934
  }
910
935
 
936
+ /**
937
+ * Gets the editors input element.
938
+ *
939
+ * @private
940
+ * @returns {HTMLTextAreaElement}
941
+ */
942
+ }, {
943
+ key: "getEditorInputElement",
944
+ value: function getEditorInputElement() {
945
+ return _classPrivateFieldGet(this, _editor).getInputElement();
946
+ }
947
+
911
948
  /**
912
949
  * Destroys the plugin instance.
913
950
  */
914
951
  }, {
915
952
  key: "destroy",
916
953
  value: function destroy() {
917
- if (this.editor) {
918
- this.editor.destroy();
954
+ if (_classPrivateFieldGet(this, _editor)) {
955
+ _classPrivateFieldGet(this, _editor).destroy();
919
956
  }
920
- if (this.displaySwitch) {
921
- this.displaySwitch.destroy();
957
+ if (_classPrivateFieldGet(this, _displaySwitch)) {
958
+ _classPrivateFieldGet(this, _displaySwitch).destroy();
922
959
  }
923
960
  _get(_getPrototypeOf(Comments.prototype), "destroy", this).call(this);
924
961
  }