handsontable 0.0.0-next-deccb4d-20240618 → 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.
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/core.js +22 -24
- package/core.mjs +22 -24
- package/dist/handsontable.css +2 -2
- package/dist/handsontable.full.css +2 -2
- package/dist/handsontable.full.js +814 -653
- package/dist/handsontable.full.min.css +2 -2
- package/dist/handsontable.full.min.js +8 -8
- package/dist/handsontable.js +814 -653
- package/dist/handsontable.min.css +2 -2
- package/dist/handsontable.min.js +9 -9
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/package.json +1 -1
- package/plugins/columnSorting/columnSorting.js +2 -1
- package/plugins/columnSorting/columnSorting.mjs +2 -1
- package/plugins/comments/commentEditor.js +74 -39
- package/plugins/comments/commentEditor.mjs +73 -39
- package/plugins/comments/comments.js +20 -39
- package/plugins/comments/comments.mjs +21 -40
- package/plugins/comments/editorResizeObserver.js +100 -0
- package/plugins/comments/editorResizeObserver.mjs +95 -0
- package/plugins/multiColumnSorting/multiColumnSorting.js +1 -0
- package/plugins/multiColumnSorting/multiColumnSorting.mjs +1 -0
- package/plugins/multiColumnSorting/utils.js +1 -1
- package/plugins/multiColumnSorting/utils.mjs +1 -1
- package/plugins/undoRedo/undoRedo.js +37 -0
- package/plugins/undoRedo/undoRedo.mjs +37 -0
package/helpers/mixed.js
CHANGED
@@ -134,7 +134,7 @@ const domMessages = {
|
|
134
134
|
function _injectProductInfo(key, element) {
|
135
135
|
const hasValidType = !isEmpty(key);
|
136
136
|
const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
|
137
|
-
const hotVersion = "0.0.0-next-
|
137
|
+
const hotVersion = "0.0.0-next-3c01700-20240619";
|
138
138
|
let keyValidityDate;
|
139
139
|
let consoleMessageState = 'invalid';
|
140
140
|
let domMessageState = 'invalid';
|
package/helpers/mixed.mjs
CHANGED
@@ -124,7 +124,7 @@ const domMessages = {
|
|
124
124
|
export function _injectProductInfo(key, element) {
|
125
125
|
const hasValidType = !isEmpty(key);
|
126
126
|
const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
|
127
|
-
const hotVersion = "0.0.0-next-
|
127
|
+
const hotVersion = "0.0.0-next-3c01700-20240619";
|
128
128
|
let keyValidityDate;
|
129
129
|
let consoleMessageState = 'invalid';
|
130
130
|
let domMessageState = 'invalid';
|
package/package.json
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
"url": "https://github.com/handsontable/handsontable/issues"
|
11
11
|
},
|
12
12
|
"author": "Handsoncode <hello@handsontable.com>",
|
13
|
-
"version": "0.0.0-next-
|
13
|
+
"version": "0.0.0-next-3c01700-20240619",
|
14
14
|
"main": "index",
|
15
15
|
"module": "index.mjs",
|
16
16
|
"jsnext:main": "index.mjs",
|
@@ -199,6 +199,7 @@ class ColumnSorting extends _base.BasePlugin {
|
|
199
199
|
if (this.indexesSequenceCache !== null) {
|
200
200
|
this.hot.rowIndexMapper.setIndexesSequence(this.indexesSequenceCache.getValues());
|
201
201
|
this.hot.rowIndexMapper.unregisterMap(this.pluginKey);
|
202
|
+
this.indexesSequenceCache = null;
|
202
203
|
}
|
203
204
|
}, true);
|
204
205
|
this.hot.columnIndexMapper.unregisterMap(`${this.pluginKey}.columnMeta`);
|
@@ -586,8 +587,8 @@ class ColumnSorting extends _base.BasePlugin {
|
|
586
587
|
* @private
|
587
588
|
*/
|
588
589
|
sortByPresetSortStates(sortConfigs) {
|
590
|
+
this.hot.rowIndexMapper.setIndexesSequence(this.indexesSequenceCache.getValues());
|
589
591
|
if (sortConfigs.length === 0) {
|
590
|
-
this.hot.rowIndexMapper.setIndexesSequence(this.indexesSequenceCache.getValues());
|
591
592
|
return;
|
592
593
|
}
|
593
594
|
const indexesWithData = [];
|
@@ -195,6 +195,7 @@ export class ColumnSorting extends BasePlugin {
|
|
195
195
|
if (this.indexesSequenceCache !== null) {
|
196
196
|
this.hot.rowIndexMapper.setIndexesSequence(this.indexesSequenceCache.getValues());
|
197
197
|
this.hot.rowIndexMapper.unregisterMap(this.pluginKey);
|
198
|
+
this.indexesSequenceCache = null;
|
198
199
|
}
|
199
200
|
}, true);
|
200
201
|
this.hot.columnIndexMapper.unregisterMap(`${this.pluginKey}.columnMeta`);
|
@@ -582,8 +583,8 @@ export class ColumnSorting extends BasePlugin {
|
|
582
583
|
* @private
|
583
584
|
*/
|
584
585
|
sortByPresetSortStates(sortConfigs) {
|
586
|
+
this.hot.rowIndexMapper.setIndexesSequence(this.indexesSequenceCache.getValues());
|
585
587
|
if (sortConfigs.length === 0) {
|
586
|
-
this.hot.rowIndexMapper.setIndexesSequence(this.indexesSequenceCache.getValues());
|
587
588
|
return;
|
588
589
|
}
|
589
590
|
const indexesWithData = [];
|
@@ -3,15 +3,28 @@
|
|
3
3
|
exports.__esModule = true;
|
4
4
|
require("core-js/modules/es.error.cause.js");
|
5
5
|
var _element = require("../../helpers/dom/element");
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
var _object = require("../../helpers/object");
|
7
|
+
var _localHooks = _interopRequireDefault(require("../../mixins/localHooks"));
|
8
|
+
var _editorResizeObserver = require("./editorResizeObserver");
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
11
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
12
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
13
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
14
|
+
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"); }
|
9
15
|
/**
|
10
16
|
* Comment editor for the Comments plugin.
|
11
17
|
*
|
12
18
|
* @private
|
13
19
|
* @class CommentEditor
|
14
20
|
*/
|
21
|
+
var _rootDocument = /*#__PURE__*/new WeakMap();
|
22
|
+
var _isRtl = /*#__PURE__*/new WeakMap();
|
23
|
+
var _container = /*#__PURE__*/new WeakMap();
|
24
|
+
var _editor = /*#__PURE__*/new WeakMap();
|
25
|
+
var _editorStyle = /*#__PURE__*/new WeakMap();
|
26
|
+
var _hidden = /*#__PURE__*/new WeakMap();
|
27
|
+
var _resizeObserver = /*#__PURE__*/new WeakMap();
|
15
28
|
class CommentEditor {
|
16
29
|
static get CLASS_EDITOR_CONTAINER() {
|
17
30
|
return 'htCommentsContainer';
|
@@ -27,35 +40,47 @@ class CommentEditor {
|
|
27
40
|
}
|
28
41
|
|
29
42
|
/**
|
30
|
-
* @type {
|
43
|
+
* @type {Document}
|
31
44
|
*/
|
32
45
|
|
33
46
|
constructor(rootDocument, isRtl) {
|
34
|
-
|
47
|
+
var _this = this;
|
48
|
+
_classPrivateFieldInitSpec(this, _rootDocument, void 0);
|
35
49
|
/**
|
36
50
|
* @type {boolean}
|
37
51
|
*/
|
38
|
-
|
52
|
+
_classPrivateFieldInitSpec(this, _isRtl, false);
|
39
53
|
/**
|
40
54
|
* @type {HTMLElement}
|
41
55
|
*/
|
42
|
-
|
56
|
+
_classPrivateFieldInitSpec(this, _container, null);
|
43
57
|
/**
|
44
58
|
* @type {HTMLElement}
|
45
59
|
*/
|
46
|
-
|
60
|
+
_classPrivateFieldInitSpec(this, _editor, void 0);
|
47
61
|
/**
|
48
62
|
* @type {CSSStyleDeclaration}
|
49
63
|
*/
|
50
|
-
|
64
|
+
_classPrivateFieldInitSpec(this, _editorStyle, void 0);
|
51
65
|
/**
|
52
66
|
* @type {boolean}
|
53
67
|
*/
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
this
|
68
|
+
_classPrivateFieldInitSpec(this, _hidden, true);
|
69
|
+
/**
|
70
|
+
* @type {EditorResizeObserver}
|
71
|
+
*/
|
72
|
+
_classPrivateFieldInitSpec(this, _resizeObserver, new _editorResizeObserver.EditorResizeObserver());
|
73
|
+
_classPrivateFieldSet(_rootDocument, this, rootDocument);
|
74
|
+
_classPrivateFieldSet(_isRtl, this, isRtl);
|
75
|
+
_classPrivateFieldSet(_editor, this, this.createEditor());
|
76
|
+
_classPrivateFieldSet(_editorStyle, this, _classPrivateFieldGet(_editor, this).style);
|
77
|
+
_classPrivateFieldGet(_resizeObserver, this).setObservedElement(this.getInputElement());
|
78
|
+
_classPrivateFieldGet(_resizeObserver, this).addLocalHook('resize', function () {
|
79
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
80
|
+
args[_key] = arguments[_key];
|
81
|
+
}
|
82
|
+
return _this.runLocalHooks('resize', ...args);
|
83
|
+
});
|
59
84
|
this.hide();
|
60
85
|
}
|
61
86
|
|
@@ -66,8 +91,8 @@ class CommentEditor {
|
|
66
91
|
* @param {number} y Y position (in pixels).
|
67
92
|
*/
|
68
93
|
setPosition(x, y) {
|
69
|
-
this.
|
70
|
-
this.
|
94
|
+
_classPrivateFieldGet(_editorStyle, this).left = `${x}px`;
|
95
|
+
_classPrivateFieldGet(_editorStyle, this).top = `${y}px`;
|
71
96
|
}
|
72
97
|
|
73
98
|
/**
|
@@ -96,6 +121,13 @@ class CommentEditor {
|
|
96
121
|
};
|
97
122
|
}
|
98
123
|
|
124
|
+
/**
|
125
|
+
* Starts observing the editor size.
|
126
|
+
*/
|
127
|
+
observeSize() {
|
128
|
+
_classPrivateFieldGet(_resizeObserver, this).observe();
|
129
|
+
}
|
130
|
+
|
99
131
|
/**
|
100
132
|
* Reset the editor size to its initial state.
|
101
133
|
*/
|
@@ -119,18 +151,19 @@ class CommentEditor {
|
|
119
151
|
* Show the comments editor.
|
120
152
|
*/
|
121
153
|
show() {
|
122
|
-
this.
|
123
|
-
this
|
154
|
+
_classPrivateFieldGet(_editorStyle, this).display = 'block';
|
155
|
+
_classPrivateFieldSet(_hidden, this, false);
|
124
156
|
}
|
125
157
|
|
126
158
|
/**
|
127
159
|
* Hide the comments editor.
|
128
160
|
*/
|
129
161
|
hide() {
|
130
|
-
|
131
|
-
|
162
|
+
_classPrivateFieldGet(_resizeObserver, this).unobserve();
|
163
|
+
if (!_classPrivateFieldGet(_hidden, this)) {
|
164
|
+
_classPrivateFieldGet(_editorStyle, this).display = 'none';
|
132
165
|
}
|
133
|
-
this
|
166
|
+
_classPrivateFieldSet(_hidden, this, true);
|
134
167
|
}
|
135
168
|
|
136
169
|
/**
|
@@ -139,7 +172,7 @@ class CommentEditor {
|
|
139
172
|
* @returns {boolean}
|
140
173
|
*/
|
141
174
|
isVisible() {
|
142
|
-
return this.
|
175
|
+
return _classPrivateFieldGet(_editorStyle, this).display === 'block';
|
143
176
|
}
|
144
177
|
|
145
178
|
/**
|
@@ -168,7 +201,7 @@ class CommentEditor {
|
|
168
201
|
* @returns {boolean}
|
169
202
|
*/
|
170
203
|
isFocused() {
|
171
|
-
return this.
|
204
|
+
return _classPrivateFieldGet(_rootDocument, this).activeElement === this.getInputElement();
|
172
205
|
}
|
173
206
|
|
174
207
|
/**
|
@@ -184,18 +217,18 @@ class CommentEditor {
|
|
184
217
|
* @returns {HTMLElement}
|
185
218
|
*/
|
186
219
|
createEditor() {
|
187
|
-
const editor = this.
|
188
|
-
const
|
220
|
+
const editor = _classPrivateFieldGet(_rootDocument, this).createElement('div');
|
221
|
+
const textarea = _classPrivateFieldGet(_rootDocument, this).createElement('textarea');
|
189
222
|
editor.style.display = 'none';
|
190
|
-
this
|
191
|
-
this.
|
192
|
-
(0, _element.addClass)(this
|
193
|
-
this.
|
223
|
+
_classPrivateFieldSet(_container, this, _classPrivateFieldGet(_rootDocument, this).createElement('div'));
|
224
|
+
_classPrivateFieldGet(_container, this).setAttribute('dir', _classPrivateFieldGet(_isRtl, this) ? 'rtl' : 'ltr');
|
225
|
+
(0, _element.addClass)(_classPrivateFieldGet(_container, this), CommentEditor.CLASS_EDITOR_CONTAINER);
|
226
|
+
_classPrivateFieldGet(_rootDocument, this).body.appendChild(_classPrivateFieldGet(_container, this));
|
194
227
|
(0, _element.addClass)(editor, CommentEditor.CLASS_EDITOR);
|
195
|
-
(0, _element.addClass)(
|
196
|
-
|
197
|
-
editor.appendChild(
|
198
|
-
this.
|
228
|
+
(0, _element.addClass)(textarea, CommentEditor.CLASS_INPUT);
|
229
|
+
textarea.setAttribute('data-hot-input', true);
|
230
|
+
editor.appendChild(textarea);
|
231
|
+
_classPrivateFieldGet(_container, this).appendChild(editor);
|
199
232
|
return editor;
|
200
233
|
}
|
201
234
|
|
@@ -205,20 +238,22 @@ class CommentEditor {
|
|
205
238
|
* @returns {HTMLElement}
|
206
239
|
*/
|
207
240
|
getInputElement() {
|
208
|
-
return this.
|
241
|
+
return _classPrivateFieldGet(_editor, this).querySelector(`.${CommentEditor.CLASS_INPUT}`);
|
209
242
|
}
|
210
243
|
|
211
244
|
/**
|
212
245
|
* Destroy the comments editor.
|
213
246
|
*/
|
214
247
|
destroy() {
|
215
|
-
const containerParentElement = this
|
216
|
-
this.
|
217
|
-
this
|
218
|
-
this
|
248
|
+
const containerParentElement = _classPrivateFieldGet(_container, this) ? _classPrivateFieldGet(_container, this).parentNode : null;
|
249
|
+
_classPrivateFieldGet(_editor, this).parentNode.removeChild(_classPrivateFieldGet(_editor, this));
|
250
|
+
_classPrivateFieldSet(_editor, this, null);
|
251
|
+
_classPrivateFieldSet(_editorStyle, this, null);
|
252
|
+
_classPrivateFieldGet(_resizeObserver, this).destroy();
|
219
253
|
if (containerParentElement) {
|
220
|
-
containerParentElement.removeChild(this
|
254
|
+
containerParentElement.removeChild(_classPrivateFieldGet(_container, this));
|
221
255
|
}
|
222
256
|
}
|
223
257
|
}
|
258
|
+
(0, _object.mixin)(CommentEditor, _localHooks.default);
|
224
259
|
var _default = exports.default = CommentEditor;
|
@@ -1,14 +1,26 @@
|
|
1
1
|
import "core-js/modules/es.error.cause.js";
|
2
|
-
function
|
3
|
-
function
|
4
|
-
function
|
2
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
3
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
4
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
5
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
6
|
+
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"); }
|
5
7
|
import { addClass, outerWidth, outerHeight } from "../../helpers/dom/element.mjs";
|
8
|
+
import { mixin } from "../../helpers/object.mjs";
|
9
|
+
import localHooks from "../../mixins/localHooks.mjs";
|
10
|
+
import { EditorResizeObserver } from "./editorResizeObserver.mjs";
|
6
11
|
/**
|
7
12
|
* Comment editor for the Comments plugin.
|
8
13
|
*
|
9
14
|
* @private
|
10
15
|
* @class CommentEditor
|
11
16
|
*/
|
17
|
+
var _rootDocument = /*#__PURE__*/new WeakMap();
|
18
|
+
var _isRtl = /*#__PURE__*/new WeakMap();
|
19
|
+
var _container = /*#__PURE__*/new WeakMap();
|
20
|
+
var _editor = /*#__PURE__*/new WeakMap();
|
21
|
+
var _editorStyle = /*#__PURE__*/new WeakMap();
|
22
|
+
var _hidden = /*#__PURE__*/new WeakMap();
|
23
|
+
var _resizeObserver = /*#__PURE__*/new WeakMap();
|
12
24
|
class CommentEditor {
|
13
25
|
static get CLASS_EDITOR_CONTAINER() {
|
14
26
|
return 'htCommentsContainer';
|
@@ -24,35 +36,47 @@ class CommentEditor {
|
|
24
36
|
}
|
25
37
|
|
26
38
|
/**
|
27
|
-
* @type {
|
39
|
+
* @type {Document}
|
28
40
|
*/
|
29
41
|
|
30
42
|
constructor(rootDocument, isRtl) {
|
31
|
-
|
43
|
+
var _this = this;
|
44
|
+
_classPrivateFieldInitSpec(this, _rootDocument, void 0);
|
32
45
|
/**
|
33
46
|
* @type {boolean}
|
34
47
|
*/
|
35
|
-
|
48
|
+
_classPrivateFieldInitSpec(this, _isRtl, false);
|
36
49
|
/**
|
37
50
|
* @type {HTMLElement}
|
38
51
|
*/
|
39
|
-
|
52
|
+
_classPrivateFieldInitSpec(this, _container, null);
|
40
53
|
/**
|
41
54
|
* @type {HTMLElement}
|
42
55
|
*/
|
43
|
-
|
56
|
+
_classPrivateFieldInitSpec(this, _editor, void 0);
|
44
57
|
/**
|
45
58
|
* @type {CSSStyleDeclaration}
|
46
59
|
*/
|
47
|
-
|
60
|
+
_classPrivateFieldInitSpec(this, _editorStyle, void 0);
|
48
61
|
/**
|
49
62
|
* @type {boolean}
|
50
63
|
*/
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
this
|
64
|
+
_classPrivateFieldInitSpec(this, _hidden, true);
|
65
|
+
/**
|
66
|
+
* @type {EditorResizeObserver}
|
67
|
+
*/
|
68
|
+
_classPrivateFieldInitSpec(this, _resizeObserver, new EditorResizeObserver());
|
69
|
+
_classPrivateFieldSet(_rootDocument, this, rootDocument);
|
70
|
+
_classPrivateFieldSet(_isRtl, this, isRtl);
|
71
|
+
_classPrivateFieldSet(_editor, this, this.createEditor());
|
72
|
+
_classPrivateFieldSet(_editorStyle, this, _classPrivateFieldGet(_editor, this).style);
|
73
|
+
_classPrivateFieldGet(_resizeObserver, this).setObservedElement(this.getInputElement());
|
74
|
+
_classPrivateFieldGet(_resizeObserver, this).addLocalHook('resize', function () {
|
75
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
76
|
+
args[_key] = arguments[_key];
|
77
|
+
}
|
78
|
+
return _this.runLocalHooks('resize', ...args);
|
79
|
+
});
|
56
80
|
this.hide();
|
57
81
|
}
|
58
82
|
|
@@ -63,8 +87,8 @@ class CommentEditor {
|
|
63
87
|
* @param {number} y Y position (in pixels).
|
64
88
|
*/
|
65
89
|
setPosition(x, y) {
|
66
|
-
this.
|
67
|
-
this.
|
90
|
+
_classPrivateFieldGet(_editorStyle, this).left = `${x}px`;
|
91
|
+
_classPrivateFieldGet(_editorStyle, this).top = `${y}px`;
|
68
92
|
}
|
69
93
|
|
70
94
|
/**
|
@@ -93,6 +117,13 @@ class CommentEditor {
|
|
93
117
|
};
|
94
118
|
}
|
95
119
|
|
120
|
+
/**
|
121
|
+
* Starts observing the editor size.
|
122
|
+
*/
|
123
|
+
observeSize() {
|
124
|
+
_classPrivateFieldGet(_resizeObserver, this).observe();
|
125
|
+
}
|
126
|
+
|
96
127
|
/**
|
97
128
|
* Reset the editor size to its initial state.
|
98
129
|
*/
|
@@ -116,18 +147,19 @@ class CommentEditor {
|
|
116
147
|
* Show the comments editor.
|
117
148
|
*/
|
118
149
|
show() {
|
119
|
-
this.
|
120
|
-
this
|
150
|
+
_classPrivateFieldGet(_editorStyle, this).display = 'block';
|
151
|
+
_classPrivateFieldSet(_hidden, this, false);
|
121
152
|
}
|
122
153
|
|
123
154
|
/**
|
124
155
|
* Hide the comments editor.
|
125
156
|
*/
|
126
157
|
hide() {
|
127
|
-
|
128
|
-
|
158
|
+
_classPrivateFieldGet(_resizeObserver, this).unobserve();
|
159
|
+
if (!_classPrivateFieldGet(_hidden, this)) {
|
160
|
+
_classPrivateFieldGet(_editorStyle, this).display = 'none';
|
129
161
|
}
|
130
|
-
this
|
162
|
+
_classPrivateFieldSet(_hidden, this, true);
|
131
163
|
}
|
132
164
|
|
133
165
|
/**
|
@@ -136,7 +168,7 @@ class CommentEditor {
|
|
136
168
|
* @returns {boolean}
|
137
169
|
*/
|
138
170
|
isVisible() {
|
139
|
-
return this.
|
171
|
+
return _classPrivateFieldGet(_editorStyle, this).display === 'block';
|
140
172
|
}
|
141
173
|
|
142
174
|
/**
|
@@ -165,7 +197,7 @@ class CommentEditor {
|
|
165
197
|
* @returns {boolean}
|
166
198
|
*/
|
167
199
|
isFocused() {
|
168
|
-
return this.
|
200
|
+
return _classPrivateFieldGet(_rootDocument, this).activeElement === this.getInputElement();
|
169
201
|
}
|
170
202
|
|
171
203
|
/**
|
@@ -181,18 +213,18 @@ class CommentEditor {
|
|
181
213
|
* @returns {HTMLElement}
|
182
214
|
*/
|
183
215
|
createEditor() {
|
184
|
-
const editor = this.
|
185
|
-
const
|
216
|
+
const editor = _classPrivateFieldGet(_rootDocument, this).createElement('div');
|
217
|
+
const textarea = _classPrivateFieldGet(_rootDocument, this).createElement('textarea');
|
186
218
|
editor.style.display = 'none';
|
187
|
-
this
|
188
|
-
this.
|
189
|
-
addClass(this
|
190
|
-
this.
|
219
|
+
_classPrivateFieldSet(_container, this, _classPrivateFieldGet(_rootDocument, this).createElement('div'));
|
220
|
+
_classPrivateFieldGet(_container, this).setAttribute('dir', _classPrivateFieldGet(_isRtl, this) ? 'rtl' : 'ltr');
|
221
|
+
addClass(_classPrivateFieldGet(_container, this), CommentEditor.CLASS_EDITOR_CONTAINER);
|
222
|
+
_classPrivateFieldGet(_rootDocument, this).body.appendChild(_classPrivateFieldGet(_container, this));
|
191
223
|
addClass(editor, CommentEditor.CLASS_EDITOR);
|
192
|
-
addClass(
|
193
|
-
|
194
|
-
editor.appendChild(
|
195
|
-
this.
|
224
|
+
addClass(textarea, CommentEditor.CLASS_INPUT);
|
225
|
+
textarea.setAttribute('data-hot-input', true);
|
226
|
+
editor.appendChild(textarea);
|
227
|
+
_classPrivateFieldGet(_container, this).appendChild(editor);
|
196
228
|
return editor;
|
197
229
|
}
|
198
230
|
|
@@ -202,20 +234,22 @@ class CommentEditor {
|
|
202
234
|
* @returns {HTMLElement}
|
203
235
|
*/
|
204
236
|
getInputElement() {
|
205
|
-
return this.
|
237
|
+
return _classPrivateFieldGet(_editor, this).querySelector(`.${CommentEditor.CLASS_INPUT}`);
|
206
238
|
}
|
207
239
|
|
208
240
|
/**
|
209
241
|
* Destroy the comments editor.
|
210
242
|
*/
|
211
243
|
destroy() {
|
212
|
-
const containerParentElement = this
|
213
|
-
this.
|
214
|
-
this
|
215
|
-
this
|
244
|
+
const containerParentElement = _classPrivateFieldGet(_container, this) ? _classPrivateFieldGet(_container, this).parentNode : null;
|
245
|
+
_classPrivateFieldGet(_editor, this).parentNode.removeChild(_classPrivateFieldGet(_editor, this));
|
246
|
+
_classPrivateFieldSet(_editor, this, null);
|
247
|
+
_classPrivateFieldSet(_editorStyle, this, null);
|
248
|
+
_classPrivateFieldGet(_resizeObserver, this).destroy();
|
216
249
|
if (containerParentElement) {
|
217
|
-
containerParentElement.removeChild(this
|
250
|
+
containerParentElement.removeChild(_classPrivateFieldGet(_container, this));
|
218
251
|
}
|
219
252
|
}
|
220
253
|
}
|
254
|
+
mixin(CommentEditor, localHooks);
|
221
255
|
export default CommentEditor;
|
@@ -126,7 +126,6 @@ var _editor = /*#__PURE__*/new WeakMap();
|
|
126
126
|
var _displaySwitch = /*#__PURE__*/new WeakMap();
|
127
127
|
var _preventEditorAutoSwitch = /*#__PURE__*/new WeakMap();
|
128
128
|
var _preventEditorHiding = /*#__PURE__*/new WeakMap();
|
129
|
-
var _tempEditorDimensions = /*#__PURE__*/new WeakMap();
|
130
129
|
var _cellBelowCursor = /*#__PURE__*/new WeakMap();
|
131
130
|
var _commentValueBeforeSave = /*#__PURE__*/new WeakMap();
|
132
131
|
var _Comments_brand = /*#__PURE__*/new WeakSet();
|
@@ -174,13 +173,6 @@ class Comments extends _base.BasePlugin {
|
|
174
173
|
* @type {boolean}
|
175
174
|
*/
|
176
175
|
_classPrivateFieldInitSpec(this, _preventEditorHiding, false);
|
177
|
-
/**
|
178
|
-
* The property for holding editor dimensions for further processing.
|
179
|
-
*
|
180
|
-
* @private
|
181
|
-
* @type {object}
|
182
|
-
*/
|
183
|
-
_classPrivateFieldInitSpec(this, _tempEditorDimensions, {});
|
184
176
|
/**
|
185
177
|
* The flag that allows processing mousedown event correctly when comments editor is triggered.
|
186
178
|
*
|
@@ -216,11 +208,18 @@ class Comments extends _base.BasePlugin {
|
|
216
208
|
* Enables the plugin functionality for this Handsontable instance.
|
217
209
|
*/
|
218
210
|
enablePlugin() {
|
211
|
+
var _this = this;
|
219
212
|
if (this.enabled) {
|
220
213
|
return;
|
221
214
|
}
|
222
215
|
if (!_classPrivateFieldGet(_editor, this)) {
|
223
216
|
_classPrivateFieldSet(_editor, this, new _commentEditor.default(this.hot.rootDocument, this.hot.isRtl()));
|
217
|
+
_classPrivateFieldGet(_editor, this).addLocalHook('resize', function () {
|
218
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
219
|
+
args[_key] = arguments[_key];
|
220
|
+
}
|
221
|
+
return _assertClassBrand(_Comments_brand, _this, _onEditorResize).call(_this, ...args);
|
222
|
+
});
|
224
223
|
}
|
225
224
|
if (!_classPrivateFieldGet(_displaySwitch, this)) {
|
226
225
|
_classPrivateFieldSet(_displaySwitch, this, new _displaySwitch2.default(this.getDisplayDelaySetting()));
|
@@ -332,8 +331,6 @@ class Comments extends _base.BasePlugin {
|
|
332
331
|
this.eventManager.addEventListener(rootDocument, 'mouseup', () => _assertClassBrand(_Comments_brand, this, _onMouseUp).call(this));
|
333
332
|
this.eventManager.addEventListener(editorElement, 'focus', () => _assertClassBrand(_Comments_brand, this, _onEditorFocus).call(this));
|
334
333
|
this.eventManager.addEventListener(editorElement, 'blur', () => _assertClassBrand(_Comments_brand, this, _onEditorBlur).call(this));
|
335
|
-
this.eventManager.addEventListener(editorElement, 'mousedown', event => _assertClassBrand(_Comments_brand, this, _onEditorMouseDown).call(this, event));
|
336
|
-
this.eventManager.addEventListener(editorElement, 'mouseup', event => _assertClassBrand(_Comments_brand, this, _onEditorMouseUp).call(this, event));
|
337
334
|
}
|
338
335
|
|
339
336
|
/**
|
@@ -607,6 +604,7 @@ class Comments extends _base.BasePlugin {
|
|
607
604
|
}
|
608
605
|
_classPrivateFieldGet(_editor, this).setPosition(x, y);
|
609
606
|
_classPrivateFieldGet(_editor, this).setReadOnlyState(this.getCommentMeta(visualRow, visualColumn, META_READONLY));
|
607
|
+
_classPrivateFieldGet(_editor, this).observeSize();
|
610
608
|
}
|
611
609
|
|
612
610
|
/**
|
@@ -689,12 +687,9 @@ class Comments extends _base.BasePlugin {
|
|
689
687
|
* Destroys the plugin instance.
|
690
688
|
*/
|
691
689
|
destroy() {
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
if (_classPrivateFieldGet(_displaySwitch, this)) {
|
696
|
-
_classPrivateFieldGet(_displaySwitch, this).destroy();
|
697
|
-
}
|
690
|
+
var _classPrivateFieldGet2, _classPrivateFieldGet3;
|
691
|
+
(_classPrivateFieldGet2 = _classPrivateFieldGet(_editor, this)) === null || _classPrivateFieldGet2 === void 0 || _classPrivateFieldGet2.destroy();
|
692
|
+
(_classPrivateFieldGet3 = _classPrivateFieldGet(_displaySwitch, this)) === null || _classPrivateFieldGet3 === void 0 || _classPrivateFieldGet3.destroy();
|
698
693
|
super.destroy();
|
699
694
|
}
|
700
695
|
}
|
@@ -770,33 +765,19 @@ function _onEditorFocus() {
|
|
770
765
|
this.hot.getShortcutManager().setActiveContextName(SHORTCUTS_CONTEXT_NAME);
|
771
766
|
}
|
772
767
|
/**
|
773
|
-
*
|
768
|
+
* Saves the comments editor size to the cell meta.
|
774
769
|
*
|
775
|
-
* @param {
|
770
|
+
* @param {number} width The new width of the editor.
|
771
|
+
* @param {number} height The new height of the editor.
|
776
772
|
*/
|
777
|
-
function
|
778
|
-
|
779
|
-
|
780
|
-
|
773
|
+
function _onEditorResize(width, height) {
|
774
|
+
this.updateCommentMeta(this.range.from.row, this.range.from.col, {
|
775
|
+
[META_STYLE]: {
|
776
|
+
width,
|
777
|
+
height
|
778
|
+
}
|
781
779
|
});
|
782
780
|
}
|
783
|
-
/**
|
784
|
-
* `mouseup` hook. Along with `onEditorMouseDown` used to simulate the textarea resizing event.
|
785
|
-
*
|
786
|
-
* @param {MouseEvent} event The `mouseup` event.
|
787
|
-
*/
|
788
|
-
function _onEditorMouseUp(event) {
|
789
|
-
const currentWidth = (0, _element.outerWidth)(event.target);
|
790
|
-
const currentHeight = (0, _element.outerHeight)(event.target);
|
791
|
-
if (currentWidth !== _classPrivateFieldGet(_tempEditorDimensions, this).width + 1 || currentHeight !== _classPrivateFieldGet(_tempEditorDimensions, this).height + 2) {
|
792
|
-
this.updateCommentMeta(this.range.from.row, this.range.from.col, {
|
793
|
-
[META_STYLE]: {
|
794
|
-
width: currentWidth,
|
795
|
-
height: currentHeight
|
796
|
-
}
|
797
|
-
});
|
798
|
-
}
|
799
|
-
}
|
800
781
|
/**
|
801
782
|
* Observes the pressed keys and if there is already opened the comment editor prevents open
|
802
783
|
* the table editor into the fast edit mode.
|