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
@@ -12,6 +12,25 @@ describe('CopyPaste', () => {
|
|
12
12
|
}
|
13
13
|
});
|
14
14
|
|
15
|
+
class DataTransferObject {
|
16
|
+
constructor() {
|
17
|
+
this.data = '';
|
18
|
+
}
|
19
|
+
getData() {
|
20
|
+
return this.data;
|
21
|
+
}
|
22
|
+
setData(type, value) {
|
23
|
+
this.data = value;
|
24
|
+
}
|
25
|
+
};
|
26
|
+
|
27
|
+
function getClipboardEvent() {
|
28
|
+
let event = {};
|
29
|
+
event.clipboardData = new DataTransferObject();
|
30
|
+
event.preventDefault = () => {};
|
31
|
+
return event;
|
32
|
+
}
|
33
|
+
|
15
34
|
const arrayOfArrays = function() {
|
16
35
|
return [
|
17
36
|
['', 'Kia', 'Nissan', 'Toyota', 'Honda'],
|
@@ -81,67 +100,7 @@ describe('CopyPaste', () => {
|
|
81
100
|
});
|
82
101
|
});
|
83
102
|
|
84
|
-
|
85
|
-
it('should set copyable text when selecting a single cell and hitting ctrl', () => {
|
86
|
-
handsontable({
|
87
|
-
data: Handsontable.helper.createSpreadsheetData(2, 2)
|
88
|
-
});
|
89
|
-
|
90
|
-
const copyPasteTextarea = $('#HandsontableCopyPaste')[0];
|
91
|
-
|
92
|
-
expect(copyPasteTextarea.value.length).toEqual(0);
|
93
|
-
|
94
|
-
selectCell(0, 0);
|
95
|
-
keyDownUp(Handsontable.helper.KEY_CODES.CONTROL_LEFT);
|
96
|
-
|
97
|
-
expect(copyPasteTextarea.value).toEqual('A1');
|
98
|
-
});
|
99
|
-
|
100
|
-
it('should set copyable text when selecting a single cell and hitting left command', () => {
|
101
|
-
handsontable({
|
102
|
-
data: Handsontable.helper.createSpreadsheetData(2, 2)
|
103
|
-
});
|
104
|
-
|
105
|
-
const copyPasteTextarea = $('#HandsontableCopyPaste')[0];
|
106
|
-
|
107
|
-
expect(copyPasteTextarea.value.length).toEqual(0);
|
108
|
-
|
109
|
-
selectCell(0, 0);
|
110
|
-
keyDownUp(Handsontable.helper.KEY_CODES.COMMAND_LEFT);
|
111
|
-
|
112
|
-
expect(copyPasteTextarea.value).toEqual('A1');
|
113
|
-
});
|
114
|
-
|
115
|
-
it('should set copyable text when selecting a single cell and hitting right command', () => {
|
116
|
-
handsontable({
|
117
|
-
data: Handsontable.helper.createSpreadsheetData(2, 2)
|
118
|
-
});
|
119
|
-
|
120
|
-
const copyPasteTextarea = $('#HandsontableCopyPaste')[0];
|
121
|
-
|
122
|
-
expect(copyPasteTextarea.value.length).toEqual(0);
|
123
|
-
|
124
|
-
selectCell(0, 0);
|
125
|
-
keyDownUp(Handsontable.helper.KEY_CODES.COMMAND_RIGHT);
|
126
|
-
|
127
|
-
expect(copyPasteTextarea.value).toEqual('A1');
|
128
|
-
});
|
129
|
-
|
130
|
-
it('should set copyable text when selecting multiple cells and hitting ctrl', () => {
|
131
|
-
handsontable({
|
132
|
-
data: Handsontable.helper.createSpreadsheetData(2, 2)
|
133
|
-
});
|
134
|
-
|
135
|
-
const copyPasteTextarea = $('#HandsontableCopyPaste')[0];
|
136
|
-
|
137
|
-
expect(copyPasteTextarea.value.length).toEqual(0);
|
138
|
-
|
139
|
-
selectCell(0, 0, 1, 0);
|
140
|
-
keyDownUp(Handsontable.helper.KEY_CODES.CONTROL_LEFT);
|
141
|
-
|
142
|
-
expect(copyPasteTextarea.value).toEqual('A1\nA2');
|
143
|
-
});
|
144
|
-
|
103
|
+
xdescribe('setting values copyable', () => {
|
145
104
|
it('should set copyable text when selecting all cells with CTRL+A', (done) => {
|
146
105
|
handsontable({
|
147
106
|
data: Handsontable.helper.createSpreadsheetData(2, 2)
|
@@ -162,24 +121,6 @@ describe('CopyPaste', () => {
|
|
162
121
|
}, 10);
|
163
122
|
});
|
164
123
|
|
165
|
-
it('should not throw error when no cell is selected (#1221)', () => {
|
166
|
-
handsontable({
|
167
|
-
data: Handsontable.helper.createSpreadsheetData(2, 2)
|
168
|
-
});
|
169
|
-
|
170
|
-
selectCell(0, 0);
|
171
|
-
deselectCell();
|
172
|
-
|
173
|
-
function keydownCtrl() {
|
174
|
-
$(document).simulate('keydown', {
|
175
|
-
keyCode: Handsontable.helper.KEY_CODES.COMMAND_LEFT
|
176
|
-
});
|
177
|
-
}
|
178
|
-
|
179
|
-
// expect no to throw any exception
|
180
|
-
expect(keydownCtrl).not.toThrow();
|
181
|
-
});
|
182
|
-
|
183
124
|
it('should not throw error when no cell is selected and contextmenu options was clicked', () => {
|
184
125
|
// This is ugly trick to check problematic thing (#4390).
|
185
126
|
// Unfortunately we cannot open the context menu, when event.target is not an TD element.
|
@@ -211,25 +152,6 @@ describe('CopyPaste', () => {
|
|
211
152
|
expect(copyPasteTextarea.value).toEqual('A\t1\nB\t2');
|
212
153
|
});
|
213
154
|
|
214
|
-
it('should set copyable text when selecting a single cell with editor type as false (#2574)', () => {
|
215
|
-
handsontable({
|
216
|
-
data: [['A', 1], ['B', 2]],
|
217
|
-
columns: [
|
218
|
-
{ type: 'text' },
|
219
|
-
{ editor: false }
|
220
|
-
]
|
221
|
-
});
|
222
|
-
|
223
|
-
const copyPasteTextarea = $('#HandsontableCopyPaste')[0];
|
224
|
-
|
225
|
-
expect(copyPasteTextarea.value.length).toEqual(0);
|
226
|
-
|
227
|
-
selectCell(1, 1, 1, 1);
|
228
|
-
keyDownUp(Handsontable.helper.KEY_CODES.CONTROL_LEFT);
|
229
|
-
|
230
|
-
expect(copyPasteTextarea.value).toEqual('2');
|
231
|
-
});
|
232
|
-
|
233
155
|
it('should set copyable text until copyRowsLimit is reached', () => {
|
234
156
|
handsontable({
|
235
157
|
data: arrayOfArrays(),
|
@@ -281,67 +203,46 @@ describe('CopyPaste', () => {
|
|
281
203
|
});
|
282
204
|
|
283
205
|
describe('copy', () => {
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
});
|
288
|
-
|
289
|
-
selectCell(1, 1);
|
290
|
-
keyDown('ctrl');
|
291
|
-
keyDown('ctrl+c');
|
206
|
+
xit('should be possible to copy data by keyboard shortcut', () => {
|
207
|
+
// simulated keyboard shortcuts doesn't run the true events
|
208
|
+
});
|
292
209
|
|
293
|
-
|
294
|
-
//
|
210
|
+
xit('should be possible to copy data by contextMenu option', () => {
|
211
|
+
// simulated mouse events doesn't run the true browser event
|
295
212
|
});
|
296
213
|
|
297
214
|
it('should be possible to copy data by API', () => {
|
298
215
|
const hot = handsontable({
|
299
216
|
data: Handsontable.helper.createSpreadsheetData(2, 2),
|
300
217
|
});
|
218
|
+
const copyEvent = getClipboardEvent('copy');
|
219
|
+
const plugin = hot.getPlugin('CopyPaste');
|
301
220
|
|
302
221
|
selectCell(1, 0);
|
303
222
|
|
304
|
-
|
305
|
-
|
306
|
-
hot.getPlugin('CopyPaste').copy(true);
|
223
|
+
plugin.setCopyableText();
|
224
|
+
plugin.onCopy(copyEvent);
|
307
225
|
|
308
|
-
expect(
|
309
|
-
// unfortunately we have not access to read data from the system clipboard
|
310
|
-
});
|
311
|
-
|
312
|
-
it('should be possible to copy data by contextMenu option', () => {
|
313
|
-
const beforeCopySpy = jasmine.createSpy('beforeCopy');
|
314
|
-
|
315
|
-
handsontable({
|
316
|
-
data: Handsontable.helper.createSpreadsheetData(2, 2),
|
317
|
-
beforeCopy: beforeCopySpy,
|
318
|
-
contextMenu: ['copy']
|
319
|
-
});
|
320
|
-
|
321
|
-
selectCell(0, 1);
|
322
|
-
contextMenu();
|
323
|
-
|
324
|
-
const items = $('.htContextMenu tbody td');
|
325
|
-
const actions = items.not('.htSeparator');
|
326
|
-
|
327
|
-
actions.simulate('mousedown');
|
328
|
-
|
329
|
-
expect(beforeCopySpy).toHaveBeenCalledTimes(1);
|
226
|
+
expect(copyEvent.clipboardData.getData()).toBe('A2');
|
330
227
|
});
|
331
228
|
|
332
229
|
it('should call beforeCopy and afterCopy during copying operation', () => {
|
333
230
|
const beforeCopySpy = jasmine.createSpy('beforeCopy');
|
334
231
|
const afterCopySpy = jasmine.createSpy('afterCopy');
|
335
232
|
|
336
|
-
handsontable({
|
233
|
+
const hot = handsontable({
|
337
234
|
data: Handsontable.helper.createSpreadsheetData(2, 2),
|
338
235
|
beforeCopy: beforeCopySpy,
|
339
|
-
afterCopy: afterCopySpy
|
236
|
+
afterCopy: afterCopySpy,
|
340
237
|
});
|
341
238
|
|
239
|
+
const copyEvent = getClipboardEvent('copy');
|
240
|
+
const plugin = hot.getPlugin('CopyPaste');
|
241
|
+
|
342
242
|
selectCell(0, 0);
|
343
|
-
|
344
|
-
|
243
|
+
|
244
|
+
plugin.setCopyableText();
|
245
|
+
plugin.onCopy(copyEvent);
|
345
246
|
|
346
247
|
expect(beforeCopySpy.calls.count()).toEqual(1);
|
347
248
|
expect(beforeCopySpy).toHaveBeenCalledWith([['A1']], [{startRow: 0, startCol: 0, endRow: 0, endCol: 0}], void 0, void 0, void 0, void 0);
|
@@ -350,111 +251,92 @@ describe('CopyPaste', () => {
|
|
350
251
|
});
|
351
252
|
|
352
253
|
it('should be possible to block copying', () => {
|
254
|
+
const beforeCopySpy = jasmine.createSpy('beforeCopy');
|
353
255
|
const afterCopySpy = jasmine.createSpy('afterCopy');
|
354
256
|
|
355
|
-
handsontable({
|
257
|
+
const hot = handsontable({
|
356
258
|
data: Handsontable.helper.createSpreadsheetData(2, 2),
|
357
259
|
beforeCopy() {
|
260
|
+
beforeCopySpy();
|
358
261
|
return false;
|
359
262
|
},
|
360
|
-
afterCopy: afterCopySpy
|
263
|
+
afterCopy: afterCopySpy,
|
361
264
|
});
|
362
265
|
|
266
|
+
const copyEvent = getClipboardEvent('copy');
|
267
|
+
const plugin = hot.getPlugin('CopyPaste');
|
268
|
+
|
363
269
|
selectCell(0, 0);
|
364
|
-
keyDown('ctrl');
|
365
|
-
keyDown('ctrl+c');
|
366
270
|
|
271
|
+
plugin.setCopyableText();
|
272
|
+
plugin.onCopy(copyEvent);
|
273
|
+
|
274
|
+
expect(beforeCopySpy.calls.count()).toEqual(1);
|
367
275
|
expect(afterCopySpy.calls.count()).toEqual(0);
|
368
276
|
});
|
369
277
|
|
370
|
-
it('should be possible modification of changes during copying',
|
371
|
-
handsontable({
|
278
|
+
it('should be possible modification of changes during copying', () => {
|
279
|
+
const hot = handsontable({
|
372
280
|
data: Handsontable.helper.createSpreadsheetData(2, 2),
|
373
281
|
beforeCopy(changes) {
|
374
282
|
changes.splice(0, 1);
|
375
|
-
}
|
283
|
+
},
|
376
284
|
});
|
377
285
|
|
286
|
+
const copyEvent = getClipboardEvent('copy');
|
287
|
+
const plugin = hot.getPlugin('CopyPaste');
|
378
288
|
selectCell(0, 0, 1, 0);
|
379
|
-
keyDown('ctrl');
|
380
|
-
keyDown('ctrl+c');
|
381
289
|
|
382
|
-
|
290
|
+
plugin.setCopyableText();
|
291
|
+
plugin.onCopy(copyEvent);
|
383
292
|
|
384
|
-
expect(
|
293
|
+
expect(copyEvent.clipboardData.getData()).toEqual('A2');
|
385
294
|
});
|
386
295
|
});
|
387
296
|
|
388
297
|
describe('cut', () => {
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
});
|
393
|
-
|
394
|
-
selectCell(1, 1);
|
395
|
-
keyDown('ctrl');
|
396
|
-
keyDown('ctrl+x');
|
397
|
-
|
398
|
-
expect($('#HandsontableCopyPaste')[0]).toBe(document.activeElement);
|
399
|
-
|
400
|
-
await sleep(100);
|
298
|
+
xit('should be possible to cut data by keyboard shortcut', () => {
|
299
|
+
// simulated keyboard shortcuts doesn't run the true events
|
300
|
+
});
|
401
301
|
|
402
|
-
|
403
|
-
//
|
302
|
+
xit('should be possible to cut data by contextMenu option', () => {
|
303
|
+
// simulated mouse events doesn't run the true browser event
|
404
304
|
});
|
405
305
|
|
406
|
-
it('should be possible to cut data by API',
|
306
|
+
it('should be possible to cut data by API', () => {
|
407
307
|
const hot = handsontable({
|
408
308
|
data: Handsontable.helper.createSpreadsheetData(2, 2),
|
409
309
|
});
|
310
|
+
const cutEvent = getClipboardEvent('cut');
|
311
|
+
const plugin = hot.getPlugin('CopyPaste');
|
410
312
|
|
411
313
|
selectCell(1, 0);
|
412
314
|
|
413
|
-
|
414
|
-
|
415
|
-
hot.getPlugin('CopyPaste').cut(true);
|
315
|
+
plugin.setCopyableText();
|
316
|
+
plugin.onCut(cutEvent);
|
416
317
|
|
417
|
-
expect(
|
418
|
-
|
419
|
-
await sleep(100);
|
318
|
+
expect(cutEvent.clipboardData.getData()).toBe('A2');
|
420
319
|
|
320
|
+
// await sleep(100);
|
421
321
|
expect(hot.getDataAtCell(1, 0)).toBe('');
|
422
|
-
// unfortunately we have not access to read data from the system clipboard
|
423
|
-
});
|
424
|
-
|
425
|
-
it('should be possible to cut data by contextMenu option', () => {
|
426
|
-
const beforeCutSpy = jasmine.createSpy('beforeCopy');
|
427
|
-
|
428
|
-
handsontable({
|
429
|
-
data: Handsontable.helper.createSpreadsheetData(2, 2),
|
430
|
-
beforeCut: beforeCutSpy,
|
431
|
-
contextMenu: ['cut']
|
432
|
-
});
|
433
|
-
|
434
|
-
selectCell(0, 1);
|
435
|
-
contextMenu();
|
436
|
-
|
437
|
-
const items = $('.htContextMenu tbody td');
|
438
|
-
const actions = items.not('.htSeparator');
|
439
|
-
|
440
|
-
actions.simulate('mousedown');
|
441
|
-
|
442
|
-
expect(beforeCutSpy).toHaveBeenCalledTimes(1);
|
443
322
|
});
|
444
323
|
|
445
324
|
it('should call beforeCut and afterCut during cutting out operation', () => {
|
446
325
|
const beforeCutSpy = jasmine.createSpy('beforeCut');
|
447
326
|
const afterCutSpy = jasmine.createSpy('afterCut');
|
448
327
|
|
449
|
-
handsontable({
|
328
|
+
const hot = handsontable({
|
450
329
|
data: Handsontable.helper.createSpreadsheetData(2, 2),
|
451
330
|
beforeCut: beforeCutSpy,
|
452
331
|
afterCut: afterCutSpy
|
453
332
|
});
|
333
|
+
const cutEvent = getClipboardEvent('cut');
|
334
|
+
const plugin = hot.getPlugin('CopyPaste');
|
454
335
|
|
455
336
|
selectCell(0, 0);
|
456
|
-
|
457
|
-
|
337
|
+
|
338
|
+
plugin.setCopyableText();
|
339
|
+
plugin.onCut(cutEvent);
|
458
340
|
|
459
341
|
expect(beforeCutSpy.calls.count()).toEqual(1);
|
460
342
|
expect(beforeCutSpy).toHaveBeenCalledWith([['A1']], [{startRow: 0, startCol: 0, endRow: 0, endCol: 0}], void 0, void 0, void 0, void 0);
|
@@ -56,7 +56,7 @@ describe('CopyPaste', () => {
|
|
56
56
|
const textarea = Textarea.getSingleton();
|
57
57
|
const newValue = 'zxcvb';
|
58
58
|
|
59
|
-
expect(textarea.element.value.length).toBe(
|
59
|
+
expect(textarea.element.value.length).toBe(1);
|
60
60
|
|
61
61
|
textarea.setValue(newValue);
|
62
62
|
|
@@ -69,7 +69,7 @@ describe('CopyPaste', () => {
|
|
69
69
|
const textarea = Textarea.getSingleton();
|
70
70
|
const newValue = 'zxcvb';
|
71
71
|
|
72
|
-
expect(textarea.getValue().length).toBe(
|
72
|
+
expect(textarea.getValue().length).toBe(1);
|
73
73
|
|
74
74
|
textarea.setValue(newValue);
|
75
75
|
|
@@ -116,9 +116,9 @@ class ManualColumnMove extends BasePlugin {
|
|
116
116
|
this.addHook('afterScrollVertically', () => this.onAfterScrollVertically());
|
117
117
|
this.addHook('modifyCol', (row, source) => this.onModifyCol(row, source));
|
118
118
|
this.addHook('beforeRemoveCol', (index, amount) => this.onBeforeRemoveCol(index, amount));
|
119
|
-
this.addHook('afterRemoveCol', (
|
119
|
+
this.addHook('afterRemoveCol', () => this.onAfterRemoveCol());
|
120
120
|
this.addHook('afterCreateCol', (index, amount) => this.onAfterCreateCol(index, amount));
|
121
|
-
this.addHook('afterLoadData', (
|
121
|
+
this.addHook('afterLoadData', () => this.onAfterLoadData());
|
122
122
|
this.addHook('unmodifyCol', (column) => this.onUnmodifyCol(column));
|
123
123
|
|
124
124
|
this.registerEvents();
|
@@ -235,7 +235,7 @@ class ManualColumnMove extends BasePlugin {
|
|
235
235
|
let columnWidth = 0;
|
236
236
|
|
237
237
|
if (i < 0) {
|
238
|
-
columnWidth = this.hot.view.wt.
|
238
|
+
columnWidth = this.hot.view.wt.wtViewport.getRowHeaderWidth() || 0;
|
239
239
|
} else {
|
240
240
|
columnWidth = this.hot.view.wt.wtTable.getStretchedColumnWidth(i) || 0;
|
241
241
|
}
|
@@ -428,7 +428,7 @@ class ManualColumnMove extends BasePlugin {
|
|
428
428
|
let maxIndex = countCols - 1;
|
429
429
|
let columnsToRemove = [];
|
430
430
|
|
431
|
-
arrayEach(this.columnsMapper._arrayMap, (value, index
|
431
|
+
arrayEach(this.columnsMapper._arrayMap, (value, index) => {
|
432
432
|
if (value > maxIndex) {
|
433
433
|
columnsToRemove.push(index);
|
434
434
|
}
|
@@ -668,10 +668,8 @@ class ManualColumnMove extends BasePlugin {
|
|
668
668
|
* `afterRemoveCol` hook callback.
|
669
669
|
*
|
670
670
|
* @private
|
671
|
-
* @param {Number} index Visual column index of the removed column.
|
672
|
-
* @param {Number} amount Amount of removed columns.
|
673
671
|
*/
|
674
|
-
onAfterRemoveCol(
|
672
|
+
onAfterRemoveCol() {
|
675
673
|
this.columnsMapper.unshiftItems(this.removedColumns);
|
676
674
|
}
|
677
675
|
|
@@ -679,9 +677,8 @@ class ManualColumnMove extends BasePlugin {
|
|
679
677
|
* `afterLoadData` hook callback.
|
680
678
|
*
|
681
679
|
* @private
|
682
|
-
* @param {Boolean} firstTime True if that was loading data during the initialization.
|
683
680
|
*/
|
684
|
-
onAfterLoadData(
|
681
|
+
onAfterLoadData() {
|
685
682
|
this.updateColumnsMapper();
|
686
683
|
}
|
687
684
|
|
@@ -116,6 +116,41 @@ describe('manualColumnMove', () => {
|
|
116
116
|
expect(this.$container.find('.ht__manualColumnMove--backlight')[0].offsetWidth).toBe($headerTH[0].offsetWidth);
|
117
117
|
});
|
118
118
|
|
119
|
+
it('should set proper left position of the backlight element when colWidths is undefined', () => {
|
120
|
+
handsontable({
|
121
|
+
data: Handsontable.helper.createSpreadsheetData(10, 10),
|
122
|
+
manualColumnMove: true,
|
123
|
+
rowHeaders: true,
|
124
|
+
colHeaders: true,
|
125
|
+
});
|
126
|
+
|
127
|
+
let header = spec().$container.find('thead tr:eq(0) th:eq(2)');
|
128
|
+
|
129
|
+
header.simulate('mousedown');
|
130
|
+
header.simulate('mouseup');
|
131
|
+
header.simulate('mousedown');
|
132
|
+
|
133
|
+
expect(spec().$container.find('.ht__manualColumnMove--backlight')[0].offsetLeft).toBe(100);
|
134
|
+
});
|
135
|
+
|
136
|
+
it('should set proper left position of the backlight element when colWidths is defined', () => {
|
137
|
+
handsontable({
|
138
|
+
data: Handsontable.helper.createSpreadsheetData(10, 10),
|
139
|
+
manualColumnMove: true,
|
140
|
+
rowHeaders: true,
|
141
|
+
colWidths: 100,
|
142
|
+
colHeaders: true,
|
143
|
+
});
|
144
|
+
|
145
|
+
let header = spec().$container.find('thead tr:eq(0) th:eq(2)');
|
146
|
+
|
147
|
+
header.simulate('mousedown');
|
148
|
+
header.simulate('mouseup');
|
149
|
+
header.simulate('mousedown');
|
150
|
+
|
151
|
+
expect(spec().$container.find('.ht__manualColumnMove--backlight')[0].offsetLeft).toBe(150);
|
152
|
+
});
|
153
|
+
|
119
154
|
it('should not run moving ui if mousedown was fired on sorting element', function() {
|
120
155
|
var hot = handsontable({
|
121
156
|
data: arrayOfArrays.slice(),
|
@@ -114,9 +114,9 @@ class ManualRowMove extends BasePlugin {
|
|
114
114
|
this.addHook('afterScrollHorizontally', () => this.onAfterScrollHorizontally());
|
115
115
|
this.addHook('modifyRow', (row, source) => this.onModifyRow(row, source));
|
116
116
|
this.addHook('beforeRemoveRow', (index, amount) => this.onBeforeRemoveRow(index, amount));
|
117
|
-
this.addHook('afterRemoveRow', (
|
117
|
+
this.addHook('afterRemoveRow', () => this.onAfterRemoveRow());
|
118
118
|
this.addHook('afterCreateRow', (index, amount) => this.onAfterCreateRow(index, amount));
|
119
|
-
this.addHook('afterLoadData', (
|
119
|
+
this.addHook('afterLoadData', () => this.onAfterLoadData());
|
120
120
|
this.addHook('beforeColumnSort', (column, order) => this.onBeforeColumnSort(column, order));
|
121
121
|
this.addHook('unmodifyRow', (row) => this.onUnmodifyRow(row));
|
122
122
|
|
@@ -434,7 +434,7 @@ class ManualRowMove extends BasePlugin {
|
|
434
434
|
let maxIndex = countRows - 1;
|
435
435
|
let rowsToRemove = [];
|
436
436
|
|
437
|
-
arrayEach(this.rowsMapper._arrayMap, (value, index
|
437
|
+
arrayEach(this.rowsMapper._arrayMap, (value, index) => {
|
438
438
|
if (value > maxIndex) {
|
439
439
|
rowsToRemove.push(index);
|
440
440
|
}
|
@@ -518,7 +518,7 @@ class ManualRowMove extends BasePlugin {
|
|
518
518
|
priv.target.TD = TD;
|
519
519
|
priv.rowsToMove = this.prepareRowsToMoving();
|
520
520
|
|
521
|
-
let leftPos = wtTable.holder.scrollLeft +
|
521
|
+
let leftPos = wtTable.holder.scrollLeft + this.hot.view.wt.wtViewport.getRowHeaderWidth();
|
522
522
|
|
523
523
|
this.backlight.setPosition(null, leftPos);
|
524
524
|
this.backlight.setSize(wtTable.hider.offsetWidth - leftPos, this.getRowsHeight(start, end + 1));
|
@@ -638,7 +638,7 @@ class ManualRowMove extends BasePlugin {
|
|
638
638
|
*/
|
639
639
|
onAfterScrollHorizontally() {
|
640
640
|
let wtTable = this.hot.view.wt.wtTable;
|
641
|
-
let headerWidth =
|
641
|
+
let headerWidth = this.hot.view.wt.wtViewport.getRowHeaderWidth();
|
642
642
|
let scrollLeft = wtTable.holder.scrollLeft;
|
643
643
|
let posLeft = headerWidth + scrollLeft;
|
644
644
|
|
@@ -679,10 +679,8 @@ class ManualRowMove extends BasePlugin {
|
|
679
679
|
* `afterRemoveRow` hook callback.
|
680
680
|
*
|
681
681
|
* @private
|
682
|
-
* @param {Number} index Visual index of the removed row.
|
683
|
-
* @param {Number} amount Amount of removed rows.
|
684
682
|
*/
|
685
|
-
onAfterRemoveRow(
|
683
|
+
onAfterRemoveRow() {
|
686
684
|
this.rowsMapper.unshiftItems(this.removedRows);
|
687
685
|
}
|
688
686
|
|
@@ -690,9 +688,8 @@ class ManualRowMove extends BasePlugin {
|
|
690
688
|
* `afterLoadData` hook callback.
|
691
689
|
*
|
692
690
|
* @private
|
693
|
-
* @param {Boolean} firstTime True if that was loading data during the initialization.
|
694
691
|
*/
|
695
|
-
onAfterLoadData(
|
692
|
+
onAfterLoadData() {
|
696
693
|
this.updateRowsMapper();
|
697
694
|
}
|
698
695
|
|