@atlaskit/editor-plugin-table 7.4.9 → 7.5.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 (180) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/commands/column-resize.js +4 -2
  3. package/dist/cjs/commands/delete.js +2 -1
  4. package/dist/cjs/commands/insert.js +6 -3
  5. package/dist/cjs/commands-with-analytics.js +4 -2
  6. package/dist/cjs/event-handlers.js +2 -1
  7. package/dist/cjs/nodeviews/TableComponent.js +116 -47
  8. package/dist/cjs/nodeviews/TableContainer.js +8 -4
  9. package/dist/cjs/nodeviews/TableResizer.js +6 -5
  10. package/dist/cjs/nodeviews/table.js +12 -4
  11. package/dist/cjs/plugin.js +50 -47
  12. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +9 -6
  13. package/dist/cjs/pm-plugins/keymap.js +6 -3
  14. package/dist/cjs/pm-plugins/main.js +4 -1
  15. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +7 -3
  16. package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +32 -11
  17. package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +4 -2
  18. package/dist/cjs/pm-plugins/table-resizing/utils/index.js +24 -0
  19. package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +20 -1
  20. package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +2 -1
  21. package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +52 -11
  22. package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +19 -8
  23. package/dist/cjs/toolbar.js +17 -10
  24. package/dist/cjs/transforms/column-width.js +22 -7
  25. package/dist/cjs/transforms/delete-columns.js +2 -1
  26. package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +45 -38
  27. package/dist/cjs/ui/FloatingContextualMenu/index.js +4 -2
  28. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +3 -2
  29. package/dist/cjs/ui/FloatingDragMenu/index.js +7 -2
  30. package/dist/cjs/ui/FloatingInsertButton/index.js +5 -1
  31. package/dist/cjs/utils/create.js +1 -1
  32. package/dist/cjs/utils/drag-menu.js +4 -3
  33. package/dist/es2019/commands/column-resize.js +4 -3
  34. package/dist/es2019/commands/delete.js +2 -2
  35. package/dist/es2019/commands/insert.js +6 -6
  36. package/dist/es2019/commands-with-analytics.js +4 -4
  37. package/dist/es2019/event-handlers.js +2 -2
  38. package/dist/es2019/nodeviews/TableComponent.js +77 -8
  39. package/dist/es2019/nodeviews/TableContainer.js +8 -4
  40. package/dist/es2019/nodeviews/TableResizer.js +6 -5
  41. package/dist/es2019/nodeviews/table.js +12 -4
  42. package/dist/es2019/plugin.js +14 -8
  43. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +7 -4
  44. package/dist/es2019/pm-plugins/keymap.js +6 -3
  45. package/dist/es2019/pm-plugins/main.js +4 -1
  46. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +7 -3
  47. package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +31 -12
  48. package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +3 -1
  49. package/dist/es2019/pm-plugins/table-resizing/utils/index.js +2 -2
  50. package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +20 -2
  51. package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +2 -2
  52. package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +47 -10
  53. package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +19 -12
  54. package/dist/es2019/toolbar.js +15 -12
  55. package/dist/es2019/transforms/column-width.js +24 -10
  56. package/dist/es2019/transforms/delete-columns.js +2 -2
  57. package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +12 -5
  58. package/dist/es2019/ui/FloatingContextualMenu/index.js +4 -2
  59. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +3 -2
  60. package/dist/es2019/ui/FloatingDragMenu/index.js +7 -2
  61. package/dist/es2019/ui/FloatingInsertButton/index.js +5 -1
  62. package/dist/es2019/utils/create.js +1 -1
  63. package/dist/es2019/utils/drag-menu.js +4 -4
  64. package/dist/esm/commands/column-resize.js +4 -2
  65. package/dist/esm/commands/delete.js +2 -1
  66. package/dist/esm/commands/insert.js +6 -3
  67. package/dist/esm/commands-with-analytics.js +4 -2
  68. package/dist/esm/event-handlers.js +2 -1
  69. package/dist/esm/nodeviews/TableComponent.js +118 -49
  70. package/dist/esm/nodeviews/TableContainer.js +8 -4
  71. package/dist/esm/nodeviews/TableResizer.js +6 -5
  72. package/dist/esm/nodeviews/table.js +12 -4
  73. package/dist/esm/plugin.js +50 -47
  74. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +9 -6
  75. package/dist/esm/pm-plugins/keymap.js +6 -3
  76. package/dist/esm/pm-plugins/main.js +4 -1
  77. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +7 -3
  78. package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +32 -11
  79. package/dist/esm/pm-plugins/table-resizing/utils/consts.js +3 -1
  80. package/dist/esm/pm-plugins/table-resizing/utils/index.js +2 -2
  81. package/dist/esm/pm-plugins/table-resizing/utils/misc.js +22 -2
  82. package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +2 -1
  83. package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +52 -11
  84. package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +19 -8
  85. package/dist/esm/toolbar.js +17 -10
  86. package/dist/esm/transforms/column-width.js +23 -8
  87. package/dist/esm/transforms/delete-columns.js +2 -1
  88. package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +45 -38
  89. package/dist/esm/ui/FloatingContextualMenu/index.js +4 -2
  90. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +3 -2
  91. package/dist/esm/ui/FloatingDragMenu/index.js +7 -2
  92. package/dist/esm/ui/FloatingInsertButton/index.js +5 -1
  93. package/dist/esm/utils/create.js +1 -1
  94. package/dist/esm/utils/drag-menu.js +4 -3
  95. package/dist/types/commands/column-resize.d.ts +1 -1
  96. package/dist/types/commands/delete.d.ts +1 -1
  97. package/dist/types/commands/insert.d.ts +3 -3
  98. package/dist/types/commands-with-analytics.d.ts +2 -2
  99. package/dist/types/event-handlers.d.ts +1 -1
  100. package/dist/types/nodeviews/TableComponent.d.ts +3 -0
  101. package/dist/types/nodeviews/TableContainer.d.ts +4 -2
  102. package/dist/types/nodeviews/TableResizer.d.ts +2 -1
  103. package/dist/types/nodeviews/table.d.ts +1 -0
  104. package/dist/types/pm-plugins/drag-and-drop/plugin.d.ts +3 -2
  105. package/dist/types/pm-plugins/keymap.d.ts +2 -2
  106. package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +2 -2
  107. package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +2 -0
  108. package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +2 -2
  109. package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +7 -0
  110. package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +1 -1
  111. package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -3
  112. package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
  113. package/dist/types/toolbar.d.ts +2 -2
  114. package/dist/types/transforms/column-width.d.ts +1 -1
  115. package/dist/types/transforms/delete-columns.d.ts +1 -1
  116. package/dist/types/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -1
  117. package/dist/types/ui/FloatingContextualMenu/index.d.ts +1 -1
  118. package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +2 -1
  119. package/dist/types/ui/FloatingDragMenu/index.d.ts +3 -2
  120. package/dist/types/ui/FloatingInsertButton/index.d.ts +2 -1
  121. package/dist/types/utils/drag-menu.d.ts +1 -1
  122. package/dist/types-ts4.5/commands/column-resize.d.ts +1 -1
  123. package/dist/types-ts4.5/commands/delete.d.ts +1 -1
  124. package/dist/types-ts4.5/commands/insert.d.ts +3 -3
  125. package/dist/types-ts4.5/commands-with-analytics.d.ts +2 -2
  126. package/dist/types-ts4.5/event-handlers.d.ts +1 -1
  127. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +3 -0
  128. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -2
  129. package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -1
  130. package/dist/types-ts4.5/nodeviews/table.d.ts +1 -0
  131. package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin.d.ts +3 -2
  132. package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -2
  133. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +2 -2
  134. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/consts.d.ts +2 -0
  135. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +2 -2
  136. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +7 -0
  137. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +1 -1
  138. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -3
  139. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
  140. package/dist/types-ts4.5/toolbar.d.ts +2 -2
  141. package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
  142. package/dist/types-ts4.5/transforms/delete-columns.d.ts +1 -1
  143. package/dist/types-ts4.5/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -1
  144. package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +1 -1
  145. package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +2 -1
  146. package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +3 -2
  147. package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +2 -1
  148. package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
  149. package/package.json +2 -2
  150. package/src/commands/column-resize.ts +3 -0
  151. package/src/commands/delete.ts +2 -1
  152. package/src/commands/insert.ts +15 -6
  153. package/src/commands-with-analytics.ts +9 -3
  154. package/src/event-handlers.ts +2 -0
  155. package/src/nodeviews/TableComponent.tsx +91 -5
  156. package/src/nodeviews/TableContainer.tsx +6 -0
  157. package/src/nodeviews/TableResizer.tsx +6 -0
  158. package/src/nodeviews/table.tsx +15 -10
  159. package/src/plugin.tsx +17 -5
  160. package/src/pm-plugins/drag-and-drop/plugin.ts +16 -8
  161. package/src/pm-plugins/keymap.ts +11 -3
  162. package/src/pm-plugins/main.ts +3 -0
  163. package/src/pm-plugins/table-resizing/event-handlers.ts +11 -1
  164. package/src/pm-plugins/table-resizing/utils/colgroup.ts +49 -17
  165. package/src/pm-plugins/table-resizing/utils/consts.ts +2 -0
  166. package/src/pm-plugins/table-resizing/utils/index.ts +8 -1
  167. package/src/pm-plugins/table-resizing/utils/misc.ts +25 -1
  168. package/src/pm-plugins/table-resizing/utils/resize-column.ts +2 -1
  169. package/src/pm-plugins/table-resizing/utils/resize-state.ts +56 -11
  170. package/src/pm-plugins/table-resizing/utils/scale-table.ts +24 -6
  171. package/src/toolbar.tsx +18 -5
  172. package/src/transforms/column-width.ts +33 -11
  173. package/src/transforms/delete-columns.ts +7 -2
  174. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +20 -5
  175. package/src/ui/FloatingContextualMenu/index.tsx +2 -0
  176. package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -0
  177. package/src/ui/FloatingDragMenu/index.tsx +9 -1
  178. package/src/ui/FloatingInsertButton/index.tsx +17 -5
  179. package/src/utils/create.ts +1 -3
  180. package/src/utils/drag-menu.ts +4 -1
