@atlaskit/editor-plugin-table 2.1.7 → 2.3.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 (147) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/plugins/table/handlers.js +1 -0
  3. package/dist/cjs/plugins/table/index.js +41 -35
  4. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +5 -4
  5. package/dist/cjs/plugins/table/nodeviews/TableContainer.js +50 -47
  6. package/dist/cjs/plugins/table/nodeviews/TableResizer.js +72 -28
  7. package/dist/cjs/plugins/table/nodeviews/table.js +12 -5
  8. package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +14 -5
  9. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +2 -0
  10. package/dist/cjs/plugins/table/pm-plugins/main.js +2 -2
  11. package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-factory.js +1 -1
  12. package/dist/cjs/plugins/table/pm-plugins/{table-add-width.js → table-width.js} +27 -4
  13. package/dist/cjs/plugins/table/toolbar.js +6 -1
  14. package/dist/cjs/plugins/table/ui/consts.js +6 -2
  15. package/dist/cjs/plugins/table/utils/collapse.js +2 -0
  16. package/dist/cjs/plugins/table/utils/decoration.js +2 -0
  17. package/dist/cjs/plugins/table/utils/guidelines.js +12 -0
  18. package/dist/cjs/plugins/table/utils/snapping.js +37 -0
  19. package/dist/cjs/version.json +1 -1
  20. package/dist/es2019/plugins/table/handlers.js +1 -0
  21. package/dist/es2019/plugins/table/index.js +19 -10
  22. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +5 -4
  23. package/dist/es2019/plugins/table/nodeviews/TableContainer.js +25 -23
  24. package/dist/es2019/plugins/table/nodeviews/TableResizer.js +71 -29
  25. package/dist/es2019/plugins/table/nodeviews/table.js +12 -5
  26. package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +18 -6
  27. package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +2 -0
  28. package/dist/es2019/plugins/table/pm-plugins/main.js +2 -2
  29. package/dist/es2019/plugins/table/pm-plugins/table-resizing/plugin-factory.js +2 -0
  30. package/dist/es2019/plugins/table/pm-plugins/{table-add-width.js → table-width.js} +25 -3
  31. package/dist/es2019/plugins/table/toolbar.js +6 -1
  32. package/dist/es2019/plugins/table/ui/consts.js +3 -1
  33. package/dist/es2019/plugins/table/utils/collapse.js +2 -0
  34. package/dist/es2019/plugins/table/utils/decoration.js +2 -0
  35. package/dist/es2019/plugins/table/utils/guidelines.js +4 -0
  36. package/dist/es2019/plugins/table/utils/snapping.js +27 -0
  37. package/dist/es2019/version.json +1 -1
  38. package/dist/esm/plugins/table/handlers.js +1 -0
  39. package/dist/esm/plugins/table/index.js +41 -35
  40. package/dist/esm/plugins/table/nodeviews/TableComponent.js +5 -4
  41. package/dist/esm/plugins/table/nodeviews/TableContainer.js +50 -47
  42. package/dist/esm/plugins/table/nodeviews/TableResizer.js +69 -28
  43. package/dist/esm/plugins/table/nodeviews/table.js +12 -5
  44. package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +18 -6
  45. package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +2 -0
  46. package/dist/esm/plugins/table/pm-plugins/main.js +2 -2
  47. package/dist/esm/plugins/table/pm-plugins/table-resizing/plugin-factory.js +2 -0
  48. package/dist/esm/plugins/table/pm-plugins/{table-add-width.js → table-width.js} +25 -3
  49. package/dist/esm/plugins/table/toolbar.js +6 -1
  50. package/dist/esm/plugins/table/ui/consts.js +3 -1
  51. package/dist/esm/plugins/table/utils/collapse.js +2 -0
  52. package/dist/esm/plugins/table/utils/decoration.js +2 -0
  53. package/dist/esm/plugins/table/utils/guidelines.js +4 -0
  54. package/dist/esm/plugins/table/utils/snapping.js +30 -0
  55. package/dist/esm/version.json +1 -1
  56. package/dist/types/plugins/table/index.d.ts +3 -1
  57. package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +3 -2
  58. package/dist/types/plugins/table/nodeviews/TableContainer.d.ts +5 -2
  59. package/dist/types/plugins/table/nodeviews/TableResizer.d.ts +3 -1
  60. package/dist/types/plugins/table/nodeviews/table.d.ts +2 -1
  61. package/dist/types/plugins/table/nodeviews/types.d.ts +2 -0
  62. package/dist/types/plugins/table/pm-plugins/decorations/plugin.d.ts +1 -1
  63. package/dist/types/plugins/table/pm-plugins/main.d.ts +2 -1
  64. package/dist/types/plugins/table/pm-plugins/table-width.d.ts +16 -0
  65. package/dist/types/plugins/table/types.d.ts +3 -0
  66. package/dist/types/plugins/table/ui/consts.d.ts +2 -0
  67. package/dist/types/plugins/table/utils/guidelines.d.ts +3 -0
  68. package/dist/types/plugins/table/utils/snapping.d.ts +8 -0
  69. package/dist/types-ts4.5/plugins/table/index.d.ts +3 -1
  70. package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +3 -2
  71. package/dist/types-ts4.5/plugins/table/nodeviews/TableContainer.d.ts +5 -2
  72. package/dist/types-ts4.5/plugins/table/nodeviews/TableResizer.d.ts +3 -1
  73. package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +2 -1
  74. package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +2 -0
  75. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/plugin.d.ts +1 -1
  76. package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +2 -1
  77. package/dist/types-ts4.5/plugins/table/pm-plugins/table-width.d.ts +16 -0
  78. package/dist/types-ts4.5/plugins/table/types.d.ts +3 -0
  79. package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +2 -0
  80. package/dist/types-ts4.5/plugins/table/utils/guidelines.d.ts +3 -0
  81. package/dist/types-ts4.5/plugins/table/utils/snapping.d.ts +8 -0
  82. package/package.json +4 -3
  83. package/report.api.md +2 -0
  84. package/src/__tests__/unit/analytics.ts +2 -0
  85. package/src/__tests__/unit/collab.ts +2 -0
  86. package/src/__tests__/unit/commands/go-to-next-cell.ts +2 -0
  87. package/src/__tests__/unit/commands/insert.ts +2 -0
  88. package/src/__tests__/unit/commands/misc.ts +2 -0
  89. package/src/__tests__/unit/commands/sort.ts +4 -0
  90. package/src/__tests__/unit/commands.ts +2 -0
  91. package/src/__tests__/unit/copy-paste.ts +2 -0
  92. package/src/__tests__/unit/event-handlers/index.ts +3 -0
  93. package/src/__tests__/unit/event-handlers.ts +3 -0
  94. package/src/__tests__/unit/fix-tables.ts +2 -0
  95. package/src/__tests__/unit/get-toolbar-config.ts +2 -0
  96. package/src/__tests__/unit/handlers.ts +2 -0
  97. package/src/__tests__/unit/hover-selection.ts +2 -0
  98. package/src/__tests__/unit/index.ts +2 -0
  99. package/src/__tests__/unit/layout.ts +2 -0
  100. package/src/__tests__/unit/nodeviews/cell.ts +2 -0
  101. package/src/__tests__/unit/nodeviews/table.ts +2 -0
  102. package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +2 -0
  103. package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +68 -0
  104. package/src/__tests__/unit/pm-plugins/main.ts +2 -0
  105. package/src/__tests__/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +2 -0
  106. package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +3 -0
  107. package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +2 -0
  108. package/src/__tests__/unit/sort-column.ts +2 -0
  109. package/src/__tests__/unit/toolbar.ts +2 -0
  110. package/src/__tests__/unit/transforms/delete-columns.ts +2 -0
  111. package/src/__tests__/unit/transforms/delete-rows.ts +2 -0
  112. package/src/__tests__/unit/transforms/merging.ts +2 -0
  113. package/src/__tests__/unit/ui/ContextualMenu.tsx +2 -0
  114. package/src/__tests__/unit/ui/CornerControls.tsx +2 -0
  115. package/src/__tests__/unit/ui/FloatingContextualButton.tsx +2 -0
  116. package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +2 -0
  117. package/src/__tests__/unit/ui/RowControls.tsx +2 -0
  118. package/src/__tests__/unit/ui/TableFloatingControls.tsx +2 -0
  119. package/src/__tests__/unit/undo-redo.ts +2 -0
  120. package/src/__tests__/unit/utils/collapse.ts +2 -0
  121. package/src/__tests__/unit/utils/nodes.ts +2 -0
  122. package/src/__tests__/unit/utils/row-controls.ts +2 -0
  123. package/src/__tests__/unit/utils.ts +2 -0
  124. package/src/plugins/table/handlers.ts +1 -0
  125. package/src/plugins/table/index.tsx +38 -23
  126. package/src/plugins/table/nodeviews/TableComponent.tsx +6 -5
  127. package/src/plugins/table/nodeviews/TableContainer.tsx +31 -22
  128. package/src/plugins/table/nodeviews/TableResizer.tsx +107 -34
  129. package/src/plugins/table/nodeviews/table.tsx +16 -2
  130. package/src/plugins/table/nodeviews/types.ts +2 -0
  131. package/src/plugins/table/pm-plugins/decorations/plugin.ts +27 -4
  132. package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +1 -0
  133. package/src/plugins/table/pm-plugins/decorations/utils/types.ts +1 -0
  134. package/src/plugins/table/pm-plugins/main.ts +3 -0
  135. package/src/plugins/table/pm-plugins/table-resizing/plugin-factory.ts +1 -0
  136. package/src/plugins/table/pm-plugins/table-resizing/utils/dom.ts +1 -0
  137. package/src/plugins/table/pm-plugins/{table-add-width.ts → table-width.ts} +33 -3
  138. package/src/plugins/table/toolbar.tsx +7 -1
  139. package/src/plugins/table/types.ts +4 -0
  140. package/src/plugins/table/ui/consts.ts +3 -0
  141. package/src/plugins/table/utils/collapse.ts +1 -0
  142. package/src/plugins/table/utils/decoration.ts +1 -0
  143. package/src/plugins/table/utils/guidelines.ts +17 -0
  144. package/src/plugins/table/utils/snapping.ts +38 -0
  145. package/tmp/api-report-tmp.d.ts +3 -1
  146. package/dist/types/plugins/table/pm-plugins/table-add-width.d.ts +0 -7
  147. package/dist/types-ts4.5/plugins/table/pm-plugins/table-add-width.d.ts +0 -7
