handsontable 0.34.4 → 0.34.5

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 (191) hide show
  1. package/.travis.yml +2 -0
  2. package/README.md +1 -1
  3. package/commonjs/core.js +5 -2
  4. package/commonjs/helpers/mixed.js +1 -1
  5. package/commonjs/index.js +2 -2
  6. package/commonjs/pluginHooks.js +18 -2
  7. package/commonjs/plugins/copyPaste/clipboardData.js +31 -0
  8. package/commonjs/plugins/copyPaste/contextMenuItem/copy.js +1 -2
  9. package/commonjs/plugins/copyPaste/contextMenuItem/cut.js +1 -2
  10. package/commonjs/plugins/copyPaste/copyPaste.js +127 -134
  11. package/commonjs/plugins/copyPaste/pasteEvent.js +19 -0
  12. package/commonjs/plugins/copyPaste/test/copyPaste.e2e.js +90 -189
  13. package/commonjs/plugins/copyPaste/test/textarea.unit.js +2 -2
  14. package/commonjs/plugins/copyPaste/textarea.js +2 -1
  15. package/dist/handsontable.css +5 -3
  16. package/dist/handsontable.css.map +1 -1
  17. package/dist/handsontable.full.css +5 -3
  18. package/dist/handsontable.full.js +474 -401
  19. package/dist/handsontable.full.min.css +3 -3
  20. package/dist/handsontable.full.min.js +5 -5
  21. package/dist/handsontable.js +474 -401
  22. package/dist/handsontable.js.map +1 -1
  23. package/dist/handsontable.min.css +3 -3
  24. package/dist/handsontable.min.js +3 -3
  25. package/es/core.js +5 -2
  26. package/es/helpers/mixed.js +1 -1
  27. package/es/index.js +2 -2
  28. package/es/pluginHooks.js +18 -2
  29. package/es/plugins/copyPaste/clipboardData.js +27 -0
  30. package/es/plugins/copyPaste/contextMenuItem/copy.js +1 -2
  31. package/es/plugins/copyPaste/contextMenuItem/cut.js +1 -2
  32. package/es/plugins/copyPaste/copyPaste.js +124 -132
  33. package/es/plugins/copyPaste/pasteEvent.js +11 -0
  34. package/es/plugins/copyPaste/test/copyPaste.e2e.js +90 -189
  35. package/es/plugins/copyPaste/test/textarea.unit.js +2 -2
  36. package/es/plugins/copyPaste/textarea.js +2 -1
  37. package/handsontable.jquery.json +1 -1
  38. package/hot.config.js +1 -1
  39. package/package.json +1 -1
  40. package/src/3rdparty/walkontable/dist/walkontable.js +1 -1
  41. package/src/3rdparty/walkontable/dist/walkontable.js.map +1 -1
  42. package/src/core.js +5 -2
  43. package/src/pluginHooks.js +18 -2
  44. package/src/plugins/copyPaste/clipboardData.js +11 -0
  45. package/src/plugins/copyPaste/contextMenuItem/copy.js +1 -2
  46. package/src/plugins/copyPaste/contextMenuItem/cut.js +1 -2
  47. package/src/plugins/copyPaste/copyPaste.css +3 -1
  48. package/src/plugins/copyPaste/copyPaste.js +120 -127
  49. package/src/plugins/copyPaste/pasteEvent.js +7 -0
  50. package/src/plugins/copyPaste/test/copyPaste.e2e.js +75 -193
  51. package/src/plugins/copyPaste/test/textarea.unit.js +2 -2
  52. package/src/plugins/copyPaste/textarea.js +2 -1
  53. package/test/E2ERunner.html +42 -0
  54. package/test/__mocks__/styleMock.js +1 -0
  55. package/test/dist/e2e.entry.js +43235 -0
  56. package/test/dist/e2e.entry.js.map +1 -0
  57. package/test/dist/helpers.entry.js +990 -0
  58. package/test/dist/helpers.entry.js.map +1 -0
  59. package/test/e2e/ColHeader.spec.js +365 -0
  60. package/test/e2e/Core_alter.spec.js +987 -0
  61. package/test/e2e/Core_beforeKeyDown.spec.js +111 -0
  62. package/test/e2e/Core_beforechange.spec.js +89 -0
  63. package/test/e2e/Core_count.spec.js +81 -0
  64. package/test/e2e/Core_dataSchema.spec.js +512 -0
  65. package/test/e2e/Core_datachange.spec.js +175 -0
  66. package/test/e2e/Core_destroy.spec.js +46 -0
  67. package/test/e2e/Core_destroyEditor.spec.js +80 -0
  68. package/test/e2e/Core_getCellMeta.spec.js +239 -0
  69. package/test/e2e/Core_getColHeader.spec.js +66 -0
  70. package/test/e2e/Core_getDataAt.spec.js +157 -0
  71. package/test/e2e/Core_getDataType.spec.js +112 -0
  72. package/test/e2e/Core_getRowHeader.spec.js +66 -0
  73. package/test/e2e/Core_init.spec.js +86 -0
  74. package/test/e2e/Core_isEmpty.spec.js +58 -0
  75. package/test/e2e/Core_keepEmptyRows.spec.js +363 -0
  76. package/test/e2e/Core_listen.spec.js +111 -0
  77. package/test/e2e/Core_loadData.spec.js +633 -0
  78. package/test/e2e/Core_navigation.spec.js +299 -0
  79. package/test/e2e/Core_onKeyDown.spec.js +313 -0
  80. package/test/e2e/Core_populateFromArray.spec.js +190 -0
  81. package/test/e2e/Core_reCreate.spec.js +29 -0
  82. package/test/e2e/Core_removeCellMeta.spec.js +175 -0
  83. package/test/e2e/Core_render.spec.js +138 -0
  84. package/test/e2e/Core_selection.spec.js +1105 -0
  85. package/test/e2e/Core_setDataAtCell.spec.js +304 -0
  86. package/test/e2e/Core_splice.spec.js +87 -0
  87. package/test/e2e/Core_update.spec.js +651 -0
  88. package/test/e2e/Core_validate.spec.js +1650 -0
  89. package/test/e2e/Core_view.spec.js +757 -0
  90. package/test/e2e/Dom.spec.js +477 -0
  91. package/test/e2e/FillHandle.spec.js +856 -0
  92. package/test/e2e/MemoryLeakTest.js +6 -0
  93. package/test/e2e/Performance.spec.js +239 -0
  94. package/test/e2e/PluginHooks.spec.js +372 -0
  95. package/test/e2e/RowHeader.spec.js +203 -0
  96. package/test/e2e/cellTypes/index.spec.js +193 -0
  97. package/test/e2e/core/colToProp.spec.js +42 -0
  98. package/test/e2e/core/countSourceCols.spec.js +25 -0
  99. package/test/e2e/core/getCellMetaAtRow.spec.js +36 -0
  100. package/test/e2e/core/getCellsMeta.spec.js +28 -0
  101. package/test/e2e/core/getCopyableData.spec.js +38 -0
  102. package/test/e2e/core/getCopyableText.spec.js +34 -0
  103. package/test/e2e/core/getSourceDataArray.spec.js +34 -0
  104. package/test/e2e/core/getSourceDataAtCell.spec.js +130 -0
  105. package/test/e2e/core/propToCol.spec.js +26 -0
  106. package/test/e2e/core/setCellMeta.spec.js +131 -0
  107. package/test/e2e/core/spliceCellsMeta.spec.js +29 -0
  108. package/test/e2e/core/spliceCol.spec.js +93 -0
  109. package/test/e2e/core/spliceRow.spec.js +91 -0
  110. package/test/e2e/core/toPhysicalColumn.spec.js +27 -0
  111. package/test/e2e/core/toPhysicalRow.spec.js +27 -0
  112. package/test/e2e/core/toVisualColumn.spec.js +27 -0
  113. package/test/e2e/core/toVisualRow.spec.js +27 -0
  114. package/test/e2e/editors/autocompleteEditor.spec.js +2953 -0
  115. package/test/e2e/editors/baseEditor.spec.js +88 -0
  116. package/test/e2e/editors/dateEditor.spec.js +407 -0
  117. package/test/e2e/editors/dropdownEditor.spec.js +117 -0
  118. package/test/e2e/editors/handsontableEditor.spec.js +297 -0
  119. package/test/e2e/editors/index.spec.js +79 -0
  120. package/test/e2e/editors/noEditor.spec.js +169 -0
  121. package/test/e2e/editors/numericEditor.spec.js +519 -0
  122. package/test/e2e/editors/passwordEditor.spec.js +127 -0
  123. package/test/e2e/editors/selectEditor.spec.js +277 -0
  124. package/test/e2e/editors/textEditor.spec.js +1115 -0
  125. package/test/e2e/index.js +27 -0
  126. package/test/e2e/publicAPI.spec.js +154 -0
  127. package/test/e2e/renderers/autocompleteRenderer.spec.js +66 -0
  128. package/test/e2e/renderers/cellDecorator.spec.js +120 -0
  129. package/test/e2e/renderers/checkboxRenderer.spec.js +770 -0
  130. package/test/e2e/renderers/htmlRenderer.spec.js +31 -0
  131. package/test/e2e/renderers/index.spec.js +54 -0
  132. package/test/e2e/renderers/numericRenderer.spec.js +149 -0
  133. package/test/e2e/renderers/passwordRenderer.spec.js +172 -0
  134. package/test/e2e/renderers/textRenderer.spec.js +87 -0
  135. package/test/e2e/settings/colWidths.spec.js +252 -0
  136. package/test/e2e/settings/columns.spec.js +230 -0
  137. package/test/e2e/settings/copyable.spec.js +69 -0
  138. package/test/e2e/settings/currentHeaderClassName.spec.js +53 -0
  139. package/test/e2e/settings/currentRowClassName.spec.js +64 -0
  140. package/test/e2e/settings/editor.spec.js +136 -0
  141. package/test/e2e/settings/fixedColumnsLeft.spec.js +118 -0
  142. package/test/e2e/settings/fixedRowsTop.spec.js +118 -0
  143. package/test/e2e/settings/fragmentSelection.spec.js +200 -0
  144. package/test/e2e/settings/maxCols.spec.js +226 -0
  145. package/test/e2e/settings/maxRows.spec.js +178 -0
  146. package/test/e2e/settings/renderer.spec.js +197 -0
  147. package/test/e2e/settings/tableClassName.spec.js +96 -0
  148. package/test/e2e/utils/ghostTable.spec.js +268 -0
  149. package/test/e2e/validators/autocompleteValidator.spec.js +223 -0
  150. package/test/e2e/validators/dateValidator.spec.js +372 -0
  151. package/test/e2e/validators/index.spec.js +72 -0
  152. package/test/e2e/validators/numericValidator.spec.js +228 -0
  153. package/test/e2e/validators/timeValidator.spec.js +412 -0
  154. package/test/helpers/common.js +716 -0
  155. package/test/helpers/index.js +22 -0
  156. package/test/helpers/jasmine.js +63 -0
  157. package/test/lib/backbone.js +1508 -0
  158. package/test/lib/jquery.min.js +4 -0
  159. package/test/lib/jquery.simulate.js +354 -0
  160. package/test/lib/lodash.underscore.js +3870 -0
  161. package/test/lib/normalize.css +500 -0
  162. package/test/lib/phantom-reporter.js +118 -0
  163. package/test/scripts/trigger-hot-builder-tests.sh +39 -0
  164. package/test/scripts/trigger-pro-tests.sh +41 -0
  165. package/test/types/handsontable-tests.ts +492 -0
  166. package/test/types/tsconfig.json +18 -0
  167. package/test/unit/EventManager.spec.js +160 -0
  168. package/test/unit/PluginHooks.spec.js +293 -0
  169. package/test/unit/helpers/Array.spec.js +86 -0
  170. package/test/unit/helpers/Data.spec.js +32 -0
  171. package/test/unit/helpers/Date.spec.js +38 -0
  172. package/test/unit/helpers/Feature.spec.js +32 -0
  173. package/test/unit/helpers/Function.spec.js +238 -0
  174. package/test/unit/helpers/Mixed.spec.js +124 -0
  175. package/test/unit/helpers/Number.spec.js +112 -0
  176. package/test/unit/helpers/Object.spec.js +307 -0
  177. package/test/unit/helpers/String.spec.js +57 -0
  178. package/test/unit/helpers/TemplateLiteralTag.spec.js +35 -0
  179. package/test/unit/helpers/Unicode.spec.js +31 -0
  180. package/test/unit/helpers/dom/Element.spec.js +110 -0
  181. package/test/unit/helpers/dom/Event.spec.js +40 -0
  182. package/test/unit/index.js +8 -0
  183. package/test/unit/mixins/localHooks.spec.js +57 -0
  184. package/test/unit/multiMap.spec.js +93 -0
  185. package/test/unit/utils/Interval.spec.js +84 -0
  186. package/test/unit/utils/dataStructures/LinkedList.spec.js +172 -0
  187. package/test/unit/utils/recordTranslator.spec.js +104 -0
  188. package/test/unit/utils/rootInstance.spec.js +47 -0
  189. package/test/unit/utils/samplesGenerator.spec.js +115 -0
  190. package/test/unit/utils/sortingAlgorithms/mergeSort.spec.js +50 -0
  191. package/test/unit/utils/staticRegister.spec.js +101 -0
