handsontable 0.0.0-next-3b33ccd-20230710 → 0.0.0-next-90e205d-20230711

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 (64) hide show
  1. package/base.js +2 -2
  2. package/base.mjs +2 -2
  3. package/core/focusCatcher/focusDetector.js +62 -0
  4. package/core/focusCatcher/focusDetector.mjs +58 -0
  5. package/core/focusCatcher/index.js +140 -0
  6. package/core/focusCatcher/index.mjs +136 -0
  7. package/core/index.js +12 -0
  8. package/core/index.mjs +1 -0
  9. package/core.d.ts +0 -1
  10. package/core.js +24 -31
  11. package/core.mjs +24 -31
  12. package/dataMap/metaManager/metaSchema.js +22 -0
  13. package/dataMap/metaManager/metaSchema.mjs +22 -0
  14. package/dist/handsontable.css +13 -2
  15. package/dist/handsontable.full.css +13 -2
  16. package/dist/handsontable.full.js +4815 -4810
  17. package/dist/handsontable.full.min.css +3 -3
  18. package/dist/handsontable.full.min.js +61 -61
  19. package/dist/handsontable.js +13215 -13210
  20. package/dist/handsontable.min.css +3 -3
  21. package/dist/handsontable.min.js +4 -4
  22. package/editorManager.js +10 -4
  23. package/editorManager.mjs +10 -4
  24. package/helpers/mixed.js +1 -1
  25. package/helpers/mixed.mjs +1 -1
  26. package/package.json +1 -1
  27. package/pluginHooks.d.ts +1 -1
  28. package/pluginHooks.js +10 -7
  29. package/pluginHooks.mjs +10 -7
  30. package/plugins/comments/commentEditor.js +0 -1
  31. package/plugins/comments/commentEditor.mjs +0 -1
  32. package/plugins/comments/comments.js +231 -289
  33. package/plugins/comments/comments.mjs +241 -297
  34. package/plugins/contextMenu/contextMenu.js +0 -1
  35. package/plugins/contextMenu/contextMenu.mjs +0 -1
  36. package/plugins/copyPaste/copyPaste.js +1 -1
  37. package/plugins/copyPaste/copyPaste.mjs +1 -1
  38. package/plugins/dropdownMenu/dropdownMenu.js +1 -0
  39. package/plugins/dropdownMenu/dropdownMenu.mjs +1 -0
  40. package/plugins/formulas/engine/settings.js +2 -2
  41. package/plugins/formulas/engine/settings.mjs +2 -2
  42. package/plugins/formulas/formulas.js +2 -2
  43. package/plugins/formulas/formulas.mjs +2 -2
  44. package/plugins/manualRowResize/manualRowResize.js +2 -2
  45. package/plugins/manualRowResize/manualRowResize.mjs +2 -2
  46. package/settings.d.ts +1 -0
  47. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +2 -7
  48. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +2 -7
  49. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +2 -7
  50. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +2 -7
  51. package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +2 -7
  52. package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +2 -7
  53. package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +2 -7
  54. package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +2 -7
  55. package/shortcutContexts/constants.js +1 -6
  56. package/shortcutContexts/constants.mjs +0 -4
  57. package/tableView.js +4 -9
  58. package/tableView.mjs +4 -9
  59. package/plugins/comments/contextMenuItem/addEditComment.js +0 -51
  60. package/plugins/comments/contextMenuItem/addEditComment.mjs +0 -35
  61. package/plugins/comments/contextMenuItem/readOnlyComment.js +0 -63
  62. package/plugins/comments/contextMenuItem/readOnlyComment.mjs +0 -55
  63. package/plugins/comments/contextMenuItem/removeComment.js +0 -48
  64. package/plugins/comments/contextMenuItem/removeComment.mjs +0 -32
@@ -1,40 +1,41 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.symbol.to-primitive.js");
4
- require("core-js/modules/es.date.to-primitive.js");
5
- require("core-js/modules/es.symbol.js");
6
- require("core-js/modules/es.symbol.description.js");
7
- require("core-js/modules/es.number.constructor.js");
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); }
8
4
  require("core-js/modules/es.object.set-prototype-of.js");
9
5
  require("core-js/modules/es.object.get-prototype-of.js");
10
6
  require("core-js/modules/es.reflect.construct.js");
11
7
  require("core-js/modules/es.reflect.get.js");
12
8
  require("core-js/modules/es.object.get-own-property-descriptor.js");
9
+ require("core-js/modules/es.symbol.to-primitive.js");
10
+ require("core-js/modules/es.date.to-primitive.js");
11
+ require("core-js/modules/es.symbol.js");
12
+ require("core-js/modules/es.symbol.description.js");
13
+ require("core-js/modules/es.number.constructor.js");
13
14
  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.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");
