handsontable 0.0.0-next-820d8a2-20221122 → 0.0.0-next-6812ce6-20221122
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/3rdparty/walkontable/src/cell/range.js +8 -0
- package/3rdparty/walkontable/src/cell/range.mjs +8 -0
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/core.d.ts +1 -1
- package/core.js +37 -29
- package/core.mjs +37 -29
- package/dist/handsontable.css +2 -2
- package/dist/handsontable.full.css +2 -2
- package/dist/handsontable.full.js +3135 -2444
- package/dist/handsontable.full.min.css +2 -2
- package/dist/handsontable.full.min.js +62 -62
- package/dist/handsontable.js +2563 -1872
- package/dist/handsontable.min.css +2 -2
- package/dist/handsontable.min.js +3 -3
- package/dist/languages/all.js +1 -1
- package/dist/languages/all.min.js +1 -1
- package/dist/languages/en-US.js +1 -1
- package/dist/languages/en-US.min.js +1 -1
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/i18n/constants.js +49 -42
- package/i18n/constants.mjs +45 -41
- package/i18n/languages/en-US.js +1 -1
- package/i18n/languages/en-US.mjs +1 -1
- package/languages/all.js +1 -1
- package/languages/en-US.js +1 -1
- package/languages/en-US.mjs +1 -1
- package/languages/index.js +1 -1
- package/package.json +1 -1
- package/pluginHooks.d.ts +7 -2
- package/pluginHooks.js +23 -3
- package/pluginHooks.mjs +23 -3
- package/plugins/contextMenu/contextMenu.d.ts +4 -3
- package/plugins/copyPaste/contextMenuItem/copy.js +4 -16
- package/plugins/copyPaste/contextMenuItem/copy.mjs +4 -4
- package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.js +35 -0
- package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.mjs +31 -0
- package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.js +35 -0
- package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.mjs +31 -0
- package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.js +35 -0
- package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.mjs +31 -0
- package/plugins/copyPaste/copyPaste.d.ts +10 -2
- package/plugins/copyPaste/copyPaste.js +263 -173
- package/plugins/copyPaste/copyPaste.mjs +263 -173
- package/plugins/copyPaste/copyableRanges.js +260 -0
- package/plugins/copyPaste/copyableRanges.mjs +255 -0
- package/plugins/nestedHeaders/nestedHeaders.js +114 -11
- package/plugins/nestedHeaders/nestedHeaders.mjs +114 -11
- package/plugins/nestedHeaders/stateManager/headersTree.js +1 -0
- package/plugins/nestedHeaders/stateManager/headersTree.mjs +1 -0
- package/plugins/nestedHeaders/stateManager/index.js +21 -10
- package/plugins/nestedHeaders/stateManager/index.mjs +21 -10
- package/selection/selection.js +2 -1
- package/selection/selection.mjs +2 -1
- package/tableView.js +133 -63
- package/tableView.mjs +133 -63
@@ -10,29 +10,35 @@ require("core-js/modules/es.symbol.description.js");
|
|
10
10
|
require("core-js/modules/es.symbol.iterator.js");
|
11
11
|
require("core-js/modules/es.array.slice.js");
|
12
12
|
require("core-js/modules/es.function.name.js");
|
13
|
-
require("core-js/modules/es.array.from.js");
|
14
13
|
exports.__esModule = true;
|
15
14
|
exports.PLUGIN_PRIORITY = exports.PLUGIN_KEY = exports.CopyPaste = void 0;
|
15
|
+
require("core-js/modules/es.array.join.js");
|
16
|
+
require("core-js/modules/es.array.concat.js");
|
16
17
|
require("core-js/modules/es.array.iterator.js");
|
18
|
+
require("core-js/modules/es.map.js");
|
17
19
|
require("core-js/modules/es.object.to-string.js");
|
18
20
|
require("core-js/modules/es.string.iterator.js");
|
19
|
-
require("core-js/modules/es.weak-map.js");
|
20
21
|
require("core-js/modules/web.dom-collections.iterator.js");
|
21
|
-
require("core-js/modules/es.array.
|
22
|
-
require("core-js/modules/es.array.
|
22
|
+
require("core-js/modules/es.array.map.js");
|
23
|
+
require("core-js/modules/es.array.filter.js");
|
24
|
+
require("core-js/modules/es.array.from.js");
|
23
25
|
require("core-js/modules/es.regexp.exec.js");
|
24
|
-
require("core-js/modules/es.
|
26
|
+
require("core-js/modules/es.weak-map.js");
|
27
|
+
require("core-js/modules/es.weak-set.js");
|
25
28
|
var _base = require("../base");
|
26
29
|
var _pluginHooks = _interopRequireDefault(require("../../pluginHooks"));
|
27
30
|
var _SheetClip = require("../../3rdparty/SheetClip");
|
28
31
|
var _array = require("../../helpers/array");
|
29
|
-
var _number = require("../../helpers/number");
|
30
32
|
var _string = require("../../helpers/string");
|
31
33
|
var _element = require("../../helpers/dom/element");
|
32
34
|
var _copy = _interopRequireDefault(require("./contextMenuItem/copy"));
|
35
|
+
var _copyColumnHeadersOnly = _interopRequireDefault(require("./contextMenuItem/copyColumnHeadersOnly"));
|
36
|
+
var _copyWithColumnGroupHeaders = _interopRequireDefault(require("./contextMenuItem/copyWithColumnGroupHeaders"));
|
37
|
+
var _copyWithColumnHeaders = _interopRequireDefault(require("./contextMenuItem/copyWithColumnHeaders"));
|
33
38
|
var _cut = _interopRequireDefault(require("./contextMenuItem/cut"));
|
34
39
|
var _pasteEvent = _interopRequireDefault(require("./pasteEvent"));
|
35
40
|
var _focusableElement = require("./focusableElement");
|
41
|
+
var _copyableRanges = require("./copyableRanges");
|
36
42
|
var _parseTable = require("../../utils/parseTable");
|
37
43
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
38
44
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
@@ -54,6 +60,16 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
54
60
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
55
61
|
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; } }
|
56
62
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
63
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
64
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
65
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
66
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
67
|
+
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
68
|
+
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
69
|
+
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
70
|
+
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
|
71
|
+
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
72
|
+
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; } }
|
57
73
|
_pluginHooks.default.getSingleton().register('afterCopyLimit');
|
58
74
|
_pluginHooks.default.getSingleton().register('modifyCopyableRange');
|
59
75
|
_pluginHooks.default.getSingleton().register('beforeCut');
|
@@ -67,9 +83,6 @@ exports.PLUGIN_KEY = PLUGIN_KEY;
|
|
67
83
|
var PLUGIN_PRIORITY = 80;
|
68
84
|
exports.PLUGIN_PRIORITY = PLUGIN_PRIORITY;
|
69
85
|
var SETTING_KEYS = ['fragmentSelection'];
|
70
|
-
var ROWS_LIMIT = Infinity;
|
71
|
-
var COLUMNS_LIMIT = Infinity;
|
72
|
-
var privatePool = new WeakMap();
|
73
86
|
var META_HEAD = ['<meta name="generator" content="Handsontable"/>', '<style type="text/css">td{white-space:normal}br{mso-data-placement:same-cell}</style>'].join('');
|
74
87
|
|
75
88
|
/* eslint-disable jsdoc/require-description-complete-sentence */
|
@@ -85,6 +98,9 @@ var META_HEAD = ['<meta name="generator" content="Handsontable"/>', '<style type
|
|
85
98
|
* * `'columnsLimit'` (see {@link CopyPaste#columnsLimit})
|
86
99
|
* * `'rowsLimit'` (see {@link CopyPaste#rowsLimit})
|
87
100
|
* * `'pasteMode'` (see {@link CopyPaste#pasteMode})
|
101
|
+
* * `'copyColumnHeaders'`
|
102
|
+
* * `'copyColumnGroupHeaders'`
|
103
|
+
* * `'copyColumnHeadersOnly'`
|
88
104
|
* * `'uiContainer'` (see {@link CopyPaste#uiContainer}).
|
89
105
|
*
|
90
106
|
* See [the copy/paste demo](@/guides/cell-features/clipboard.md) for examples.
|
@@ -98,82 +114,96 @@ var META_HEAD = ['<meta name="generator" content="Handsontable"/>', '<style type
|
|
98
114
|
* columnsLimit: 25,
|
99
115
|
* rowsLimit: 50,
|
100
116
|
* pasteMode: 'shift_down',
|
117
|
+
* copyColumnHeaders: true,
|
118
|
+
* copyColumnGroupHeaders: true,
|
119
|
+
* copyColumnHeadersOnly: true,
|
101
120
|
* uiContainer: document.body,
|
102
121
|
* },
|
103
122
|
* ```
|
104
123
|
* @class CopyPaste
|
105
124
|
* @plugin CopyPaste
|
106
125
|
*/
|
126
|
+
var _enableCopyColumnHeaders = /*#__PURE__*/new WeakMap();
|
127
|
+
var _enableCopyColumnGroupHeaders = /*#__PURE__*/new WeakMap();
|
128
|
+
var _enableCopyColumnHeadersOnly = /*#__PURE__*/new WeakMap();
|
129
|
+
var _copyMode = /*#__PURE__*/new WeakMap();
|
130
|
+
var _isTriggeredByCopy = /*#__PURE__*/new WeakMap();
|
131
|
+
var _isTriggeredByCut = /*#__PURE__*/new WeakMap();
|
132
|
+
var _copyableRangesFactory = /*#__PURE__*/new WeakMap();
|
133
|
+
var _countCopiedHeaders = /*#__PURE__*/new WeakSet();
|
107
134
|
var CopyPaste = /*#__PURE__*/function (_BasePlugin) {
|
108
135
|
_inherits(CopyPaste, _BasePlugin);
|
109
136
|
var _super = _createSuper(CopyPaste);
|
110
|
-
function CopyPaste(
|
137
|
+
function CopyPaste() {
|
111
138
|
var _this;
|
112
139
|
_classCallCheck(this, CopyPaste);
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
_this
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
_this
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
140
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
141
|
+
args[_key] = arguments[_key];
|
142
|
+
}
|
143
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
144
|
+
_classPrivateMethodInitSpec(_assertThisInitialized(_this), _countCopiedHeaders);
|
145
|
+
_defineProperty(_assertThisInitialized(_this), "columnsLimit", Infinity);
|
146
|
+
_defineProperty(_assertThisInitialized(_this), "rowsLimit", Infinity);
|
147
|
+
_defineProperty(_assertThisInitialized(_this), "pasteMode", 'overwrite');
|
148
|
+
_defineProperty(_assertThisInitialized(_this), "uiContainer", _this.hot.rootDocument.body);
|
149
|
+
_classPrivateFieldInitSpec(_assertThisInitialized(_this), _enableCopyColumnHeaders, {
|
150
|
+
writable: true,
|
151
|
+
value: false
|
152
|
+
});
|
153
|
+
_classPrivateFieldInitSpec(_assertThisInitialized(_this), _enableCopyColumnGroupHeaders, {
|
154
|
+
writable: true,
|
155
|
+
value: false
|
156
|
+
});
|
157
|
+
_classPrivateFieldInitSpec(_assertThisInitialized(_this), _enableCopyColumnHeadersOnly, {
|
158
|
+
writable: true,
|
159
|
+
value: false
|
160
|
+
});
|
161
|
+
_classPrivateFieldInitSpec(_assertThisInitialized(_this), _copyMode, {
|
162
|
+
writable: true,
|
163
|
+
value: 'cells-only'
|
164
|
+
});
|
165
|
+
_classPrivateFieldInitSpec(_assertThisInitialized(_this), _isTriggeredByCopy, {
|
166
|
+
writable: true,
|
167
|
+
value: false
|
168
|
+
});
|
169
|
+
_classPrivateFieldInitSpec(_assertThisInitialized(_this), _isTriggeredByCut, {
|
170
|
+
writable: true,
|
171
|
+
value: false
|
172
|
+
});
|
173
|
+
_classPrivateFieldInitSpec(_assertThisInitialized(_this), _copyableRangesFactory, {
|
174
|
+
writable: true,
|
175
|
+
value: new _copyableRanges.CopyableRangesFactory({
|
176
|
+
countRows: function countRows() {
|
177
|
+
return _this.hot.countRows();
|
178
|
+
},
|
179
|
+
countColumns: function countColumns() {
|
180
|
+
return _this.hot.countCols();
|
181
|
+
},
|
182
|
+
rowsLimit: function rowsLimit() {
|
183
|
+
return _this.rowsLimit;
|
184
|
+
},
|
185
|
+
columnsLimit: function columnsLimit() {
|
186
|
+
return _this.columnsLimit;
|
187
|
+
},
|
188
|
+
countColumnHeaders: function countColumnHeaders() {
|
189
|
+
return _this.hot.view.getColumnHeadersCount();
|
190
|
+
}
|
191
|
+
})
|
164
192
|
});
|
193
|
+
_defineProperty(_assertThisInitialized(_this), "copyableRanges", []);
|
194
|
+
_defineProperty(_assertThisInitialized(_this), "focusableElement", void 0);
|
165
195
|
return _this;
|
166
196
|
}
|
167
|
-
|
168
|
-
/**
|
169
|
-
* Checks if the plugin is enabled in the handsontable settings. This method is executed in {@link Hooks#beforeInit}
|
170
|
-
* hook and if it returns `true` then the {@link CopyPaste#enablePlugin} method is called.
|
171
|
-
*
|
172
|
-
* @returns {boolean}
|
173
|
-
*/
|
174
197
|
_createClass(CopyPaste, [{
|
175
198
|
key: "isEnabled",
|
176
|
-
value:
|
199
|
+
value:
|
200
|
+
/**
|
201
|
+
* Checks if the plugin is enabled in the handsontable settings. This method is executed in {@link Hooks#beforeInit}
|
202
|
+
* hook and if it returns `true` then the {@link CopyPaste#enablePlugin} method is called.
|
203
|
+
*
|
204
|
+
* @returns {boolean}
|
205
|
+
*/
|
206
|
+
function isEnabled() {
|
177
207
|
return !!this.hot.getSettings()[PLUGIN_KEY];
|
178
208
|
}
|
179
209
|
|
@@ -188,15 +218,16 @@ var CopyPaste = /*#__PURE__*/function (_BasePlugin) {
|
|
188
218
|
return;
|
189
219
|
}
|
190
220
|
var _this$hot$getSettings = this.hot.getSettings(),
|
191
|
-
settings = _this$hot$getSettings[PLUGIN_KEY]
|
192
|
-
fragmentSelection = _this$hot$getSettings.fragmentSelection;
|
193
|
-
var priv = privatePool.get(this);
|
194
|
-
priv.isFragmentSelectionEnabled = !!fragmentSelection;
|
221
|
+
settings = _this$hot$getSettings[PLUGIN_KEY];
|
195
222
|
if (_typeof(settings) === 'object') {
|
196
|
-
|
223
|
+
var _settings$pasteMode, _settings$uiContainer;
|
224
|
+
this.pasteMode = (_settings$pasteMode = settings.pasteMode) !== null && _settings$pasteMode !== void 0 ? _settings$pasteMode : this.pasteMode;
|
197
225
|
this.rowsLimit = isNaN(settings.rowsLimit) ? this.rowsLimit : settings.rowsLimit;
|
198
226
|
this.columnsLimit = isNaN(settings.columnsLimit) ? this.columnsLimit : settings.columnsLimit;
|
199
|
-
this
|
227
|
+
_classPrivateFieldSet(this, _enableCopyColumnHeaders, !!settings.copyColumnHeaders);
|
228
|
+
_classPrivateFieldSet(this, _enableCopyColumnGroupHeaders, !!settings.copyColumnGroupHeaders);
|
229
|
+
_classPrivateFieldSet(this, _enableCopyColumnHeadersOnly, !!settings.copyColumnHeadersOnly);
|
230
|
+
this.uiContainer = (_settings$uiContainer = settings.uiContainer) !== null && _settings$uiContainer !== void 0 ? _settings$uiContainer : this.uiContainer;
|
200
231
|
}
|
201
232
|
this.addHook('afterContextMenuDefaultOptions', function (options) {
|
202
233
|
return _this2.onAfterContextMenuDefaultOptions(options);
|
@@ -250,105 +281,110 @@ var CopyPaste = /*#__PURE__*/function (_BasePlugin) {
|
|
250
281
|
}
|
251
282
|
|
252
283
|
/**
|
253
|
-
* Copies the selected cell into the clipboard.
|
284
|
+
* Copies the selected cell with or without column headers into the clipboard.
|
285
|
+
*
|
286
|
+
* @param {'cells-only' | 'column-headers-only' | 'with-all-column-headers' | 'with-column-headers'} [copyMode='cells-only']
|
287
|
+
* Defines the data range to copy. Possible values: `cells-only` (copy selected cells only),
|
288
|
+
* `column-headers-only` (copy the most-bottom column headers only), `with-all-column-headers` (copy cells
|
289
|
+
* with all column headers levels) or `with-column-headers` (copy cells with the most-bottom column headers).
|
254
290
|
*/
|
255
291
|
}, {
|
256
292
|
key: "copy",
|
257
293
|
value: function copy() {
|
258
|
-
var
|
259
|
-
|
294
|
+
var copyMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'cells-only';
|
295
|
+
_classPrivateFieldSet(this, _copyMode, copyMode);
|
296
|
+
_classPrivateFieldSet(this, _isTriggeredByCopy, true);
|
260
297
|
this.getOrCreateFocusableElement();
|
261
298
|
this.focusableElement.focus();
|
262
299
|
this.hot.rootDocument.execCommand('copy');
|
263
300
|
}
|
264
301
|
|
302
|
+
/**
|
303
|
+
* Copies the selected cell/cells into the clipboard.
|
304
|
+
*/
|
305
|
+
}, {
|
306
|
+
key: "copyCellsOnly",
|
307
|
+
value: function copyCellsOnly() {
|
308
|
+
this.copy('cells-only');
|
309
|
+
}
|
310
|
+
/**
|
311
|
+
* Copies only the most-bottom column headers into the clipboard.
|
312
|
+
*/
|
313
|
+
}, {
|
314
|
+
key: "copyColumnHeadersOnly",
|
315
|
+
value: function copyColumnHeadersOnly() {
|
316
|
+
this.copy('column-headers-only');
|
317
|
+
}
|
318
|
+
/**
|
319
|
+
* Copies the selected cell/cells and all column headers levels (including column group) into the clipboard.
|
320
|
+
*/
|
321
|
+
}, {
|
322
|
+
key: "copyWithAllColumnHeaders",
|
323
|
+
value: function copyWithAllColumnHeaders() {
|
324
|
+
this.copy('with-column-group-headers');
|
325
|
+
}
|
326
|
+
/**
|
327
|
+
* Copies the selected cell/cells and most-bottom column headers into the clipboard.
|
328
|
+
*/
|
329
|
+
}, {
|
330
|
+
key: "copyWithColumnHeaders",
|
331
|
+
value: function copyWithColumnHeaders() {
|
332
|
+
this.copy('with-column-headers');
|
333
|
+
}
|
334
|
+
|
265
335
|
/**
|
266
336
|
* Cuts the selected cell into the clipboard.
|
267
337
|
*/
|
268
338
|
}, {
|
269
339
|
key: "cut",
|
270
340
|
value: function cut() {
|
271
|
-
|
272
|
-
priv.isTriggeredByCut = true;
|
341
|
+
_classPrivateFieldSet(this, _isTriggeredByCut, true);
|
273
342
|
this.getOrCreateFocusableElement();
|
274
343
|
this.focusableElement.focus();
|
275
344
|
this.hot.rootDocument.execCommand('cut');
|
276
345
|
}
|
277
346
|
|
278
347
|
/**
|
279
|
-
* Creates copyable text
|
348
|
+
* Creates copyable text related to range objects.
|
280
349
|
*
|
281
|
-
* @param {
|
350
|
+
* @param {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>} ranges Array of objects with properties `startRow`, `endRow`, `startCol` and `endCol`.
|
282
351
|
* @returns {string} Returns string which will be copied into clipboard.
|
283
352
|
*/
|
284
353
|
}, {
|
285
354
|
key: "getRangedCopyableData",
|
286
355
|
value: function getRangedCopyableData(ranges) {
|
287
|
-
|
288
|
-
var dataSet = [];
|
289
|
-
var copyableRows = [];
|
290
|
-
var copyableColumns = [];
|
291
|
-
|
292
|
-
// Count all copyable rows and columns
|
293
|
-
(0, _array.arrayEach)(ranges, function (range) {
|
294
|
-
(0, _number.rangeEach)(range.startRow, range.endRow, function (row) {
|
295
|
-
if (copyableRows.indexOf(row) === -1) {
|
296
|
-
copyableRows.push(row);
|
297
|
-
}
|
298
|
-
});
|
299
|
-
(0, _number.rangeEach)(range.startCol, range.endCol, function (column) {
|
300
|
-
if (copyableColumns.indexOf(column) === -1) {
|
301
|
-
copyableColumns.push(column);
|
302
|
-
}
|
303
|
-
});
|
304
|
-
});
|
305
|
-
// Concat all rows and columns data defined in ranges into one copyable string
|
306
|
-
(0, _array.arrayEach)(copyableRows, function (row) {
|
307
|
-
var rowSet = [];
|
308
|
-
(0, _array.arrayEach)(copyableColumns, function (column) {
|
309
|
-
rowSet.push(_this3.hot.getCopyableData(row, column));
|
310
|
-
});
|
311
|
-
dataSet.push(rowSet);
|
312
|
-
});
|
313
|
-
return (0, _SheetClip.stringify)(dataSet);
|
356
|
+
return (0, _SheetClip.stringify)(this.getRangedData(ranges));
|
314
357
|
}
|
315
358
|
|
316
359
|
/**
|
317
|
-
* Creates copyable text
|
360
|
+
* Creates copyable text related to range objects.
|
318
361
|
*
|
319
|
-
* @param {
|
362
|
+
* @param {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>} ranges Array of objects with properties `startRow`, `startCol`, `endRow` and `endCol`.
|
320
363
|
* @returns {Array[]} Returns array of arrays which will be copied into clipboard.
|
321
364
|
*/
|
322
365
|
}, {
|
323
366
|
key: "getRangedData",
|
324
367
|
value: function getRangedData(ranges) {
|
325
|
-
var
|
326
|
-
var
|
327
|
-
var
|
328
|
-
|
368
|
+
var _this3 = this;
|
369
|
+
var data = [];
|
370
|
+
var _normalizeRanges = (0, _copyableRanges.normalizeRanges)(ranges),
|
371
|
+
rows = _normalizeRanges.rows,
|
372
|
+
columns = _normalizeRanges.columns;
|
329
373
|
|
330
|
-
// Count all copyable rows and columns
|
331
|
-
(0, _array.arrayEach)(ranges, function (range) {
|
332
|
-
(0, _number.rangeEach)(range.startRow, range.endRow, function (row) {
|
333
|
-
if (copyableRows.indexOf(row) === -1) {
|
334
|
-
copyableRows.push(row);
|
335
|
-
}
|
336
|
-
});
|
337
|
-
(0, _number.rangeEach)(range.startCol, range.endCol, function (column) {
|
338
|
-
if (copyableColumns.indexOf(column) === -1) {
|
339
|
-
copyableColumns.push(column);
|
340
|
-
}
|
341
|
-
});
|
342
|
-
});
|
343
374
|
// Concat all rows and columns data defined in ranges into one copyable string
|
344
|
-
(0, _array.arrayEach)(
|
375
|
+
(0, _array.arrayEach)(rows, function (row) {
|
345
376
|
var rowSet = [];
|
346
|
-
(0, _array.arrayEach)(
|
347
|
-
|
377
|
+
(0, _array.arrayEach)(columns, function (column) {
|
378
|
+
if (row < 0) {
|
379
|
+
// 'row' as the second argument act here as 'headerLevel' argument
|
380
|
+
rowSet.push(_this3.hot.getColHeader(column, row));
|
381
|
+
} else {
|
382
|
+
rowSet.push(_this3.hot.getCopyableData(row, column));
|
383
|
+
}
|
348
384
|
});
|
349
|
-
|
385
|
+
data.push(rowSet);
|
350
386
|
});
|
351
|
-
return
|
387
|
+
return data;
|
352
388
|
}
|
353
389
|
|
354
390
|
/**
|
@@ -384,27 +420,43 @@ var CopyPaste = /*#__PURE__*/function (_BasePlugin) {
|
|
384
420
|
}, {
|
385
421
|
key: "setCopyableText",
|
386
422
|
value: function setCopyableText() {
|
387
|
-
var
|
388
|
-
if (!
|
423
|
+
var selectionRange = this.hot.getSelectedRangeLast();
|
424
|
+
if (!selectionRange) {
|
389
425
|
return;
|
390
426
|
}
|
391
|
-
|
392
|
-
var
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
427
|
+
_classPrivateFieldGet(this, _copyableRangesFactory).setSelectedRange(selectionRange);
|
428
|
+
var groupedRanges = new Map([['headers', null], ['cells', null]]);
|
429
|
+
if (_classPrivateFieldGet(this, _copyMode) === 'column-headers-only') {
|
430
|
+
groupedRanges.set('headers', _classPrivateFieldGet(this, _copyableRangesFactory).getMostBottomColumnHeadersRange());
|
431
|
+
} else {
|
432
|
+
if (_classPrivateFieldGet(this, _copyMode) === 'with-column-headers') {
|
433
|
+
groupedRanges.set('headers', _classPrivateFieldGet(this, _copyableRangesFactory).getMostBottomColumnHeadersRange());
|
434
|
+
} else if (_classPrivateFieldGet(this, _copyMode) === 'with-column-group-headers') {
|
435
|
+
groupedRanges.set('headers', _classPrivateFieldGet(this, _copyableRangesFactory).getAllColumnHeadersRange());
|
436
|
+
}
|
437
|
+
groupedRanges.set('cells', _classPrivateFieldGet(this, _copyableRangesFactory).getCellsRange());
|
438
|
+
}
|
439
|
+
this.copyableRanges = Array.from(groupedRanges.values()).filter(function (range) {
|
440
|
+
return range !== null;
|
441
|
+
}).map(function (_ref) {
|
442
|
+
var startRow = _ref.startRow,
|
443
|
+
startCol = _ref.startCol,
|
444
|
+
endRow = _ref.endRow,
|
445
|
+
endCol = _ref.endCol;
|
446
|
+
return {
|
447
|
+
startRow: startRow,
|
448
|
+
startCol: startCol,
|
449
|
+
endRow: endRow,
|
450
|
+
endCol: endCol
|
451
|
+
};
|
405
452
|
});
|
406
453
|
this.copyableRanges = this.hot.runHooks('modifyCopyableRange', this.copyableRanges);
|
407
|
-
|
454
|
+
var cellsRange = groupedRanges.get('cells');
|
455
|
+
if (cellsRange !== null && cellsRange.isRangeTrimmed) {
|
456
|
+
var startRow = cellsRange.startRow,
|
457
|
+
startCol = cellsRange.startCol,
|
458
|
+
endRow = cellsRange.endRow,
|
459
|
+
endCol = cellsRange.endCol;
|
408
460
|
this.hot.runHooks('afterCopyLimit', endRow - startRow + 1, endCol - startCol + 1, this.rowsLimit, this.columnsLimit);
|
409
461
|
}
|
410
462
|
}
|
@@ -417,8 +469,8 @@ var CopyPaste = /*#__PURE__*/function (_BasePlugin) {
|
|
417
469
|
}, {
|
418
470
|
key: "getOrCreateFocusableElement",
|
419
471
|
value: function getOrCreateFocusableElement() {
|
420
|
-
var
|
421
|
-
var editableElement =
|
472
|
+
var _this$hot$getActiveEd;
|
473
|
+
var editableElement = (_this$hot$getActiveEd = this.hot.getActiveEditor()) === null || _this$hot$getActiveEd === void 0 ? void 0 : _this$hot$getActiveEd.TEXTAREA;
|
422
474
|
if (editableElement) {
|
423
475
|
this.focusableElement.setFocusableElement(editableElement);
|
424
476
|
} else {
|
@@ -435,10 +487,21 @@ var CopyPaste = /*#__PURE__*/function (_BasePlugin) {
|
|
435
487
|
}, {
|
436
488
|
key: "isEditorOpened",
|
437
489
|
value: function isEditorOpened() {
|
438
|
-
var
|
439
|
-
return
|
490
|
+
var _this$hot$getActiveEd2;
|
491
|
+
return (_this$hot$getActiveEd2 = this.hot.getActiveEditor()) === null || _this$hot$getActiveEd2 === void 0 ? void 0 : _this$hot$getActiveEd2.isOpened();
|
440
492
|
}
|
441
493
|
|
494
|
+
/**
|
495
|
+
* Counts how many column headers will be copied based on the passed range.
|
496
|
+
*
|
497
|
+
* @private
|
498
|
+
* @param {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>} ranges Array of objects with properties `startRow`, `startCol`, `endRow` and `endCol`.
|
499
|
+
* @returns {{ columnHeadersCount: number }} Returns an object with keys that holds
|
500
|
+
* information with the number of copied headers.
|
501
|
+
*/
|
502
|
+
}, {
|
503
|
+
key: "populateValues",
|
504
|
+
value:
|
442
505
|
/**
|
443
506
|
* Prepares new values to populate them into datasource.
|
444
507
|
*
|
@@ -447,9 +510,7 @@ var CopyPaste = /*#__PURE__*/function (_BasePlugin) {
|
|
447
510
|
* @param {Array} [selection] The selection which indicates from what position the data will be populated.
|
448
511
|
* @returns {Array} Range coordinates after populate data.
|
449
512
|
*/
|
450
|
-
|
451
|
-
key: "populateValues",
|
452
|
-
value: function populateValues(inputArray) {
|
513
|
+
function populateValues(inputArray) {
|
453
514
|
var selection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.hot.getSelectedRangeLast();
|
454
515
|
if (!inputArray.length) {
|
455
516
|
return;
|
@@ -512,25 +573,26 @@ var CopyPaste = /*#__PURE__*/function (_BasePlugin) {
|
|
512
573
|
}, {
|
513
574
|
key: "onCopy",
|
514
575
|
value: function onCopy(event) {
|
515
|
-
|
516
|
-
if (!this.hot.isListening() && !priv.isTriggeredByCopy || this.isEditorOpened()) {
|
576
|
+
if (!this.hot.isListening() && !_classPrivateFieldGet(this, _isTriggeredByCopy) || this.isEditorOpened()) {
|
517
577
|
return;
|
518
578
|
}
|
519
579
|
this.setCopyableText();
|
520
|
-
|
521
|
-
var
|
522
|
-
var
|
580
|
+
_classPrivateFieldSet(this, _isTriggeredByCopy, false);
|
581
|
+
var data = this.getRangedData(this.copyableRanges);
|
582
|
+
var copiedHeadersCount = _classPrivateMethodGet(this, _countCopiedHeaders, _countCopiedHeaders2).call(this, this.copyableRanges);
|
583
|
+
var allowCopying = !!this.hot.runHooks('beforeCopy', data, this.copyableRanges, copiedHeadersCount);
|
523
584
|
if (allowCopying) {
|
524
|
-
var textPlain = (0, _SheetClip.stringify)(
|
585
|
+
var textPlain = (0, _SheetClip.stringify)(data);
|
525
586
|
if (event && event.clipboardData) {
|
526
|
-
var textHTML = (0, _parseTable._dataToHTML)(
|
587
|
+
var textHTML = (0, _parseTable._dataToHTML)(data, this.hot.rootDocument);
|
527
588
|
event.clipboardData.setData('text/plain', textPlain);
|
528
589
|
event.clipboardData.setData('text/html', [META_HEAD, textHTML].join(''));
|
529
590
|
} else if (typeof ClipboardEvent === 'undefined') {
|
530
591
|
this.hot.rootWindow.clipboardData.setData('Text', textPlain);
|
531
592
|
}
|
532
|
-
this.hot.runHooks('afterCopy',
|
593
|
+
this.hot.runHooks('afterCopy', data, this.copyableRanges, copiedHeadersCount);
|
533
594
|
}
|
595
|
+
_classPrivateFieldSet(this, _copyMode, 'cells-only');
|
534
596
|
event.preventDefault();
|
535
597
|
}
|
536
598
|
|
@@ -543,12 +605,11 @@ var CopyPaste = /*#__PURE__*/function (_BasePlugin) {
|
|
543
605
|
}, {
|
544
606
|
key: "onCut",
|
545
607
|
value: function onCut(event) {
|
546
|
-
|
547
|
-
if (!this.hot.isListening() && !priv.isTriggeredByCut || this.isEditorOpened()) {
|
608
|
+
if (!this.hot.isListening() && !_classPrivateFieldGet(this, _isTriggeredByCut) || this.isEditorOpened()) {
|
548
609
|
return;
|
549
610
|
}
|
550
611
|
this.setCopyableText();
|
551
|
-
|
612
|
+
_classPrivateFieldSet(this, _isTriggeredByCut, false);
|
552
613
|
var rangedData = this.getRangedData(this.copyableRanges);
|
553
614
|
var allowCuttingOut = !!this.hot.runHooks('beforeCut', rangedData, this.copyableRanges);
|
554
615
|
if (allowCuttingOut) {
|
@@ -627,7 +688,17 @@ var CopyPaste = /*#__PURE__*/function (_BasePlugin) {
|
|
627
688
|
value: function onAfterContextMenuDefaultOptions(options) {
|
628
689
|
options.items.push({
|
629
690
|
name: '---------'
|
630
|
-
}, (0, _copy.default)(this)
|
691
|
+
}, (0, _copy.default)(this));
|
692
|
+
if (_classPrivateFieldGet(this, _enableCopyColumnHeaders)) {
|
693
|
+
options.items.push((0, _copyWithColumnHeaders.default)(this));
|
694
|
+
}
|
695
|
+
if (_classPrivateFieldGet(this, _enableCopyColumnGroupHeaders)) {
|
696
|
+
options.items.push((0, _copyWithColumnGroupHeaders.default)(this));
|
697
|
+
}
|
698
|
+
if (_classPrivateFieldGet(this, _enableCopyColumnHeadersOnly)) {
|
699
|
+
options.items.push((0, _copyColumnHeadersOnly.default)(this));
|
700
|
+
}
|
701
|
+
options.items.push((0, _cut.default)(this));
|
631
702
|
}
|
632
703
|
|
633
704
|
/**
|
@@ -655,13 +726,11 @@ var CopyPaste = /*#__PURE__*/function (_BasePlugin) {
|
|
655
726
|
}, {
|
656
727
|
key: "onAfterSelectionEnd",
|
657
728
|
value: function onAfterSelectionEnd() {
|
658
|
-
var _privatePool$get = privatePool.get(this),
|
659
|
-
isFragmentSelectionEnabled = _privatePool$get.isFragmentSelectionEnabled;
|
660
729
|
if (this.isEditorOpened()) {
|
661
730
|
return;
|
662
731
|
}
|
663
732
|
this.getOrCreateFocusableElement();
|
664
|
-
if (
|
733
|
+
if (this.hot.getSettings().fragmentSelection && this.focusableElement.getFocusableElement() !== this.hot.rootDocument.activeElement && (0, _element.getSelectionText)()) {
|
665
734
|
return;
|
666
735
|
}
|
667
736
|
this.setCopyableText();
|
@@ -715,7 +784,28 @@ var CopyPaste = /*#__PURE__*/function (_BasePlugin) {
|
|
715
784
|
get: function get() {
|
716
785
|
return PLUGIN_PRIORITY;
|
717
786
|
}
|
787
|
+
|
788
|
+
/**
|
789
|
+
* Maximum number of columns than can be copied to clipboard using <kbd>**Ctrl**</kbd>/<kbd>**Cmd**</kbd> + <kbd>**C**</kbd>.
|
790
|
+
*
|
791
|
+
* @type {number}
|
792
|
+
* @default Infinity
|
793
|
+
*/
|
718
794
|
}]);
|
719
795
|
return CopyPaste;
|
720
796
|
}(_base.BasePlugin);
|
721
|
-
exports.CopyPaste = CopyPaste;
|
797
|
+
exports.CopyPaste = CopyPaste;
|
798
|
+
function _countCopiedHeaders2(ranges) {
|
799
|
+
var _normalizeRanges2 = (0, _copyableRanges.normalizeRanges)(ranges),
|
800
|
+
rows = _normalizeRanges2.rows;
|
801
|
+
var columnHeadersCount = 0;
|
802
|
+
for (var row = 0; row < rows.length; row++) {
|
803
|
+
if (rows[row] >= 0) {
|
804
|
+
break;
|
805
|
+
}
|
806
|
+
columnHeadersCount += 1;
|
807
|
+
}
|
808
|
+
return {
|
809
|
+
columnHeadersCount: columnHeadersCount
|
810
|
+
};
|
811
|
+
}
|