@atlaskit/editor-plugin-table 7.11.2 → 7.11.4

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 (78) hide show
  1. package/CHANGELOG.md +1731 -699
  2. package/dist/cjs/commands/column-resize.js +5 -1
  3. package/dist/cjs/nodeviews/TableComponent.js +31 -6
  4. package/dist/cjs/nodeviews/table.js +31 -14
  5. package/dist/cjs/plugin.js +8 -9
  6. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +6 -1
  7. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +16 -10
  8. package/dist/cjs/pm-plugins/table-resizing/plugin.js +2 -2
  9. package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +7 -2
  10. package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +16 -11
  11. package/dist/cjs/pm-plugins/table-width.js +1 -5
  12. package/dist/cjs/pm-plugins/view-mode-sort/utils.js +37 -20
  13. package/dist/cjs/toolbar.js +12 -21
  14. package/dist/cjs/transforms/column-width.js +3 -0
  15. package/dist/cjs/ui/FloatingDragMenu/index.js +2 -5
  16. package/dist/cjs/ui/common-styles.js +8 -16
  17. package/dist/cjs/ui/ui-styles.js +18 -36
  18. package/dist/es2019/commands/column-resize.js +6 -2
  19. package/dist/es2019/nodeviews/TableComponent.js +33 -7
  20. package/dist/es2019/nodeviews/table.js +32 -15
  21. package/dist/es2019/plugin.js +8 -9
  22. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +6 -1
  23. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +13 -7
  24. package/dist/es2019/pm-plugins/table-resizing/plugin.js +2 -2
  25. package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +7 -2
  26. package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +16 -11
  27. package/dist/es2019/pm-plugins/table-width.js +1 -5
  28. package/dist/es2019/pm-plugins/view-mode-sort/utils.js +36 -21
  29. package/dist/es2019/toolbar.js +7 -16
  30. package/dist/es2019/transforms/column-width.js +4 -1
  31. package/dist/es2019/ui/FloatingDragMenu/index.js +2 -5
  32. package/dist/es2019/ui/common-styles.js +18 -30
  33. package/dist/es2019/ui/ui-styles.js +88 -174
  34. package/dist/esm/commands/column-resize.js +5 -1
  35. package/dist/esm/nodeviews/TableComponent.js +31 -6
  36. package/dist/esm/nodeviews/table.js +31 -14
  37. package/dist/esm/plugin.js +8 -9
  38. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +6 -1
  39. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +16 -10
  40. package/dist/esm/pm-plugins/table-resizing/plugin.js +2 -2
  41. package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +7 -2
  42. package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +16 -11
  43. package/dist/esm/pm-plugins/table-width.js +1 -5
  44. package/dist/esm/pm-plugins/view-mode-sort/utils.js +37 -20
  45. package/dist/esm/toolbar.js +12 -21
  46. package/dist/esm/transforms/column-width.js +3 -0
  47. package/dist/esm/ui/FloatingDragMenu/index.js +2 -5
  48. package/dist/esm/ui/common-styles.js +8 -16
  49. package/dist/esm/ui/ui-styles.js +18 -36
  50. package/dist/types/pm-plugins/table-resizing/event-handlers.d.ts +1 -1
  51. package/dist/types/pm-plugins/table-resizing/plugin.d.ts +1 -1
  52. package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -3
  53. package/dist/types/pm-plugins/table-width.d.ts +1 -1
  54. package/dist/types/pm-plugins/view-mode-sort/utils.d.ts +3 -1
  55. package/dist/types/ui/FloatingDragMenu/index.d.ts +2 -1
  56. package/dist/types-ts4.5/pm-plugins/table-resizing/event-handlers.d.ts +1 -1
  57. package/dist/types-ts4.5/pm-plugins/table-resizing/plugin.d.ts +1 -1
  58. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -3
  59. package/dist/types-ts4.5/pm-plugins/table-width.d.ts +1 -1
  60. package/dist/types-ts4.5/pm-plugins/view-mode-sort/utils.d.ts +3 -1
  61. package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +2 -1
  62. package/package.json +3 -6
  63. package/src/commands/column-resize.ts +11 -2
  64. package/src/nodeviews/TableComponent.tsx +79 -9
  65. package/src/nodeviews/table.tsx +49 -26
  66. package/src/plugin.tsx +10 -4
  67. package/src/pm-plugins/drag-and-drop/plugin.ts +14 -1
  68. package/src/pm-plugins/table-resizing/event-handlers.ts +26 -4
  69. package/src/pm-plugins/table-resizing/plugin.ts +2 -0
  70. package/src/pm-plugins/table-resizing/utils/resize-state.ts +13 -2
  71. package/src/pm-plugins/table-resizing/utils/scale-table.ts +24 -10
  72. package/src/pm-plugins/table-width.ts +1 -3
  73. package/src/pm-plugins/view-mode-sort/utils.ts +49 -23
  74. package/src/toolbar.tsx +7 -11
  75. package/src/transforms/column-width.ts +8 -1
  76. package/src/ui/FloatingDragMenu/index.tsx +2 -3
  77. package/src/ui/common-styles.ts +18 -30
  78. package/src/ui/ui-styles.ts +92 -183
