handsontable 0.0.0-next-b96fb9f-20231207 → 0.0.0-next-3d099da-20231208

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.

Files changed (122) hide show
  1. package/3rdparty/walkontable/src/calculator/index.js +6 -11
  2. package/3rdparty/walkontable/src/calculator/index.mjs +3 -5
  3. package/3rdparty/walkontable/src/calculator/viewportColumns.js +122 -1
  4. package/3rdparty/walkontable/src/calculator/viewportColumns.mjs +124 -2
  5. package/3rdparty/walkontable/src/calculator/viewportRows.js +1 -1
  6. package/3rdparty/walkontable/src/calculator/viewportRows.mjs +3 -2
  7. package/3rdparty/walkontable/src/core/_base.js +12 -0
  8. package/3rdparty/walkontable/src/core/_base.mjs +12 -0
  9. package/3rdparty/walkontable/src/core/core.js +2 -0
  10. package/3rdparty/walkontable/src/core/core.mjs +2 -0
  11. package/3rdparty/walkontable/src/facade/core.js +9 -0
  12. package/3rdparty/walkontable/src/facade/core.mjs +9 -0
  13. package/3rdparty/walkontable/src/index.js +4 -3
  14. package/3rdparty/walkontable/src/index.mjs +2 -1
  15. package/3rdparty/walkontable/src/overlays.js +3 -0
  16. package/3rdparty/walkontable/src/overlays.mjs +4 -0
  17. package/3rdparty/walkontable/src/renderer/colGroup.js +0 -10
  18. package/3rdparty/walkontable/src/renderer/colGroup.mjs +0 -10
  19. package/3rdparty/walkontable/src/renderer/rows.js +3 -4
  20. package/3rdparty/walkontable/src/renderer/rows.mjs +3 -4
  21. package/3rdparty/walkontable/src/selection/manager.js +1 -0
  22. package/3rdparty/walkontable/src/selection/manager.mjs +1 -0
  23. package/3rdparty/walkontable/src/settings.js +0 -3
  24. package/3rdparty/walkontable/src/settings.mjs +0 -2
  25. package/3rdparty/walkontable/src/table.js +1 -0
  26. package/3rdparty/walkontable/src/table.mjs +1 -0
  27. package/3rdparty/walkontable/src/utils/column.js +12 -27
  28. package/3rdparty/walkontable/src/utils/column.mjs +12 -27
  29. package/3rdparty/walkontable/src/viewport.js +17 -22
  30. package/3rdparty/walkontable/src/viewport.mjs +18 -23
  31. package/base.js +2 -4
  32. package/base.mjs +2 -2
  33. package/core/focusCatcher/index.js +6 -44
  34. package/core/focusCatcher/index.mjs +6 -44
  35. package/core.js +11 -0
  36. package/core.mjs +11 -0
  37. package/dataMap/dataMap.js +0 -1
  38. package/dataMap/metaManager/metaSchema.js +2 -28
  39. package/dataMap/metaManager/metaSchema.mjs +2 -28
  40. package/dataMap/metaManager/mods/extendMetaProperties.js +0 -12
  41. package/dataMap/metaManager/mods/extendMetaProperties.mjs +0 -12
  42. package/dist/handsontable.css +2 -2
  43. package/dist/handsontable.full.css +2 -2
  44. package/dist/handsontable.full.js +3903 -2640
  45. package/dist/handsontable.full.min.css +2 -2
  46. package/dist/handsontable.full.min.js +70 -66
  47. package/dist/handsontable.js +3906 -2643
  48. package/dist/handsontable.min.css +2 -2
  49. package/dist/handsontable.min.js +39 -35
  50. package/editorManager.js +4 -3
  51. package/editorManager.mjs +4 -3
  52. package/editors/autocompleteEditor/autocompleteEditor.js +2 -0
  53. package/editors/autocompleteEditor/autocompleteEditor.mjs +2 -0
  54. package/editors/handsontableEditor/handsontableEditor.js +1 -0
  55. package/editors/handsontableEditor/handsontableEditor.mjs +1 -0
  56. package/editors/textEditor/textEditor.js +4 -0
  57. package/editors/textEditor/textEditor.mjs +4 -0
  58. package/helpers/mixed.js +1 -1
  59. package/helpers/mixed.mjs +1 -1
  60. package/package.json +1 -1
  61. package/pluginHooks.d.ts +29 -6
  62. package/pluginHooks.js +123 -65
  63. package/pluginHooks.mjs +122 -62
  64. package/plugins/copyPaste/clipboardData/clipboardData.js +588 -0
  65. package/plugins/copyPaste/clipboardData/clipboardData.mjs +584 -0
  66. package/plugins/copyPaste/clipboardData/copyClipboardData.js +69 -0
  67. package/plugins/copyPaste/clipboardData/copyClipboardData.mjs +65 -0
  68. package/plugins/copyPaste/clipboardData/index.js +9 -0
  69. package/plugins/copyPaste/clipboardData/index.mjs +4 -0
  70. package/plugins/copyPaste/clipboardData/pasteClipboardData.js +81 -0
  71. package/plugins/copyPaste/clipboardData/pasteClipboardData.mjs +77 -0
  72. package/plugins/copyPaste/copyPaste.js +51 -129
  73. package/plugins/copyPaste/copyPaste.mjs +54 -132
  74. package/plugins/copyPaste/copyableRanges.js +7 -43
  75. package/plugins/copyPaste/copyableRanges.mjs +7 -42
  76. package/plugins/copyPaste/pasteEvent.mjs +1 -1
  77. package/plugins/customBorders/customBorders.js +5 -0
  78. package/plugins/customBorders/customBorders.mjs +5 -0
  79. package/plugins/customBorders/utils.js +1 -0
  80. package/plugins/customBorders/utils.mjs +1 -0
  81. package/plugins/filters/ui/radioInput.js +1 -1
  82. package/plugins/filters/ui/radioInput.mjs +1 -1
  83. package/plugins/formulas/formulas.js +2 -0
  84. package/plugins/formulas/formulas.mjs +2 -0
  85. package/plugins/formulas/indexSyncer/axisSyncer.js +1 -0
  86. package/plugins/formulas/indexSyncer/axisSyncer.mjs +1 -0
  87. package/plugins/manualColumnResize/manualColumnResize.js +1 -0
  88. package/plugins/manualColumnResize/manualColumnResize.mjs +1 -0
  89. package/plugins/mergeCells/mergeCells.js +127 -1
  90. package/plugins/mergeCells/mergeCells.mjs +127 -1
  91. package/plugins/nestedHeaders/nestedHeaders.js +87 -41
  92. package/plugins/nestedHeaders/nestedHeaders.mjs +88 -42
  93. package/plugins/nestedHeaders/stateManager/headersTree.js +1 -0
  94. package/plugins/nestedHeaders/stateManager/headersTree.mjs +1 -0
  95. package/plugins/undoRedo/undoRedo.js +2 -0
  96. package/plugins/undoRedo/undoRedo.mjs +2 -0
  97. package/renderers/autocompleteRenderer/autocompleteRenderer.js +1 -0
  98. package/renderers/autocompleteRenderer/autocompleteRenderer.mjs +1 -0
  99. package/renderers/checkboxRenderer/checkboxRenderer.js +2 -0
  100. package/renderers/checkboxRenderer/checkboxRenderer.mjs +2 -0
  101. package/selection/highlight/highlight.js +1 -0
  102. package/selection/highlight/highlight.mjs +1 -0
  103. package/selection/index.js +3 -1
  104. package/selection/index.mjs +2 -2
  105. package/selection/utils.js +34 -0
  106. package/selection/utils.mjs +33 -0
  107. package/settings.d.ts +0 -1
  108. package/tableView.js +2 -1
  109. package/tableView.mjs +2 -1
  110. package/translations/indexMapper.js +1 -2
  111. package/utils/parseTable.js +538 -84
  112. package/utils/parseTable.mjs +534 -83
  113. package/validators/timeValidator/timeValidator.js +1 -0
  114. package/validators/timeValidator/timeValidator.mjs +1 -0
  115. package/3rdparty/walkontable/src/calculator/renderAllColumns.js +0 -50
  116. package/3rdparty/walkontable/src/calculator/renderAllColumns.mjs +0 -46
  117. package/3rdparty/walkontable/src/calculator/renderAllRows.js +0 -50
  118. package/3rdparty/walkontable/src/calculator/renderAllRows.mjs +0 -46
  119. package/3rdparty/walkontable/src/utils/columnStretching.js +0 -219
  120. package/3rdparty/walkontable/src/utils/columnStretching.mjs +0 -215
  121. package/plugins/copyPaste/clipboardData.js +0 -18
  122. package/plugins/copyPaste/clipboardData.mjs +0 -14
