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.
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/core/focusCatcher/focusDetector.js +62 -0
- package/core/focusCatcher/focusDetector.mjs +58 -0
- package/core/focusCatcher/index.js +140 -0
- package/core/focusCatcher/index.mjs +136 -0
- package/core/index.js +12 -0
- package/core/index.mjs +1 -0
- package/core.d.ts +0 -1
- package/core.js +24 -31
- package/core.mjs +24 -31
- package/dataMap/metaManager/metaSchema.js +22 -0
- package/dataMap/metaManager/metaSchema.mjs +22 -0
- package/dist/handsontable.css +13 -2
- package/dist/handsontable.full.css +13 -2
- package/dist/handsontable.full.js +4815 -4810
- package/dist/handsontable.full.min.css +3 -3
- package/dist/handsontable.full.min.js +61 -61
- package/dist/handsontable.js +13215 -13210
- package/dist/handsontable.min.css +3 -3
- package/dist/handsontable.min.js +4 -4
- package/editorManager.js +10 -4
- package/editorManager.mjs +10 -4
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/package.json +1 -1
- package/pluginHooks.d.ts +1 -1
- package/pluginHooks.js +10 -7
- package/pluginHooks.mjs +10 -7
- package/plugins/comments/commentEditor.js +0 -1
- package/plugins/comments/commentEditor.mjs +0 -1
- package/plugins/comments/comments.js +231 -289
- package/plugins/comments/comments.mjs +241 -297
- package/plugins/contextMenu/contextMenu.js +0 -1
- package/plugins/contextMenu/contextMenu.mjs +0 -1
- package/plugins/copyPaste/copyPaste.js +1 -1
- package/plugins/copyPaste/copyPaste.mjs +1 -1
- package/plugins/dropdownMenu/dropdownMenu.js +1 -0
- package/plugins/dropdownMenu/dropdownMenu.mjs +1 -0
- package/plugins/formulas/engine/settings.js +2 -2
- package/plugins/formulas/engine/settings.mjs +2 -2
- package/plugins/formulas/formulas.js +2 -2
- package/plugins/formulas/formulas.mjs +2 -2
- package/plugins/manualRowResize/manualRowResize.js +2 -2
- package/plugins/manualRowResize/manualRowResize.mjs +2 -2
- package/settings.d.ts +1 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +2 -7
- package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +2 -7
- package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +2 -7
- package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +2 -7
- package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +2 -7
- package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +2 -7
- package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +2 -7
- package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +2 -7
- package/shortcutContexts/constants.js +1 -6
- package/shortcutContexts/constants.mjs +0 -4
- package/tableView.js +4 -9
- package/tableView.mjs +4 -9
- 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,24 +1,10 @@
|
|
1
1
|
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); }
|
2
|
-
|
3
|
-
import "core-js/modules/es.array.iterator.js";
|
4
|
-
import "core-js/modules/es.object.to-string.js";
|
5
|
-
import "core-js/modules/es.string.iterator.js";
|
6
|
-
import "core-js/modules/es.weak-map.js";
|
7
|
-
import "core-js/modules/web.dom-collections.iterator.js";
|
8
|
-
import "core-js/modules/es.symbol.to-primitive.js";
|
9
|
-
import "core-js/modules/es.date.to-primitive.js";
|
10
|
-
import "core-js/modules/es.symbol.js";
|
11
|
-
import "core-js/modules/es.symbol.description.js";
|
12
|
-
import "core-js/modules/es.number.constructor.js";
|
13
|
-
import "core-js/modules/es.object.set-prototype-of.js";
|
14
|
-
import "core-js/modules/es.object.get-prototype-of.js";
|
15
|
-
import "core-js/modules/es.reflect.construct.js";
|
16
|
-
import "core-js/modules/es.reflect.get.js";
|
17
|
-
import "core-js/modules/es.object.get-own-property-descriptor.js";
|
18
|
-
import "core-js/modules/es.symbol.iterator.js";
|
2
|
+
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; }
|
19
3
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
20
4
|
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); } }
|
21
5
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
6
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
7
|
+
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); }
|
22
8
|
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); }
|
23
9
|
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
24
10
|
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); }
|
@@ -28,35 +14,37 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
28
14
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
29
15
|
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; } }
|
30
16
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
17
|
+
import "core-js/modules/es.array.iterator.js";
|
18
|
+
import "core-js/modules/es.object.to-string.js";
|
19
|
+
import "core-js/modules/es.string.iterator.js";
|
20
|
+
import "core-js/modules/es.weak-map.js";
|
21
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
22
|
+
import "core-js/modules/es.object.set-prototype-of.js";
|
23
|
+
import "core-js/modules/es.object.get-prototype-of.js";
|
24
|
+
import "core-js/modules/es.reflect.construct.js";
|
25
|
+
import "core-js/modules/es.reflect.get.js";
|
26
|
+
import "core-js/modules/es.object.get-own-property-descriptor.js";
|
27
|
+
import "core-js/modules/es.symbol.to-primitive.js";
|
28
|
+
import "core-js/modules/es.date.to-primitive.js";
|
29
|
+
import "core-js/modules/es.symbol.js";
|
30
|
+
import "core-js/modules/es.symbol.description.js";
|
31
|
+
import "core-js/modules/es.number.constructor.js";
|
32
|
+
import "core-js/modules/es.symbol.iterator.js";
|
41
33
|
import { addClass, closest, isChildOf, hasClass, outerWidth, outerHeight } from "../../helpers/dom/element.mjs";
|
42
|
-
import { stopImmediatePropagation } from "../../helpers/dom/event.mjs";
|
43
34
|
import { deepClone, deepExtend, isObject } from "../../helpers/object.mjs";
|
44
35
|
import EventManager from "../../eventManager.mjs";
|
45
36
|
import { BasePlugin } from "../base/index.mjs";
|
46
37
|
import CommentEditor from "./commentEditor.mjs";
|
38
|
+
import { checkSelectionConsistency, markLabelAsSelected } from "../contextMenu/utils.mjs";
|
47
39
|
import DisplaySwitch from "./displaySwitch.mjs";
|
48
|
-
import
|
49
|
-
import addEditCommentItem from "./contextMenuItem/addEditComment.mjs";
|
50
|
-
import removeCommentItem from "./contextMenuItem/removeComment.mjs";
|
51
|
-
import readOnlyCommentItem from "./contextMenuItem/readOnlyComment.mjs";
|
40
|
+
import * as C from "../../i18n/constants.mjs";
|
52
41
|
export var PLUGIN_KEY = 'comments';
|
53
42
|
export var PLUGIN_PRIORITY = 60;
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
var
|
59
|
-
var SHORTCUTS_CONTEXT_NAME = "plugin:".concat(PLUGIN_KEY);
|
43
|
+
var privatePool = new WeakMap();
|
44
|
+
var META_COMMENT = 'comment';
|
45
|
+
var META_COMMENT_VALUE = 'value';
|
46
|
+
var META_STYLE = 'style';
|
47
|
+
var META_READONLY = 'readOnly';
|
60
48
|
|
61
49
|
/* eslint-disable jsdoc/require-description-complete-sentence */
|
62
50
|
/**
|
@@ -148,119 +136,63 @@ var SHORTCUTS_CONTEXT_NAME = "plugin:".concat(PLUGIN_KEY);
|
|
148
136
|
* ```
|
149
137
|
* :::
|
150
138
|
*/
|
151
|
-
var _editor = /*#__PURE__*/new WeakMap();
|
152
|
-
var _displaySwitch = /*#__PURE__*/new WeakMap();
|
153
|
-
var _preventEditorAutoSwitch = /*#__PURE__*/new WeakMap();
|
154
|
-
var _preventEditorHiding = /*#__PURE__*/new WeakMap();
|
155
|
-
var _tempEditorDimensions = /*#__PURE__*/new WeakMap();
|
156
|
-
var _cellBelowCursor = /*#__PURE__*/new WeakMap();
|
157
|
-
var _commentValueBeforeSave = /*#__PURE__*/new WeakMap();
|
158
139
|
export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
159
140
|
_inherits(Comments, _BasePlugin);
|
160
141
|
var _super = _createSuper(Comments);
|
161
|
-
function Comments() {
|
142
|
+
function Comments(hotInstance) {
|
162
143
|
var _this;
|
163
144
|
_classCallCheck(this, Comments);
|
164
|
-
|
165
|
-
args[_key] = arguments[_key];
|
166
|
-
}
|
167
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
168
|
-
/**
|
169
|
-
* Current cell range, an object with `from` property, with `row` and `col` properties (e.q. `{from: {row: 1, col: 6}}`).
|
170
|
-
*
|
171
|
-
* @type {object}
|
172
|
-
*/
|
173
|
-
_defineProperty(_assertThisInitialized(_this), "range", {});
|
174
|
-
/**
|
175
|
-
* Instance of {@link EventManager}.
|
176
|
-
*
|
177
|
-
* @protected
|
178
|
-
* @type {EventManager}
|
179
|
-
*/
|
180
|
-
_defineProperty(_assertThisInitialized(_this), "eventManager", null);
|
145
|
+
_this = _super.call(this, hotInstance);
|
181
146
|
/**
|
182
147
|
* Instance of {@link CommentEditor}.
|
183
148
|
*
|
184
149
|
* @private
|
185
150
|
* @type {CommentEditor}
|
186
151
|
*/
|
187
|
-
|
188
|
-
writable: true,
|
189
|
-
value: null
|
190
|
-
});
|
152
|
+
_this.editor = null;
|
191
153
|
/**
|
192
154
|
* Instance of {@link DisplaySwitch}.
|
193
155
|
*
|
194
156
|
* @private
|
195
157
|
* @type {DisplaySwitch}
|
196
158
|
*/
|
197
|
-
|
198
|
-
writable: true,
|
199
|
-
value: null
|
200
|
-
});
|
159
|
+
_this.displaySwitch = null;
|
201
160
|
/**
|
202
|
-
*
|
203
|
-
*
|
204
|
-
* @private
|
205
|
-
* @type {boolean}
|
206
|
-
*/
|
207
|
-
_classPrivateFieldInitSpec(_assertThisInitialized(_this), _preventEditorAutoSwitch, {
|
208
|
-
writable: true,
|
209
|
-
value: false
|
210
|
-
});
|
211
|
-
/**
|
212
|
-
* Prevents hiding editor when the table viewport is scrolled and that scroll is triggered by the
|
213
|
-
* keyboard shortcut that insert or edits the comment.
|
161
|
+
* Instance of {@link EventManager}.
|
214
162
|
*
|
215
163
|
* @private
|
216
|
-
* @type {
|
164
|
+
* @type {EventManager}
|
217
165
|
*/
|
218
|
-
|
219
|
-
writable: true,
|
220
|
-
value: false
|
221
|
-
});
|
166
|
+
_this.eventManager = null;
|
222
167
|
/**
|
223
|
-
*
|
168
|
+
* Current cell range, an object with `from` property, with `row` and `col` properties (e.q. `{from: {row: 1, col: 6}}`).
|
224
169
|
*
|
225
|
-
* @private
|
226
170
|
* @type {object}
|
227
171
|
*/
|
228
|
-
|
229
|
-
writable: true,
|
230
|
-
value: {}
|
231
|
-
});
|
172
|
+
_this.range = {};
|
232
173
|
/**
|
233
|
-
*
|
174
|
+
* Prevents showing/hiding editor that reacts on the logic triggered by the "mouseover" events.
|
234
175
|
*
|
235
176
|
* @private
|
236
177
|
* @type {boolean}
|
237
178
|
*/
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
/**
|
243
|
-
* Holds the comment value before it's actually saved to the cell meta.
|
244
|
-
*
|
245
|
-
* @private
|
246
|
-
* @type {string}
|
247
|
-
*/
|
248
|
-
_classPrivateFieldInitSpec(_assertThisInitialized(_this), _commentValueBeforeSave, {
|
249
|
-
writable: true,
|
250
|
-
value: ''
|
179
|
+
_this.preventEditorAutoSwitch = false;
|
180
|
+
privatePool.set(_assertThisInitialized(_this), {
|
181
|
+
tempEditorDimensions: {},
|
182
|
+
cellBelowCursor: null
|
251
183
|
});
|
252
184
|
return _this;
|
253
185
|
}
|
186
|
+
|
187
|
+
/**
|
188
|
+
* Checks if the plugin is enabled in the handsontable settings. This method is executed in {@link Hooks#beforeInit}
|
189
|
+
* hook and if it returns `true` then the {@link Comments#enablePlugin} method is called.
|
190
|
+
*
|
191
|
+
* @returns {boolean}
|
192
|
+
*/
|
254
193
|
_createClass(Comments, [{
|
255
194
|
key: "isEnabled",
|
256
|
-
value:
|
257
|
-
/**
|
258
|
-
* Checks if the plugin is enabled in the handsontable settings. This method is executed in {@link Hooks#beforeInit}
|
259
|
-
* hook and if it returns `true` then the {@link Comments#enablePlugin} method is called.
|
260
|
-
*
|
261
|
-
* @returns {boolean}
|
262
|
-
*/
|
263
|
-
function isEnabled() {
|
195
|
+
value: function isEnabled() {
|
264
196
|
return !!this.hot.getSettings()[PLUGIN_KEY];
|
265
197
|
}
|
266
198
|
|
@@ -274,14 +206,14 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
274
206
|
if (this.enabled) {
|
275
207
|
return;
|
276
208
|
}
|
277
|
-
if (!
|
278
|
-
|
209
|
+
if (!this.editor) {
|
210
|
+
this.editor = new CommentEditor(this.hot.rootDocument, this.hot.isRtl());
|
279
211
|
}
|
280
212
|
if (!this.eventManager) {
|
281
213
|
this.eventManager = new EventManager(this);
|
282
214
|
}
|
283
|
-
if (!
|
284
|
-
|
215
|
+
if (!this.displaySwitch) {
|
216
|
+
this.displaySwitch = new DisplaySwitch(this.getDisplayDelaySetting());
|
285
217
|
}
|
286
218
|
this.addHook('afterContextMenuDefaultOptions', function (options) {
|
287
219
|
return _this2.addToContextMenu(options);
|
@@ -289,22 +221,21 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
289
221
|
this.addHook('afterRenderer', function (TD, row, col, prop, value, cellProperties) {
|
290
222
|
return _this2.onAfterRenderer(TD, cellProperties);
|
291
223
|
});
|
292
|
-
this.addHook('
|
293
|
-
return _this2.
|
224
|
+
this.addHook('afterScrollHorizontally', function () {
|
225
|
+
return _this2.hide();
|
294
226
|
});
|
295
|
-
this.addHook('
|
227
|
+
this.addHook('afterScrollVertically', function () {
|
296
228
|
return _this2.hide();
|
297
229
|
});
|
298
|
-
this.addHook('
|
299
|
-
return _this2.
|
230
|
+
this.addHook('afterBeginEditing', function () {
|
231
|
+
return _this2.hide();
|
300
232
|
});
|
301
|
-
|
233
|
+
this.displaySwitch.addLocalHook('hide', function () {
|
302
234
|
return _this2.hide();
|
303
235
|
});
|
304
|
-
|
236
|
+
this.displaySwitch.addLocalHook('show', function (row, col) {
|
305
237
|
return _this2.showAtCell(row, col);
|
306
238
|
});
|
307
|
-
this.registerShortcuts();
|
308
239
|
this.registerListeners();
|
309
240
|
_get(_getPrototypeOf(Comments.prototype), "enablePlugin", this).call(this);
|
310
241
|
}
|
@@ -318,8 +249,10 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
318
249
|
}, {
|
319
250
|
key: "updatePlugin",
|
320
251
|
value: function updatePlugin() {
|
321
|
-
|
252
|
+
this.disablePlugin();
|
253
|
+
this.enablePlugin();
|
322
254
|
_get(_getPrototypeOf(Comments.prototype), "updatePlugin", this).call(this);
|
255
|
+
this.displaySwitch.updateDelay(this.getDisplayDelaySetting());
|
323
256
|
}
|
324
257
|
|
325
258
|
/**
|
@@ -328,82 +261,9 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
328
261
|
}, {
|
329
262
|
key: "disablePlugin",
|
330
263
|
value: function disablePlugin() {
|
331
|
-
this.unregisterShortcuts();
|
332
264
|
_get(_getPrototypeOf(Comments.prototype), "disablePlugin", this).call(this);
|
333
265
|
}
|
334
266
|
|
335
|
-
/**
|
336
|
-
* Register shortcuts responsible for toggling context menu.
|
337
|
-
*
|
338
|
-
* @private
|
339
|
-
*/
|
340
|
-
}, {
|
341
|
-
key: "registerShortcuts",
|
342
|
-
value: function registerShortcuts() {
|
343
|
-
var _this3 = this;
|
344
|
-
var manager = this.hot.getShortcutManager();
|
345
|
-
var gridContext = manager.getContext('grid');
|
346
|
-
var pluginContext = manager.addContext(SHORTCUTS_CONTEXT_NAME);
|
347
|
-
gridContext.addShortcut({
|
348
|
-
keys: [['Control', 'Alt', 'M']],
|
349
|
-
callback: function callback() {
|
350
|
-
var range = _this3.hot.getSelectedRangeLast();
|
351
|
-
_classPrivateFieldSet(_this3, _preventEditorHiding, true);
|
352
|
-
_this3.hot.scrollToFocusedCell(function () {
|
353
|
-
_this3.setRange(range);
|
354
|
-
_this3.show();
|
355
|
-
_this3.focusEditor();
|
356
|
-
manager.setActiveContextName(SHORTCUTS_CONTEXT_NAME);
|
357
|
-
_this3.hot._registerTimeout(function () {
|
358
|
-
_classPrivateFieldSet(_this3, _preventEditorHiding, false);
|
359
|
-
});
|
360
|
-
});
|
361
|
-
},
|
362
|
-
stopPropagation: true,
|
363
|
-
runOnlyIf: function runOnlyIf() {
|
364
|
-
var _this3$hot$getSelecte;
|
365
|
-
return ((_this3$hot$getSelecte = _this3.hot.getSelectedRangeLast()) === null || _this3$hot$getSelecte === void 0 ? void 0 : _this3$hot$getSelecte.highlight.isCell()) && !_classPrivateFieldGet(_this3, _editor).isVisible();
|
366
|
-
},
|
367
|
-
group: SHORTCUTS_GROUP
|
368
|
-
});
|
369
|
-
pluginContext.addShortcut({
|
370
|
-
keys: [['Escape']],
|
371
|
-
callback: function callback() {
|
372
|
-
_classPrivateFieldGet(_this3, _editor).setValue(_classPrivateFieldGet(_this3, _commentValueBeforeSave));
|
373
|
-
_this3.hide();
|
374
|
-
manager.setActiveContextName('grid');
|
375
|
-
},
|
376
|
-
runOnlyIf: function runOnlyIf() {
|
377
|
-
var _this3$hot$getSelecte2;
|
378
|
-
return ((_this3$hot$getSelecte2 = _this3.hot.getSelectedRangeLast()) === null || _this3$hot$getSelecte2 === void 0 ? void 0 : _this3$hot$getSelecte2.highlight.isCell()) && _classPrivateFieldGet(_this3, _editor).isVisible();
|
379
|
-
},
|
380
|
-
group: SHORTCUTS_GROUP
|
381
|
-
});
|
382
|
-
pluginContext.addShortcut({
|
383
|
-
keys: [['Control/Meta', 'Enter']],
|
384
|
-
callback: function callback() {
|
385
|
-
_this3.hide();
|
386
|
-
manager.setActiveContextName('grid');
|
387
|
-
},
|
388
|
-
runOnlyIf: function runOnlyIf() {
|
389
|
-
var _this3$hot$getSelecte3;
|
390
|
-
return ((_this3$hot$getSelecte3 = _this3.hot.getSelectedRangeLast()) === null || _this3$hot$getSelecte3 === void 0 ? void 0 : _this3$hot$getSelecte3.highlight.isCell()) && _classPrivateFieldGet(_this3, _editor).isVisible();
|
391
|
-
},
|
392
|
-
group: SHORTCUTS_GROUP
|
393
|
-
});
|
394
|
-
}
|
395
|
-
|
396
|
-
/**
|
397
|
-
* Unregister shortcuts responsible for toggling context menu.
|
398
|
-
*
|
399
|
-
* @private
|
400
|
-
*/
|
401
|
-
}, {
|
402
|
-
key: "unregisterShortcuts",
|
403
|
-
value: function unregisterShortcuts() {
|
404
|
-
this.hot.getShortcutManager().getContext('grid').removeShortcutsByGroup(SHORTCUTS_GROUP);
|
405
|
-
}
|
406
|
-
|
407
267
|
/**
|
408
268
|
* Registers all necessary DOM listeners.
|
409
269
|
*
|
@@ -412,29 +272,25 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
412
272
|
}, {
|
413
273
|
key: "registerListeners",
|
414
274
|
value: function registerListeners() {
|
415
|
-
var
|
275
|
+
var _this3 = this;
|
416
276
|
var rootDocument = this.hot.rootDocument;
|
417
|
-
var editorElement = this.getEditorInputElement();
|
418
277
|
this.eventManager.addEventListener(rootDocument, 'mouseover', function (event) {
|
419
|
-
return
|
278
|
+
return _this3.onMouseOver(event);
|
420
279
|
});
|
421
280
|
this.eventManager.addEventListener(rootDocument, 'mousedown', function (event) {
|
422
|
-
return
|
281
|
+
return _this3.onMouseDown(event);
|
423
282
|
});
|
424
283
|
this.eventManager.addEventListener(rootDocument, 'mouseup', function () {
|
425
|
-
return
|
426
|
-
});
|
427
|
-
this.eventManager.addEventListener(editorElement, 'focus', function () {
|
428
|
-
return _this4.onEditorFocus();
|
284
|
+
return _this3.onMouseUp();
|
429
285
|
});
|
430
|
-
this.eventManager.addEventListener(
|
431
|
-
return
|
286
|
+
this.eventManager.addEventListener(this.editor.getInputElement(), 'blur', function () {
|
287
|
+
return _this3.onEditorBlur();
|
432
288
|
});
|
433
|
-
this.eventManager.addEventListener(
|
434
|
-
return
|
289
|
+
this.eventManager.addEventListener(this.editor.getInputElement(), 'mousedown', function (event) {
|
290
|
+
return _this3.onEditorMouseDown(event);
|
435
291
|
});
|
436
|
-
this.eventManager.addEventListener(
|
437
|
-
return
|
292
|
+
this.eventManager.addEventListener(this.editor.getInputElement(), 'mouseup', function (event) {
|
293
|
+
return _this3.onEditorMouseUp(event);
|
438
294
|
});
|
439
295
|
}
|
440
296
|
|
@@ -482,7 +338,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
482
338
|
}, {
|
483
339
|
key: "targetIsCommentTextArea",
|
484
340
|
value: function targetIsCommentTextArea(event) {
|
485
|
-
return this.
|
341
|
+
return this.editor.getInputElement() === event.target;
|
486
342
|
}
|
487
343
|
|
488
344
|
/**
|
@@ -496,7 +352,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
496
352
|
if (!this.range.from) {
|
497
353
|
throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
|
498
354
|
}
|
499
|
-
var editorValue =
|
355
|
+
var editorValue = this.editor.getValue();
|
500
356
|
var comment = '';
|
501
357
|
if (value !== null && value !== void 0) {
|
502
358
|
comment = value;
|
@@ -605,9 +461,8 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
605
461
|
return false;
|
606
462
|
}
|
607
463
|
var meta = this.hot.getCellMeta(this.range.from.row, this.range.from.col);
|
608
|
-
|
609
|
-
|
610
|
-
_classPrivateFieldGet(this, _editor).show();
|
464
|
+
this.editor.setValue(meta[META_COMMENT] ? meta[META_COMMENT][META_COMMENT_VALUE] : null || '');
|
465
|
+
this.editor.show();
|
611
466
|
this.refreshEditor(true);
|
612
467
|
return true;
|
613
468
|
}
|
@@ -634,7 +489,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
634
489
|
}, {
|
635
490
|
key: "hide",
|
636
491
|
value: function hide() {
|
637
|
-
|
492
|
+
this.editor.hide();
|
638
493
|
}
|
639
494
|
|
640
495
|
/**
|
@@ -647,7 +502,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
647
502
|
value: function refreshEditor() {
|
648
503
|
var _renderableRow, _renderableColumn;
|
649
504
|
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
650
|
-
if (!force && (!this.range.from || !
|
505
|
+
if (!force && (!this.range.from || !this.editor.isVisible())) {
|
651
506
|
return;
|
652
507
|
}
|
653
508
|
var _this$hot = this.hot,
|
@@ -663,7 +518,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
663
518
|
|
664
519
|
// Reset the editor position to (0, 0) so the opening direction calculation wouldn't be influenced by its
|
665
520
|
// previous position
|
666
|
-
|
521
|
+
this.editor.setPosition(0, 0);
|
667
522
|
if (renderableRow === null) {
|
668
523
|
renderableRow = rowIndexMapper.getRenderableFromVisualIndex(rowIndexMapper.getNearestNotHiddenIndex(visualRow, -1));
|
669
524
|
}
|
@@ -686,9 +541,9 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
686
541
|
}, true);
|
687
542
|
var commentStyle = this.getCommentMeta(visualRow, visualColumn, META_STYLE);
|
688
543
|
if (commentStyle) {
|
689
|
-
|
544
|
+
this.editor.setSize(commentStyle.width, commentStyle.height);
|
690
545
|
} else {
|
691
|
-
|
546
|
+
this.editor.resetSize();
|
692
547
|
}
|
693
548
|
var lastColWidth = isBeforeRenderedColumns ? 0 : wtTable.getStretchedColumnWidth(renderableColumn);
|
694
549
|
var lastRowHeight = targetingPreviousRow && !isBeforeRenderedRows ? outerHeight(TD) : 0;
|
@@ -697,9 +552,9 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
697
552
|
top = _TD$getBoundingClient.top,
|
698
553
|
cellWidth = _TD$getBoundingClient.width,
|
699
554
|
cellHeight = _TD$getBoundingClient.height;
|
700
|
-
var
|
701
|
-
editorWidth =
|
702
|
-
editorHeight =
|
555
|
+
var _this$editor$getSize = this.editor.getSize(),
|
556
|
+
editorWidth = _this$editor$getSize.width,
|
557
|
+
editorHeight = _this$editor$getSize.height;
|
703
558
|
var _this$hot$rootWindow = this.hot.rootWindow,
|
704
559
|
innerWidth = _this$hot$rootWindow.innerWidth,
|
705
560
|
innerHeight = _this$hot$rootWindow.innerHeight;
|
@@ -719,17 +574,30 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
719
574
|
if (top + editorHeight > innerHeight) {
|
720
575
|
y -= editorHeight - cellHeight + 1;
|
721
576
|
}
|
722
|
-
|
723
|
-
|
577
|
+
this.editor.setPosition(x, y);
|
578
|
+
this.editor.setReadOnlyState(this.getCommentMeta(visualRow, visualColumn, META_READONLY));
|
724
579
|
}
|
725
580
|
|
726
581
|
/**
|
727
|
-
*
|
582
|
+
* Checks if there is a comment for selected range.
|
583
|
+
*
|
584
|
+
* @private
|
585
|
+
* @returns {boolean}
|
728
586
|
*/
|
729
587
|
}, {
|
730
|
-
key: "
|
731
|
-
value: function
|
732
|
-
|
588
|
+
key: "checkSelectionCommentsConsistency",
|
589
|
+
value: function checkSelectionCommentsConsistency() {
|
590
|
+
var selected = this.hot.getSelectedRangeLast();
|
591
|
+
if (!selected) {
|
592
|
+
return false;
|
593
|
+
}
|
594
|
+
var hasComment = false;
|
595
|
+
var cell = selected.getTopStartCorner(); // IN EXCEL THERE IS COMMENT ONLY FOR TOP LEFT CELL IN SELECTION
|
596
|
+
|
597
|
+
if (this.getCommentMeta(cell.row, cell.col, META_COMMENT_VALUE)) {
|
598
|
+
hasComment = true;
|
599
|
+
}
|
600
|
+
return hasComment;
|
733
601
|
}
|
734
602
|
|
735
603
|
/**
|
@@ -783,7 +651,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
783
651
|
if (!this.hot.view || !this.hot.view._wt) {
|
784
652
|
return;
|
785
653
|
}
|
786
|
-
if (!
|
654
|
+
if (!this.preventEditorAutoSwitch && !this.targetIsCommentTextArea(event)) {
|
787
655
|
var eventCell = closest(event.target, 'TD', 'TBODY');
|
788
656
|
var coordinates = null;
|
789
657
|
if (eventCell) {
|
@@ -804,16 +672,17 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
804
672
|
}, {
|
805
673
|
key: "onMouseOver",
|
806
674
|
value: function onMouseOver(event) {
|
675
|
+
var priv = privatePool.get(this);
|
807
676
|
var rootDocument = this.hot.rootDocument;
|
808
|
-
if (
|
677
|
+
if (this.preventEditorAutoSwitch || this.editor.isFocused() || hasClass(event.target, 'wtBorder') || priv.cellBelowCursor === event.target || !this.editor) {
|
809
678
|
return;
|
810
679
|
}
|
811
|
-
|
680
|
+
priv.cellBelowCursor = rootDocument.elementFromPoint(event.clientX, event.clientY);
|
812
681
|
if (this.targetIsCellWithComment(event)) {
|
813
682
|
var range = this.hot._createCellRange(this.hot.getCoords(event.target));
|
814
|
-
|
683
|
+
this.displaySwitch.show(range);
|
815
684
|
} else if (isChildOf(event.target, rootDocument) && !this.targetIsCommentTextArea(event)) {
|
816
|
-
|
685
|
+
this.displaySwitch.hide();
|
817
686
|
}
|
818
687
|
}
|
819
688
|
|
@@ -825,7 +694,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
825
694
|
}, {
|
826
695
|
key: "onMouseUp",
|
827
696
|
value: function onMouseUp() {
|
828
|
-
|
697
|
+
this.preventEditorAutoSwitch = false;
|
829
698
|
}
|
830
699
|
|
831
700
|
/**
|
@@ -844,33 +713,16 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
844
713
|
}
|
845
714
|
|
846
715
|
/**
|
847
|
-
*
|
848
|
-
* editor content and gives back the keyboard shortcuts control by switching to the "grid" context.
|
716
|
+
* `blur` event callback for the comment editor.
|
849
717
|
*
|
850
718
|
* @private
|
851
719
|
*/
|
852
720
|
}, {
|
853
721
|
key: "onEditorBlur",
|
854
722
|
value: function onEditorBlur() {
|
855
|
-
_classPrivateFieldSet(this, _commentValueBeforeSave, '');
|
856
|
-
this.hot.getShortcutManager().setActiveContextName('grid');
|
857
723
|
this.setComment();
|
858
724
|
}
|
859
725
|
|
860
|
-
/**
|
861
|
-
* Hook observer the "focus" event from the comments editor element. The hook takes the control of
|
862
|
-
* the keyboard shortcuts by switching the context to plugins one.
|
863
|
-
*
|
864
|
-
* @private
|
865
|
-
*/
|
866
|
-
}, {
|
867
|
-
key: "onEditorFocus",
|
868
|
-
value: function onEditorFocus() {
|
869
|
-
_classPrivateFieldSet(this, _commentValueBeforeSave, this.getComment());
|
870
|
-
this.hot.listen();
|
871
|
-
this.hot.getShortcutManager().setActiveContextName(SHORTCUTS_CONTEXT_NAME);
|
872
|
-
}
|
873
|
-
|
874
726
|
/**
|
875
727
|
* `mousedown` hook. Along with `onEditorMouseUp` used to simulate the textarea resizing event.
|
876
728
|
*
|
@@ -880,10 +732,11 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
880
732
|
}, {
|
881
733
|
key: "onEditorMouseDown",
|
882
734
|
value: function onEditorMouseDown(event) {
|
883
|
-
|
735
|
+
var priv = privatePool.get(this);
|
736
|
+
priv.tempEditorDimensions = {
|
884
737
|
width: outerWidth(event.target),
|
885
738
|
height: outerHeight(event.target)
|
886
|
-
}
|
739
|
+
};
|
887
740
|
}
|
888
741
|
|
889
742
|
/**
|
@@ -895,9 +748,10 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
895
748
|
}, {
|
896
749
|
key: "onEditorMouseUp",
|
897
750
|
value: function onEditorMouseUp(event) {
|
751
|
+
var priv = privatePool.get(this);
|
898
752
|
var currentWidth = outerWidth(event.target);
|
899
753
|
var currentHeight = outerHeight(event.target);
|
900
|
-
if (currentWidth !==
|
754
|
+
if (currentWidth !== priv.tempEditorDimensions.width + 1 || currentHeight !== priv.tempEditorDimensions.height + 2) {
|
901
755
|
this.updateCommentMeta(this.range.from.row, this.range.from.col, _defineProperty({}, META_STYLE, {
|
902
756
|
width: currentWidth,
|
903
757
|
height: currentHeight
|
@@ -906,42 +760,144 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
906
760
|
}
|
907
761
|
|
908
762
|
/**
|
909
|
-
*
|
910
|
-
*
|
763
|
+
* Context Menu's "Add comment" callback. Results in showing the comment editor.
|
764
|
+
*
|
765
|
+
* @private
|
766
|
+
*/
|
767
|
+
}, {
|
768
|
+
key: "onContextMenuAddComment",
|
769
|
+
value: function onContextMenuAddComment() {
|
770
|
+
var coords = this.hot.getSelectedRangeLast();
|
771
|
+
this.preventEditorAutoSwitch = true;
|
772
|
+
this.displaySwitch.cancelHiding();
|
773
|
+
this.setRange({
|
774
|
+
from: coords.highlight
|
775
|
+
});
|
776
|
+
this.show();
|
777
|
+
this.hot.deselectCell();
|
778
|
+
this.editor.focus();
|
779
|
+
}
|
780
|
+
|
781
|
+
/**
|
782
|
+
* Context Menu's "remove comment" callback.
|
911
783
|
*
|
912
|
-
* @
|
784
|
+
* @private
|
913
785
|
*/
|
914
786
|
}, {
|
915
|
-
key: "
|
916
|
-
value: function
|
917
|
-
|
918
|
-
|
919
|
-
|
787
|
+
key: "onContextMenuRemoveComment",
|
788
|
+
value: function onContextMenuRemoveComment() {
|
789
|
+
var _this4 = this;
|
790
|
+
var coords = this.hot.getSelectedRangeLast();
|
791
|
+
this.preventEditorAutoSwitch = true;
|
792
|
+
coords.forAll(function (row, column) {
|
793
|
+
if (row >= 0 && column >= 0) {
|
794
|
+
_this4.removeCommentAtCell(row, column, false);
|
795
|
+
}
|
796
|
+
});
|
797
|
+
this.hot.render();
|
920
798
|
}
|
921
799
|
|
922
800
|
/**
|
923
|
-
*
|
801
|
+
* Context Menu's "make comment read-only" callback.
|
802
|
+
*
|
803
|
+
* @private
|
924
804
|
*/
|
925
805
|
}, {
|
926
|
-
key: "
|
927
|
-
value: function
|
928
|
-
|
929
|
-
|
930
|
-
|
806
|
+
key: "onContextMenuMakeReadOnly",
|
807
|
+
value: function onContextMenuMakeReadOnly() {
|
808
|
+
var _this5 = this;
|
809
|
+
var coords = this.hot.getSelectedRangeLast();
|
810
|
+
this.preventEditorAutoSwitch = true;
|
811
|
+
coords.forAll(function (row, column) {
|
812
|
+
if (row >= 0 && column >= 0) {
|
813
|
+
var currentState = !!_this5.getCommentMeta(row, column, META_READONLY);
|
814
|
+
_this5.updateCommentMeta(row, column, _defineProperty({}, META_READONLY, !currentState));
|
815
|
+
}
|
816
|
+
});
|
931
817
|
}
|
932
818
|
|
933
819
|
/**
|
934
820
|
* Add Comments plugin options to the Context Menu.
|
935
821
|
*
|
936
822
|
* @private
|
937
|
-
* @param {object}
|
823
|
+
* @param {object} defaultOptions The menu options.
|
938
824
|
*/
|
939
825
|
}, {
|
940
826
|
key: "addToContextMenu",
|
941
|
-
value: function addToContextMenu(
|
942
|
-
|
943
|
-
|
944
|
-
|
827
|
+
value: function addToContextMenu(defaultOptions) {
|
828
|
+
var _this6 = this;
|
829
|
+
var isThereAnySelectedCellToProcess = function isThereAnySelectedCellToProcess() {
|
830
|
+
var range = _this6.hot.getSelectedRangeLast();
|
831
|
+
if (!range) {
|
832
|
+
return false;
|
833
|
+
}
|
834
|
+
if (range.isSingleHeader() || range.highlight.isHeader()) {
|
835
|
+
return false;
|
836
|
+
}
|
837
|
+
return _this6.hot.rowIndexMapper.getRenderableIndexesLength() > 0 && _this6.hot.columnIndexMapper.getRenderableIndexesLength() > 0;
|
838
|
+
};
|
839
|
+
defaultOptions.items.push({
|
840
|
+
name: '---------'
|
841
|
+
}, {
|
842
|
+
key: 'commentsAddEdit',
|
843
|
+
name: function name() {
|
844
|
+
if (_this6.checkSelectionCommentsConsistency()) {
|
845
|
+
return _this6.hot.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_EDIT_COMMENT);
|
846
|
+
}
|
847
|
+
return _this6.hot.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_ADD_COMMENT);
|
848
|
+
},
|
849
|
+
callback: function callback() {
|
850
|
+
return _this6.onContextMenuAddComment();
|
851
|
+
},
|
852
|
+
disabled: function disabled() {
|
853
|
+
if (!isThereAnySelectedCellToProcess()) {
|
854
|
+
return true;
|
855
|
+
}
|
856
|
+
return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner());
|
857
|
+
}
|
858
|
+
}, {
|
859
|
+
key: 'commentsRemove',
|
860
|
+
name: function name() {
|
861
|
+
return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_REMOVE_COMMENT);
|
862
|
+
},
|
863
|
+
callback: function callback() {
|
864
|
+
return _this6.onContextMenuRemoveComment();
|
865
|
+
},
|
866
|
+
disabled: function disabled() {
|
867
|
+
if (!isThereAnySelectedCellToProcess()) {
|
868
|
+
return true;
|
869
|
+
}
|
870
|
+
return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner());
|
871
|
+
}
|
872
|
+
}, {
|
873
|
+
key: 'commentsReadOnly',
|
874
|
+
name: function name() {
|
875
|
+
var _this7 = this;
|
876
|
+
var label = this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_READ_ONLY_COMMENT);
|
877
|
+
var hasProperty = checkSelectionConsistency(this.getSelectedRangeLast(), function (row, col) {
|
878
|
+
var readOnlyProperty = _this7.getCellMeta(row, col)[META_COMMENT];
|
879
|
+
if (readOnlyProperty) {
|
880
|
+
readOnlyProperty = readOnlyProperty[META_READONLY];
|
881
|
+
}
|
882
|
+
if (readOnlyProperty) {
|
883
|
+
return true;
|
884
|
+
}
|
885
|
+
});
|
886
|
+
if (hasProperty) {
|
887
|
+
label = markLabelAsSelected(label);
|
888
|
+
}
|
889
|
+
return label;
|
890
|
+
},
|
891
|
+
callback: function callback() {
|
892
|
+
return _this6.onContextMenuMakeReadOnly();
|
893
|
+
},
|
894
|
+
disabled: function disabled() {
|
895
|
+
if (!isThereAnySelectedCellToProcess()) {
|
896
|
+
return true;
|
897
|
+
}
|
898
|
+
return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner()) || !_this6.checkSelectionCommentsConsistency();
|
899
|
+
}
|
900
|
+
});
|
945
901
|
}
|
946
902
|
|
947
903
|
/**
|
@@ -959,29 +915,17 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
959
915
|
}
|
960
916
|
}
|
961
917
|
|
962
|
-
/**
|
963
|
-
* Gets the editors input element.
|
964
|
-
*
|
965
|
-
* @private
|
966
|
-
* @returns {HTMLTextAreaElement}
|
967
|
-
*/
|
968
|
-
}, {
|
969
|
-
key: "getEditorInputElement",
|
970
|
-
value: function getEditorInputElement() {
|
971
|
-
return _classPrivateFieldGet(this, _editor).getInputElement();
|
972
|
-
}
|
973
|
-
|
974
918
|
/**
|
975
919
|
* Destroys the plugin instance.
|
976
920
|
*/
|
977
921
|
}, {
|
978
922
|
key: "destroy",
|
979
923
|
value: function destroy() {
|
980
|
-
if (
|
981
|
-
|
924
|
+
if (this.editor) {
|
925
|
+
this.editor.destroy();
|
982
926
|
}
|
983
|
-
if (
|
984
|
-
|
927
|
+
if (this.displaySwitch) {
|
928
|
+
this.displaySwitch.destroy();
|
985
929
|
}
|
986
930
|
_get(_getPrototypeOf(Comments.prototype), "destroy", this).call(this);
|
987
931
|
}
|