@atlaskit/editor-plugin-table 7.16.14 → 7.16.16

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 (158) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/commands/column-resize.js +6 -3
  3. package/dist/cjs/commands/delete.js +2 -1
  4. package/dist/cjs/commands/insert.js +8 -5
  5. package/dist/cjs/commands-with-analytics.js +6 -4
  6. package/dist/cjs/event-handlers.js +2 -1
  7. package/dist/cjs/nodeviews/TableComponent.js +21 -10
  8. package/dist/cjs/nodeviews/TableContainer.js +7 -3
  9. package/dist/cjs/nodeviews/TableResizer.js +3 -2
  10. package/dist/cjs/plugin.js +4 -3
  11. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +4 -2
  12. package/dist/cjs/pm-plugins/keymap.js +5 -4
  13. package/dist/cjs/pm-plugins/main.js +2 -2
  14. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +12 -7
  15. package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +6 -5
  16. package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +2 -1
  17. package/dist/cjs/pm-plugins/table-resizing/utils/index.js +6 -0
  18. package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +6 -4
  19. package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +5 -3
  20. package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +13 -8
  21. package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +17 -9
  22. package/dist/cjs/toolbar.js +7 -4
  23. package/dist/cjs/transforms/column-width.js +3 -1
  24. package/dist/cjs/transforms/delete-columns.js +2 -1
  25. package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +4 -2
  26. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +3 -2
  27. package/dist/cjs/ui/FloatingDragMenu/index.js +4 -1
  28. package/dist/cjs/ui/FloatingInsertButton/index.js +3 -1
  29. package/dist/cjs/ui/TableFloatingControls/index.js +2 -2
  30. package/dist/cjs/utils/drag-menu.js +2 -1
  31. package/dist/es2019/commands/column-resize.js +6 -3
  32. package/dist/es2019/commands/delete.js +2 -2
  33. package/dist/es2019/commands/insert.js +8 -8
  34. package/dist/es2019/commands-with-analytics.js +6 -6
  35. package/dist/es2019/event-handlers.js +2 -2
  36. package/dist/es2019/nodeviews/TableComponent.js +21 -10
  37. package/dist/es2019/nodeviews/TableContainer.js +7 -3
  38. package/dist/es2019/nodeviews/TableResizer.js +3 -2
  39. package/dist/es2019/plugin.js +4 -3
  40. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +4 -2
  41. package/dist/es2019/pm-plugins/keymap.js +5 -5
  42. package/dist/es2019/pm-plugins/main.js +2 -2
  43. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +12 -7
  44. package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +6 -6
  45. package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +1 -0
  46. package/dist/es2019/pm-plugins/table-resizing/utils/index.js +1 -1
  47. package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +7 -5
  48. package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +5 -5
  49. package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +12 -8
  50. package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +17 -12
  51. package/dist/es2019/toolbar.js +7 -7
  52. package/dist/es2019/transforms/column-width.js +3 -2
  53. package/dist/es2019/transforms/delete-columns.js +2 -2
  54. package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +4 -2
  55. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +3 -2
  56. package/dist/es2019/ui/FloatingDragMenu/index.js +4 -1
  57. package/dist/es2019/ui/FloatingInsertButton/index.js +3 -1
  58. package/dist/es2019/ui/TableFloatingControls/index.js +2 -2
  59. package/dist/es2019/utils/drag-menu.js +2 -2
  60. package/dist/esm/commands/column-resize.js +6 -3
  61. package/dist/esm/commands/delete.js +2 -1
  62. package/dist/esm/commands/insert.js +8 -5
  63. package/dist/esm/commands-with-analytics.js +6 -4
  64. package/dist/esm/event-handlers.js +2 -1
  65. package/dist/esm/nodeviews/TableComponent.js +21 -10
  66. package/dist/esm/nodeviews/TableContainer.js +7 -3
  67. package/dist/esm/nodeviews/TableResizer.js +3 -2
  68. package/dist/esm/plugin.js +4 -3
  69. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +4 -2
  70. package/dist/esm/pm-plugins/keymap.js +5 -4
  71. package/dist/esm/pm-plugins/main.js +2 -2
  72. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +12 -7
  73. package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +6 -5
  74. package/dist/esm/pm-plugins/table-resizing/utils/consts.js +1 -0
  75. package/dist/esm/pm-plugins/table-resizing/utils/index.js +1 -1
  76. package/dist/esm/pm-plugins/table-resizing/utils/misc.js +7 -5
  77. package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +5 -3
  78. package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +13 -8
  79. package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +17 -9
  80. package/dist/esm/toolbar.js +7 -4
  81. package/dist/esm/transforms/column-width.js +3 -1
  82. package/dist/esm/transforms/delete-columns.js +2 -1
  83. package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +4 -2
  84. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +3 -2
  85. package/dist/esm/ui/FloatingDragMenu/index.js +4 -1
  86. package/dist/esm/ui/FloatingInsertButton/index.js +3 -1
  87. package/dist/esm/ui/TableFloatingControls/index.js +2 -2
  88. package/dist/esm/utils/drag-menu.js +2 -1
  89. package/dist/types/commands/delete.d.ts +1 -1
  90. package/dist/types/commands/insert.d.ts +4 -4
  91. package/dist/types/commands-with-analytics.d.ts +3 -3
  92. package/dist/types/event-handlers.d.ts +1 -1
  93. package/dist/types/nodeviews/TableContainer.d.ts +4 -2
  94. package/dist/types/nodeviews/TableResizer.d.ts +2 -1
  95. package/dist/types/pm-plugins/keymap.d.ts +1 -1
  96. package/dist/types/pm-plugins/main.d.ts +1 -1
  97. package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +2 -2
  98. package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
  99. package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +1 -1
  100. package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +2 -2
  101. package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -2
  102. package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +3 -2
  103. package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -3
  104. package/dist/types/toolbar.d.ts +2 -2
  105. package/dist/types/transforms/column-width.d.ts +1 -1
  106. package/dist/types/transforms/delete-columns.d.ts +1 -1
  107. package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +2 -1
  108. package/dist/types/utils/drag-menu.d.ts +1 -1
  109. package/dist/types-ts4.5/commands/delete.d.ts +1 -1
  110. package/dist/types-ts4.5/commands/insert.d.ts +4 -4
  111. package/dist/types-ts4.5/commands-with-analytics.d.ts +3 -3
  112. package/dist/types-ts4.5/event-handlers.d.ts +1 -1
  113. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -2
  114. package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -1
  115. package/dist/types-ts4.5/pm-plugins/keymap.d.ts +1 -1
  116. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
  117. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +2 -2
  118. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
  119. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +1 -1
  120. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +2 -2
  121. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -2
  122. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +3 -2
  123. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -3
  124. package/dist/types-ts4.5/toolbar.d.ts +2 -2
  125. package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
  126. package/dist/types-ts4.5/transforms/delete-columns.d.ts +1 -1
  127. package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +2 -1
  128. package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
  129. package/package.json +8 -2
  130. package/src/commands/column-resize.ts +9 -3
  131. package/src/commands/delete.ts +2 -1
  132. package/src/commands/insert.ts +31 -12
  133. package/src/commands-with-analytics.ts +24 -8
  134. package/src/event-handlers.ts +2 -0
  135. package/src/nodeviews/TableComponent.tsx +41 -12
  136. package/src/nodeviews/TableContainer.tsx +6 -0
  137. package/src/nodeviews/TableResizer.tsx +4 -0
  138. package/src/plugin.tsx +9 -0
  139. package/src/pm-plugins/drag-and-drop/plugin.ts +13 -4
  140. package/src/pm-plugins/keymap.ts +17 -4
  141. package/src/pm-plugins/main.ts +2 -0
  142. package/src/pm-plugins/table-resizing/event-handlers.ts +21 -10
  143. package/src/pm-plugins/table-resizing/utils/colgroup.ts +14 -4
  144. package/src/pm-plugins/table-resizing/utils/consts.ts +1 -0
  145. package/src/pm-plugins/table-resizing/utils/index.ts +1 -0
  146. package/src/pm-plugins/table-resizing/utils/misc.ts +24 -5
  147. package/src/pm-plugins/table-resizing/utils/resize-column.ts +11 -4
  148. package/src/pm-plugins/table-resizing/utils/resize-state.ts +17 -6
  149. package/src/pm-plugins/table-resizing/utils/scale-table.ts +32 -9
  150. package/src/toolbar.tsx +15 -9
  151. package/src/transforms/column-width.ts +2 -1
  152. package/src/transforms/delete-columns.ts +11 -2
  153. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +12 -5
  154. package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -0
  155. package/src/ui/FloatingDragMenu/index.tsx +7 -0
  156. package/src/ui/FloatingInsertButton/index.tsx +7 -0
  157. package/src/ui/TableFloatingControls/index.tsx +18 -16
  158. package/src/utils/drag-menu.ts +2 -0
