@atlaskit/editor-plugin-table 7.16.18 → 7.17.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 +21 -0
  2. package/dist/cjs/commands/column-resize.js +4 -3
  3. package/dist/cjs/commands/delete.js +3 -2
  4. package/dist/cjs/commands/insert.js +12 -8
  5. package/dist/cjs/commands-with-analytics.js +10 -7
  6. package/dist/cjs/event-handlers.js +3 -2
  7. package/dist/cjs/nodeviews/TableComponent.js +32 -19
  8. package/dist/cjs/nodeviews/TableContainer.js +4 -0
  9. package/dist/cjs/nodeviews/TableResizer.js +3 -2
  10. package/dist/cjs/nodeviews/table.js +6 -4
  11. package/dist/cjs/plugin.js +9 -6
  12. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +12 -13
  13. package/dist/cjs/pm-plugins/keymap.js +11 -9
  14. package/dist/cjs/pm-plugins/main.js +4 -1
  15. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +10 -9
  16. package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +4 -3
  17. package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +4 -3
  18. package/dist/cjs/toolbar.js +29 -20
  19. package/dist/cjs/transforms/column-width.js +3 -3
  20. package/dist/cjs/transforms/delete-columns.js +3 -2
  21. package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +21 -15
  22. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +3 -2
  23. package/dist/cjs/ui/FloatingDragMenu/index.js +6 -3
  24. package/dist/cjs/ui/FloatingInsertButton/index.js +7 -8
  25. package/dist/cjs/ui/TableFloatingControls/index.js +4 -1
  26. package/dist/cjs/utils/drag-menu.js +5 -4
  27. package/dist/es2019/commands/column-resize.js +4 -3
  28. package/dist/es2019/commands/delete.js +2 -2
  29. package/dist/es2019/commands/insert.js +8 -8
  30. package/dist/es2019/commands-with-analytics.js +9 -8
  31. package/dist/es2019/event-handlers.js +2 -2
  32. package/dist/es2019/nodeviews/TableComponent.js +28 -17
  33. package/dist/es2019/nodeviews/TableContainer.js +4 -0
  34. package/dist/es2019/nodeviews/TableResizer.js +3 -2
  35. package/dist/es2019/nodeviews/table.js +5 -4
  36. package/dist/es2019/plugin.js +9 -6
  37. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +7 -10
  38. package/dist/es2019/pm-plugins/keymap.js +9 -9
  39. package/dist/es2019/pm-plugins/main.js +4 -1
  40. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +10 -9
  41. package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +4 -4
  42. package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +4 -4
  43. package/dist/es2019/toolbar.js +25 -22
  44. package/dist/es2019/transforms/column-width.js +2 -3
  45. package/dist/es2019/transforms/delete-columns.js +2 -2
  46. package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +12 -7
  47. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +3 -2
  48. package/dist/es2019/ui/FloatingDragMenu/index.js +5 -3
  49. package/dist/es2019/ui/FloatingInsertButton/index.js +6 -8
  50. package/dist/es2019/ui/TableFloatingControls/index.js +5 -1
  51. package/dist/es2019/utils/drag-menu.js +4 -4
  52. package/dist/esm/commands/column-resize.js +4 -3
  53. package/dist/esm/commands/delete.js +3 -2
  54. package/dist/esm/commands/insert.js +12 -8
  55. package/dist/esm/commands-with-analytics.js +10 -7
  56. package/dist/esm/event-handlers.js +3 -2
  57. package/dist/esm/nodeviews/TableComponent.js +32 -19
  58. package/dist/esm/nodeviews/TableContainer.js +4 -0
  59. package/dist/esm/nodeviews/TableResizer.js +3 -2
  60. package/dist/esm/nodeviews/table.js +6 -4
  61. package/dist/esm/plugin.js +9 -6
  62. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +12 -13
  63. package/dist/esm/pm-plugins/keymap.js +11 -9
  64. package/dist/esm/pm-plugins/main.js +4 -1
  65. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +10 -9
  66. package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +4 -3
  67. package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +4 -3
  68. package/dist/esm/toolbar.js +29 -20
  69. package/dist/esm/transforms/column-width.js +3 -3
  70. package/dist/esm/transforms/delete-columns.js +3 -2
  71. package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +21 -15
  72. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +3 -2
  73. package/dist/esm/ui/FloatingDragMenu/index.js +6 -3
  74. package/dist/esm/ui/FloatingInsertButton/index.js +7 -8
  75. package/dist/esm/ui/TableFloatingControls/index.js +4 -1
  76. package/dist/esm/utils/drag-menu.js +5 -4
  77. package/dist/types/commands/column-resize.d.ts +2 -1
  78. package/dist/types/commands/delete.d.ts +1 -1
  79. package/dist/types/commands/insert.d.ts +4 -4
  80. package/dist/types/commands-with-analytics.d.ts +4 -4
  81. package/dist/types/event-handlers.d.ts +1 -1
  82. package/dist/types/nodeviews/TableContainer.d.ts +4 -2
  83. package/dist/types/nodeviews/TableResizer.d.ts +2 -1
  84. package/dist/types/nodeviews/table.d.ts +1 -0
  85. package/dist/types/plugin.d.ts +3 -1
  86. package/dist/types/pm-plugins/drag-and-drop/plugin.d.ts +1 -1
  87. package/dist/types/pm-plugins/keymap.d.ts +1 -1
  88. package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +1 -1
  89. package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +1 -1
  90. package/dist/types/toolbar.d.ts +5 -5
  91. package/dist/types/transforms/column-width.d.ts +1 -1
  92. package/dist/types/transforms/delete-columns.d.ts +1 -1
  93. package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +2 -1
  94. package/dist/types/ui/FloatingInsertButton/index.d.ts +1 -0
  95. package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +8 -2
  96. package/dist/types/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +16 -4
  97. package/dist/types/ui/TableFloatingControls/index.d.ts +8 -2
  98. package/dist/types/utils/drag-menu.d.ts +1 -1
  99. package/dist/types-ts4.5/commands/column-resize.d.ts +2 -1
  100. package/dist/types-ts4.5/commands/delete.d.ts +1 -1
  101. package/dist/types-ts4.5/commands/insert.d.ts +4 -4
  102. package/dist/types-ts4.5/commands-with-analytics.d.ts +4 -4
  103. package/dist/types-ts4.5/event-handlers.d.ts +1 -1
  104. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -2
  105. package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -1
  106. package/dist/types-ts4.5/nodeviews/table.d.ts +1 -0
  107. package/dist/types-ts4.5/plugin.d.ts +3 -1
  108. package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin.d.ts +1 -1
  109. package/dist/types-ts4.5/pm-plugins/keymap.d.ts +1 -1
  110. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +1 -1
  111. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +1 -1
  112. package/dist/types-ts4.5/toolbar.d.ts +5 -5
  113. package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
  114. package/dist/types-ts4.5/transforms/delete-columns.d.ts +1 -1
  115. package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +2 -1
  116. package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +1 -0
  117. package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +10 -2
  118. package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +20 -4
  119. package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +10 -2
  120. package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
  121. package/package.json +3 -9
  122. package/src/commands/column-resize.ts +6 -6
  123. package/src/commands/delete.ts +7 -1
  124. package/src/commands/insert.ts +33 -5
  125. package/src/commands-with-analytics.ts +14 -2
  126. package/src/event-handlers.ts +2 -0
  127. package/src/nodeviews/TableComponent.tsx +28 -28
  128. package/src/nodeviews/TableContainer.tsx +6 -0
  129. package/src/nodeviews/TableResizer.tsx +4 -0
  130. package/src/nodeviews/table.tsx +4 -2
  131. package/src/plugin.tsx +19 -7
  132. package/src/pm-plugins/drag-and-drop/plugin.ts +26 -13
  133. package/src/pm-plugins/keymap.ts +30 -4
  134. package/src/pm-plugins/main.ts +2 -0
  135. package/src/pm-plugins/table-resizing/event-handlers.ts +12 -14
  136. package/src/pm-plugins/table-resizing/utils/resize-state.ts +5 -5
  137. package/src/pm-plugins/table-resizing/utils/scale-table.ts +6 -4
  138. package/src/toolbar.tsx +46 -12
  139. package/src/transforms/column-width.ts +7 -3
  140. package/src/transforms/delete-columns.ts +6 -2
  141. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +12 -4
  142. package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -0
  143. package/src/ui/FloatingDragMenu/index.tsx +4 -4
  144. package/src/ui/FloatingInsertButton/index.tsx +12 -9
  145. package/src/ui/TableFloatingControls/index.tsx +4 -1
  146. package/src/utils/drag-menu.ts +13 -4
  147. package/tsconfig.app.json +3 -0
