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
@@ -1,41 +1,40 @@
1
1
  "use strict";
2
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.object.set-prototype-of.js");
5
- require("core-js/modules/es.object.get-prototype-of.js");
6
- require("core-js/modules/es.reflect.construct.js");
7
- require("core-js/modules/es.reflect.get.js");
8
- require("core-js/modules/es.object.get-own-property-descriptor.js");
9
3
  require("core-js/modules/es.symbol.to-primitive.js");
10
4
  require("core-js/modules/es.date.to-primitive.js");
11
5
  require("core-js/modules/es.symbol.js");
12
6
  require("core-js/modules/es.symbol.description.js");
13
7
  require("core-js/modules/es.number.constructor.js");
8
+ require("core-js/modules/es.object.set-prototype-of.js");
9
+ require("core-js/modules/es.object.get-prototype-of.js");
10
+ require("core-js/modules/es.reflect.construct.js");
11
+ require("core-js/modules/es.reflect.get.js");
12
+ require("core-js/modules/es.object.get-own-property-descriptor.js");
14
13
  require("core-js/modules/es.symbol.iterator.js");
14
+ 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); }
15
15
  exports.__esModule = true;
16
- exports.PLUGIN_PRIORITY = exports.PLUGIN_KEY = exports.Comments = void 0;
16
+ exports.PLUGIN_PRIORITY = exports.PLUGIN_KEY = exports.META_STYLE = exports.META_READONLY = exports.META_COMMENT_VALUE = exports.META_COMMENT = exports.Comments = void 0;
17
+ require("core-js/modules/es.array.concat.js");
17
18
  require("core-js/modules/es.array.iterator.js");
18
19
  require("core-js/modules/es.object.to-string.js");
19
20
  require("core-js/modules/es.string.iterator.js");
20
21
  require("core-js/modules/es.weak-map.js");
21
22
  require("core-js/modules/web.dom-collections.iterator.js");
22
23
  var _element = require("../../helpers/dom/element");
24
+ var _event = require("../../helpers/dom/event");
23
25
  var _object = require("../../helpers/object");
24
26
  var _eventManager = _interopRequireDefault(require("../../eventManager"));
25
27
  var _base = require("../base");
26
28
  var _commentEditor = _interopRequireDefault(require("./commentEditor"));
27
- var _utils = require("../contextMenu/utils");
28
- var _displaySwitch = _interopRequireDefault(require("./displaySwitch"));
29
- var C = _interopRequireWildcard(require("../../i18n/constants"));
30
- 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); }
31
- 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; }
29
+ var _displaySwitch2 = _interopRequireDefault(require("./displaySwitch"));
30
+ var _predefinedItems = require("../contextMenu/predefinedItems");
31
+ var _addEditComment = _interopRequireDefault(require("./contextMenuItem/addEditComment"));
32
+ var _removeComment = _interopRequireDefault(require("./contextMenuItem/removeComment"));
33
+ var _readOnlyComment = _interopRequireDefault(require("./contextMenuItem/readOnlyComment"));
32
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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
35
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
35
36
  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); } }
36
37
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
37
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
38
- 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); }
39
38
  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); }
40
39
  function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
41
40
  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); }
@@ -45,15 +44,30 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
45
44
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
46
45
  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; } }
47
46
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
47
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
48
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
49
+ 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; }
50
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
51
+ 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); }
52
+ function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
53
+ 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; } }
54
+ function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
55
+ function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
56
+ function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
48
57
  var PLUGIN_KEY = 'comments';
49
58
  exports.PLUGIN_KEY = PLUGIN_KEY;
50
59
  var PLUGIN_PRIORITY = 60;
51
60
  exports.PLUGIN_PRIORITY = PLUGIN_PRIORITY;
52
- var privatePool = new WeakMap();
53
61
  var META_COMMENT = 'comment';
62
+ exports.META_COMMENT = META_COMMENT;
54
63
  var META_COMMENT_VALUE = 'value';
64
+ exports.META_COMMENT_VALUE = META_COMMENT_VALUE;
55
65
  var META_STYLE = 'style';
66
+ exports.META_STYLE = META_STYLE;
56
67
  var META_READONLY = 'readOnly';
68
+ exports.META_READONLY = META_READONLY;
69
+ var SHORTCUTS_GROUP = PLUGIN_KEY;
70
+ var SHORTCUTS_CONTEXT_NAME = "plugin:".concat(PLUGIN_KEY);
57
71
 
58
72
  /* eslint-disable jsdoc/require-description-complete-sentence */
