@atlaskit/editor-plugin-table 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/plugins/table/commands/delete.js +18 -0
  3. package/dist/cjs/plugins/table/commands-with-analytics.js +2 -7
  4. package/dist/cjs/plugins/table/event-handlers.js +2 -2
  5. package/dist/cjs/plugins/table/nodeviews/TableContainer.js +27 -9
  6. package/dist/cjs/plugins/table/pm-plugins/main.js +1 -1
  7. package/dist/cjs/plugins/table/transforms/column-width.js +110 -5
  8. package/dist/cjs/plugins/table/transforms/delete-columns.js +16 -6
  9. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
  10. package/dist/cjs/plugins/table/ui/FloatingDeleteButton/index.js +1 -1
  11. package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
  12. package/dist/es2019/plugins/table/commands/delete.js +10 -0
  13. package/dist/es2019/plugins/table/commands-with-analytics.js +3 -8
  14. package/dist/es2019/plugins/table/event-handlers.js +2 -2
  15. package/dist/es2019/plugins/table/nodeviews/TableContainer.js +27 -9
  16. package/dist/es2019/plugins/table/pm-plugins/main.js +1 -1
  17. package/dist/es2019/plugins/table/transforms/column-width.js +105 -5
  18. package/dist/es2019/plugins/table/transforms/delete-columns.js +16 -5
  19. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
  20. package/dist/es2019/plugins/table/ui/FloatingDeleteButton/index.js +1 -1
  21. package/dist/es2019/plugins/table/ui/common-styles.js +0 -1
  22. package/dist/esm/plugins/table/commands/delete.js +12 -0
  23. package/dist/esm/plugins/table/commands-with-analytics.js +3 -8
  24. package/dist/esm/plugins/table/event-handlers.js +2 -2
  25. package/dist/esm/plugins/table/nodeviews/TableContainer.js +27 -9
  26. package/dist/esm/plugins/table/pm-plugins/main.js +1 -1
  27. package/dist/esm/plugins/table/transforms/column-width.js +111 -5
  28. package/dist/esm/plugins/table/transforms/delete-columns.js +16 -6
  29. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
  30. package/dist/esm/plugins/table/ui/FloatingDeleteButton/index.js +1 -1
  31. package/dist/esm/plugins/table/ui/common-styles.js +1 -1
  32. package/dist/types/plugins/table/commands/delete.d.ts +3 -0
  33. package/dist/types/plugins/table/event-handlers.d.ts +1 -1
  34. package/dist/types/plugins/table/nodeviews/TableContainer.d.ts +3 -3
  35. package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
  36. package/dist/types/plugins/table/transforms/column-width.d.ts +25 -6
  37. package/dist/types/plugins/table/transforms/delete-columns.d.ts +2 -1
  38. package/dist/types/plugins/table/ui/FloatingDeleteButton/index.d.ts +4 -4
  39. package/dist/types-ts4.5/plugins/table/commands/delete.d.ts +3 -0
  40. package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +1 -1
  41. package/dist/types-ts4.5/plugins/table/nodeviews/TableContainer.d.ts +3 -3
  42. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
  43. package/dist/types-ts4.5/plugins/table/transforms/column-width.d.ts +25 -6
  44. package/dist/types-ts4.5/plugins/table/transforms/delete-columns.d.ts +2 -1
  45. package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/index.d.ts +4 -4
  46. package/package.json +8 -2
  47. package/src/__tests__/unit/commands.ts +1 -0
  48. package/src/__tests__/unit/transforms/delete-columns.ts +406 -105
  49. package/src/__tests__/unit/undo-redo.ts +1 -1
  50. package/src/plugins/table/commands/delete.ts +20 -0
  51. package/src/plugins/table/commands-with-analytics.ts +3 -10
  52. package/src/plugins/table/event-handlers.ts +6 -1
  53. package/src/plugins/table/nodeviews/TableContainer.tsx +189 -159
  54. package/src/plugins/table/pm-plugins/main.ts +7 -1
  55. package/src/plugins/table/pm-plugins/table-resizing/utils/misc.ts +1 -1
  56. package/src/plugins/table/transforms/column-width.ts +155 -15
  57. package/src/plugins/table/transforms/delete-columns.ts +23 -6
  58. package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +1 -1
  59. package/src/plugins/table/ui/FloatingDeleteButton/index.tsx +7 -6
  60. package/src/plugins/table/ui/common-styles.ts +0 -1