16
+ exports.PLUGIN_PRIORITY = exports.PLUGIN_KEY = exports.Comments = void 0;
18
17
  require("core-js/modules/es.array.iterator.js");
19
18
  require("core-js/modules/es.object.to-string.js");
20
19
  require("core-js/modules/es.string.iterator.js");
21
20
  require("core-js/modules/es.weak-map.js");
22
21
  require("core-js/modules/web.dom-collections.iterator.js");
23
22
  var _element = require("../../helpers/dom/element");
24
- var _event = require("../../helpers/dom/event");
25
23
  var _object = require("../../helpers/object");
26
24
  var _eventManager = _interopRequireDefault(require("../../eventManager"));
27
25
  var _base = require("../base");
28
26
  var _commentEditor = _interopRequireDefault(require("./commentEditor"));
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"));
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; }
34
32
  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; }
35
34
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
36
35
  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); } }
37
36
  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); }
38
39
  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); }
39
40
  function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
40
41
  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); }
@@ -44,30 +45,15 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
44
45
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
45
46
  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; } }
46
47
  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; }
57
48
  var PLUGIN_KEY = 'comments';
58
49
  exports.PLUGIN_KEY = PLUGIN_KEY;
59
50
  var PLUGIN_PRIORITY = 60;
60
51
  exports.PLUGIN_PRIORITY = PLUGIN_PRIORITY;
52
+ var privatePool = new WeakMap();
61
53
  var META_COMMENT = 'comment';
62
- exports.META_COMMENT = META_COMMENT;
63
54
  var META_COMMENT_VALUE = 'value';
64
- exports.META_COMMENT_VALUE = META_COMMENT_VALUE;
65
55
  var META_STYLE = 'style';
66
- exports.META_STYLE = META_STYLE;
67
56
  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);
71
57
 
72
58
  /* eslint-disable jsdoc/require-description-complete-sentence */
73
59
  /**
@@ -159,119 +145,63 @@ var SHORTCUTS_CONTEXT_NAME = "plugin:".concat(PLUGIN_KEY);
159
145
  * ```
160
146
  * :::
161
147
  */
