handsontable 0.0.0-next-c3d199b-20230626 → 0.0.0-next-74a68c1-20230627
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/CHANGELOG.md +31 -0
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/dist/handsontable.css +2 -2
- package/dist/handsontable.full.css +2 -2
- package/dist/handsontable.full.js +3347 -3475
- package/dist/handsontable.full.min.css +2 -2
- package/dist/handsontable.full.min.js +53 -53
- package/dist/handsontable.js +5524 -5652
- package/dist/handsontable.min.css +2 -2
- package/dist/handsontable.min.js +4 -4
- package/helpers/mixed.js +2 -2
- package/helpers/mixed.mjs +2 -2
- package/package.json +1 -1
- package/plugins/comments/commentEditor.js +0 -1
- package/plugins/comments/commentEditor.mjs +0 -1
- package/plugins/comments/comments.js +231 -263
- package/plugins/comments/comments.mjs +241 -271
- package/plugins/copyPaste/copyPaste.js +1 -1
- package/plugins/copyPaste/copyPaste.mjs +1 -1
- package/plugins/filters/filters.js +62 -42
- package/plugins/filters/filters.mjs +61 -41
- package/shortcutContexts/commands/index.js +2 -1
- package/shortcutContexts/commands/index.mjs +2 -1
- package/shortcutContexts/commands/scrollToFocusedCell.js +38 -0
- package/shortcutContexts/commands/scrollToFocusedCell.mjs +33 -0
- package/shortcutContexts/grid.js +5 -0
- package/shortcutContexts/grid.mjs +5 -0
- package/tableView.js +2 -5
- package/tableView.mjs +2 -5
- package/translations/indexMapper.d.ts +0 -2
- package/plugins/comments/contextMenuItem/addEditComment.js +0 -51
- package/plugins/comments/contextMenuItem/addEditComment.mjs +0 -35
- package/plugins/comments/contextMenuItem/readOnlyComment.js +0 -63
- package/plugins/comments/contextMenuItem/readOnlyComment.mjs +0 -55
- package/plugins/comments/contextMenuItem/removeComment.js +0 -48
- package/plugins/comments/contextMenuItem/removeComment.mjs +0 -32
@@ -1,40 +1,41 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
|
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.
|
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
|
30
|
-
var
|
31
|
-
var
|
32
|
-
var
|
33
|
-
var
|
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,107 +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 _tempEditorDimensions = /*#__PURE__*/new WeakMap();
|
166
|
-
var _cellBelowCursor = /*#__PURE__*/new WeakMap();
|
167
|
-
var _commentValueBeforeSave = /*#__PURE__*/new WeakMap();
|
168
148
|
var Comments = /*#__PURE__*/function (_BasePlugin) {
|
169
149
|
_inherits(Comments, _BasePlugin);
|
170
150
|
var _super = _createSuper(Comments);
|
171
|
-
function Comments() {
|
151
|
+
function Comments(hotInstance) {
|
172
152
|
var _this;
|
173
153
|
_classCallCheck(this, Comments);
|
174
|
-
|
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);
|
154
|
+
_this = _super.call(this, hotInstance);
|
191
155
|
/**
|
192
156
|
* Instance of {@link CommentEditor}.
|
193
157
|
*
|
194
158
|
* @private
|
195
159
|
* @type {CommentEditor}
|
196
160
|
*/
|
197
|
-
|
198
|
-
writable: true,
|
199
|
-
value: null
|
200
|
-
});
|
161
|
+
_this.editor = null;
|
201
162
|
/**
|
202
163
|
* Instance of {@link DisplaySwitch}.
|
203
164
|
*
|
204
165
|
* @private
|
205
166
|
* @type {DisplaySwitch}
|
206
167
|
*/
|
207
|
-
|
208
|
-
writable: true,
|
209
|
-
value: null
|
210
|
-
});
|
168
|
+
_this.displaySwitch = null;
|
211
169
|
/**
|
212
|
-
*
|
170
|
+
* Instance of {@link EventManager}.
|
213
171
|
*
|
214
172
|
* @private
|
215
|
-
* @type {
|
173
|
+
* @type {EventManager}
|
216
174
|
*/
|
217
|
-
|
218
|
-
writable: true,
|
219
|
-
value: false
|
220
|
-
});
|
175
|
+
_this.eventManager = null;
|
221
176
|
/**
|
222
|
-
*
|
177
|
+
* Current cell range, an object with `from` property, with `row` and `col` properties (e.q. `{from: {row: 1, col: 6}}`).
|
223
178
|
*
|
224
|
-
* @private
|
225
179
|
* @type {object}
|
226
180
|
*/
|
227
|
-
|
228
|
-
writable: true,
|
229
|
-
value: {}
|
230
|
-
});
|
181
|
+
_this.range = {};
|
231
182
|
/**
|
232
|
-
*
|
183
|
+
* Prevents showing/hiding editor that reacts on the logic triggered by the "mouseover" events.
|
233
184
|
*
|
234
185
|
* @private
|
235
186
|
* @type {boolean}
|
236
187
|
*/
|
237
|
-
|
238
|
-
|
239
|
-
|
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: ''
|
188
|
+
_this.preventEditorAutoSwitch = false;
|
189
|
+
privatePool.set(_assertThisInitialized(_this), {
|
190
|
+
tempEditorDimensions: {},
|
191
|
+
cellBelowCursor: null
|
250
192
|
});
|
251
193
|
return _this;
|
252
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
|
+
*/
|
253
202
|
_createClass(Comments, [{
|
254
203
|
key: "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() {
|
204
|
+
value: function isEnabled() {
|
263
205
|
return !!this.hot.getSettings()[PLUGIN_KEY];
|
264
206
|
}
|
265
207
|
|
@@ -273,14 +215,14 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
273
215
|
if (this.enabled) {
|
274
216
|
return;
|
275
217
|
}
|
276
|
-
if (!
|
277
|
-
|
218
|
+
if (!this.editor) {
|
219
|
+
this.editor = new _commentEditor.default(this.hot.rootDocument, this.hot.isRtl());
|
278
220
|
}
|
279
221
|
if (!this.eventManager) {
|
280
222
|
this.eventManager = new _eventManager.default(this);
|
281
223
|
}
|
282
|
-
if (!
|
283
|
-
|
224
|
+
if (!this.displaySwitch) {
|
225
|
+
this.displaySwitch = new _displaySwitch.default(this.getDisplayDelaySetting());
|
284
226
|
}
|
285
227
|
this.addHook('afterContextMenuDefaultOptions', function (options) {
|
286
228
|
return _this2.addToContextMenu(options);
|
@@ -297,16 +239,12 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
297
239
|
this.addHook('afterBeginEditing', function () {
|
298
240
|
return _this2.hide();
|
299
241
|
});
|
300
|
-
this.
|
301
|
-
return _this2.onAfterDocumentKeyDown(event);
|
302
|
-
});
|
303
|
-
_classPrivateFieldGet(this, _displaySwitch).addLocalHook('hide', function () {
|
242
|
+
this.displaySwitch.addLocalHook('hide', function () {
|
304
243
|
return _this2.hide();
|
305
244
|
});
|
306
|
-
|
245
|
+
this.displaySwitch.addLocalHook('show', function (row, col) {
|
307
246
|
return _this2.showAtCell(row, col);
|
308
247
|
});
|
309
|
-
this.registerShortcuts();
|
310
248
|
this.registerListeners();
|
311
249
|
_get(_getPrototypeOf(Comments.prototype), "enablePlugin", this).call(this);
|
312
250
|
}
|
@@ -320,8 +258,10 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
320
258
|
}, {
|
321
259
|
key: "updatePlugin",
|
322
260
|
value: function updatePlugin() {
|
323
|
-
|
261
|
+
this.disablePlugin();
|
262
|
+
this.enablePlugin();
|
324
263
|
_get(_getPrototypeOf(Comments.prototype), "updatePlugin", this).call(this);
|
264
|
+
this.displaySwitch.updateDelay(this.getDisplayDelaySetting());
|
325
265
|
}
|
326
266
|
|
327
267
|
/**
|
@@ -330,76 +270,9 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
330
270
|
}, {
|
331
271
|
key: "disablePlugin",
|
332
272
|
value: function disablePlugin() {
|
333
|
-
this.unregisterShortcuts();
|
334
273
|
_get(_getPrototypeOf(Comments.prototype), "disablePlugin", this).call(this);
|
335
274
|
}
|
336
275
|
|
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
|
-
|
403
276
|
/**
|
404
277
|
* Registers all necessary DOM listeners.
|
405
278
|
*
|
@@ -408,29 +281,25 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
408
281
|
}, {
|
409
282
|
key: "registerListeners",
|
410
283
|
value: function registerListeners() {
|
411
|
-
var
|
284
|
+
var _this3 = this;
|
412
285
|
var rootDocument = this.hot.rootDocument;
|
413
|
-
var editorElement = this.getEditorInputElement();
|
414
286
|
this.eventManager.addEventListener(rootDocument, 'mouseover', function (event) {
|
415
|
-
return
|
287
|
+
return _this3.onMouseOver(event);
|
416
288
|
});
|
417
289
|
this.eventManager.addEventListener(rootDocument, 'mousedown', function (event) {
|
418
|
-
return
|
290
|
+
return _this3.onMouseDown(event);
|
419
291
|
});
|
420
292
|
this.eventManager.addEventListener(rootDocument, 'mouseup', function () {
|
421
|
-
return
|
293
|
+
return _this3.onMouseUp();
|
422
294
|
});
|
423
|
-
this.eventManager.addEventListener(
|
424
|
-
return
|
295
|
+
this.eventManager.addEventListener(this.editor.getInputElement(), 'blur', function () {
|
296
|
+
return _this3.onEditorBlur();
|
425
297
|
});
|
426
|
-
this.eventManager.addEventListener(
|
427
|
-
return
|
298
|
+
this.eventManager.addEventListener(this.editor.getInputElement(), 'mousedown', function (event) {
|
299
|
+
return _this3.onEditorMouseDown(event);
|
428
300
|
});
|
429
|
-
this.eventManager.addEventListener(
|
430
|
-
return
|
431
|
-
});
|
432
|
-
this.eventManager.addEventListener(editorElement, 'mouseup', function (event) {
|
433
|
-
return _this4.onEditorMouseUp(event);
|
301
|
+
this.eventManager.addEventListener(this.editor.getInputElement(), 'mouseup', function (event) {
|
302
|
+
return _this3.onEditorMouseUp(event);
|
434
303
|
});
|
435
304
|
}
|
436
305
|
|
@@ -478,7 +347,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
478
347
|
}, {
|
479
348
|
key: "targetIsCommentTextArea",
|
480
349
|
value: function targetIsCommentTextArea(event) {
|
481
|
-
return this.
|
350
|
+
return this.editor.getInputElement() === event.target;
|
482
351
|
}
|
483
352
|
|
484
353
|
/**
|
@@ -492,7 +361,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
492
361
|
if (!this.range.from) {
|
493
362
|
throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
|
494
363
|
}
|
495
|
-
var editorValue =
|
364
|
+
var editorValue = this.editor.getValue();
|
496
365
|
var comment = '';
|
497
366
|
if (value !== null && value !== void 0) {
|
498
367
|
comment = value;
|
@@ -601,9 +470,8 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
601
470
|
return false;
|
602
471
|
}
|
603
472
|
var meta = this.hot.getCellMeta(this.range.from.row, this.range.from.col);
|
604
|
-
|
605
|
-
|
606
|
-
_classPrivateFieldGet(this, _editor).show();
|
473
|
+
this.editor.setValue(meta[META_COMMENT] ? meta[META_COMMENT][META_COMMENT_VALUE] : null || '');
|
474
|
+
this.editor.show();
|
607
475
|
this.refreshEditor(true);
|
608
476
|
return true;
|
609
477
|
}
|
@@ -630,7 +498,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
630
498
|
}, {
|
631
499
|
key: "hide",
|
632
500
|
value: function hide() {
|
633
|
-
|
501
|
+
this.editor.hide();
|
634
502
|
}
|
635
503
|
|
636
504
|
/**
|
@@ -643,7 +511,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
643
511
|
value: function refreshEditor() {
|
644
512
|
var _renderableRow, _renderableColumn;
|
645
513
|
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
646
|
-
if (!force && (!this.range.from || !
|
514
|
+
if (!force && (!this.range.from || !this.editor.isVisible())) {
|
647
515
|
return;
|
648
516
|
}
|
649
517
|
var _this$hot = this.hot,
|
@@ -659,7 +527,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
659
527
|
|
660
528
|
// Reset the editor position to (0, 0) so the opening direction calculation wouldn't be influenced by its
|
661
529
|
// previous position
|
662
|
-
|
530
|
+
this.editor.setPosition(0, 0);
|
663
531
|
if (renderableRow === null) {
|
664
532
|
renderableRow = rowIndexMapper.getRenderableFromVisualIndex(rowIndexMapper.getNearestNotHiddenIndex(visualRow, -1));
|
665
533
|
}
|
@@ -682,9 +550,9 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
682
550
|
}, true);
|
683
551
|
var commentStyle = this.getCommentMeta(visualRow, visualColumn, META_STYLE);
|
684
552
|
if (commentStyle) {
|
685
|
-
|
553
|
+
this.editor.setSize(commentStyle.width, commentStyle.height);
|
686
554
|
} else {
|
687
|
-
|
555
|
+
this.editor.resetSize();
|
688
556
|
}
|
689
557
|
var lastColWidth = isBeforeRenderedColumns ? 0 : wtTable.getStretchedColumnWidth(renderableColumn);
|
690
558
|
var lastRowHeight = targetingPreviousRow && !isBeforeRenderedRows ? (0, _element.outerHeight)(TD) : 0;
|
@@ -693,9 +561,9 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
693
561
|
top = _TD$getBoundingClient.top,
|
694
562
|
cellWidth = _TD$getBoundingClient.width,
|
695
563
|
cellHeight = _TD$getBoundingClient.height;
|
696
|
-
var
|
697
|
-
editorWidth =
|
698
|
-
editorHeight =
|
564
|
+
var _this$editor$getSize = this.editor.getSize(),
|
565
|
+
editorWidth = _this$editor$getSize.width,
|
566
|
+
editorHeight = _this$editor$getSize.height;
|
699
567
|
var _this$hot$rootWindow = this.hot.rootWindow,
|
700
568
|
innerWidth = _this$hot$rootWindow.innerWidth,
|
701
569
|
innerHeight = _this$hot$rootWindow.innerHeight;
|
@@ -715,17 +583,30 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
715
583
|
if (top + editorHeight > innerHeight) {
|
716
584
|
y -= editorHeight - cellHeight + 1;
|
717
585
|
}
|
718
|
-
|
719
|
-
|
586
|
+
this.editor.setPosition(x, y);
|
587
|
+
this.editor.setReadOnlyState(this.getCommentMeta(visualRow, visualColumn, META_READONLY));
|
720
588
|
}
|
721
589
|
|
722
590
|
/**
|
723
|
-
*
|
591
|
+
* Checks if there is a comment for selected range.
|
592
|
+
*
|
593
|
+
* @private
|
594
|
+
* @returns {boolean}
|
724
595
|
*/
|
725
596
|
}, {
|
726
|
-
key: "
|
727
|
-
value: function
|
728
|
-
|
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;
|
729
610
|
}
|
730
611
|
|
731
612
|
/**
|
@@ -779,7 +660,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
779
660
|
if (!this.hot.view || !this.hot.view._wt) {
|
780
661
|
return;
|
781
662
|
}
|
782
|
-
if (!
|
663
|
+
if (!this.preventEditorAutoSwitch && !this.targetIsCommentTextArea(event)) {
|
783
664
|
var eventCell = (0, _element.closest)(event.target, 'TD', 'TBODY');
|
784
665
|
var coordinates = null;
|
785
666
|
if (eventCell) {
|
@@ -800,16 +681,17 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
800
681
|
}, {
|
801
682
|
key: "onMouseOver",
|
802
683
|
value: function onMouseOver(event) {
|
684
|
+
var priv = privatePool.get(this);
|
803
685
|
var rootDocument = this.hot.rootDocument;
|
804
|
-
if (
|
686
|
+
if (this.preventEditorAutoSwitch || this.editor.isFocused() || (0, _element.hasClass)(event.target, 'wtBorder') || priv.cellBelowCursor === event.target || !this.editor) {
|
805
687
|
return;
|
806
688
|
}
|
807
|
-
|
689
|
+
priv.cellBelowCursor = rootDocument.elementFromPoint(event.clientX, event.clientY);
|
808
690
|
if (this.targetIsCellWithComment(event)) {
|
809
691
|
var range = this.hot._createCellRange(this.hot.getCoords(event.target));
|
810
|
-
|
692
|
+
this.displaySwitch.show(range);
|
811
693
|
} else if ((0, _element.isChildOf)(event.target, rootDocument) && !this.targetIsCommentTextArea(event)) {
|
812
|
-
|
694
|
+
this.displaySwitch.hide();
|
813
695
|
}
|
814
696
|
}
|
815
697
|
|
@@ -821,7 +703,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
821
703
|
}, {
|
822
704
|
key: "onMouseUp",
|
823
705
|
value: function onMouseUp() {
|
824
|
-
|
706
|
+
this.preventEditorAutoSwitch = false;
|
825
707
|
}
|
826
708
|
|
827
709
|
/**
|
@@ -840,33 +722,16 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
840
722
|
}
|
841
723
|
|
842
724
|
/**
|
843
|
-
*
|
844
|
-
* editor content and gives back the keyboard shortcuts control by switching to the "grid" context.
|
725
|
+
* `blur` event callback for the comment editor.
|
845
726
|
*
|
846
727
|
* @private
|
847
728
|
*/
|
848
729
|
}, {
|
849
730
|
key: "onEditorBlur",
|
850
731
|
value: function onEditorBlur() {
|
851
|
-
_classPrivateFieldSet(this, _commentValueBeforeSave, '');
|
852
|
-
this.hot.getShortcutManager().setActiveContextName('grid');
|
853
732
|
this.setComment();
|
854
733
|
}
|
855
734
|
|
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
|
-
|
870
735
|
/**
|
871
736
|
* `mousedown` hook. Along with `onEditorMouseUp` used to simulate the textarea resizing event.
|
872
737
|
*
|
@@ -876,10 +741,11 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
876
741
|
}, {
|
877
742
|
key: "onEditorMouseDown",
|
878
743
|
value: function onEditorMouseDown(event) {
|
879
|
-
|
744
|
+
var priv = privatePool.get(this);
|
745
|
+
priv.tempEditorDimensions = {
|
880
746
|
width: (0, _element.outerWidth)(event.target),
|
881
747
|
height: (0, _element.outerHeight)(event.target)
|
882
|
-
}
|
748
|
+
};
|
883
749
|
}
|
884
750
|
|
885
751
|
/**
|
@@ -891,9 +757,10 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
891
757
|
}, {
|
892
758
|
key: "onEditorMouseUp",
|
893
759
|
value: function onEditorMouseUp(event) {
|
760
|
+
var priv = privatePool.get(this);
|
894
761
|
var currentWidth = (0, _element.outerWidth)(event.target);
|
895
762
|
var currentHeight = (0, _element.outerHeight)(event.target);
|
896
|
-
if (currentWidth !==
|
763
|
+
if (currentWidth !== priv.tempEditorDimensions.width + 1 || currentHeight !== priv.tempEditorDimensions.height + 2) {
|
897
764
|
this.updateCommentMeta(this.range.from.row, this.range.from.col, _defineProperty({}, META_STYLE, {
|
898
765
|
width: currentWidth,
|
899
766
|
height: currentHeight
|
@@ -902,31 +769,144 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
902
769
|
}
|
903
770
|
|
904
771
|
/**
|
905
|
-
*
|
906
|
-
* the table editor into the fast edit mode.
|
772
|
+
* Context Menu's "Add comment" callback. Results in showing the comment editor.
|
907
773
|
*
|
908
|
-
* @
|
774
|
+
* @private
|
909
775
|
*/
|
910
776
|
}, {
|
911
|
-
key: "
|
912
|
-
value: function
|
913
|
-
|
914
|
-
|
915
|
-
|
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();
|
807
|
+
}
|
808
|
+
|
809
|
+
/**
|
810
|
+
* Context Menu's "make comment read-only" callback.
|
811
|
+
*
|
812
|
+
* @private
|
813
|
+
*/
|
814
|
+
}, {
|
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
|
+
});
|
916
826
|
}
|
917
827
|
|
918
828
|
/**
|
919
829
|
* Add Comments plugin options to the Context Menu.
|
920
830
|
*
|
921
831
|
* @private
|
922
|
-
* @param {object}
|
832
|
+
* @param {object} defaultOptions The menu options.
|
923
833
|
*/
|
924
834
|
}, {
|
925
835
|
key: "addToContextMenu",
|
926
|
-
value: function addToContextMenu(
|
927
|
-
|
928
|
-
|
929
|
-
|
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
|
+
});
|
930
910
|
}
|
931
911
|
|
932
912
|
/**
|
@@ -944,29 +924,17 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
944
924
|
}
|
945
925
|
}
|
946
926
|
|
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
|
-
|
959
927
|
/**
|
960
928
|
* Destroys the plugin instance.
|
961
929
|
*/
|
962
930
|
}, {
|
963
931
|
key: "destroy",
|
964
932
|
value: function destroy() {
|
965
|
-
if (
|
966
|
-
|
933
|
+
if (this.editor) {
|
934
|
+
this.editor.destroy();
|
967
935
|
}
|
968
|
-
if (
|
969
|
-
|
936
|
+
if (this.displaySwitch) {
|
937
|
+
this.displaySwitch.destroy();
|
970
938
|
}
|
971
939
|
_get(_getPrototypeOf(Comments.prototype), "destroy", this).call(this);
|
972
940
|
}
|