59
73
  /**
@@ -145,63 +159,107 @@ var META_READONLY = 'readOnly';
145
159
  * ```
146
160
  * :::
147
161
  */
162
+ var _editor = /*#__PURE__*/new WeakMap();
163
+ var _displaySwitch = /*#__PURE__*/new WeakMap();
164
+ var _preventEditorAutoSwitch = /*#__PURE__*/new WeakMap();
165
+ var _tempEditorDimensions = /*#__PURE__*/new WeakMap();
166
+ var _cellBelowCursor = /*#__PURE__*/new WeakMap();
167
+ var _commentValueBeforeSave = /*#__PURE__*/new WeakMap();
148
168
  var Comments = /*#__PURE__*/function (_BasePlugin) {
149
169
  _inherits(Comments, _BasePlugin);
150
170
  var _super = _createSuper(Comments);
151
- function Comments(hotInstance) {
171
+ function Comments() {
152
172
  var _this;
153
173
  _classCallCheck(this, Comments);
154
- _this = _super.call(this, hotInstance);
174
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
175
+ args[_key] = arguments[_key];
176
+ }
177
+ _this = _super.call.apply(_super, [this].concat(args));
178
+ /**
179
+ * Current cell range, an object with `from` property, with `row` and `col` properties (e.q. `{from: {row: 1, col: 6}}`).
180
+ *
181
+ * @type {object}
182
+ */
183
+ _defineProperty(_assertThisInitialized(_this), "range", {});
184
+ /**
185
+ * Instance of {@link EventManager}.
186
+ *
187
+ * @protected
188
+ * @type {EventManager}
189
+ */
190
+ _defineProperty(_assertThisInitialized(_this), "eventManager", null);
155
191
  /**
156
192
  * Instance of {@link CommentEditor}.
157
193
  *
158
194
  * @private
159
195
  * @type {CommentEditor}
160
196
  */
161
- _this.editor = null;
197
+ _classPrivateFieldInitSpec(_assertThisInitialized(_this), _editor, {
198
+ writable: true,
199
+ value: null
200
+ });
162
201
  /**
163
202
  * Instance of {@link DisplaySwitch}.
164
203
  *
165
204
  * @private
166
205
  * @type {DisplaySwitch}
167
206
  */
168
- _this.displaySwitch = null;
207
+ _classPrivateFieldInitSpec(_assertThisInitialized(_this), _displaySwitch, {
208
+ writable: true,
209
+ value: null
210
+ });
169
211
  /**
170
- * Instance of {@link EventManager}.
212
+ * Prevents showing/hiding editor that reacts on the logic triggered by the "mouseover" events.
171
213
  *
172
214
  * @private
173
- * @type {EventManager}
215
+ * @type {boolean}
174
216
  */
175
- _this.eventManager = null;
217
+ _classPrivateFieldInitSpec(_assertThisInitialized(_this), _preventEditorAutoSwitch, {
218
+ writable: true,
219
+ value: false
220
+ });
176
221
  /**
177
- * Current cell range, an object with `from` property, with `row` and `col` properties (e.q. `{from: {row: 1, col: 6}}`).
222
+ * The property for holding editor dimensions for further processing.
178
223
  *
224
+ * @private
179
225
  * @type {object}
180
226
  */
181
- _this.range = {};
227
+ _classPrivateFieldInitSpec(_assertThisInitialized(_this), _tempEditorDimensions, {
228
+ writable: true,
229
+ value: {}
230
+ });
182
231
  /**
183
- * Prevents showing/hiding editor that reacts on the logic triggered by the "mouseover" events.
232
+ * The flag that allows processing mousedown event correctly when comments editor is triggered.
184
233
  *
185
234
  * @private
186
235
  * @type {boolean}
187
236
  */
188
- _this.preventEditorAutoSwitch = false;
189
- privatePool.set(_assertThisInitialized(_this), {
190
- tempEditorDimensions: {},
191
- cellBelowCursor: null
237
+ _classPrivateFieldInitSpec(_assertThisInitialized(_this), _cellBelowCursor, {
238
+ writable: true,
239
+ value: null
240
+ });
241
+ /**
242
+ * Holds the comment value before it's actually saved to the cell meta.
243
+ *
244
+ * @private
245
+ * @type {string}
246
+ */
247
+ _classPrivateFieldInitSpec(_assertThisInitialized(_this), _commentValueBeforeSave, {
248
+ writable: true,
249
+ value: ''
192
250
  });
193
251
  return _this;
194
252
  }
195
-
196
- /**
197
- * Checks if the plugin is enabled in the handsontable settings. This method is executed in {@link Hooks#beforeInit}
198
- * hook and if it returns `true` then the {@link Comments#enablePlugin} method is called.
199
- *
200
- * @returns {boolean}
201
- */
202
253
  _createClass(Comments, [{
203
254
  key: "isEnabled",
204
- value: function isEnabled() {
255
+ value:
256
+ /**
257
+ * Checks if the plugin is enabled in the handsontable settings. This method is executed in {@link Hooks#beforeInit}
258
+ * hook and if it returns `true` then the {@link Comments#enablePlugin} method is called.
259
+ *
260
+ * @returns {boolean}
261
+ */
262
+ function isEnabled() {
205
263
  return !!this.hot.getSettings()[PLUGIN_KEY];
206
264
  }
207
265
 
@@ -215,14 +273,14 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
215
273
  if (this.enabled) {
216
274
  return;
217
275
  }
218
- if (!this.editor) {
219
- this.editor = new _commentEditor.default(this.hot.rootDocument, this.hot.isRtl());
276
+ if (!_classPrivateFieldGet(this, _editor)) {
277
+ _classPrivateFieldSet(this, _editor, new _commentEditor.default(this.hot.rootDocument, this.hot.isRtl()));
220
278
  }
221
279
  if (!this.eventManager) {
222
280
  this.eventManager = new _eventManager.default(this);
223
281
  }
224
- if (!this.displaySwitch) {
225
- this.displaySwitch = new _displaySwitch.default(this.getDisplayDelaySetting());
282
+ if (!_classPrivateFieldGet(this, _displaySwitch)) {
283
+ _classPrivateFieldSet(this, _displaySwitch, new _displaySwitch2.default(this.getDisplayDelaySetting()));
226
284
  }
227
285
  this.addHook('afterContextMenuDefaultOptions', function (options) {
228
286
  return _this2.addToContextMenu(options);
@@ -239,12 +297,16 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
239
297
  this.addHook('afterBeginEditing', function () {
240
298
  return _this2.hide();
241
299
  });
242
- this.displaySwitch.addLocalHook('hide', function () {
300
+ this.addHook('afterDocumentKeyDown', function (event) {
301
+ return _this2.onAfterDocumentKeyDown(event);
302
+ });
303
+ _classPrivateFieldGet(this, _displaySwitch).addLocalHook('hide', function () {
243
304
  return _this2.hide();
244
305
  });
245
- this.displaySwitch.addLocalHook('show', function (row, col) {
306
+ _classPrivateFieldGet(this, _displaySwitch).addLocalHook('show', function (row, col) {
246
307
  return _this2.showAtCell(row, col);
247
308
  });
309
+ this.registerShortcuts();
248
310
  this.registerListeners();
249
311
  _get(_getPrototypeOf(Comments.prototype), "enablePlugin", this).call(this);
250
312
  }
@@ -258,10 +320,8 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
258
320
  }, {
259
321
  key: "updatePlugin",
260
322
  value: function updatePlugin() {
261
- this.disablePlugin();
262
- this.enablePlugin();
323
+ _classPrivateFieldGet(this, _displaySwitch).updateDelay(this.getDisplayDelaySetting());
263
324
  _get(_getPrototypeOf(Comments.prototype), "updatePlugin", this).call(this);
264
- this.displaySwitch.updateDelay(this.getDisplayDelaySetting());
265
325
  }
266
326
 
267
327
  /**
@@ -270,9 +330,76 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
270
330
  }, {
271
331
  key: "disablePlugin",
272
332
  value: function disablePlugin() {
333
+ this.unregisterShortcuts();
273
334
  _get(_getPrototypeOf(Comments.prototype), "disablePlugin", this).call(this);
274
335
  }
275
336
 
337
+ /**
338
+ * Register shortcuts responsible for toggling context menu.
339
+ *
340
+ * @private
341
+ */
342
+ }, {
343
+ key: "registerShortcuts",
344
+ value: function registerShortcuts() {
345
+ var _this3 = this;
346
+ var manager = this.hot.getShortcutManager();
347
+ var gridContext = manager.getContext('grid');
348
+ var pluginContext = manager.addContext(SHORTCUTS_CONTEXT_NAME);
349
+ gridContext.addShortcut({
350
+ keys: [['Control', 'Alt', 'M']],
351
+ callback: function callback() {
352
+ var range = _this3.hot.getSelectedRangeLast();
353
+ _this3.setRange(range);
354
+ _this3.show();
355
+ _this3.focusEditor();
356
+ manager.setActiveContextName(SHORTCUTS_CONTEXT_NAME);
357
+ },
358
+ stopPropagation: true,
359
+ runOnlyIf: function runOnlyIf() {
360
+ var _this3$hot$getSelecte;
361
+ return ((_this3$hot$getSelecte = _this3.hot.getSelectedRangeLast()) === null || _this3$hot$getSelecte === void 0 ? void 0 : _this3$hot$getSelecte.highlight.isCell()) && !_classPrivateFieldGet(_this3, _editor).isVisible();
362
+ },
363
+ group: SHORTCUTS_GROUP
364
+ });
365
+ pluginContext.addShortcut({
366
+ keys: [['Escape']],
367
+ callback: function callback() {
368
+ _classPrivateFieldGet(_this3, _editor).setValue(_classPrivateFieldGet(_this3, _commentValueBeforeSave));
369
+ _this3.hide();
370
+ manager.setActiveContextName('grid');
371
+ },
372
+ runOnlyIf: function runOnlyIf() {
373
+ var _this3$hot$getSelecte2;
374
+ return ((_this3$hot$getSelecte2 = _this3.hot.getSelectedRangeLast()) === null || _this3$hot$getSelecte2 === void 0 ? void 0 : _this3$hot$getSelecte2.highlight.isCell()) && _classPrivateFieldGet(_this3, _editor).isVisible();
375
+ },
376
+ group: SHORTCUTS_GROUP
377
+ });
378
+ pluginContext.addShortcut({
379
+ keys: [['Control/Meta', 'Enter']],
380
+ callback: function callback() {
381
+ _this3.hide();
382
+ manager.setActiveContextName('grid');
383
+ },
384
+ runOnlyIf: function runOnlyIf() {
385
+ var _this3$hot$getSelecte3;
386
+ return ((_this3$hot$getSelecte3 = _this3.hot.getSelectedRangeLast()) === null || _this3$hot$getSelecte3 === void 0 ? void 0 : _this3$hot$getSelecte3.highlight.isCell()) && _classPrivateFieldGet(_this3, _editor).isVisible();
387
+ },
388
+ group: SHORTCUTS_GROUP
389
+ });
390
+ }
391
+
392
+ /**
393
+ * Unregister shortcuts responsible for toggling context menu.
394
+ *
395
+ * @private
396
+ */
397
+ }, {
398
+ key: "unregisterShortcuts",
399
+ value: function unregisterShortcuts() {
400
+ this.hot.getShortcutManager().getContext('grid').removeShortcutsByGroup(SHORTCUTS_GROUP);
401
+ }
402
+
276
403
  /**
277
404
  * Registers all necessary DOM listeners.
278
405
  *
@@ -281,25 +408,29 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
281
408
  }, {
282
409
  key: "registerListeners",
283
410
  value: function registerListeners() {
284
- var _this3 = this;
411
+ var _this4 = this;
285
412
  var rootDocument = this.hot.rootDocument;
413
+ var editorElement = this.getEditorInputElement();
286
414
  this.eventManager.addEventListener(rootDocument, 'mouseover', function (event) {
287
- return _this3.onMouseOver(event);
415
+ return _this4.onMouseOver(event);
288
416
  });
289
417
  this.eventManager.addEventListener(rootDocument, 'mousedown', function (event) {
290
- return _this3.onMouseDown(event);
418
+ return _this4.onMouseDown(event);
291
419
  });
292
420
  this.eventManager.addEventListener(rootDocument, 'mouseup', function () {
293
- return _this3.onMouseUp();
421
+ return _this4.onMouseUp();
422
+ });
423
+ this.eventManager.addEventListener(editorElement, 'focus', function () {
424
+ return _this4.onEditorFocus();
294
425
  });
295
- this.eventManager.addEventListener(this.editor.getInputElement(), 'blur', function () {
296
- return _this3.onEditorBlur();
426
+ this.eventManager.addEventListener(editorElement, 'blur', function () {
427
+ return _this4.onEditorBlur();
297
428
  });
298
- this.eventManager.addEventListener(this.editor.getInputElement(), 'mousedown', function (event) {
299
- return _this3.onEditorMouseDown(event);
429
+ this.eventManager.addEventListener(editorElement, 'mousedown', function (event) {
430
+ return _this4.onEditorMouseDown(event);
300
431
  });
301
- this.eventManager.addEventListener(this.editor.getInputElement(), 'mouseup', function (event) {
302
- return _this3.onEditorMouseUp(event);
432
+ this.eventManager.addEventListener(editorElement, 'mouseup', function (event) {
433
+ return _this4.onEditorMouseUp(event);
303
434
  });
304
435
  }
305
436
 
@@ -347,7 +478,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
347
478
  }, {
348
479
  key: "targetIsCommentTextArea",
349
480
  value: function targetIsCommentTextArea(event) {
350
- return this.editor.getInputElement() === event.target;
481
+ return this.getEditorInputElement() === event.target;
351
482
  }
352
483
 
353
484
  /**
@@ -361,7 +492,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
361
492
  if (!this.range.from) {
362
493
  throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
363
494
  }
364
- var editorValue = this.editor.getValue();
495
+ var editorValue = _classPrivateFieldGet(this, _editor).getValue();
365
496
  var comment = '';
366
497
  if (value !== null && value !== void 0) {
367
498
  comment = value;
@@ -470,8 +601,9 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
470
601
  return false;
471
602
  }
472
603
  var meta = this.hot.getCellMeta(this.range.from.row, this.range.from.col);
473
- this.editor.setValue(meta[META_COMMENT] ? meta[META_COMMENT][META_COMMENT_VALUE] : null || '');
474
- this.editor.show();
604
+ _classPrivateFieldGet(this, _displaySwitch).cancelHiding();
605
+ _classPrivateFieldGet(this, _editor).setValue(meta[META_COMMENT] ? meta[META_COMMENT][META_COMMENT_VALUE] : null || '');
606
+ _classPrivateFieldGet(this, _editor).show();
475
607
  this.refreshEditor(true);
476
608
  return true;
477
609
  }
@@ -498,7 +630,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
498
630
  }, {
499
631
  key: "hide",
500
632
  value: function hide() {
501
- this.editor.hide();
633
+ _classPrivateFieldGet(this, _editor).hide();
502
634
  }
503
635
 
504
636
  /**
@@ -511,7 +643,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
511
643
  value: function refreshEditor() {
512
644
  var _renderableRow, _renderableColumn;
513
645
  var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
514
- if (!force && (!this.range.from || !this.editor.isVisible())) {
646
+ if (!force && (!this.range.from || !_classPrivateFieldGet(this, _editor).isVisible())) {
515
647
  return;
516
648
  }
517
649
  var _this$hot = this.hot,
@@ -527,7 +659,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
527
659
 
528
660
  // Reset the editor position to (0, 0) so the opening direction calculation wouldn't be influenced by its
529
661
  // previous position
530
- this.editor.setPosition(0, 0);
662
+ _classPrivateFieldGet(this, _editor).setPosition(0, 0);
531
663
  if (renderableRow === null) {
532
664
  renderableRow = rowIndexMapper.getRenderableFromVisualIndex(rowIndexMapper.getNearestNotHiddenIndex(visualRow, -1));
533
665
  }
@@ -550,9 +682,9 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
550
682
  }, true);
551
683
  var commentStyle = this.getCommentMeta(visualRow, visualColumn, META_STYLE);
552
684
  if (commentStyle) {
553
- this.editor.setSize(commentStyle.width, commentStyle.height);
685
+ _classPrivateFieldGet(this, _editor).setSize(commentStyle.width, commentStyle.height);
554
686
  } else {
555
- this.editor.resetSize();
687
+ _classPrivateFieldGet(this, _editor).resetSize();
556
688
  }
557
689
  var lastColWidth = isBeforeRenderedColumns ? 0 : wtTable.getStretchedColumnWidth(renderableColumn);
558
690
  var lastRowHeight = targetingPreviousRow && !isBeforeRenderedRows ? (0, _element.outerHeight)(TD) : 0;
@@ -561,9 +693,9 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
561
693
  top = _TD$getBoundingClient.top,
562
694
  cellWidth = _TD$getBoundingClient.width,
563
695
  cellHeight = _TD$getBoundingClient.height;
564
- var _this$editor$getSize = this.editor.getSize(),
565
- editorWidth = _this$editor$getSize.width,
566
- editorHeight = _this$editor$getSize.height;
696
+ var _classPrivateFieldGet2 = _classPrivateFieldGet(this, _editor).getSize(),
697
+ editorWidth = _classPrivateFieldGet2.width,
698
+ editorHeight = _classPrivateFieldGet2.height;
567
699
  var _this$hot$rootWindow = this.hot.rootWindow,
568
700
  innerWidth = _this$hot$rootWindow.innerWidth,
569
701
  innerHeight = _this$hot$rootWindow.innerHeight;
@@ -583,30 +715,17 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
583
715
  if (top + editorHeight > innerHeight) {
584
716
  y -= editorHeight - cellHeight + 1;
585
717
  }
586
- this.editor.setPosition(x, y);
587
- this.editor.setReadOnlyState(this.getCommentMeta(visualRow, visualColumn, META_READONLY));
718
+ _classPrivateFieldGet(this, _editor).setPosition(x, y);
719
+ _classPrivateFieldGet(this, _editor).setReadOnlyState(this.getCommentMeta(visualRow, visualColumn, META_READONLY));
588
720
  }
589
721
 
590
722
  /**
591
- * Checks if there is a comment for selected range.
592
- *
593
- * @private
594
- * @returns {boolean}
723
+ * Focuses the comments editor element.
595
724
  */
596
725
  }, {
597
- key: "checkSelectionCommentsConsistency",
598
- value: function checkSelectionCommentsConsistency() {
599
- var selected = this.hot.getSelectedRangeLast();
600
- if (!selected) {
601
- return false;
602
- }
603
- var hasComment = false;
604
- var cell = selected.getTopStartCorner(); // IN EXCEL THERE IS COMMENT ONLY FOR TOP LEFT CELL IN SELECTION
605
-
606
- if (this.getCommentMeta(cell.row, cell.col, META_COMMENT_VALUE)) {
607
- hasComment = true;
608
- }
609
- return hasComment;
726
+ key: "focusEditor",
727
+ value: function focusEditor() {
728
+ _classPrivateFieldGet(this, _editor).focus();
610
729
  }
611
730
 
612
731
  /**
@@ -660,7 +779,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
660
779
  if (!this.hot.view || !this.hot.view._wt) {
661
780
  return;
662
781
  }
663
- if (!this.preventEditorAutoSwitch && !this.targetIsCommentTextArea(event)) {
782
+ if (!_classPrivateFieldGet(this, _preventEditorAutoSwitch) && !this.targetIsCommentTextArea(event)) {
664
783
  var eventCell = (0, _element.closest)(event.target, 'TD', 'TBODY');
665
784
  var coordinates = null;
666
785
  if (eventCell) {
@@ -681,17 +800,16 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
681
800
  }, {
682
801
  key: "onMouseOver",
683
802
  value: function onMouseOver(event) {
684
- var priv = privatePool.get(this);
685
803
  var rootDocument = this.hot.rootDocument;
686
- if (this.preventEditorAutoSwitch || this.editor.isFocused() || (0, _element.hasClass)(event.target, 'wtBorder') || priv.cellBelowCursor === event.target || !this.editor) {
804
+ if (_classPrivateFieldGet(this, _preventEditorAutoSwitch) || _classPrivateFieldGet(this, _editor).isFocused() || (0, _element.hasClass)(event.target, 'wtBorder') || _classPrivateFieldGet(this, _cellBelowCursor) === event.target || !_classPrivateFieldGet(this, _editor)) {
687
805
  return;
688
806
  }
689
- priv.cellBelowCursor = rootDocument.elementFromPoint(event.clientX, event.clientY);
807
+ _classPrivateFieldSet(this, _cellBelowCursor, rootDocument.elementFromPoint(event.clientX, event.clientY));
690
808
  if (this.targetIsCellWithComment(event)) {
691
809
  var range = this.hot._createCellRange(this.hot.getCoords(event.target));
692
- this.displaySwitch.show(range);
810
+ _classPrivateFieldGet(this, _displaySwitch).show(range);
693
811
  } else if ((0, _element.isChildOf)(event.target, rootDocument) && !this.targetIsCommentTextArea(event)) {
694
- this.displaySwitch.hide();
812
+ _classPrivateFieldGet(this, _displaySwitch).hide();
695
813
  }
696
814
  }
697
815
 
@@ -703,7 +821,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
703
821
  }, {
704
822
  key: "onMouseUp",
705
823
  value: function onMouseUp() {
706
- this.preventEditorAutoSwitch = false;
824
+ _classPrivateFieldSet(this, _preventEditorAutoSwitch, false);
707
825
  }
708
826
 
709
827
  /**
@@ -722,16 +840,33 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
722
840
  }
723
841
 
724
842
  /**
725
- * `blur` event callback for the comment editor.
843
+ * Hook observer the "blur" event from the comments editor element. The hook clears the
844
+ * editor content and gives back the keyboard shortcuts control by switching to the "grid" context.
726
845
  *
727
846
  * @private
728
847
  */
729
848
  }, {
730
849
  key: "onEditorBlur",
731
850
  value: function onEditorBlur() {
851
+ _classPrivateFieldSet(this, _commentValueBeforeSave, '');
852
+ this.hot.getShortcutManager().setActiveContextName('grid');
732
853
  this.setComment();
733
854
  }
734
855
 
856
+ /**
857
+ * Hook observer the "focus" event from the comments editor element. The hook takes the control of
858
+ * the keyboard shortcuts by switching the context to plugins one.
859
+ *
860
+ * @private
861
+ */
862
+ }, {
863
+ key: "onEditorFocus",
864
+ value: function onEditorFocus() {
865
+ _classPrivateFieldSet(this, _commentValueBeforeSave, this.getComment());
866
+ this.hot.listen();
867
+ this.hot.getShortcutManager().setActiveContextName(SHORTCUTS_CONTEXT_NAME);
868
+ }
869
+
735
870
  /**
736
871
  * `mousedown` hook. Along with `onEditorMouseUp` used to simulate the textarea resizing event.
737
872
  *
@@ -741,11 +876,10 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
741
876
  }, {
742
877
  key: "onEditorMouseDown",
743
878
  value: function onEditorMouseDown(event) {
744
- var priv = privatePool.get(this);
745
- priv.tempEditorDimensions = {
879
+ _classPrivateFieldSet(this, _tempEditorDimensions, {
746
880
  width: (0, _element.outerWidth)(event.target),
747
881
  height: (0, _element.outerHeight)(event.target)
748
- };
882
+ });
749
883
  }
750
884
 
751
885
  /**
@@ -757,10 +891,9 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
757
891
  }, {
758
892
  key: "onEditorMouseUp",
759
893
  value: function onEditorMouseUp(event) {
760
- var priv = privatePool.get(this);
761
894
  var currentWidth = (0, _element.outerWidth)(event.target);
762
895
  var currentHeight = (0, _element.outerHeight)(event.target);
763
- if (currentWidth !== priv.tempEditorDimensions.width + 1 || currentHeight !== priv.tempEditorDimensions.height + 2) {
896
+ if (currentWidth !== _classPrivateFieldGet(this, _tempEditorDimensions).width + 1 || currentHeight !== _classPrivateFieldGet(this, _tempEditorDimensions).height + 2) {
764
897
  this.updateCommentMeta(this.range.from.row, this.range.from.col, _defineProperty({}, META_STYLE, {
765
898
  width: currentWidth,
766
899
  height: currentHeight
@@ -769,137 +902,31 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
769
902
  }
770
903
 
771
904
  /**
772
- * Context Menu's "Add comment" callback. Results in showing the comment editor.
773
- *
774
- * @private
775
- */
776
- }, {
777
- key: "onContextMenuAddComment",
778
- value: function onContextMenuAddComment() {
779
- var coords = this.hot.getSelectedRangeLast();
780
- this.preventEditorAutoSwitch = true;
781
- this.displaySwitch.cancelHiding();
782
- this.setRange({
783
- from: coords.highlight
784
- });
785
- this.show();
786
- this.hot.deselectCell();
787
- this.editor.focus();
788
- }
789
-
790
- /**
791
- * Context Menu's "remove comment" callback.
905
+ * Observes the pressed keys and if there is already opened the comment editor prevents open
906
+ * the table editor into the fast edit mode.
792
907
  *
793
- * @private
794
- */
795
- }, {
796
- key: "onContextMenuRemoveComment",
797
- value: function onContextMenuRemoveComment() {
798
- var _this4 = this;
799
- var coords = this.hot.getSelectedRangeLast();
800
- this.preventEditorAutoSwitch = true;
801
- coords.forAll(function (row, column) {
802
- if (row >= 0 && column >= 0) {
803
- _this4.removeCommentAtCell(row, column, false);
804
- }
805
- });
806
- this.hot.render();
807
- }
808
-
809
- /**
810
- * Context Menu's "make comment read-only" callback.
811
- *
812
- * @private
908
+ * @param {Event} event The keydown event.
813
909
  */
814
910
  }, {
815
- key: "onContextMenuMakeReadOnly",
816
- value: function onContextMenuMakeReadOnly() {
817
- var _this5 = this;
818
- var coords = this.hot.getSelectedRangeLast();
819
- this.preventEditorAutoSwitch = true;
820
- coords.forAll(function (row, column) {
821
- if (row >= 0 && column >= 0) {
822
- var currentState = !!_this5.getCommentMeta(row, column, META_READONLY);
823
- _this5.updateCommentMeta(row, column, _defineProperty({}, META_READONLY, !currentState));
824
- }
825
- });
911
+ key: "onAfterDocumentKeyDown",
912
+ value: function onAfterDocumentKeyDown(event) {
913
+ if (_classPrivateFieldGet(this, _editor).isVisible()) {
914
+ (0, _event.stopImmediatePropagation)(event);
915
+ }
826
916
  }
827
917
 
828
918
  /**
829
919
  * Add Comments plugin options to the Context Menu.
830
920
  *
831
921
  * @private
832
- * @param {object} defaultOptions The menu options.
922
+ * @param {object} options The menu options.
833
923
  */
834
924
  }, {
835
925
  key: "addToContextMenu",
836
- value: function addToContextMenu(defaultOptions) {
837
- var _this6 = this;
838
- var isThereAnyCellRendered = function isThereAnyCellRendered() {
839
- return _this6.hot.rowIndexMapper.getRenderableIndexesLength() > 0 && _this6.hot.columnIndexMapper.getRenderableIndexesLength() > 0;
840
- };
841
- defaultOptions.items.push({
842
- name: '---------'
843
- }, {
844
- key: 'commentsAddEdit',
845
- name: function name() {
846
- if (_this6.checkSelectionCommentsConsistency()) {
847
- return _this6.hot.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_EDIT_COMMENT);
848
- }
849
- return _this6.hot.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ADD_COMMENT);
850
- },
851
- callback: function callback() {
852
- return _this6.onContextMenuAddComment();
853
- },
854
- disabled: function disabled() {
855
- if (!isThereAnyCellRendered()) {
856
- return true;
857
- }
858
- return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner());
859
- }
860
- }, {
861
- key: 'commentsRemove',
862
- name: function name() {
863
- return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_REMOVE_COMMENT);
864
- },
865
- callback: function callback() {
866
- return _this6.onContextMenuRemoveComment();
867
- },
868
- disabled: function disabled() {
869
- if (!isThereAnyCellRendered()) {
870
- return true;
871
- }
872
- return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner());
873
- }
874
- }, {
875
- key: 'commentsReadOnly',
876
- name: function name() {
877
- var _this7 = this;
878
- var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_READ_ONLY_COMMENT);
879
- var hasProperty = (0, _utils.checkSelectionConsistency)(this.getSelectedRangeLast(), function (row, col) {
880
- var readOnlyProperty = _this7.getCellMeta(row, col)[META_COMMENT];
881
- if (readOnlyProperty) {
882
- readOnlyProperty = readOnlyProperty[META_READONLY];
883
- }
884
- if (readOnlyProperty) {
885
- return true;
886
- }
887
- });
888
- if (hasProperty) {
889
- label = (0, _utils.markLabelAsSelected)(label);
890
- }
891
- return label;
892
- },
893
- callback: function callback() {
894
- return _this6.onContextMenuMakeReadOnly();
895
- },
896
- disabled: function disabled() {
897
- if (!isThereAnyCellRendered()) {
898
- return true;
899
- }
900
- return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner()) || !_this6.checkSelectionCommentsConsistency();
901
- }
902
- });
926
+ value: function addToContextMenu(options) {
927
+ options.items.push({
928
+ name: _predefinedItems.SEPARATOR
929
+ }, (0, _addEditComment.default)(this), (0, _removeComment.default)(this), (0, _readOnlyComment.default)(this));
903
930
  }
904
931
 
905
932
  /**
@@ -917,17 +944,29 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
917
944
  }
918
945
  }
919
946
 
947
+ /**
948
+ * Gets the editors input element.
949
+ *
950
+ * @private
951
+ * @returns {HTMLTextAreaElement}
952
+ */
953
+ }, {
954
+ key: "getEditorInputElement",
955
+ value: function getEditorInputElement() {
956
+ return _classPrivateFieldGet(this, _editor).getInputElement();
957
+ }
958
+
920
959
  /**
921
960
  * Destroys the plugin instance.
922
961
  */
923
962
  }, {
924
963
  key: "destroy",
925
964
  value: function destroy() {
926
- if (this.editor) {
927
- this.editor.destroy();
965
+ if (_classPrivateFieldGet(this, _editor)) {
966
+ _classPrivateFieldGet(this, _editor).destroy();
928
967
  }
929
- if (this.displaySwitch) {
930
- this.displaySwitch.destroy();
968
+ if (_classPrivateFieldGet(this, _displaySwitch)) {
969
+ _classPrivateFieldGet(this, _displaySwitch).destroy();
931
970
  }
932
971
  _get(_getPrototypeOf(Comments.prototype), "destroy", this).call(this);
933
972
  }