@@ -22,12 +22,15 @@ import {
22
22
  handleDocOrSelectionChanged,
23
23
  } from '../../../../plugins/table/pm-plugins/decorations/plugin';
24
24
  import { pluginKey } from '../../../../plugins/table/pm-plugins/plugin-key';
25
+ import { pluginKey as tableWidthPluginKey } from '../../../../plugins/table/pm-plugins/table-width';
25
26
  import { TableDecorations } from '../../../../plugins/table/types';
26
27
  import tablePlugin from '../../../../plugins/table';
27
28
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
28
29
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
29
30
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
30
31
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
32
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
33
+ import { ffTest } from '@atlassian/feature-flags-test-utils';
31
34
 
32
35
  describe('decorations plugin', () => {
33
36
  const createEditor = createProsemirrorEditorFactory();
@@ -40,6 +43,7 @@ describe('decorations plugin', () => {
40
43
  .add([analyticsPlugin, {}])
41
44
  .add(contentInsertionPlugin)
42
45
  .add(widthPlugin)
46
+ .add(guidelinePlugin)
43
47
  .add(tablePlugin),
44
48
  pluginKey,
45
49
  });
@@ -82,12 +86,14 @@ describe('decorations plugin', () => {
82
86
  editorView.state.tr,
83
87
  pluginState,
84
88
  editorView.state,
89
+ editorView.state,
85
90
  );
86
91
 
87
92
  const newState = handleDocOrSelectionChanged(
88
93
  editorView.state.tr,
89
94
  oldState,
90
95
  editorView.state,
96
+ editorView.state,
91
97
  );
92
98
 
93
99
  expect(newState).toEqual(oldState);
@@ -105,6 +111,7 @@ describe('decorations plugin', () => {
105
111
  editorView.state.tr,
106
112
  DecorationSet.empty,
107
113
  editorView.state,
114
+ state,
108
115
  );
109
116
 
110
117
  const { tr: transaction } = state;
@@ -114,6 +121,7 @@ describe('decorations plugin', () => {
114
121
  transaction,
115
122
  nextPluginState,
116
123
  editorView.state,
124
+ state,
117
125
  );
118
126
  const expectedDecorationSet = newState;
119
127
  const decorations = expectedDecorationSet.find(
@@ -136,14 +144,74 @@ describe('decorations plugin', () => {
136
144
  editorView.state.tr,
137
145
  DecorationSet.empty,
138
146
  editorView.state,
147
+ editorView.state,
139
148
  );
140
149
 
141
150
  const newPluginState = handleDocOrSelectionChanged(
142
151
  editorView.state.tr,
143
152
  oldPluginState,
144
153
  editorView.state,
154
+ editorView.state,
145
155
  );
146
156
  expect(oldPluginState).toEqual(newPluginState);
147
157
  });
148
158
  });
159
+
160
+ describe('table width resizing', () => {
161
+ describe('should remove column controls when resizing starts and add back when it ends', () => {
162
+ ffTest(
163
+ 'platform.editor.custom-table-width',
164
+ () => {
165
+ const { editorView } = editor(
166
+ doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
167
+ );
168
+
169
+ const startTransaction = editorView.state.tr.setMeta(
170
+ tableWidthPluginKey,
171
+ {
172
+ resizing: true,
173
+ },
174
+ );
175
+ editorView.dispatch(startTransaction);
176
+ const startDecorationSet = getDecorations(editorView.state);
177
+ expect(startDecorationSet).toEqual(DecorationSet.empty);
178
+
179
+ const endTransaction = editorView.state.tr.setMeta(
180
+ tableWidthPluginKey,
181
+ {
182
+ resizing: false,
183
+ },
184
+ );
185
+ editorView.dispatch(endTransaction);
186
+ const endDecorationSet = getDecorations(editorView.state);
187
+ expect(endDecorationSet).not.toEqual(DecorationSet.empty);
188
+ },
189
+ () => {
190
+ const { editorView } = editor(
191
+ doc(table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
192
+ );
193
+
194
+ const startTransaction = editorView.state.tr.setMeta(
195
+ tableWidthPluginKey,
196
+ {
197
+ resizing: true,
198
+ },
199
+ );
200
+ editorView.dispatch(startTransaction);
201
+ const startDecorationSet = getDecorations(editorView.state);
202
+ expect(startDecorationSet).not.toEqual(DecorationSet.empty);
203
+
204
+ const endTransaction = editorView.state.tr.setMeta(
205
+ tableWidthPluginKey,
206
+ {
207
+ resizing: false,
208
+ },
209
+ );
210
+ editorView.dispatch(endTransaction);
211
+ const endDecorationSet = getDecorations(editorView.state);
212
+ expect(endDecorationSet).not.toEqual(DecorationSet.empty);
213
+ },
214
+ );
215
+ });
216
+ });
149
217
  });
@@ -31,6 +31,7 @@ import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
31
31
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
32
32
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
33
33
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
34
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
34
35
 
35
36
  describe('tables: main plugin', () => {
36
37
  const createEditor = createProsemirrorEditorFactory();
@@ -42,6 +43,7 @@ describe('tables: main plugin', () => {
42
43
  .add([analyticsPlugin, {}])
43
44
  .add(contentInsertionPlugin)
44
45
  .add(widthPlugin)
46
+ .add(guidelinePlugin)
45
47
  .add(tablePlugin),
46
48
  pluginKey,
47
49
  });
@@ -17,6 +17,7 @@ import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
17
17
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
18
18
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
19
19
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
20
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
20
21
 
21
22
  describe('table/safari-delete-composition-text-issue-workaround', () => {
22
23
  let editor: any;
@@ -30,6 +31,7 @@ describe('table/safari-delete-composition-text-issue-workaround', () => {
30
31
  .add([analyticsPlugin, {}])
31
32
  .add(contentInsertionPlugin)
32
33
  .add(widthPlugin)
34
+ .add(guidelinePlugin)
33
35
  .add([tablePlugin, { tableOptions: { allowColumnResizing: true } }]),
34
36
  pluginKey,
35
37
  });
@@ -47,6 +47,7 @@ import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
47
47
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
48
48
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
49
49
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
50
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
50
51
 
51
52
  describe('TableRowNodeView', () => {
52
53
  let tableRowNodeView: TableRowNodeView;
@@ -62,6 +63,7 @@ describe('TableRowNodeView', () => {
62
63
  .add([analyticsPlugin, {}])
63
64
  .add(contentInsertionPlugin)
64
65
  .add(widthPlugin)
66
+ .add(guidelinePlugin)
65
67
  .add(tablePlugin),
66
68
  pluginKey,
67
69
  attachTo: document.body,
@@ -94,6 +96,7 @@ describe('TableRowNodeView', () => {
94
96
  .add([analyticsPlugin, {}])
95
97
  .add(contentInsertionPlugin)
96
98
  .add(widthPlugin)
99
+ .add(guidelinePlugin)
97
100
  .add(tablePlugin),
98
101
  pluginKey,
99
102
  });
@@ -23,6 +23,7 @@ import { pluginKey } from '../../../../plugins/table/pm-plugins/plugin-key';
23
23
  import { TextSelection, EditorState } from 'prosemirror-state';
24
24
  import { EditorView } from 'prosemirror-view';
25
25
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
26
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
26
27
  import {
27
28
  akEditorFullPageMaxWidth,
28
29
  akEditorDefaultLayoutWidth,
@@ -56,6 +57,7 @@ describe('table-resizing/event-handlers', () => {
56
57
  .add(contentInsertionPlugin)
57
58
  .add(decorationsPlugin)
58
59
  .add(widthPlugin)
60
+ .add(guidelinePlugin)
59
61
  .add([
60
62
  tablePlugin,
61
63
  {
@@ -26,6 +26,7 @@ import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
26
26
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
27
27
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
28
28
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
29
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
29
30
 
30
31
  const TABLE_LOCAL_ID = 'test-table-local-id';
31
32
 
@@ -52,6 +53,7 @@ describe('table plugin', () => {
52
53
  .add([analyticsPlugin, {}])
53
54
  .add(contentInsertionPlugin)
54
55
  .add(widthPlugin)
56
+ .add(guidelinePlugin)
55
57
  .add([tablePlugin, { tableOptions }]);
56
58
 
57
59
  const editor = (doc: DocBuilder) => {
@@ -35,6 +35,7 @@ import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
35
35
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
36
36
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
37
37
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
38
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
38
39
 
39
40
  jest.mock('@atlaskit/editor-tables/utils');
40
41
  jest.mock('../../plugins/table/transforms');
@@ -160,6 +161,7 @@ describe('getToolbarCellOptionsConfig', () => {
160
161
  .add([analyticsPlugin, {}])
161
162
  .add(contentInsertionPlugin)
162
163
  .add(widthPlugin)
164
+ .add(guidelinePlugin)
163
165
  .add([
164
166
  tablePlugin,
165
167
  {
@@ -25,6 +25,7 @@ import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
25
25
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
26
26
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
27
27
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
28
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
28
29
 
29
30
  const colsToRect = (cols: Array<number>, noOfRows: number): Rect => ({
30
31
  left: Math.min(...cols),
@@ -50,6 +51,7 @@ describe('table plugin -> transforms -> delete columns', () => {
50
51
  .add([analyticsPlugin, {}])
51
52
  .add(contentInsertionPlugin)
52
53
  .add(widthPlugin)
54
+ .add(guidelinePlugin)
53
55
  .add(tablePlugin);
54
56
 
55
57
  const editor = (doc: DocBuilder) =>
@@ -26,6 +26,7 @@ import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
26
26
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
27
27
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
28
28
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
29
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
29
30
 
30
31
  const rowsToRect = (rows: Array<number>, noOfColumns: number): Rect => ({
31
32
  left: 0,
@@ -50,6 +51,7 @@ describe('table plugin -> transforms -> delete rows', () => {
50
51
  .add([analyticsPlugin, {}])
51
52
  .add(contentInsertionPlugin)
52
53
  .add(widthPlugin)
54
+ .add(guidelinePlugin)
53
55
  .add(tablePlugin);
54
56
 
55
57
  const editor = (doc: DocBuilder) =>
@@ -22,6 +22,7 @@ import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
22
22
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
23
23
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
24
24
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
25
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
25
26
 
26
27
  const TABLE_LOCAL_ID = 'test-table-local-id';
27
28
 
@@ -40,6 +41,7 @@ describe('table plugin -> transforms -> merge cells', () => {
40
41
  .add([analyticsPlugin, {}])
41
42
  .add(contentInsertionPlugin)
42
43
  .add(widthPlugin)
44
+ .add(guidelinePlugin)
43
45
  .add(tablePlugin);
44
46
 
45
47
  const editor = (doc: DocBuilder) =>
@@ -21,6 +21,7 @@ import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
21
21
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
22
22
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
23
23
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
24
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
24
25
 
25
26
  import { ContextualMenu } from '../../../plugins/table/ui/FloatingContextualMenu/ContextualMenu';
26
27
 
@@ -38,6 +39,7 @@ describe('ContextualMenu', () => {
38
39
  .add([analyticsPlugin, {}])
39
40
  .add(contentInsertionPlugin)
40
41
  .add(widthPlugin)
42
+ .add(guidelinePlugin)
41
43
  .add([tablePlugin, { tableOptions: { advanced: true } }]),
42
44
  }));
43
45
  });
@@ -23,6 +23,7 @@ import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
23
23
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
24
24
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
25
25
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
26
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
26
27
 
27
28
  describe('CornerControls', () => {
28
29
  const createEditor = createProsemirrorEditorFactory();
@@ -35,6 +36,7 @@ describe('CornerControls', () => {
35
36
  .add([analyticsPlugin, {}])
36
37
  .add(contentInsertionPlugin)
37
38
  .add(widthPlugin)
39
+ .add(guidelinePlugin)
38
40
  .add(tablePlugin),
39
41
  pluginKey,
40
42
  });
@@ -27,6 +27,7 @@ import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
27
27
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
28
28
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
29
29
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
30
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
30
31
 
31
32
  const createEditor = createProsemirrorEditorFactory();
32
33
  let createAnalyticsEvent = jest.fn(() => ({ fire() {} } as UIAnalyticsEvent));
@@ -38,6 +39,7 @@ const editor = (doc: DocBuilder) =>
38
39
  .add([analyticsPlugin, {}])
39
40
  .add(contentInsertionPlugin)
40
41
  .add(widthPlugin)
42
+ .add(guidelinePlugin)
41
43
  .add(tablePlugin),
42
44
  });
43
45
 
@@ -24,6 +24,7 @@ import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
24
24
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
25
25
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
26
26
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
27
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
27
28
 
28
29
  describe('FloatingContextualMenu', () => {
29
30
  const createEditor = createProsemirrorEditorFactory();
@@ -37,6 +38,7 @@ describe('FloatingContextualMenu', () => {
37
38
  .add([analyticsPlugin, {}])
38
39
  .add(contentInsertionPlugin)
39
40
  .add(widthPlugin)
41
+ .add(guidelinePlugin)
40
42
  .add(tablePlugin),
41
43
  }));
42
44
  });
@@ -29,6 +29,7 @@ import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
29
29
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
30
30
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
31
31
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
32
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
32
33
 
33
34
  describe('RowControls', () => {
34
35
  const createEditor = createProsemirrorEditorFactory();
@@ -61,6 +62,7 @@ describe('RowControls', () => {
61
62
  .add([analyticsPlugin, {}])
62
63
  .add(contentInsertionPlugin)
63
64
  .add(widthPlugin)
65
+ .add(guidelinePlugin)
64
66
  .add(tablePlugin),
65
67
  pluginKey,
66
68
  });
@@ -28,6 +28,7 @@ import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
28
28
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
29
29
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
30
30
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
31
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
31
32
 
32
33
  describe('TableFloatingControls', () => {
33
34
  const createEditor = createProsemirrorEditorFactory();
@@ -37,6 +38,7 @@ describe('TableFloatingControls', () => {
37
38
  .add([analyticsPlugin, {}])
38
39
  .add(contentInsertionPlugin)
39
40
  .add(widthPlugin)
41
+ .add(guidelinePlugin)
40
42
  .add(tablePlugin);
41
43
 
42
44
  const editor = (doc: DocBuilder) =>
@@ -25,6 +25,7 @@ import sendKeyToPm from '@atlaskit/editor-test-helpers/send-key-to-pm';
25
25
  import clone from 'lodash/clone';
26
26
  import tablePlugin from '../../plugins/table';
27
27
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
28
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
28
29
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
29
30
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
30
31
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
@@ -66,6 +67,7 @@ describe('undo/redo with tables', () => {
66
67
  .add([analyticsPlugin, {}])
67
68
  .add(contentInsertionPlugin)
68
69
  .add(widthPlugin)
70
+ .add(guidelinePlugin)
69
71
  .add([tablePlugin, { tableOptions }]),
70
72
  pluginKey: tablePluginKey,
71
73
  });
@@ -13,6 +13,7 @@ import {
13
13
 
14
14
  import tablePlugin from '../../../plugins/table';
15
15
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
16
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
16
17
 
17
18
  import { isTableCollapsible } from '../../../plugins/table/utils/collapse';
18
19
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
@@ -28,6 +29,7 @@ describe('collapse', () => {
28
29
  .add([analyticsPlugin, {}])
29
30
  .add(contentInsertionPlugin)
30
31
  .add(widthPlugin)
32
+ .add(guidelinePlugin)
31
33
  .add(tablePlugin);
32
34
 
33
35
  return createEditor({ doc, preset });
@@ -22,6 +22,7 @@ import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
22
22
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
23
23
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
24
24
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
25
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
25
26
 
26
27
  describe('table merging logic', () => {
27
28
  const createEditor = createProsemirrorEditorFactory();
@@ -34,6 +35,7 @@ describe('table merging logic', () => {
34
35
  .add([analyticsPlugin, {}])
35
36
  .add(contentInsertionPlugin)
36
37
  .add(widthPlugin)
38
+ .add(guidelinePlugin)
37
39
  .add(tablePlugin),
38
40
  pluginKey,
39
41
  });
@@ -23,6 +23,7 @@ import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
23
23
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
24
24
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
25
25
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
26
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
26
27
 
27
28
  const TABLE_LOCAL_ID = 'test-table-local-id';
28
29
 
@@ -44,6 +45,7 @@ describe('table plugin: utils/row-controls.js', () => {
44
45
  .add([analyticsPlugin, {}])
45
46
  .add(contentInsertionPlugin)
46
47
  .add(widthPlugin)
48
+ .add(guidelinePlugin)
47
49
  .add(tablePlugin),
48
50
  pluginKey,
49
51
  });
@@ -32,6 +32,7 @@ import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
32
32
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
33
33
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
34
34
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
35
+ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
35
36
 
36
37
  describe('table plugin: utils', () => {
37
38
  const createEditor = createProsemirrorEditorFactory();
@@ -40,6 +41,7 @@ describe('table plugin: utils', () => {
40
41
  .add([analyticsPlugin, {}])
41
42
  .add(contentInsertionPlugin)
42
43
  .add(widthPlugin)
44
+ .add(guidelinePlugin)
43
45
  .add(tablePlugin);
44
46
 
45
47
  const editor = (doc: DocBuilder) =>
@@ -1,4 +1,5 @@
1
1
  // #region Imports
2
+ // @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
2
3
  import { Transaction, ReadonlyTransaction } from 'prosemirror-state';
3
4
  import { ContentNodeWithPos, findParentNodeOfType } from 'prosemirror-utils';
4
5
  import { findTable } from '@atlaskit/editor-tables/utils';
@@ -36,7 +36,10 @@ import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
36
36
 
37
37
  import { pluginConfig } from './create-plugin-config';
38
38
  import { createPlugin as createTableLocalIdPlugin } from './pm-plugins/table-local-id';
39
- import { createPlugin as createTableAddWidthPlugin } from './pm-plugins/table-add-width';
39
+ import {
40
+ pluginKey as tableWidthPluginKey,
41
+ createPlugin as createTableWidthPlugin,
42
+ } from './pm-plugins/table-width';
40
43
  import { createPlugin as createTableSafariDeleteCompositionTextIssueWorkaroundPlugin } from './pm-plugins/safari-delete-composition-text-issue-workaround';
41
44
  import { createPlugin as createDecorationsPlugin } from './pm-plugins/decorations/plugin';
42
45
  import { keymapPlugin } from './pm-plugins/keymap';
@@ -71,6 +74,7 @@ import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
71
74
  import type { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
72
75
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
73
76
  import type { widthPlugin } from '@atlaskit/editor-plugin-width';
77
+ import type { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
74
78
 
75
79
  interface TablePluginOptions {
76
80
  tableOptions: PluginConfig;
@@ -98,6 +102,7 @@ const tablesPlugin: NextEditorPlugin<
98
102
  typeof analyticsPlugin,
99
103
  typeof contentInsertionPlugin,
100
104
  typeof widthPlugin,
105
+ typeof guidelinePlugin,
101
106
  ];
102
107
  }
103
108
  > = (options?: TablePluginOptions, api?) => {
@@ -172,13 +177,13 @@ const tablesPlugin: NextEditorPlugin<
172
177
  portalProviderAPI,
173
178
  eventDispatcher,
174
179
  pluginConfig(tableOptions),
175
-
176
180
  defaultGetEditorContainerWidth,
177
181
  getEditorFeatureFlags || defaultGetEditorFeatureFlags,
178
182
  breakoutEnabled,
179
183
  fullWidthEnabled,
180
184
  wasFullWidthEnabled,
181
185
  editorAnalyticsAPI,
186
+ api,
182
187
  );
183
188
  },
184
189
  },
@@ -255,10 +260,13 @@ const tablesPlugin: NextEditorPlugin<
255
260
  plugin: ({ dispatch }) => createTableLocalIdPlugin(dispatch),
256
261
  },
257
262
  {
258
- name: 'tableAddWidth',
259
- plugin: () =>
260
- getBooleanFF('platform.editor.custom-table-width') && options
261
- ? createTableAddWidthPlugin(options.fullWidthEnabled || false)
263
+ name: 'tableWidth',
264
+ plugin: ({ dispatch }) =>
265
+ getBooleanFF('platform.editor.custom-table-width')
266
+ ? createTableWidthPlugin(
267
+ dispatch,
268
+ options?.fullWidthEnabled ?? false,
269
+ )
262
270
  : undefined,
263
271
  },
264
272
 
@@ -309,6 +317,7 @@ const tablesPlugin: NextEditorPlugin<
309
317
  <WithPluginState
310
318
  plugins={{
311
319
  tablePluginState: pluginKey,
320
+ tableWidthPluginState: tableWidthPluginKey,
312
321
  tableResizingPluginState: tableResizingPluginKey,
313
322
  stickyHeadersState: stickyHeadersPluginKey,
314
323
  }}
@@ -316,9 +325,13 @@ const tablesPlugin: NextEditorPlugin<
316
325
  tableResizingPluginState: resizingPluginState,
317
326
  stickyHeadersState,
318
327
  tablePluginState,
328
+ tableWidthPluginState,
319
329
  }) => {
320
330
  const { state } = editorView;
321
- const isDragging = resizingPluginState?.dragging;
331
+ const isColumnResizing = resizingPluginState?.dragging;
332
+ const isTableResizing = tableWidthPluginState?.resizing;
333
+ const isResizing = isColumnResizing || isTableResizing;
334
+
322
335
  const {
323
336
  tableNode,
324
337
  tablePos,
@@ -364,7 +377,7 @@ const tablesPlugin: NextEditorPlugin<
364
377
  <>
365
378
  {targetCellPosition &&
366
379
  tableRef &&
367
- !isDragging &&
380
+ !isResizing &&
368
381
  options &&
369
382
  options.allowContextualMenu && (
370
383
  <FloatingContextualButton
@@ -401,21 +414,23 @@ const tablesPlugin: NextEditorPlugin<
401
414
  getEditorContainerWidth={defaultGetEditorContainerWidth}
402
415
  />
403
416
  )}
404
- <FloatingContextualMenu
405
- editorView={editorView}
406
- mountPoint={popupsMountPoint}
407
- boundariesElement={popupsBoundariesElement}
408
- targetCellPosition={targetCellPosition}
409
- isOpen={Boolean(isContextualMenuOpen)}
410
- pluginConfig={pluginConfig}
411
- editorAnalyticsAPI={editorAnalyticsAPI}
412
- getEditorContainerWidth={defaultGetEditorContainerWidth}
413
- getEditorFeatureFlags={
414
- options?.getEditorFeatureFlags ||
415
- defaultGetEditorFeatureFlags
416
- }
417
- />
418
- {allowControls && (
417
+ {options?.allowContextualMenu && (
418
+ <FloatingContextualMenu
419
+ editorView={editorView}
420
+ mountPoint={popupsMountPoint}
421
+ boundariesElement={popupsBoundariesElement}
422
+ targetCellPosition={targetCellPosition}
423
+ isOpen={Boolean(isContextualMenuOpen) && !isResizing}
424
+ pluginConfig={pluginConfig}
425
+ editorAnalyticsAPI={editorAnalyticsAPI}
426
+ getEditorContainerWidth={defaultGetEditorContainerWidth}
427
+ getEditorFeatureFlags={
428
+ options?.getEditorFeatureFlags ||
429
+ defaultGetEditorFeatureFlags
430
+ }
431
+ />
432
+ )}
433
+ {allowControls && !isResizing && (
419
434
  <FloatingDeleteButton
420
435
  editorView={editorView}
421
436
  selection={editorView.state.selection}
@@ -34,7 +34,7 @@ import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
34
34
  import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
35
35
  import {
36
36
  TableCssClassName as ClassName,
37
- ColumnResizingPluginState,
37
+ PluginInjectionAPI,
38
38
  ShadowEvent,
39
39
  } from '../types';
40
40
  import type { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
@@ -72,8 +72,9 @@ export interface ComponentProps {
72
72
  isMediaFullscreen?: boolean;
73
73
  tableActive: boolean;
74
74
  ordering: TableColumnOrdering;
75
- tableResizingPluginState?: ColumnResizingPluginState;
75
+ isResizing?: boolean;
76
76
  getEditorFeatureFlags: GetEditorFeatureFlags;
77
+ pluginInjectionApi?: PluginInjectionAPI;
77
78
  }
78
79
 
79
80
  interface TableState {
@@ -317,7 +318,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
317
318
  const {
318
319
  view,
319
320
  getNode,
320
- tableResizingPluginState,
321
+ isResizing,
321
322
  allowControls = true,
322
323
  isHeaderRowEnabled,
323
324
  ordering,
@@ -326,6 +327,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
326
327
  containerWidth,
327
328
  options,
328
329
  getPos,
330
+ pluginInjectionApi,
329
331
  } = this.props;
330
332
  const { isLoading, showBeforeShadow, showAfterShadow } = this.state;
331
333
  const node = getNode();
@@ -340,8 +342,6 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
340
342
  } = this.props.getEditorFeatureFlags();
341
343
 
342
344
  const tableRef = this.table || undefined;
343
- const isResizing =
344
- !!tableResizingPluginState && !!tableResizingPluginState.dragging;
345
345
  const headerRow = tableRef
346
346
  ? tableRef.querySelector<HTMLTableRowElement>('tr[data-header-row]')
347
347
  : undefined;
@@ -406,6 +406,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
406
406
  isFullWidthModeEnabled={options?.isFullWidthModeEnabled}
407
407
  isBreakoutEnabled={options?.isBreakoutEnabled}
408
408
  isNested={isNested}
409
+ pluginInjectionApi={pluginInjectionApi}
409
410
  >
410
411
  {stickyHeadersOptimization && (
411
412
  <div