package/src/plugin.tsx CHANGED
@@ -30,6 +30,7 @@ import type { AccessibilityUtilsPlugin } from '@atlaskit/editor-plugin-accessibi
30
30
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
31
31
  import type { ContentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
32
32
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
33
+ import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
33
34
  import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
34
35
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
35
36
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
@@ -134,6 +135,7 @@ export type TablePlugin = NextEditorPlugin<
134
135
  OptionalPlugin<AccessibilityUtilsPlugin>,
135
136
  OptionalPlugin<MediaPlugin>,
136
137
  OptionalPlugin<EditorViewModePlugin>,
138
+ OptionalPlugin<FeatureFlagsPlugin>,
137
139
  ];
138
140
  }
139
141
  >;
@@ -153,13 +155,15 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
153
155
  };
154
156
  const editorAnalyticsAPI = api?.analytics?.actions;
155
157
 
156
- const isTableScalingWithFixedColumnWidthsOptionEnabled =
157
- options?.isTableScalingEnabled &&
158
- getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
159
- const shouldUseIncreasedScalingPercent =
160
- isTableScalingWithFixedColumnWidthsOptionEnabled &&
158
+ const isTableFixedColumnWidthsOptionEnabled =
159
+ options?.getEditorFeatureFlags?.().tableWithFixedColumnWidthsOption || false;
160
+ const shouldUseIncreasedScalingPercent = options?.isTableScalingEnabled;
161
+ isTableFixedColumnWidthsOptionEnabled &&
161
162
  getBooleanFF('platform.editor.table.use-increased-scaling-percent');
162
163
 