@@ -26,6 +26,7 @@ import {
26
26
  tdEmpty,
27
27
  tr,
28
28
  } from '@atlaskit/editor-test-helpers/doc-builder';
29
+ import { ffTest } from '@atlassian/feature-flags-test-utils';
29
30
 
30
31
  import tablePlugin from '../../../plugins/table-plugin';
31
32
  import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
@@ -42,12 +43,27 @@ const colsToRect = (cols: Array<number>, noOfRows: number): Rect => ({
42
43
  const TABLE_LOCAL_ID = 'test-table-local-id';
43
44
 
44
45
  describe('table plugin -> transforms -> delete columns', () => {
46
+ const originalClientWidth = Object.getOwnPropertyDescriptor(
47
+ HTMLElement.prototype,
48
+ 'clientWidth',
49
+ );
45
50
  beforeAll(() => {
46
51
  uuid.setStatic(TABLE_LOCAL_ID);
52
+
53
+ Object.defineProperty(HTMLElement.prototype, 'clientWidth', {
54
+ get() {
55
+ return 760;
56
+ },
57
+ });
47
58
  });
48
59
 
49
60
  afterAll(() => {
50
61
  uuid.setStatic(false);
62
+ Object.defineProperty(HTMLElement.prototype, 'clientWidth', {
63
+ get() {
64
+ return originalClientWidth;
65
+ },
66
+ });
51
67
  });
52
68
 
53
69
  const createEditor = createProsemirrorEditorFactory();
@@ -65,132 +81,411 @@ describe('table plugin -> transforms -> delete columns', () => {
65
81
  doc,
66
82
  preset,
67
83
  pluginKey,
84
+ attachTo: document.body,
68
85
  });
69
86
 
70
87
  describe('when selection rect is given', () => {
71
88
  describe('when the first column is deleted', () => {
72
- it('should delete the column and move cursor to the first column', () => {
73
- const {
74
- editorView,
75
- refs: { nextCursorPos },
76
- } = editor(
77
- doc(
78
- p('text'),
79
- table()(
80
- tr(
81
- td({})(p('{nextCursorPos}')),
82
- td({})(p('c2')),
83
- td({})(p('c3')),
89
+ describe('should delete the column and move cursor to the first column', () => {
90
+ ffTest(
91
+ 'platform.editor.table-update-colwidths-after-column-is-deleted',
92
+ () => {
93
+ const {
94
+ editorView,
95
+ refs: { nextCursorPos },
96
+ } = editor(
97
+ doc(
98
+ p('text'),
99
+ table()(
100
+ tr(
101
+ td({})(p('{nextCursorPos}')),
102
+ td({})(p('c2')),
103
+ td({})(p('c3')),
104
+ ),
105
+ ),
84
106
  ),
85
- ),
86
- ),
87
- );
88
- const { state, dispatch } = editorView;
89
- dispatch(deleteColumns(colsToRect([0], 1))(state.tr));
90
- expect(editorView.state.doc).toEqualDocument(
91
- doc(
92
- p('text'),
93
- table({ localId: TABLE_LOCAL_ID })(
94
- tr(td({})(p('c2')), td()(p('c3'))),
95
- ),
96
- ),
107
+ );
108
+ const { state, dispatch } = editorView;
109
+ dispatch(deleteColumns(colsToRect([0], 1), true)(state.tr));
110
+ expect(editorView.state.doc).toEqualDocument(
111
+ doc(
112
+ p('text'),
113
+ table({ localId: TABLE_LOCAL_ID })(
114
+ tr(td({})(p('c2')), td()(p('c3'))),
115
+ ),
116
+ ),
117
+ );
118
+ expect(editorView.state.selection.from).toEqual(nextCursorPos);
119
+ },
120
+ () => {
121
+ const {
122
+ editorView,
123
+ refs: { nextCursorPos },
124
+ } = editor(
125
+ doc(
126
+ p('text'),
127
+ table()(
128
+ tr(
129
+ td({})(p('{nextCursorPos}')),
130
+ td({})(p('c2')),
131
+ td({})(p('c3')),
132
+ ),
133
+ ),
134
+ ),
135
+ );
136
+ const { state, dispatch } = editorView;
137
+ dispatch(deleteColumns(colsToRect([0], 1), true)(state.tr));
138
+ expect(editorView.state.doc).toEqualDocument(
139
+ doc(
140
+ p('text'),
141
+ table({ localId: TABLE_LOCAL_ID })(
142
+ tr(td({})(p('c2')), td()(p('c3'))),
143
+ ),
144
+ ),
145
+ );
146
+ expect(editorView.state.selection.from).toEqual(nextCursorPos);
147
+ },
97
148
  );
98
- expect(editorView.state.selection.from).toEqual(nextCursorPos);
99
149
  });
100
150
  });
101
151
 
102
152
  describe('when middle column is deleted', () => {
103
- it('should delete the column and move cursor to the previous column', () => {
104
- const {
105
- editorView,
106
- refs: { nextCursorPos },
107
- } = editor(
108
- doc(
109
- p('text'),
110
- table()(
111
- tr(
112
- td({})(p('{nextCursorPos}')),
113
- td({})(p('c2')),
114
- td({})(p('c3')),
153
+ describe('should delete the column and move cursor to the previous column', () => {
154
+ ffTest(
155
+ 'platform.editor.table-update-colwidths-after-column-is-deleted',
156
+ () => {
157
+ const {
158
+ editorView,
159
+ refs: { nextCursorPos },
160
+ } = editor(
161
+ doc(
162
+ p('text'),
163
+ table()(
164
+ tr(
165
+ td({})(p('{nextCursorPos}')),
166
+ td({})(p('c2')),
167
+ td({})(p('c3')),
168
+ ),
169
+ ),
115
170
  ),
116
- ),
117
- ),
118
- );
119
- const { state, dispatch } = editorView;
120
- dispatch(deleteColumns(colsToRect([1], 1))(state.tr));
121
- expect(editorView.state.doc).toEqualDocument(
122
- doc(
123
- p('text'),
124
- table({ localId: TABLE_LOCAL_ID })(tr(tdEmpty, td()(p('c3')))),
125
- ),
171
+ );
172
+ const { state, dispatch } = editorView;
173
+ dispatch(deleteColumns(colsToRect([1], 1), true)(state.tr));
174
+ expect(editorView.state.doc).toEqualDocument(
175
+ doc(
176
+ p('text'),
177
+ table({ localId: TABLE_LOCAL_ID })(tr(tdEmpty, td()(p('c3')))),
178
+ ),
179
+ );
180
+ expect(editorView.state.selection.from).toEqual(nextCursorPos);
181
+ },
182
+ () => {
183
+ const {
184
+ editorView,
185
+ refs: { nextCursorPos },
186
+ } = editor(
187
+ doc(
188
+ p('text'),
189
+ table()(
190
+ tr(
191
+ td({})(p('{nextCursorPos}')),
192
+ td({})(p('c2')),
193
+ td({})(p('c3')),
194
+ ),
195
+ ),
196
+ ),
197
+ );
198
+ const { state, dispatch } = editorView;
199
+ dispatch(deleteColumns(colsToRect([1], 1), true)(state.tr));
200
+ expect(editorView.state.doc).toEqualDocument(
201
+ doc(
202
+ p('text'),
203
+ table({ localId: TABLE_LOCAL_ID })(tr(tdEmpty, td()(p('c3')))),
204
+ ),
205
+ );
206
+ expect(editorView.state.selection.from).toEqual(nextCursorPos);
207
+ },
126
208
  );
127
- expect(editorView.state.selection.from).toEqual(nextCursorPos);
128
209
  });
129
210
  });
130
211
 
131
212
  describe('when multiple rows are selected', () => {
132
- it('should delete these columns', () => {
133
- const { editorView } = editor(
134
- doc(
135
- p('text'),
136
- table()(tr(tdCursor, td({})(p('c1')), td({})(p('c2')))),
137
- ),
138
- );
139
- const { state, dispatch } = editorView;
140
- dispatch(deleteColumns(colsToRect([0, 1], 1))(state.tr));
141
- expect(editorView.state.doc).toEqualDocument(
142
- doc(p('text'), table({ localId: TABLE_LOCAL_ID })(tr(td()(p('c2'))))),
213
+ describe('should delete these columns', () => {
214
+ ffTest(
215
+ 'platform.editor.table-update-colwidths-after-column-is-deleted',
216
+ () => {
217
+ const { editorView } = editor(
218
+ doc(
219
+ p('text'),
220
+ table()(tr(tdCursor, td({})(p('c1')), td({})(p('c2')))),
221
+ ),
222
+ );
223
+ const { state, dispatch } = editorView;
224
+ dispatch(deleteColumns(colsToRect([0, 1], 1), true)(state.tr));
225
+ expect(editorView.state.doc).toEqualDocument(
226
+ doc(
227
+ p('text'),
228
+ table({ localId: TABLE_LOCAL_ID })(tr(td()(p('c2')))),
229
+ ),
230
+ );
231
+ },
232
+ () => {
233
+ const { editorView } = editor(
234
+ doc(
235
+ p('text'),
236
+ table()(tr(tdCursor, td({})(p('c1')), td({})(p('c2')))),
237
+ ),
238
+ );
239
+ const { state, dispatch } = editorView;
240
+ dispatch(deleteColumns(colsToRect([0, 1], 1), true)(state.tr));
241
+ expect(editorView.state.doc).toEqualDocument(
242
+ doc(
243
+ p('text'),
244
+ table({ localId: TABLE_LOCAL_ID })(tr(td()(p('c2')))),
245
+ ),
246
+ );
247
+ },
143
248
  );
144
249
  });
145
250
  });
146
251
  });
147
252
 
148
253
  describe('when one column is selected', () => {
149
- it('should delete the column', () => {
150
- const { editorView } = editor(
151
- doc(
152
- p('text'),
153
- table()(
154
- tr(td({})(p('a1')), td({})(p('{<cell}a2')), td({})(p('a3'))),
155
- tr(td({})(p('b1')), td({})(p('{cell>}b2')), td({})(p('b3'))),
156
- ),
157
- ),
254
+ describe('should delete the column', () => {
255
+ ffTest(
256
+ 'platform.editor.table-update-colwidths-after-column-is-deleted',
257
+ () => {
258
+ const { editorView } = editor(
259
+ doc(
260
+ p('text'),
261
+ table()(
262
+ tr(td({})(p('a1')), td({})(p('{<cell}a2')), td({})(p('a3'))),
263
+ tr(td({})(p('b1')), td({})(p('{cell>}b2')), td({})(p('b3'))),
264
+ ),
265
+ ),
266
+ );
267
+ const { state, dispatch } = editorView;
268
+ dispatch(
269
+ deleteColumns(getSelectionRect(state.selection)!, true)(state.tr),
270
+ );
271
+ expect(editorView.state.doc).toEqualDocument(
272
+ doc(
273
+ p('text'),
274
+ table({ localId: TABLE_LOCAL_ID })(
275
+ tr(td({})(p('a1')), td({})(p('a3'))),
276
+ tr(td({})(p('b1')), td({})(p('b3'))),
277
+ ),
278
+ ),
279
+ );
280
+ },
281
+ () => {
282
+ const { editorView } = editor(
283
+ doc(
284
+ p('text'),
285
+ table()(
286
+ tr(td({})(p('a1')), td({})(p('{<cell}a2')), td({})(p('a3'))),
287
+ tr(td({})(p('b1')), td({})(p('{cell>}b2')), td({})(p('b3'))),
288
+ ),
289
+ ),
290
+ );
291
+ const { state, dispatch } = editorView;
292
+ dispatch(
293
+ deleteColumns(getSelectionRect(state.selection)!, true)(state.tr),
294
+ );
295
+ expect(editorView.state.doc).toEqualDocument(
296
+ doc(
297
+ p('text'),
298
+ table({ localId: TABLE_LOCAL_ID })(
299
+ tr(td({})(p('a1')), td({})(p('a3'))),
300
+ tr(td({})(p('b1')), td({})(p('b3'))),
301
+ ),
302
+ ),
303
+ );
304
+ },
158
305
  );
159
- const { state, dispatch } = editorView;
160
- dispatch(deleteColumns(getSelectionRect(state.selection)!)(state.tr));
161
- expect(editorView.state.doc).toEqualDocument(
162
- doc(
163
- p('text'),
164
- table({ localId: TABLE_LOCAL_ID })(
165
- tr(td({})(p('a1')), td({})(p('a3'))),
166
- tr(td({})(p('b1')), td({})(p('b3'))),
167
- ),
168
- ),
306
+ });
307
+
308
+ describe('should update each cells colWidth', () => {
309
+ ffTest(
310
+ 'platform.editor.table-update-colwidths-after-column-is-deleted',
311
+ () => {
312
+ const { editorView } = editor(
313
+ doc(
314
+ table({ localId: TABLE_LOCAL_ID, layout: 'default', width: 760 })(
315
+ tr(
316
+ td({ colwidth: [401] })(p('{<>}')),
317
+ td({ colwidth: [105] })(p('')),
318
+ td({ colwidth: [253] })(p('')),
319
+ ),
320
+ ),
321
+ ),
322
+ );
323
+ const { dispatch, state } = editorView;
324
+ dispatch(
325
+ deleteColumns(colsToRect([1], 1), true, editorView)(state.tr),
326
+ );
327
+
328
+ expect(editorView.state.doc).toEqualDocument(
329
+ doc(
330
+ table({ localId: TABLE_LOCAL_ID, width: 760 })(
331
+ tr(
332
+ td({ colwidth: [460] })(p('')),
333
+ td({ colwidth: [289] })(p('')),
334
+ ),
335
+ ),
336
+ ),
337
+ );
338
+ },
339
+ () => {
340
+ const { editorView } = editor(
341
+ doc(
342
+ table({ localId: TABLE_LOCAL_ID, width: 691 })(
343
+ tr(
344
+ td({ colwidth: [230] })(p('')),
345
+ td({ colwidth: [230] })(p('')),
346
+ td({ colwidth: [230] })(p('')),
347
+ ),
348
+ ),
349
+ ),
350
+ );
351
+ const { dispatch, state } = editorView;
352
+
353
+ dispatch(
354
+ deleteColumns(colsToRect([1], 1), true, editorView)(state.tr),
355
+ );
356
+
357
+ expect(editorView.state.doc).toEqualDocument(
358
+ doc(
359
+ table({ localId: TABLE_LOCAL_ID, width: 691 })(
360
+ tr(
361
+ td({ colwidth: [230] })(p('')),
362
+ td({ colwidth: [230] })(p('')),
363
+ ),
364
+ ),
365
+ ),
366
+ );
367
+ },
169
368
  );
170
369
  });
171
370
  });
172
371
 
173
372
  describe('when multiple columns are selected', () => {
174
- it('should delete these column', () => {
175
- const { editorView } = editor(
176
- doc(
177
- p('text'),
178
- table()(
179
- tr(td({})(p('{<cell}a1')), td({})(p('a2')), td({})(p('a3'))),
180
- tr(td({})(p('b1')), td({})(p('{cell>}b2')), td({})(p('b3'))),
181
- ),
182
- ),
373
+ describe('should delete these column', () => {
374
+ ffTest(
375
+ 'platform.editor.table-update-colwidths-after-column-is-deleted',
376
+ () => {
377
+ const { editorView } = editor(
378
+ doc(
379
+ p('text'),
380
+ table()(
381
+ tr(td({})(p('{<cell}a1')), td({})(p('a2')), td({})(p('a3'))),
382
+ tr(td({})(p('b1')), td({})(p('{cell>}b2')), td({})(p('b3'))),
383
+ ),
384
+ ),
385
+ );
386
+ const { state, dispatch } = editorView;
387
+ dispatch(
388
+ deleteColumns(getSelectionRect(state.selection)!, true)(state.tr),
389
+ );
390
+ expect(editorView.state.doc).toEqualDocument(
391
+ doc(
392
+ p('text'),
393
+ table({ localId: TABLE_LOCAL_ID })(
394
+ tr(td({})(p('a3'))),
395
+ tr(td({})(p('b3'))),
396
+ ),
397
+ ),
398
+ );
399
+ },
400
+ () => {
401
+ const { editorView } = editor(
402
+ doc(
403
+ p('text'),
404
+ table()(
405
+ tr(td({})(p('{<cell}a1')), td({})(p('a2')), td({})(p('a3'))),
406
+ tr(td({})(p('b1')), td({})(p('{cell>}b2')), td({})(p('b3'))),
407
+ ),
408
+ ),
409
+ );
410
+ const { state, dispatch } = editorView;
411
+ dispatch(
412
+ deleteColumns(getSelectionRect(state.selection)!, true)(state.tr),
413
+ );
414
+ expect(editorView.state.doc).toEqualDocument(
415
+ doc(
416
+ p('text'),
417
+ table({ localId: TABLE_LOCAL_ID })(
418
+ tr(td({})(p('a3'))),
419
+ tr(td({})(p('b3'))),
420
+ ),
421
+ ),
422
+ );
423
+ },
183
424
  );
184
- const { state, dispatch } = editorView;
185
- dispatch(deleteColumns(getSelectionRect(state.selection)!)(state.tr));
186
- expect(editorView.state.doc).toEqualDocument(
187
- doc(
188
- p('text'),
189
- table({ localId: TABLE_LOCAL_ID })(
190
- tr(td({})(p('a3'))),
191
- tr(td({})(p('b3'))),
192
- ),
193
- ),
425
+ });
426
+
427
+ describe('should update each cells colWidth', () => {
428
+ ffTest(
429
+ 'platform.editor.table-update-colwidths-after-column-is-deleted',
430
+ () => {
431
+ const { editorView } = editor(
432
+ doc(
433
+ table({ localId: TABLE_LOCAL_ID, layout: 'default', width: 760 })(
434
+ tr(
435
+ td({ colwidth: [401] })(p('{<cell}')),
436
+ td({ colwidth: [105] })(p('{cell>}')),
437
+ td({ colwidth: [253] })(p('')),
438
+ ),
439
+ ),
440
+ ),
441
+ );
442
+ const { dispatch, state } = editorView;
443
+ dispatch(
444
+ deleteColumns(
445
+ getSelectionRect(state.selection)!,
446
+ true,
447
+ editorView,
448
+ )(state.tr),
449
+ );
450
+
451
+ expect(editorView.state.doc).toEqualDocument(
452
+ doc(
453
+ table({ localId: TABLE_LOCAL_ID, width: 760 })(
454
+ tr(td({ colwidth: [749] })(p(''))),
455
+ ),
456
+ ),
457
+ );
458
+ },
459
+ () => {
460
+ const { editorView } = editor(
461
+ doc(
462
+ table({ localId: TABLE_LOCAL_ID, width: 691 })(
463
+ tr(
464
+ td({ colwidth: [401] })(p('{<cell}')),
465
+ td({ colwidth: [105] })(p('{cell>}')),
466
+ td({ colwidth: [253] })(p('')),
467
+ ),
468
+ ),
469
+ ),
470
+ );
471
+ const { dispatch, state } = editorView;
472
+
473
+ dispatch(
474
+ deleteColumns(
475
+ getSelectionRect(state.selection)!,
476
+ true,
477
+ editorView,
478
+ )(state.tr),
479
+ );
480
+
481
+ expect(editorView.state.doc).toEqualDocument(
482
+ doc(
483
+ table({ localId: TABLE_LOCAL_ID, width: 691 })(
484
+ tr(td({ colwidth: [253] })(p(''))),
485
+ ),
486
+ ),
487
+ );
488
+ },
194
489
  );
195
490
  });
196
491
  });
@@ -207,7 +502,9 @@ describe('table plugin -> transforms -> delete columns', () => {
207
502
  ),
208
503
  );
209
504
  const { state, dispatch } = editorView;
210
- dispatch(deleteColumns(getSelectionRect(state.selection)!)(state.tr));
505
+ dispatch(
506
+ deleteColumns(getSelectionRect(state.selection)!, true)(state.tr),
507
+ );
211
508
  expect(editorView.state.doc).toEqualDocument(
212
509
  doc(
213
510
  p('text'),
@@ -241,7 +538,9 @@ describe('table plugin -> transforms -> delete columns', () => {
241
538
  ),
242
539
  );
243
540
  const { state, dispatch } = editorView;
244
- dispatch(deleteColumns(getSelectionRect(state.selection)!)(state.tr));
541
+ dispatch(
542
+ deleteColumns(getSelectionRect(state.selection)!, false)(state.tr),
543
+ );
245
544
  expect(editorView.state.doc).toEqualDocument(
246
545
  doc(
247
546
  p('text'),
@@ -271,7 +570,9 @@ describe('table plugin -> transforms -> delete columns', () => {
271
570
  ),
272
571
  );
273
572
  const { state, dispatch } = editorView;
274
- dispatch(deleteColumns(getSelectionRect(state.selection)!)(state.tr));
573
+ dispatch(
574
+ deleteColumns(getSelectionRect(state.selection)!, false)(state.tr),
575
+ );
275
576
  expect(editorView.state.doc).toEqualDocument(
276
577
  doc(
277
578
  p('text'),
@@ -305,7 +606,7 @@ describe('table plugin -> transforms -> delete columns', () => {
305
606
  ),
306
607
  );
307
608
  const { state, dispatch } = editorView;
308
- dispatch(deleteColumns(colsToRect([0], 3))(state.tr));
609
+ dispatch(deleteColumns(colsToRect([0], 3), true)(state.tr));
309
610
  expect(editorView.state.doc).toEqualDocument(
310
611
  doc(
311
612
  table({ localId: TABLE_LOCAL_ID })(
@@ -355,7 +656,7 @@ describe('table plugin -> transforms -> delete columns', () => {
355
656
  ),
356
657
  );
357
658
  const { state, dispatch } = editorView;
358
- dispatch(deleteColumns(colsToRect([0], 4))(state.tr));
659
+ dispatch(deleteColumns(colsToRect([0], 4), true)(state.tr));
359
660
  expect(editorView.state.doc).toEqualDocument(
360
661
  doc(
361
662
  table({ localId: TABLE_LOCAL_ID })(
@@ -407,7 +708,7 @@ describe('table plugin -> transforms -> delete columns', () => {
407
708
  ),
408
709
  );
409
710
  const { state, dispatch } = editorView;
410
- dispatch(deleteColumns(colsToRect([1], 3))(state.tr));
711
+ dispatch(deleteColumns(colsToRect([1], 3), true)(state.tr));
411
712
  expect(editorView.state.doc).toEqualDocument(
412
713
  doc(
413
714
  table({ localId: TABLE_LOCAL_ID })(
@@ -454,7 +755,7 @@ describe('table plugin -> transforms -> delete columns', () => {
454
755
  ),
455
756
  );
456
757
  const { state, dispatch } = editorView;
457
- dispatch(deleteColumns(colsToRect([1], 4))(state.tr));
758
+ dispatch(deleteColumns(colsToRect([1], 4), true)(state.tr));
458
759
  expect(editorView.state.doc).toEqualDocument(
459
760
  doc(
460
761
  table({ localId: TABLE_LOCAL_ID })(
@@ -500,7 +801,7 @@ describe('table plugin -> transforms -> delete columns', () => {
500
801
  ),
501
802
  );
502
803
  const { state, dispatch } = editorView;
503
- dispatch(deleteColumns(colsToRect([1, 2], 3))(state.tr));
804
+ dispatch(deleteColumns(colsToRect([1, 2], 3), true)(state.tr));
504
805
  expect(editorView.state.doc).toEqualDocument(
505
806
  doc(
506
807
  table({ localId: TABLE_LOCAL_ID })(
@@ -53,7 +53,7 @@ const INSERT_COLUMN = (editorView: EditorView) =>
53
53
  );
54
54
  const DELETE_COLUMN = (editorView: EditorView) => {
55
55
  const { state, dispatch } = editorView;
56
- dispatch(deleteColumns(colsToRect([0], 1))(state.tr));
56
+ dispatch(deleteColumns(colsToRect([0], 1), true, editorView)(state.tr));
57
57
  };
58
58
  const SHORTCUT_ADD_COLUMN_BEFORE = (editorView: EditorView) =>
59
59
  sendKeyToPm(editorView, 'Ctrl-Alt-ArrowLeft');
@@ -0,0 +1,20 @@
1
+ import type { Command } from '@atlaskit/editor-common/types';
2
+ import type { Rect } from '@atlaskit/editor-tables/table-map';
3
+
4
+ import { deleteColumns } from '../transforms/delete-columns';
5
+ import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
6
+
7
+ export const deleteColumnsCommand =
8
+ (rect: Rect): Command =>
9
+ (state, dispatch, view) => {
10
+ const tr = deleteColumns(
11
+ rect,
12
+ getAllowAddColumnCustomStep(state),
13
+ view,
14
+ )(state.tr);
15
+ if (dispatch) {
16
+ dispatch(tr);
17
+ return true;
18
+ }
19
+ return false;
20
+ };