handsontable 0.34.1 → 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.
- package/.travis.yml +2 -0
- package/README.md +127 -96
- package/commonjs/core.js +11 -6
- package/commonjs/helpers/dom/element.js +4 -3
- package/commonjs/helpers/mixed.js +8 -4
- package/commonjs/index.js +5 -4
- package/commonjs/pluginHooks.js +18 -2
- package/commonjs/plugins/copyPaste/clipboardData.js +31 -0
- package/commonjs/plugins/copyPaste/contextMenuItem/copy.js +1 -2
- package/commonjs/plugins/copyPaste/contextMenuItem/cut.js +1 -2
- package/commonjs/plugins/copyPaste/copyPaste.js +127 -134
- package/commonjs/plugins/copyPaste/pasteEvent.js +19 -0
- package/commonjs/plugins/copyPaste/test/copyPaste.e2e.js +90 -189
- package/commonjs/plugins/copyPaste/test/textarea.unit.js +2 -2
- package/commonjs/plugins/copyPaste/textarea.js +2 -1
- package/commonjs/plugins/manualColumnMove/manualColumnMove.js +8 -11
- package/commonjs/plugins/manualColumnMove/test/manualColumnMoveUI.e2e.js +35 -0
- package/commonjs/plugins/manualRowMove/manualRowMove.js +9 -12
- package/commonjs/plugins/manualRowMove/test/manualRowMove.e2e.js +256 -60
- package/commonjs/plugins/manualRowMove/test/manualRowMoveUI.e2e.js +40 -182
- package/commonjs/plugins/manualRowMove/ui/_base.js +2 -2
- package/commonjs/tableView.js +1 -0
- package/dist/handsontable.css +6 -5
- package/dist/handsontable.css.map +1 -1
- package/dist/handsontable.full.css +6 -5
- package/dist/handsontable.full.js +37721 -42290
- package/dist/handsontable.full.min.css +4 -4
- package/dist/handsontable.full.min.js +5 -5
- package/dist/handsontable.js +28732 -28433
- package/dist/handsontable.js.map +1 -1
- package/dist/handsontable.min.css +4 -4
- package/dist/handsontable.min.js +3 -3
- package/es/core.js +11 -6
- package/es/helpers/dom/element.js +4 -3
- package/es/helpers/mixed.js +4 -4
- package/es/index.js +3 -4
- package/es/pluginHooks.js +18 -2
- package/es/plugins/copyPaste/clipboardData.js +27 -0
- package/es/plugins/copyPaste/contextMenuItem/copy.js +1 -2
- package/es/plugins/copyPaste/contextMenuItem/cut.js +1 -2
- package/es/plugins/copyPaste/copyPaste.js +124 -132
- package/es/plugins/copyPaste/pasteEvent.js +11 -0
- package/es/plugins/copyPaste/test/copyPaste.e2e.js +90 -189
- package/es/plugins/copyPaste/test/textarea.unit.js +2 -2
- package/es/plugins/copyPaste/textarea.js +2 -1
- package/es/plugins/manualColumnMove/manualColumnMove.js +8 -11
- package/es/plugins/manualColumnMove/test/manualColumnMoveUI.e2e.js +35 -0
- package/es/plugins/manualRowMove/manualRowMove.js +9 -12
- package/es/plugins/manualRowMove/test/manualRowMove.e2e.js +256 -60
- package/es/plugins/manualRowMove/test/manualRowMoveUI.e2e.js +40 -182
- package/es/plugins/manualRowMove/ui/_base.js +2 -2
- package/es/tableView.js +1 -0
- package/handsontable.jquery.json +1 -1
- package/hot.config.js +1 -1
- package/package.json +5 -5
- package/src/3rdparty/walkontable/dist/walkontable.js +27234 -11175
- package/src/3rdparty/walkontable/dist/walkontable.js.map +1 -1
- package/src/3rdparty/walkontable/test/dist/helpers.entry.js +32 -36
- package/src/3rdparty/walkontable/test/dist/helpers.entry.js.map +1 -1
- package/src/3rdparty/walkontable/test/dist/specs.entry.js +36 -39
- package/src/3rdparty/walkontable/test/dist/specs.entry.js.map +1 -1
- package/src/core.js +11 -6
- package/src/css/handsontable.css +1 -2
- package/src/helpers/dom/element.js +4 -3
- package/src/helpers/mixed.js +3 -3
- package/src/index.js +1 -2
- package/src/pluginHooks.js +18 -2
- package/src/plugins/copyPaste/clipboardData.js +11 -0
- package/src/plugins/copyPaste/contextMenuItem/copy.js +1 -2
- package/src/plugins/copyPaste/contextMenuItem/cut.js +1 -2
- package/src/plugins/copyPaste/copyPaste.css +3 -1
- package/src/plugins/copyPaste/copyPaste.js +120 -127
- package/src/plugins/copyPaste/pasteEvent.js +7 -0
- package/src/plugins/copyPaste/test/copyPaste.e2e.js +75 -193
- package/src/plugins/copyPaste/test/textarea.unit.js +2 -2
- package/src/plugins/copyPaste/textarea.js +2 -1
- package/src/plugins/manualColumnMove/manualColumnMove.js +6 -9
- package/src/plugins/manualColumnMove/test/manualColumnMoveUI.e2e.js +35 -0
- package/src/plugins/manualRowMove/manualRowMove.js +7 -10
- package/src/plugins/manualRowMove/test/manualRowMove.e2e.js +282 -86
- package/src/plugins/manualRowMove/test/manualRowMoveUI.e2e.js +51 -190
- package/src/plugins/manualRowMove/ui/_base.js +2 -2
- package/test/dist/e2e.entry.js +31381 -31131
- package/test/dist/e2e.entry.js.map +1 -1
- package/test/dist/helpers.entry.js +16 -19
- package/test/dist/helpers.entry.js.map +1 -1
- package/test/e2e/Core_listen.spec.js +32 -0
- package/test/e2e/Core_selection.spec.js +1 -1
- package/test/e2e/Core_validate.spec.js +29 -0
- package/test/e2e/renderers/checkboxRenderer.spec.js +20 -7
- package/test/e2e/settings/fragmentSelection.spec.js +12 -9
- package/test/scripts/trigger-pro-tests.sh +41 -0
- package/yarn.lock +260 -208
- package/.npmignore +0 -19
- package/demo/bower_components/numbro/package.json +0 -63
@@ -1,7 +1,11 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
+
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; }; }();
|
4
|
+
|
3
5
|
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
4
6
|
|
7
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
8
|
+
|
5
9
|
describe('CopyPaste', function () {
|
6
10
|
var id = 'testContainer';
|
7
11
|
|
@@ -16,6 +20,37 @@ describe('CopyPaste', function () {
|
|
16
20
|
}
|
17
21
|
});
|
18
22
|
|
23
|
+
var DataTransferObject = function () {
|
24
|
+
function DataTransferObject() {
|
25
|
+
_classCallCheck(this, DataTransferObject);
|
26
|
+
|
27
|
+
this.data = '';
|
28
|
+
}
|
29
|
+
|
30
|
+
_createClass(DataTransferObject, [{
|
31
|
+
key: 'getData',
|
32
|
+
value: function getData() {
|
33
|
+
return this.data;
|
34
|
+
}
|
35
|
+
}, {
|
36
|
+
key: 'setData',
|
37
|
+
value: function setData(type, value) {
|
38
|
+
this.data = value;
|
39
|
+
}
|
40
|
+
}]);
|
41
|
+
|
42
|
+
return DataTransferObject;
|
43
|
+
}();
|
44
|
+
|
45
|
+
;
|
46
|
+
|
47
|
+
function getClipboardEvent() {
|
48
|
+
var event = {};
|
49
|
+
event.clipboardData = new DataTransferObject();
|
50
|
+
event.preventDefault = function () {};
|
51
|
+
return event;
|
52
|
+
}
|
53
|
+
|
19
54
|
var arrayOfArrays = function arrayOfArrays() {
|
20
55
|
return [['', 'Kia', 'Nissan', 'Toyota', 'Honda'], ['2008', 10, 11, 12, 13], ['2009', 20, 11, 14, 13], ['2010', 30, 15, 12, 13]];
|
21
56
|
};
|
@@ -80,67 +115,7 @@ describe('CopyPaste', function () {
|
|
80
115
|
});
|
81
116
|
});
|
82
117
|
|
83
|
-
|
84
|
-
it('should set copyable text when selecting a single cell and hitting ctrl', function () {
|
85
|
-
handsontable({
|
86
|
-
data: Handsontable.helper.createSpreadsheetData(2, 2)
|
87
|
-
});
|
88
|
-
|
89
|
-
var copyPasteTextarea = $('#HandsontableCopyPaste')[0];
|
90
|
-
|
91
|
-
expect(copyPasteTextarea.value.length).toEqual(0);
|
92
|
-
|
93
|
-
selectCell(0, 0);
|
94
|
-
keyDownUp(Handsontable.helper.KEY_CODES.CONTROL_LEFT);
|
95
|
-
|
96
|
-
expect(copyPasteTextarea.value).toEqual('A1');
|
97
|
-
});
|
98
|
-
|
99
|
-
it('should set copyable text when selecting a single cell and hitting left command', function () {
|
100
|
-
handsontable({
|
101
|
-
data: Handsontable.helper.createSpreadsheetData(2, 2)
|
102
|
-
});
|
103
|
-
|
104
|
-
var copyPasteTextarea = $('#HandsontableCopyPaste')[0];
|
105
|
-
|
106
|
-
expect(copyPasteTextarea.value.length).toEqual(0);
|
107
|
-
|
108
|
-
selectCell(0, 0);
|
109
|
-
keyDownUp(Handsontable.helper.KEY_CODES.COMMAND_LEFT);
|
110
|
-
|
111
|
-
expect(copyPasteTextarea.value).toEqual('A1');
|
112
|
-
});
|
113
|
-
|
114
|
-
it('should set copyable text when selecting a single cell and hitting right command', function () {
|
115
|
-
handsontable({
|
116
|
-
data: Handsontable.helper.createSpreadsheetData(2, 2)
|
117
|
-
});
|
118
|
-
|
119
|
-
var copyPasteTextarea = $('#HandsontableCopyPaste')[0];
|
120
|
-
|
121
|
-
expect(copyPasteTextarea.value.length).toEqual(0);
|
122
|
-
|
123
|
-
selectCell(0, 0);
|
124
|
-
keyDownUp(Handsontable.helper.KEY_CODES.COMMAND_RIGHT);
|
125
|
-
|
126
|
-
expect(copyPasteTextarea.value).toEqual('A1');
|
127
|
-
});
|
128
|
-
|
129
|
-
it('should set copyable text when selecting multiple cells and hitting ctrl', function () {
|
130
|
-
handsontable({
|
131
|
-
data: Handsontable.helper.createSpreadsheetData(2, 2)
|
132
|
-
});
|
133
|
-
|
134
|
-
var copyPasteTextarea = $('#HandsontableCopyPaste')[0];
|
135
|
-
|
136
|
-
expect(copyPasteTextarea.value.length).toEqual(0);
|
137
|
-
|
138
|
-
selectCell(0, 0, 1, 0);
|
139
|
-
keyDownUp(Handsontable.helper.KEY_CODES.CONTROL_LEFT);
|
140
|
-
|
141
|
-
expect(copyPasteTextarea.value).toEqual('A1\nA2');
|
142
|
-
});
|
143
|
-
|
118
|
+
xdescribe('setting values copyable', function () {
|
144
119
|
it('should set copyable text when selecting all cells with CTRL+A', function (done) {
|
145
120
|
handsontable({
|
146
121
|
data: Handsontable.helper.createSpreadsheetData(2, 2)
|
@@ -161,24 +136,6 @@ describe('CopyPaste', function () {
|
|
161
136
|
}, 10);
|
162
137
|
});
|
163
138
|
|
164
|
-
it('should not throw error when no cell is selected (#1221)', function () {
|
165
|
-
handsontable({
|
166
|
-
data: Handsontable.helper.createSpreadsheetData(2, 2)
|
167
|
-
});
|
168
|
-
|
169
|
-
selectCell(0, 0);
|
170
|
-
deselectCell();
|
171
|
-
|
172
|
-
function keydownCtrl() {
|
173
|
-
$(document).simulate('keydown', {
|
174
|
-
keyCode: Handsontable.helper.KEY_CODES.COMMAND_LEFT
|
175
|
-
});
|
176
|
-
}
|
177
|
-
|
178
|
-
// expect no to throw any exception
|
179
|
-
expect(keydownCtrl).not.toThrow();
|
180
|
-
});
|
181
|
-
|
182
139
|
it('should not throw error when no cell is selected and contextmenu options was clicked', function () {
|
183
140
|
// This is ugly trick to check problematic thing (#4390).
|
184
141
|
// Unfortunately we cannot open the context menu, when event.target is not an TD element.
|
@@ -209,22 +166,6 @@ describe('CopyPaste', function () {
|
|
209
166
|
expect(copyPasteTextarea.value).toEqual('A\t1\nB\t2');
|
210
167
|
});
|
211
168
|
|
212
|
-
it('should set copyable text when selecting a single cell with editor type as false (#2574)', function () {
|
213
|
-
handsontable({
|
214
|
-
data: [['A', 1], ['B', 2]],
|
215
|
-
columns: [{ type: 'text' }, { editor: false }]
|
216
|
-
});
|
217
|
-
|
218
|
-
var copyPasteTextarea = $('#HandsontableCopyPaste')[0];
|
219
|
-
|
220
|
-
expect(copyPasteTextarea.value.length).toEqual(0);
|
221
|
-
|
222
|
-
selectCell(1, 1, 1, 1);
|
223
|
-
keyDownUp(Handsontable.helper.KEY_CODES.CONTROL_LEFT);
|
224
|
-
|
225
|
-
expect(copyPasteTextarea.value).toEqual('2');
|
226
|
-
});
|
227
|
-
|
228
169
|
it('should set copyable text until copyRowsLimit is reached', function () {
|
229
170
|
handsontable({
|
230
171
|
data: arrayOfArrays(),
|
@@ -276,67 +217,46 @@ describe('CopyPaste', function () {
|
|
276
217
|
});
|
277
218
|
|
278
219
|
describe('copy', function () {
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
});
|
283
|
-
|
284
|
-
selectCell(1, 1);
|
285
|
-
keyDown('ctrl');
|
286
|
-
keyDown('ctrl+c');
|
220
|
+
xit('should be possible to copy data by keyboard shortcut', function () {
|
221
|
+
// simulated keyboard shortcuts doesn't run the true events
|
222
|
+
});
|
287
223
|
|
288
|
-
|
289
|
-
//
|
224
|
+
xit('should be possible to copy data by contextMenu option', function () {
|
225
|
+
// simulated mouse events doesn't run the true browser event
|
290
226
|
});
|
291
227
|
|
292
228
|
it('should be possible to copy data by API', function () {
|
293
229
|
var hot = handsontable({
|
294
230
|
data: Handsontable.helper.createSpreadsheetData(2, 2)
|
295
231
|
});
|
232
|
+
var copyEvent = getClipboardEvent('copy');
|
233
|
+
var plugin = hot.getPlugin('CopyPaste');
|
296
234
|
|
297
235
|
selectCell(1, 0);
|
298
236
|
|
299
|
-
|
300
|
-
|
301
|
-
hot.getPlugin('CopyPaste').copy(true);
|
302
|
-
|
303
|
-
expect($('#HandsontableCopyPaste')[0]).toBe(document.activeElement);
|
304
|
-
// unfortunately we have not access to read data from the system clipboard
|
305
|
-
});
|
306
|
-
|
307
|
-
it('should be possible to copy data by contextMenu option', function () {
|
308
|
-
var beforeCopySpy = jasmine.createSpy('beforeCopy');
|
309
|
-
|
310
|
-
handsontable({
|
311
|
-
data: Handsontable.helper.createSpreadsheetData(2, 2),
|
312
|
-
beforeCopy: beforeCopySpy,
|
313
|
-
contextMenu: ['copy']
|
314
|
-
});
|
315
|
-
|
316
|
-
selectCell(0, 1);
|
317
|
-
contextMenu();
|
318
|
-
|
319
|
-
var items = $('.htContextMenu tbody td');
|
320
|
-
var actions = items.not('.htSeparator');
|
321
|
-
|
322
|
-
actions.simulate('mousedown');
|
237
|
+
plugin.setCopyableText();
|
238
|
+
plugin.onCopy(copyEvent);
|
323
239
|
|
324
|
-
expect(
|
240
|
+
expect(copyEvent.clipboardData.getData()).toBe('A2');
|
325
241
|
});
|
326
242
|
|
327
243
|
it('should call beforeCopy and afterCopy during copying operation', function () {
|
328
244
|
var beforeCopySpy = jasmine.createSpy('beforeCopy');
|
329
245
|
var afterCopySpy = jasmine.createSpy('afterCopy');
|
330
246
|
|
331
|
-
handsontable({
|
247
|
+
var hot = handsontable({
|
332
248
|
data: Handsontable.helper.createSpreadsheetData(2, 2),
|
333
249
|
beforeCopy: beforeCopySpy,
|
334
250
|
afterCopy: afterCopySpy
|
335
251
|
});
|
336
252
|
|
253
|
+
var copyEvent = getClipboardEvent('copy');
|
254
|
+
var plugin = hot.getPlugin('CopyPaste');
|
255
|
+
|
337
256
|
selectCell(0, 0);
|
338
|
-
|
339
|
-
|
257
|
+
|
258
|
+
plugin.setCopyableText();
|
259
|
+
plugin.onCopy(copyEvent);
|
340
260
|
|
341
261
|
expect(beforeCopySpy.calls.count()).toEqual(1);
|
342
262
|
expect(beforeCopySpy).toHaveBeenCalledWith([['A1']], [{ startRow: 0, startCol: 0, endRow: 0, endCol: 0 }], void 0, void 0, void 0, void 0);
|
@@ -345,112 +265,93 @@ describe('CopyPaste', function () {
|
|
345
265
|
});
|
346
266
|
|
347
267
|
it('should be possible to block copying', function () {
|
268
|
+
var beforeCopySpy = jasmine.createSpy('beforeCopy');
|
348
269
|
var afterCopySpy = jasmine.createSpy('afterCopy');
|
349
270
|
|
350
|
-
handsontable({
|
271
|
+
var hot = handsontable({
|
351
272
|
data: Handsontable.helper.createSpreadsheetData(2, 2),
|
352
273
|
beforeCopy: function beforeCopy() {
|
274
|
+
beforeCopySpy();
|
353
275
|
return false;
|
354
276
|
},
|
355
277
|
|
356
278
|
afterCopy: afterCopySpy
|
357
279
|
});
|
358
280
|
|
281
|
+
var copyEvent = getClipboardEvent('copy');
|
282
|
+
var plugin = hot.getPlugin('CopyPaste');
|
283
|
+
|
359
284
|
selectCell(0, 0);
|
360
|
-
keyDown('ctrl');
|
361
|
-
keyDown('ctrl+c');
|
362
285
|
|
286
|
+
plugin.setCopyableText();
|
287
|
+
plugin.onCopy(copyEvent);
|
288
|
+
|
289
|
+
expect(beforeCopySpy.calls.count()).toEqual(1);
|
363
290
|
expect(afterCopySpy.calls.count()).toEqual(0);
|
364
291
|
});
|
365
292
|
|
366
|
-
it('should be possible modification of changes during copying',
|
367
|
-
handsontable({
|
293
|
+
it('should be possible modification of changes during copying', function () {
|
294
|
+
var hot = handsontable({
|
368
295
|
data: Handsontable.helper.createSpreadsheetData(2, 2),
|
369
296
|
beforeCopy: function beforeCopy(changes) {
|
370
297
|
changes.splice(0, 1);
|
371
298
|
}
|
372
299
|
});
|
373
300
|
|
301
|
+
var copyEvent = getClipboardEvent('copy');
|
302
|
+
var plugin = hot.getPlugin('CopyPaste');
|
374
303
|
selectCell(0, 0, 1, 0);
|
375
|
-
keyDown('ctrl');
|
376
|
-
keyDown('ctrl+c');
|
377
304
|
|
378
|
-
|
305
|
+
plugin.setCopyableText();
|
306
|
+
plugin.onCopy(copyEvent);
|
379
307
|
|
380
|
-
expect(
|
381
|
-
})
|
308
|
+
expect(copyEvent.clipboardData.getData()).toEqual('A2');
|
309
|
+
});
|
382
310
|
});
|
383
311
|
|
384
312
|
describe('cut', function () {
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
});
|
389
|
-
|
390
|
-
selectCell(1, 1);
|
391
|
-
keyDown('ctrl');
|
392
|
-
keyDown('ctrl+x');
|
393
|
-
|
394
|
-
expect($('#HandsontableCopyPaste')[0]).toBe(document.activeElement);
|
395
|
-
|
396
|
-
yield sleep(100);
|
313
|
+
xit('should be possible to cut data by keyboard shortcut', function () {
|
314
|
+
// simulated keyboard shortcuts doesn't run the true events
|
315
|
+
});
|
397
316
|
|
398
|
-
|
399
|
-
//
|
400
|
-
})
|
317
|
+
xit('should be possible to cut data by contextMenu option', function () {
|
318
|
+
// simulated mouse events doesn't run the true browser event
|
319
|
+
});
|
401
320
|
|
402
|
-
it('should be possible to cut data by API',
|
321
|
+
it('should be possible to cut data by API', function () {
|
403
322
|
var hot = handsontable({
|
404
323
|
data: Handsontable.helper.createSpreadsheetData(2, 2)
|
405
324
|
});
|
325
|
+
var cutEvent = getClipboardEvent('cut');
|
326
|
+
var plugin = hot.getPlugin('CopyPaste');
|
406
327
|
|
407
328
|
selectCell(1, 0);
|
408
329
|
|
409
|
-
|
410
|
-
|
411
|
-
hot.getPlugin('CopyPaste').cut(true);
|
330
|
+
plugin.setCopyableText();
|
331
|
+
plugin.onCut(cutEvent);
|
412
332
|
|
413
|
-
expect(
|
414
|
-
|
415
|
-
yield sleep(100);
|
333
|
+
expect(cutEvent.clipboardData.getData()).toBe('A2');
|
416
334
|
|
335
|
+
// await sleep(100);
|
417
336
|
expect(hot.getDataAtCell(1, 0)).toBe('');
|
418
|
-
// unfortunately we have not access to read data from the system clipboard
|
419
|
-
}));
|
420
|
-
|
421
|
-
it('should be possible to cut data by contextMenu option', function () {
|
422
|
-
var beforeCutSpy = jasmine.createSpy('beforeCopy');
|
423
|
-
|
424
|
-
handsontable({
|
425
|
-
data: Handsontable.helper.createSpreadsheetData(2, 2),
|
426
|
-
beforeCut: beforeCutSpy,
|
427
|
-
contextMenu: ['cut']
|
428
|
-
});
|
429
|
-
|
430
|
-
selectCell(0, 1);
|
431
|
-
contextMenu();
|
432
|
-
|
433
|
-
var items = $('.htContextMenu tbody td');
|
434
|
-
var actions = items.not('.htSeparator');
|
435
|
-
|
436
|
-
actions.simulate('mousedown');
|
437
|
-
|
438
|
-
expect(beforeCutSpy).toHaveBeenCalledTimes(1);
|
439
337
|
});
|
440
338
|
|
441
339
|
it('should call beforeCut and afterCut during cutting out operation', function () {
|
442
340
|
var beforeCutSpy = jasmine.createSpy('beforeCut');
|
443
341
|
var afterCutSpy = jasmine.createSpy('afterCut');
|
444
342
|
|
445
|
-
handsontable({
|
343
|
+
var hot = handsontable({
|
446
344
|
data: Handsontable.helper.createSpreadsheetData(2, 2),
|
447
345
|
beforeCut: beforeCutSpy,
|
448
346
|
afterCut: afterCutSpy
|
449
347
|
});
|
348
|
+
var cutEvent = getClipboardEvent('cut');
|
349
|
+
var plugin = hot.getPlugin('CopyPaste');
|
450
350
|
|
451
351
|
selectCell(0, 0);
|
452
|
-
|
453
|
-
|
352
|
+
|
353
|
+
plugin.setCopyableText();
|
354
|
+
plugin.onCut(cutEvent);
|
454
355
|
|
455
356
|
expect(beforeCutSpy.calls.count()).toEqual(1);
|
456
357
|
expect(beforeCutSpy).toHaveBeenCalledWith([['A1']], [{ startRow: 0, startCol: 0, endRow: 0, endCol: 0 }], void 0, void 0, void 0, void 0);
|
@@ -62,7 +62,7 @@ describe('CopyPaste', function () {
|
|
62
62
|
var textarea = _textarea2.default.getSingleton();
|
63
63
|
var newValue = 'zxcvb';
|
64
64
|
|
65
|
-
expect(textarea.element.value.length).toBe(
|
65
|
+
expect(textarea.element.value.length).toBe(1);
|
66
66
|
|
67
67
|
textarea.setValue(newValue);
|
68
68
|
|
@@ -75,7 +75,7 @@ describe('CopyPaste', function () {
|
|
75
75
|
var textarea = _textarea2.default.getSingleton();
|
76
76
|
var newValue = 'zxcvb';
|
77
77
|
|
78
|
-
expect(textarea.getValue().length).toBe(
|
78
|
+
expect(textarea.getValue().length).toBe(1);
|
79
79
|
|
80
80
|
textarea.setValue(newValue);
|
81
81
|
|
@@ -177,14 +177,14 @@ var ManualColumnMove = function (_BasePlugin) {
|
|
177
177
|
this.addHook('beforeRemoveCol', function (index, amount) {
|
178
178
|
return _this2.onBeforeRemoveCol(index, amount);
|
179
179
|
});
|
180
|
-
this.addHook('afterRemoveCol', function (
|
181
|
-
return _this2.onAfterRemoveCol(
|
180
|
+
this.addHook('afterRemoveCol', function () {
|
181
|
+
return _this2.onAfterRemoveCol();
|
182
182
|
});
|
183
183
|
this.addHook('afterCreateCol', function (index, amount) {
|
184
184
|
return _this2.onAfterCreateCol(index, amount);
|
185
185
|
});
|
186
|
-
this.addHook('afterLoadData', function (
|
187
|
-
return _this2.onAfterLoadData(
|
186
|
+
this.addHook('afterLoadData', function () {
|
187
|
+
return _this2.onAfterLoadData();
|
188
188
|
});
|
189
189
|
this.addHook('unmodifyCol', function (column) {
|
190
190
|
return _this2.onUnmodifyCol(column);
|
@@ -324,7 +324,7 @@ var ManualColumnMove = function (_BasePlugin) {
|
|
324
324
|
var columnWidth = 0;
|
325
325
|
|
326
326
|
if (i < 0) {
|
327
|
-
columnWidth = this.hot.view.wt.
|
327
|
+
columnWidth = this.hot.view.wt.wtViewport.getRowHeaderWidth() || 0;
|
328
328
|
} else {
|
329
329
|
columnWidth = this.hot.view.wt.wtTable.getStretchedColumnWidth(i) || 0;
|
330
330
|
}
|
@@ -530,7 +530,7 @@ var ManualColumnMove = function (_BasePlugin) {
|
|
530
530
|
var maxIndex = countCols - 1;
|
531
531
|
var columnsToRemove = [];
|
532
532
|
|
533
|
-
(0, _array.arrayEach)(this.columnsMapper._arrayMap, function (value, index
|
533
|
+
(0, _array.arrayEach)(this.columnsMapper._arrayMap, function (value, index) {
|
534
534
|
if (value > maxIndex) {
|
535
535
|
columnsToRemove.push(index);
|
536
536
|
}
|
@@ -805,13 +805,11 @@ var ManualColumnMove = function (_BasePlugin) {
|
|
805
805
|
* `afterRemoveCol` hook callback.
|
806
806
|
*
|
807
807
|
* @private
|
808
|
-
* @param {Number} index Visual column index of the removed column.
|
809
|
-
* @param {Number} amount Amount of removed columns.
|
810
808
|
*/
|
811
809
|
|
812
810
|
}, {
|
813
811
|
key: 'onAfterRemoveCol',
|
814
|
-
value: function onAfterRemoveCol(
|
812
|
+
value: function onAfterRemoveCol() {
|
815
813
|
this.columnsMapper.unshiftItems(this.removedColumns);
|
816
814
|
}
|
817
815
|
|
@@ -819,12 +817,11 @@ var ManualColumnMove = function (_BasePlugin) {
|
|
819
817
|
* `afterLoadData` hook callback.
|
820
818
|
*
|
821
819
|
* @private
|
822
|
-
* @param {Boolean} firstTime True if that was loading data during the initialization.
|
823
820
|
*/
|
824
821
|
|
825
822
|
}, {
|
826
823
|
key: 'onAfterLoadData',
|
827
|
-
value: function onAfterLoadData(
|
824
|
+
value: function onAfterLoadData() {
|
828
825
|
this.updateColumnsMapper();
|
829
826
|
}
|
830
827
|
|
@@ -104,6 +104,41 @@ describe('manualColumnMove', function () {
|
|
104
104
|
expect(this.$container.find('.ht__manualColumnMove--backlight')[0].offsetWidth).toBe($headerTH[0].offsetWidth);
|
105
105
|
});
|
106
106
|
|
107
|
+
it('should set proper left position of the backlight element when colWidths is undefined', function () {
|
108
|
+
handsontable({
|
109
|
+
data: Handsontable.helper.createSpreadsheetData(10, 10),
|
110
|
+
manualColumnMove: true,
|
111
|
+
rowHeaders: true,
|
112
|
+
colHeaders: true
|
113
|
+
});
|
114
|
+
|
115
|
+
var header = spec().$container.find('thead tr:eq(0) th:eq(2)');
|
116
|
+
|
117
|
+
header.simulate('mousedown');
|
118
|
+
header.simulate('mouseup');
|
119
|
+
header.simulate('mousedown');
|
120
|
+
|
121
|
+
expect(spec().$container.find('.ht__manualColumnMove--backlight')[0].offsetLeft).toBe(100);
|
122
|
+
});
|
123
|
+
|
124
|
+
it('should set proper left position of the backlight element when colWidths is defined', function () {
|
125
|
+
handsontable({
|
126
|
+
data: Handsontable.helper.createSpreadsheetData(10, 10),
|
127
|
+
manualColumnMove: true,
|
128
|
+
rowHeaders: true,
|
129
|
+
colWidths: 100,
|
130
|
+
colHeaders: true
|
131
|
+
});
|
132
|
+
|
133
|
+
var header = spec().$container.find('thead tr:eq(0) th:eq(2)');
|
134
|
+
|
135
|
+
header.simulate('mousedown');
|
136
|
+
header.simulate('mouseup');
|
137
|
+
header.simulate('mousedown');
|
138
|
+
|
139
|
+
expect(spec().$container.find('.ht__manualColumnMove--backlight')[0].offsetLeft).toBe(150);
|
140
|
+
});
|
141
|
+
|
107
142
|
it('should not run moving ui if mousedown was fired on sorting element', function () {
|
108
143
|
var hot = handsontable({
|
109
144
|
data: arrayOfArrays.slice(),
|
@@ -175,14 +175,14 @@ var ManualRowMove = function (_BasePlugin) {
|
|
175
175
|
this.addHook('beforeRemoveRow', function (index, amount) {
|
176
176
|
return _this2.onBeforeRemoveRow(index, amount);
|
177
177
|
});
|
178
|
-
this.addHook('afterRemoveRow', function (
|
179
|
-
return _this2.onAfterRemoveRow(
|
178
|
+
this.addHook('afterRemoveRow', function () {
|
179
|
+
return _this2.onAfterRemoveRow();
|
180
180
|
});
|
181
181
|
this.addHook('afterCreateRow', function (index, amount) {
|
182
182
|
return _this2.onAfterCreateRow(index, amount);
|
183
183
|
});
|
184
|
-
this.addHook('afterLoadData', function (
|
185
|
-
return _this2.onAfterLoadData(
|
184
|
+
this.addHook('afterLoadData', function () {
|
185
|
+
return _this2.onAfterLoadData();
|
186
186
|
});
|
187
187
|
this.addHook('beforeColumnSort', function (column, order) {
|
188
188
|
return _this2.onBeforeColumnSort(column, order);
|
@@ -545,7 +545,7 @@ var ManualRowMove = function (_BasePlugin) {
|
|
545
545
|
var maxIndex = countRows - 1;
|
546
546
|
var rowsToRemove = [];
|
547
547
|
|
548
|
-
(0, _array.arrayEach)(this.rowsMapper._arrayMap, function (value, index
|
548
|
+
(0, _array.arrayEach)(this.rowsMapper._arrayMap, function (value, index) {
|
549
549
|
if (value > maxIndex) {
|
550
550
|
rowsToRemove.push(index);
|
551
551
|
}
|
@@ -649,7 +649,7 @@ var ManualRowMove = function (_BasePlugin) {
|
|
649
649
|
priv.target.TD = TD;
|
650
650
|
priv.rowsToMove = this.prepareRowsToMoving();
|
651
651
|
|
652
|
-
var leftPos = wtTable.holder.scrollLeft +
|
652
|
+
var leftPos = wtTable.holder.scrollLeft + this.hot.view.wt.wtViewport.getRowHeaderWidth();
|
653
653
|
|
654
654
|
this.backlight.setPosition(null, leftPos);
|
655
655
|
this.backlight.setSize(wtTable.hider.offsetWidth - leftPos, this.getRowsHeight(start, end + 1));
|
@@ -778,7 +778,7 @@ var ManualRowMove = function (_BasePlugin) {
|
|
778
778
|
key: 'onAfterScrollHorizontally',
|
779
779
|
value: function onAfterScrollHorizontally() {
|
780
780
|
var wtTable = this.hot.view.wt.wtTable;
|
781
|
-
var headerWidth =
|
781
|
+
var headerWidth = this.hot.view.wt.wtViewport.getRowHeaderWidth();
|
782
782
|
var scrollLeft = wtTable.holder.scrollLeft;
|
783
783
|
var posLeft = headerWidth + scrollLeft;
|
784
784
|
|
@@ -827,13 +827,11 @@ var ManualRowMove = function (_BasePlugin) {
|
|
827
827
|
* `afterRemoveRow` hook callback.
|
828
828
|
*
|
829
829
|
* @private
|
830
|
-
* @param {Number} index Visual index of the removed row.
|
831
|
-
* @param {Number} amount Amount of removed rows.
|
832
830
|
*/
|
833
831
|
|
834
832
|
}, {
|
835
833
|
key: 'onAfterRemoveRow',
|
836
|
-
value: function onAfterRemoveRow(
|
834
|
+
value: function onAfterRemoveRow() {
|
837
835
|
this.rowsMapper.unshiftItems(this.removedRows);
|
838
836
|
}
|
839
837
|
|
@@ -841,12 +839,11 @@ var ManualRowMove = function (_BasePlugin) {
|
|
841
839
|
* `afterLoadData` hook callback.
|
842
840
|
*
|
843
841
|
* @private
|
844
|
-
* @param {Boolean} firstTime True if that was loading data during the initialization.
|
845
842
|
*/
|
846
843
|
|
847
844
|
}, {
|
848
845
|
key: 'onAfterLoadData',
|
849
|
-
value: function onAfterLoadData(
|
846
|
+
value: function onAfterLoadData() {
|
850
847
|
this.updateRowsMapper();
|
851
848
|
}
|
852
849
|
|