@@ -0,0 +1,65 @@
1
+ import "core-js/modules/es.error.cause.js";
2
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
4
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
5
+ import { META_HEAD, ClipboardData } from "./clipboardData.mjs";
6
+ import { transformRangeLikeToIndexes } from "../../../selection/index.mjs";
7
+ import { getDataByCoords, getHTMLByCoords } from "../../../utils/parseTable.mjs";
8
+ /**
9
+ * Creates an object containing information about copy/cut action.
10
+ *
11
+ * @private
12
+ */
13
+ export class CopyClipboardData extends ClipboardData {
14
+ /**
15
+ * @param {Core} instance Handsontable instance (used only while copying data).
16
+ * @param {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>} copyableRanges Cell
17
+ * ranges related to instance of Handsontable (used only while copying data).
18
+ */
19
+ constructor(instance, copyableRanges) {
20
+ super();
21
+ /**
22
+ * Sanitized data of "text/html" type inside the clipboard.
23
+ *
24
+ * @private
25
+ * @type {string}
26
+ */
27
+ _defineProperty(this, "html", void 0);
28
+ /**
29
+ * Copied data stored as array of arrays.
30
+ *
31
+ * @private
32
+ * @type {string[][]}
33
+ */
34
+ _defineProperty(this, "data", void 0);
35
+ /**
36
+ * Copied cell ranges related to instance of Handsontable.
37
+ *
38
+ * @private
39
+ * @type {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>}
40
+ */
41
+ _defineProperty(this, "copyableRanges", void 0);
42
+ const {
43
+ rows,
44
+ columns
45
+ } = transformRangeLikeToIndexes(copyableRanges);
46
+ this.html = [META_HEAD, getHTMLByCoords(instance, {
47
+ rows,
48
+ columns
49
+ })].join('');
50
+ this.data = getDataByCoords(instance, {
51
+ rows,
52
+ columns
53
+ });
54
+ this.copyableRanges = copyableRanges;
55
+ }
56
+
57
+ /**
58
+ * Gets ranges related to copied part of Handsontable.
59
+ *
60
+ * @returns {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>}
61
+ */
62
+ getRanges() {
63
+ return this.copyableRanges;
64
+ }
65
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ var _copyClipboardData = require("./copyClipboardData");
5
+ exports.CopyClipboardData = _copyClipboardData.CopyClipboardData;
6
+ var _pasteClipboardData = require("./pasteClipboardData");
7
+ exports.PasteClipboardData = _pasteClipboardData.PasteClipboardData;
8
+ var _clipboardData = require("./clipboardData");
9
+ exports.META_HEAD = _clipboardData.META_HEAD;
@@ -0,0 +1,4 @@
1
+ import { CopyClipboardData } from "./copyClipboardData.mjs";
2
+ import { PasteClipboardData } from "./pasteClipboardData.mjs";
3
+ import { META_HEAD } from "./clipboardData.mjs";
4
+ export { CopyClipboardData, PasteClipboardData, META_HEAD };
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ require("core-js/modules/es.error.cause.js");
5
+ var _clipboardData = require("./clipboardData");
6
+ var _parseTable = require("../../../utils/parseTable");
7
+ var _SheetClip = require("../../../3rdparty/SheetClip");
8
+ var _mixed = require("../../../helpers/mixed");
9
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
11
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
12
+ /**
13
+ * Creates an object containing information about paste action.
14
+ *
15
+ * @private
16
+ */
17
+ class PasteClipboardData extends _clipboardData.ClipboardData {
18
+ /**
19
+ * @param {string} data Data of "text/plain" type inside the clipboard.
20
+ * @param {string} html Sanitized data of "text/html" type inside the clipboard.
21
+ */
22
+ constructor(data, html) {
23
+ super();
24
+ /**
25
+ * Sanitized data of "text/html" type inside the clipboard.
26
+ *
27
+ * @private
28
+ * @type {string}
29
+ */
30
+ _defineProperty(this, "html", void 0);
31
+ /**
32
+ * Copied data stored as array of arrays.
33
+ *
34
+ * @private
35
+ * @type {string[][]}
36
+ */
37
+ _defineProperty(this, "data", void 0);
38
+ this.html = html;
39
+ if (this.isSerializedTable()) {
40
+ this.data = (0, _parseTable.getDataWithHeadersByConfig)(this.getMetaInfo());
41
+ } else {
42
+ this.data = (0, _SheetClip.parse)(data);
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Checks whether pasted data is an array.
48
+ *
49
+ * @private
50
+ * @returns {boolean}
51
+ */
52
+ isSerializedTable() {
53
+ return (0, _mixed.isDefined)(this.html) && /(<table)|(<TABLE)/g.test(this.html);
54
+ }
55
+
56
+ /**
57
+ * Checks whether pasted data is a Handsontable.
58
+ *
59
+ * @private
60
+ * @returns {boolean}
61
+ */
62
+ isSerializedHandsontable() {
63
+ return this.isSerializedTable() && /<meta (.*?)content="Handsontable"/.test(this.html);
64
+ }
65
+
66
+ /**
67
+ * Gets type of the copied data.
68
+ *
69
+ * @returns {'table' | 'handsontable' | 'unrecognizable'}
70
+ */
71
+ getType() {
72
+ if (this.isSerializedHandsontable()) {
73
+ return 'handsontable';
74
+ }
75
+ if (this.isSerializedTable()) {
76
+ return 'table';
77
+ }
78
+ return 'unrecognizable';
79
+ }
80
+ }
81
+ exports.PasteClipboardData = PasteClipboardData;
@@ -0,0 +1,77 @@
1
+ import "core-js/modules/es.error.cause.js";
2
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
4
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
5
+ import { ClipboardData } from "./clipboardData.mjs";
6
+ import { getDataWithHeadersByConfig } from "../../../utils/parseTable.mjs";
7
+ import { parse } from "../../../3rdparty/SheetClip/index.mjs";
8
+ import { isDefined } from "../../../helpers/mixed.mjs";
9
+ /**
10
+ * Creates an object containing information about paste action.
11
+ *
12
+ * @private
13
+ */
14
+ export class PasteClipboardData extends ClipboardData {
15
+ /**
16
+ * @param {string} data Data of "text/plain" type inside the clipboard.
17
+ * @param {string} html Sanitized data of "text/html" type inside the clipboard.
18
+ */
19
+ constructor(data, html) {
20
+ super();
21
+ /**
22
+ * Sanitized data of "text/html" type inside the clipboard.
23
+ *
24
+ * @private
25
+ * @type {string}
26
+ */
27
+ _defineProperty(this, "html", void 0);
28
+ /**
29
+ * Copied data stored as array of arrays.
30
+ *
31
+ * @private
32
+ * @type {string[][]}
33
+ */
34
+ _defineProperty(this, "data", void 0);
35
+ this.html = html;
36
+ if (this.isSerializedTable()) {
37
+ this.data = getDataWithHeadersByConfig(this.getMetaInfo());
38
+ } else {
39
+ this.data = parse(data);
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Checks whether pasted data is an array.
45
+ *
46
+ * @private
47
+ * @returns {boolean}
48
+ */
49
+ isSerializedTable() {
50
+ return isDefined(this.html) && /(<table)|(<TABLE)/g.test(this.html);
51
+ }
52
+
53
+ /**
54
+ * Checks whether pasted data is a Handsontable.
55
+ *
56
+ * @private
57
+ * @returns {boolean}
58
+ */
59
+ isSerializedHandsontable() {
60
+ return this.isSerializedTable() && /<meta (.*?)content="Handsontable"/.test(this.html);
61
+ }
62
+
63
+ /**
64
+ * Gets type of the copied data.
65
+ *
66
+ * @returns {'table' | 'handsontable' | 'unrecognizable'}
67
+ */
68
+ getType() {
69
+ if (this.isSerializedHandsontable()) {
70
+ return 'handsontable';
71
+ }
72
+ if (this.isSerializedTable()) {
73
+ return 'table';
74
+ }
75
+ return 'unrecognizable';
76
+ }
77
+ }
@@ -6,7 +6,6 @@ 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");
10
9
  var _string = require("../../helpers/string");
11
10
  var _element = require("../../helpers/dom/element");
12
11
  var _browser = require("../../helpers/browser");
@@ -15,9 +14,11 @@ var _copyColumnHeadersOnly = _interopRequireDefault(require("./contextMenuItem/c
15
14
  var _copyWithColumnGroupHeaders = _interopRequireDefault(require("./contextMenuItem/copyWithColumnGroupHeaders"));
16
15
  var _copyWithColumnHeaders = _interopRequireDefault(require("./contextMenuItem/copyWithColumnHeaders"));
17
16
  var _cut = _interopRequireDefault(require("./contextMenuItem/cut"));
18
- var _pasteEvent = _interopRequireDefault(require("./pasteEvent"));
19
17
  var _copyableRanges = require("./copyableRanges");
18
+ var _selection = require("../../selection");
20
19
  var _parseTable = require("../../utils/parseTable");
20
+ var _eventManager = _interopRequireDefault(require("../../eventManager"));
21
+ var _clipboardData = require("./clipboardData");
21
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
23
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
23
24
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
@@ -42,7 +43,6 @@ _pluginHooks.default.getSingleton().register('afterCopy');
42
43
  const PLUGIN_KEY = exports.PLUGIN_KEY = 'copyPaste';
43
44
  const PLUGIN_PRIORITY = exports.PLUGIN_PRIORITY = 80;
44
45
  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,13 +86,10 @@ 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();
90
89
  var _ensureClipboardEventsGetTriggered = /*#__PURE__*/new WeakSet();
91
- var _countCopiedHeaders = /*#__PURE__*/new WeakSet();
92
90
  var _addContentEditableToHighlightedCell = /*#__PURE__*/new WeakSet();
93
91
  var _removeContentEditableFromHighlightedCell = /*#__PURE__*/new WeakSet();
94
92
  var _onAfterContextMenuDefaultOptions = /*#__PURE__*/new WeakSet();
95
- var _onAfterSelection = /*#__PURE__*/new WeakSet();
96
93
  var _onAfterSelectionEnd = /*#__PURE__*/new WeakSet();
97
94
  var _onSafariMouseEnter = /*#__PURE__*/new WeakSet();
98
95
  var _onSafariMouseLeave = /*#__PURE__*/new WeakSet();
@@ -102,35 +99,32 @@ class CopyPaste extends _base.BasePlugin {
102
99
  super(...arguments);
103
100
  /**
104
101
  * `afterSelection` hook callback triggered only on Safari.
102
+ *
103
+ * @private
105
104
  */
106
105
  _classPrivateMethodInitSpec(this, _onSafariAfterSelection);
107
106
  /**
108
107
  * `document.body` `mouseleave` callback used to work around a Safari's problem with copying/cutting from the
109
108
  * browser's menu.
109
+ *
110
+ * @private
110
111
  */
111
112
  _classPrivateMethodInitSpec(this, _onSafariMouseLeave);
112
113
  /**
113
114
  * `document.body` `mouseenter` callback used to work around a Safari's problem with copying/cutting from the
114
115
  * browser's menu.
116
+ *
117
+ * @private
115
118
  */
116
119
  _classPrivateMethodInitSpec(this, _onSafariMouseEnter);
117
120
  /**
118
121
  * Force focus on focusableElement after end of the selection.
119
122
  */
120
123
  _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);
131
124
  /**
132
125
  * Add copy and cut options to the Context Menu.
133
126
  *
127
+ * @private
134
128
  * @param {object} options Contains default added options of the Context Menu.
135
129
  */
136
130
  _classPrivateMethodInitSpec(this, _onAfterContextMenuDefaultOptions);
@@ -142,15 +136,6 @@ class CopyPaste extends _base.BasePlugin {
142
136
  * Add the `contenteditable` attribute to the highlighted cell and select its content.
143
137
  */
144
138
  _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);
154
139
  /**
155
140
  * Ensure that the `copy`/`cut` events get triggered properly in Safari.
156
141
  *
@@ -267,15 +252,6 @@ class CopyPaste extends _base.BasePlugin {
267
252
  countColumnHeaders: () => this.hot.view.getColumnHeadersCount()
268
253
  })
269
254
  });
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
- });
279
255
  /**
280
256
  * Ranges of the cells coordinates, which should be used to copy/cut/paste actions.
281
257
  *
@@ -327,13 +303,8 @@ class CopyPaste extends _base.BasePlugin {
327
303
  this.uiContainer = (_settings$uiContainer = settings.uiContainer) !== null && _settings$uiContainer !== void 0 ? _settings$uiContainer : this.uiContainer;
328
304
  }
329
305
  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
- });
336
306
  this.addHook('afterSelectionEnd', () => _classPrivateMethodGet(this, _onAfterSelectionEnd, _onAfterSelectionEnd2).call(this));
307
+ this.eventManager = new _eventManager.default(this);
337
308
  this.eventManager.addEventListener(this.hot.rootDocument, 'copy', function () {
338
309
  return _this.onCopy(...arguments);
339
310
  });
@@ -347,14 +318,14 @@ class CopyPaste extends _base.BasePlugin {
347
318
  // Without this workaround Safari (tested on Safari@16.5.2) does allow copying/cutting from the browser menu.
348
319
  if ((0, _browser.isSafari)()) {
349
320
  this.eventManager.addEventListener(this.hot.rootDocument.body, 'mouseenter', function () {
350
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
351
- args[_key2] = arguments[_key2];
321
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
322
+ args[_key] = arguments[_key];
352
323
  }
353
324
  return _classPrivateMethodGet(_this, _onSafariMouseEnter, _onSafariMouseEnter2).call(_this, ...args);
354
325
  });
355
326
  this.eventManager.addEventListener(this.hot.rootDocument.body, 'mouseleave', function () {
356
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
357
- args[_key3] = arguments[_key3];
327
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
328
+ args[_key2] = arguments[_key2];
358
329
  }
359
330
  return _classPrivateMethodGet(_this, _onSafariMouseLeave, _onSafariMouseLeave2).call(_this, ...args);
360
331
  });
@@ -455,26 +426,14 @@ class CopyPaste extends _base.BasePlugin {
455
426
  * @returns {Array[]} An array of arrays that will be copied to the clipboard.
456
427
  */
457
428
  getRangedData(ranges) {
458
- const data = [];
459
429
  const {
460
430
  rows,
461
431
  columns
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);
432
+ } = (0, _selection.transformRangeLikeToIndexes)(ranges);
433
+ return (0, _parseTable.getDataByCoords)(this.hot, {
434
+ rows,
435
+ columns
476
436
  });
477
- return data;
478
437
  }
479
438
 
480
439
  /**
@@ -491,7 +450,17 @@ class CopyPaste extends _base.BasePlugin {
491
450
  if (!pastableText && !pastableHtml) {
492
451
  return;
493
452
  }
494
- const pasteData = new _pasteEvent.default();
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
+ };
495
464
  if (pastableText) {
496
465
  pasteData.clipboardData.setData('text/plain', pastableText);
497
466
  }
@@ -624,7 +593,6 @@ class CopyPaste extends _base.BasePlugin {
624
593
  }
625
594
  newRows.push(newRow);
626
595
  }
627
- _classPrivateFieldSet(this, _preventViewportScrollOnPaste, true);
628
596
  this.hot.populateFromArray(startRow, startColumn, newRows, undefined, undefined, 'CopyPaste.paste', this.pasteMode);
629
597
  return [startRow, startColumn, lastVisualRow, lastVisualColumn];
630
598
  }
@@ -640,19 +608,12 @@ class CopyPaste extends _base.BasePlugin {
640
608
  }
641
609
  this.setCopyableText();
642
610
  _classPrivateFieldSet(this, _isTriggeredByCopy, false);
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);
611
+ const copyClipboardData = new _clipboardData.CopyClipboardData(this.hot, this.copyableRanges);
612
+ const allowCopying = !!this.hot.runHooks('beforeCopy', copyClipboardData);
646
613
  if (allowCopying) {
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);
614
+ event.clipboardData.setData('text/plain', (0, _SheetClip.stringify)(copyClipboardData.getData()));
615
+ event.clipboardData.setData('text/html', [copyClipboardData.getType() === 'handsontable' ? _clipboardData.META_HEAD : '', (0, _parseTable.getHTMLFromConfig)(copyClipboardData.getMetaInfo())].join(''));
616
+ this.hot.runHooks('afterCopy', copyClipboardData);
656
617
  }
657
618
  _classPrivateFieldSet(this, _copyMode, 'cells-only');
658
619
  event.preventDefault();
@@ -670,19 +631,13 @@ class CopyPaste extends _base.BasePlugin {
670
631
  }
671
632
  this.setCopyableText();
672
633
  _classPrivateFieldSet(this, _isTriggeredByCut, false);
673
- const rangedData = this.getRangedData(this.copyableRanges);
674
- const allowCuttingOut = !!this.hot.runHooks('beforeCut', rangedData, this.copyableRanges);
634
+ const copyClipboardData = new _clipboardData.CopyClipboardData(this.hot, this.copyableRanges);
635
+ const allowCuttingOut = !!this.hot.runHooks('beforeCut', copyClipboardData);
675
636
  if (allowCuttingOut) {
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
- }
637
+ event.clipboardData.setData('text/plain', (0, _SheetClip.stringify)(copyClipboardData.getData()));
638
+ event.clipboardData.setData('text/html', [copyClipboardData.getType() === 'handsontable' ? _clipboardData.META_HEAD : '', (0, _parseTable.getHTMLFromConfig)(copyClipboardData.getMetaInfo())].join(''));
684
639
  this.hot.emptySelectedCells('CopyPaste.cut');
685
- this.hot.runHooks('afterCut', rangedData, this.copyableRanges);
640
+ this.hot.runHooks('afterCut', copyClipboardData);
686
641
  }
687
642
  event.preventDefault();
688
643
  }
@@ -700,34 +655,22 @@ class CopyPaste extends _base.BasePlugin {
700
655
  if (event && event.preventDefault) {
701
656
  event.preventDefault();
702
657
  }
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) {
658
+ const html = (0, _string.sanitize)(event.clipboardData.getData('text/html'), {
659
+ ADD_TAGS: ['meta'],
660
+ ADD_ATTR: ['content'],
661
+ FORCE_BODY: true
662
+ });
663
+ const pasteClipboardData = new _clipboardData.PasteClipboardData(event.clipboardData.getData('text/plain'), html);
664
+ if (this.hot.runHooks('beforePaste', pasteClipboardData) === false) {
723
665
  return;
724
666
  }
725
- if (this.hot.runHooks('beforePaste', pastedData, this.copyableRanges) === false) {
667
+ const pastedTable = pasteClipboardData.getData();
668
+ if (pastedTable.length === 0) {
726
669
  return;
727
670
  }
728
- const [startRow, startColumn, endRow, endColumn] = this.populateValues(pastedData);
671
+ const [startRow, startColumn, endRow, endColumn] = this.populateValues(pastedTable);
729
672
  this.hot.selectCell(startRow, startColumn, Math.min(this.hot.countRows() - 1, endRow), Math.min(this.hot.countCols() - 1, endColumn));
730
- this.hot.runHooks('afterPaste', pastedData, this.copyableRanges);
673
+ this.hot.runHooks('afterPaste', pasteClipboardData);
731
674
  }
732
675
  /**
733
676
  * Destroys the `CopyPaste` plugin instance.
@@ -757,21 +700,6 @@ function _ensureClipboardEventsGetTriggered2(eventName) {
757
700
  this.hot.rootDocument.execCommand(eventName);
758
701
  }
759
702
  }
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
- }
775
703
  function _addContentEditableToHighlightedCell2() {
776
704
  if (this.hot.isListening()) {
777
705
  const lastSelectedRange = this.hot.getSelectedRangeLast();
@@ -818,12 +746,6 @@ function _onAfterContextMenuDefaultOptions2(options) {
818
746
  }
819
747
  options.items.push((0, _cut.default)(this));
820
748
  }
821
- function _onAfterSelection2(fromRow, fromColumn, toRow, toColumn, preventScrolling) {
822
- if (_classPrivateFieldGet(this, _preventViewportScrollOnPaste)) {
823
- preventScrolling.value = true;
824
- }
825
- _classPrivateFieldSet(this, _preventViewportScrollOnPaste, false);
826
- }
827
749
  function _onAfterSelectionEnd2() {
828
750
  if (this.isEditorOpened()) {
829
751
  return;