162
- var _editor = /*#__PURE__*/new WeakMap();
163
- var _displaySwitch = /*#__PURE__*/new WeakMap();
164
- var _preventEditorAutoSwitch = /*#__PURE__*/new WeakMap();
165
- var _preventEditorHiding = /*#__PURE__*/new WeakMap();
166
- var _tempEditorDimensions = /*#__PURE__*/new WeakMap();
167
- var _cellBelowCursor = /*#__PURE__*/new WeakMap();
168
- var _commentValueBeforeSave = /*#__PURE__*/new WeakMap();
169
148
  var Comments = /*#__PURE__*/function (_BasePlugin) {
170
149
  _inherits(Comments, _BasePlugin);
171
150
  var _super = _createSuper(Comments);
172
- function Comments() {
151
+ function Comments(hotInstance) {
173
152
  var _this;
174
153
  _classCallCheck(this, Comments);
175
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
176
- args[_key] = arguments[_key];
177
- }
178
- _this = _super.call.apply(_super, [this].concat(args));
179
- /**
180
- * Current cell range, an object with `from` property, with `row` and `col` properties (e.q. `{from: {row: 1, col: 6}}`).
181
- *
182
- * @type {object}
183
- */
184
- _defineProperty(_assertThisInitialized(_this), "range", {});
185
- /**
186
- * Instance of {@link EventManager}.
187
- *
188
- * @protected
189
- * @type {EventManager}
190
- */
191
- _defineProperty(_assertThisInitialized(_this), "eventManager", null);
154
+ _this = _super.call(this, hotInstance);
192
155
  /**
193
156
  * Instance of {@link CommentEditor}.
194
157
  *
195
158
  * @private
196
159
  * @type {CommentEditor}
197
160
  */
198
- _classPrivateFieldInitSpec(_assertThisInitialized(_this), _editor, {
199
- writable: true,
200
- value: null
201
- });
161
+ _this.editor = null;
202
162
  /**
203
163
  * Instance of {@link DisplaySwitch}.
204
164
  *
205
165
  * @private
206
166
  * @type {DisplaySwitch}
207
167
  */
208
- _classPrivateFieldInitSpec(_assertThisInitialized(_this), _displaySwitch, {
209
- writable: true,
210
- value: null
211
- });
212
- /**
213
- * Prevents showing/hiding editor that reacts on the logic triggered by the "mouseover" events.
214
- *
215
- * @private
216
- * @type {boolean}
217
- */
218
- _classPrivateFieldInitSpec(_assertThisInitialized(_this), _preventEditorAutoSwitch, {
219
- writable: true,
220
- value: false
221
- });
168
+ _this.displaySwitch = null;
222
169
  /**
223
- * Prevents hiding editor when the table viewport is scrolled and that scroll is triggered by the
224
- * keyboard shortcut that insert or edits the comment.
170
+ * Instance of {@link EventManager}.
225
171
  *
226
172
  * @private
227
- * @type {boolean}
173
+ * @type {EventManager}
228
174
  */
229
- _classPrivateFieldInitSpec(_assertThisInitialized(_this), _preventEditorHiding, {
230
- writable: true,
231
- value: false
232
- });
175
+ _this.eventManager = null;
233
176
  /**
234
- * The property for holding editor dimensions for further processing.
177
+ * Current cell range, an object with `from` property, with `row` and `col` properties (e.q. `{from: {row: 1, col: 6}}`).
235
178
  *
236
- * @private
237
179
  * @type {object}
238
180
  */
239
- _classPrivateFieldInitSpec(_assertThisInitialized(_this), _tempEditorDimensions, {
240
- writable: true,
241
- value: {}
242
- });
181
+ _this.range = {};
243
182
  /**
244
- * The flag that allows processing mousedown event correctly when comments editor is triggered.
183
+ * Prevents showing/hiding editor that reacts on the logic triggered by the "mouseover" events.
245
184
  *
246
185
  * @private
247
186
  * @type {boolean}
248
187
  */
249
- _classPrivateFieldInitSpec(_assertThisInitialized(_this), _cellBelowCursor, {
250
- writable: true,
251
- value: null
252
- });
253
- /**
254
- * Holds the comment value before it's actually saved to the cell meta.
255
- *
256
- * @private
257
- * @type {string}
258
- */
259
- _classPrivateFieldInitSpec(_assertThisInitialized(_this), _commentValueBeforeSave, {
260
- writable: true,
261
- value: ''
188
+ _this.preventEditorAutoSwitch = false;
189
+ privatePool.set(_assertThisInitialized(_this), {
190
+ tempEditorDimensions: {},
191
+ cellBelowCursor: null
262
192
  });
263
193
  return _this;
264
194
  }
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
+ */
265
202
  _createClass(Comments, [{
266
203
  key: "isEnabled",
267
- value:
268
- /**
269
- * Checks if the plugin is enabled in the handsontable settings. This method is executed in {@link Hooks#beforeInit}
270
- * hook and if it returns `true` then the {@link Comments#enablePlugin} method is called.
271
- *
272
- * @returns {boolean}
273
- */
274
- function isEnabled() {
204
+ value: function isEnabled() {
275
205
  return !!this.hot.getSettings()[PLUGIN_KEY];
276
206
  }
277
207
 
@@ -285,14 +215,14 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
285
215
  if (this.enabled) {
286
216
  return;
287
217
  }
288
- if (!_classPrivateFieldGet(this, _editor)) {
289
- _classPrivateFieldSet(this, _editor, new _commentEditor.default(this.hot.rootDocument, this.hot.isRtl()));
218
+ if (!this.editor) {
219
+ this.editor = new _commentEditor.default(this.hot.rootDocument, this.hot.isRtl());
290
220
  }
291
221
  if (!this.eventManager) {
292
222
  this.eventManager = new _eventManager.default(this);
293
223
  }
294
- if (!_classPrivateFieldGet(this, _displaySwitch)) {
295
- _classPrivateFieldSet(this, _displaySwitch, new _displaySwitch2.default(this.getDisplayDelaySetting()));
224
+ if (!this.displaySwitch) {
225
+ this.displaySwitch = new _displaySwitch.default(this.getDisplayDelaySetting());
296
226
  }
297
227
  this.addHook('afterContextMenuDefaultOptions', function (options) {
298
228
  return _this2.addToContextMenu(options);
@@ -300,22 +230,21 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
300
230
  this.addHook('afterRenderer', function (TD, row, col, prop, value, cellProperties) {
301
231
  return _this2.onAfterRenderer(TD, cellProperties);
302
232
  });
303
- this.addHook('afterScroll', function () {
304
- return _this2.onAfterScroll();
233
+ this.addHook('afterScrollHorizontally', function () {
234
+ return _this2.hide();
305
235
  });
306
- this.addHook('afterBeginEditing', function () {
236
+ this.addHook('afterScrollVertically', function () {
307
237
  return _this2.hide();
308
238
  });
309
- this.addHook('afterDocumentKeyDown', function (event) {
310
- return _this2.onAfterDocumentKeyDown(event);
239
+ this.addHook('afterBeginEditing', function () {
240
+ return _this2.hide();
311
241
  });
312
- _classPrivateFieldGet(this, _displaySwitch).addLocalHook('hide', function () {
242
+ this.displaySwitch.addLocalHook('hide', function () {
313
243
  return _this2.hide();
314
244
  });
315
- _classPrivateFieldGet(this, _displaySwitch).addLocalHook('show', function (row, col) {
245
+ this.displaySwitch.addLocalHook('show', function (row, col) {
316
246
  return _this2.showAtCell(row, col);
317
247
  });
318
- this.registerShortcuts();
319
248
  this.registerListeners();
320
249
  _get(_getPrototypeOf(Comments.prototype), "enablePlugin", this).call(this);
321
250
  }
@@ -329,8 +258,10 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
329
258
  }, {
330
259
  key: "updatePlugin",
331
260
  value: function updatePlugin() {
332
- _classPrivateFieldGet(this, _displaySwitch).updateDelay(this.getDisplayDelaySetting());
261
+ this.disablePlugin();
262
+ this.enablePlugin();
333
263
  _get(_getPrototypeOf(Comments.prototype), "updatePlugin", this).call(this);
264
+ this.displaySwitch.updateDelay(this.getDisplayDelaySetting());
334
265
  }
335
266
 
336
267
  /**
@@ -339,82 +270,9 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
339
270
  }, {
340
271
  key: "disablePlugin",
341
272
  value: function disablePlugin() {
342
- this.unregisterShortcuts();
343
273
  _get(_getPrototypeOf(Comments.prototype), "disablePlugin", this).call(this);
344
274
  }
345
275
 
346
- /**
347
- * Register shortcuts responsible for toggling context menu.
348
- *
349
- * @private
350
- */
351
- }, {
352
- key: "registerShortcuts",
353
- value: function registerShortcuts() {
354
- var _this3 = this;
355
- var manager = this.hot.getShortcutManager();
356
- var gridContext = manager.getContext('grid');
357
- var pluginContext = manager.addContext(SHORTCUTS_CONTEXT_NAME);
358
- gridContext.addShortcut({
359
- keys: [['Control', 'Alt', 'M']],
360
- callback: function callback() {
361
- var range = _this3.hot.getSelectedRangeLast();
362
- _classPrivateFieldSet(_this3, _preventEditorHiding, true);
363
- _this3.hot.scrollToFocusedCell(function () {
364
- _this3.setRange(range);
365
- _this3.show();
366
- _this3.focusEditor();
367
- manager.setActiveContextName(SHORTCUTS_CONTEXT_NAME);
368
- _this3.hot._registerTimeout(function () {
369
- _classPrivateFieldSet(_this3, _preventEditorHiding, false);
370
- });
371
- });
372
- },
373
- stopPropagation: true,
374
- runOnlyIf: function runOnlyIf() {
375
- var _this3$hot$getSelecte;
376
- return ((_this3$hot$getSelecte = _this3.hot.getSelectedRangeLast()) === null || _this3$hot$getSelecte === void 0 ? void 0 : _this3$hot$getSelecte.highlight.isCell()) && !_classPrivateFieldGet(_this3, _editor).isVisible();
377
- },
378
- group: SHORTCUTS_GROUP
379
- });
380
- pluginContext.addShortcut({
381
- keys: [['Escape']],
382
- callback: function callback() {
383
- _classPrivateFieldGet(_this3, _editor).setValue(_classPrivateFieldGet(_this3, _commentValueBeforeSave));
384
- _this3.hide();
385
- manager.setActiveContextName('grid');
386
- },
387
- runOnlyIf: function runOnlyIf() {
388
- var _this3$hot$getSelecte2;
389
- return ((_this3$hot$getSelecte2 = _this3.hot.getSelectedRangeLast()) === null || _this3$hot$getSelecte2 === void 0 ? void 0 : _this3$hot$getSelecte2.highlight.isCell()) && _classPrivateFieldGet(_this3, _editor).isVisible();
390
- },
391
- group: SHORTCUTS_GROUP
392
- });
393
- pluginContext.addShortcut({
394
- keys: [['Control/Meta', 'Enter']],
395
- callback: function callback() {
396
- _this3.hide();
397
- manager.setActiveContextName('grid');
398
- },
399
- runOnlyIf: function runOnlyIf() {
400
- var _this3$hot$getSelecte3;
401
- return ((_this3$hot$getSelecte3 = _this3.hot.getSelectedRangeLast()) === null || _this3$hot$getSelecte3 === void 0 ? void 0 : _this3$hot$getSelecte3.highlight.isCell()) && _classPrivateFieldGet(_this3, _editor).isVisible();
402
- },
403
- group: SHORTCUTS_GROUP
404
- });
405
- }
406
-
407
- /**
408
- * Unregister shortcuts responsible for toggling context menu.
409
- *
410
- * @private
411
- */
412
- }, {
413
- key: "unregisterShortcuts",
414
- value: function unregisterShortcuts() {
415
- this.hot.getShortcutManager().getContext('grid').removeShortcutsByGroup(SHORTCUTS_GROUP);
416
- }
417
-
418
276
  /**
419
277
  * Registers all necessary DOM listeners.
420
278
  *
@@ -423,29 +281,25 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
423
281
  }, {
424
282
  key: "registerListeners",
425
283
  value: function registerListeners() {
426
- var _this4 = this;
284
+ var _this3 = this;
427
285
  var rootDocument = this.hot.rootDocument;
428
- var editorElement = this.getEditorInputElement();
429
286
  this.eventManager.addEventListener(rootDocument, 'mouseover', function (event) {
430
- return _this4.onMouseOver(event);
287
+ return _this3.onMouseOver(event);
431
288
  });
432
289
  this.eventManager.addEventListener(rootDocument, 'mousedown', function (event) {
433
- return _this4.onMouseDown(event);
290
+ return _this3.onMouseDown(event);
434
291
  });
435
292
  this.eventManager.addEventListener(rootDocument, 'mouseup', function () {
436
- return _this4.onMouseUp();
293
+ return _this3.onMouseUp();
437
294
  });
438
- this.eventManager.addEventListener(editorElement, 'focus', function () {
439
- return _this4.onEditorFocus();
295
+ this.eventManager.addEventListener(this.editor.getInputElement(), 'blur', function () {
296
+ return _this3.onEditorBlur();
440
297
  });
441
- this.eventManager.addEventListener(editorElement, 'blur', function () {
442
- return _this4.onEditorBlur();
298
+ this.eventManager.addEventListener(this.editor.getInputElement(), 'mousedown', function (event) {
299
+ return _this3.onEditorMouseDown(event);
443
300
  });
444
- this.eventManager.addEventListener(editorElement, 'mousedown', function (event) {
445
- return _this4.onEditorMouseDown(event);
446
- });
447
- this.eventManager.addEventListener(editorElement, 'mouseup', function (event) {
448
- return _this4.onEditorMouseUp(event);
301
+ this.eventManager.addEventListener(this.editor.getInputElement(), 'mouseup', function (event) {
302
+ return _this3.onEditorMouseUp(event);
449
303
  });
450
304
  }
451
305
 
@@ -493,7 +347,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
493
347
  }, {
494
348
  key: "targetIsCommentTextArea",
495
349
  value: function targetIsCommentTextArea(event) {
496
- return this.getEditorInputElement() === event.target;
350
+ return this.editor.getInputElement() === event.target;
497
351
  }
498
352
 
499
353
  /**
@@ -507,7 +361,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
507
361
  if (!this.range.from) {
508
362
  throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
509
363
  }
510
- var editorValue = _classPrivateFieldGet(this, _editor).getValue();
364
+ var editorValue = this.editor.getValue();
511
365
  var comment = '';
512
366
  if (value !== null && value !== void 0) {
513
367
  comment = value;
@@ -616,9 +470,8 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
616
470
  return false;
617
471
  }
618
472
  var meta = this.hot.getCellMeta(this.range.from.row, this.range.from.col);
619
- _classPrivateFieldGet(this, _displaySwitch).cancelHiding();
620
- _classPrivateFieldGet(this, _editor).setValue(meta[META_COMMENT] ? meta[META_COMMENT][META_COMMENT_VALUE] : null || '');
621
- _classPrivateFieldGet(this, _editor).show();
473
+ this.editor.setValue(meta[META_COMMENT] ? meta[META_COMMENT][META_COMMENT_VALUE] : null || '');
474
+ this.editor.show();
622
475
  this.refreshEditor(true);
623
476
  return true;
624
477
  }
@@ -645,7 +498,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
645
498
  }, {
646
499
  key: "hide",
647
500
  value: function hide() {
648
- _classPrivateFieldGet(this, _editor).hide();
501
+ this.editor.hide();
649
502
  }
650
503
 
651
504
  /**
@@ -658,7 +511,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
658
511
  value: function refreshEditor() {
659
512
  var _renderableRow, _renderableColumn;
660
513
  var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
661
- if (!force && (!this.range.from || !_classPrivateFieldGet(this, _editor).isVisible())) {
514
+ if (!force && (!this.range.from || !this.editor.isVisible())) {
662
515
  return;
663
516
  }
664
517
  var _this$hot = this.hot,
@@ -674,7 +527,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
674
527
 
675
528
  // Reset the editor position to (0, 0) so the opening direction calculation wouldn't be influenced by its
676
529
  // previous position
677
- _classPrivateFieldGet(this, _editor).setPosition(0, 0);
530
+ this.editor.setPosition(0, 0);
678
531
  if (renderableRow === null) {
679
532
  renderableRow = rowIndexMapper.getRenderableFromVisualIndex(rowIndexMapper.getNearestNotHiddenIndex(visualRow, -1));
680
533
  }
@@ -697,9 +550,9 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
697
550
  }, true);
698
551
  var commentStyle = this.getCommentMeta(visualRow, visualColumn, META_STYLE);
699
552
  if (commentStyle) {
700
- _classPrivateFieldGet(this, _editor).setSize(commentStyle.width, commentStyle.height);
553
+ this.editor.setSize(commentStyle.width, commentStyle.height);
701
554
  } else {
702
- _classPrivateFieldGet(this, _editor).resetSize();
555
+ this.editor.resetSize();
703
556
  }
704
557
  var lastColWidth = isBeforeRenderedColumns ? 0 : wtTable.getStretchedColumnWidth(renderableColumn);
705
558
  var lastRowHeight = targetingPreviousRow && !isBeforeRenderedRows ? (0, _element.outerHeight)(TD) : 0;
@@ -708,9 +561,9 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
708
561
  top = _TD$getBoundingClient.top,
709
562
  cellWidth = _TD$getBoundingClient.width,
710
563
  cellHeight = _TD$getBoundingClient.height;
711
- var _classPrivateFieldGet2 = _classPrivateFieldGet(this, _editor).getSize(),
712
- editorWidth = _classPrivateFieldGet2.width,
713
- editorHeight = _classPrivateFieldGet2.height;
564
+ var _this$editor$getSize = this.editor.getSize(),
565
+ editorWidth = _this$editor$getSize.width,
566
+ editorHeight = _this$editor$getSize.height;
714
567
  var _this$hot$rootWindow = this.hot.rootWindow,
715
568
  innerWidth = _this$hot$rootWindow.innerWidth,
716
569
  innerHeight = _this$hot$rootWindow.innerHeight;
@@ -730,17 +583,30 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
730
583
  if (top + editorHeight > innerHeight) {
731
584
  y -= editorHeight - cellHeight + 1;
732
585
  }
733
- _classPrivateFieldGet(this, _editor).setPosition(x, y);
734
- _classPrivateFieldGet(this, _editor).setReadOnlyState(this.getCommentMeta(visualRow, visualColumn, META_READONLY));
586
+ this.editor.setPosition(x, y);
587
+ this.editor.setReadOnlyState(this.getCommentMeta(visualRow, visualColumn, META_READONLY));
735
588
  }
736
589
 
737
590
  /**
738
- * Focuses the comments editor element.
591
+ * Checks if there is a comment for selected range.
592
+ *
593
+ * @private
594
+ * @returns {boolean}
739
595
  */
740
596
  }, {
741
- key: "focusEditor",
742
- value: function focusEditor() {
743
- _classPrivateFieldGet(this, _editor).focus();
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;
744
610
  }
745
611
 
746
612
  /**
@@ -794,7 +660,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
794
660
  if (!this.hot.view || !this.hot.view._wt) {
795
661
  return;
796
662
  }
797
- if (!_classPrivateFieldGet(this, _preventEditorAutoSwitch) && !this.targetIsCommentTextArea(event)) {
663
+ if (!this.preventEditorAutoSwitch && !this.targetIsCommentTextArea(event)) {
798
664
  var eventCell = (0, _element.closest)(event.target, 'TD', 'TBODY');
799
665
  var coordinates = null;
800
666
  if (eventCell) {
@@ -815,16 +681,17 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
815
681
  }, {
816
682
  key: "onMouseOver",
817
683
  value: function onMouseOver(event) {
684
+ var priv = privatePool.get(this);
818
685
  var rootDocument = this.hot.rootDocument;
819
- if (_classPrivateFieldGet(this, _preventEditorAutoSwitch) || _classPrivateFieldGet(this, _editor).isFocused() || (0, _element.hasClass)(event.target, 'wtBorder') || _classPrivateFieldGet(this, _cellBelowCursor) === event.target || !_classPrivateFieldGet(this, _editor)) {
686
+ if (this.preventEditorAutoSwitch || this.editor.isFocused() || (0, _element.hasClass)(event.target, 'wtBorder') || priv.cellBelowCursor === event.target || !this.editor) {
820
687
  return;
821
688
  }
822
- _classPrivateFieldSet(this, _cellBelowCursor, rootDocument.elementFromPoint(event.clientX, event.clientY));
689
+ priv.cellBelowCursor = rootDocument.elementFromPoint(event.clientX, event.clientY);
823
690
  if (this.targetIsCellWithComment(event)) {
824
691
  var range = this.hot._createCellRange(this.hot.getCoords(event.target));
825
- _classPrivateFieldGet(this, _displaySwitch).show(range);
692
+ this.displaySwitch.show(range);
826
693
  } else if ((0, _element.isChildOf)(event.target, rootDocument) && !this.targetIsCommentTextArea(event)) {
827
- _classPrivateFieldGet(this, _displaySwitch).hide();
694
+ this.displaySwitch.hide();
828
695
  }
829
696
  }
830
697
 
@@ -836,7 +703,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
836
703
  }, {
837
704
  key: "onMouseUp",
838
705
  value: function onMouseUp() {
839
- _classPrivateFieldSet(this, _preventEditorAutoSwitch, false);
706
+ this.preventEditorAutoSwitch = false;
840
707
  }
841
708
 
842
709
  /**
@@ -855,33 +722,16 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
855
722
  }
856
723
 
857
724
  /**
858
- * Hook observer the "blur" event from the comments editor element. The hook clears the
859
- * editor content and gives back the keyboard shortcuts control by switching to the "grid" context.
725
+ * `blur` event callback for the comment editor.
860
726
  *
861
727
  * @private
862
728
  */
863
729
  }, {
864
730
  key: "onEditorBlur",
865
731
  value: function onEditorBlur() {
866
- _classPrivateFieldSet(this, _commentValueBeforeSave, '');
867
- this.hot.getShortcutManager().setActiveContextName('grid');
868
732
  this.setComment();
869
733
  }
870
734
 
871
- /**
872
- * Hook observer the "focus" event from the comments editor element. The hook takes the control of
873
- * the keyboard shortcuts by switching the context to plugins one.
874
- *
875
- * @private
876
- */
877
- }, {
878
- key: "onEditorFocus",
879
- value: function onEditorFocus() {
880
- _classPrivateFieldSet(this, _commentValueBeforeSave, this.getComment());
881
- this.hot.listen();
882
- this.hot.getShortcutManager().setActiveContextName(SHORTCUTS_CONTEXT_NAME);
883
- }
884
-
885
735
  /**
886
736
  * `mousedown` hook. Along with `onEditorMouseUp` used to simulate the textarea resizing event.
887
737
  *
@@ -891,10 +741,11 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
891
741
  }, {
892
742
  key: "onEditorMouseDown",
893
743
  value: function onEditorMouseDown(event) {
894
- _classPrivateFieldSet(this, _tempEditorDimensions, {
744
+ var priv = privatePool.get(this);
745
+ priv.tempEditorDimensions = {
895
746
  width: (0, _element.outerWidth)(event.target),
896
747
  height: (0, _element.outerHeight)(event.target)
897
- });
748
+ };
898
749
  }
899
750
 
900
751
  /**
@@ -906,9 +757,10 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
906
757
  }, {
907
758
  key: "onEditorMouseUp",
908
759
  value: function onEditorMouseUp(event) {
760
+ var priv = privatePool.get(this);
909
761
  var currentWidth = (0, _element.outerWidth)(event.target);
910
762
  var currentHeight = (0, _element.outerHeight)(event.target);
911
- if (currentWidth !== _classPrivateFieldGet(this, _tempEditorDimensions).width + 1 || currentHeight !== _classPrivateFieldGet(this, _tempEditorDimensions).height + 2) {
763
+ if (currentWidth !== priv.tempEditorDimensions.width + 1 || currentHeight !== priv.tempEditorDimensions.height + 2) {
912
764
  this.updateCommentMeta(this.range.from.row, this.range.from.col, _defineProperty({}, META_STYLE, {
913
765
  width: currentWidth,
914
766
  height: currentHeight
@@ -917,42 +769,144 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
917
769
  }
918
770
 
919
771
  /**
920
- * Observes the pressed keys and if there is already opened the comment editor prevents open
921
- * the table editor into the fast edit mode.
772
+ * Context Menu's "Add comment" callback. Results in showing the comment editor.
922
773
  *
923
- * @param {Event} event The keydown event.
774
+ * @private
924
775
  */
925
776
  }, {
926
- key: "onAfterDocumentKeyDown",
927
- value: function onAfterDocumentKeyDown(event) {
928
- if (_classPrivateFieldGet(this, _editor).isVisible()) {
929
- (0, _event.stopImmediatePropagation)(event);
930
- }
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.
792
+ *
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();
931
807
  }
932
808
 
933
809
  /**
934
- * Observes the changes in the scroll position if triggered it hides the comment editor.
810
+ * Context Menu's "make comment read-only" callback.
811
+ *
812
+ * @private
935
813
  */
936
814
  }, {
937
- key: "onAfterScroll",
938
- value: function onAfterScroll() {
939
- if (!_classPrivateFieldGet(this, _preventEditorHiding)) {
940
- this.hide();
941
- }
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
+ });
942
826
  }
943
827
 
944
828
  /**
945
829
  * Add Comments plugin options to the Context Menu.
946
830
  *
947
831
  * @private
948
- * @param {object} options The menu options.
832
+ * @param {object} defaultOptions The menu options.
949
833
  */
950
834
  }, {
951
835
  key: "addToContextMenu",
952
- value: function addToContextMenu(options) {
953
- options.items.push({
954
- name: _predefinedItems.SEPARATOR
955
- }, (0, _addEditComment.default)(this), (0, _removeComment.default)(this), (0, _readOnlyComment.default)(this));
836
+ value: function addToContextMenu(defaultOptions) {
837
+ var _this6 = this;
838
+ var isThereAnySelectedCellToProcess = function isThereAnySelectedCellToProcess() {
839
+ var range = _this6.hot.getSelectedRangeLast();
840
+ if (!range) {
841
+ return false;
842
+ }
843
+ if (range.isSingleHeader() || range.highlight.isHeader()) {
844
+ return false;
845
+ }
846
+ return _this6.hot.rowIndexMapper.getRenderableIndexesLength() > 0 && _this6.hot.columnIndexMapper.getRenderableIndexesLength() > 0;
847
+ };
848
+ defaultOptions.items.push({
849
+ name: '---------'
850
+ }, {
851
+ key: 'commentsAddEdit',
852
+ name: function name() {
853
+ if (_this6.checkSelectionCommentsConsistency()) {
854
+ return _this6.hot.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_EDIT_COMMENT);
855
+ }
856
+ return _this6.hot.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ADD_COMMENT);
857
+ },
858
+ callback: function callback() {
859
+ return _this6.onContextMenuAddComment();
860
+ },
861
+ disabled: function disabled() {
862
+ if (!isThereAnySelectedCellToProcess()) {
863
+ return true;
864
+ }
865
+ return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner());
866
+ }
867
+ }, {
868
+ key: 'commentsRemove',
869
+ name: function name() {
870
+ return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_REMOVE_COMMENT);
871
+ },
872
+ callback: function callback() {
873
+ return _this6.onContextMenuRemoveComment();
874
+ },
875
+ disabled: function disabled() {
876
+ if (!isThereAnySelectedCellToProcess()) {
877
+ return true;
878
+ }
879
+ return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner());
880
+ }
881
+ }, {
882
+ key: 'commentsReadOnly',
883
+ name: function name() {
884
+ var _this7 = this;
885
+ var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_READ_ONLY_COMMENT);
886
+ var hasProperty = (0, _utils.checkSelectionConsistency)(this.getSelectedRangeLast(), function (row, col) {
887
+ var readOnlyProperty = _this7.getCellMeta(row, col)[META_COMMENT];
888
+ if (readOnlyProperty) {
889
+ readOnlyProperty = readOnlyProperty[META_READONLY];
890
+ }
891
+ if (readOnlyProperty) {
892
+ return true;
893
+ }
894
+ });
895
+ if (hasProperty) {
896
+ label = (0, _utils.markLabelAsSelected)(label);
897
+ }
898
+ return label;
899
+ },
900
+ callback: function callback() {
901
+ return _this6.onContextMenuMakeReadOnly();
902
+ },
903
+ disabled: function disabled() {
904
+ if (!isThereAnySelectedCellToProcess()) {
905
+ return true;
906
+ }
907
+ return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner()) || !_this6.checkSelectionCommentsConsistency();
908
+ }
909
+ });
956
910
  }
957
911
 
958
912
  /**
@@ -970,29 +924,17 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
970
924
  }
971
925
  }
972
926
 
973
- /**
974
- * Gets the editors input element.
975
- *
976
- * @private
977
- * @returns {HTMLTextAreaElement}
978
- */
979
- }, {
980
- key: "getEditorInputElement",
981
- value: function getEditorInputElement() {
982
- return _classPrivateFieldGet(this, _editor).getInputElement();
983
- }
984
-
985
927
  /**
986
928
  * Destroys the plugin instance.
987
929
  */
988
930
  }, {
989
931
  key: "destroy",
990
932
  value: function destroy() {
991
- if (_classPrivateFieldGet(this, _editor)) {
992
- _classPrivateFieldGet(this, _editor).destroy();
933
+ if (this.editor) {
934
+ this.editor.destroy();
993
935
  }
994
- if (_classPrivateFieldGet(this, _displaySwitch)) {
995
- _classPrivateFieldGet(this, _displaySwitch).destroy();
936
+ if (this.displaySwitch) {
937
+ this.displaySwitch.destroy();
996
938
  }
997
939
  _get(_getPrototypeOf(Comments.prototype), "destroy", this).call(this);
998
940
  }