handsontable 0.0.0-next-fcd6191-20240619 → 0.0.0-next-3c01700-20240619

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.

@@ -9,7 +9,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
9
9
  function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
10
10
  function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
11
11
  function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
12
- import { addClass, closest, isChildOf, hasClass, outerWidth, outerHeight } from "../../helpers/dom/element.mjs";
12
+ import { addClass, closest, isChildOf, hasClass, outerHeight } from "../../helpers/dom/element.mjs";
13
13
  import { stopImmediatePropagation } from "../../helpers/dom/event.mjs";
14
14
  import { deepClone, deepExtend, isObject } from "../../helpers/object.mjs";
15
15
  import { BasePlugin } from "../base/index.mjs";
@@ -122,7 +122,6 @@ var _editor = /*#__PURE__*/new WeakMap();
122
122
  var _displaySwitch = /*#__PURE__*/new WeakMap();
123
123
  var _preventEditorAutoSwitch = /*#__PURE__*/new WeakMap();
124
124
  var _preventEditorHiding = /*#__PURE__*/new WeakMap();
125
- var _tempEditorDimensions = /*#__PURE__*/new WeakMap();
126
125
  var _cellBelowCursor = /*#__PURE__*/new WeakMap();
127
126
  var _commentValueBeforeSave = /*#__PURE__*/new WeakMap();
128
127
  var _Comments_brand = /*#__PURE__*/new WeakSet();
