@atlaskit/editor-plugin-table 2.2.0 → 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 (42) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cjs/plugins/table/index.js +40 -34
  3. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +1 -2
  4. package/dist/cjs/plugins/table/nodeviews/TableResizer.js +21 -13
  5. package/dist/cjs/plugins/table/nodeviews/table.js +7 -2
  6. package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +14 -5
  7. package/dist/cjs/plugins/table/pm-plugins/{table-add-width.js → table-width.js} +27 -4
  8. package/dist/cjs/plugins/table/toolbar.js +6 -1
  9. package/dist/cjs/version.json +1 -1
  10. package/dist/es2019/plugins/table/index.js +18 -9
  11. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +1 -2
  12. package/dist/es2019/plugins/table/nodeviews/TableResizer.js +26 -14
  13. package/dist/es2019/plugins/table/nodeviews/table.js +7 -2
  14. package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +14 -5
  15. package/dist/es2019/plugins/table/pm-plugins/{table-add-width.js → table-width.js} +25 -3
  16. package/dist/es2019/plugins/table/toolbar.js +6 -1
  17. package/dist/es2019/version.json +1 -1
  18. package/dist/esm/plugins/table/index.js +40 -34
  19. package/dist/esm/plugins/table/nodeviews/TableComponent.js +1 -2
  20. package/dist/esm/plugins/table/nodeviews/TableResizer.js +21 -13
  21. package/dist/esm/plugins/table/nodeviews/table.js +7 -2
  22. package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +14 -5
  23. package/dist/esm/plugins/table/pm-plugins/{table-add-width.js → table-width.js} +25 -3
  24. package/dist/esm/plugins/table/toolbar.js +6 -1
  25. package/dist/esm/version.json +1 -1
  26. package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +2 -2
  27. package/dist/types/plugins/table/pm-plugins/decorations/plugin.d.ts +1 -1
  28. package/dist/types/plugins/table/pm-plugins/table-width.d.ts +16 -0
  29. package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +2 -2
  30. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/plugin.d.ts +1 -1
  31. package/dist/types-ts4.5/plugins/table/pm-plugins/table-width.d.ts +16 -0
  32. package/package.json +3 -3
  33. package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +66 -0
  34. package/src/plugins/table/index.tsx +35 -22
  35. package/src/plugins/table/nodeviews/TableComponent.tsx +3 -6
  36. package/src/plugins/table/nodeviews/TableResizer.tsx +27 -20
  37. package/src/plugins/table/nodeviews/table.tsx +12 -2
  38. package/src/plugins/table/pm-plugins/decorations/plugin.ts +26 -4
  39. package/src/plugins/table/pm-plugins/{table-add-width.ts → table-width.ts} +33 -3
  40. package/src/plugins/table/toolbar.tsx +7 -1
  41. package/dist/types/plugins/table/pm-plugins/table-add-width.d.ts +0 -7
  42. package/dist/types-ts4.5/plugins/table/pm-plugins/table-add-width.d.ts +0 -7
@@ -22,6 +22,7 @@ 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';
@@ -29,6 +30,7 @@ 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';
31
32
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
33
+ import { ffTest } from '@atlassian/feature-flags-test-utils';
32
34
 