@@ -20,7 +20,10 @@ import {
20
20
  import type { TableOptions } from '../../../nodeviews/types';
21
21
 
22
22
  import { hasTableBeenResized } from './colgroup';
23
- import { MAX_SCALING_PERCENT } from './consts';
23
+ import {
24
+ MAX_SCALING_PERCENT,
25
+ MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION,
26
+ } from './consts';
24
27
 
25
28
  // Translates named layouts in number values.
26
29
  export function getLayoutSize(
@@ -137,19 +140,35 @@ export const getTableContainerElementWidth = (table: PMNode) => {
137
140
  return getTableContainerWidth(table);
138
141
  };
139
142
 
140
- export const getTableScalingPercent = (table: PMNode, tableRef: HTMLElement | null) => {
143
+ export const getTableScalingPercent = (
144
+ table: PMNode,
145
+ tableRef: HTMLElement | null,
146
+ shouldUseIncreasedScalingPercent?: boolean,
147
+ ) => {
148
+ const maxScalingPercent = shouldUseIncreasedScalingPercent
149
+ ? MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION
150
+ : MAX_SCALING_PERCENT;
151
+
141
152
  const tableWidth = getTableContainerElementWidth(table);
142
153
  let renderWidth = tableRef?.parentElement?.clientWidth || tableWidth;
143
154
  // minus 1 here to avoid any 1px scroll in Firefox
144
155
  let scalePercent = (renderWidth - 1) / tableWidth;
145
- scalePercent = Math.max(scalePercent, 1 - MAX_SCALING_PERCENT);
156
+ scalePercent = Math.max(scalePercent, 1 - maxScalingPercent);
146
157
  return Math.min(scalePercent, 1);
147
158
  };
148
159
 
149
- export const getStaticTableScalingPercent = (table: PMNode, tableRenderWidth: number) => {
160
+ export const getStaticTableScalingPercent = (
161
+ table: PMNode,
162
+ tableRenderWidth: number,
163
+ shouldUseIncreasedScalingPercent?: boolean,
164
+ ) => {
165
+ const maxScalingPercent = shouldUseIncreasedScalingPercent
166
+ ? MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION
167
+ : MAX_SCALING_PERCENT;
168
+
150
169
  const tableWidth = getTableContainerElementWidth(table);
151
170
  // minus 1 here to avoid any 1px scroll in Firefox
152
171
  let scalePercent = (tableRenderWidth - 1) / tableWidth;
153
- scalePercent = Math.max(scalePercent, 1 - MAX_SCALING_PERCENT);
172
+ scalePercent = Math.max(scalePercent, 1 - maxScalingPercent);
154
173
  return Math.min(scalePercent, 1);
155
174
  };
@@ -16,12 +16,13 @@ export const resizeColumn = (
16
16
  tableNode: PmNode,
17
17
  selectedColumns?: number[],
18
18
  isTableScalingEnabled = false,
19
+ shouldUseIncreasedScalingPercent = false,
19
20
  ): ResizeState => {
20
21
  let scalePercent = 1;
21
22
  let resizeAmount = amount;
22
23
 
23
24
  if (isTableScalingEnabled) {
24
- scalePercent = getTableScalingPercent(tableNode, tableRef);
25
+ scalePercent = getTableScalingPercent(tableNode, tableRef, shouldUseIncreasedScalingPercent);
25
26
  resizeAmount = amount / scalePercent;
26
27
  }
27
28
 
@@ -32,7 +33,13 @@ export const resizeColumn = (
32
33
  ? shrinkColumn(resizeState, colIndex, resizeAmount, selectedColumns)
33
34
  : resizeState;
34
35
 
35
- updateColgroup(newState, tableRef, tableNode, isTableScalingEnabled);
36
+ updateColgroup(
37
+ newState,
38
+ tableRef,
39
+ tableNode,
40
+ isTableScalingEnabled,
41
+ shouldUseIncreasedScalingPercent,
42
+ );
36
43
 
37
44
  return newState;
38
45
  };
@@ -47,13 +54,13 @@ export const resizeColumnAndTable = (
47
54
  selectedColumns?: number[],
48
55
  isTableScalingEnabled = false,
49
56
  originalTableWidth?: number,
57
+ shouldUseIncreasedScalingPercent = false,
50
58
  ): ResizeState => {
51
59
  // TODO: can we use document state, and apply scaling factor?
52
60
  const tableWidth = tableRef.clientWidth;
53
61
  const tableContainerWidth = tableRef.closest('.pm-table-container')?.clientWidth;
54
62
 
55
63
  const isOverflowed = !!(tableWidth && tableContainerWidth && tableWidth > tableContainerWidth);
56
-
57
64
  let resizeAmount = amount * 2;
58
65
 
59
66
  // todo: reimplement - use getTableScalingPercentFrozen to get scaled percent before table width changes dynamically
@@ -84,7 +91,7 @@ export const resizeColumnAndTable = (
84
91
 
85
92
  // this function only updates the colgroup in DOM, it reverses the scalePercent
86
93
  // todo: change isScalingEnabled to true when reimplementing scaling
87
- updateColgroup(newState, tableRef, tableNode, false);
94
+ updateColgroup(newState, tableRef, tableNode, false, shouldUseIncreasedScalingPercent);
88
95
 
89
96
  // use the difference in width from affected column to update overall table width
90
97
  const delta = newState.cols[colIndex].width - resizeState.cols[colIndex].width;
@@ -24,6 +24,7 @@ export const getResizeState = ({
24
24
  start,
25
25
  domAtPos,
26
26
  isTableScalingEnabled = false,
27
+ shouldUseIncreasedScalingPercent = false,
27
28
  }: {
28
29
  minWidth: number;
29
30
  maxSize: number;
@@ -32,9 +33,10 @@ export const getResizeState = ({
32
33
  start: number;
33
34
  domAtPos: (pos: number) => { node: Node; offset: number };
34
35
  isTableScalingEnabled: boolean;
36
+ shouldUseIncreasedScalingPercent: boolean;
35
37
  }): ResizeState => {
36
38
  if (isTableScalingEnabled) {
37
- const scalePercent = getTableScalingPercent(table, tableRef);
39
+ const scalePercent = getTableScalingPercent(table, tableRef, shouldUseIncreasedScalingPercent);
38
40
  minWidth = Math.ceil(minWidth / scalePercent);
39
41
  }
40
42
  // If the table has been resized, we can use the column widths from the table node
@@ -67,6 +69,7 @@ export const getResizeState = ({
67
69
  table,
68
70
  isTableScalingEnabled,
69
71
  shouldReinsertColgroup, // don't reinsert colgroup when preserving table width - this causes widths to jump
72
+ shouldUseIncreasedScalingPercent,
70
73
  );
71
74
  const cols = Array.from(colgroupChildren).map((_, index) => {
72
75
  // If the table hasn't been resized and we have a table width attribute, we can use it
@@ -104,6 +107,7 @@ export const updateColgroup = (
104
107
  tableRef: HTMLElement | null,
105
108
  tableNode?: PMNode,
106
109
  isTableScalingEnabled?: boolean,
110
+ shouldUseIncreasedScalingPercent?: boolean,
107
111
  ): void => {
108
112
  const cols = tableRef?.querySelectorAll('col');
109
113
  const columnsCount = cols?.length;
@@ -113,7 +117,11 @@ export const updateColgroup = (
113
117
  We need to remove !isColumnResizing if we handled auto scale table when mouseUp event.
114
118
  * */
115
119
  if (isTableScalingEnabled && tableNode) {
116
- const scalePercent = getTableScalingPercent(tableNode, tableRef);
120
+ const scalePercent = getTableScalingPercent(
121
+ tableNode,
122
+ tableRef,
123
+ shouldUseIncreasedScalingPercent,
124
+ );
117
125
  state.cols
118
126
  .filter((column) => column && !!column.width) // if width is 0, we dont want to apply that.
119
127
  .forEach((column, i) => {
@@ -359,10 +367,10 @@ export const getNewResizeStateFromSelectedColumns = (
359
367
  let resizeState;
360
368
 
361
369
  let isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
362
- if (
363
- isTableScalingEnabled &&
364
- getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
365
- ) {
370
+
371
+ const isTableScalingEnabledWithLockButton =
372
+ isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
373
+ if (isTableScalingEnabledWithLockButton) {
366
374
  isTableScalingEnabledOnCurrentTable = table.node.attrs.displayMode !== 'fixed';
367
375
  }
368
376
 
@@ -374,6 +382,9 @@ export const getNewResizeStateFromSelectedColumns = (
374
382
  start: table.start,
375
383
  domAtPos,
376
384
  isTableScalingEnabled: isTableScalingEnabledOnCurrentTable,
385
+ shouldUseIncreasedScalingPercent:
386
+ isTableScalingEnabledWithLockButton &&
387
+ getBooleanFF('platform.editor.table.use-increased-scaling-percent'),
377
388
  });
378
389
 
379
390
  const newResizeState = evenSelectedColumnsWidths(resizeState, rect);
@@ -40,6 +40,7 @@ export const scale = (
40
40
  options: ScaleOptions,
41
41
  domAtPos: DomAtPos,
42
42
  isTableScalingEnabledOnCurrentTable = false,
43
+ shouldUseIncreasedScalingPercent = false,
43
44
  ): ResizeState | undefined => {
44
45
  const {
45
46
  node,
@@ -89,6 +90,7 @@ export const scale = (
89
90
  start,
90
91
  domAtPos,
91
92
  isTableScalingEnabled: isTableScalingEnabledOnCurrentTable,
93
+ shouldUseIncreasedScalingPercent,
92
94
  });
93
95
 
94
96
  return scaleTableTo(resizeState, newWidth);
@@ -101,6 +103,7 @@ export const scaleWithParent = (
101
103
  start: number,
102
104
  domAtPos: DomAtPos,
103
105
  isTableScalingEnabledOnCurrentTable = false,
106
+ shouldUseIncreasedScalingPercent = false,
104
107
  ) => {
105
108
  const resizeState = getResizeState({
106
109
  minWidth: tableCellMinWidth,
@@ -110,6 +113,7 @@ export const scaleWithParent = (
110
113
  start,
111
114
  domAtPos,
112
115
  isTableScalingEnabled: isTableScalingEnabledOnCurrentTable,
116
+ shouldUseIncreasedScalingPercent,
113
117
  });
114
118
 
115
119
  if (table.attrs.isNumberColumnEnabled) {
@@ -165,10 +169,9 @@ export const previewScaleTable = (
165
169
  }
166
170
 
167
171
  let isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
168
- if (
169
- isTableScalingEnabled &&
170
- getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
171
- ) {
172
+ const isTableScalingEnabledWithLockButton =
173
+ isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
174
+ if (isTableScalingEnabledWithLockButton) {
172
175
  isTableScalingEnabledOnCurrentTable =
173
176
  isTableScalingEnabled && node.attrs.displayMode !== 'fixed';
174
177
  }
@@ -179,12 +182,24 @@ export const previewScaleTable = (
179
182
  return;
180
183
  }
181
184
 
185
+ const shouldUseIncreasedScalingPercent =
186
+ isTableScalingEnabledWithLockButton &&
187
+ getBooleanFF('platform.editor.table.use-increased-scaling-percent');
188
+
182
189
  const resizeState = parentWidth
183
- ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos, false) // Here last value is isTableScalingEnabled = false
184
- : scale(tableRef, options, domAtPos, false);
190
+ ? scaleWithParent(
191
+ tableRef,
192
+ parentWidth,
193
+ node,
194
+ start,
195
+ domAtPos,
196
+ false, // Here isTableScalingEnabled = false
197
+ shouldUseIncreasedScalingPercent,
198
+ )
199
+ : scale(tableRef, options, domAtPos, false, shouldUseIncreasedScalingPercent);
185
200
 
186
201
  if (resizeState) {
187
- updateColgroup(resizeState, tableRef, node, false);
202
+ updateColgroup(resizeState, tableRef, node, false, shouldUseIncreasedScalingPercent);
188
203
  }
189
204
  };
190
205
 
@@ -195,6 +210,7 @@ export const scaleTable =
195
210
  options: ScaleOptions,
196
211
  domAtPos: DomAtPos,
197
212
  isTableScalingEnabledOnCurrentTable = false,
213
+ shouldUseIncreasedScalingPercent = false,
198
214
  ) =>
199
215
  (tr: Transaction) => {
200
216
  if (!tableRef) {
@@ -207,7 +223,7 @@ export const scaleTable =
207
223
  // If its not a re-sized table, we still want to re-create cols
208
224
  // To force reflow of columns upon delete.
209
225
  if (!isTableScalingEnabledOnCurrentTable) {
210
- insertColgroupFromNode(tableRef, node);
226
+ insertColgroupFromNode(tableRef, node, false, undefined, shouldUseIncreasedScalingPercent);
211
227
  }
212
228
  tr.setMeta('scrollIntoView', false);
213
229
  return tr;
@@ -222,9 +238,16 @@ export const scaleTable =
222
238
  start,
223
239
  domAtPos,
224
240
  isTableScalingEnabledOnCurrentTable,
241
+ shouldUseIncreasedScalingPercent,
225
242
  );
226
243
  } else {
227
- resizeState = scale(tableRef, options, domAtPos, isTableScalingEnabledOnCurrentTable);
244
+ resizeState = scale(
245
+ tableRef,
246
+ options,
247
+ domAtPos,
248
+ isTableScalingEnabledOnCurrentTable,
249
+ shouldUseIncreasedScalingPercent,
250
+ );
228
251
  }
229
252
 
230
253
  if (resizeState) {
package/src/toolbar.tsx CHANGED
@@ -180,6 +180,7 @@ export const getToolbarCellOptionsConfig = (
180
180
  getEditorContainerWidth: GetEditorContainerWidth,
181
181
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
182
182
  isTableScalingEnabled = false,
183
+ shouldUseIncreasedScalingPercent = false,
183
184
  ): FloatingToolbarDropdown<Command> => {
184
185
  const { top, bottom, right, left } = initialSelectionRect;
185
186
  const numberOfColumns = right - left;
@@ -194,10 +195,11 @@ export const getToolbarCellOptionsConfig = (
194
195
  const selectionRect = getClosestSelectionRect(state);
195
196
  const index = selectionRect?.right;
196
197
  if (index) {
197
- insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled)(
198
- INPUT_METHOD.FLOATING_TB,
199
- index,
200
- )(state, dispatch, view);
198
+ insertColumnWithAnalytics(
199
+ editorAnalyticsAPI,
200
+ isTableScalingEnabled,
201
+ shouldUseIncreasedScalingPercent,
202
+ )(INPUT_METHOD.FLOATING_TB, index)(state, dispatch, view);
201
203
  }
202
204
  return true;
203
205
  },
@@ -231,11 +233,11 @@ export const getToolbarCellOptionsConfig = (
231
233
  onClick: (state: EditorState, dispatch?: CommandDispatch, view?: EditorView) => {
232
234
  const selectionRect = getClosestSelectionRect(state);
233
235
  if (selectionRect) {
234
- deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, selectionRect)(
235
- state,
236
- dispatch,
237
- view,
238
- );
236
+ deleteColumnsWithAnalytics(
237
+ editorAnalyticsAPI,
238
+ isTableScalingEnabled,
239
+ shouldUseIncreasedScalingPercent,
240
+ )(INPUT_METHOD.FLOATING_TB, selectionRect)(state, dispatch, view);
239
241
  }
240
242
  return true;
241
243
  },
@@ -432,6 +434,7 @@ export const getToolbarConfig =
432
434
  getEditorFeatureFlags: GetEditorFeatureFlags,
433
435
  getEditorView: () => EditorView | null,
434
436
  options?: TablePluginOptions,
437
+ shouldUseIncreasedScalingPercent = false,
435
438
  ) =>
436
439
  (config: PluginConfig): FloatingToolbarHandler =>
437
440
  (state, intl) => {
@@ -465,6 +468,7 @@ export const getToolbarConfig =
465
468
  getEditorContainerWidth,
466
469
  editorAnalyticsAPI,
467
470
  options?.isTableScalingEnabled,
471
+ shouldUseIncreasedScalingPercent,
468
472
  );
469
473
 
470
474
  let columnSettingsItems;
@@ -589,6 +593,7 @@ const getCellItems = (
589
593
  getEditorContainerWidth: GetEditorContainerWidth,
590
594
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
591
595
  isTableScalingEnabled = false,
596
+ shouldUseIncreasedScalingPercent = false,
592
597
  ): Array<FloatingToolbarItem<Command>> => {
593
598
  const initialSelectionRect = getClosestSelectionRect(state);
594
599
  if (initialSelectionRect) {
@@ -600,6 +605,7 @@ const getCellItems = (
600
605
  getEditorContainerWidth,
601
606
  editorAnalyticsAPI,
602
607
  isTableScalingEnabled,
608
+ shouldUseIncreasedScalingPercent,
603
609
  );
604
610
  return [cellOptions, separator(cellOptions.hidden!)];
605
611
  }
@@ -104,7 +104,7 @@ 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) =>
107
+ (isTableScalingEnabled = false, shouldUseIncreasedScalingPercent = false) =>
108
108
  (table: ContentNodeWithPos, view: EditorView | undefined) =>
109
109
  (tr: Transaction): Transaction => {
110
110
  if (!view) {
@@ -206,6 +206,7 @@ export const rescaleColumns =
206
206
  domAtPos,
207
207
  maxSize: previousTableInfo.possibleMaxWidth,
208
208
  isTableScalingEnabled: shouldScale,
209
+ shouldUseIncreasedScalingPercent,
209
210
  });
210
211
 
211
212
  // Two scenarios that require scaling:
@@ -240,7 +240,13 @@ function fixRowSpans(table: PMNode): PMNode | null {
240
240
  }
241
241
 
242
242
  export const deleteColumns =
243
- (rect: Rect, allowCustomStep: boolean, view?: EditorView, isTableScalingEnabled = false) =>
243
+ (
244
+ rect: Rect,
245
+ allowCustomStep: boolean,
246
+ view?: EditorView,
247
+ isTableScalingEnabled = false,
248
+ shouldUseIncreasedScalingPercent = false,
249
+ ) =>
244
250
  (tr: Transaction) => {
245
251
  let updatedTr = tr;
246
252
  updatedTr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
@@ -255,7 +261,10 @@ export const deleteColumns =
255
261
  const table = findTable(updatedTr.selection);
256
262
 
257
263
  if (table) {
258
- updatedTr = rescaleColumns(isTableScalingEnabled)(table, view)(updatedTr);
264
+ updatedTr = rescaleColumns(isTableScalingEnabled, shouldUseIncreasedScalingPercent)(
265
+ table,
266
+ view,
267
+ )(updatedTr);
259
268
  }
260
269
  return updatedTr;
261
270
  };
@@ -35,6 +35,7 @@ import { splitCell } from '@atlaskit/editor-tables/utils';
35
35
  import CrossCircleIcon from '@atlaskit/icon/glyph/cross-circle';
36
36
  import EditorBackgroundColorIcon from '@atlaskit/icon/glyph/editor/background-color';
37
37
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
38
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
38
39
 
39
40
  import {
40
41
  clearHoverSelection,
@@ -510,6 +511,11 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
510
511
  ? getEditorFeatureFlags()
511
512
  : {};
512
513
 
514
+ const shouldUseIncreasedScalingPercent =
515
+ isTableScalingEnabled &&
516
+ getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') &&
517
+ getBooleanFF('platform.editor.table.use-increased-scaling-percent');
518
+
513
519
  switch (item.value.name) {
514
520
  case 'sort_column_desc':
515
521
  sortColumnWithAnalytics(editorAnalyticsAPI)(
@@ -564,6 +570,7 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
564
570
  editorAnalyticsAPI,
565
571
  isTableScalingEnabled,
566
572
  tableDuplicateCellColouring,
573
+ shouldUseIncreasedScalingPercent,
567
574
  )(INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(state, dispatch, editorView);
568
575
  this.toggleOpen();
569
576
  break;
@@ -578,11 +585,11 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
578
585
  this.toggleOpen();
579
586
  break;
580
587
  case 'delete_column':
581
- deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, selectionRect)(
582
- state,
583
- dispatch,
584
- editorView,
585
- );
588
+ deleteColumnsWithAnalytics(
589
+ editorAnalyticsAPI,
590
+ isTableScalingEnabled,
591
+ shouldUseIncreasedScalingPercent,
592
+ )(INPUT_METHOD.CONTEXT_MENU, selectionRect)(state, dispatch, editorView);
586
593
  this.toggleOpen();
587
594
  break;
588
595
  case 'delete_row':
@@ -93,6 +93,7 @@ type DragMenuProps = {
93
93
  scrollableElement?: HTMLElement;
94
94
  isTableScalingEnabled?: boolean;
95
95
  tableDuplicateCellColouring?: boolean;
96
+ shouldUseIncreasedScalingPercent?: boolean;
96
97
  };
97
98
 
98
99
  type PluralOptionType = 'noOfCols' | 'noOfRows' | 'noOfCells' | null;
@@ -261,6 +262,7 @@ export const DragMenu = React.memo(
261
262
  boundariesElement,
262
263
  isTableScalingEnabled,
263
264
  tableDuplicateCellColouring,
265
+ shouldUseIncreasedScalingPercent,
264
266
  }: DragMenuProps & WrappedComponentProps) => {
265
267
  const { state, dispatch } = editorView;
266
268
  const { selection } = state;
@@ -301,6 +303,7 @@ export const DragMenu = React.memo(
301
303
  pluginConfig?.isHeaderRowRequired,
302
304
  isTableScalingEnabled,
303
305
  tableDuplicateCellColouring,
306
+ shouldUseIncreasedScalingPercent,
304
307
  );
305
308
 
306
309
  const { menuItems, menuCallback } = convertToDropdownItems(
@@ -10,6 +10,7 @@ import {
10
10
  akEditorFloatingOverlapPanelZIndex,
11
11
  } from '@atlaskit/editor-shared-styles';
12
12
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
13
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
13
14
 
14
15
  import type { RowStickyState } from '../../pm-plugins/sticky-headers';
15
16
  import type { PluginConfig, TableDirection } from '../../types';
@@ -73,6 +74,11 @@ const FloatingDragMenu = ({
73
74
  ? getEditorFeatureFlags()
74
75
  : {};
75
76
 
77
+ const shouldUseIncreasedScalingPercent =
78
+ isTableScalingEnabled &&
79
+ getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') &&
80
+ getBooleanFF('platform.editor.table.use-increased-scaling-percent');
81
+
76
82
  return (
77
83
  <Popup
78
84
  alignX={direction === 'row' ? 'right' : undefined}
@@ -109,6 +115,7 @@ const FloatingDragMenu = ({
109
115
  scrollableElement={scrollableElement}
110
116
  isTableScalingEnabled={isTableScalingEnabled}
111
117
  tableDuplicateCellColouring={tableDuplicateCellColouring}
118
+ shouldUseIncreasedScalingPercent={shouldUseIncreasedScalingPercent}
112
119
  />
113
120
  </Popup>
114
121
  );
@@ -25,6 +25,7 @@ import { akEditorTableCellOnStickyHeaderZIndex } from '@atlaskit/editor-shared-s
25
25
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
26
26
  import { TableMap } from '@atlaskit/editor-tables/table-map';
27
27
  import { findTable } from '@atlaskit/editor-tables/utils';
28
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
28
29
 
29
30
  import { insertColumnWithAnalytics, insertRowWithAnalytics } from '../../commands-with-analytics';
30
31
  import { getPluginState } from '../../pm-plugins/plugin-factory';
@@ -263,6 +264,11 @@ export class FloatingInsertButton extends React.Component<Props & WrappedCompone
263
264
 
264
265
  const { isTableScalingEnabled = false } = getPluginState(editorView.state);
265
266
 
267
+ const shouldUseIncreasedScalingPercent =
268
+ isTableScalingEnabled &&
269
+ getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') &&
270
+ getBooleanFF('platform.editor.table.use-increased-scaling-percent');
271
+
266
272
  const { tableDuplicateCellColouring = false } = getEditorFeatureFlags
267
273
  ? getEditorFeatureFlags()
268
274
  : {};
@@ -272,6 +278,7 @@ export class FloatingInsertButton extends React.Component<Props & WrappedCompone
272
278
  editorAnalyticsAPI,
273
279
  isTableScalingEnabled,
274
280
  tableDuplicateCellColouring,
281
+ shouldUseIncreasedScalingPercent,
275
282
  )(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
276
283
  }
277
284
  }
@@ -149,22 +149,24 @@ export const TableFloatingControls = ({
149
149
  <>
150
150
  {isDragAndDropEnabled ? (
151
151
  <>
152
- {getBooleanFF('platform.editor.table.use-shared-state-hook') ? (
153
- <DragCornerControlsWithSelection
154
- editorView={editorView}
155
- tableRef={tableRef}
156
- isInDanger={isInDanger}
157
- isResizing={isResizing}
158
- api={api}
159
- />
160
- ) : (
161
- <DragCornerControls
162
- editorView={editorView}
163
- tableRef={tableRef}
164
- isInDanger={isInDanger}
165
- isResizing={isResizing}
166
- />
167
- )}
152
+ {!getBooleanFF('platform.editor.drag-and-drop_wmv9t') &&
153
+ (getBooleanFF('platform.editor.table.use-shared-state-hook') ? (
154
+ <DragCornerControlsWithSelection
155
+ editorView={editorView}
156
+ tableRef={tableRef}
157
+ isInDanger={isInDanger}
158
+ isResizing={isResizing}
159
+ api={api}
160
+ />
161
+ ) : (
162
+ <DragCornerControls
163
+ editorView={editorView}
164
+ tableRef={tableRef}
165
+ isInDanger={isInDanger}
166
+ isResizing={isResizing}
167
+ />
168
+
169
+ ))}
168
170
  <DragControls
169
171
  tableRef={tableRef}
170
172
  tableNode={tableNode}
@@ -160,6 +160,7 @@ export const getDragMenuConfig = (
160
160
  isHeaderRowRequired?: boolean,
161
161
  isTableScalingEnabled = false,
162
162
  tableDuplicateCellColouring = false,
163
+ shouldUseIncreasedScalingPercent = false,
163
164
  ): DragMenuConfig[] => {
164
165
  const addOptions =
165
166
  direction === 'row'
@@ -271,6 +272,7 @@ export const getDragMenuConfig = (
271
272
  editorAnalyticsAPI,
272
273
  isTableScalingEnabled,
273
274
  tableDuplicateCellColouring,
275
+ shouldUseIncreasedScalingPercent,
274
276
  )(INPUT_METHOD.TABLE_CONTEXT_MENU, (index ?? 0) + offset)(state, dispatch, editorView);
275
277
  }
276
278
  return true;