@@ -170,13 +169,6 @@ export class Comments extends BasePlugin {
170
169
  * @type {boolean}
171
170
  */
172
171
  _classPrivateFieldInitSpec(this, _preventEditorHiding, false);
173
- /**
174
- * The property for holding editor dimensions for further processing.
175
- *
176
- * @private
177
- * @type {object}
178
- */
179
- _classPrivateFieldInitSpec(this, _tempEditorDimensions, {});
180
172
  /**
181
173
  * The flag that allows processing mousedown event correctly when comments editor is triggered.
182
174
  *
@@ -212,11 +204,18 @@ export class Comments extends BasePlugin {
212
204
  * Enables the plugin functionality for this Handsontable instance.
213
205
  */
214
206
  enablePlugin() {
207
+ var _this = this;
215
208
  if (this.enabled) {
216
209
  return;
217
210
  }
218
211
  if (!_classPrivateFieldGet(_editor, this)) {
219
212
  _classPrivateFieldSet(_editor, this, new CommentEditor(this.hot.rootDocument, this.hot.isRtl()));
213
+ _classPrivateFieldGet(_editor, this).addLocalHook('resize', function () {
214
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
215
+ args[_key] = arguments[_key];
216
+ }
217
+ return _assertClassBrand(_Comments_brand, _this, _onEditorResize).call(_this, ...args);
218
+ });
220
219
  }
221
220
  if (!_classPrivateFieldGet(_displaySwitch, this)) {
222
221
  _classPrivateFieldSet(_displaySwitch, this, new DisplaySwitch(this.getDisplayDelaySetting()));
@@ -328,8 +327,6 @@ export class Comments extends BasePlugin {
328
327
  this.eventManager.addEventListener(rootDocument, 'mouseup', () => _assertClassBrand(_Comments_brand, this, _onMouseUp).call(this));
329
328
  this.eventManager.addEventListener(editorElement, 'focus', () => _assertClassBrand(_Comments_brand, this, _onEditorFocus).call(this));
330
329
  this.eventManager.addEventListener(editorElement, 'blur', () => _assertClassBrand(_Comments_brand, this, _onEditorBlur).call(this));
331
- this.eventManager.addEventListener(editorElement, 'mousedown', event => _assertClassBrand(_Comments_brand, this, _onEditorMouseDown).call(this, event));
332
- this.eventManager.addEventListener(editorElement, 'mouseup', event => _assertClassBrand(_Comments_brand, this, _onEditorMouseUp).call(this, event));
333
330
  }
334
331
 
335
332
  /**
@@ -603,6 +600,7 @@ export class Comments extends BasePlugin {
603
600
  }
604
601
  _classPrivateFieldGet(_editor, this).setPosition(x, y);
605
602
  _classPrivateFieldGet(_editor, this).setReadOnlyState(this.getCommentMeta(visualRow, visualColumn, META_READONLY));
603
+ _classPrivateFieldGet(_editor, this).observeSize();
606
604
  }
607
605
 
608
606
  /**
@@ -685,12 +683,9 @@ export class Comments extends BasePlugin {
685
683
  * Destroys the plugin instance.
686
684
  */
687
685
  destroy() {
688
- if (_classPrivateFieldGet(_editor, this)) {
689
- _classPrivateFieldGet(_editor, this).destroy();
690
- }
691
- if (_classPrivateFieldGet(_displaySwitch, this)) {
692
- _classPrivateFieldGet(_displaySwitch, this).destroy();
693
- }
686
+ var _classPrivateFieldGet2, _classPrivateFieldGet3;
687
+ (_classPrivateFieldGet2 = _classPrivateFieldGet(_editor, this)) === null || _classPrivateFieldGet2 === void 0 || _classPrivateFieldGet2.destroy();
688
+ (_classPrivateFieldGet3 = _classPrivateFieldGet(_displaySwitch, this)) === null || _classPrivateFieldGet3 === void 0 || _classPrivateFieldGet3.destroy();
694
689
  super.destroy();
695
690
  }
696
691
  }
@@ -765,33 +760,19 @@ function _onEditorFocus() {
765
760
  this.hot.getShortcutManager().setActiveContextName(SHORTCUTS_CONTEXT_NAME);
766
761
  }
767
762
  /**
768
- * `mousedown` hook. Along with `onEditorMouseUp` used to simulate the textarea resizing event.
763
+ * Saves the comments editor size to the cell meta.
769
764
  *
770
- * @param {MouseEvent} event The `mousedown` event.
765
+ * @param {number} width The new width of the editor.
766
+ * @param {number} height The new height of the editor.
771
767
  */
772
- function _onEditorMouseDown(event) {
773
- _classPrivateFieldSet(_tempEditorDimensions, this, {
774
- width: outerWidth(event.target),
775
- height: outerHeight(event.target)
768
+ function _onEditorResize(width, height) {
769
+ this.updateCommentMeta(this.range.from.row, this.range.from.col, {
770
+ [META_STYLE]: {
771
+ width,
772
+ height
773
+ }
776
774
  });
777
775
  }
778
- /**
779
- * `mouseup` hook. Along with `onEditorMouseDown` used to simulate the textarea resizing event.
780
- *
781
- * @param {MouseEvent} event The `mouseup` event.
782
- */
783
- function _onEditorMouseUp(event) {
784
- const currentWidth = outerWidth(event.target);
785
- const currentHeight = outerHeight(event.target);
786
- if (currentWidth !== _classPrivateFieldGet(_tempEditorDimensions, this).width + 1 || currentHeight !== _classPrivateFieldGet(_tempEditorDimensions, this).height + 2) {
787
- this.updateCommentMeta(this.range.from.row, this.range.from.col, {
788
- [META_STYLE]: {
789
- width: currentWidth,
790
- height: currentHeight
791
- }
792
- });
793
- }
794
- }
795
776
  /**
796
777
  * Observes the pressed keys and if there is already opened the comment editor prevents open
797
778
  * the table editor into the fast edit mode.
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ require("core-js/modules/es.error.cause.js");
5
+ var _object = require("../../helpers/object");
6
+ var _localHooks = _interopRequireDefault(require("../../mixins/localHooks"));
7
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+ function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
9
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
10
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
11
+ function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
12
+ function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
13
+ function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
14
+ /**
15
+ * Module that observes the editor size after it has been resized by the user.
16
+ *
17
+ * @private
18
+ * @class EditorResizeObserver
19
+ */
20
+ var _ignoreInitialCall = /*#__PURE__*/new WeakMap();
21
+ var _observedElement = /*#__PURE__*/new WeakMap();
22
+ var _observer = /*#__PURE__*/new WeakMap();
23
+ var _EditorResizeObserver_brand = /*#__PURE__*/new WeakSet();
24
+ class EditorResizeObserver {
25
+ constructor() {
26
+ /**
27
+ * Listens for event from the ResizeObserver and forwards the through the local hooks.
28
+ *
29
+ * @param {*} entries The entries from the ResizeObserver.
30
+ */
31
+ _classPrivateMethodInitSpec(this, _EditorResizeObserver_brand);
32
+ /**
33
+ * The flag that indicates if the initial call should be ignored. It is used to prevent the initial call
34
+ * that happens after the observer is attached to the element.
35
+ *
36
+ * @type {boolean}
37
+ */
38
+ _classPrivateFieldInitSpec(this, _ignoreInitialCall, true);
39
+ /**
40
+ * The element that is observed by the observer.
41
+ *
42
+ * @type {HTMLElement}
43
+ */
44
+ _classPrivateFieldInitSpec(this, _observedElement, null);
45
+ /**
46
+ * The ResizeObserver instance.
47
+ *
48
+ * @type {ResizeObserver}
49
+ */
50
+ _classPrivateFieldInitSpec(this, _observer, new ResizeObserver(entries => _assertClassBrand(_EditorResizeObserver_brand, this, _onResize).call(this, entries)));
51
+ }
52
+ /**
53
+ * Sets the observed element.
54
+ *
55
+ * @param {HTMLElement} element The element to observe.
56
+ */
57
+ setObservedElement(element) {
58
+ _classPrivateFieldSet(_observedElement, this, element);
59
+ }
60
+
61
+ /**
62
+ * Stops observing the element.
63
+ */
64
+ unobserve() {
65
+ _classPrivateFieldGet(_observer, this).unobserve(_classPrivateFieldGet(_observedElement, this));
66
+ }
67
+
68
+ /**
69
+ * Starts observing the element.
70
+ */
71
+ observe() {
72
+ _classPrivateFieldSet(_ignoreInitialCall, this, true);
73
+ _classPrivateFieldGet(_observer, this).observe(_classPrivateFieldGet(_observedElement, this));
74
+ }
75
+
76
+ /**
77
+ * Destroys the observer.
78
+ */
79
+ destroy() {
80
+ _classPrivateFieldGet(_observer, this).disconnect();
81
+ }
82
+ }
83
+ exports.EditorResizeObserver = EditorResizeObserver;
84
+ function _onResize(entries) {
85
+ if (_classPrivateFieldGet(_ignoreInitialCall, this) || !Array.isArray(entries) || !entries.length) {
86
+ _classPrivateFieldSet(_ignoreInitialCall, this, false);
87
+ return;
88
+ }
89
+ entries.forEach(_ref => {
90
+ let {
91
+ borderBoxSize
92
+ } = _ref;
93
+ const {
94
+ inlineSize,
95
+ blockSize
96
+ } = borderBoxSize[0];
97
+ this.runLocalHooks('resize', inlineSize, blockSize);
98
+ });
99
+ }
100
+ (0, _object.mixin)(EditorResizeObserver, _localHooks.default);
@@ -0,0 +1,95 @@
1
+ import "core-js/modules/es.error.cause.js";
2
+ function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
3
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
4
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
5
+ function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
6
+ function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
7
+ function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
8
+ import { mixin } from "../../helpers/object.mjs";
9
+ import localHooks from "../../mixins/localHooks.mjs";
10
+ /**
11
+ * Module that observes the editor size after it has been resized by the user.
12
+ *
13
+ * @private
14
+ * @class EditorResizeObserver
15
+ */
16
+ var _ignoreInitialCall = /*#__PURE__*/new WeakMap();
17
+ var _observedElement = /*#__PURE__*/new WeakMap();
18
+ var _observer = /*#__PURE__*/new WeakMap();
19
+ var _EditorResizeObserver_brand = /*#__PURE__*/new WeakSet();
20
+ export class EditorResizeObserver {
21
+ constructor() {
22
+ /**
23
+ * Listens for event from the ResizeObserver and forwards the through the local hooks.
24
+ *
25
+ * @param {*} entries The entries from the ResizeObserver.
26
+ */
27
+ _classPrivateMethodInitSpec(this, _EditorResizeObserver_brand);
28
+ /**
29
+ * The flag that indicates if the initial call should be ignored. It is used to prevent the initial call
30
+ * that happens after the observer is attached to the element.
31
+ *
32
+ * @type {boolean}
33
+ */
34
+ _classPrivateFieldInitSpec(this, _ignoreInitialCall, true);
35
+ /**
36
+ * The element that is observed by the observer.
37
+ *
38
+ * @type {HTMLElement}
39
+ */
40
+ _classPrivateFieldInitSpec(this, _observedElement, null);
41
+ /**
42
+ * The ResizeObserver instance.
43
+ *
44
+ * @type {ResizeObserver}
45
+ */
46
+ _classPrivateFieldInitSpec(this, _observer, new ResizeObserver(entries => _assertClassBrand(_EditorResizeObserver_brand, this, _onResize).call(this, entries)));
47
+ }
48
+ /**
49
+ * Sets the observed element.
50
+ *
51
+ * @param {HTMLElement} element The element to observe.
52
+ */
53
+ setObservedElement(element) {
54
+ _classPrivateFieldSet(_observedElement, this, element);
55
+ }
56
+
57
+ /**
58
+ * Stops observing the element.
59
+ */
60
+ unobserve() {
61
+ _classPrivateFieldGet(_observer, this).unobserve(_classPrivateFieldGet(_observedElement, this));
62
+ }
63
+
64
+ /**
65
+ * Starts observing the element.
66
+ */
67
+ observe() {
68
+ _classPrivateFieldSet(_ignoreInitialCall, this, true);
69
+ _classPrivateFieldGet(_observer, this).observe(_classPrivateFieldGet(_observedElement, this));
70
+ }
71
+
72
+ /**
73
+ * Destroys the observer.
74
+ */
75
+ destroy() {
76
+ _classPrivateFieldGet(_observer, this).disconnect();
77
+ }
78
+ }
79
+ function _onResize(entries) {
80
+ if (_classPrivateFieldGet(_ignoreInitialCall, this) || !Array.isArray(entries) || !entries.length) {
81
+ _classPrivateFieldSet(_ignoreInitialCall, this, false);
82
+ return;
83
+ }
84
+ entries.forEach(_ref => {
85
+ let {
86
+ borderBoxSize
87
+ } = _ref;
88
+ const {
89
+ inlineSize,
90
+ blockSize
91
+ } = borderBoxSize[0];
92
+ this.runLocalHooks('resize', inlineSize, blockSize);
93
+ });
94
+ }
95
+ mixin(EditorResizeObserver, localHooks);