package/.travis.yml CHANGED
@@ -8,9 +8,11 @@ node_js:
8
8
  before_script:
9
9
  - export TZ=Europe/Warsaw
10
10
  - chmod ugo+x test/scripts/trigger-hot-builder-tests.sh
11
+ - chmod ugo+x test/scripts/trigger-pro-tests.sh
11
12
 
12
13
  after_success:
13
14
  - "./test/scripts/trigger-hot-builder-tests.sh"
15
+ - "./test/scripts/trigger-pro-tests.sh"
14
16
 
15
17
  notifications:
16
18
  email: false
package/README.md CHANGED
@@ -46,7 +46,7 @@ The list below gives a rough idea on what you can do with Handsontable CE, but i
46
46
  <br/>
47
47
 
48
48
  ### Installation
49
- There are many ways to install Handsontable CE but we suggest using npm:
49
+ There are many ways to install Handsontable CE, but we suggest using npm:
50
50
  ```
51
51
  npm install handsontable
52
52
  ```
package/commonjs/core.js CHANGED
@@ -1358,7 +1358,10 @@ function Core(rootElement, userSettings) {
1358
1358
  document.body.focus();
1359
1359
  }
1360
1360
 
1361
- activeGuid = instance.guid;
1361
+ if (instance && !instance.isListening()) {
1362
+ activeGuid = instance.guid;
1363
+ instance.runHooks('afterListen');
1364
+ }
1362
1365
  };