33
35
  describe('decorations plugin', () => {
34
36
  const createEditor = createProsemirrorEditorFactory();
@@ -84,12 +86,14 @@ describe('decorations plugin', () => {
84
86
  editorView.state.tr,
85
87
  pluginState,
86
88
  editorView.state,
89
+ editorView.state,
87
90
  );
88
91
 
89
92
  const newState = handleDocOrSelectionChanged(
90
93
  editorView.state.tr,
91
94
  oldState,
92
95
  editorView.state,
96
+ editorView.state,
93
97
  );
94
98
 
95
99
  expect(newState).toEqual(oldState);
@@ -107,6 +111,7 @@ describe('decorations plugin', () => {
107
111
  editorView.state.tr,
108
112
  DecorationSet.empty,
109
113
  editorView.state,
114
+ state,
110
115
  );
111
116
 
112
117
  const { tr: transaction } = state;
@@ -116,6 +121,7 @@ describe('decorations plugin', () => {
116
121
  transaction,
117
122
  nextPluginState,
118
123
  editorView.state,
124
+ state,
119
125
  );
120
126
  const expectedDecorationSet = newState;
121
127
  const decorations = expectedDecorationSet.find(
@@ -138,14 +144,74 @@ describe('decorations plugin', () => {
138
144
  editorView.state.tr,
139
145
  DecorationSet.empty,
140
146
  editorView.state,
147
+ editorView.state,
141
148
  );
142
149
 
143
150
  const newPluginState = handleDocOrSelectionChanged(
144
151
  editorView.state.tr,
145
152
  oldPluginState,
146
153
  editorView.state,
154
+ editorView.state,
147
155
  );
148
156
  expect(oldPluginState).toEqual(newPluginState);
149
157
  });
150
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
+ });
151
217
  });
@@ -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';
@@ -257,10 +260,13 @@ const tablesPlugin: NextEditorPlugin<
257
260
  plugin: ({ dispatch }) => createTableLocalIdPlugin(dispatch),
258
261
  },
259
262
  {
260
- name: 'tableAddWidth',
261
- plugin: () =>
262
- getBooleanFF('platform.editor.custom-table-width') && options
263
- ? 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
+ )
264
270
  : undefined,
265
271
  },
266
272
 
@@ -311,6 +317,7 @@ const tablesPlugin: NextEditorPlugin<
311
317
  <WithPluginState
312
318
  plugins={{
313
319
  tablePluginState: pluginKey,
320
+ tableWidthPluginState: tableWidthPluginKey,
314
321
  tableResizingPluginState: tableResizingPluginKey,
315
322
  stickyHeadersState: stickyHeadersPluginKey,
316
323
  }}
@@ -318,9 +325,13 @@ const tablesPlugin: NextEditorPlugin<
318
325
  tableResizingPluginState: resizingPluginState,
319
326
  stickyHeadersState,
320
327
  tablePluginState,