@@ -223,7 +223,18 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
223
223
  }
224
224
  }
225
225
 
226
- if (isTableScalingEnabled) {
226
+ if (
227
+ isTableScalingEnabled &&
228
+ !getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
229
+ ) {
230
+ this.handleColgroupUpdates(true);
231
+ }
232
+
233
+ if (
234
+ isTableScalingEnabled &&
235
+ getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') &&
236
+ getNode().attrs.displayMode !== 'fixed'
237
+ ) {
227
238
  this.handleColgroupUpdates(true);
228
239
  }
229
240
 
@@ -382,12 +393,17 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
382
393
  const wasTableResized = hasTableBeenResized(this.node);
383
394
  const isTableResized = hasTableBeenResized(tableNode);
384
395
  const isColumnsDistributed = wasTableResized && !isTableResized;
385
- const shouldScale =
396
+ const isTableDisplayModeChanged =
397
+ this.node.attrs.displayMode !== tableNode.attrs.displayMode;
398
+
399
+ const shouldUpdateColgroup =
386
400
  isWidthChanged ||
387
401
  isColumnsDistributed ||
388
402
  isTableResizedFullWidth ||
389
- isTableWidthChanged;
390
- if (force || (!isResizing && shouldScale)) {
403
+ isTableWidthChanged ||
404
+ isTableDisplayModeChanged;
405
+
406
+ if (force || (!isResizing && shouldUpdateColgroup)) {
391
407
  const resizeState = getResizeState({
392
408
  minWidth: COLUMN_MIN_WIDTH,
393
409
  maxSize: tableRenderWidth,
@@ -398,9 +414,34 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
398
414
  isTableScalingEnabled: true,
399
415
  });
400
416
 
417
+ let shouldScaleOnColgroupUpdate = false;
418
+ if (
419
+ this.props.options?.isTableScalingEnabled &&
420
+ !getBooleanFF(
421
+ 'platform.editor.table.preserve-widths-with-lock-button',
422
+ )
423
+ ) {
424
+ shouldScaleOnColgroupUpdate = true;
425
+ }
426
+
427
+ if (
428
+ this.props.options?.isTableScalingEnabled &&
429
+ getBooleanFF(
430
+ 'platform.editor.table.preserve-widths-with-lock-button',
431
+ ) &&
432
+ tableNode.attrs.displayMode !== 'fixed'
433
+ ) {
434
+ shouldScaleOnColgroupUpdate = true;
435
+ }
436
+
401
437
  // Request animation frame required for Firefox
402
438
  requestAnimationFrame(() => {
403
- updateColgroup(resizeState, this.table!, tableNode, true);
439
+ updateColgroup(
440
+ resizeState,
441
+ this.table!,
442
+ tableNode,
443
+ shouldScaleOnColgroupUpdate,
444
+ );
404
445
  });
405
446
  }
406
447
  }
@@ -417,7 +458,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
417
458
  allowColumnResizing,
418
459
  isResizing,
419
460
  options,
420
- isTableScalingEnabled,
461
+ isTableScalingEnabled, // we could use options.isTableScalingEnabled here
421
462
  getPos,
422
463
  } = this.props;