164
+ const isCellBackgroundDuplicated =
165
+ options?.getEditorFeatureFlags?.().tableDuplicateCellColouring || false;
166
+
163
167
  return {
164
168
  name: 'table',
165
169
 
@@ -331,6 +335,8 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
331
335
  fullWidthEnabled,
332
336
  api,
333
337
  getIntl,
338
+ isCellBackgroundDuplicated,
339
+ isTableFixedColumnWidthsOptionEnabled,
334
340
  shouldUseIncreasedScalingPercent,
335
341
  );
336
342
  },
@@ -371,7 +377,12 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
371
377
  name: 'tableDragAndDrop',
372
378
  plugin: ({ dispatch }) => {
373
379
  return options?.dragAndDropEnabled
374
- ? createDragAndDropPlugin(dispatch, editorAnalyticsAPI)
380
+ ? createDragAndDropPlugin(
381
+ dispatch,
382
+ editorAnalyticsAPI,
383
+ options?.isTableScalingEnabled,
384
+ isTableFixedColumnWidthsOptionEnabled,
385
+ )
375
386
  : undefined;
376
387
  },
377
388
  },
@@ -533,6 +544,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
533
544
  isHeaderColumnEnabled={isHeaderColumnEnabled}
534
545
  isHeaderRowEnabled={isHeaderRowEnabled}
535
546
  isDragAndDropEnabled={isDragAndDropEnabled}
547
+ isTableScalingEnabled={options?.isTableScalingEnabled}
536
548
  editorView={editorView}
537
549
  mountPoint={popupsMountPoint}
538
550
  boundariesElement={popupsBoundariesElement}
@@ -662,7 +674,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
662
674
  options?.getEditorFeatureFlags || defaultGetEditorFeatureFlags,
663
675
  () => editorViewRef.current,
664
676
  options,
665
- isTableScalingWithFixedColumnWidthsOptionEnabled,
677
+ isTableFixedColumnWidthsOptionEnabled,
666
678
  shouldUseIncreasedScalingPercent,
667
679
  )(pluginConfig(options?.tableOptions)),
668
680
  },
@@ -29,7 +29,12 @@ import { createPluginState, getPluginState } from './plugin-factory';
29
29
  import { pluginKey } from './plugin-key';
30
30
  import { getDraggableDataFromEvent } from './utils/monitor';
31
31
 
