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
@@ -6,6 +6,7 @@ require("core-js/modules/es.error.cause.js");
|
|
6
6
|
var _base = require("../base");
|
7
7
|
var _pluginHooks = _interopRequireDefault(require("../../pluginHooks"));
|
8
8
|
var _SheetClip = require("../../3rdparty/SheetClip");
|
9
|
+
var _array = require("../../helpers/array");
|
9
10
|
var _string = require("../../helpers/string");
|
10
11
|
var _element = require("../../helpers/dom/element");
|
11
12
|
var _browser = require("../../helpers/browser");
|
@@ -14,11 +15,9 @@ var _copyColumnHeadersOnly = _interopRequireDefault(require("./contextMenuItem/c
|
|
14
15
|
var _copyWithColumnGroupHeaders = _interopRequireDefault(require("./contextMenuItem/copyWithColumnGroupHeaders"));
|
15
16
|
var _copyWithColumnHeaders = _interopRequireDefault(require("./contextMenuItem/copyWithColumnHeaders"));
|
16
17
|
var _cut = _interopRequireDefault(require("./contextMenuItem/cut"));
|
18
|
+
var _pasteEvent = _interopRequireDefault(require("./pasteEvent"));
|
17
19
|
var _copyableRanges = require("./copyableRanges");
|
18
|
-
var _selection = require("../../selection");
|
19
20
|
var _parseTable = require("../../utils/parseTable");
|
20
|
-
var _eventManager = _interopRequireDefault(require("../../eventManager"));
|
21
|
-
var _clipboardData = require("./clipboardData");
|
22
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23
22
|
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
24
23
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
@@ -43,6 +42,7 @@ _pluginHooks.default.getSingleton().register('afterCopy');
|
|
43
42
|
const PLUGIN_KEY = exports.PLUGIN_KEY = 'copyPaste';
|
44
43
|
const PLUGIN_PRIORITY = exports.PLUGIN_PRIORITY = 80;
|
45
44
|
const SETTING_KEYS = ['fragmentSelection'];
|
45
|
+
const META_HEAD = ['<meta name="generator" content="Handsontable"/>', '<style type="text/css">td{white-space:normal}br{mso-data-placement:same-cell}</style>'].join('');
|
46
46
|
|
47
47
|
/* eslint-disable jsdoc/require-description-complete-sentence */
|
48
48
|
/**
|
@@ -86,10 +86,13 @@ var _copyMode = /*#__PURE__*/new WeakMap();
|
|
86
86
|
var _isTriggeredByCopy = /*#__PURE__*/new WeakMap();
|
87
87
|
var _isTriggeredByCut = /*#__PURE__*/new WeakMap();
|
88
88
|
var _copyableRangesFactory = /*#__PURE__*/new WeakMap();
|
89
|
+
var _preventViewportScrollOnPaste = /*#__PURE__*/new WeakMap();
|
89
90
|
var _ensureClipboardEventsGetTriggered = /*#__PURE__*/new WeakSet();
|
91
|
+
var _countCopiedHeaders = /*#__PURE__*/new WeakSet();
|
90
92
|
var _addContentEditableToHighlightedCell = /*#__PURE__*/new WeakSet();
|
91
93
|
var _removeContentEditableFromHighlightedCell = /*#__PURE__*/new WeakSet();
|
92
94
|
var _onAfterContextMenuDefaultOptions = /*#__PURE__*/new WeakSet();
|
95
|
+
var _onAfterSelection = /*#__PURE__*/new WeakSet();
|
93
96
|
var _onAfterSelectionEnd = /*#__PURE__*/new WeakSet();
|
94
97
|
var _onSafariMouseEnter = /*#__PURE__*/new WeakSet();
|
95
98
|
var _onSafariMouseLeave = /*#__PURE__*/new WeakSet();
|
@@ -99,32 +102,35 @@ class CopyPaste extends _base.BasePlugin {
|
|
99
102
|
super(...arguments);
|
100
103
|
/**
|
101
104
|
* `afterSelection` hook callback triggered only on Safari.
|
102
|
-
*
|
103
|
-
* @private
|
104
105
|
*/
|
105
106
|
_classPrivateMethodInitSpec(this, _onSafariAfterSelection);
|
106
107
|
/**
|
107
108
|
* `document.body` `mouseleave` callback used to work around a Safari's problem with copying/cutting from the
|
108
109
|
* browser's menu.
|
109
|
-
*
|
110
|
-
* @private
|
111
110
|
*/
|
112
111
|
_classPrivateMethodInitSpec(this, _onSafariMouseLeave);
|
113
112
|
/**
|
114
113
|
* `document.body` `mouseenter` callback used to work around a Safari's problem with copying/cutting from the
|
115
114
|
* browser's menu.
|
116
|
-
*
|
117
|
-
* @private
|
118
115
|
*/
|
119
116
|
_classPrivateMethodInitSpec(this, _onSafariMouseEnter);
|
120
117
|
/**
|
121
118
|
* Force focus on focusableElement after end of the selection.
|
122
119
|
*/
|
123
120
|
_classPrivateMethodInitSpec(this, _onAfterSelectionEnd);
|
121
|
+
/**
|
122
|
+
* Disables the viewport scroll after pasting the data.
|
123
|
+
*
|
124
|
+
* @param {number} fromRow Selection start row visual index.
|
125
|
+
* @param {number} fromColumn Selection start column visual index.
|
126
|
+
* @param {number} toRow Selection end row visual index.
|
127
|
+
* @param {number} toColumn Selection end column visual index.
|
128
|
+
* @param {object} preventScrolling Object with `value` property. If `true`, the viewport scroll will be prevented.
|
129
|
+
*/
|
130
|
+
_classPrivateMethodInitSpec(this, _onAfterSelection);
|
124
131
|
/**
|
125
132
|
* Add copy and cut options to the Context Menu.
|
126
133
|
*
|
127
|
-
* @private
|
128
134
|
* @param {object} options Contains default added options of the Context Menu.
|
129
135
|
*/
|
130
136
|
_classPrivateMethodInitSpec(this, _onAfterContextMenuDefaultOptions);
|
@@ -136,6 +142,15 @@ class CopyPaste extends _base.BasePlugin {
|
|
136
142
|
* Add the `contenteditable` attribute to the highlighted cell and select its content.
|
137
143
|
*/
|
138
144
|
_classPrivateMethodInitSpec(this, _addContentEditableToHighlightedCell);
|
145
|
+
/**
|
146
|
+
* Counts how many column headers will be copied based on the passed range.
|
147
|
+
*
|
148
|
+
* @private
|
149
|
+
* @param {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>} ranges Array of objects with properties `startRow`, `startCol`, `endRow` and `endCol`.
|
150
|
+
* @returns {{ columnHeadersCount: number }} Returns an object with keys that holds
|
151
|
+
* information with the number of copied headers.
|
152
|
+
*/
|
153
|
+
_classPrivateMethodInitSpec(this, _countCopiedHeaders);
|
139
154
|
/**
|
140
155
|
* Ensure that the `copy`/`cut` events get triggered properly in Safari.
|
141
156
|
*
|
@@ -252,6 +267,15 @@ class CopyPaste extends _base.BasePlugin {
|
|
252
267
|
countColumnHeaders: () => this.hot.view.getColumnHeadersCount()
|
253
268
|
})
|
254
269
|
});
|
270
|
+
/**
|
271
|
+
* Flag that indicates if the viewport scroll should be prevented after pasting the data.
|
272
|
+
*
|
273
|
+
* @type {boolean}
|
274
|
+
*/
|
275
|
+
_classPrivateFieldInitSpec(this, _preventViewportScrollOnPaste, {
|
276
|
+
writable: true,
|
277
|
+
value: false
|
278
|
+
});
|
255
279
|
/**
|
256
280
|
* Ranges of the cells coordinates, which should be used to copy/cut/paste actions.
|
257
281
|
*
|
@@ -303,8 +327,13 @@ class CopyPaste extends _base.BasePlugin {
|
|
303
327
|
this.uiContainer = (_settings$uiContainer = settings.uiContainer) !== null && _settings$uiContainer !== void 0 ? _settings$uiContainer : this.uiContainer;
|
304
328
|
}
|
305
329
|
this.addHook('afterContextMenuDefaultOptions', options => _classPrivateMethodGet(this, _onAfterContextMenuDefaultOptions, _onAfterContextMenuDefaultOptions2).call(this, options));
|
330
|
+
this.addHook('afterSelection', function () {
|
331
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
332
|
+
args[_key] = arguments[_key];
|
333
|
+
}
|
334
|
+
return _classPrivateMethodGet(_this, _onAfterSelection, _onAfterSelection2).call(_this, ...args);
|
335
|
+
});
|
306
336
|
this.addHook('afterSelectionEnd', () => _classPrivateMethodGet(this, _onAfterSelectionEnd, _onAfterSelectionEnd2).call(this));
|
307
|
-
this.eventManager = new _eventManager.default(this);
|
308
337
|
this.eventManager.addEventListener(this.hot.rootDocument, 'copy', function () {
|
309
338
|
return _this.onCopy(...arguments);
|
310
339
|
});
|
@@ -318,14 +347,14 @@ class CopyPaste extends _base.BasePlugin {
|
|
318
347
|
// Without this workaround Safari (tested on Safari@16.5.2) does allow copying/cutting from the browser menu.
|
319
348
|
if ((0, _browser.isSafari)()) {
|
320
349
|
this.eventManager.addEventListener(this.hot.rootDocument.body, 'mouseenter', function () {
|
321
|
-
for (var
|
322
|
-
args[
|
350
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
351
|
+
args[_key2] = arguments[_key2];
|
323
352
|
}
|
324
353
|
return _classPrivateMethodGet(_this, _onSafariMouseEnter, _onSafariMouseEnter2).call(_this, ...args);
|
325
354
|
});
|
326
355
|
this.eventManager.addEventListener(this.hot.rootDocument.body, 'mouseleave', function () {
|
327
|
-
for (var
|
328
|
-
args[
|
356
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
357
|
+
args[_key3] = arguments[_key3];
|
329
358
|
}
|
330
359
|
return _classPrivateMethodGet(_this, _onSafariMouseLeave, _onSafariMouseLeave2).call(_this, ...args);
|
331
360
|
});
|
@@ -426,14 +455,26 @@ class CopyPaste extends _base.BasePlugin {
|
|
426
455
|
* @returns {Array[]} An array of arrays that will be copied to the clipboard.
|
427
456
|
*/
|
428
457
|
getRangedData(ranges) {
|
458
|
+
const data = [];
|
429
459
|
const {
|
430
460
|
rows,
|
431
461
|
columns
|
432
|
-
} = (0,
|
433
|
-
|
434
|
-
|
435
|
-
|
462
|
+
} = (0, _copyableRanges.normalizeRanges)(ranges);
|
463
|
+
|
464
|
+
// concatenate all rows and columns data defined in ranges into one copyable string
|
465
|
+
(0, _array.arrayEach)(rows, row => {
|
466
|
+
const rowSet = [];
|
467
|
+
(0, _array.arrayEach)(columns, column => {
|
468
|
+
if (row < 0) {
|
469
|
+
// `row` as the second argument acts here as the `headerLevel` argument
|
470
|
+
rowSet.push(this.hot.getColHeader(column, row));
|
471
|
+
} else {
|
472
|
+
rowSet.push(this.hot.getCopyableData(row, column));
|
473
|
+
}
|
474
|
+
});
|
475
|
+
data.push(rowSet);
|
436
476
|
});
|
477
|
+
return data;
|
437
478
|
}
|
438
479
|
|
439
480
|
/**
|
@@ -450,17 +491,7 @@ class CopyPaste extends _base.BasePlugin {
|
|
450
491
|
if (!pastableText && !pastableHtml) {
|
451
492
|
return;
|
452
493
|
}
|
453
|
-
const pasteData =
|
454
|
-
clipboardData: {
|
455
|
-
data: {},
|
456
|
-
setData(type, value) {
|
457
|
-
this.data[type] = value;
|
458
|
-
},
|
459
|
-
getData(type) {
|
460
|
-
return this.data[type];
|
461
|
-
}
|
462
|
-
}
|
463
|
-
};
|
494
|
+
const pasteData = new _pasteEvent.default();
|
464
495
|
if (pastableText) {
|
465
496
|
pasteData.clipboardData.setData('text/plain', pastableText);
|
466
497
|
}
|
@@ -593,6 +624,7 @@ class CopyPaste extends _base.BasePlugin {
|
|
593
624
|
}
|
594
625
|
newRows.push(newRow);
|
595
626
|
}
|
627
|
+
_classPrivateFieldSet(this, _preventViewportScrollOnPaste, true);
|
596
628
|
this.hot.populateFromArray(startRow, startColumn, newRows, undefined, undefined, 'CopyPaste.paste', this.pasteMode);
|
597
629
|
return [startRow, startColumn, lastVisualRow, lastVisualColumn];
|
598
630
|
}
|
@@ -608,12 +640,19 @@ class CopyPaste extends _base.BasePlugin {
|
|
608
640
|
}
|
609
641
|
this.setCopyableText();
|
610
642
|
_classPrivateFieldSet(this, _isTriggeredByCopy, false);
|
611
|
-
const
|
612
|
-
const
|
643
|
+
const data = this.getRangedData(this.copyableRanges);
|
644
|
+
const copiedHeadersCount = _classPrivateMethodGet(this, _countCopiedHeaders, _countCopiedHeaders2).call(this, this.copyableRanges);
|
645
|
+
const allowCopying = !!this.hot.runHooks('beforeCopy', data, this.copyableRanges, copiedHeadersCount);
|
613
646
|
if (allowCopying) {
|
614
|
-
|
615
|
-
|
616
|
-
|
647
|
+
const textPlain = (0, _SheetClip.stringify)(data);
|
648
|
+
if (event && event.clipboardData) {
|
649
|
+
const textHTML = (0, _parseTable._dataToHTML)(data, this.hot.rootDocument);
|
650
|
+
event.clipboardData.setData('text/plain', textPlain);
|
651
|
+
event.clipboardData.setData('text/html', [META_HEAD, textHTML].join(''));
|
652
|
+
} else if (typeof ClipboardEvent === 'undefined') {
|
653
|
+
this.hot.rootWindow.clipboardData.setData('Text', textPlain);
|
654
|
+
}
|
655
|
+
this.hot.runHooks('afterCopy', data, this.copyableRanges, copiedHeadersCount);
|
617
656
|
}
|
618
657
|
_classPrivateFieldSet(this, _copyMode, 'cells-only');
|
619
658
|
event.preventDefault();
|
@@ -631,13 +670,19 @@ class CopyPaste extends _base.BasePlugin {
|
|
631
670
|
}
|
632
671
|
this.setCopyableText();
|
633
672
|
_classPrivateFieldSet(this, _isTriggeredByCut, false);
|
634
|
-
const
|
635
|
-
const allowCuttingOut = !!this.hot.runHooks('beforeCut',
|
673
|
+
const rangedData = this.getRangedData(this.copyableRanges);
|
674
|
+
const allowCuttingOut = !!this.hot.runHooks('beforeCut', rangedData, this.copyableRanges);
|
636
675
|
if (allowCuttingOut) {
|
637
|
-
|
638
|
-
|
676
|
+
const textPlain = (0, _SheetClip.stringify)(rangedData);
|
677
|
+
if (event && event.clipboardData) {
|
678
|
+
const textHTML = (0, _parseTable._dataToHTML)(rangedData, this.hot.rootDocument);
|
679
|
+
event.clipboardData.setData('text/plain', textPlain);
|
680
|
+
event.clipboardData.setData('text/html', [META_HEAD, textHTML].join(''));
|
681
|
+
} else if (typeof ClipboardEvent === 'undefined') {
|
682
|
+
this.hot.rootWindow.clipboardData.setData('Text', textPlain);
|
683
|
+
}
|
639
684
|
this.hot.emptySelectedCells('CopyPaste.cut');
|
640
|
-
this.hot.runHooks('afterCut',
|
685
|
+
this.hot.runHooks('afterCut', rangedData, this.copyableRanges);
|
641
686
|
}
|
642
687
|
event.preventDefault();
|
643
688
|
}
|
@@ -655,22 +700,34 @@ class CopyPaste extends _base.BasePlugin {
|
|
655
700
|
if (event && event.preventDefault) {
|
656
701
|
event.preventDefault();
|
657
702
|
}
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
703
|
+
let pastedData;
|
704
|
+
if (event && typeof event.clipboardData !== 'undefined') {
|
705
|
+
const textHTML = (0, _string.sanitize)(event.clipboardData.getData('text/html'), {
|
706
|
+
ADD_TAGS: ['meta'],
|
707
|
+
ADD_ATTR: ['content'],
|
708
|
+
FORCE_BODY: true
|
709
|
+
});
|
710
|
+
if (textHTML && /(<table)|(<TABLE)/g.test(textHTML)) {
|
711
|
+
const parsedConfig = (0, _parseTable.htmlToGridSettings)(textHTML, this.hot.rootDocument);
|
712
|
+
pastedData = parsedConfig.data;
|
713
|
+
} else {
|
714
|
+
pastedData = event.clipboardData.getData('text/plain');
|
715
|
+
}
|
716
|
+
} else if (typeof ClipboardEvent === 'undefined' && typeof this.hot.rootWindow.clipboardData !== 'undefined') {
|
717
|
+
pastedData = this.hot.rootWindow.clipboardData.getData('Text');
|
718
|
+
}
|
719
|
+
if (typeof pastedData === 'string') {
|
720
|
+
pastedData = (0, _SheetClip.parse)(pastedData);
|
721
|
+
}
|
722
|
+
if (pastedData === void 0 || pastedData && pastedData.length === 0) {
|
665
723
|
return;
|
666
724
|
}
|
667
|
-
|
668
|
-
if (pastedTable.length === 0) {
|
725
|
+
if (this.hot.runHooks('beforePaste', pastedData, this.copyableRanges) === false) {
|
669
726
|
return;
|
670
727
|
}
|
671
|
-
const [startRow, startColumn, endRow, endColumn] = this.populateValues(
|
728
|
+
const [startRow, startColumn, endRow, endColumn] = this.populateValues(pastedData);
|
672
729
|
this.hot.selectCell(startRow, startColumn, Math.min(this.hot.countRows() - 1, endRow), Math.min(this.hot.countCols() - 1, endColumn));
|
673
|
-
this.hot.runHooks('afterPaste',
|
730
|
+
this.hot.runHooks('afterPaste', pastedData, this.copyableRanges);
|
674
731
|
}
|
675
732
|
/**
|
676
733
|
* Destroys the `CopyPaste` plugin instance.
|
@@ -700,6 +757,21 @@ function _ensureClipboardEventsGetTriggered2(eventName) {
|
|
700
757
|
this.hot.rootDocument.execCommand(eventName);
|
701
758
|
}
|
702
759
|
}
|
760
|
+
function _countCopiedHeaders2(ranges) {
|
761
|
+
const {
|
762
|
+
rows
|
763
|
+
} = (0, _copyableRanges.normalizeRanges)(ranges);
|
764
|
+
let columnHeadersCount = 0;
|
765
|
+
for (let row = 0; row < rows.length; row++) {
|
766
|
+
if (rows[row] >= 0) {
|
767
|
+
break;
|
768
|
+
}
|
769
|
+
columnHeadersCount += 1;
|
770
|
+
}
|
771
|
+
return {
|
772
|
+
columnHeadersCount
|
773
|
+
};
|
774
|
+
}
|
703
775
|
function _addContentEditableToHighlightedCell2() {
|
704
776
|
if (this.hot.isListening()) {
|
705
777
|
const lastSelectedRange = this.hot.getSelectedRangeLast();
|
@@ -746,6 +818,12 @@ function _onAfterContextMenuDefaultOptions2(options) {
|
|
746
818
|
}
|
747
819
|
options.items.push((0, _cut.default)(this));
|
748
820
|
}
|
821
|
+
function _onAfterSelection2(fromRow, fromColumn, toRow, toColumn, preventScrolling) {
|
822
|
+
if (_classPrivateFieldGet(this, _preventViewportScrollOnPaste)) {
|
823
|
+
preventScrolling.value = true;
|
824
|
+
}
|
825
|
+
_classPrivateFieldSet(this, _preventViewportScrollOnPaste, false);
|
826
|
+
}
|
749
827
|
function _onAfterSelectionEnd2() {
|
750
828
|
if (this.isEditorOpened()) {
|
751
829
|
return;
|