423
464
  let { isInDanger } = this.props;
@@ -429,7 +470,35 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
429
470
  isInDanger = pluginState.isInDanger;
430
471
  }
431
472
 
432
- if (isTableScalingEnabled) {
473
+ let shouldScale = false;
474
+ let shouldHandleColgroupUpdates = false;
475
+
476
+ if (
477
+ isTableScalingEnabled &&
478
+ !getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
479
+ ) {
480
+ shouldScale = true;
481
+ shouldHandleColgroupUpdates = true;
482
+ }
483
+
484
+ if (
485
+ isTableScalingEnabled &&
486
+ getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') &&
487
+ getNode().attrs.displayMode !== 'fixed'
488
+ ) {
489
+ shouldScale = true;
490
+ shouldHandleColgroupUpdates = true;
491
+ }
492
+
493
+ if (
494
+ isTableScalingEnabled &&
495
+ getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') &&
496
+ getNode().attrs.displayMode !== this.node.attrs.displayMode
497
+ ) {
498
+ shouldHandleColgroupUpdates = true;
499
+ }
500
+
501
+ if (shouldHandleColgroupUpdates) {
433
502
  this.handleColgroupUpdates();
434
503
  }
435
504
 
@@ -506,7 +575,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
506
575
  if (shouldRecreateResizeCols) {
507
576
  const start = getPos() || 0;
508
577
  const depth = view.state.doc.resolve(start).depth;
509
- const shouldScale = depth === 0 && isTableScalingEnabled;
578
+ shouldScale = depth === 0 && shouldScale;
579
+
510
580
  insertColgroupFromNode(this.table, currentTable, shouldScale);
511
581
  }
512
582
 
@@ -610,7 +680,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
610
680
  pluginInjectionApi,
611
681
  isDragAndDropEnabled,
612
682
  getEditorFeatureFlags,
613
- isTableScalingEnabled,
683
+ isTableScalingEnabled, // here we can use options.isTableScalingEnabled
614
684
  } = this.props;
615
685
 