1363
1366
 
1364
1367
  /**
@@ -1371,6 +1374,7 @@ function Core(rootElement, userSettings) {
1371
1374
  this.unlisten = function () {
1372
1375
  if (this.isListening()) {
1373
1376
  activeGuid = null;
1377
+ instance.runHooks('afterUnlisten');
1374
1378
  }
1375
1379
  };
1376
1380
 
@@ -3117,7 +3121,6 @@ function Core(rootElement, userSettings) {
3117
3121
  selection.setRangeEnd(new _src.CellCoords(endRow, endCol), scrollToCell);
3118
3122
  }
3119
3123
  instance.selection.finish();
3120
-
3121
3124
  return true;
3122
3125
  };
3123
3126
 
@@ -128,7 +128,7 @@ function _injectProductInfo(key, element) {
128
128
 
129
129
  if (trial || schemaValidity) {
130
130
  if (schemaValidity) {
131
- var releaseTime = Math.floor((0, _moment2.default)('13/09/2017', 'DD/MM/YYYY').toDate().getTime() / 8.64e7);
131
+ var releaseTime = Math.floor((0, _moment2.default)('12/10/2017', 'DD/MM/YYYY').toDate().getTime() / 8.64e7);
132
132
  var keyGenTime = _extractTime(key);
133
133
 
134
134
  if (keyGenTime > 45000 || keyGenTime !== parseInt(keyGenTime, 10)) {
package/commonjs/index.js CHANGED
@@ -205,9 +205,9 @@ Handsontable.DefaultSettings = _defaultSettings2.default;
205
205
  Handsontable.EventManager = _eventManager2.default;
206
206
  Handsontable._getListenersCounter = _eventManager.getListenersCounter; // For MemoryLeak tests
207
207
 
208
- Handsontable.buildDate = '13/09/2017 11:19:47';
208
+ Handsontable.buildDate = '12/10/2017 10:11:09';
209
209
  Handsontable.packageName = 'handsontable';
210
- Handsontable.version = '0.34.4';
210
+ Handsontable.version = '0.34.5';
211
211
 
212
212
  var baseVersion = '';
213
213
 
@@ -1116,7 +1116,7 @@ var REGISTERED_HOOKS = [
1116
1116
  /**
1117
1117
  * Fired after values are pasted into table.
1118
1118
  *
1119
- * @event Hooks#afterePaste
1119
+ * @event Hooks#afterPaste
1120
1120
  * @since 0.31.1
1121
1121
  * @param {Array} data An array of arrays which contains the pasted data.
1122
1122
  * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
@@ -1493,7 +1493,23 @@ var REGISTERED_HOOKS = [
1493
1493
  * @param {Number} row Row index of the edited cell.
1494
1494
  * @param {Number} column Column index of the edited cell.
1495
1495
  */