@@ -9,7 +9,11 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
9
9
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
10
10
 
11
11
  import type { ResizeState } from '../pm-plugins/table-resizing/utils';
12
- import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils';
12
+ import {
13
+ getTableContainerElement,
14
+ getTableElementWidth,
15
+ hasTableBeenResized,
16
+ } from '../pm-plugins/table-resizing/utils';
13
17
  import { isMinCellWidthTable } from '../pm-plugins/table-resizing/utils/colgroup';
14
18
  import { getResizeState } from '../pm-plugins/table-resizing/utils/resize-state';
15
19
  import { scaleTableTo } from '../pm-plugins/table-resizing/utils/scale-table';
@@ -104,7 +108,7 @@ export const updateColumnWidths =
104
108
  * @returns Updated transaction with rescaled columns for a given table
105
109
  */
106
110
  export const rescaleColumns =
107
- () =>
111
+ (tablePreserveWidth = false) =>
108
112
  (table: ContentNodeWithPos, view: EditorView | undefined) =>
109
113
  (tr: Transaction): Transaction => {
110
114
  if (!view) {
@@ -121,18 +125,35 @@ export const rescaleColumns =
121
125
  }
122
126
 
123
127
  const isResized = hasTableBeenResized(table.node);
124
- // get current table info
125
- const previousTableInfo = {
126
- // when table is resized the tableRef client width will be 1px larger than colGroup, which is used in calculations
127
- width: isResized ? tableRef.clientWidth - 1 : tableRef.clientWidth,
128
- /** the is the width the table can reach before overflowing */
129
- possibleMaxWidth: getBooleanFF('platform.editor.custom-table-width')
130
- ? tableRef?.parentElement?.clientWidth || 0
131
- : (tableRef?.parentElement?.clientWidth || 0) -
132
- insertColumnButtonOffset,
128
+
129
+ let previousTableInfo = {
130
+ width: 0,
131
+ possibleMaxWidth: 0,
133
132
  isResized,
134
133
  };
135
134
 
135
+ if (tablePreserveWidth) {
136
+ previousTableInfo = {
137
+ // TODO - ensure correct width is returned when table doesn't have a width value
138
+ width: getTableElementWidth(table.node),
139
+ possibleMaxWidth: getBooleanFF('platform.editor.custom-table-width')
140
+ ? getTableContainerElement(table.node)
141
+ : getTableContainerElement(table.node) - insertColumnButtonOffset,
142
+ isResized,
143
+ };
144
+ } else {
145
+ previousTableInfo = {
146
+ // when table is resized the tableRef client width will be 1px larger than colGroup, which is used in calculations
147
+ width: isResized ? tableRef.clientWidth - 1 : tableRef.clientWidth,
148
+ /** the is the width the table can reach before overflowing */
149
+ possibleMaxWidth: getBooleanFF('platform.editor.custom-table-width')
150
+ ? tableRef?.parentElement?.clientWidth || 0
151
+ : (tableRef?.parentElement?.clientWidth || 0) -
152
+ insertColumnButtonOffset,
153
+ isResized,
154
+ };
155
+ }
156
+
136
157
  // determine the new table, based on new width
137
158
  const newTableInfo = {
138
159
  noOfColumns: TableMap.get(newTable).width,
@@ -195,6 +216,7 @@ export const rescaleColumns =
195
216
  tableRef,
196
217
  domAtPos,
197
218
  maxSize: previousTableInfo.possibleMaxWidth,
219
+ tablePreserveWidth,
198
220
  });
199
221
 
200
222
  // Two scenarios that require scaling:
@@ -249,7 +249,12 @@ function fixRowSpans(table: PMNode): PMNode | null {
249
249
  }
250
250
 
251
251
  export const deleteColumns =
252
- (rect: Rect, allowCustomStep: boolean, view?: EditorView) =>
252
+ (
253
+ rect: Rect,
254
+ allowCustomStep: boolean,
255
+ view?: EditorView,
256
+ tablePreserveWidth = false,
257
+ ) =>
253
258
  (tr: Transaction) => {
254
259
  let updatedTr = tr;
255
260
  updatedTr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
@@ -264,7 +269,7 @@ export const deleteColumns =
264
269
  const table = findTable(updatedTr.selection);
265
270
 
266
271
  if (table) {
267
- updatedTr = rescaleColumns()(table, view)(updatedTr);
272
+ updatedTr = rescaleColumns(tablePreserveWidth)(table, view)(updatedTr);
268
273
  }
269
274
  return updatedTr;
270
275
  };
@@ -23,7 +23,10 @@ import {
23
23
  } from '@atlaskit/editor-common/keymaps';
24
24
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
25
25
  import { DropdownMenuSharedCssClassName } from '@atlaskit/editor-common/styles';
26
- import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
26
+ import type {
27
+ GetEditorContainerWidth,
28
+ GetEditorFeatureFlags,
29
+ } from '@atlaskit/editor-common/types';
27
30
  import {
28
31
  backgroundPaletteTooltipMessages,
29
32
  cellBackgroundColorPalette,
@@ -99,6 +102,7 @@ export interface Props {
99
102
  offset?: Array<number>;
100
103
  editorAnalyticsAPI?: EditorAnalyticsAPI;
101
104
  getEditorContainerWidth: GetEditorContainerWidth;
105
+ getEditorFeatureFlags?: GetEditorFeatureFlags;
102
106
  }
103
107
 
104
108
  export interface State {
@@ -464,11 +468,14 @@ export class ContextualMenu extends Component<
464
468
  (!isDragAndDropEnabled ||
465
469
  !getBooleanFF('platform.editor.table.new-cell-context-menu-styling'))
466
470
  ) {
471
+ const { tablePreserveWidth = false } =
472
+ this.props.getEditorFeatureFlags?.() || {};
467
473
  const newResizeState = getNewResizeStateFromSelectedColumns(
468
474
  selectionRect,
469
475
  editorView.state,
470
476
  editorView.domAtPos.bind(editorView),
471
477
  getEditorContainerWidth,
478
+ tablePreserveWidth,
472
479
  );
473
480
 
474
481
  const wouldChange = newResizeState?.changed ?? false;
@@ -583,10 +590,12 @@ export class ContextualMenu extends Component<
583
590
  selectionRect,
584
591
  editorAnalyticsAPI,
585
592
  getEditorContainerWidth,
593
+ getEditorFeatureFlags,
586
594
  } = this.props;
587
595
  // TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
588
596
  const { state, dispatch } = editorView;
589
597
  const { targetCellPosition } = getPluginState(state);
598
+ const { tablePreserveWidth = false } = getEditorFeatureFlags?.() || {};
590
599
 
591
600
  switch (item.value.name) {
592
601
  case 'sort_column_desc':
@@ -626,6 +635,7 @@ export class ContextualMenu extends Component<
626
635
  state,
627
636
  editorView.domAtPos.bind(editorView),
628
637
  getEditorContainerWidth,
638
+ tablePreserveWidth,
629
639
  );
630
640
 
631
641
  if (newResizeStateWithAnalytics) {
@@ -644,10 +654,15 @@ export class ContextualMenu extends Component<
644
654
  this.toggleOpen();
645
655
  break;
646
656
  case 'insert_column':
647
- insertColumnWithAnalytics(getEditorContainerWidth, editorAnalyticsAPI)(
648
- INPUT_METHOD.CONTEXT_MENU,
649
- selectionRect.right,
650
- )(state, dispatch, editorView);
657
+ insertColumnWithAnalytics(
658
+ getEditorContainerWidth,
659
+ editorAnalyticsAPI,
660
+ tablePreserveWidth,
661
+ )(INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(
662
+ state,
663
+ dispatch,
664
+ editorView,
665
+ );
651
666
  this.toggleOpen();
652
667
  break;
653
668
  case 'insert_row':
@@ -53,6 +53,7 @@ const FloatingContextualMenu = ({
53
53
  pluginConfig,
54
54
  editorAnalyticsAPI,
55
55
  getEditorContainerWidth,
56
+ getEditorFeatureFlags,
56
57
  }: Props) => {
57
58
  // TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
58
59
  const { targetCellPosition, isDragAndDropEnabled } = getPluginState(
@@ -122,6 +123,7 @@ const FloatingContextualMenu = ({
122
123
  boundariesElement={boundariesElement}
123
124
  editorAnalyticsAPI={editorAnalyticsAPI}
124
125
  getEditorContainerWidth={getEditorContainerWidth}
126
+ getEditorFeatureFlags={getEditorFeatureFlags}
125
127
  />
126
128
  </div>
127
129
  </Popup>
@@ -101,6 +101,7 @@ type DragMenuProps = {
101
101
  mountPoint?: HTMLElement;
102
102
  boundariesElement?: HTMLElement;
103
103
  scrollableElement?: HTMLElement;
104
+ tablePreserveWidth?: boolean;
104
105
  };
105
106
 
106
107
  type PluralOptionType = 'noOfCols' | 'noOfRows' | 'noOfCells' | null;
@@ -279,6 +280,7 @@ export const DragMenu = React.memo(
279
280
  mountPoint,
280
281
  scrollableElement,
281
282
  boundariesElement,
283
+ tablePreserveWidth,
282
284
  }: DragMenuProps & WrappedComponentProps) => {
283
285
  const { state, dispatch } = editorView;
284
286
  const { selection } = state;
@@ -311,6 +313,7 @@ export const DragMenu = React.memo(
311
313
  selectionRect,
312
314
  editorAnalyticsAPI,
313
315
  pluginConfig?.isHeaderRowRequired,
316
+ tablePreserveWidth,
314
317
  );
315
318
 
316
319
  const { menuItems, menuCallback } = convertToDropdownItems(
@@ -1,7 +1,10 @@
1
1
  import React from 'react';
2
2
 
3
3
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
- import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
4
+ import type {
5
+ GetEditorContainerWidth,
6
+ GetEditorFeatureFlags,
7
+ } from '@atlaskit/editor-common/types';
5
8
  import { Popup } from '@atlaskit/editor-common/ui';
6
9
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
7
10
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -32,6 +35,7 @@ export interface Props {
32
35
  editorAnalyticsAPI?: EditorAnalyticsAPI;
33
36
  stickyHeaders?: RowStickyState;
34
37
  pluginConfig?: PluginConfig;
38
+ getEditorFeatureFlags: GetEditorFeatureFlags;
35
39
  }
36
40
 
37
41
  const FloatingDragMenu = ({
@@ -48,6 +52,7 @@ const FloatingDragMenu = ({
48
52
  editorAnalyticsAPI,
49
53
  stickyHeaders,
50
54
  pluginConfig,
55
+ getEditorFeatureFlags,
51
56
  }: Props) => {
52
57
  if (
53
58
  !isOpen ||
@@ -72,6 +77,8 @@ const FloatingDragMenu = ({
72
77
  return null;
73
78
  }
74
79
 
80
+ const { tablePreserveWidth = false } = getEditorFeatureFlags();
81
+
75
82
  return (
76
83
  <Popup
77
84
  alignX={direction === 'row' ? 'right' : undefined}
@@ -110,6 +117,7 @@ const FloatingDragMenu = ({
110
117
  mountPoint={mountPoint}
111
118
  boundariesElement={boundariesElement}
112
119
  scrollableElement={scrollableElement}
120
+ tablePreserveWidth={tablePreserveWidth}
113
121
  />
114
122
  </Popup>
115
123
  );
@@ -15,7 +15,10 @@ import {
15
15
  EVENT_TYPE,
16
16
  INPUT_METHOD,
17
17
  } from '@atlaskit/editor-common/analytics';
18
- import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
18
+ import type {
19
+ GetEditorContainerWidth,
20
+ GetEditorFeatureFlags,
21
+ } from '@atlaskit/editor-common/types';
19
22
  import { Popup } from '@atlaskit/editor-common/ui';
20
23
  import { closestElement } from '@atlaskit/editor-common/utils';
21
24
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
@@ -52,6 +55,7 @@ export interface Props {
52
55
  hasStickyHeaders?: boolean;
53
56
  dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
54
57
  editorAnalyticsAPI?: EditorAnalyticsAPI;
58
+ getEditorFeatureFlags?: GetEditorFeatureFlags;
55
59
  }
56
60
 
57
61
  export class FloatingInsertButton extends React.Component<
@@ -284,11 +288,19 @@ export class FloatingInsertButton extends React.Component<
284
288
  if (typeof insertColumnButtonIndex !== 'undefined') {
285
289
  event.preventDefault();
286
290
 
291
+ const { tablePreserveWidth = false } =
292
+ this.props.getEditorFeatureFlags?.() || {};
293
+
287
294
  const { state, dispatch } = editorView;
288
- insertColumnWithAnalytics(getEditorContainerWidth, editorAnalyticsAPI)(
289
- INPUT_METHOD.BUTTON,
290
- insertColumnButtonIndex,
291
- )(state, dispatch, editorView);
295
+ insertColumnWithAnalytics(
296
+ getEditorContainerWidth,
297
+ editorAnalyticsAPI,
298
+ tablePreserveWidth,
299
+ )(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(
300
+ state,
301
+ dispatch,
302
+ editorView,
303
+ );
292
304
  }
293
305
  }
294
306
  }
@@ -14,9 +14,7 @@ export const createTableWithWidth =
14
14
  },
15
15
  ) =>
16
16
  (schema: Schema) => {
17
- const { tablePreserveWidth = false } = getEditorFeatureFlags
18
- ? getEditorFeatureFlags()
19
- : {};
17
+ const { tablePreserveWidth = false } = getEditorFeatureFlags?.() || {};
20
18
 
21
19
  if (tablePreserveWidth && isFullWidthModeEnabled) {
22
20
  return createTable({
@@ -159,6 +159,7 @@ export const getDragMenuConfig = (
159
159
  selectionRect?: Rect,
160
160
  editorAnalyticsAPI?: EditorAnalyticsAPI,
161
161
  isHeaderRowRequired?: boolean,
162
+ tablePreserveWidth = false,
162
163
  ): DragMenuConfig[] => {
163
164
  const addOptions =
164
165
  direction === 'row'
@@ -296,6 +297,7 @@ export const getDragMenuConfig = (
296
297
  insertColumnWithAnalytics(
297
298
  getEditorContainerWidth,
298
299
  editorAnalyticsAPI,
300
+ tablePreserveWidth,
299
301
  )(INPUT_METHOD.TABLE_CONTEXT_MENU, (index ?? 0) + offset)(
300
302
  state,
301
303
  dispatch,
@@ -319,6 +321,7 @@ export const getDragMenuConfig = (
319
321
  state,
320
322
  editorView.domAtPos.bind(editorView),
321
323
  getEditorContainerWidth,
324
+ tablePreserveWidth,
322
325
  );
323
326
 
324
327
  if (newResizeState) {
@@ -359,7 +362,7 @@ export const getDragMenuConfig = (
359
362
  !!isHeaderRowRequired,
360
363
  )(state, dispatch);
361
364
  } else {
362
- deleteColumnsWithAnalytics(editorAnalyticsAPI)(
365
+ deleteColumnsWithAnalytics(editorAnalyticsAPI, tablePreserveWidth)(
363
366
  INPUT_METHOD.TABLE_CONTEXT_MENU,
364
367
  selectionRect ?? defaultSelectionRect,
365
368
  )(state, dispatch, editorView);