328
+ tableWidthPluginState,
321
329
  }) => {
322
330
  const { state } = editorView;
323
- const isDragging = resizingPluginState?.dragging;
331
+ const isColumnResizing = resizingPluginState?.dragging;
332
+ const isTableResizing = tableWidthPluginState?.resizing;
333
+ const isResizing = isColumnResizing || isTableResizing;
334
+
324
335
  const {
325
336
  tableNode,
326
337
  tablePos,
@@ -366,7 +377,7 @@ const tablesPlugin: NextEditorPlugin<
366
377
  <>
367
378
  {targetCellPosition &&
368
379
  tableRef &&
369
- !isDragging &&
380
+ !isResizing &&
370
381
  options &&
371
382
  options.allowContextualMenu && (
372
383
  <FloatingContextualButton
@@ -403,21 +414,23 @@ const tablesPlugin: NextEditorPlugin<
403
414
  getEditorContainerWidth={defaultGetEditorContainerWidth}
404
415
  />
405
416
  )}
406
- <FloatingContextualMenu
407
- editorView={editorView}
408
- mountPoint={popupsMountPoint}
409
- boundariesElement={popupsBoundariesElement}
410
- targetCellPosition={targetCellPosition}
411
- isOpen={Boolean(isContextualMenuOpen)}
412
- pluginConfig={pluginConfig}
413
- editorAnalyticsAPI={editorAnalyticsAPI}
414
- getEditorContainerWidth={defaultGetEditorContainerWidth}
415
- getEditorFeatureFlags={
416
- options?.getEditorFeatureFlags ||
417
- defaultGetEditorFeatureFlags
418
- }
419
- />
420
- {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 && (
421
434
  <FloatingDeleteButton
422
435
  editorView={editorView}
423
436
  selection={editorView.state.selection}
@@ -34,9 +34,8 @@ 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,
38
- ShadowEvent,
39
37
  PluginInjectionAPI,
38
+ ShadowEvent,
40
39
  } from '../types';
41
40
  import type { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
42
41
  import TableFloatingControls from '../ui/TableFloatingControls';
@@ -73,7 +72,7 @@ export interface ComponentProps {
73
72
  isMediaFullscreen?: boolean;
74
73
  tableActive: boolean;
75
74
  ordering: TableColumnOrdering;
76
- tableResizingPluginState?: ColumnResizingPluginState;
75
+ isResizing?: boolean;
77
76
  getEditorFeatureFlags: GetEditorFeatureFlags;
78
77
  pluginInjectionApi?: PluginInjectionAPI;
79
78
  }
@@ -319,7 +318,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
319
318
  const {
320
319
  view,
321
320
  getNode,
322
- tableResizingPluginState,
321
+ isResizing,
323
322
  allowControls = true,
324
323
  isHeaderRowEnabled,
325
324
  ordering,
@@ -343,8 +342,6 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
343
342
  } = this.props.getEditorFeatureFlags();
344
343
 
345
344
  const tableRef = this.table || undefined;
346
- const isResizing =
347
- !!tableResizingPluginState && !!tableResizingPluginState.dragging;
348
345
  const headerRow = tableRef
349
346
  ? tableRef.querySelector<HTMLTableRowElement>('tr[data-header-row]')
350
347
  : undefined;
@@ -23,6 +23,7 @@ import {
23
23
  getColgroupChildrenLength,
24
24
  COLUMN_MIN_WIDTH,
25
25
  } from '../pm-plugins/table-resizing/utils';
26
+ import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
26
27
  import { defaultGuidelines, defaultGuidelineWidths } from '../utils/guidelines';
27
28
  import { findClosestSnap } from '../utils/snapping';
28
29
  import { TABLE_SNAP_GAP, TABLE_HIGHLIGHT_GAP } from '../ui/consts';
@@ -105,9 +106,15 @@ export const TableResizer = ({
105
106
  );
106
107
 
107
108
  const handleResizeStart = useCallback(() => {
109
+ const {
110
+ dispatch,
111
+ state: { tr },
112
+ } = editorView;
113
+ dispatch(tr.setMeta(tableWidthPluginKey, { resizing: true }));
114
+
108
115
  setSnappingEnabled(displayGuideline(defaultGuidelines));
109
116
  return width;
110
- }, [width, displayGuideline]);
117
+ }, [width, displayGuideline, editorView]);
111
118
 
112
119
  const handleResizeStop = useCallback<HandleResize>(
113
120
  (originalState, delta) => {
@@ -115,26 +122,26 @@ export const TableResizer = ({
115
122
  const { state, dispatch } = editorView;
116
123
  const pos = getPos();
117
124
 
118
- if (typeof pos !== 'number') {
119
- return;
120
- }
125
+ let tr = state.tr.setMeta(tableWidthPluginKey, { resizing: false });
126
+
127
+ if (typeof pos === 'number') {
128
+ tr = tr.setNodeMarkup(pos, undefined, {
129
+ ...node.attrs,
130
+ width: newWidth,
131
+ });
121
132
 
122
- let tr = state.tr.setNodeMarkup(pos, undefined, {
123
- ...node.attrs,
124
- width: newWidth,
125
- });
126
-
127
- const newNode = tr.doc.nodeAt(pos)!;
128
- tr = scaleTable(
129
- tableRef,
130
- {
131
- node: newNode,
132
- prevNode: node,
133
- start: pos + 1,
134
- parentWidth: newWidth,
135
- },
136
- editorView.domAtPos.bind(editorView),
137
- )(tr);
133
+ const newNode = tr.doc.nodeAt(pos)!;
134
+ tr = scaleTable(
135
+ tableRef,
136
+ {
137
+ node: newNode,
138
+ prevNode: node,
139
+ start: pos + 1,
140
+ parentWidth: newWidth,
141
+ },
142
+ editorView.domAtPos.bind(editorView),
143
+ )(tr);
144
+ }
138
145
 
139
146
  dispatch(tr);
140
147
 
@@ -24,6 +24,7 @@ import { pluginConfig as getPluginConfig } from '../create-plugin-config';
24
24
  import { getPluginState } from '../pm-plugins/plugin-factory';
25
25
  import { pluginKey } from '../pm-plugins/plugin-key';
26
26
  import { pluginKey as tableResizingPluginKey } from '../pm-plugins/table-resizing';
27
+ import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
27
28
  import { generateColgroup } from '../pm-plugins/table-resizing/utils';
28
29
  import { TableMap } from '@atlaskit/editor-tables/table-map';
29
30
  import TableComponent from './TableComponent';
@@ -157,6 +158,7 @@ export default class TableView extends ReactNodeView<Props> {
157
158
  plugins={{
158
159
  pluginState: pluginKey,
159
160
  tableResizingPluginState: tableResizingPluginKey,
161
+ tableWidthPluginState: tableWidthPluginKey,
160
162
  widthPlugin: fakePluginKey,
161
163
  mediaState: fakeMediaPluginKey,
162
164
  }}
@@ -164,12 +166,20 @@ export default class TableView extends ReactNodeView<Props> {
164
166
  render={(pluginStates) => {
165
167
  const {
166
168
  tableResizingPluginState,
169
+ tableWidthPluginState,
167
170
  pluginState,
168
171
  // containerWidth,
169
172
  mediaState,
170
173
  } = pluginStates;
171
- const tableActive = props.getPos() === pluginState!.tablePos;
172
174
  const containerWidth = props.getEditorContainerWidth();
175
+
176
+ const isTableResizing = tableWidthPluginState?.resizing;
177
+ const isResizing = Boolean(
178
+ tableResizingPluginState?.dragging || isTableResizing,
179
+ );
180
+ const tableActive =
181
+ props.getPos() === pluginState!.tablePos && !isTableResizing;
182
+
173
183
  return (
174
184
  <TableComponent
175
185
  view={props.view}
@@ -183,7 +193,7 @@ export default class TableView extends ReactNodeView<Props> {
183
193
  isHeaderColumnEnabled={pluginState!.isHeaderColumnEnabled}
184
194
  tableActive={tableActive}
185
195
  ordering={pluginState!.ordering as TableColumnOrdering}
186
- tableResizingPluginState={tableResizingPluginState}
196
+ isResizing={isResizing}
187
197
  getNode={this.getNode}
188
198
  containerWidth={containerWidth!}
189
199
  contentDOM={forwardRef}
@@ -10,6 +10,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
10
10
  import { DecorationSet } from 'prosemirror-view';
11
11
 
12
12
  import { pluginKey as tablePluginKey } from '../plugin-key';
13
+ import { pluginKey as tableWidthPluginKey } from '../table-width';
13
14
 
14
15
  import {
15
16
  buildColumnControlsDecorations,
@@ -25,8 +26,20 @@ export const handleDocOrSelectionChanged = (
25
26
  tr: Transaction | ReadonlyTransaction,
26
27
  decorationSet: DecorationSet,
27
28
  oldState: EditorState,
29
+ newState: EditorState,
28
30
  ): DecorationSet => {
29
- if (tr.docChanged || tr.selection instanceof CellSelection) {
31
+ const isResizing = tableWidthPluginKey.getState(newState)?.resizing;
32
+ const wasResizing = tableWidthPluginKey.getState(oldState)?.resizing;
33
+ const changedResizing = isResizing !== wasResizing;
34
+
35
+ // Remove column controls when resizing
36
+ if (isResizing) {
37
+ return DecorationSet.empty;
38
+ } else if (
39
+ tr.docChanged ||
40
+ tr.selection instanceof CellSelection ||
41
+ changedResizing
42
+ ) {
30
43
  return buildColumnControlsDecorations({
31
44
  decorationSet,
32
45
  tr,
@@ -53,16 +66,25 @@ export const createPlugin = () => {
53
66
  state: {
54
67
  init: () => DecorationSet.empty,
55
68
 
56
- apply: (tr, decorationSet, oldState) => {
69
+ apply: (tr, decorationSet, oldState, newState) => {
57
70
  let pluginState = decorationSet;
58
71
  const meta = tr.getMeta(tablePluginKey);
59
72
  if (meta && meta.data && meta.data.decorationSet) {
60
73
  pluginState = meta.data.decorationSet;
61
74
  }
62
75
 
63
- if (tr.docChanged || tr.selectionSet) {
76
+ if (
77
+ tr.docChanged ||
78
+ tr.selectionSet ||
79
+ tr.getMeta(tableWidthPluginKey)
80
+ ) {
64
81
  pluginState = pluginState.map(tr.mapping, tr.doc);
65
- return handleDocOrSelectionChanged(tr, pluginState, oldState);
82
+ return handleDocOrSelectionChanged(
83
+ tr,
84
+ pluginState,
85
+ oldState,
86
+ newState,
87
+ );
66
88
  }
67
89
 
68
90
  return pluginState;
@@ -1,6 +1,7 @@
1
1
  /**
2
- * A plugin for scan the document, add width value to table's width attribute when necessary
3
- *
2
+ * A plugin for handle table custom widths
3
+ * Has login to scan the document, add width value to table's width attribute when necessary
4
+ * Also holds resizing state to hide / show table controls
4
5
  */
5
6
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
7
  import {
@@ -9,6 +10,8 @@ import {
9
10
  } from '@atlaskit/editor-shared-styles';
10
11
  import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
11
12
  import { ReplaceStep } from 'prosemirror-transform';
13
+ import { PluginKey } from 'prosemirror-state';
14
+ import { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
12
15
 
13
16
  type __ReplaceStep = ReplaceStep & {
14
17
  // Properties `to` and `from` are private attributes of ReplaceStep.
@@ -16,8 +19,35 @@ type __ReplaceStep = ReplaceStep & {
16
19
  from: number;
17
20
  };
18
21
 
19
- const createPlugin = (fullWidthEnabled: boolean) =>
22
+ type TableWidthPluginState = {
23
+ resizing: boolean;
24
+ };
25
+
26
+ export const pluginKey = new PluginKey<TableWidthPluginState>(
27
+ 'tableWidthPlugin',
28
+ );
29
+
30
+ const createPlugin = (dispatch: Dispatch, fullWidthEnabled: boolean) =>
20
31
  new SafePlugin({
32
+ key: pluginKey,
33
+ state: {
34
+ init() {
35
+ return {
36
+ resizing: false,
37
+ };
38
+ },
39
+ apply(tr, pluginState) {
40
+ const meta = tr.getMeta(pluginKey);
41
+ if (meta && meta.resizing !== pluginState.resizing) {
42
+ const newState = { resizing: meta.resizing };
43
+
44
+ dispatch(pluginKey, newState);
45
+ return newState;
46
+ }
47
+
48
+ return pluginState;
49
+ },
50
+ },
21
51
  appendTransaction: (transactions, _oldState, newState) => {
22
52
  // When document first load in Confluence, initially it is an empty document
23
53
  // and Collab service triggers a transaction to replace the empty document with the real document that should be rendered.
@@ -44,6 +44,7 @@ import {
44
44
  } from './commands-with-analytics';
45
45
  import { getPluginState } from './pm-plugins/plugin-factory';
46
46
  import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
47
+ import { pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
47
48
  import {
48
49
  ToolbarMenuConfig,
49
50
  ToolbarMenuState,
@@ -440,7 +441,12 @@ export const getToolbarConfig =
440
441
  const tableObject = findTable(state.selection);
441
442
  const pluginState = getPluginState(state);
442
443
  const resizeState = tableResizingPluginKey.getState(state);
443
- if (tableObject && pluginState.editorHasFocus) {
444
+ const tableWidthState = tableWidthPluginKey.getState(state);
445
+
446
+ // We don't want to show floating toolbar while resizing the table
447
+ const isWidthResizing = tableWidthState?.resizing;
448
+
449
+ if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
444
450
  const nodeType = state.schema.nodes.table;
445
451
  const menu = getToolbarMenuConfig(
446
452
  config,
@@ -1,7 +0,0 @@
1
- /**
2
- * A plugin for scan the document, add width value to table's width attribute when necessary
3
- *
4
- */
5
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
- declare const createPlugin: (fullWidthEnabled: boolean) => SafePlugin<any>;
7
- export { createPlugin };
@@ -1,7 +0,0 @@
1
- /**
2
- * A plugin for scan the document, add width value to table's width attribute when necessary
3
- *
4
- */
5
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
- declare const createPlugin: (fullWidthEnabled: boolean) => SafePlugin<any>;
7
- export { createPlugin };