616
686
  let {
@@ -136,16 +136,37 @@ export default class TableView extends ReactNodeView<Props> {
136
136
 
137
137
  if (rendered.dom) {
138
138
  this.table = rendered.dom;
139
- // Preserve Table Width cannot have inline width set on the table
140
- if (!this.options?.isTableScalingEnabled) {
141
- const tableInlineWidth = getInlineWidth(
142
- this.node,
143
- this.reactComponentProps.options,
144
- this.reactComponentProps.view.state,
145
- this.reactComponentProps.getPos(),
146
- );
147
- if (tableInlineWidth) {
148
- handleInlineTableWidth(this.table, tableInlineWidth);
139
+
140
+ if (
141
+ !getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
142
+ ) {
143
+ if (!this.options?.isTableScalingEnabled) {
144
+ // Preserve Table Width cannot have inline width set on the table
145
+ const tableInlineWidth = getInlineWidth(
146
+ this.node,
147
+ this.reactComponentProps.options,
148
+ this.reactComponentProps.view.state,
149
+ this.reactComponentProps.getPos(),
150
+ );
151
+ if (tableInlineWidth) {
152
+ handleInlineTableWidth(this.table, tableInlineWidth);
153
+ }
154
+ }
155
+ } else {
156
+ if (
157
+ !this.options?.isTableScalingEnabled ||
158
+ this.node.attrs.displayMode === 'fixed'
159
+ ) {
160
+ // Preserve Table Width cannot have inline width set on the table
161
+ const tableInlineWidth = getInlineWidth(
162
+ this.node,
163
+ this.reactComponentProps.options,
164
+ this.reactComponentProps.view.state,
165
+ this.reactComponentProps.getPos(),
166
+ );
167
+ if (tableInlineWidth) {
168
+ handleInlineTableWidth(this.table, tableInlineWidth);
169
+ }
149
170
  }
150
171
  }
151
172
  }
@@ -157,26 +178,28 @@ export default class TableView extends ReactNodeView<Props> {
157
178
  if (!this.table) {
158
179
  return;
159
180
  }
160
-
161
181
  const attrs = tableAttributes(node);
162
182
  (Object.keys(attrs) as Array<keyof typeof attrs>).forEach((attr) => {
163
183
  this.table!.setAttribute(attr, attrs[attr]);
164
184
  });
165
185
 
166
- // handle inline style when table been resized
167
- const tableInlineWidth = getInlineWidth(
168
- node,
169
- (this.reactComponentProps as Props).options,
170
- this.view.state,
171
- this.getPos(),
172
- );
186
+ // Preserve Table Width cannot have inline width set on the table
187
+ if (!this.options?.isTableScalingEnabled) {
188
+ // handle inline style when table been resized
189
+ const tableInlineWidth = getInlineWidth(
190
+ node,
191
+ (this.reactComponentProps as Props).options,
192
+ this.view.state,
193
+ this.getPos(),
194
+ );
173
195
 
174
- const isTableResizing = tableWidthPluginKey.getState(
175
- this.view.state,
176
- )?.resizing;
196
+ const isTableResizing = tableWidthPluginKey.getState(
197
+ this.view.state,
198
+ )?.resizing;
177
199
 
178
- if (!isTableResizing && tableInlineWidth) {
179
- handleInlineTableWidth(this.table, tableInlineWidth);
200
+ if (!isTableResizing && tableInlineWidth) {
201
+ handleInlineTableWidth(this.table, tableInlineWidth);
202
+ }
180
203
  }
181
204
  }
182
205
 
@@ -275,7 +298,7 @@ export default class TableView extends ReactNodeView<Props> {
275
298
  isHeaderRowEnabled={pluginState!.isHeaderRowEnabled}
276
299
  isHeaderColumnEnabled={pluginState!.isHeaderColumnEnabled}
277
300
  isDragAndDropEnabled={pluginState!.isDragAndDropEnabled}
278
- isTableScalingEnabled={pluginState!.isTableScalingEnabled}
301
+ isTableScalingEnabled={props.options?.isTableScalingEnabled} // this.options?.isTableScalingEnabled sams as TableOptions.isTableScalingEnabled same as pluginState.isTableScalingEnabled
279
302
  tableActive={tableActive}
280
303
  ordering={pluginState!.ordering as TableColumnOrdering}
281
304
  isResizing={isResizing}
@@ -381,7 +404,7 @@ export const createTableView = (
381
404
  wasFullWidthModeEnabled,
382
405
  isTableResizingEnabled,
383
406
  isDragAndDropEnabled,
384
- isTableScalingEnabled,
407
+ isTableScalingEnabled, // same as options.isTableScalingEnabled
385
408
  } = getPluginState(view.state);
386
409
  const { allowColumnResizing, allowControls } = getPluginConfig(pluginConfig);
387
410
  const hasIntlContext = true;
@@ -399,7 +422,7 @@ export const createTableView = (
399
422
  wasFullWidthModeEnabled,
400
423
  isTableResizingEnabled,
401
424
  isDragAndDropEnabled,
402
- isTableScalingEnabled,
425
+ isTableScalingEnabled, // same as options.isTableScalingEnabled
403
426
  },
404
427
  getEditorContainerWidth,
405
428
  getEditorFeatureFlags,
package/src/plugin.tsx CHANGED
@@ -287,8 +287,12 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
287
287
  {
288
288
  name: 'tablePMColResizing',
289
289
  plugin: ({ dispatch }) => {
290
- const { fullWidthEnabled, tableOptions, getEditorFeatureFlags } =
291
- options || ({} as TablePluginOptions);
290
+ const {
291
+ fullWidthEnabled,
292
+ tableOptions,
293
+ getEditorFeatureFlags,
294
+ isTableScalingEnabled,
295
+ } = options || ({} as TablePluginOptions);
292
296
  const { allowColumnResizing } = pluginConfig(tableOptions);
293
297
  return allowColumnResizing
294
298
  ? createFlexiResizingPlugin(
@@ -299,6 +303,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
299
303
  defaultGetEditorContainerWidth,
300
304
  getEditorFeatureFlags || defaultGetEditorFeatureFlags,
301
305
  editorAnalyticsAPI,
306
+ isTableScalingEnabled || false,
302
307
  )
303
308
  : undefined;
304
309
  },
@@ -394,6 +399,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
394
399
  dispatch,
395
400
  dispatchAnalyticsEvent,
396
401
  options?.fullWidthEnabled ?? false,
402
+ options?.isTableScalingEnabled ?? false,
397
403
  )
398
404
  : undefined,
399
405
  },
@@ -569,6 +575,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
569
575
  editorAnalyticsAPI={editorAnalyticsAPI}
570
576
  stickyHeaders={stickyHeader}
571
577
  pluginConfig={pluginConfig}
578
+ isTableScalingEnabled={options?.isTableScalingEnabled}
572
579
  />
573
580
  )}
574
581
  {allowControls && !isDragAndDropEnabled && !isResizing && (
@@ -607,11 +614,10 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
607
614
  action(insert, state) {
608
615
  // see comment on tablesPlugin.getSharedState on usage
609
616
  const tableState = api?.table?.sharedState.currentState();
610
- const { isTableScalingEnabled = false } = getPluginState(state);
611
617
 
612
618
  const tr = insert(
613
619
  createTableWithWidth(
614
- isTableScalingEnabled,
620
+ options?.isTableScalingEnabled,
615
621
  tableState?.isFullWidthModeEnabled,
616
622
  )(state.schema),
617
623
  );
@@ -9,6 +9,7 @@ import {
9
9
  getCellsInRow,
10
10
  getSelectedCellInfo,
11
11
  } from '@atlaskit/editor-tables/utils';
12
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
12
13
  import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
13
14
  import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
14
15
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
@@ -235,10 +236,22 @@ const destroyFn = (editorView: EditorView, editorAnalyticsAPI: any) => {
235
236
  const { isTableScalingEnabled = false } = getTablePluginState(
236
237
  editorView.state,
237
238
  );
239
+
240
+ let isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
241
+ if (
242
+ isTableScalingEnabled &&
243
+ getBooleanFF(
244
+ 'platform.editor.table.preserve-widths-with-lock-button',
245
+ )
246
+ ) {
247
+ isTableScalingEnabledOnCurrentTable =
248
+ tableNode.attrs.displayMode !== 'fixed';
249
+ }
250
+
238
251
  insertColgroupFromNode(
239
252
  tableRef,
240
253
  tableNode,
241
- isTableScalingEnabled,
254
+ isTableScalingEnabledOnCurrentTable,
242
255
  );
243
256
  }
244
257
  }
@@ -41,12 +41,12 @@ export const handleMouseDown = (
41
41
  localResizeHandlePos: number,
42
42
  getEditorContainerWidth: GetEditorContainerWidth,
43
43
  getEditorFeatureFlags: GetEditorFeatureFlags,
44
+ isTableScalingEnabled: boolean,
44
45
  editorAnalyticsAPI?: EditorAnalyticsAPI,
45
46
  ): boolean => {
46
47
  const { state, dispatch } = view;
47
48
  const editorDisabled = !view.editable;
48
49
  const domAtPos = view.domAtPos.bind(view);
49
- const { isTableScalingEnabled = false } = getTablePluginState(state);
50
50
 
51
51
  if (
52
52
  editorDisabled ||
@@ -85,7 +85,14 @@ export const handleMouseDown = (
85
85
  getEditorContainerWidth,
86
86
  });
87
87
 
88
- const shouldScale = tableDepth === 0 && isTableScalingEnabled;
88
+ let shouldScale = tableDepth === 0 && isTableScalingEnabled;
89
+ if (
90
+ isTableScalingEnabled &&
91
+ getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
92
+ ) {
93
+ shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
94
+ }
95
+
89
96
  const resizeState = getResizeState({
90
97
  minWidth: tableCellMinWidth,
91
98
  maxSize,
@@ -181,7 +188,15 @@ export const handleMouseDown = (
181
188
  selectedColumns.indexOf(colIndex) > -1 ||
182
189
  selectedColumns.indexOf(colIndex + 1) > -1;
183
190
 
184
- const shouldScale = tableDepth === 0 && isTableScalingEnabled;
191
+ let shouldScale = tableDepth === 0 && isTableScalingEnabled;
192
+ if (
193
+ isTableScalingEnabled &&
194
+ getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
195
+ ) {
196
+ shouldScale =
197
+ shouldScale && originalTable.attrs.displayMode !== 'fixed';
198
+ }
199
+
185
200
  const newResizeState = resizeColumn(
186
201
  resizeState,
187
202
  colIndex,
@@ -277,7 +292,14 @@ export const handleMouseDown = (
277
292
  $cell.nodeAfter!.attrs.colspan -
278
293
  1;
279
294
 
280
- const shouldScale = tableDepth === 0 && isTableScalingEnabled;
295
+ let shouldScale = tableDepth === 0 && isTableScalingEnabled;
296
+ if (
297
+ isTableScalingEnabled &&
298
+ getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
299
+ ) {
300
+ shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
301
+ }
302
+
281
303
  resizeColumn(
282
304
  resizeState,
283
305
  colIndex,
@@ -25,6 +25,7 @@ export function createPlugin(
25
25
  getEditorContainerWidth: GetEditorContainerWidth,
26
26
  getEditorFeatureFlags: GetEditorFeatureFlags,
27
27
  editorAnalyticsAPI?: EditorAnalyticsAPI,
28
+ isTableScalingEnabled?: boolean,
28
29
  ) {
29
30
  return new SafePlugin({
30
31
  key: pluginKey,
@@ -79,6 +80,7 @@ export function createPlugin(
79
80
  resizeHandlePos,
80
81
  getEditorContainerWidth,
81
82
  getEditorFeatureFlags,
83
+ isTableScalingEnabled || false,
82
84
  editorAnalyticsAPI,
83
85
  )
84
86
  ) {
@@ -384,14 +384,25 @@ export const getNewResizeStateFromSelectedColumns = (
384
384
  getEditorContainerWidth,
385
385
  });
386
386
 
387
- const resizeState = getResizeState({
387
+ let resizeState;
388
+
389
+ let isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
390
+ if (
391
+ isTableScalingEnabled &&
392
+ getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
393
+ ) {
394
+ isTableScalingEnabledOnCurrentTable =
395
+ table.node.attrs.displayMode !== 'fixed';
396
+ }
397
+
398
+ resizeState = getResizeState({
388
399
  minWidth: tableCellMinWidth,
389
400
  maxSize,
390
401
  table: table.node,
391
402
  tableRef,
392
403
  start: table.start,
393
404
  domAtPos,
394
- isTableScalingEnabled,
405
+ isTableScalingEnabled: isTableScalingEnabledOnCurrentTable,
395
406
  });
396
407
 
397
408
  const newResizeState = evenSelectedColumnsWidths(resizeState, rect);
@@ -4,6 +4,7 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
5
5
  import type { DomAtPos } from '@atlaskit/editor-prosemirror/utils';
6
6
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
7
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
8
 
8
9
  import { updateColumnWidths } from '../../../transforms';
9
10
  import { getTableWidth } from '../../../utils';
@@ -38,7 +39,7 @@ export const scale = (
38
39
  tableRef: HTMLTableElement,
39
40
  options: ScaleOptions,
40
41
  domAtPos: DomAtPos,
41
- isTableScalingEnabled = false,
42
+ isTableScalingEnabledOnCurrentTable = false,
42
43
  ): ResizeState | undefined => {
43
44
  const {
44
45
  node,
@@ -87,7 +88,7 @@ export const scale = (
87
88
  tableRef,
88
89
  start,
89
90
  domAtPos,
90
- isTableScalingEnabled,
91
+ isTableScalingEnabled: isTableScalingEnabledOnCurrentTable,
91
92
  });
92
93
 
93
94
  return scaleTableTo(resizeState, newWidth);
@@ -99,7 +100,7 @@ export const scaleWithParent = (
99
100
  table: PMNode,
100
101
  start: number,
101
102
  domAtPos: DomAtPos,
102
- isTableScalingEnabled = false,
103
+ isTableScalingEnabledOnCurrentTable = false,
103
104
  ) => {
104
105
  const resizeState = getResizeState({
105
106
  minWidth: tableCellMinWidth,
@@ -108,7 +109,7 @@ export const scaleWithParent = (
108
109
  tableRef,
109
110
  start,
110
111
  domAtPos,
111
- isTableScalingEnabled,
112
+ isTableScalingEnabled: isTableScalingEnabledOnCurrentTable,
112
113
  });
113
114
 
114
115
  if (table.attrs.isNumberColumnEnabled) {
@@ -163,15 +164,23 @@ export const previewScaleTable = (
163
164
  tableRef.style.width = `${width}px`;
164
165
  }
165
166
 
167
+ let isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
168
+ if (
169
+ isTableScalingEnabled &&
170
+ getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
171
+ ) {
172
+ isTableScalingEnabledOnCurrentTable =
173
+ isTableScalingEnabled && node.attrs.displayMode !== 'fixed';
174
+ }
166
175
  // If the table hasn't been resize, the colgroup 48px width values will gracefully scale down.
167
176
  // If we are scaling the table down with isTableScalingEnabled, the colgroup widths may be scaled to a value that is not 48px.
168
- if (!hasTableBeenResized(node) && !isTableScalingEnabled) {
177
+ if (!hasTableBeenResized(node) && !isTableScalingEnabledOnCurrentTable) {
169
178
  syncStickyRowToTable(tableRef);
170
179
  return;
171
180
  }
172
181
 
173
182
  const resizeState = parentWidth
174
- ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos, false)
183
+ ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos, false) // Here last value is isTableScalingEnabled = false
175
184
  : scale(tableRef, options, domAtPos, false);
176
185
 
177
186
  if (resizeState) {
@@ -185,7 +194,7 @@ export const scaleTable =
185
194
  tableRef: HTMLTableElement | null | undefined,
186
195
  options: ScaleOptions,
187
196
  domAtPos: DomAtPos,
188
- isTableScalingEnabled = false,
197
+ isTableScalingEnabledOnCurrentTable = false,
189
198
  ) =>
190
199
  (tr: Transaction) => {
191
200
  if (!tableRef) {
@@ -197,7 +206,7 @@ export const scaleTable =
197
206
  if (hasTableBeenResized(node) === false) {
198
207
  // If its not a re-sized table, we still want to re-create cols
199
208
  // To force reflow of columns upon delete.
200
- if (!isTableScalingEnabled) {
209
+ if (!isTableScalingEnabledOnCurrentTable) {
201
210
  insertColgroupFromNode(tableRef, node);
202
211
  }
203
212
  tr.setMeta('scrollIntoView', false);
@@ -212,10 +221,15 @@ export const scaleTable =
212
221
  node,
213
222
  start,
214
223
  domAtPos,
215
- isTableScalingEnabled,
224
+ isTableScalingEnabledOnCurrentTable,
216
225
  );
217
226
  } else {
218
- resizeState = scale(tableRef, options, domAtPos, isTableScalingEnabled);
227
+ resizeState = scale(
228
+ tableRef,
229
+ options,
230
+ domAtPos,
231
+ isTableScalingEnabledOnCurrentTable,
232
+ );
219
233
  }
220
234
 
221
235
  if (resizeState) {
@@ -23,7 +23,6 @@ import {
23
23
  } from '@atlaskit/editor-shared-styles';
24
24
  import { findTable } from '@atlaskit/editor-tables/utils';
25
25
 
26
- import { getPluginState } from './plugin-factory';
27
26
  import { TABLE_MAX_WIDTH } from './table-resizing/utils';
28
27
 
29
28
  type __ReplaceStep = ReplaceStep & {
@@ -44,6 +43,7 @@ const createPlugin = (
44
43
  dispatch: Dispatch,
45
44
  dispatchAnalyticsEvent: DispatchAnalyticsEvent,
46
45
  fullWidthEnabled: boolean,
46
+ isTableScalingEnabled: boolean,
47
47
  ) => {
48
48
  return new SafePlugin({
49
49
  key: pluginKey,
@@ -122,8 +122,6 @@ const createPlugin = (
122
122
  tr.getMeta('referentialityTableInserted'),
123
123
  );
124
124
 
125
- const { isTableScalingEnabled = false } = getPluginState(newState);
126
-
127
125
  const shouldPatchTable = fullWidthEnabled && isTableScalingEnabled;
128
126
 
129
127
  if (