1496
- 'afterBeginEditing'];
1496
+ 'afterBeginEditing',
1497
+
1498
+ /**
1499
+ * Fired after the listening is turned on.
1500
+ *
1501
+ * @event Hooks#afterListen
1502
+ * @since 0.34.5
1503
+ */
1504
+ 'afterListen',
1505
+
1506
+ /**
1507
+ * Fired after the listening is turned off.
1508
+ *
1509
+ * @event Hooks#afterUnlisten
1510
+ * @since 0.34.5
1511
+ */
1512
+ 'afterUnlisten'];
1497
1513
 
1498
1514
  var Hooks = function () {
1499
1515
  _createClass(Hooks, null, [{
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+
5
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
6
+
7
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
+
9
+ var ClipboardData = function () {
10
+ function ClipboardData() {
11
+ _classCallCheck(this, ClipboardData);
12
+
13
+ this.data = {};
14
+ }
15
+
16
+ _createClass(ClipboardData, [{
17
+ key: "setData",
18
+ value: function setData(type, value) {
19
+ this.data[type] = value;
20
+ }
21
+ }, {
22
+ key: "getData",
23
+ value: function getData(type) {
24
+ return this.data[type] || void 0;
25
+ }
26
+ }]);
27
+
28
+ return ClipboardData;
29
+ }();
30
+
31
+ exports.default = ClipboardData;
@@ -7,8 +7,7 @@ function copyItem(copyPastePlugin) {
7
7
  key: 'copy',
8
8
  name: 'Copy',
9
9
  callback: function callback() {
10
- copyPastePlugin.setCopyableText();
11
- copyPastePlugin.copy(true);
10
+ copyPastePlugin.copy();
12
11
  },
13
12
  disabled: function disabled() {
14
13
  return !copyPastePlugin.hot.getSelected();
@@ -7,8 +7,7 @@ function cutItem(copyPastePlugin) {
7
7
  key: 'cut',
8
8
  name: 'Cut',
9
9
  callback: function callback() {
10
- copyPastePlugin.setCopyableText();
11
- copyPastePlugin.cut(true);
10
+ copyPastePlugin.cut();
12
11
  },
13
12
  disabled: function disabled() {
14
13
  return !copyPastePlugin.hot.getSelected();
@@ -22,16 +22,12 @@ var _SheetClip2 = _interopRequireDefault(_SheetClip);
22
22
 
23
23
  var _src = require('./../../3rdparty/walkontable/src');
24
24
 
25
- var _unicode = require('./../../helpers/unicode');
26
-
27
25
  var _element = require('./../../helpers/dom/element');
28
26
 
29
27
  var _array = require('./../../helpers/array');
30
28
 
31
29
  var _number = require('./../../helpers/number');
32
30
 
33
- var _event = require('./../../helpers/dom/event');
34
-
35
31
  var _plugins = require('./../../plugins');
36
32
 
37
33
  var _textarea = require('./textarea');
@@ -50,6 +46,10 @@ var _eventManager = require('./../../eventManager');
50
46
 
51
47
  var _eventManager2 = _interopRequireDefault(_eventManager);
52
48
 
49
+ var _pasteEvent = require('./pasteEvent');
50
+
51
+ var _pasteEvent2 = _interopRequireDefault(_pasteEvent);
52
+
53
53
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
54
54
 
55
55
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -143,7 +143,10 @@ var CopyPaste = function (_BasePlugin) {
143
143
  _this.textarea = void 0;
144
144
 
145
145
  privatePool.set(_this, {
146
- isTriggeredByPaste: false
146
+ isTriggeredByCopy: false,
147
+ isTriggeredByCut: false,
148
+ isBeginEditing: false,
149
+ isFragmentSelectionEnabled: false
147
150
  });
148
151
  return _this;
149
152
  }
@@ -173,10 +176,11 @@ var CopyPaste = function (_BasePlugin) {
173
176
  if (this.enabled) {
174
177
  return;
175
178
  }
176
-
177
179
  var settings = this.hot.getSettings();
180
+ var priv = privatePool.get(this);
178
181
 
179
182
  this.textarea = _textarea2.default.getSingleton();
183
+ priv.isFragmentSelectionEnabled = settings.fragmentSelection;
180
184
 
181
185
  if (_typeof(settings.copyPaste) === 'object') {
182
186
  this.pasteMode = settings.copyPaste.pasteMode || this.pasteMode;
@@ -187,14 +191,15 @@ var CopyPaste = function (_BasePlugin) {
187
191
  this.addHook('afterContextMenuDefaultOptions', function (options) {
188
192
  return _this2.onAfterContextMenuDefaultOptions(options);
189
193
  });
190
- this.addHook('beforeKeyDown', function (event) {
191
- return _this2.onBeforeKeyDown(event);
194
+ this.addHook('afterSelectionEnd', function () {
195
+ return _this2.onAfterSelectionEnd();
192
196
  });
193
197
 
194
198
  this.registerEvents();
195
199
 
196
200
  _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'enablePlugin', this).call(this);
197
201
  }
202
+
198
203
  /**
199
204
  * Updates the plugin to use the latest options you have specified.
200
205
  */
@@ -258,10 +263,6 @@ var CopyPaste = function (_BasePlugin) {
258
263
 
259
264
  this.copyableRanges = this.hot.runHooks('modifyCopyableRange', this.copyableRanges);
260
265
 
261
- var copyableData = this.getRangedCopyableData(this.copyableRanges);
262
-
263
- this.textarea.setValue(copyableData);
264
-
265
266
  if (endRow !== finalEndRow || endCol !== finalEndCol) {
266
267
  this.hot.runHooks('afterCopyLimit', endRow - startRow + 1, endCol - startCol + 1, this.rowsLimit, this.columnsLimit);
267
268
  }
@@ -357,57 +358,32 @@ var CopyPaste = function (_BasePlugin) {
357
358
 
358
359
  /**
359
360
  * Copy action.
360
- *
361
- * @param {Boolean} isTriggeredByClick Flag to determine that copy action was executed by the mouse click.
362
361
  */
363
362
 
364
363
  }, {
365
364
  key: 'copy',
366
- value: function copy(isTriggeredByClick) {
367
- var rangedData = this.getRangedData(this.copyableRanges);
368
-
369
- var allowCopying = !!this.hot.runHooks('beforeCopy', rangedData, this.copyableRanges);
370
-
371
- if (allowCopying) {
372
- this.textarea.setValue(_SheetClip2.default.stringify(rangedData));
373
- this.textarea.select();
365
+ value: function copy() {
366
+ var priv = privatePool.get(this);
374
367
 
375
- if (isTriggeredByClick) {
376
- document.execCommand('copy');
377
- }
368
+ priv.isTriggeredByCopy = true;
378
369
 
379
- this.hot.runHooks('afterCopy', rangedData, this.copyableRanges);
380
- } else {
381
- this.textarea.setValue('');
382
- }
370
+ this.textarea.select();
371
+ document.execCommand('copy');
383
372
  }
384
373
 
385
374
  /**
386
375
  * Cut action.
387
- *
388
- * @param {Boolean} isTriggeredByClick Flag to determine that cut action was executed by the mouse click.
389
376
  */
390
377
 
391
378
  }, {
392
379
  key: 'cut',
393
- value: function cut(isTriggeredByClick) {
394
- var rangedData = this.getRangedData(this.copyableRanges);
395
-
396
- var allowCuttingOut = !!this.hot.runHooks('beforeCut', rangedData, this.copyableRanges);
397
-
398
- if (allowCuttingOut) {
399
- this.textarea.setValue(_SheetClip2.default.stringify(rangedData));
400
- this.hot.selection.empty();
401
- this.textarea.select();
380
+ value: function cut() {
381
+ var priv = privatePool.get(this);
402
382
 
403
- if (isTriggeredByClick) {
404
- document.execCommand('cut');
405
- }
383
+ priv.isTriggeredByCut = true;
406
384
 
407
- this.hot.runHooks('afterCut', rangedData, this.copyableRanges);
408
- } else {
409
- this.textarea.setValue('');
410
- }
385
+ this.textarea.select();
386
+ document.execCommand('cut');
411
387
  }
412
388
 
413
389
  /**
@@ -421,10 +397,10 @@ var CopyPaste = function (_BasePlugin) {
421
397
  value: function paste() {
422
398
  var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
423
399
 
424
- this.textarea.setValue(value);
400
+ var pasteData = new _pasteEvent2.default();
401
+ pasteData.clipboardData.setData('text/plain', value);
425
402
 
426
- this.onPaste();
427
- this.onInput();
403
+ this.onPaste(pasteData);
428
404
  }
429
405
 
430
406
  /**
@@ -441,71 +417,124 @@ var CopyPaste = function (_BasePlugin) {
441
417
  this.eventManager.addEventListener(this.textarea.element, 'paste', function (event) {
442
418
  return _this5.onPaste(event);
443
419
  });
444
- this.eventManager.addEventListener(this.textarea.element, 'input', function (event) {
445
- return _this5.onInput(event);
420
+ this.eventManager.addEventListener(this.textarea.element, 'cut', function (event) {
421
+ return _this5.onCut(event);
422
+ });
423
+ this.eventManager.addEventListener(this.textarea.element, 'copy', function (event) {
424
+ return _this5.onCopy(event);
446
425
  });
447
426
  }
448
427
 
449
428
  /**
450
- * Trigger to make possible observe `onInput` in textarea.
429
+ * `copy` event callback on textarea element.
451
430
  *
431
+ * @param {Event} event ClipboardEvent.
452
432
  * @private
453
433
  */
454
434
 
455
435
  }, {
456
- key: 'triggerPaste',
457
- value: function triggerPaste() {
458
- this.textarea.select();
436
+ key: 'onCopy',
437
+ value: function onCopy(event) {
438
+ var priv = privatePool.get(this);
459
439
 
460
- this.onPaste();
440
+ if (!this.hot.isListening() && !priv.isTriggeredByCopy) {
441
+ return;
442
+ }
443
+
444
+ this.setCopyableText();
445
+ priv.isTriggeredByCopy = false;
446
+
447
+ var rangedData = this.getRangedData(this.copyableRanges);
448
+ var allowCopying = !!this.hot.runHooks('beforeCopy', rangedData, this.copyableRanges);
449
+ var value = '';
450
+
451
+ if (allowCopying) {
452
+ value = _SheetClip2.default.stringify(rangedData);
453
+
454
+ if (event && event.clipboardData) {
455
+ event.clipboardData.setData('text/plain', value);
456
+ } else if (typeof ClipboardEvent === 'undefined') {
457
+ window.clipboardData.setData('Text', value);
458
+ }
459
+
460
+ this.hot.runHooks('afterCopy', rangedData, this.copyableRanges);
461
+ }
462
+
463
+ event.preventDefault();
461
464
  }
462
465
 
463
466
  /**
464
- * `paste` event callback on textarea element.
467
+ * `cut` event callback on textarea element.
465
468
  *
469
+ * @param {Event} event ClipboardEvent.
466
470
  * @private
467
471
  */
468
472
 
469
473
  }, {
470
- key: 'onPaste',
471
- value: function onPaste() {
474
+ key: 'onCut',
475
+ value: function onCut(event) {
472
476
  var priv = privatePool.get(this);
473
477
 
474
- priv.isTriggeredByPaste = true;
478
+ if (!this.hot.isListening() && !priv.isTriggeredByCut) {
479
+ return;
480
+ }
481
+
482
+ this.setCopyableText();
483
+ priv.isTriggeredByCut = false;
484
+
485
+ var rangedData = this.getRangedData(this.copyableRanges);
486
+ var allowCuttingOut = !!this.hot.runHooks('beforeCut', rangedData, this.copyableRanges);
487
+ var value = void 0;
488
+
489
+ if (allowCuttingOut) {
490
+ value = _SheetClip2.default.stringify(rangedData);
491
+
492
+ if (event && event.clipboardData) {
493
+ event.clipboardData.setData('text/plain', value);
494
+ } else if (typeof ClipboardEvent === 'undefined') {
495
+ window.clipboardData.setData('Text', value);
496
+ }
497
+
498
+ this.hot.selection.empty();
499
+ this.hot.runHooks('afterCut', rangedData, this.copyableRanges);
500
+ }
501
+
502
+ event.preventDefault();
475
503
  }
476
504
 
477
505
  /**
478
- * `input` event callback is called after `paste` event callback.
506
+ * `paste` event callback on textarea element.
479
507
  *
508
+ * @param {Event} event ClipboardEvent or pseudo ClipboardEvent, if paste was called manually.
480
509
  * @private
481
510
  */
482
511
 
483
512
  }, {
484
- key: 'onInput',
485
- value: function onInput() {
513
+ key: 'onPaste',
514
+ value: function onPaste(event) {
486
515
  var _this6 = this;
487
516
 
488
- var priv = privatePool.get(this);
489
-
490
- if (!this.hot.isListening() || !priv.isTriggeredByPaste) {
517
+ if (!this.hot.isListening()) {
491
518
  return;
492
519
  }
520
+ if (event && event.preventDefault) {
521
+ event.preventDefault();
522
+ }
523
+
524
+ var inputArray = void 0;
493
525
 
494
- priv.isTriggeredByPaste = false;
526
+ if (event && typeof event.clipboardData !== 'undefined') {
527
+ this.textarea.setValue(event.clipboardData.getData('text/plain'));
528
+ } else if (typeof ClipboardEvent === 'undefined' && typeof window.clipboardData !== 'undefined') {
529
+ this.textarea.setValue(window.clipboardData.getData('Text'));
530
+ }
495
531
 
496
- var input = void 0,
497
- inputArray = void 0,
498
- selected = void 0,
499
- coordsFrom = void 0,
500
- coordsTo = void 0,
501
- cellRange = void 0,
502
- topLeftCorner = void 0,
503
- bottomRightCorner = void 0,
504
- areaStart = void 0,
505
- areaEnd = void 0;
532
+ inputArray = _SheetClip2.default.parse(this.textarea.getValue());
533
+ this.textarea.setValue(' ');
506
534
 
507
- input = this.textarea.getValue();
508
- inputArray = _SheetClip2.default.parse(input);
535
+ if (inputArray.length === 0) {
536
+ return;
537
+ }
509
538
 
510
539
  var allowPasting = !!this.hot.runHooks('beforePaste', inputArray, this.copyableRanges);
511
540
 
@@ -513,19 +542,19 @@ var CopyPaste = function (_BasePlugin) {
513
542
  return;
514
543
  }
515
544
 
516
- selected = this.hot.getSelected();
517
- coordsFrom = new _src.CellCoords(selected[0], selected[1]);
518
- coordsTo = new _src.CellCoords(selected[2], selected[3]);
519
- cellRange = new _src.CellRange(coordsFrom, coordsFrom, coordsTo);
520
- topLeftCorner = cellRange.getTopLeftCorner();
521
- bottomRightCorner = cellRange.getBottomRightCorner();
522
- areaStart = topLeftCorner;
523
- areaEnd = new _src.CellCoords(Math.max(bottomRightCorner.row, inputArray.length - 1 + topLeftCorner.row), Math.max(bottomRightCorner.col, inputArray[0].length - 1 + topLeftCorner.col));
545
+ var selected = this.hot.getSelected();
546
+ var coordsFrom = new _src.CellCoords(selected[0], selected[1]);
547
+ var coordsTo = new _src.CellCoords(selected[2], selected[3]);
548
+ var cellRange = new _src.CellRange(coordsFrom, coordsFrom, coordsTo);
549
+ var topLeftCorner = cellRange.getTopLeftCorner();
550
+ var bottomRightCorner = cellRange.getBottomRightCorner();
551
+ var areaStart = topLeftCorner;
552
+ var areaEnd = new _src.CellCoords(Math.max(bottomRightCorner.row, inputArray.length - 1 + topLeftCorner.row), Math.max(bottomRightCorner.col, inputArray[0].length - 1 + topLeftCorner.col));
524
553
 
525
554
  var isSelRowAreaCoverInputValue = coordsTo.row - coordsFrom.row >= inputArray.length - 1;
526
555
  var isSelColAreaCoverInputValue = coordsTo.col - coordsFrom.col >= inputArray[0].length - 1;
527
556
 
528
- this.hot.addHookOnce('afterChange', function (changes, source) {
557
+ this.hot.addHookOnce('afterChange', function (changes) {
529
558
  var changesLength = changes ? changes.length : 0;
530
559
 
531
560
  if (changesLength) {
@@ -569,62 +598,26 @@ var CopyPaste = function (_BasePlugin) {
569
598
  }
570
599
 
571
600
  /**
572
- * beforeKeyDown callback.
601
+ * We have to keep focus on textarea element, to make possible use of the browser tools (copy, cut, paste).
573
602
  *
574
603
  * @private
575
- * @param {Event} event
576
604
  */
577
605
 
578
606
  }, {
579
- key: 'onBeforeKeyDown',
580
- value: function onBeforeKeyDown(event) {
581
- var _this7 = this;
607
+ key: 'onAfterSelectionEnd',
608
+ value: function onAfterSelectionEnd() {
609
+ var priv = privatePool.get(this);
610
+ var editor = this.hot.getActiveEditor();
582
611
 
583
- if (!this.hot.getSelected()) {
612
+ if (editor && typeof editor.isOpened !== 'undefined' && editor.isOpened()) {
584
613
  return;
585
614
  }
586
- if (this.hot.getActiveEditor() && this.hot.getActiveEditor().isOpened()) {
615
+ if (priv.isFragmentSelectionEnabled && !this.textarea.isActive() && (0, _element.getSelectionText)()) {
587
616
  return;
588
617
  }
589
- if ((0, _event.isImmediatePropagationStopped)(event)) {
590
- return;
591
- }
592
- if (!this.textarea.isActive() && (0, _element.getSelectionText)()) {
593
- return;
594
- }
595
-
596
- if ((0, _unicode.isCtrlKey)(event.keyCode)) {
597
- // When fragmentSelection is enabled and some text is selected then don't blur selection calling 'setCopyableText'
598
- if (this.hot.getSettings().fragmentSelection && (0, _element.getSelectionText)()) {
599
- return;
600
- }
601
618
 
602
- // when CTRL is pressed, prepare selectable text in textarea
603
- this.setCopyableText();
604
- (0, _event.stopImmediatePropagation)(event);
605
-
606
- return;
607
- }
608
-
609
- // catch CTRL but not right ALT (which in some systems triggers ALT+CTRL)
610
- var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
611
-
612
- if (ctrlDown) {
613
- if (event.keyCode == _unicode.KEY_CODES.A) {
614
- setTimeout(function () {
615
- _this7.setCopyableText();
616
- }, 0);
617
- }
618
- if (event.keyCode == _unicode.KEY_CODES.X) {
619
- this.cut();
620
- }
621
- if (event.keyCode == _unicode.KEY_CODES.C) {
622
- this.copy();
623
- }
624
- if (event.keyCode == _unicode.KEY_CODES.V) {
625
- this.triggerPaste();
626
- }
627
- }
619
+ this.setCopyableText();
620
+ this.textarea.select();
628
621
  }
629
622
 
630
623
  /**
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ exports.__esModule = true;
4
+
5
+ var _clipboardData = require('./clipboardData');
6
+
7
+ var _clipboardData2 = _interopRequireDefault(_clipboardData);
8
+
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+
11
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
+
13
+ var PasteEvent = function PasteEvent() {
14
+ _classCallCheck(this, PasteEvent);
15
+
16
+ this.clipboardData = new _clipboardData2.default();
17
+ };
18
+
19
+ exports.default = PasteEvent;