handsontable 0.0.0-next-3d099da-20231208 → 0.0.0-next-51d3397-20231211
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/calculator/index.js +11 -6
- package/3rdparty/walkontable/src/calculator/index.mjs +5 -3
- package/3rdparty/walkontable/src/calculator/renderAllColumns.js +50 -0
- package/3rdparty/walkontable/src/calculator/renderAllColumns.mjs +46 -0
- package/3rdparty/walkontable/src/calculator/renderAllRows.js +50 -0
- package/3rdparty/walkontable/src/calculator/renderAllRows.mjs +46 -0
- package/3rdparty/walkontable/src/calculator/viewportColumns.js +1 -122
- package/3rdparty/walkontable/src/calculator/viewportColumns.mjs +2 -124
- package/3rdparty/walkontable/src/calculator/viewportRows.js +1 -1
- package/3rdparty/walkontable/src/calculator/viewportRows.mjs +2 -3
- package/3rdparty/walkontable/src/core/_base.js +0 -12
- package/3rdparty/walkontable/src/core/_base.mjs +0 -12
- package/3rdparty/walkontable/src/core/core.js +0 -2
- package/3rdparty/walkontable/src/core/core.mjs +0 -2
- package/3rdparty/walkontable/src/facade/core.js +0 -9
- package/3rdparty/walkontable/src/facade/core.mjs +0 -9
- package/3rdparty/walkontable/src/index.js +3 -4
- package/3rdparty/walkontable/src/index.mjs +1 -2
- package/3rdparty/walkontable/src/overlays.js +0 -3
- package/3rdparty/walkontable/src/overlays.mjs +0 -4
- package/3rdparty/walkontable/src/renderer/colGroup.js +10 -0
- package/3rdparty/walkontable/src/renderer/colGroup.mjs +10 -0
- package/3rdparty/walkontable/src/renderer/rows.js +4 -3
- package/3rdparty/walkontable/src/renderer/rows.mjs +4 -3
- package/3rdparty/walkontable/src/selection/manager.js +0 -1
- package/3rdparty/walkontable/src/selection/manager.mjs +0 -1
- package/3rdparty/walkontable/src/settings.js +3 -0
- package/3rdparty/walkontable/src/settings.mjs +2 -0
- package/3rdparty/walkontable/src/table.js +0 -1
- package/3rdparty/walkontable/src/table.mjs +0 -1
- package/3rdparty/walkontable/src/utils/column.js +27 -12
- package/3rdparty/walkontable/src/utils/column.mjs +27 -12
- package/3rdparty/walkontable/src/utils/columnStretching.js +219 -0
- package/3rdparty/walkontable/src/utils/columnStretching.mjs +215 -0
- package/3rdparty/walkontable/src/viewport.js +22 -17
- package/3rdparty/walkontable/src/viewport.mjs +23 -18
- package/base.js +4 -2
- package/base.mjs +2 -2
- package/core/focusCatcher/index.js +44 -6
- package/core/focusCatcher/index.mjs +44 -6
- package/core.js +0 -11
- package/core.mjs +0 -11
- package/dataMap/dataMap.js +1 -0
- package/dataMap/metaManager/metaSchema.js +28 -2
- package/dataMap/metaManager/metaSchema.mjs +28 -2
- package/dataMap/metaManager/mods/extendMetaProperties.js +12 -0
- package/dataMap/metaManager/mods/extendMetaProperties.mjs +12 -0
- package/dist/handsontable.css +2 -2
- package/dist/handsontable.full.css +3 -3
- package/dist/handsontable.full.js +3979 -5577
- package/dist/handsontable.full.min.css +3 -3
- package/dist/handsontable.full.min.js +66 -71
- package/dist/handsontable.js +3058 -4305
- package/dist/handsontable.min.css +2 -2
- package/dist/handsontable.min.js +35 -39
- package/editorManager.js +3 -4
- package/editorManager.mjs +3 -4
- package/editors/autocompleteEditor/autocompleteEditor.js +0 -2
- package/editors/autocompleteEditor/autocompleteEditor.mjs +0 -2
- package/editors/dateEditor/dateEditor.d.ts +1 -1
- package/editors/dateEditor/dateEditor.js +4 -1
- package/editors/dateEditor/dateEditor.mjs +4 -1
- package/editors/handsontableEditor/handsontableEditor.js +0 -1
- package/editors/handsontableEditor/handsontableEditor.mjs +0 -1
- package/editors/textEditor/textEditor.js +0 -4
- package/editors/textEditor/textEditor.mjs +0 -4
- package/helpers/browser.js +5 -2
- package/helpers/browser.mjs +5 -2
- package/helpers/feature.js +10 -0
- package/helpers/feature.mjs +9 -0
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/package.json +3 -4
- package/pluginHooks.d.ts +6 -29
- package/pluginHooks.js +65 -123
- package/pluginHooks.mjs +62 -122
- package/plugins/copyPaste/clipboardData.js +18 -0
- package/plugins/copyPaste/clipboardData.mjs +14 -0
- package/plugins/copyPaste/copyPaste.js +129 -51
- package/plugins/copyPaste/copyPaste.mjs +132 -54
- package/plugins/copyPaste/copyableRanges.js +43 -7
- package/plugins/copyPaste/copyableRanges.mjs +42 -7
- package/plugins/copyPaste/pasteEvent.mjs +1 -1
- package/plugins/customBorders/customBorders.js +0 -5
- package/plugins/customBorders/customBorders.mjs +0 -5
- package/plugins/customBorders/utils.js +0 -1
- package/plugins/customBorders/utils.mjs +0 -1
- package/plugins/filters/ui/radioInput.js +1 -1
- package/plugins/filters/ui/radioInput.mjs +1 -1
- package/plugins/formulas/formulas.js +0 -2
- package/plugins/formulas/formulas.mjs +0 -2
- package/plugins/formulas/indexSyncer/axisSyncer.js +0 -1
- package/plugins/formulas/indexSyncer/axisSyncer.mjs +0 -1
- package/plugins/manualColumnResize/manualColumnResize.js +0 -1
- package/plugins/manualColumnResize/manualColumnResize.mjs +0 -1
- package/plugins/mergeCells/mergeCells.js +1 -127
- package/plugins/mergeCells/mergeCells.mjs +1 -127
- package/plugins/nestedHeaders/nestedHeaders.js +41 -87
- package/plugins/nestedHeaders/nestedHeaders.mjs +42 -88
- package/plugins/nestedHeaders/stateManager/headersTree.js +0 -1
- package/plugins/nestedHeaders/stateManager/headersTree.mjs +0 -1
- package/plugins/undoRedo/undoRedo.js +0 -2
- package/plugins/undoRedo/undoRedo.mjs +0 -2
- package/renderers/autocompleteRenderer/autocompleteRenderer.js +0 -1
- package/renderers/autocompleteRenderer/autocompleteRenderer.mjs +0 -1
- package/renderers/checkboxRenderer/checkboxRenderer.js +0 -2
- package/renderers/checkboxRenderer/checkboxRenderer.mjs +0 -2
- package/selection/highlight/highlight.js +0 -1
- package/selection/highlight/highlight.mjs +0 -1
- package/selection/index.js +1 -3
- package/selection/index.mjs +2 -2
- package/selection/utils.js +0 -34
- package/selection/utils.mjs +0 -33
- package/settings.d.ts +2 -1
- package/tableView.js +1 -2
- package/tableView.mjs +1 -2
- package/translations/indexMapper.js +2 -1
- package/utils/parseTable.js +84 -538
- package/utils/parseTable.mjs +83 -534
- package/validators/timeValidator/timeValidator.js +0 -1
- package/validators/timeValidator/timeValidator.mjs +0 -1
- package/plugins/copyPaste/clipboardData/clipboardData.js +0 -588
- package/plugins/copyPaste/clipboardData/clipboardData.mjs +0 -584
- package/plugins/copyPaste/clipboardData/copyClipboardData.js +0 -69
- package/plugins/copyPaste/clipboardData/copyClipboardData.mjs +0 -65
- package/plugins/copyPaste/clipboardData/index.js +0 -9
- package/plugins/copyPaste/clipboardData/index.mjs +0 -4
- package/plugins/copyPaste/clipboardData/pasteClipboardData.js +0 -81
- package/plugins/copyPaste/clipboardData/pasteClipboardData.mjs +0 -77
@@ -14,7 +14,8 @@ function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!priva
|
|
14
14
|
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; } }
|
15
15
|
import { BasePlugin } from "../base/index.mjs";
|
16
16
|
import Hooks from "../../pluginHooks.mjs";
|
17
|
-
import { stringify } from "../../3rdparty/SheetClip/index.mjs";
|
17
|
+
import { stringify, parse } from "../../3rdparty/SheetClip/index.mjs";
|
18
|
+
import { arrayEach } from "../../helpers/array.mjs";
|
18
19
|
import { sanitize } from "../../helpers/string.mjs";
|
19
20
|
import { removeContentEditableFromElementAndDeselect, runWithSelectedContendEditableElement, makeElementContentEditableAndSelectItsContent } from "../../helpers/dom/element.mjs";
|
20
21
|
import { isSafari } from "../../helpers/browser.mjs";
|
@@ -23,11 +24,9 @@ import copyColumnHeadersOnlyItem from "./contextMenuItem/copyColumnHeadersOnly.m
|
|
23
24
|
import copyWithColumnGroupHeadersItem from "./contextMenuItem/copyWithColumnGroupHeaders.mjs";
|
24
25
|
import copyWithColumnHeadersItem from "./contextMenuItem/copyWithColumnHeaders.mjs";
|
25
26
|
import cutItem from "./contextMenuItem/cut.mjs";
|
26
|
-
import
|
27
|
-
import {
|
28
|
-
import {
|
29
|
-
import EventManager from "../../eventManager.mjs";
|
30
|
-
import { CopyClipboardData, PasteClipboardData, META_HEAD } from "./clipboardData/index.mjs";
|
27
|
+
import PasteEvent from "./pasteEvent.mjs";
|
28
|
+
import { CopyableRangesFactory, normalizeRanges } from "./copyableRanges.mjs";
|
29
|
+
import { _dataToHTML, htmlToGridSettings } from "../../utils/parseTable.mjs";
|
31
30
|
Hooks.getSingleton().register('afterCopyLimit');
|
32
31
|
Hooks.getSingleton().register('modifyCopyableRange');
|
33
32
|
Hooks.getSingleton().register('beforeCut');
|
@@ -39,6 +38,7 @@ Hooks.getSingleton().register('afterCopy');
|
|
39
38
|
export const PLUGIN_KEY = 'copyPaste';
|
40
39
|
export const PLUGIN_PRIORITY = 80;
|
41
40
|
const SETTING_KEYS = ['fragmentSelection'];
|
41
|
+
const META_HEAD = ['<meta name="generator" content="Handsontable"/>', '<style type="text/css">td{white-space:normal}br{mso-data-placement:same-cell}</style>'].join('');
|
42
42
|
|
43
43
|
/* eslint-disable jsdoc/require-description-complete-sentence */
|
44
44
|
/**
|
@@ -82,10 +82,13 @@ var _copyMode = /*#__PURE__*/new WeakMap();
|
|
82
82
|
var _isTriggeredByCopy = /*#__PURE__*/new WeakMap();
|
83
83
|
var _isTriggeredByCut = /*#__PURE__*/new WeakMap();
|
84
84
|
var _copyableRangesFactory = /*#__PURE__*/new WeakMap();
|
85
|
+
var _preventViewportScrollOnPaste = /*#__PURE__*/new WeakMap();
|
85
86
|
var _ensureClipboardEventsGetTriggered = /*#__PURE__*/new WeakSet();
|
87
|
+
var _countCopiedHeaders = /*#__PURE__*/new WeakSet();
|
86
88
|
var _addContentEditableToHighlightedCell = /*#__PURE__*/new WeakSet();
|
87
89
|
var _removeContentEditableFromHighlightedCell = /*#__PURE__*/new WeakSet();
|
88
90
|
var _onAfterContextMenuDefaultOptions = /*#__PURE__*/new WeakSet();
|
91
|
+
var _onAfterSelection = /*#__PURE__*/new WeakSet();
|
89
92
|
var _onAfterSelectionEnd = /*#__PURE__*/new WeakSet();
|
90
93
|
var _onSafariMouseEnter = /*#__PURE__*/new WeakSet();
|
91
94
|
var _onSafariMouseLeave = /*#__PURE__*/new WeakSet();
|
@@ -95,32 +98,35 @@ export class CopyPaste extends BasePlugin {
|
|
95
98
|
super(...arguments);
|
96
99
|
/**
|
97
100
|
* `afterSelection` hook callback triggered only on Safari.
|
98
|
-
*
|
99
|
-
* @private
|
100
101
|
*/
|
101
102
|
_classPrivateMethodInitSpec(this, _onSafariAfterSelection);
|
102
103
|
/**
|
103
104
|
* `document.body` `mouseleave` callback used to work around a Safari's problem with copying/cutting from the
|
104
105
|
* browser's menu.
|
105
|
-
*
|
106
|
-
* @private
|
107
106
|
*/
|
108
107
|
_classPrivateMethodInitSpec(this, _onSafariMouseLeave);
|
109
108
|
/**
|
110
109
|
* `document.body` `mouseenter` callback used to work around a Safari's problem with copying/cutting from the
|
111
110
|
* browser's menu.
|
112
|
-
*
|
113
|
-
* @private
|
114
111
|
*/
|
115
112
|
_classPrivateMethodInitSpec(this, _onSafariMouseEnter);
|
116
113
|
/**
|
117
114
|
* Force focus on focusableElement after end of the selection.
|
118
115
|
*/
|
119
116
|
_classPrivateMethodInitSpec(this, _onAfterSelectionEnd);
|
117
|
+
/**
|
118
|
+
* Disables the viewport scroll after pasting the data.
|
119
|
+
*
|
120
|
+
* @param {number} fromRow Selection start row visual index.
|
121
|
+
* @param {number} fromColumn Selection start column visual index.
|
122
|
+
* @param {number} toRow Selection end row visual index.
|
123
|
+
* @param {number} toColumn Selection end column visual index.
|
124
|
+
* @param {object} preventScrolling Object with `value` property. If `true`, the viewport scroll will be prevented.
|
125
|
+
*/
|
126
|
+
_classPrivateMethodInitSpec(this, _onAfterSelection);
|
120
127
|
/**
|
121
128
|
* Add copy and cut options to the Context Menu.
|
122
129
|
*
|
123
|
-
* @private
|
124
130
|
* @param {object} options Contains default added options of the Context Menu.
|
125
131
|
*/
|
126
132
|
_classPrivateMethodInitSpec(this, _onAfterContextMenuDefaultOptions);
|
@@ -132,6 +138,15 @@ export class CopyPaste extends BasePlugin {
|
|
132
138
|
* Add the `contenteditable` attribute to the highlighted cell and select its content.
|
133
139
|
*/
|
134
140
|
_classPrivateMethodInitSpec(this, _addContentEditableToHighlightedCell);
|
141
|
+
/**
|
142
|
+
* Counts how many column headers will be copied based on the passed range.
|
143
|
+
*
|
144
|
+
* @private
|
145
|
+
* @param {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>} ranges Array of objects with properties `startRow`, `startCol`, `endRow` and `endCol`.
|
146
|
+
* @returns {{ columnHeadersCount: number }} Returns an object with keys that holds
|
147
|
+
* information with the number of copied headers.
|
148
|
+
*/
|
149
|
+
_classPrivateMethodInitSpec(this, _countCopiedHeaders);
|
135
150
|
/**
|
136
151
|
* Ensure that the `copy`/`cut` events get triggered properly in Safari.
|
137
152
|
*
|
@@ -248,6 +263,15 @@ export class CopyPaste extends BasePlugin {
|
|
248
263
|
countColumnHeaders: () => this.hot.view.getColumnHeadersCount()
|
249
264
|
})
|
250
265
|
});
|
266
|
+
/**
|
267
|
+
* Flag that indicates if the viewport scroll should be prevented after pasting the data.
|
268
|
+
*
|
269
|
+
* @type {boolean}
|
270
|
+
*/
|
271
|
+
_classPrivateFieldInitSpec(this, _preventViewportScrollOnPaste, {
|
272
|
+
writable: true,
|
273
|
+
value: false
|
274
|
+
});
|
251
275
|
/**
|
252
276
|
* Ranges of the cells coordinates, which should be used to copy/cut/paste actions.
|
253
277
|
*
|
@@ -299,8 +323,13 @@ export class CopyPaste extends BasePlugin {
|
|
299
323
|
this.uiContainer = (_settings$uiContainer = settings.uiContainer) !== null && _settings$uiContainer !== void 0 ? _settings$uiContainer : this.uiContainer;
|
300
324
|
}
|
301
325
|
this.addHook('afterContextMenuDefaultOptions', options => _classPrivateMethodGet(this, _onAfterContextMenuDefaultOptions, _onAfterContextMenuDefaultOptions2).call(this, options));
|
326
|
+
this.addHook('afterSelection', function () {
|
327
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
328
|
+
args[_key] = arguments[_key];
|
329
|
+
}
|
330
|
+
return _classPrivateMethodGet(_this, _onAfterSelection, _onAfterSelection2).call(_this, ...args);
|
331
|
+
});
|
302
332
|
this.addHook('afterSelectionEnd', () => _classPrivateMethodGet(this, _onAfterSelectionEnd, _onAfterSelectionEnd2).call(this));
|
303
|
-
this.eventManager = new EventManager(this);
|
304
333
|
this.eventManager.addEventListener(this.hot.rootDocument, 'copy', function () {
|
305
334
|
return _this.onCopy(...arguments);
|
306
335
|
});
|
@@ -314,14 +343,14 @@ export class CopyPaste extends BasePlugin {
|
|
314
343
|
// Without this workaround Safari (tested on Safari@16.5.2) does allow copying/cutting from the browser menu.
|
315
344
|
if (isSafari()) {
|
316
345
|
this.eventManager.addEventListener(this.hot.rootDocument.body, 'mouseenter', function () {
|
317
|
-
for (var
|
318
|
-
args[
|
346
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
347
|
+
args[_key2] = arguments[_key2];
|
319
348
|
}
|
320
349
|
return _classPrivateMethodGet(_this, _onSafariMouseEnter, _onSafariMouseEnter2).call(_this, ...args);
|
321
350
|
});
|
322
351
|
this.eventManager.addEventListener(this.hot.rootDocument.body, 'mouseleave', function () {
|
323
|
-
for (var
|
324
|
-
args[
|
352
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
353
|
+
args[_key3] = arguments[_key3];
|
325
354
|
}
|
326
355
|
return _classPrivateMethodGet(_this, _onSafariMouseLeave, _onSafariMouseLeave2).call(_this, ...args);
|
327
356
|
});
|
@@ -422,14 +451,26 @@ export class CopyPaste extends BasePlugin {
|
|
422
451
|
* @returns {Array[]} An array of arrays that will be copied to the clipboard.
|
423
452
|
*/
|
424
453
|
getRangedData(ranges) {
|
454
|
+
const data = [];
|
425
455
|
const {
|
426
456
|
rows,
|
427
457
|
columns
|
428
|
-
} =
|
429
|
-
|
430
|
-
|
431
|
-
|
458
|
+
} = normalizeRanges(ranges);
|
459
|
+
|
460
|
+
// concatenate all rows and columns data defined in ranges into one copyable string
|
461
|
+
arrayEach(rows, row => {
|
462
|
+
const rowSet = [];
|
463
|
+
arrayEach(columns, column => {
|
464
|
+
if (row < 0) {
|
465
|
+
// `row` as the second argument acts here as the `headerLevel` argument
|
466
|
+
rowSet.push(this.hot.getColHeader(column, row));
|
467
|
+
} else {
|
468
|
+
rowSet.push(this.hot.getCopyableData(row, column));
|
469
|
+
}
|
470
|
+
});
|
471
|
+
data.push(rowSet);
|
432
472
|
});
|
473
|
+
return data;
|
433
474
|
}
|
434
475
|
|
435
476
|
/**
|
@@ -446,17 +487,7 @@ export class CopyPaste extends BasePlugin {
|
|
446
487
|
if (!pastableText && !pastableHtml) {
|
447
488
|
return;
|
448
489
|
}
|
449
|
-
const pasteData =
|
450
|
-
clipboardData: {
|
451
|
-
data: {},
|
452
|
-
setData(type, value) {
|
453
|
-
this.data[type] = value;
|
454
|
-
},
|
455
|
-
getData(type) {
|
456
|
-
return this.data[type];
|
457
|
-
}
|
458
|
-
}
|
459
|
-
};
|
490
|
+
const pasteData = new PasteEvent();
|
460
491
|
if (pastableText) {
|
461
492
|
pasteData.clipboardData.setData('text/plain', pastableText);
|
462
493
|
}
|
@@ -589,6 +620,7 @@ export class CopyPaste extends BasePlugin {
|
|
589
620
|
}
|
590
621
|
newRows.push(newRow);
|
591
622
|
}
|
623
|
+
_classPrivateFieldSet(this, _preventViewportScrollOnPaste, true);
|
592
624
|
this.hot.populateFromArray(startRow, startColumn, newRows, undefined, undefined, 'CopyPaste.paste', this.pasteMode);
|
593
625
|
return [startRow, startColumn, lastVisualRow, lastVisualColumn];
|
594
626
|
}
|
@@ -604,12 +636,19 @@ export class CopyPaste extends BasePlugin {
|
|
604
636
|
}
|
605
637
|
this.setCopyableText();
|
606
638
|
_classPrivateFieldSet(this, _isTriggeredByCopy, false);
|
607
|
-
const
|
608
|
-
const
|
639
|
+
const data = this.getRangedData(this.copyableRanges);
|
640
|
+
const copiedHeadersCount = _classPrivateMethodGet(this, _countCopiedHeaders, _countCopiedHeaders2).call(this, this.copyableRanges);
|
641
|
+
const allowCopying = !!this.hot.runHooks('beforeCopy', data, this.copyableRanges, copiedHeadersCount);
|
609
642
|
if (allowCopying) {
|
610
|
-
|
611
|
-
|
612
|
-
|
643
|
+
const textPlain = stringify(data);
|
644
|
+
if (event && event.clipboardData) {
|
645
|
+
const textHTML = _dataToHTML(data, this.hot.rootDocument);
|
646
|
+
event.clipboardData.setData('text/plain', textPlain);
|
647
|
+
event.clipboardData.setData('text/html', [META_HEAD, textHTML].join(''));
|
648
|
+
} else if (typeof ClipboardEvent === 'undefined') {
|
649
|
+
this.hot.rootWindow.clipboardData.setData('Text', textPlain);
|
650
|
+
}
|
651
|
+
this.hot.runHooks('afterCopy', data, this.copyableRanges, copiedHeadersCount);
|
613
652
|
}
|
614
653
|
_classPrivateFieldSet(this, _copyMode, 'cells-only');
|
615
654
|
event.preventDefault();
|
@@ -627,13 +666,19 @@ export class CopyPaste extends BasePlugin {
|
|
627
666
|
}
|
628
667
|
this.setCopyableText();
|
629
668
|
_classPrivateFieldSet(this, _isTriggeredByCut, false);
|
630
|
-
const
|
631
|
-
const allowCuttingOut = !!this.hot.runHooks('beforeCut',
|
669
|
+
const rangedData = this.getRangedData(this.copyableRanges);
|
670
|
+
const allowCuttingOut = !!this.hot.runHooks('beforeCut', rangedData, this.copyableRanges);
|
632
671
|
if (allowCuttingOut) {
|
633
|
-
|
634
|
-
|
672
|
+
const textPlain = stringify(rangedData);
|
673
|
+
if (event && event.clipboardData) {
|
674
|
+
const textHTML = _dataToHTML(rangedData, this.hot.rootDocument);
|
675
|
+
event.clipboardData.setData('text/plain', textPlain);
|
676
|
+
event.clipboardData.setData('text/html', [META_HEAD, textHTML].join(''));
|
677
|
+
} else if (typeof ClipboardEvent === 'undefined') {
|
678
|
+
this.hot.rootWindow.clipboardData.setData('Text', textPlain);
|
679
|
+
}
|
635
680
|
this.hot.emptySelectedCells('CopyPaste.cut');
|
636
|
-
this.hot.runHooks('afterCut',
|
681
|
+
this.hot.runHooks('afterCut', rangedData, this.copyableRanges);
|
637
682
|
}
|
638
683
|
event.preventDefault();
|
639
684
|
}
|
@@ -651,22 +696,34 @@ export class CopyPaste extends BasePlugin {
|
|
651
696
|
if (event && event.preventDefault) {
|
652
697
|
event.preventDefault();
|
653
698
|
}
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
699
|
+
let pastedData;
|
700
|
+
if (event && typeof event.clipboardData !== 'undefined') {
|
701
|
+
const textHTML = sanitize(event.clipboardData.getData('text/html'), {
|
702
|
+
ADD_TAGS: ['meta'],
|
703
|
+
ADD_ATTR: ['content'],
|
704
|
+
FORCE_BODY: true
|
705
|
+
});
|
706
|
+
if (textHTML && /(<table)|(<TABLE)/g.test(textHTML)) {
|
707
|
+
const parsedConfig = htmlToGridSettings(textHTML, this.hot.rootDocument);
|
708
|
+
pastedData = parsedConfig.data;
|
709
|
+
} else {
|
710
|
+
pastedData = event.clipboardData.getData('text/plain');
|
711
|
+
}
|
712
|
+
} else if (typeof ClipboardEvent === 'undefined' && typeof this.hot.rootWindow.clipboardData !== 'undefined') {
|
713
|
+
pastedData = this.hot.rootWindow.clipboardData.getData('Text');
|
714
|
+
}
|
715
|
+
if (typeof pastedData === 'string') {
|
716
|
+
pastedData = parse(pastedData);
|
717
|
+
}
|
718
|
+
if (pastedData === void 0 || pastedData && pastedData.length === 0) {
|
661
719
|
return;
|
662
720
|
}
|
663
|
-
|
664
|
-
if (pastedTable.length === 0) {
|
721
|
+
if (this.hot.runHooks('beforePaste', pastedData, this.copyableRanges) === false) {
|
665
722
|
return;
|
666
723
|
}
|
667
|
-
const [startRow, startColumn, endRow, endColumn] = this.populateValues(
|
724
|
+
const [startRow, startColumn, endRow, endColumn] = this.populateValues(pastedData);
|
668
725
|
this.hot.selectCell(startRow, startColumn, Math.min(this.hot.countRows() - 1, endRow), Math.min(this.hot.countCols() - 1, endColumn));
|
669
|
-
this.hot.runHooks('afterPaste',
|
726
|
+
this.hot.runHooks('afterPaste', pastedData, this.copyableRanges);
|
670
727
|
}
|
671
728
|
/**
|
672
729
|
* Destroys the `CopyPaste` plugin instance.
|
@@ -695,6 +752,21 @@ function _ensureClipboardEventsGetTriggered2(eventName) {
|
|
695
752
|
this.hot.rootDocument.execCommand(eventName);
|
696
753
|
}
|
697
754
|
}
|
755
|
+
function _countCopiedHeaders2(ranges) {
|
756
|
+
const {
|
757
|
+
rows
|
758
|
+
} = normalizeRanges(ranges);
|
759
|
+
let columnHeadersCount = 0;
|
760
|
+
for (let row = 0; row < rows.length; row++) {
|
761
|
+
if (rows[row] >= 0) {
|
762
|
+
break;
|
763
|
+
}
|
764
|
+
columnHeadersCount += 1;
|
765
|
+
}
|
766
|
+
return {
|
767
|
+
columnHeadersCount
|
768
|
+
};
|
769
|
+
}
|
698
770
|
function _addContentEditableToHighlightedCell2() {
|
699
771
|
if (this.hot.isListening()) {
|
700
772
|
const lastSelectedRange = this.hot.getSelectedRangeLast();
|
@@ -741,6 +813,12 @@ function _onAfterContextMenuDefaultOptions2(options) {
|
|
741
813
|
}
|
742
814
|
options.items.push(cutItem(this));
|
743
815
|
}
|
816
|
+
function _onAfterSelection2(fromRow, fromColumn, toRow, toColumn, preventScrolling) {
|
817
|
+
if (_classPrivateFieldGet(this, _preventViewportScrollOnPaste)) {
|
818
|
+
preventScrolling.value = true;
|
819
|
+
}
|
820
|
+
_classPrivateFieldSet(this, _preventViewportScrollOnPaste, false);
|
821
|
+
}
|
744
822
|
function _onAfterSelectionEnd2() {
|
745
823
|
if (this.isEditorOpened()) {
|
746
824
|
return;
|
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
exports.__esModule = true;
|
4
|
+
exports.normalizeRanges = normalizeRanges;
|
5
|
+
require("core-js/modules/es.array.push.js");
|
4
6
|
require("core-js/modules/es.error.cause.js");
|
7
|
+
var _array = require("../../helpers/array");
|
8
|
+
var _number = require("../../helpers/number");
|
5
9
|
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
6
10
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
7
11
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
@@ -11,6 +15,13 @@ function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) {
|
|
11
15
|
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
|
12
16
|
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
13
17
|
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; } }
|
18
|
+
/**
|
19
|
+
* The utils class produces the selection ranges in the `{startRow, startCol, endRow, endCol}` format
|
20
|
+
* based on the current table selection. The CopyPaste plugin consumes that ranges to generate
|
21
|
+
* appropriate data ready to copy to the clipboard.
|
22
|
+
*
|
23
|
+
* @private
|
24
|
+
*/
|
14
25
|
var _selectedRange = /*#__PURE__*/new WeakMap();
|
15
26
|
var _countRows = /*#__PURE__*/new WeakMap();
|
16
27
|
var _countColumns = /*#__PURE__*/new WeakMap();
|
@@ -19,13 +30,6 @@ var _columnsLimit = /*#__PURE__*/new WeakMap();
|
|
19
30
|
var _countColumnHeaders = /*#__PURE__*/new WeakMap();
|
20
31
|
var _trimColumnsRange = /*#__PURE__*/new WeakSet();
|
21
32
|
var _trimRowsRange = /*#__PURE__*/new WeakSet();
|
22
|
-
/**
|
23
|
-
* The utils class produces the selection ranges in the `{startRow, startCol, endRow, endCol}` format
|
24
|
-
* based on the current table selection. The CopyPaste plugin consumes that ranges to generate
|
25
|
-
* appropriate data ready to copy to the clipboard.
|
26
|
-
*
|
27
|
-
* @private
|
28
|
-
*/
|
29
33
|
class CopyableRangesFactory {
|
30
34
|
/* eslint-disable jsdoc/require-description-complete-sentence */
|
31
35
|
/**
|
@@ -204,10 +208,42 @@ class CopyableRangesFactory {
|
|
204
208
|
};
|
205
209
|
}
|
206
210
|
}
|
211
|
+
|
212
|
+
/**
|
213
|
+
* Returns an object with `rows` and `columns` keys. The arrays contains sorted indexes
|
214
|
+
* generated according to the given `ranges` array.
|
215
|
+
*
|
216
|
+
* @param {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>} ranges The range to process.
|
217
|
+
* @returns {{rows: number[], columns: number[]}}
|
218
|
+
*/
|
207
219
|
exports.CopyableRangesFactory = CopyableRangesFactory;
|
208
220
|
function _trimColumnsRange2(startColumn, endColumn) {
|
209
221
|
return Math.min(endColumn, Math.max(startColumn + _classPrivateFieldGet(this, _columnsLimit).call(this) - 1, startColumn));
|
210
222
|
}
|
211
223
|
function _trimRowsRange2(startRow, endRow) {
|
212
224
|
return Math.min(endRow, Math.max(startRow + _classPrivateFieldGet(this, _rowsLimit).call(this) - 1, startRow));
|
225
|
+
}
|
226
|
+
function normalizeRanges(ranges) {
|
227
|
+
const rows = [];
|
228
|
+
const columns = [];
|
229
|
+
(0, _array.arrayEach)(ranges, range => {
|
230
|
+
const minRow = Math.min(range.startRow, range.endRow);
|
231
|
+
const maxRow = Math.max(range.startRow, range.endRow);
|
232
|
+
(0, _number.rangeEach)(minRow, maxRow, row => {
|
233
|
+
if (rows.indexOf(row) === -1) {
|
234
|
+
rows.push(row);
|
235
|
+
}
|
236
|
+
});
|
237
|
+
const minColumn = Math.min(range.startCol, range.endCol);
|
238
|
+
const maxColumn = Math.max(range.startCol, range.endCol);
|
239
|
+
(0, _number.rangeEach)(minColumn, maxColumn, column => {
|
240
|
+
if (columns.indexOf(column) === -1) {
|
241
|
+
columns.push(column);
|
242
|
+
}
|
243
|
+
});
|
244
|
+
});
|
245
|
+
return {
|
246
|
+
rows,
|
247
|
+
columns
|
248
|
+
};
|
213
249
|
}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import "core-js/modules/es.array.push.js";
|
1
2
|
import "core-js/modules/es.error.cause.js";
|
2
3
|
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
3
4
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
@@ -8,6 +9,15 @@ function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) {
|
|
8
9
|
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
|
9
10
|
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
10
11
|
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; } }
|
12
|
+
import { arrayEach } from "../../helpers/array.mjs";
|
13
|
+
import { rangeEach } from "../../helpers/number.mjs";
|
14
|
+
/**
|
15
|
+
* The utils class produces the selection ranges in the `{startRow, startCol, endRow, endCol}` format
|
16
|
+
* based on the current table selection. The CopyPaste plugin consumes that ranges to generate
|
17
|
+
* appropriate data ready to copy to the clipboard.
|
18
|
+
*
|
19
|
+
* @private
|
20
|
+
*/
|
11
21
|
var _selectedRange = /*#__PURE__*/new WeakMap();
|
12
22
|
var _countRows = /*#__PURE__*/new WeakMap();
|
13
23
|
var _countColumns = /*#__PURE__*/new WeakMap();
|
@@ -16,13 +26,6 @@ var _columnsLimit = /*#__PURE__*/new WeakMap();
|
|
16
26
|
var _countColumnHeaders = /*#__PURE__*/new WeakMap();
|
17
27
|
var _trimColumnsRange = /*#__PURE__*/new WeakSet();
|
18
28
|
var _trimRowsRange = /*#__PURE__*/new WeakSet();
|
19
|
-
/**
|
20
|
-
* The utils class produces the selection ranges in the `{startRow, startCol, endRow, endCol}` format
|
21
|
-
* based on the current table selection. The CopyPaste plugin consumes that ranges to generate
|
22
|
-
* appropriate data ready to copy to the clipboard.
|
23
|
-
*
|
24
|
-
* @private
|
25
|
-
*/
|
26
29
|
export class CopyableRangesFactory {
|
27
30
|
/* eslint-disable jsdoc/require-description-complete-sentence */
|
28
31
|
/**
|
@@ -201,9 +204,41 @@ export class CopyableRangesFactory {
|
|
201
204
|
};
|
202
205
|
}
|
203
206
|
}
|
207
|
+
|
208
|
+
/**
|
209
|
+
* Returns an object with `rows` and `columns` keys. The arrays contains sorted indexes
|
210
|
+
* generated according to the given `ranges` array.
|
211
|
+
*
|
212
|
+
* @param {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>} ranges The range to process.
|
213
|
+
* @returns {{rows: number[], columns: number[]}}
|
214
|
+
*/
|
204
215
|
function _trimColumnsRange2(startColumn, endColumn) {
|
205
216
|
return Math.min(endColumn, Math.max(startColumn + _classPrivateFieldGet(this, _columnsLimit).call(this) - 1, startColumn));
|
206
217
|
}
|
207
218
|
function _trimRowsRange2(startRow, endRow) {
|
208
219
|
return Math.min(endRow, Math.max(startRow + _classPrivateFieldGet(this, _rowsLimit).call(this) - 1, startRow));
|
220
|
+
}
|
221
|
+
export function normalizeRanges(ranges) {
|
222
|
+
const rows = [];
|
223
|
+
const columns = [];
|
224
|
+
arrayEach(ranges, range => {
|
225
|
+
const minRow = Math.min(range.startRow, range.endRow);
|
226
|
+
const maxRow = Math.max(range.startRow, range.endRow);
|
227
|
+
rangeEach(minRow, maxRow, row => {
|
228
|
+
if (rows.indexOf(row) === -1) {
|
229
|
+
rows.push(row);
|
230
|
+
}
|
231
|
+
});
|
232
|
+
const minColumn = Math.min(range.startCol, range.endCol);
|
233
|
+
const maxColumn = Math.max(range.startCol, range.endCol);
|
234
|
+
rangeEach(minColumn, maxColumn, column => {
|
235
|
+
if (columns.indexOf(column) === -1) {
|
236
|
+
columns.push(column);
|
237
|
+
}
|
238
|
+
});
|
239
|
+
});
|
240
|
+
return {
|
241
|
+
rows,
|
242
|
+
columns
|
243
|
+
};
|
209
244
|
}
|
@@ -323,7 +323,6 @@ class CustomBorders extends _base.BasePlugin {
|
|
323
323
|
}
|
324
324
|
});
|
325
325
|
}
|
326
|
-
|
327
326
|
this.hot.setCellMeta(row, column, 'borders', (0, _utils.denormalizeBorder)(border));
|
328
327
|
this.insertBorderIntoSettings(border, place);
|
329
328
|
}
|
@@ -608,7 +607,6 @@ class CustomBorders extends _base.BasePlugin {
|
|
608
607
|
}
|
609
608
|
});
|
610
609
|
}
|
611
|
-
|
612
610
|
return check;
|
613
611
|
}
|
614
612
|
|
@@ -631,12 +629,10 @@ class CustomBorders extends _base.BasePlugin {
|
|
631
629
|
(0, _array.arrayEach)(borders, borderObject => {
|
632
630
|
borderObject.toggleHiddenClass(place, remove); // TODO this also bad?
|
633
631
|
});
|
634
|
-
|
635
632
|
check = true;
|
636
633
|
return false; // breaks forAll
|
637
634
|
}
|
638
635
|
});
|
639
|
-
|
640
636
|
return check;
|
641
637
|
}
|
642
638
|
|
@@ -672,7 +668,6 @@ class CustomBorders extends _base.BasePlugin {
|
|
672
668
|
}
|
673
669
|
});
|
674
670
|
}
|
675
|
-
|
676
671
|
return check;
|
677
672
|
}
|
678
673
|
|
@@ -318,7 +318,6 @@ export class CustomBorders extends BasePlugin {
|
|
318
318
|
}
|
319
319
|
});
|
320
320
|
}
|
321
|
-
|
322
321
|
this.hot.setCellMeta(row, column, 'borders', denormalizeBorder(border));
|
323
322
|
this.insertBorderIntoSettings(border, place);
|
324
323
|
}
|
@@ -603,7 +602,6 @@ export class CustomBorders extends BasePlugin {
|
|
603
602
|
}
|
604
603
|
});
|
605
604
|
}
|
606
|
-
|
607
605
|
return check;
|
608
606
|
}
|
609
607
|
|
@@ -626,12 +624,10 @@ export class CustomBorders extends BasePlugin {
|
|
626
624
|
arrayEach(borders, borderObject => {
|
627
625
|
borderObject.toggleHiddenClass(place, remove); // TODO this also bad?
|
628
626
|
});
|
629
|
-
|
630
627
|
check = true;
|
631
628
|
return false; // breaks forAll
|
632
629
|
}
|
633
630
|
});
|
634
|
-
|
635
631
|
return check;
|
636
632
|
}
|
637
633
|
|
@@ -667,7 +663,6 @@ export class CustomBorders extends BasePlugin {
|
|
667
663
|
}
|
668
664
|
});
|
669
665
|
}
|
670
|
-
|
671
666
|
return check;
|
672
667
|
}
|
673
668
|
|
@@ -1189,7 +1189,6 @@ function _onBeforeCreateRow2(visualRow, amount) {
|
|
1189
1189
|
if (visualRow >= this.hot.countRows()) {
|
1190
1190
|
hfRowIndex = visualRow; // Row beyond the table boundaries.
|
1191
1191
|
}
|
1192
|
-
|
1193
1192
|
if (this.sheetId === null || !this.engine.doesSheetExist(this.sheetName) || !this.engine.isItPossibleToAddRows(this.sheetId, [hfRowIndex, amount])) {
|
1194
1193
|
return false;
|
1195
1194
|
}
|
@@ -1199,7 +1198,6 @@ function _onBeforeCreateCol2(visualColumn, amount) {
|
|
1199
1198
|
if (visualColumn >= this.hot.countCols()) {
|
1200
1199
|
hfColumnIndex = visualColumn; // Column beyond the table boundaries.
|
1201
1200
|
}
|
1202
|
-
|
1203
1201
|
if (this.sheetId === null || !this.engine.doesSheetExist(this.sheetName) || !this.engine.isItPossibleToAddColumns(this.sheetId, [hfColumnIndex, amount])) {
|
1204
1202
|
return false;
|
1205
1203
|
}
|
@@ -1184,7 +1184,6 @@ function _onBeforeCreateRow2(visualRow, amount) {
|
|
1184
1184
|
if (visualRow >= this.hot.countRows()) {
|
1185
1185
|
hfRowIndex = visualRow; // Row beyond the table boundaries.
|
1186
1186
|
}
|
1187
|
-
|
1188
1187
|
if (this.sheetId === null || !this.engine.doesSheetExist(this.sheetName) || !this.engine.isItPossibleToAddRows(this.sheetId, [hfRowIndex, amount])) {
|
1189
1188
|
return false;
|
1190
1189
|
}
|
@@ -1194,7 +1193,6 @@ function _onBeforeCreateCol2(visualColumn, amount) {
|
|
1194
1193
|
if (visualColumn >= this.hot.countCols()) {
|
1195
1194
|
hfColumnIndex = visualColumn; // Column beyond the table boundaries.
|
1196
1195
|
}
|
1197
|
-
|
1198
1196
|
if (this.sheetId === null || !this.engine.doesSheetExist(this.sheetName) || !this.engine.isItPossibleToAddColumns(this.sheetId, [hfColumnIndex, amount])) {
|
1199
1197
|
return false;
|
1200
1198
|
}
|
@@ -192,7 +192,6 @@ class AxisSyncer {
|
|
192
192
|
var _notMovedElements$fin;
|
193
193
|
return (_notMovedElements$fin = notMovedElements[finalHfIndex]) !== null && _notMovedElements$fin !== void 0 ? _notMovedElements$fin : 0; // Moving before the first dataset's element.
|
194
194
|
}
|
195
|
-
|
196
195
|
return notMovedElements[finalHfIndex - 1] + 1; // Moving before another element.
|
197
196
|
}
|
198
197
|
|
@@ -189,7 +189,6 @@ class AxisSyncer {
|
|
189
189
|
var _notMovedElements$fin;
|
190
190
|
return (_notMovedElements$fin = notMovedElements[finalHfIndex]) !== null && _notMovedElements$fin !== void 0 ? _notMovedElements$fin : 0; // Moving before the first dataset's element.
|
191
191
|
}
|
192
|
-
|
193
192
|
return notMovedElements[finalHfIndex - 1] + 1; // Moving before another element.
|
194
193
|
}
|
195
194
|
|