32
- const destroyFn = (editorView: EditorView, editorAnalyticsAPI: any) => {
32
+ const destroyFn = (
33
+ editorView: EditorView,
34
+ editorAnalyticsAPI: any,
35
+ isTableScalingEnabled: boolean,
36
+ isTableFixedColumnWidthsOptionEnabled: boolean,
37
+ ) => {
33
38
  const editorPageScrollContainer = document.querySelector('.fabric-editor-popup-scroll-parent');
34
39
 
35
40
  const rowAutoScrollers = editorPageScrollContainer
@@ -211,24 +216,22 @@ const destroyFn = (editorView: EditorView, editorAnalyticsAPI: any) => {
211
216
  if (sourceType === 'table-column') {
212
217
  const { tableRef, tableNode } = getTablePluginState(editorView.state);
213
218
  if (tableRef && tableNode) {
214
- const { isTableScalingEnabled = false } = getTablePluginState(editorView.state);
215
-
216
219
  let isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
217
- const isTableScalingEnabledWithLockButton =
218
- isTableScalingEnabled &&
219
- getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
220
- const shouldUseIncreasedScalingPercent =
221
- isTableScalingEnabledWithLockButton &&
222
- getBooleanFF('platform.editor.table.use-increased-scaling-percent');
223
-
224
- if (isTableScalingEnabledWithLockButton) {
220
+ const isTableScalingWithFixedColumnWidthsOptionEnabled =
221
+ isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled;
222
+ if (isTableScalingWithFixedColumnWidthsOptionEnabled) {
225
223
  isTableScalingEnabledOnCurrentTable = tableNode.attrs.displayMode !== 'fixed';
226
224
  }
227
225
 
226
+ const shouldUseIncreasedScalingPercent =
227
+ isTableScalingWithFixedColumnWidthsOptionEnabled &&
228
+ getBooleanFF('platform.editor.table.use-increased-scaling-percent');
229
+
228
230
  insertColgroupFromNode(
229
231
  tableRef,
230
232
  tableNode,
231
233
  isTableScalingEnabledOnCurrentTable,
234
+ undefined,
232
235
  shouldUseIncreasedScalingPercent,
233
236
  );
234
237
  }
@@ -241,7 +244,12 @@ const destroyFn = (editorView: EditorView, editorAnalyticsAPI: any) => {
241
244
  );
242
245
  };
243
246
 
244
- export const createPlugin = (dispatch: Dispatch, editorAnalyticsAPI?: EditorAnalyticsAPI) => {
247
+ export const createPlugin = (
248
+ dispatch: Dispatch,
249
+ editorAnalyticsAPI?: EditorAnalyticsAPI,
250
+ isTableScalingEnabled = false,
251
+ isTableFixedColumnWidthsOptionEnabled = false,
252
+ ) => {
245
253
  return new SafePlugin({
246
254
  state: createPluginState(dispatch, (state) => ({
247
255
  decorationSet: DecorationSet.empty,
@@ -310,7 +318,12 @@ export const createPlugin = (dispatch: Dispatch, editorAnalyticsAPI?: EditorAnal
310
318
  },
311
319
  view: (editorView: EditorView) => {
312
320
  return {
313
- destroy: destroyFn(editorView, editorAnalyticsAPI),
321
+ destroy: destroyFn(
322
+ editorView,
323
+ editorAnalyticsAPI,
324
+ isTableScalingEnabled,
325
+ isTableFixedColumnWidthsOptionEnabled,
326
+ ),
314
327
  };
315
328
  },
316
329
  props: {
@@ -65,6 +65,8 @@ export function keymapPlugin(
65
65
  isFullWidthEnabled?: boolean,
66
66
  pluginInjectionApi?: PluginInjectionAPIWithA11y,
67
67
  getIntl?: () => IntlShape,
68
+ isCellBackgroundDuplicated = false,
69
+ isTableFixedColumnWidthsOptionEnabled = false,
68
70
  shouldUseIncreasedScalingPercent?: boolean,
69
71
  ): SafePlugin {
70
72
  const list = {};
@@ -116,13 +118,23 @@ export function keymapPlugin(
116
118
 
117
119
  bindKeymapWithCommand(
118
120
  addColumnBefore.common!,
119
- addColumnBeforeCommand(isTableScalingEnabled, shouldUseIncreasedScalingPercent),
121
+ addColumnBeforeCommand(
122
+ isTableScalingEnabled,
123
+ isCellBackgroundDuplicated,
124
+ isTableFixedColumnWidthsOptionEnabled,
125
+ shouldUseIncreasedScalingPercent,
126
+ ),
120
127
  list,
121
128
  );
122
129
 
123
130
  bindKeymapWithCommand(
124
131
  addColumnAfter.common!,
125
- addColumnAfterCommand(isTableScalingEnabled, shouldUseIncreasedScalingPercent),
132
+ addColumnAfterCommand(
133
+ isTableScalingEnabled,
134
+ isCellBackgroundDuplicated,
135
+ isTableFixedColumnWidthsOptionEnabled,
136
+ shouldUseIncreasedScalingPercent,
137
+ ),
126
138
  list,
127
139
  );
128
140
 
@@ -141,13 +153,23 @@ export function keymapPlugin(
141
153
 
142
154
  bindKeymapWithCommand(
143
155
  addColumnBeforeVO.common!,
144
- addColumnBeforeCommand(isTableScalingEnabled),
156
+ addColumnBeforeCommand(
157
+ isTableScalingEnabled,
158
+ isCellBackgroundDuplicated,
159
+ isTableFixedColumnWidthsOptionEnabled,
160
+ shouldUseIncreasedScalingPercent,
161
+ ),
145
162
  list,
146
163
  );
147
164
 
148
165
  bindKeymapWithCommand(
149
166
  addColumnAfterVO.common!,
150
- addColumnAfterCommand(isTableScalingEnabled),
167
+ addColumnAfterCommand(
168
+ isTableScalingEnabled,
169
+ isCellBackgroundDuplicated,
170
+ isTableFixedColumnWidthsOptionEnabled,
171
+ shouldUseIncreasedScalingPercent,
172
+ ),
151
173
  list,
152
174
  );
153
175
  }
@@ -191,6 +213,7 @@ export function keymapPlugin(
191
213
  deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(
192
214
  editorAnalyticsAPI,
193
215
  isTableScalingEnabled,
216
+ isTableFixedColumnWidthsOptionEnabled,
194
217
  shouldUseIncreasedScalingPercent,
195
218
  ),
196
219
  list,
@@ -201,6 +224,7 @@ export function keymapPlugin(
201
224
  deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(
202
225
  editorAnalyticsAPI,
203
226
  isTableScalingEnabled,
227
+ isTableFixedColumnWidthsOptionEnabled,
204
228
  shouldUseIncreasedScalingPercent,
205
229
  ),
206
230
  list,
@@ -243,6 +267,7 @@ export function keymapPlugin(
243
267
  -10,
244
268
  getEditorContainerWidth,
245
269
  isTableScalingEnabled,
270
+ isTableFixedColumnWidthsOptionEnabled,
246
271
  INPUT_METHOD.SHORTCUT,
247
272
  ariaNotifyPlugin,
248
273
  getIntl,
@@ -256,6 +281,7 @@ export function keymapPlugin(
256
281
  10,
257
282
  getEditorContainerWidth,
258
283
  isTableScalingEnabled,
284
+ isTableFixedColumnWidthsOptionEnabled,
259
285
  INPUT_METHOD.SHORTCUT,
260
286
  ariaNotifyPlugin,
261
287
  getIntl,
@@ -158,6 +158,7 @@ export const createPlugin = (
158
158
  }
159
159
 
160
160
  if (tr) {
161
+ const { tableWithFixedColumnWidthsOption = false } = getEditorFeatureFlags();
161
162
  // "fixTables" removes empty rows as we don't allow that in schema
162
163
  const updatedTr = handleCut(
163
164
  tr,
@@ -166,6 +167,7 @@ export const createPlugin = (
166
167
  editorAnalyticsAPI,
167
168
  editorViewRef || undefined,
168
169
  isTableScalingEnabled,
170
+ tableWithFixedColumnWidthsOption,
169
171
  shouldUseIncreasedScalingPercent,
170
172
  );
171
173
  return fixTables(updatedTr) || updatedTr;
@@ -84,10 +84,12 @@ export const handleMouseDown = (
84
84
  });
85
85
 
86
86
  let shouldScale = tableDepth === 0 && isTableScalingEnabled;
87
+ const { tableWithFixedColumnWidthsOption = false } = getEditorFeatureFlags();
87
88
 
88
- const isTableScalingEnabledWithLockButton =
89
- isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
90
- if (isTableScalingEnabledWithLockButton) {
89
+ const isTableScalingWithFixedColumnWidthsOptionEnabled =
90
+ isTableScalingEnabled && tableWithFixedColumnWidthsOption;
91
+
92
+ if (isTableScalingWithFixedColumnWidthsOptionEnabled) {
91
93
  shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
92
94
  }
93
95
 
@@ -100,7 +102,7 @@ export const handleMouseDown = (
100
102
  domAtPos,
101
103
  isTableScalingEnabled: shouldScale,
102
104
  shouldUseIncreasedScalingPercent:
103
- isTableScalingEnabledWithLockButton &&
105
+ isTableScalingWithFixedColumnWidthsOptionEnabled &&
104
106
  getBooleanFF('platform.editor.table.use-increased-scaling-percent'),
105
107
  });
106
108
 
@@ -183,10 +185,8 @@ export const handleMouseDown = (
183
185
  selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
184
186
 
185
187
  let shouldScale = tableDepth === 0 && isTableScalingEnabled;
186
- const isTableScalingEnabledWithLockButton =
187
- isTableScalingEnabled &&
188
- getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
189
- if (isTableScalingEnabledWithLockButton) {
188
+
189
+ if (isTableScalingWithFixedColumnWidthsOptionEnabled) {
190
190
  shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
191
191
  }
192
192
 
@@ -213,7 +213,7 @@ export const handleMouseDown = (
213
213
  originalTable,
214
214
  resizingSelectedColumns ? selectedColumns : undefined,
215
215
  shouldScale,
216
- isTableScalingEnabledWithLockButton &&
216
+ isTableScalingWithFixedColumnWidthsOptionEnabled &&
217
217
  getBooleanFF('platform.editor.table.use-increased-scaling-percent'),
218
218
  );
219
219
  tr = updateColumnWidths(newResizeState, table, start)(tr);
@@ -289,13 +289,11 @@ export const handleMouseDown = (
289
289
  const colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter!.attrs.colspan - 1;
290
290
 
291
291
  let shouldScale = tableDepth === 0 && isTableScalingEnabled;
292
- const isTableScalingEnabledWithLockButton =
293
- isTableScalingEnabled &&
294
- getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
292
+
295
293
  const shouldUseIncreasedScalingPercent =
296
- isTableScalingEnabledWithLockButton &&
294
+ isTableScalingWithFixedColumnWidthsOptionEnabled &&
297
295
  getBooleanFF('platform.editor.table.use-increased-scaling-percent');
298
- if (isTableScalingEnabledWithLockButton) {
296
+ if (isTableScalingWithFixedColumnWidthsOptionEnabled) {
299
297
  shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
300
298
  }
301
299
 
@@ -325,6 +325,7 @@ export const getNewResizeStateFromSelectedColumns = (
325
325
  domAtPos: (pos: number) => { node: Node; offset: number },
326
326
  getEditorContainerWidth: GetEditorContainerWidth,
327
327
  isTableScalingEnabled = false,
328
+ isTableFixedColumnWidthsOptionEnabled = false,
328
329
  ): ResizeStateWithAnalytics | undefined => {
329
330
  // Fail early so that we don't do complex calculations for no reason
330
331
  const numColumnsSelected = rect.right - rect.left;
@@ -367,10 +368,9 @@ export const getNewResizeStateFromSelectedColumns = (
367
368
  let resizeState;
368
369
 
369
370
  let isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
370
-
371
- const isTableScalingEnabledWithLockButton =
372
- isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
373
- if (isTableScalingEnabledWithLockButton) {
371
+ const isTableScalingWithFixedColumnWidthsOptionEnabled =
372
+ isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled;
373
+ if (isTableScalingWithFixedColumnWidthsOptionEnabled) {
374
374
  isTableScalingEnabledOnCurrentTable = table.node.attrs.displayMode !== 'fixed';
375
375
  }
376
376
 
@@ -383,7 +383,7 @@ export const getNewResizeStateFromSelectedColumns = (
383
383
  domAtPos,
384
384
  isTableScalingEnabled: isTableScalingEnabledOnCurrentTable,
385
385
  shouldUseIncreasedScalingPercent:
386
- isTableScalingEnabledWithLockButton &&
386
+ isTableScalingWithFixedColumnWidthsOptionEnabled &&
387
387
  getBooleanFF('platform.editor.table.use-increased-scaling-percent'),
388
388
  });
389
389
 
@@ -153,6 +153,7 @@ export const previewScaleTable = (
153
153
  options: ScaleOptions,
154
154
  domAtPos: DomAtPos,
155
155
  isTableScalingEnabled: boolean = false,
156
+ isTableWithFixedColumnWidthsOptionEnabled: boolean = false,
156
157
  ) => {
157
158
  const { node, start, parentWidth } = options;
158
159
 
@@ -169,9 +170,10 @@ export const previewScaleTable = (
169
170
  }
170
171
 
171
172
  let isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
172
- const isTableScalingEnabledWithLockButton =
173
- isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
174
- if (isTableScalingEnabledWithLockButton) {
173
+ const isTableScalingWithFixedColumnWidthsOptionEnabled =
174
+ isTableScalingEnabled && isTableWithFixedColumnWidthsOptionEnabled;
175
+
176
+ if (isTableScalingWithFixedColumnWidthsOptionEnabled) {
175
177
  isTableScalingEnabledOnCurrentTable =
176
178
  isTableScalingEnabled && node.attrs.displayMode !== 'fixed';
177
179
  }
@@ -183,7 +185,7 @@ export const previewScaleTable = (
183
185
  }
184
186
 
185
187
  const shouldUseIncreasedScalingPercent =
186
- isTableScalingEnabledWithLockButton &&
188
+ isTableScalingWithFixedColumnWidthsOptionEnabled &&
187
189
  getBooleanFF('platform.editor.table.use-increased-scaling-percent');
188
190
 
189
191
  const resizeState = parentWidth
package/src/toolbar.tsx CHANGED
@@ -157,6 +157,9 @@ export const getToolbarMenuConfig = (
157
157
  },
158
158
  ];
159
159
 
160
+ const tableOptionsDropdownWidth = isTableScalingWithFixedColumnWidthsOptionShown
161
+ ? 192
162
+ : undefined;
160
163
  if (state.isDragAndDropEnabled) {
161
164
  return {
162
165
  id: 'editor.table.tableOptions',
@@ -166,7 +169,7 @@ export const getToolbarMenuConfig = (
166
169
  title: formatMessage(messages.tableOptions),
167
170
  hidden: options.every((option) => option.hidden),
168
171
  options,
169
- dropdownWidth: isTableScalingWithFixedColumnWidthsOptionShown ? 192 : undefined,
172
+ dropdownWidth: tableOptionsDropdownWidth,
170
173
  };
171
174
  } else {
172
175
  return {
@@ -176,7 +179,7 @@ export const getToolbarMenuConfig = (
176
179
  title: formatMessage(messages.tableOptions),
177
180
  hidden: options.every((option) => option.hidden),
178
181
  options,
179
- dropdownWidth: isTableScalingWithFixedColumnWidthsOptionShown ? 192 : undefined,
182
+ dropdownWidth: tableOptionsDropdownWidth,
180
183
  };
181
184
  }
182
185
  };
@@ -192,6 +195,8 @@ export const getToolbarCellOptionsConfig = (
192
195
  getEditorContainerWidth: GetEditorContainerWidth,
193
196
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
194
197
  isTableScalingEnabled = false,
198
+ isCellBackgroundDuplicated = false,
199
+ isTableFixedColumnWidthsOptionEnabled = false,
195
200
  shouldUseIncreasedScalingPercent = false,
196
201
  ): FloatingToolbarDropdown<Command> => {
197
202
  const { top, bottom, right, left } = initialSelectionRect;
@@ -210,6 +215,8 @@ export const getToolbarCellOptionsConfig = (
210
215
  insertColumnWithAnalytics(
211
216
  editorAnalyticsAPI,
212
217
  isTableScalingEnabled,
218
+ isCellBackgroundDuplicated,
219
+ isTableFixedColumnWidthsOptionEnabled,
213
220
  shouldUseIncreasedScalingPercent,
214
221
  )(INPUT_METHOD.FLOATING_TB, index)(state, dispatch, view);
215
222
  }
@@ -248,6 +255,7 @@ export const getToolbarCellOptionsConfig = (
248
255
  deleteColumnsWithAnalytics(
249
256
  editorAnalyticsAPI,
250
257
  isTableScalingEnabled,
258
+ isTableFixedColumnWidthsOptionEnabled,
251
259
  shouldUseIncreasedScalingPercent,
252
260
  )(INPUT_METHOD.FLOATING_TB, selectionRect)(state, dispatch, view);
253
261
  }
@@ -307,6 +315,7 @@ export const getToolbarCellOptionsConfig = (
307
315
  editorView.domAtPos.bind(editorView),
308
316
  getEditorContainerWidth,
309
317
  isTableScalingEnabled,
318
+ isTableFixedColumnWidthsOptionEnabled,
310
319
  )
311
320
  : undefined;
312
321
  const wouldChange = newResizeStateWithAnalytics?.changed ?? false;
@@ -446,7 +455,7 @@ export const getToolbarConfig =
446
455
  getEditorFeatureFlags: GetEditorFeatureFlags,
447
456
  getEditorView: () => EditorView | null,
448
457
  options?: TablePluginOptions,
449
- isTableScalingWithFixedColumnWidthsOptionEnabled = false,
458
+ isTableFixedColumnWidthsOptionEnabled = false,
450
459
  shouldUseIncreasedScalingPercent = false,
451
460
  ) =>
452
461
  (config: PluginConfig): FloatingToolbarHandler =>
@@ -455,6 +464,7 @@ export const getToolbarConfig =
455
464
  const pluginState = getPluginState(state);
456
465
  const resizeState = tableResizingPluginKey.getState(state);
457
466
  const tableWidthState = tableWidthPluginKey.getState(state);
467
+ const isTableScalingEnabled = options?.isTableScalingEnabled || false;
458
468
 
459
469
  // We don't want to show floating toolbar while resizing the table
460
470
  const isWidthResizing = tableWidthState?.resizing;
@@ -463,7 +473,7 @@ export const getToolbarConfig =
463
473
  const nodeType = state.schema.nodes.table;
464
474
  const isNested = pluginState.tablePos && isTableNested(state, pluginState.tablePos);
465
475
  const isTableScalingWithFixedColumnWidthsOptionShown =
466
- isTableScalingWithFixedColumnWidthsOptionEnabled && !isNested;
476
+ isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled && !isNested;
467
477
  const areTableColumWidthsFixed = tableObject.node.attrs.displayMode === 'fixed';
468
478
  const editorView = getEditorView();
469
479
 
@@ -501,9 +511,13 @@ export const getToolbarConfig =
501
511
  getEditorContainerWidth,
502
512
  getDomRef,
503
513
  editorView,
514
+ shouldUseIncreasedScalingPercent,
504
515
  )
505
516
  : [];
506
517
 
518
+ const isCellBackgroundDuplicated =
519
+ getEditorFeatureFlags().tableDuplicateCellColouring || false;
520
+
507
521
  const cellItems = pluginState.isDragAndDropEnabled
508
522
  ? []
509
523
  : getCellItems(
@@ -512,7 +526,9 @@ export const getToolbarConfig =
512
526
  intl,
513
527
  getEditorContainerWidth,
514
528
  editorAnalyticsAPI,
515
- options?.isTableScalingEnabled,
529
+ isTableScalingEnabled,
530
+ isCellBackgroundDuplicated,
531
+ isTableFixedColumnWidthsOptionEnabled,
516
532
  shouldUseIncreasedScalingPercent,
517
533
  );
518
534
 
@@ -523,7 +539,8 @@ export const getToolbarConfig =
523
539
  intl,
524
540
  getEditorContainerWidth,
525
541
  editorAnalyticsAPI,
526
- options?.isTableScalingEnabled,
542
+ isTableScalingEnabled,
543
+ isTableFixedColumnWidthsOptionEnabled,
527
544
  )
528
545
  : [];
529
546
  const colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI, getEditorView);
@@ -621,6 +638,8 @@ const getCellItems = (
621
638
  getEditorContainerWidth: GetEditorContainerWidth,
622
639
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
623
640
  isTableScalingEnabled = false,
641
+ isCellBackgroundDuplicated = false,
642
+ isTableFixedColumnWidthsOptionEnabled = false,
624
643
  shouldUseIncreasedScalingPercent = false,
625
644
  ): Array<FloatingToolbarItem<Command>> => {
626
645
  const initialSelectionRect = getClosestSelectionRect(state);
@@ -633,6 +652,8 @@ const getCellItems = (
633
652
  getEditorContainerWidth,
634
653
  editorAnalyticsAPI,
635
654
  isTableScalingEnabled,
655
+ isCellBackgroundDuplicated,
656
+ isTableFixedColumnWidthsOptionEnabled,
636
657
  shouldUseIncreasedScalingPercent,
637
658
  );
638
659
  return [cellOptions, separator(cellOptions.hidden!)];
@@ -645,18 +666,21 @@ export const getDistributeConfig =
645
666
  getEditorContainerWidth: GetEditorContainerWidth,
646
667
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
647
668
  isTableScalingEnabled = false,
669
+ isTableFixedColumnWidthsOptionEnabled = false,
648
670
  ): Command =>
649
671
  (state, dispatch, editorView) => {
650
672
  const selectionOrTableRect = getClosestSelectionOrTableRect(state);
651
673
  if (!editorView || !selectionOrTableRect) {
652
674
  return false;
653
675
  }
676
+
654
677
  const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(
655
678
  selectionOrTableRect,
656
679
  state,
657
680
  editorView.domAtPos.bind(editorView),
658
681
  getEditorContainerWidth,
659
682
  isTableScalingEnabled,
683
+ isTableFixedColumnWidthsOptionEnabled,
660
684
  );
661
685
 
662
686
  if (newResizeStateWithAnalytics) {
@@ -678,6 +702,7 @@ const getColumnSettingItems = (
678
702
  getEditorContainerWidth: GetEditorContainerWidth,
679
703
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
680
704
  isTableScalingEnabled = false,
705
+ isTableFixedColumnWidthsOptionEnabled = false,
681
706
  ): Array<FloatingToolbarItem<Command>> => {
682
707
  const pluginState = getPluginState(editorState);
683
708
  const selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
@@ -692,6 +717,7 @@ const getColumnSettingItems = (
692
717
  editorView.domAtPos.bind(editorView),
693
718
  getEditorContainerWidth,
694
719
  isTableScalingEnabled,
720
+ isTableFixedColumnWidthsOptionEnabled,
695
721
  );
696
722
 
697
723
  const wouldChange = newResizeStateWithAnalytics?.changed ?? false;
@@ -705,11 +731,12 @@ const getColumnSettingItems = (
705
731
  title: formatMessage(messages.distributeColumns),
706
732
  icon: DistributeColumnIcon,
707
733
  onClick: (state, dispatch, view) =>
708
- getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled)(
709
- state,
710
- dispatch,
711
- view,
712
- ),
734
+ getDistributeConfig(
735
+ getEditorContainerWidth,
736
+ editorAnalyticsAPI,
737
+ isTableScalingEnabled,
738
+ isTableFixedColumnWidthsOptionEnabled,
739
+ )(state, dispatch, view),
713
740
  disabled: !wouldChange,
714
741
  });
715
742
  }
@@ -816,6 +843,7 @@ export const getAlignmentOptionsConfig = (
816
843
  getEditorContainerWidth: GetEditorContainerWidth,
817
844
  getDomRef: (editorView: EditorView) => HTMLElement | undefined,
818
845
  editorView: EditorView | null,
846
+ shouldUseIncreasedScalingPercent: boolean,
819
847
  ): Array<FloatingToolbarDropdown<Command>> => {
820
848
  const tableObject = findTable(editorState.selection);
821
849
 
@@ -863,6 +891,7 @@ export const getAlignmentOptionsConfig = (
863
891
  getEditorContainerWidth,
864
892
  getDomRef,
865
893
  editorView,
894
+ shouldUseIncreasedScalingPercent,
866
895
  ) && {
867
896
  disabled: value !== 'center',
868
897
  }),
@@ -904,6 +933,7 @@ export const isLayoutOptionDisabled = (
904
933
  getEditorContainerWidth: GetEditorContainerWidth,
905
934
  getDomRef: (editorView: EditorView) => HTMLElement | undefined,
906
935
  editorView: EditorView | null,
936
+ shouldUseIncreasedScalingPercent: boolean,
907
937
  ) => {
908
938
  const { lineLength } = getEditorContainerWidth();
909
939
  let tableContainerWidth = getTableContainerWidth(selectedNode);
@@ -912,7 +942,11 @@ export const isLayoutOptionDisabled = (
912
942
  if (editorView) {
913
943
  const tableWrapper = getDomRef(editorView);
914
944
  const tableWrapperWidth = tableWrapper?.clientWidth || tableContainerWidth;
915
- const scalePercent = getStaticTableScalingPercent(selectedNode, tableWrapperWidth);
945
+ const scalePercent = getStaticTableScalingPercent(
946
+ selectedNode,
947
+ tableWrapperWidth,
948
+ shouldUseIncreasedScalingPercent,
949
+ );
916
950
  tableContainerWidth = tableContainerWidth * scalePercent;
917
951
  }
918
952
 
@@ -104,7 +104,11 @@ export const updateColumnWidths =
104
104
  * @returns Updated transaction with rescaled columns for a given table
105
105
  */
106
106
  export const rescaleColumns =
107
- (isTableScalingEnabled = false, shouldUseIncreasedScalingPercent = false) =>
107
+ (
108
+ isTableScalingEnabled = false,
109
+ isTableFixedColumnWidthsOptionEnabled = false,
110
+ shouldUseIncreasedScalingPercent = false,
111
+ ) =>
108
112
  (table: ContentNodeWithPos, view: EditorView | undefined) =>
109
113
  (tr: Transaction): Transaction => {
110
114
  if (!view) {
@@ -135,7 +139,8 @@ export const rescaleColumns =
135
139
 
136
140
  const tableDepth = view.state.doc.resolve(table.pos).depth;
137
141
  let shouldScale = isTableScalingEnabled && tableDepth === 0;
138
- if (shouldScale && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')) {
142
+
143
+ if (shouldScale && isTableFixedColumnWidthsOptionEnabled) {
139
144
  shouldScale = newTable.attrs.displayMode !== 'fixed';
140
145
  }
141
146
 
@@ -208,7 +213,6 @@ export const rescaleColumns =
208
213
  isTableScalingEnabled: shouldScale,
209
214
  shouldUseIncreasedScalingPercent,
210
215
  });
211
-
212
216
  // Two scenarios that require scaling:
213
217
  // 1. If the new table width will result in the table going into overflow
214
218
  // we resize the cells to avoid it (e.g. adding a column)
@@ -245,6 +245,7 @@ export const deleteColumns =
245
245
  allowCustomStep: boolean,
246
246
  view?: EditorView,
247
247
  isTableScalingEnabled = false,
248
+ isTableFixedColumnWidthsOptionEnabled = false,
248
249
  shouldUseIncreasedScalingPercent = false,
249
250
  ) =>
250
251
  (tr: Transaction) => {
@@ -259,9 +260,12 @@ export const deleteColumns =
259
260
  updatedTr = deleteColumnsLegacy(rect)(updatedTr);
260
261
  }
261
262
  const table = findTable(updatedTr.selection);
262
-
263
263
  if (table) {
264
- updatedTr = rescaleColumns(isTableScalingEnabled, shouldUseIncreasedScalingPercent)(
264
+ updatedTr = rescaleColumns(
265
+ isTableScalingEnabled,
266
+ isTableFixedColumnWidthsOptionEnabled,
267
+ shouldUseIncreasedScalingPercent,
268
+ )(
265
269
  table,
266
270
  view,
267
271
  )(updatedTr);