@atlaskit/editor-plugin-table 2.12.6 → 2.13.1

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 (70) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/plugins/table/index.js +2 -0
  3. package/dist/cjs/plugins/table/nodeviews/TableContainer.js +6 -1
  4. package/dist/cjs/plugins/table/nodeviews/TableResizer.js +23 -5
  5. package/dist/es2019/plugins/table/index.js +3 -0
  6. package/dist/es2019/plugins/table/nodeviews/TableContainer.js +6 -1
  7. package/dist/es2019/plugins/table/nodeviews/TableResizer.js +24 -6
  8. package/dist/esm/plugins/table/index.js +3 -0
  9. package/dist/esm/plugins/table/nodeviews/TableContainer.js +6 -1
  10. package/dist/esm/plugins/table/nodeviews/TableResizer.js +24 -6
  11. package/dist/types/plugins/table/index.d.ts +9 -2
  12. package/dist/types/plugins/table/nodeviews/TableResizer.d.ts +2 -1
  13. package/dist/types-ts4.5/plugins/table/index.d.ts +9 -2
  14. package/dist/types-ts4.5/plugins/table/nodeviews/TableResizer.d.ts +2 -1
  15. package/package.json +2 -2
  16. package/report.api.md +14 -0
  17. package/src/__tests__/integration/floating-toolbar.ts +5 -5
  18. package/src/__tests__/unit/analytics.ts +2 -0
  19. package/src/__tests__/unit/collab.ts +2 -0
  20. package/src/__tests__/unit/commands/go-to-next-cell.ts +2 -0
  21. package/src/__tests__/unit/commands/insert.ts +2 -0
  22. package/src/__tests__/unit/commands/misc.ts +2 -0
  23. package/src/__tests__/unit/commands/sort.ts +4 -0
  24. package/src/__tests__/unit/commands.ts +2 -0
  25. package/src/__tests__/unit/copy-paste.ts +2 -0
  26. package/src/__tests__/unit/event-handlers/index.ts +3 -0
  27. package/src/__tests__/unit/event-handlers.ts +3 -0
  28. package/src/__tests__/unit/fix-tables.ts +2 -0
  29. package/src/__tests__/unit/get-toolbar-config.ts +2 -0
  30. package/src/__tests__/unit/handlers.ts +2 -0
  31. package/src/__tests__/unit/hover-selection.ts +2 -0
  32. package/src/__tests__/unit/index.ts +2 -0
  33. package/src/__tests__/unit/layout.ts +2 -0
  34. package/src/__tests__/unit/nodeviews/TableContainer.tsx +58 -0
  35. package/src/__tests__/unit/nodeviews/cell.ts +2 -0
  36. package/src/__tests__/unit/nodeviews/table.ts +2 -0
  37. package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +2 -0
  38. package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +3 -0
  39. package/src/__tests__/unit/pm-plugins/main.ts +2 -0
  40. package/src/__tests__/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +2 -0
  41. package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +3 -0
  42. package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +2 -0
  43. package/src/__tests__/unit/pm-plugins/table-width.ts +99 -0
  44. package/src/__tests__/unit/sort-column.ts +2 -0
  45. package/src/__tests__/unit/toolbar.ts +2 -0
  46. package/src/__tests__/unit/transforms/delete-columns.ts +2 -0
  47. package/src/__tests__/unit/transforms/delete-rows.ts +2 -0
  48. package/src/__tests__/unit/transforms/merging.ts +2 -0
  49. package/src/__tests__/unit/ui/ContextualMenu.tsx +2 -0
  50. package/src/__tests__/unit/ui/CornerControls.tsx +2 -0
  51. package/src/__tests__/unit/ui/FloatingContextualButton.tsx +2 -0
  52. package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +4 -2
  53. package/src/__tests__/unit/ui/RowControls.tsx +2 -0
  54. package/src/__tests__/unit/ui/TableFloatingControls.tsx +2 -0
  55. package/src/__tests__/unit/undo-redo.ts +2 -0
  56. package/src/__tests__/unit/utils/collapse.ts +2 -0
  57. package/src/__tests__/unit/utils/nodes.ts +2 -0
  58. package/src/__tests__/unit/utils/row-controls.ts +2 -0
  59. package/src/__tests__/unit/utils.ts +2 -0
  60. package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-should-remove-the-table-column-on-click-1-snap.png +2 -2
  61. package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-visual-hints-should-be-added-to-the-table-column-on-hover-1-snap.png +2 -2
  62. package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-should-remove-the-table-row-on-click-1-snap.png +2 -2
  63. package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-visual-hints-should-be-added-to-the-table-row-on-hover-1-snap.png +2 -2
  64. package/src/plugins/table/index.tsx +13 -0
  65. package/src/plugins/table/nodeviews/TableContainer.tsx +12 -0
  66. package/src/plugins/table/nodeviews/TableResizer.tsx +36 -5
  67. package/src/plugins/table/nodeviews/table.tsx +0 -1
  68. package/tmp/api-report-tmp.d.ts +12 -1
  69. package/tsconfig.app.json +0 -3
  70. package/tsconfig.dev.json +6 -3
