handsontable 0.0.0-next-2c41c5b-20250814 → 0.0.0-next-fce5825-20250822
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of handsontable might be problematic. Click here for more details.
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/cellTypes/autocompleteType/autocompleteType.js +1 -4
- package/cellTypes/autocompleteType/autocompleteType.mjs +1 -4
- package/cellTypes/checkboxType/checkboxType.js +1 -3
- package/cellTypes/checkboxType/checkboxType.mjs +1 -3
- package/cellTypes/dropdownType/dropdownType.js +1 -4
- package/cellTypes/dropdownType/dropdownType.mjs +1 -4
- package/cellTypes/numericType/numericType.js +1 -3
- package/cellTypes/numericType/numericType.mjs +1 -3
- package/core/focusCatcher/index.js +37 -20
- package/core/focusCatcher/index.mjs +37 -20
- package/core/focusCatcher/utils.js +3 -64
- package/core/focusCatcher/utils.mjs +1 -60
- package/core/hooks/constants.js +58 -0
- package/core/hooks/constants.mjs +58 -0
- package/core/hooks/index.d.ts +7 -0
- package/core.d.ts +0 -1
- package/core.js +59 -55
- package/core.mjs +61 -57
- package/dataMap/dataMap.js +3 -13
- package/dataMap/dataMap.mjs +4 -14
- package/dataMap/dataSource.js +0 -16
- package/dataMap/dataSource.mjs +0 -16
- package/dataMap/metaManager/lazyFactoryMap.js +3 -4
- package/dataMap/metaManager/lazyFactoryMap.mjs +1 -2
- package/dataMap/metaManager/metaLayers/cellMeta.js +2 -3
- package/dataMap/metaManager/metaLayers/cellMeta.mjs +2 -3
- package/dataMap/metaManager/metaSchema.js +97 -68
- package/dataMap/metaManager/metaSchema.mjs +97 -68
- package/dataMap/metaManager/utils.js +11 -0
- package/dataMap/metaManager/utils.mjs +10 -0
- package/dist/handsontable.css +103 -5
- package/dist/handsontable.full.css +103 -5
- package/dist/handsontable.full.js +2770 -1954
- package/dist/handsontable.full.min.css +3 -3
- package/dist/handsontable.full.min.js +67 -67
- package/dist/handsontable.js +2772 -1956
- package/dist/handsontable.min.css +3 -3
- package/dist/handsontable.min.js +27 -27
- package/editors/autocompleteEditor/autocompleteEditor.js +8 -33
- package/editors/autocompleteEditor/autocompleteEditor.mjs +9 -34
- package/editors/baseEditor/baseEditor.js +2 -2
- package/editors/baseEditor/baseEditor.mjs +2 -2
- package/helpers/a11y.js +5 -1
- package/helpers/a11y.mjs +3 -1
- package/helpers/mixed.js +64 -1
- package/helpers/mixed.mjs +62 -1
- package/helpers/number.js +0 -28
- package/helpers/number.mjs +0 -26
- package/helpers/string.js +0 -19
- package/helpers/string.mjs +0 -18
- package/index.d.ts +9 -0
- package/package.json +6 -1
- package/plugins/autofill/autofill.js +3 -50
- package/plugins/autofill/autofill.mjs +3 -50
- package/plugins/base/base.js +75 -14
- package/plugins/base/base.mjs +75 -14
- package/plugins/contextMenu/contextMenu.js +1 -0
- package/plugins/contextMenu/contextMenu.mjs +1 -0
- package/plugins/copyPaste/copyPaste.js +28 -61
- package/plugins/copyPaste/copyPaste.mjs +29 -62
- package/plugins/dialog/dialog.d.ts +23 -0
- package/plugins/dialog/dialog.js +469 -0
- package/plugins/dialog/dialog.mjs +465 -0
- package/plugins/dialog/index.d.ts +1 -0
- package/plugins/dialog/index.js +7 -0
- package/plugins/dialog/index.mjs +1 -0
- package/plugins/dialog/ui.js +240 -0
- package/plugins/dialog/ui.mjs +235 -0
- package/plugins/dropdownMenu/dropdownMenu.js +1 -0
- package/plugins/dropdownMenu/dropdownMenu.mjs +1 -0
- package/plugins/index.d.ts +3 -0
- package/plugins/index.js +3 -0
- package/plugins/index.mjs +3 -1
- package/plugins/pagination/focusController.js +27 -0
- package/plugins/pagination/focusController.mjs +23 -0
- package/plugins/pagination/pagination.js +165 -18
- package/plugins/pagination/pagination.mjs +165 -18
- package/plugins/pagination/ui.js +101 -62
- package/plugins/pagination/ui.mjs +102 -63
- package/selection/range.js +11 -0
- package/selection/range.mjs +11 -0
- package/selection/selection.js +63 -2
- package/selection/selection.mjs +63 -2
- package/selection/utils.js +2 -1
- package/selection/utils.mjs +2 -1
- package/settings.d.ts +3 -3
- package/shortcuts/context.js +4 -1
- package/shortcuts/context.mjs +4 -1
- package/shortcuts/manager.js +17 -3
- package/shortcuts/manager.mjs +17 -3
- package/styles/handsontable.css +106 -22
- package/styles/handsontable.min.css +3 -3
- package/styles/ht-theme-horizon.css +24 -6
- package/styles/ht-theme-horizon.min.css +3 -3
- package/styles/ht-theme-main.css +52 -34
- package/styles/ht-theme-main.min.css +3 -3
- package/tableView.js +7 -2
- package/tableView.mjs +7 -2
- package/{core/focusCatcher → utils}/focusDetector.js +29 -11
- package/{core/focusCatcher → utils}/focusDetector.mjs +29 -11
- package/validators/autocompleteValidator/autocompleteValidator.js +1 -2
- package/validators/autocompleteValidator/autocompleteValidator.mjs +1 -2
- package/cellTypes/autocompleteType/accessors/index.js +0 -7
- package/cellTypes/autocompleteType/accessors/index.mjs +0 -2
- package/cellTypes/autocompleteType/accessors/valueGetter.js +0 -14
- package/cellTypes/autocompleteType/accessors/valueGetter.mjs +0 -10
- package/cellTypes/autocompleteType/accessors/valueSetter.js +0 -25
- package/cellTypes/autocompleteType/accessors/valueSetter.mjs +0 -21
- package/cellTypes/checkboxType/accessors/index.js +0 -5
- package/cellTypes/checkboxType/accessors/index.mjs +0 -1
- package/cellTypes/checkboxType/accessors/valueSetter.js +0 -26
- package/cellTypes/checkboxType/accessors/valueSetter.mjs +0 -22
- package/cellTypes/dropdownType/accessors/index.js +0 -7
- package/cellTypes/dropdownType/accessors/index.mjs +0 -2
- package/cellTypes/dropdownType/accessors/valueGetter.js +0 -14
- package/cellTypes/dropdownType/accessors/valueGetter.mjs +0 -10
- package/cellTypes/dropdownType/accessors/valueSetter.js +0 -17
- package/cellTypes/dropdownType/accessors/valueSetter.mjs +0 -13
- package/cellTypes/numericType/accessors/index.js +0 -5
- package/cellTypes/numericType/accessors/index.mjs +0 -1
- package/cellTypes/numericType/accessors/valueSetter.js +0 -19
- package/cellTypes/numericType/accessors/valueSetter.mjs +0 -15
- package/utils/valueAccessors.js +0 -45
- package/utils/valueAccessors.mjs +0 -40
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
require("core-js/modules/es.error.cause.js");
|
|
5
5
|
require("core-js/modules/es.array.push.js");
|
|
6
|
-
require("core-js/modules/es.json.stringify.js");
|
|
7
6
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
8
7
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
9
8
|
require("core-js/modules/esnext.iterator.map.js");
|
|
@@ -12,7 +11,6 @@ var _hooks = require("../../core/hooks");
|
|
|
12
11
|
var _SheetClip = require("../../3rdparty/SheetClip");
|
|
13
12
|
var _array = require("../../helpers/array");
|
|
14
13
|
var _string = require("../../helpers/string");
|
|
15
|
-
var _object = require("../../helpers/object");
|
|
16
14
|
var _element = require("../../helpers/dom/element");
|
|
17
15
|
var _browser = require("../../helpers/browser");
|
|
18
16
|
var _copy = _interopRequireDefault(require("./contextMenuItem/copy"));
|
|
@@ -44,7 +42,6 @@ _hooks.Hooks.getSingleton().register('afterCopy');
|
|
|
44
42
|
const PLUGIN_KEY = exports.PLUGIN_KEY = 'copyPaste';
|
|
45
43
|
const PLUGIN_PRIORITY = exports.PLUGIN_PRIORITY = 80;
|
|
46
44
|
const SETTING_KEYS = ['fragmentSelection'];
|
|
47
|
-
const SOURCE_DATA_HTML_MIME_TYPE = 'application/ht-source-data-json-html';
|
|
48
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('');
|
|
49
46
|
|
|
50
47
|
/* eslint-disable jsdoc/require-description-complete-sentence */
|
|
@@ -380,11 +377,9 @@ class CopyPaste extends _base.BasePlugin {
|
|
|
380
377
|
* Converts the contents of multiple ranges (`ranges`) into an array of arrays.
|
|
381
378
|
*
|
|
382
379
|
* @param {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>} ranges Array of objects with properties `startRow`, `startCol`, `endRow` and `endCol`.
|
|
383
|
-
* @param {boolean} [useSourceData=false] Whether to use the source data instead of the data. This will stringify objects as JSON.
|
|
384
380
|
* @returns {Array[]} An array of arrays that will be copied to the clipboard.
|
|
385
381
|
*/
|
|
386
382
|
getRangedData(ranges) {
|
|
387
|
-
let useSourceData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
388
383
|
const data = [];
|
|
389
384
|
const {
|
|
390
385
|
rows,
|
|
@@ -399,11 +394,7 @@ class CopyPaste extends _base.BasePlugin {
|
|
|
399
394
|
// `row` as the second argument acts here as the `headerLevel` argument
|
|
400
395
|
rowSet.push(this.hot.getColHeader(column, row));
|
|
401
396
|
} else {
|
|
402
|
-
|
|
403
|
-
if (useSourceData && (0, _object.isObject)(copyableCellData)) {
|
|
404
|
-
copyableCellData = JSON.stringify(copyableCellData);
|
|
405
|
-
}
|
|
406
|
-
rowSet.push(copyableCellData);
|
|
397
|
+
rowSet.push(this.hot.getCopyableData(row, column));
|
|
407
398
|
}
|
|
408
399
|
});
|
|
409
400
|
data.push(rowSet);
|
|
@@ -501,12 +492,11 @@ class CopyPaste extends _base.BasePlugin {
|
|
|
501
492
|
*
|
|
502
493
|
* @private
|
|
503
494
|
* @param {Array} inputArray An array of the data to populate.
|
|
504
|
-
* @param {Array} sourceInputArray An array of the source data to populate.
|
|
505
495
|
* @param {Array} [selection] The selection which indicates from what position the data will be populated.
|
|
506
496
|
* @returns {Array} Range coordinates after populate data.
|
|
507
497
|
*/
|
|
508
|
-
populateValues(inputArray
|
|
509
|
-
let selection = arguments.length >
|
|
498
|
+
populateValues(inputArray) {
|
|
499
|
+
let selection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.hot.getSelectedRangeActive();
|
|
510
500
|
if (!inputArray.length) {
|
|
511
501
|
return [null, null, null, null];
|
|
512
502
|
}
|
|
@@ -544,28 +534,18 @@ class CopyPaste extends _base.BasePlugin {
|
|
|
544
534
|
const newRow = [];
|
|
545
535
|
const insertedRow = newRows.length % populatedRowsLength;
|
|
546
536
|
while (newRow.length < populatedColumnsLength || visualColumnForPopulatedData <= endColumnFromSelection) {
|
|
547
|
-
var _sourceInputArray$ins;
|
|
548
537
|
const {
|
|
549
538
|
skipColumnOnPaste,
|
|
550
539
|
visualCol
|
|
551
|
-
} = this.hot.getCellMeta(
|
|
552
|
-
const sourceDataAtTarget = this.hot.getSourceDataAtCell(visualRow, visualColumnForPopulatedData);
|
|
553
|
-
const insertedColumn = newRow.length % populatedColumnsLength;
|
|
540
|
+
} = this.hot.getCellMeta(startRow, visualColumnForPopulatedData);
|
|
554
541
|
visualColumnForPopulatedData = visualCol + 1;
|
|
555
542
|
if (skipColumnOnPaste === true) {
|
|
556
543
|
/* eslint-disable no-continue */
|
|
557
544
|
continue;
|
|
558
545
|
}
|
|
559
546
|
lastVisualColumn = visualCol;
|
|
560
|
-
const
|
|
561
|
-
|
|
562
|
-
if (sourceInputArray && (0, _string.isJSON)(sourceCellValue)) {
|
|
563
|
-
const parsedCellValue = JSON.parse(sourceCellValue);
|
|
564
|
-
if ((0, _object.isObject)(sourceDataAtTarget)) {
|
|
565
|
-
cellValue = parsedCellValue;
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
newRow.push(cellValue);
|
|
547
|
+
const insertedColumn = newRow.length % populatedColumnsLength;
|
|
548
|
+
newRow.push(inputArray[insertedRow][insertedColumn]);
|
|
569
549
|
}
|
|
570
550
|
newRows.push(newRow);
|
|
571
551
|
}
|
|
@@ -594,13 +574,19 @@ class CopyPaste extends _base.BasePlugin {
|
|
|
594
574
|
event.preventDefault();
|
|
595
575
|
this.setCopyableText();
|
|
596
576
|
_classPrivateFieldSet(_isTriggeredByCopy, this, false);
|
|
597
|
-
const
|
|
598
|
-
const rangedSourceData = this.getRangedData(this.copyableRanges, true);
|
|
577
|
+
const data = this.getRangedData(this.copyableRanges);
|
|
599
578
|
const copiedHeadersCount = _assertClassBrand(_CopyPaste_brand, this, _countCopiedHeaders).call(this, this.copyableRanges);
|
|
600
|
-
const allowCopying = !!this.hot.runHooks('beforeCopy',
|
|
579
|
+
const allowCopying = !!this.hot.runHooks('beforeCopy', data, this.copyableRanges, copiedHeadersCount);
|
|
601
580
|
if (allowCopying) {
|
|
602
|
-
|
|
603
|
-
|
|
581
|
+
const textPlain = (0, _SheetClip.stringify)(data);
|
|
582
|
+
if (event && event.clipboardData) {
|
|
583
|
+
const textHTML = (0, _parseTable._dataToHTML)(data, this.hot.rootDocument);
|
|
584
|
+
event.clipboardData.setData('text/plain', textPlain);
|
|
585
|
+
event.clipboardData.setData('text/html', [META_HEAD, textHTML].join(''));
|
|
586
|
+
} else if (typeof ClipboardEvent === 'undefined') {
|
|
587
|
+
this.hot.rootWindow.clipboardData.setData('Text', textPlain);
|
|
588
|
+
}
|
|
589
|
+
this.hot.runHooks('afterCopy', data, this.copyableRanges, copiedHeadersCount);
|
|
604
590
|
}
|
|
605
591
|
_classPrivateFieldSet(_copyMode, this, 'cells-only');
|
|
606
592
|
}
|
|
@@ -622,10 +608,16 @@ class CopyPaste extends _base.BasePlugin {
|
|
|
622
608
|
this.setCopyableText();
|
|
623
609
|
_classPrivateFieldSet(_isTriggeredByCut, this, false);
|
|
624
610
|
const rangedData = this.getRangedData(this.copyableRanges);
|
|
625
|
-
const rangedSourceData = this.getRangedData(this.copyableRanges, true);
|
|
626
611
|
const allowCuttingOut = !!this.hot.runHooks('beforeCut', rangedData, this.copyableRanges);
|
|
627
612
|
if (allowCuttingOut) {
|
|
628
|
-
|
|
613
|
+
const textPlain = (0, _SheetClip.stringify)(rangedData);
|
|
614
|
+
if (event && event.clipboardData) {
|
|
615
|
+
const textHTML = (0, _parseTable._dataToHTML)(rangedData, this.hot.rootDocument);
|
|
616
|
+
event.clipboardData.setData('text/plain', textPlain);
|
|
617
|
+
event.clipboardData.setData('text/html', [META_HEAD, textHTML].join(''));
|
|
618
|
+
} else if (typeof ClipboardEvent === 'undefined') {
|
|
619
|
+
this.hot.rootWindow.clipboardData.setData('Text', textPlain);
|
|
620
|
+
}
|
|
629
621
|
this.hot.emptySelectedCells('CopyPaste.cut');
|
|
630
622
|
this.hot.runHooks('afterCut', rangedData, this.copyableRanges);
|
|
631
623
|
}
|
|
@@ -646,13 +638,7 @@ class CopyPaste extends _base.BasePlugin {
|
|
|
646
638
|
}
|
|
647
639
|
event.preventDefault();
|
|
648
640
|
let pastedData;
|
|
649
|
-
let pastedSourceData;
|
|
650
641
|
if (event && typeof event.clipboardData !== 'undefined') {
|
|
651
|
-
const sourceDataHTML = event.clipboardData.getData(SOURCE_DATA_HTML_MIME_TYPE);
|
|
652
|
-
if (sourceDataHTML) {
|
|
653
|
-
const parsedSourceConfig = (0, _parseTable.htmlToGridSettings)(sourceDataHTML, this.hot.rootDocument);
|
|
654
|
-
pastedSourceData = parsedSourceConfig.data;
|
|
655
|
-
}
|
|
656
642
|
const textHTML = (0, _string.sanitize)(event.clipboardData.getData('text/html'), {
|
|
657
643
|
ADD_TAGS: ['meta'],
|
|
658
644
|
ADD_ATTR: ['content'],
|
|
@@ -676,7 +662,7 @@ class CopyPaste extends _base.BasePlugin {
|
|
|
676
662
|
if (this.hot.runHooks('beforePaste', pastedData, this.copyableRanges) === false) {
|
|
677
663
|
return;
|
|
678
664
|
}
|
|
679
|
-
const [startRow, startColumn, endRow, endColumn] = this.populateValues(pastedData
|
|
665
|
+
const [startRow, startColumn, endRow, endColumn] = this.populateValues(pastedData);
|
|
680
666
|
if (startRow !== null && startColumn !== null) {
|
|
681
667
|
this.hot.selectCell(startRow, startColumn, Math.min(this.hot.countRows() - 1, endRow), Math.min(this.hot.countCols() - 1, endColumn));
|
|
682
668
|
}
|
|
@@ -684,11 +670,9 @@ class CopyPaste extends _base.BasePlugin {
|
|
|
684
670
|
}
|
|
685
671
|
|
|
686
672
|
/**
|
|
687
|
-
*
|
|
673
|
+
* Add copy and cut options to the Context Menu.
|
|
688
674
|
*
|
|
689
|
-
* @param {
|
|
690
|
-
* @param {Array} rangedData Ranged data to set to the clipboard.
|
|
691
|
-
* @param {Array} rangedSourceData Ranged source data to set to the clipboard.
|
|
675
|
+
* @param {object} options Contains default added options of the Context Menu.
|
|
692
676
|
*/
|
|
693
677
|
|
|
694
678
|
/**
|
|
@@ -776,23 +760,6 @@ function _removeContentEditableFromHighlightedCell() {
|
|
|
776
760
|
}
|
|
777
761
|
}
|
|
778
762
|
}
|
|
779
|
-
function _setClipboardData(event, rangedData, rangedSourceData) {
|
|
780
|
-
const textPlain = (0, _SheetClip.stringify)(rangedData);
|
|
781
|
-
if (event && event.clipboardData) {
|
|
782
|
-
const textHTML = (0, _parseTable._dataToHTML)(rangedData);
|
|
783
|
-
const textSourceDataHTML = (0, _parseTable._dataToHTML)(rangedSourceData);
|
|
784
|
-
event.clipboardData.setData('text/plain', textPlain);
|
|
785
|
-
event.clipboardData.setData('text/html', [META_HEAD, textHTML].join(''));
|
|
786
|
-
event.clipboardData.setData(SOURCE_DATA_HTML_MIME_TYPE, [META_HEAD, textSourceDataHTML].join(''));
|
|
787
|
-
} else if (typeof ClipboardEvent === 'undefined') {
|
|
788
|
-
this.hot.rootWindow.clipboardData.setData('Text', textPlain);
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
/**
|
|
792
|
-
* Add copy and cut options to the Context Menu.
|
|
793
|
-
*
|
|
794
|
-
* @param {object} options Contains default added options of the Context Menu.
|
|
795
|
-
*/
|
|
796
763
|
function _onAfterContextMenuDefaultOptions(options) {
|
|
797
764
|
options.items.push({
|
|
798
765
|
name: '---------'
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "core-js/modules/es.error.cause.js";
|
|
2
2
|
import "core-js/modules/es.array.push.js";
|
|
3
|
-
import "core-js/modules/es.json.stringify.js";
|
|
4
3
|
import "core-js/modules/esnext.iterator.constructor.js";
|
|
5
4
|
import "core-js/modules/esnext.iterator.filter.js";
|
|
6
5
|
import "core-js/modules/esnext.iterator.map.js";
|
|
@@ -17,8 +16,7 @@ import { BasePlugin } from "../base/index.mjs";
|
|
|
17
16
|
import { Hooks } from "../../core/hooks/index.mjs";
|
|
18
17
|
import { stringify, parse } from "../../3rdparty/SheetClip/index.mjs";
|
|
19
18
|
import { arrayEach } from "../../helpers/array.mjs";
|
|
20
|
-
import { sanitize
|
|
21
|
-
import { isObject } from "../../helpers/object.mjs";
|
|
19
|
+
import { sanitize } from "../../helpers/string.mjs";
|
|
22
20
|
import { removeContentEditableFromElementAndDeselect, runWithSelectedContendEditableElement, makeElementContentEditableAndSelectItsContent, isHTMLElement, isInternalElement } from "../../helpers/dom/element.mjs";
|
|
23
21
|
import { isSafari } from "../../helpers/browser.mjs";
|
|
24
22
|
import copyItem from "./contextMenuItem/copy.mjs";
|
|
@@ -40,7 +38,6 @@ Hooks.getSingleton().register('afterCopy');
|
|
|
40
38
|
export const PLUGIN_KEY = 'copyPaste';
|
|
41
39
|
export const PLUGIN_PRIORITY = 80;
|
|
42
40
|
const SETTING_KEYS = ['fragmentSelection'];
|
|
43
|
-
const SOURCE_DATA_HTML_MIME_TYPE = 'application/ht-source-data-json-html';
|
|
44
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('');
|
|
45
42
|
|
|
46
43
|
/* eslint-disable jsdoc/require-description-complete-sentence */
|
|
@@ -376,11 +373,9 @@ export class CopyPaste extends BasePlugin {
|
|
|
376
373
|
* Converts the contents of multiple ranges (`ranges`) into an array of arrays.
|
|
377
374
|
*
|
|
378
375
|
* @param {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>} ranges Array of objects with properties `startRow`, `startCol`, `endRow` and `endCol`.
|
|
379
|
-
* @param {boolean} [useSourceData=false] Whether to use the source data instead of the data. This will stringify objects as JSON.
|
|
380
376
|
* @returns {Array[]} An array of arrays that will be copied to the clipboard.
|
|
381
377
|
*/
|
|
382
378
|
getRangedData(ranges) {
|
|
383
|
-
let useSourceData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
384
379
|
const data = [];
|
|
385
380
|
const {
|
|
386
381
|
rows,
|
|
@@ -395,11 +390,7 @@ export class CopyPaste extends BasePlugin {
|
|
|
395
390
|
// `row` as the second argument acts here as the `headerLevel` argument
|
|
396
391
|
rowSet.push(this.hot.getColHeader(column, row));
|
|
397
392
|
} else {
|
|
398
|
-
|
|
399
|
-
if (useSourceData && isObject(copyableCellData)) {
|
|
400
|
-
copyableCellData = JSON.stringify(copyableCellData);
|
|
401
|
-
}
|
|
402
|
-
rowSet.push(copyableCellData);
|
|
393
|
+
rowSet.push(this.hot.getCopyableData(row, column));
|
|
403
394
|
}
|
|
404
395
|
});
|
|
405
396
|
data.push(rowSet);
|
|
@@ -497,12 +488,11 @@ export class CopyPaste extends BasePlugin {
|
|
|
497
488
|
*
|
|
498
489
|
* @private
|
|
499
490
|
* @param {Array} inputArray An array of the data to populate.
|
|
500
|
-
* @param {Array} sourceInputArray An array of the source data to populate.
|
|
501
491
|
* @param {Array} [selection] The selection which indicates from what position the data will be populated.
|
|
502
492
|
* @returns {Array} Range coordinates after populate data.
|
|
503
493
|
*/
|
|
504
|
-
populateValues(inputArray
|
|
505
|
-
let selection = arguments.length >
|
|
494
|
+
populateValues(inputArray) {
|
|
495
|
+
let selection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.hot.getSelectedRangeActive();
|
|
506
496
|
if (!inputArray.length) {
|
|
507
497
|
return [null, null, null, null];
|
|
508
498
|
}
|
|
@@ -540,28 +530,18 @@ export class CopyPaste extends BasePlugin {
|
|
|
540
530
|
const newRow = [];
|
|
541
531
|
const insertedRow = newRows.length % populatedRowsLength;
|
|
542
532
|
while (newRow.length < populatedColumnsLength || visualColumnForPopulatedData <= endColumnFromSelection) {
|
|
543
|
-
var _sourceInputArray$ins;
|
|
544
533
|
const {
|
|
545
534
|
skipColumnOnPaste,
|
|
546
535
|
visualCol
|
|
547
|
-
} = this.hot.getCellMeta(
|
|
548
|
-
const sourceDataAtTarget = this.hot.getSourceDataAtCell(visualRow, visualColumnForPopulatedData);
|
|
549
|
-
const insertedColumn = newRow.length % populatedColumnsLength;
|
|
536
|
+
} = this.hot.getCellMeta(startRow, visualColumnForPopulatedData);
|
|
550
537
|
visualColumnForPopulatedData = visualCol + 1;
|
|
551
538
|
if (skipColumnOnPaste === true) {
|
|
552
539
|
/* eslint-disable no-continue */
|
|
553
540
|
continue;
|
|
554
541
|
}
|
|
555
542
|
lastVisualColumn = visualCol;
|
|
556
|
-
const
|
|
557
|
-
|
|
558
|
-
if (sourceInputArray && isJSON(sourceCellValue)) {
|
|
559
|
-
const parsedCellValue = JSON.parse(sourceCellValue);
|
|
560
|
-
if (isObject(sourceDataAtTarget)) {
|
|
561
|
-
cellValue = parsedCellValue;
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
newRow.push(cellValue);
|
|
543
|
+
const insertedColumn = newRow.length % populatedColumnsLength;
|
|
544
|
+
newRow.push(inputArray[insertedRow][insertedColumn]);
|
|
565
545
|
}
|
|
566
546
|
newRows.push(newRow);
|
|
567
547
|
}
|
|
@@ -590,13 +570,19 @@ export class CopyPaste extends BasePlugin {
|
|
|
590
570
|
event.preventDefault();
|
|
591
571
|
this.setCopyableText();
|
|
592
572
|
_classPrivateFieldSet(_isTriggeredByCopy, this, false);
|
|
593
|
-
const
|
|
594
|
-
const rangedSourceData = this.getRangedData(this.copyableRanges, true);
|
|
573
|
+
const data = this.getRangedData(this.copyableRanges);
|
|
595
574
|
const copiedHeadersCount = _assertClassBrand(_CopyPaste_brand, this, _countCopiedHeaders).call(this, this.copyableRanges);
|
|
596
|
-
const allowCopying = !!this.hot.runHooks('beforeCopy',
|
|
575
|
+
const allowCopying = !!this.hot.runHooks('beforeCopy', data, this.copyableRanges, copiedHeadersCount);
|
|
597
576
|
if (allowCopying) {
|
|
598
|
-
|
|
599
|
-
|
|
577
|
+
const textPlain = stringify(data);
|
|
578
|
+
if (event && event.clipboardData) {
|
|
579
|
+
const textHTML = _dataToHTML(data, this.hot.rootDocument);
|
|
580
|
+
event.clipboardData.setData('text/plain', textPlain);
|
|
581
|
+
event.clipboardData.setData('text/html', [META_HEAD, textHTML].join(''));
|
|
582
|
+
} else if (typeof ClipboardEvent === 'undefined') {
|
|
583
|
+
this.hot.rootWindow.clipboardData.setData('Text', textPlain);
|
|
584
|
+
}
|
|
585
|
+
this.hot.runHooks('afterCopy', data, this.copyableRanges, copiedHeadersCount);
|
|
600
586
|
}
|
|
601
587
|
_classPrivateFieldSet(_copyMode, this, 'cells-only');
|
|
602
588
|
}
|
|
@@ -618,10 +604,16 @@ export class CopyPaste extends BasePlugin {
|
|
|
618
604
|
this.setCopyableText();
|
|
619
605
|
_classPrivateFieldSet(_isTriggeredByCut, this, false);
|
|
620
606
|
const rangedData = this.getRangedData(this.copyableRanges);
|
|
621
|
-
const rangedSourceData = this.getRangedData(this.copyableRanges, true);
|
|
622
607
|
const allowCuttingOut = !!this.hot.runHooks('beforeCut', rangedData, this.copyableRanges);
|
|
623
608
|
if (allowCuttingOut) {
|
|
624
|
-
|
|
609
|
+
const textPlain = stringify(rangedData);
|
|
610
|
+
if (event && event.clipboardData) {
|
|
611
|
+
const textHTML = _dataToHTML(rangedData, this.hot.rootDocument);
|
|
612
|
+
event.clipboardData.setData('text/plain', textPlain);
|
|
613
|
+
event.clipboardData.setData('text/html', [META_HEAD, textHTML].join(''));
|
|
614
|
+
} else if (typeof ClipboardEvent === 'undefined') {
|
|
615
|
+
this.hot.rootWindow.clipboardData.setData('Text', textPlain);
|
|
616
|
+
}
|
|
625
617
|
this.hot.emptySelectedCells('CopyPaste.cut');
|
|
626
618
|
this.hot.runHooks('afterCut', rangedData, this.copyableRanges);
|
|
627
619
|
}
|
|
@@ -642,13 +634,7 @@ export class CopyPaste extends BasePlugin {
|
|
|
642
634
|
}
|
|
643
635
|
event.preventDefault();
|
|
644
636
|
let pastedData;
|
|
645
|
-
let pastedSourceData;
|
|
646
637
|
if (event && typeof event.clipboardData !== 'undefined') {
|
|
647
|
-
const sourceDataHTML = event.clipboardData.getData(SOURCE_DATA_HTML_MIME_TYPE);
|
|
648
|
-
if (sourceDataHTML) {
|
|
649
|
-
const parsedSourceConfig = htmlToGridSettings(sourceDataHTML, this.hot.rootDocument);
|
|
650
|
-
pastedSourceData = parsedSourceConfig.data;
|
|
651
|
-
}
|
|
652
638
|
const textHTML = sanitize(event.clipboardData.getData('text/html'), {
|
|
653
639
|
ADD_TAGS: ['meta'],
|
|
654
640
|
ADD_ATTR: ['content'],
|
|
@@ -672,7 +658,7 @@ export class CopyPaste extends BasePlugin {
|
|
|
672
658
|
if (this.hot.runHooks('beforePaste', pastedData, this.copyableRanges) === false) {
|
|
673
659
|
return;
|
|
674
660
|
}
|
|
675
|
-
const [startRow, startColumn, endRow, endColumn] = this.populateValues(pastedData
|
|
661
|
+
const [startRow, startColumn, endRow, endColumn] = this.populateValues(pastedData);
|
|
676
662
|
if (startRow !== null && startColumn !== null) {
|
|
677
663
|
this.hot.selectCell(startRow, startColumn, Math.min(this.hot.countRows() - 1, endRow), Math.min(this.hot.countCols() - 1, endColumn));
|
|
678
664
|
}
|
|
@@ -680,11 +666,9 @@ export class CopyPaste extends BasePlugin {
|
|
|
680
666
|
}
|
|
681
667
|
|
|
682
668
|
/**
|
|
683
|
-
*
|
|
669
|
+
* Add copy and cut options to the Context Menu.
|
|
684
670
|
*
|
|
685
|
-
* @param {
|
|
686
|
-
* @param {Array} rangedData Ranged data to set to the clipboard.
|
|
687
|
-
* @param {Array} rangedSourceData Ranged source data to set to the clipboard.
|
|
671
|
+
* @param {object} options Contains default added options of the Context Menu.
|
|
688
672
|
*/
|
|
689
673
|
|
|
690
674
|
/**
|
|
@@ -771,23 +755,6 @@ function _removeContentEditableFromHighlightedCell() {
|
|
|
771
755
|
}
|
|
772
756
|
}
|
|
773
757
|
}
|
|
774
|
-
function _setClipboardData(event, rangedData, rangedSourceData) {
|
|
775
|
-
const textPlain = stringify(rangedData);
|
|
776
|
-
if (event && event.clipboardData) {
|
|
777
|
-
const textHTML = _dataToHTML(rangedData);
|
|
778
|
-
const textSourceDataHTML = _dataToHTML(rangedSourceData);
|
|
779
|
-
event.clipboardData.setData('text/plain', textPlain);
|
|
780
|
-
event.clipboardData.setData('text/html', [META_HEAD, textHTML].join(''));
|
|
781
|
-
event.clipboardData.setData(SOURCE_DATA_HTML_MIME_TYPE, [META_HEAD, textSourceDataHTML].join(''));
|
|
782
|
-
} else if (typeof ClipboardEvent === 'undefined') {
|
|
783
|
-
this.hot.rootWindow.clipboardData.setData('Text', textPlain);
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
/**
|
|
787
|
-
* Add copy and cut options to the Context Menu.
|
|
788
|
-
*
|
|
789
|
-
* @param {object} options Contains default added options of the Context Menu.
|
|
790
|
-
*/
|
|
791
758
|
function _onAfterContextMenuDefaultOptions(options) {
|
|
792
759
|
options.items.push({
|
|
793
760
|
name: '---------'
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Core from '../../core';
|
|
2
|
+
import { BasePlugin } from '../base';
|
|
3
|
+
|
|
4
|
+
export interface DialogConfig {
|
|
5
|
+
content?: string | HTMLElement;
|
|
6
|
+
customClassName?: string;
|
|
7
|
+
background?: 'solid' | 'semi-transparent';
|
|
8
|
+
contentBackground?: boolean;
|
|
9
|
+
contentDirections?: 'row' | 'row-reverse' | 'column' | 'column-reverse';
|
|
10
|
+
animation?: boolean;
|
|
11
|
+
closable?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type Settings = boolean | DialogConfig;
|
|
15
|
+
|
|
16
|
+
export class Dialog extends BasePlugin {
|
|
17
|
+
|
|
18
|
+
constructor(hotInstance: Core);
|
|
19
|
+
isVisible(): boolean;
|
|
20
|
+
show(config?: DialogConfig): void;
|
|
21
|
+
hide(): void;
|
|
22
|
+
update(config: DialogConfig): void;
|
|
23
|
+
}
|