@@ -1,6 +1,7 @@
1
1
  import { uuid } from '@atlaskit/adf-schema';
2
2
  import { defaultSchema } from '@atlaskit/adf-schema/schema-default';
3
3
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
4
5
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
5
6
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
6
7
  import { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
@@ -75,6 +76,7 @@ describe('table plugin: actions', () => {
75
76
  .add(widthPlugin)
76
77
  .add(guidelinePlugin)
77
78
  .add(gridPlugin)
79
+ .add(selectionPlugin)
78
80
  .add(tablePlugin),
79
81
  pluginKey,
80
82
  });
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { uuid } from '@atlaskit/adf-schema';
4
4
  import { transformSliceToRemoveOpenExpand } from '@atlaskit/editor-common/transforms';
5
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
5
6
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
6
7
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
7
8
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -119,6 +120,7 @@ describe('table plugin', () => {
119
120
  .add(contentInsertionPlugin)
120
121
  .add(widthPlugin)
121
122
  .add(guidelinePlugin)
123
+ .add(selectionPlugin)
122
124
  .add([tablePlugin, { tableOptions }]);
123
125
 
124
126
  const editor = (doc: DocBuilder) => {
@@ -1,3 +1,4 @@
1
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
1
2
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
2
3
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
3
4
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -37,6 +38,7 @@ describe('event-handlers', () => {
37
38
  .add(contentInsertionPlugin)
38
39
  .add(widthPlugin)
39
40
  .add(guidelinePlugin)
41
+ .add(selectionPlugin)
40
42
  .add([tablePlugin, { tableOptions: { allowColumnResizing: false } }]);
41
43
  editor = (doc: DocBuilder) =>
42
44
  createEditor<TablePluginState, PluginKey, typeof preset>({
@@ -70,6 +72,7 @@ describe('event-handlers', () => {
70
72
  .add(contentInsertionPlugin)
71
73
  .add(widthPlugin)
72
74
  .add(guidelinePlugin)
75
+ .add(selectionPlugin)
73
76
  .add([tablePlugin, { tableOptions: { allowColumnResizing: false } }]);
74
77
  editor = (doc: DocBuilder) =>
75
78
  createEditor<TablePluginState, PluginKey, typeof preset>({
@@ -1,3 +1,4 @@
1
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
1
2
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
2
3
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
3
4
  import { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
@@ -47,6 +48,7 @@ describe('table plugin: decorations', () => {
47
48
  .add(contentInsertionPlugin)
48
49
  .add(widthPlugin)
49
50
  .add(guidelinePlugin)
51
+ .add(selectionPlugin)
50
52
  .add(tablePlugin),
51
53
  pluginKey,
52
54
  });
@@ -166,6 +168,7 @@ describe('table event handlers', () => {
166
168
  .add(widthPlugin)
167
169
  .add(guidelinePlugin)
168
170
  .add(gridPlugin)
171
+ .add(selectionPlugin)
169
172
  .add(tablePlugin),
170
173
  pluginKey,
171
174
  });
@@ -1,3 +1,4 @@
1
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
1
2
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
2
3
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
3
4
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -47,6 +48,7 @@ describe('fix tables', () => {
47
48
  .add(contentInsertionPlugin)
48
49
  .add(widthPlugin)
49
50
  .add(guidelinePlugin)
51
+ .add(selectionPlugin)
50
52
  .add([tablePlugin, { tableOptions }]),
51
53
  pluginKey: tablePluginKey,
52
54
  });
@@ -4,6 +4,7 @@ import type {
4
4
  FloatingToolbarItem,
5
5
  GetEditorFeatureFlags,
6
6
  } from '@atlaskit/editor-common/types';
7
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
7
8
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
8
9
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
9
10
  import { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
@@ -80,6 +81,7 @@ describe('getToolbarConfig', () => {
80
81
  .add(decorationsPlugin)
81
82
  .add(widthPlugin)
82
83
  .add(guidelinePlugin)
84
+ .add(selectionPlugin)
83
85
  .add(tablePlugin),
84
86
  });
85
87
 
@@ -1,3 +1,4 @@
1
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
1
2
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
2
3
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
3
4
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -37,6 +38,7 @@ describe('table action handlers', () => {
37
38
  .add(contentInsertionPlugin)
38
39
  .add(widthPlugin)
39
40
  .add(guidelinePlugin)
41
+ .add(selectionPlugin)
40
42
  .add(tablePlugin);
41
43
 
42
44
  editor = (doc: DocBuilder) =>
@@ -1,3 +1,4 @@
1
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
1
2
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
2
3
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
3
4
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -46,6 +47,7 @@ describe('table hover selection plugin', () => {
46
47
  .add(contentInsertionPlugin)
47
48
  .add(widthPlugin)
48
49
  .add(guidelinePlugin)
50
+ .add(selectionPlugin)
49
51
  .add(tablePlugin);
50
52
 
51
53
  const editor = (doc: DocBuilder) =>
@@ -1,6 +1,7 @@
1
1
  import { uuid } from '@atlaskit/adf-schema';
2
2
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
3
3
  import { setNodeSelection } from '@atlaskit/editor-common/utils';
4
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
4
5
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
5
6
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
6
7
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -90,6 +91,7 @@ describe('table plugin', () => {
90
91
  .add(guidelinePlugin)
91
92
  .add(gridPlugin)
92
93
  .add(contentInsertionPlugin)
94
+ .add(selectionPlugin)
93
95
  .add([tablePlugin, { tableOptions }]);
94
96
 
95
97
  return createEditor({
@@ -1,4 +1,5 @@
1
1
  import type { TableLayout } from '@atlaskit/adf-schema';
2
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
2
3
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
4
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
4
5
  import { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
@@ -46,6 +47,7 @@ describe('table toolbar', () => {
46
47
  .add(decorationsPlugin)
47
48
  .add(widthPlugin)
48
49
  .add(guidelinePlugin)
50
+ .add(selectionPlugin)
49
51
  .add([tablePlugin, { tableOptions }]);
50
52
 
51
53
  const editor = (doc: DocBuilder) => {
@@ -280,4 +280,62 @@ describe('table -> nodeviews -> TableContainer.tsx', () => {
280
280
  expect(mockEndMeasure).toHaveBeenCalled();
281
281
  });
282
282
  });
283
+
284
+ describe('selection', () => {
285
+ const selectionActionMock = jest.fn().mockReturnValue(() => {});
286
+
287
+ const buildContainer = (attrs: TableAttributes) => {
288
+ const { table, editorView } = createNode(attrs);
289
+
290
+ const { container } = render(
291
+ <ResizableTableContainer
292
+ containerWidth={1800}
293
+ lineLength={720}
294
+ node={table}
295
+ className={''}
296
+ editorView={editorView}
297
+ getPos={() => 0}
298
+ tableRef={
299
+ {
300
+ querySelector: () => null,
301
+ insertBefore: () => {},
302
+ style: {},
303
+ } as any
304
+ }
305
+ pluginInjectionApi={
306
+ {
307
+ selection: {
308
+ commands: { displayGapCursor: selectionActionMock },
309
+ },
310
+ // mock core so the selection command will execute
311
+ core: { actions: { execute: jest.fn() } },
312
+ } as any
313
+ }
314
+ />,
315
+ );
316
+
317
+ return { container, selectionActionMock };
318
+ };
319
+
320
+ afterEach(() => {
321
+ selectionActionMock.mockRestore();
322
+ });
323
+
324
+ it('fires selection action to hide gap cursor when present', () => {
325
+ const { container, selectionActionMock } = buildContainer({
326
+ layout: 'wide',
327
+ });
328
+
329
+ fireEvent.mouseDown(container.querySelector('.resizer-handle.right')!);
330
+ fireEvent.mouseMove(container.querySelector('.resizer-handle.right')!);
331
+ fireEvent.mouseMove(container.querySelector('.resizer-handle.right')!);
332
+ fireEvent.mouseMove(container.querySelector('.resizer-handle.right')!);
333
+ fireEvent.mouseUp(container.querySelector('.resizer-handle.right')!);
334
+
335
+ // when resize starts - call to hide gap cursor
336
+ expect(selectionActionMock).toHaveBeenNthCalledWith(1, false);
337
+ // when resize finishes - call to display gap cursor
338
+ expect(selectionActionMock).toHaveBeenNthCalledWith(2, true);
339
+ });
340
+ });
283
341
  });
@@ -3,6 +3,7 @@ import {
3
3
  tableBackgroundColorNames,
4
4
  uuid,
5
5
  } from '@atlaskit/adf-schema';
6
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
6
7
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
7
8
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
8
9
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -53,6 +54,7 @@ describe('table -> nodeviews -> tableCell.tsx', () => {
53
54
  .add(contentInsertionPlugin)
54
55
  .add(widthPlugin)
55
56
  .add(guidelinePlugin)
57
+ .add(selectionPlugin)
56
58
  .add([tablePlugin, { tableOptions: { advanced: true, ...props } }]),
57
59
  pluginKey,
58
60
  });
@@ -1,4 +1,5 @@
1
1
  import type { TableAttributes } from '@atlaskit/adf-schema';
2
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
2
3
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
4
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
4
5
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -45,6 +46,7 @@ describe('table -> nodeviews -> table.tsx', () => {
45
46
  .add(contentInsertionPlugin)
46
47
  .add(widthPlugin)
47
48
  .add(guidelinePlugin)
49
+ .add(selectionPlugin)
48
50
  .add([
49
51
  tablePlugin,
50
52
  {
@@ -1,3 +1,4 @@
1
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
1
2
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
2
3
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
3
4
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -44,6 +45,7 @@ describe('tables: column resizing decorations', () => {
44
45
  .add(contentInsertionPlugin)
45
46
  .add(widthPlugin)
46
47
  .add(guidelinePlugin)
48
+ .add(selectionPlugin)
47
49
  .add([
48
50
  tablePlugin,
49
51
  {
@@ -1,3 +1,4 @@
1
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
1
2
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
2
3
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
3
4
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -42,6 +43,7 @@ describe('decorations plugin', () => {
42
43
  .add(contentInsertionPlugin)
43
44
  .add(widthPlugin)
44
45
  .add(guidelinePlugin)
46
+ .add(selectionPlugin)
45
47
  .add(tablePlugin),
46
48
  pluginKey,
47
49
  });
@@ -166,6 +168,7 @@ describe('decorations plugin', () => {
166
168
  .add(contentInsertionPlugin)
167
169
  .add(widthPlugin)
168
170
  .add(guidelinePlugin)
171
+ .add(selectionPlugin)
169
172
  .add([
170
173
  tablePlugin,
171
174
  {
@@ -1,3 +1,4 @@
1
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
1
2
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
2
3
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
3
4
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -57,6 +58,7 @@ describe('tables: main plugin', () => {
57
58
  .add(contentInsertionPlugin)
58
59
  .add(widthPlugin)
59
60
  .add(guidelinePlugin)
61
+ .add(selectionPlugin)
60
62
  .add(tablePlugin),
61
63
  pluginKey,
62
64
  });
@@ -1,3 +1,4 @@
1
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
1
2
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
2
3
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
3
4
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -33,6 +34,7 @@ describe('table/safari-delete-composition-text-issue-workaround', () => {
33
34
  .add(contentInsertionPlugin)
34
35
  .add(widthPlugin)
35
36
  .add(guidelinePlugin)
37
+ .add(selectionPlugin)
36
38
  .add([tablePlugin, { tableOptions: { allowColumnResizing: true } }]),
37
39
  pluginKey,
38
40
  });
@@ -6,6 +6,7 @@ import createStub from 'raf-stub';
6
6
 
7
7
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
8
8
  import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
9
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
9
10
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
10
11
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
11
12
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -67,6 +68,7 @@ describe('TableRowNodeView', () => {
67
68
  .add(contentInsertionPlugin)
68
69
  .add(widthPlugin)
69
70
  .add(guidelinePlugin)
71
+ .add(selectionPlugin)
70
72
  .add(tablePlugin),
71
73
  pluginKey,
72
74
  attachTo: document.body,
@@ -100,6 +102,7 @@ describe('TableRowNodeView', () => {
100
102
  .add(contentInsertionPlugin)
101
103
  .add(widthPlugin)
102
104
  .add(guidelinePlugin)
105
+ .add(selectionPlugin)
103
106
  .add(tablePlugin),
104
107
  pluginKey,
105
108
  });
@@ -3,6 +3,7 @@ import {
3
3
  EVENT_TYPE,
4
4
  TABLE_ACTION,
5
5
  } from '@atlaskit/editor-common/analytics';
6
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
6
7
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
7
8
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
8
9
  import { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
@@ -59,6 +60,7 @@ describe('table-resizing/event-handlers', () => {
59
60
  .add(decorationsPlugin)
60
61
  .add(widthPlugin)
61
62
  .add(guidelinePlugin)
63
+ .add(selectionPlugin)
62
64
  .add([
63
65
  tablePlugin,
64
66
  {
@@ -0,0 +1,99 @@
1
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
2
+ import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
+ import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
4
+ import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
5
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
6
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
7
+ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
8
+ import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
9
+ import {
10
+ createProsemirrorEditorFactory,
11
+ Preset,
12
+ } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
13
+ import type { DocBuilder } from '@atlaskit/editor-test-helpers/doc-builder';
14
+ import {
15
+ doc,
16
+ p,
17
+ table,
18
+ td,
19
+ tdEmpty,
20
+ tr,
21
+ } from '@atlaskit/editor-test-helpers/doc-builder';
22
+
23
+ import tablePlugin from '../../../plugins/table-plugin';
24
+ import { pluginKey as tablePluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
25
+
26
+ describe('table width', () => {
27
+ const createEditor = createProsemirrorEditorFactory();
28
+
29
+ beforeAll(() => {
30
+ // @ts-ignore
31
+ global['fetch'] = jest.fn();
32
+ });
33
+
34
+ const editor = (doc: DocBuilder) => {
35
+ return createEditor({
36
+ doc,
37
+ attachTo: document.body,
38
+ preset: new Preset<LightEditorPlugin>()
39
+ .add([featureFlagsPlugin, {}])
40
+ .add([analyticsPlugin, {}])
41
+ .add(contentInsertionPlugin)
42
+ .add(widthPlugin)
43
+ .add(guidelinePlugin)
44
+ .add(selectionPlugin)
45
+ .add([
46
+ tablePlugin,
47
+ {
48
+ tableResizingEnabled: true, // so table-width plugin is enabled
49
+ tableOptions: {
50
+ advanced: true,
51
+ },
52
+ },
53
+ ]),
54
+ pluginKey: tablePluginKey,
55
+ });
56
+ };
57
+
58
+ describe('move selection from outside table to inside table should fire analytics', () => {
59
+ const TABLE_LOCAL_ID = 'test-table-1';
60
+ it('should fire v3 analytics', () => {
61
+ // create editor with a table and a paragraph below
62
+ // mouse cursor is at the end of the parapgraph
63
+ const {
64
+ dispatchAnalyticsEvent,
65
+ editorView,
66
+ refs: { inTablePos },
67
+ } = editor(
68
+ doc(
69
+ table({ localId: TABLE_LOCAL_ID })(
70
+ tr(td({})(p('{inTablePos}in cell')), tdEmpty, tdEmpty),
71
+ tr(tdEmpty, tdEmpty, tdEmpty),
72
+ ),
73
+ p('hello cursor is here initially{<>}'),
74
+ ),
75
+ );
76
+
77
+ // move cursor to where ths inTablePos is
78
+ const $inTablePos = editorView.state.doc.resolve(inTablePos);
79
+ editorView.dispatch(
80
+ editorView.state.tr.setSelection(
81
+ new TextSelection($inTablePos, $inTablePos),
82
+ ),
83
+ );
84
+
85
+ // analytics event should be fired
86
+ expect(dispatchAnalyticsEvent).toHaveBeenCalledWith(
87
+ expect.objectContaining({
88
+ action: 'selected',
89
+ actionSubject: 'document',
90
+ actionSubjectId: 'table',
91
+ attributes: expect.objectContaining({
92
+ localId: TABLE_LOCAL_ID,
93
+ }),
94
+ eventType: 'track',
95
+ }),
96
+ );
97
+ });
98
+ });
99
+ });
@@ -1,5 +1,6 @@
1
1
  import { uuid } from '@atlaskit/adf-schema';
2
2
  import { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
3
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
3
4
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
5
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
5
6
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -55,6 +56,7 @@ describe('table plugin', () => {
55
56
  .add(contentInsertionPlugin)
56
57
  .add(widthPlugin)
57
58
  .add(guidelinePlugin)
59
+ .add(selectionPlugin)
58
60
  .add([tablePlugin, { tableOptions }]);
59
61
 
60
62
  const editor = (doc: DocBuilder) => {
@@ -3,6 +3,7 @@ import type {
3
3
  DropdownOptionT,
4
4
  FloatingToolbarDropdown,
5
5
  } from '@atlaskit/editor-common/types';
6
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
6
7
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
7
8
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
8
9
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -166,6 +167,7 @@ describe('getToolbarCellOptionsConfig', () => {
166
167
  .add(contentInsertionPlugin)
167
168
  .add(widthPlugin)
168
169
  .add(guidelinePlugin)
170
+ .add(selectionPlugin)
169
171
  .add([
170
172
  tablePlugin,
171
173
  {
@@ -1,4 +1,5 @@
1
1
  import { uuid } from '@atlaskit/adf-schema';
2
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
2
3
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
4
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
4
5
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -53,6 +54,7 @@ describe('table plugin -> transforms -> delete columns', () => {
53
54
  .add(contentInsertionPlugin)
54
55
  .add(widthPlugin)
55
56
  .add(guidelinePlugin)
57
+ .add(selectionPlugin)
56
58
  .add(tablePlugin);
57
59
 
58
60
  const editor = (doc: DocBuilder) =>
@@ -1,4 +1,5 @@
1
1
  import { uuid } from '@atlaskit/adf-schema';
2
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
2
3
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
4
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
4
5
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -53,6 +54,7 @@ describe('table plugin -> transforms -> delete rows', () => {
53
54
  .add(contentInsertionPlugin)
54
55
  .add(widthPlugin)
55
56
  .add(guidelinePlugin)
57
+ .add(selectionPlugin)
56
58
  .add(tablePlugin);
57
59
 
58
60
  const editor = (doc: DocBuilder) =>
@@ -1,4 +1,5 @@
1
1
  import { uuid } from '@atlaskit/adf-schema';
2
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
2
3
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
4
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
4
5
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -43,6 +44,7 @@ describe('table plugin -> transforms -> merge cells', () => {
43
44
  .add(contentInsertionPlugin)
44
45
  .add(widthPlugin)
45
46
  .add(guidelinePlugin)
47
+ .add(selectionPlugin)
46
48
  .add(tablePlugin);
47
49
 
48
50
  const editor = (doc: DocBuilder) =>
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  import { render, screen } from '@testing-library/react';
4
4
  import { createIntl } from 'react-intl-next';
5
5
 
6
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
6
7
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
7
8
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
8
9
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -42,6 +43,7 @@ describe('ContextualMenu', () => {
42
43
  .add(contentInsertionPlugin)
43
44
  .add(widthPlugin)
44
45
  .add(guidelinePlugin)
46
+ .add(selectionPlugin)
45
47
  .add([tablePlugin, { tableOptions: { advanced: true } }]),
46
48
  }));
47
49
  });
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  import { fireEvent, render, screen } from '@testing-library/react';
4
4
  import { IntlProvider } from 'react-intl-next';
5
5
 
6
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
6
7
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
7
8
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
8
9
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -39,6 +40,7 @@ describe('CornerControls', () => {
39
40
  .add(contentInsertionPlugin)
40
41
  .add(widthPlugin)
41
42
  .add(guidelinePlugin)
43
+ .add(selectionPlugin)
42
44
  .add(tablePlugin),
43
45
  pluginKey,
44
46
  });
@@ -4,6 +4,7 @@ import { render, screen } from '@testing-library/react';
4
4
  import { IntlProvider } from 'react-intl-next';
5
5
 
6
6
  import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
7
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
7
8
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
8
9
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
9
10
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -55,6 +56,7 @@ const editor = (doc: DocBuilder) =>
55
56
  .add(contentInsertionPlugin)
56
57
  .add(widthPlugin)
57
58
  .add(guidelinePlugin)
59
+ .add(selectionPlugin)
58
60
  .add(tablePlugin),
59
61
  });
60
62
 
@@ -3,15 +3,16 @@ import React from 'react';
3
3
  import { render, screen } from '@testing-library/react';
4
4
  import { IntlProvider } from 'react-intl-next';
5
5
 
6
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
6
7
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
7
8
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
8
9
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
9
10
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
10
11
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
11
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
12
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
13
+ import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
12
14
  import {
13
15
  createProsemirrorEditorFactory,
14
- LightEditorPlugin,
15
16
  Preset,
16
17
  } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
17
18
  import {
@@ -41,6 +42,7 @@ describe('FloatingContextualMenu', () => {
41
42
  .add(contentInsertionPlugin)
42
43
  .add(widthPlugin)
43
44
  .add(guidelinePlugin)
45
+ .add(selectionPlugin)
44
46
  .add(tablePlugin),
45
47
  }));
46
48
  });
@@ -4,6 +4,7 @@ import { fireEvent, render, screen } from '@testing-library/react';
4
4
  import { IntlProvider } from 'react-intl-next';
5
5
 
6
6
  import { setTextSelection } from '@atlaskit/editor-common/utils';
7
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
7
8
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
8
9
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
9
10
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -67,6 +68,7 @@ describe('RowControls', () => {
67
68
  .add(contentInsertionPlugin)
68
69
  .add(widthPlugin)
69
70
  .add(guidelinePlugin)
71
+ .add(selectionPlugin)
70
72
  .add(tablePlugin),
71
73
  pluginKey,
72
74
  });
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  import { render, screen } from '@testing-library/react';
4
4
  import { IntlProvider } from 'react-intl-next';
5
5
 
6
+ import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
6
7
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
7
8
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
8
9
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -40,6 +41,7 @@ describe('TableFloatingControls', () => {
40
41
  .add(contentInsertionPlugin)
41
42
  .add(widthPlugin)
42
43
  .add(guidelinePlugin)
44
+ .add(selectionPlugin)
43
45
  .add(tablePlugin);
44
46
 
45
47
  const editor = (doc: DocBuilder) =>