@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
@@ -5,13 +5,14 @@ import { deleteColumns } from '../transforms/delete-columns';
5
5
  import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
6
6
 
7
7
  export const deleteColumnsCommand =
8
- (rect: Rect, isTableScalingEnabled = false): Command =>
8
+ (rect: Rect, isTableScalingEnabled = false, shouldUseIncreasedScalingPercent = false): Command =>
9
9
  (state, dispatch, view) => {
10
10
  const tr = deleteColumns(
11
11
  rect,
12
12
  getAllowAddColumnCustomStep(state),
13
13
  view,
14
14
  isTableScalingEnabled,
15
+ shouldUseIncreasedScalingPercent,
15
16
  )(state.tr);
16
17
  if (dispatch) {
17
18
  dispatch(tr);
@@ -38,7 +38,11 @@ function addColumnAtCustomStep(column: number) {
38
38
  };
39
39
  }
40
40
 
41
- export function addColumnAt(isTableScalingEnabled = false, isCellBackgroundDuplicated?: boolean) {
41
+ export function addColumnAt(
42
+ isTableScalingEnabled = false,
43
+ isCellBackgroundDuplicated?: boolean,
44
+ shouldUseIncreasedScalingPercent?: boolean,
45
+ ) {
42
46
  return (
43
47
  column: number,
44
48
  allowAddColumnCustomStep: boolean = false,
@@ -54,7 +58,10 @@ export function addColumnAt(isTableScalingEnabled = false, isCellBackgroundDupli
54
58
  const table = findTable(updatedTr.selection);
55
59
  if (table) {
56
60
  // [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
57
- updatedTr = rescaleColumns(isTableScalingEnabled)(table, view)(updatedTr);
61
+ updatedTr = rescaleColumns(isTableScalingEnabled, shouldUseIncreasedScalingPercent)(
62
+ table,
63
+ view,
64
+ )(updatedTr);
58
65
  }
59
66
 
60
67
  if (view) {
@@ -76,7 +83,7 @@ export function addColumnAt(isTableScalingEnabled = false, isCellBackgroundDupli
76
83
  // :: (EditorState, dispatch: ?(tr: Transaction)) → bool
77
84
  // Command to add a column before the column with the selection.
78
85
  export const addColumnBefore =
79
- (isTableScalingEnabled = false): Command =>
86
+ (isTableScalingEnabled = false, shouldUseIncreasedScalingPercent = false): Command =>
80
87
  (state, dispatch, view) => {
81
88
  const table = findTable(state.selection);
82
89
  if (!table) {
@@ -85,9 +92,11 @@ export const addColumnBefore =
85
92
  if (dispatch) {
86
93
  let rect = selectedRect(state);
87
94
  dispatch(
88
- addColumnAt(isTableScalingEnabled)(rect.left, getAllowAddColumnCustomStep(state), view)(
89
- state.tr,
90
- ),
95
+ addColumnAt(isTableScalingEnabled, shouldUseIncreasedScalingPercent)(
96
+ rect.left,
97
+ getAllowAddColumnCustomStep(state),
98
+ view,
99
+ )(state.tr),
91
100
  );
92
101
  }
93
102
  return true;
@@ -96,7 +105,7 @@ export const addColumnBefore =
96
105
  // :: (EditorState, dispatch: ?(tr: Transaction)) → bool
97
106
  // Command to add a column after the column with the selection.
98
107
  export const addColumnAfter =
99
- (isTableScalingEnabled?: boolean): Command =>
108
+ (isTableScalingEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean): Command =>
100
109
  (state, dispatch, view) => {
101
110
  const table = findTable(state.selection);
102
111
  if (!table) {
@@ -105,19 +114,29 @@ export const addColumnAfter =
105
114
  if (dispatch) {
106
115
  let rect = selectedRect(state);
107
116
  dispatch(
108
- addColumnAt(isTableScalingEnabled)(rect.right, getAllowAddColumnCustomStep(state), view)(
109
- state.tr,
110
- ),
117
+ addColumnAt(isTableScalingEnabled, shouldUseIncreasedScalingPercent)(
118
+ rect.right,
119
+ getAllowAddColumnCustomStep(state),
120
+ view,
121
+ )(state.tr),
111
122
  );
112
123
  }
113
124
  return true;
114
125
  };
115
126
 
116
127
  export const insertColumn =
117
- (isTableScalingEnabled = false, isCellBackgroundDuplicated?: boolean) =>
128
+ (
129
+ isTableScalingEnabled = false,
130
+ isCellBackgroundDuplicated?: boolean,
131
+ shouldUseIncreasedScalingPercent?: boolean,
132
+ ) =>
118
133
  (column: number): Command =>
119
134
  (state, dispatch, view) => {
120
- let tr = addColumnAt(isTableScalingEnabled, isCellBackgroundDuplicated)(
135
+ let tr = addColumnAt(
136
+ isTableScalingEnabled,
137
+ isCellBackgroundDuplicated,
138
+ shouldUseIncreasedScalingPercent,
139
+ )(
121
140
  column,
122
141
  getAllowAddColumnCustomStep(state),
123
142
  view,
@@ -276,6 +276,7 @@ export const insertColumnWithAnalytics =
276
276
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
277
277
  isTableScalingEnabled = false,
278
278
  isCellbackgroundDuplicated = false,
279
+ shouldUseIncreasedScalingPercent = false,
279
280
  ) =>
280
281
  (
281
282
  inputMethod:
@@ -301,7 +302,11 @@ export const insertColumnWithAnalytics =
301
302
  eventType: EVENT_TYPE.TRACK,
302
303
  };
303
304
  })(editorAnalyticsAPI)(
304
- insertColumn(isTableScalingEnabled, isCellbackgroundDuplicated)(position),
305
+ insertColumn(
306
+ isTableScalingEnabled,
307
+ isCellbackgroundDuplicated,
308
+ shouldUseIncreasedScalingPercent,
309
+ )(position),
305
310
  );
306
311
 
307
312
  export const deleteRowsWithAnalytics =
@@ -340,7 +345,11 @@ export const deleteRowsWithAnalytics =
340
345
  });
341
346
 
342
347
  export const deleteColumnsWithAnalytics =
343
- (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled = false) =>
348
+ (
349
+ editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
350
+ isTableScalingEnabled = false,
351
+ shouldUseIncreasedScalingPercent = false,
352
+ ) =>
344
353
  (
345
354
  inputMethod:
346
355
  | INPUT_METHOD.CONTEXT_MENU
@@ -366,10 +375,16 @@ export const deleteColumnsWithAnalytics =
366
375
  },
367
376
  eventType: EVENT_TYPE.TRACK,
368
377
  };
369
- })(editorAnalyticsAPI)(deleteColumnsCommand(rect, isTableScalingEnabled));
378
+ })(editorAnalyticsAPI)(
379
+ deleteColumnsCommand(rect, isTableScalingEnabled, shouldUseIncreasedScalingPercent),
380
+ );
370
381
 
371
382
  export const deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut =
372
- (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null): Command =>
383
+ (
384
+ editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
385
+ isTableScalingEnabled?: boolean,
386
+ shouldUseIncreasedScalingPercent?: boolean,
387
+ ): Command =>
373
388
  (state, dispatch) => {
374
389
  const { selection } = state;
375
390
  const isCellSelection = selection instanceof CellSelection;
@@ -393,10 +408,11 @@ export const deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut =
393
408
  isHeaderRowRequired,
394
409
  )(state, dispatch);
395
410
  } else if (selectionType === 'column') {
396
- return deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT, rect)(
397
- state,
398
- dispatch,
399
- );
411
+ return deleteColumnsWithAnalytics(
412
+ editorAnalyticsAPI,
413
+ isTableScalingEnabled,
414
+ shouldUseIncreasedScalingPercent,
415
+ )(INPUT_METHOD.SHORTCUT, rect)(state, dispatch);
400
416
  } else {
401
417
  return false;
402
418
  }
@@ -477,6 +477,7 @@ export const handleCut = (
477
477
  editorAnalyticsAPI?: EditorAnalyticsAPI,
478
478
  editorView?: EditorView,
479
479
  isTableScalingEnabled = false,
480
+ shouldUseIncreasedScalingPercent = false,
480
481
  ): Transaction => {
481
482
  const oldSelection = oldState.tr.selection;
482
483
  let { tr } = newState;
@@ -524,6 +525,7 @@ export const handleCut = (
524
525
  getAllowAddColumnCustomStep(oldState),
525
526
  editorView,
526
527
  isTableScalingEnabled,
528
+ shouldUseIncreasedScalingPercent,
527
529
  )(tr);
528
530
  }
529
531
  }
@@ -383,6 +383,15 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
383
383
  isNumberColumnChanged ||
384
384
  isNumberOfColumnsChanged;
385
385
 
386
+ const isTableScalingEnabledWithLockButton =
387
+ this.props.options?.isTableScalingEnabled &&
388
+ getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
389
+
390
+ const shouldUseIncreasedScalingPercent =
391
+ (isTableScalingEnabledWithLockButton &&
392
+ getBooleanFF('platform.editor.table.use-increased-scaling-percent')) ||
393
+ false;
394
+
386
395
  if (force || (!isResizing && shouldUpdateColgroup)) {
387
396
  const resizeState = getResizeState({
388
397
  minWidth: COLUMN_MIN_WIDTH,
@@ -392,6 +401,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
392
401
  start,
393
402
  domAtPos: view.domAtPos.bind(view),
394
403
  isTableScalingEnabled: true,
404
+ shouldUseIncreasedScalingPercent,
395
405
  });
396
406
 
397
407
  let shouldScaleOnColgroupUpdate = false;
@@ -402,17 +412,19 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
402
412
  shouldScaleOnColgroupUpdate = true;
403
413
  }
404
414
 
405
- if (
406
- this.props.options?.isTableScalingEnabled &&
407
- getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') &&
408
- tableNode.attrs.displayMode !== 'fixed'
409
- ) {
415
+ if (isTableScalingEnabledWithLockButton && tableNode.attrs.displayMode !== 'fixed') {
410
416
  shouldScaleOnColgroupUpdate = true;
411
417
  }
412
418
 
413
419
  // Request animation frame required for Firefox
414
420
  requestAnimationFrame(() => {
415
- updateColgroup(resizeState, this.table!, tableNode, shouldScaleOnColgroupUpdate);
421
+ updateColgroup(
422
+ resizeState,
423
+ this.table!,
424
+ tableNode,
425
+ shouldScaleOnColgroupUpdate,
426
+ shouldUseIncreasedScalingPercent,
427
+ );
416
428
  });
417
429
  }
418
430
  }
@@ -452,11 +464,14 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
452
464
  shouldHandleColgroupUpdates = true;
453
465
  }
454
466
 
455
- if (
467
+ const isTableScalingEnabledWithLockButton =
456
468
  isTableScalingEnabled &&
457
- getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') &&
458
- getNode().attrs.displayMode !== 'fixed'
459
- ) {
469
+ getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
470
+ const shouldUseIncreasedScalingPercent =
471
+ isTableScalingEnabledWithLockButton &&
472
+ getBooleanFF('platform.editor.table.use-increased-scaling-percent');
473
+
474
+ if (isTableScalingEnabledWithLockButton && getNode().attrs.displayMode !== 'fixed') {
460
475
  shouldScale = true;
461
476
  shouldHandleColgroupUpdates = true;
462
477
  }
@@ -523,7 +538,13 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
523
538
  const depth = view.state.doc.resolve(start).depth;
524
539
  shouldScale = depth === 0 && shouldScale;
525
540
 
526
- insertColgroupFromNode(this.table, currentTable, shouldScale);
541
+ insertColgroupFromNode(
542
+ this.table,
543
+ currentTable,
544
+ shouldScale,
545
+ undefined,
546
+ shouldUseIncreasedScalingPercent,
547
+ );
527
548
  }
528
549
 
529
550
  updateControls()(view.state);
@@ -724,6 +745,11 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
724
745
 
725
746
  const { stickyScrollbar } = getEditorFeatureFlags();
726
747
 
748
+ const shouldUseIncreasedScalingPercent =
749
+ isTableScalingEnabled &&
750
+ getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') &&
751
+ getBooleanFF('platform.editor.table.use-increased-scaling-percent');
752
+
727
753
  return (
728
754
  <TableContainer
729
755
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -746,6 +772,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
746
772
  isTableScalingEnabled={isTableScalingEnabled}
747
773
  isWholeTableInDanger={isWholeTableInDanger}
748
774
  isTableAlignmentEnabled={isTableAlignmentEnabled}
775
+ shouldUseIncreasedScalingPercent={shouldUseIncreasedScalingPercent}
749
776
  >
750
777
  <div
751
778
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -961,6 +988,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
961
988
  this.layoutSize = layoutSize;
962
989
  };
963
990
 
991
+ // Function gets called when table is nested.
964
992
  private scaleTable = (scaleOptions: { parentWidth?: number }) => {
965
993
  const { view, getNode, getPos, containerWidth, options } = this.props;
966
994
  const node = getNode();
@@ -987,7 +1015,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
987
1015
  ...options,
988
1016
  },
989
1017
  domAtPos,
990
- false,
1018
+ false, // isTableScalingEnabled doesn't change the behavior of nested tables
1019
+ false, // shouldUseIncreasedScalingPercent set to false for nested tables
991
1020
  )(state.tr);
992
1021
 
993
1022
  dispatch(tr);
@@ -162,6 +162,7 @@ type ResizableTableContainerProps = {
162
162
 
163
163
  isTableScalingEnabled?: boolean;
164
164
  isTableAlignmentEnabled?: boolean;
165
+ shouldUseIncreasedScalingPercent?: boolean;
165
166
  };
166
167
 
167
168
  export const ResizableTableContainer = React.memo(
@@ -180,6 +181,7 @@ export const ResizableTableContainer = React.memo(
180
181
  isWholeTableInDanger,
181
182
  isTableScalingEnabled,
182
183
  isTableAlignmentEnabled,
184
+ shouldUseIncreasedScalingPercent,
183
185
  }: PropsWithChildren<ResizableTableContainerProps>) => {
184
186
  const containerRef = useRef<HTMLDivElement | null>(null);
185
187
  const tableWidthRef = useRef<number>(akEditorDefaultLayoutWidth);
@@ -308,6 +310,7 @@ export const ResizableTableContainer = React.memo(
308
310
  isFullWidthModeEnabled,
309
311
  isTableScalingEnabled,
310
312
  isWholeTableInDanger,
313
+ shouldUseIncreasedScalingPercent,
311
314
  pluginInjectionApi,
312
315
  onResizeStart,
313
316
  onResizeStop,
@@ -373,6 +376,7 @@ type TableContainerProps = {
373
376
  isTableResizingEnabled: boolean | undefined;
374
377
  isTableScalingEnabled?: boolean;
375
378
  isTableAlignmentEnabled?: boolean;
379
+ shouldUseIncreasedScalingPercent?: boolean;
376
380
  };
377
381
 
378
382
  export const TableContainer = ({
@@ -391,6 +395,7 @@ export const TableContainer = ({
391
395
  isTableResizingEnabled,
392
396
  isTableScalingEnabled,
393
397
  isTableAlignmentEnabled,
398
+ shouldUseIncreasedScalingPercent,
394
399
  }: PropsWithChildren<TableContainerProps>) => {
395
400
  if (isTableResizingEnabled && !isNested) {
396
401
  return (
@@ -409,6 +414,7 @@ export const TableContainer = ({
409
414
  isTableScalingEnabled={isTableScalingEnabled}
410
415
  isWholeTableInDanger={isWholeTableInDanger}
411
416
  isTableAlignmentEnabled={isTableAlignmentEnabled}
417
+ shouldUseIncreasedScalingPercent={shouldUseIncreasedScalingPercent}
412
418
  >
413
419
  {children}
414
420
  </ResizableTableContainer>
@@ -76,6 +76,7 @@ interface TableResizerProps {
76
76
  isTableAlignmentEnabled?: boolean;
77
77
  isWholeTableInDanger?: boolean;
78
78
  isFullWidthModeEnabled?: boolean;
79
+ shouldUseIncreasedScalingPercent?: boolean;
79
80
  }
80
81
 
81
82
  export interface TableResizerImprovementProps extends TableResizerProps {
@@ -189,6 +190,7 @@ export const TableResizer = ({
189
190
  isTableScalingEnabled,
190
191
  isTableAlignmentEnabled,
191
192
  isWholeTableInDanger,
193
+ shouldUseIncreasedScalingPercent,
192
194
  pluginInjectionApi,
193
195
  isFullWidthModeEnabled,
194
196
  }: PropsWithChildren<TableResizerImprovementProps>) => {
@@ -517,6 +519,7 @@ export const TableResizer = ({
517
519
  },
518
520
  editorView.domAtPos.bind(editorView),
519
521
  isTableScalingEnabled,
522
+ shouldUseIncreasedScalingPercent || false,
520
523
  )(tr);
521
524
 
522
525
  const scaledNode = tr.doc.nodeAt(pos)!;
@@ -571,6 +574,7 @@ export const TableResizer = ({
571
574
  endMeasure,
572
575
  onResizeStop,
573
576
  isTableScalingEnabled,
577
+ shouldUseIncreasedScalingPercent,
574
578
  widthToWidest,
575
579
  formatMessage,
576
580
  pluginInjectionApi,
package/src/plugin.tsx CHANGED
@@ -153,6 +153,11 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
153
153
  };
154
154
  const editorAnalyticsAPI = api?.analytics?.actions;
155
155
 
156
+ const shouldUseIncreasedScalingPercent =
157
+ options?.isTableScalingEnabled &&
158
+ getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') &&
159
+ getBooleanFF('platform.editor.table.use-increased-scaling-percent');
160
+
156
161
  return {
157
162
  name: 'table',
158
163
 
@@ -278,6 +283,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
278
283
  api,
279
284
  isTableScalingEnabled,
280
285
  isTableAlignmentEnabled,
286
+ shouldUseIncreasedScalingPercent,
281
287
  );
282
288
  },
283
289
  },
@@ -313,6 +319,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
313
319
  isTableAlignmentEnabled = false,
314
320
  fullWidthEnabled = false,
315
321
  } = options || ({} as TablePluginOptions);
322
+
316
323
  return keymapPlugin(
317
324
  defaultGetEditorContainerWidth,
318
325
  editorAnalyticsAPI,
@@ -322,6 +329,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
322
329
  fullWidthEnabled,
323
330
  api,
324
331
  getIntl,
332
+ shouldUseIncreasedScalingPercent,
325
333
  );
326
334
  },
327
335
  },
@@ -652,6 +660,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
652
660
  options?.getEditorFeatureFlags || defaultGetEditorFeatureFlags,
653
661
  () => editorViewRef.current,
654
662
  options,
663
+ shouldUseIncreasedScalingPercent,
655
664
  )(pluginConfig(options?.tableOptions)),
656
665
  },
657
666
  };
@@ -214,14 +214,23 @@ const destroyFn = (editorView: EditorView, editorAnalyticsAPI: any) => {
214
214
  const { isTableScalingEnabled = false } = getTablePluginState(editorView.state);
215
215
 
216
216
  let isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
217
- if (
217
+ const isTableScalingEnabledWithLockButton =
218
218
  isTableScalingEnabled &&
219
- getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
220
- ) {
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) {
221
225
  isTableScalingEnabledOnCurrentTable = tableNode.attrs.displayMode !== 'fixed';
222
226
  }
223
227
 
224
- insertColgroupFromNode(tableRef, tableNode, isTableScalingEnabledOnCurrentTable);
228
+ insertColgroupFromNode(
229
+ tableRef,
230
+ tableNode,
231
+ isTableScalingEnabledOnCurrentTable,
232
+ shouldUseIncreasedScalingPercent,
233
+ );
225
234
  }
226
235
  }
227
236
 
@@ -61,6 +61,7 @@ export function keymapPlugin(
61
61
  isFullWidthEnabled?: boolean,
62
62
  pluginInjectionApi?: PluginInjectionAPIWithA11y,
63
63
  getIntl?: () => IntlShape,
64
+ shouldUseIncreasedScalingPercent?: boolean,
64
65
  ): SafePlugin {
65
66
  const list = {};
66
67
 
@@ -111,11 +112,15 @@ export function keymapPlugin(
111
112
 
112
113
  bindKeymapWithCommand(
113
114
  addColumnBefore.common!,
114
- addColumnBeforeCommand(isTableScalingEnabled),
115
+ addColumnBeforeCommand(isTableScalingEnabled, shouldUseIncreasedScalingPercent),
115
116
  list,
116
117
  );
117
118
 
118
- bindKeymapWithCommand(addColumnAfter.common!, addColumnAfterCommand(isTableScalingEnabled), list);
119
+ bindKeymapWithCommand(
120
+ addColumnAfter.common!,
121
+ addColumnAfterCommand(isTableScalingEnabled, shouldUseIncreasedScalingPercent),
122
+ list,
123
+ );
119
124
 
120
125
  if (dragAndDropEnabled) {
121
126
  // Move row/column shortcuts
@@ -153,13 +158,21 @@ export function keymapPlugin(
153
158
  // Delete row/column shortcuts
154
159
  bindKeymapWithCommand(
155
160
  deleteColumn.common!,
156
- deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI),
161
+ deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(
162
+ editorAnalyticsAPI,
163
+ isTableScalingEnabled,
164
+ shouldUseIncreasedScalingPercent,
165
+ ),
157
166
  list,
158
167
  );
159
168
 
160
169
  bindKeymapWithCommand(
161
170
  deleteRow.common!,
162
- deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI),
171
+ deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(
172
+ editorAnalyticsAPI,
173
+ isTableScalingEnabled,
174
+ shouldUseIncreasedScalingPercent,
175
+ ),
163
176
  list,
164
177
  );
165
178
  }
@@ -93,6 +93,7 @@ export const createPlugin = (
93
93
  pluginInjectionApi?: PluginInjectionAPI,
94
94
  isTableScalingEnabled?: boolean,
95
95
  isTableAlignmentEnabled?: boolean,
96
+ shouldUseIncreasedScalingPercent?: boolean,
96
97
  ) => {
97
98
  const state = createPluginState(dispatch, {
98
99
  pluginConfig,
@@ -165,6 +166,7 @@ export const createPlugin = (
165
166
  editorAnalyticsAPI,
166
167
  editorViewRef || undefined,
167
168
  isTableScalingEnabled,
169
+ shouldUseIncreasedScalingPercent,
168
170
  );
169
171
  return fixTables(updatedTr) || updatedTr;
170
172
  }
@@ -84,10 +84,10 @@ export const handleMouseDown = (
84
84
  });
85
85
 
86
86
  let shouldScale = tableDepth === 0 && isTableScalingEnabled;
87
- if (
88
- isTableScalingEnabled &&
89
- getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
90
- ) {
87
+
88
+ const isTableScalingEnabledWithLockButton =
89
+ isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
90
+ if (isTableScalingEnabledWithLockButton) {
91
91
  shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
92
92
  }
93
93
 
@@ -99,6 +99,9 @@ export const handleMouseDown = (
99
99
  start,
100
100
  domAtPos,
101
101
  isTableScalingEnabled: shouldScale,
102
+ shouldUseIncreasedScalingPercent:
103
+ isTableScalingEnabledWithLockButton &&
104
+ getBooleanFF('platform.editor.table.use-increased-scaling-percent'),
102
105
  });
103
106
 
104
107
  if (
@@ -180,10 +183,10 @@ export const handleMouseDown = (
180
183
  selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
181
184
 
182
185
  let shouldScale = tableDepth === 0 && isTableScalingEnabled;
183
- if (
186
+ const isTableScalingEnabledWithLockButton =
184
187
  isTableScalingEnabled &&
185
- getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
186
- ) {
188
+ getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
189
+ if (isTableScalingEnabledWithLockButton) {
187
190
  shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
188
191
  }
189
192
 
@@ -210,6 +213,8 @@ export const handleMouseDown = (
210
213
  originalTable,
211
214
  resizingSelectedColumns ? selectedColumns : undefined,
212
215
  shouldScale,
216
+ isTableScalingEnabledWithLockButton &&
217
+ getBooleanFF('platform.editor.table.use-increased-scaling-percent'),
213
218
  );
214
219
  tr = updateColumnWidths(newResizeState, table, start)(tr);
215
220
  }
@@ -284,10 +289,13 @@ export const handleMouseDown = (
284
289
  const colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter!.attrs.colspan - 1;
285
290
 
286
291
  let shouldScale = tableDepth === 0 && isTableScalingEnabled;
287
- if (
292
+ const isTableScalingEnabledWithLockButton =
288
293
  isTableScalingEnabled &&
289
- getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
290
- ) {
294
+ getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
295
+ const shouldUseIncreasedScalingPercent =
296
+ isTableScalingEnabledWithLockButton &&
297
+ getBooleanFF('platform.editor.table.use-increased-scaling-percent');
298
+ if (isTableScalingEnabledWithLockButton) {
291
299
  shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
292
300
  }
293
301
 
@@ -300,6 +308,8 @@ export const handleMouseDown = (
300
308
  table,
301
309
  undefined,
302
310
  shouldScale,
311
+ undefined,
312
+ shouldUseIncreasedScalingPercent,
303
313
  );
304
314
  } else {
305
315
  resizeColumn(
@@ -310,6 +320,7 @@ export const handleMouseDown = (
310
320
  table,
311
321
  undefined,
312
322
  shouldScale,
323
+ shouldUseIncreasedScalingPercent,
313
324
  );
314
325
  }
315
326
 
@@ -17,9 +17,12 @@ type Col = Array<string | { [name: string]: string }>;
17
17
  export const getColWidthFix = (colwidth: number, tableColumnCount: number) =>
18
18
  colwidth - 1 / tableColumnCount;
19
19
 
20
- export const generateColgroup = (table: PmNode, tableRef?: HTMLElement) => {
20
+ export const generateColgroup = (
21
+ table: PmNode,
22
+ tableRef?: HTMLElement,
23
+ shouldUseIncreasedScalingPercent?: boolean,
24
+ ) => {
21
25
  const cols: Col[] = [];
22
-
23
26
  const map = TableMap.get(table);
24
27
  table.content.firstChild!.content.forEach((cell) => {
25
28
  const colspan = cell.attrs.colspan || 1;
@@ -27,7 +30,11 @@ export const generateColgroup = (table: PmNode, tableRef?: HTMLElement) => {
27
30
  // We slice here to guard against our colwidth array having more entries
28
31
  // Than the we actually span. We'll patch the document at a later point.
29
32
  if (tableRef) {
30
- const scalePercent = getTableScalingPercent(table, tableRef);
33
+ const scalePercent = getTableScalingPercent(
34
+ table,
35
+ tableRef,
36
+ shouldUseIncreasedScalingPercent,
37
+ );
31
38
  cell.attrs.colwidth.slice(0, colspan).forEach((width) => {
32
39
  const fixedColWidth = getColWidthFix(width, map.width);
33
40
  const scaledWidth = fixedColWidth * scalePercent;
@@ -73,6 +80,7 @@ export const insertColgroupFromNode = (
73
80
  table: PmNode,
74
81
  isTableScalingEnabled = false,
75
82
  shouldRemove = true,
83
+ shouldUseIncreasedScalingPercent = false,
76
84
  ): HTMLCollection => {
77
85
  let colgroup = tableRef?.querySelector('colgroup') as HTMLElement;
78
86
  if (colgroup && shouldRemove) {
@@ -82,6 +90,7 @@ export const insertColgroupFromNode = (
82
90
  colgroup = renderColgroupFromNode(
83
91
  table,
84
92
  isTableScalingEnabled ? tableRef ?? undefined : undefined,
93
+ shouldUseIncreasedScalingPercent,
85
94
  );
86
95
  if (shouldRemove) {
87
96
  tableRef?.insertBefore(colgroup, tableRef?.firstChild);
@@ -117,11 +126,12 @@ export const isMinCellWidthTable = (table: PmNode) => {
117
126
  function renderColgroupFromNode(
118
127
  table: PmNode,
119
128
  maybeTableRef: HTMLElement | undefined,
129
+ shouldUseIncreasedScalingPercent: boolean,
120
130
  ): HTMLElement {
121
131
  const rendered = DOMSerializer.renderSpec(document, [
122
132
  'colgroup',
123
133
  {},
124
- ...generateColgroup(table, maybeTableRef),
134
+ ...generateColgroup(table, maybeTableRef, shouldUseIncreasedScalingPercent),
125
135
  ]);
126
136
 
127
137
  return rendered.dom as HTMLElement;
@@ -2,5 +2,6 @@ export const COLUMN_MIN_WIDTH = 48;
2
2
  export const TABLE_DEFAULT_WIDTH = 760;
3
3
  export const TABLE_MAX_WIDTH = 1800;
4
4
  export const MAX_SCALING_PERCENT = 0.3;
5
+ export const MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION = 0.4;
5
6
  // Used to calculate the width of a table using the Editor width
6
7
  export const TABLE_EDITOR_MARGIN = 76;
@@ -43,4 +43,5 @@ export {
43
43
  TABLE_MAX_WIDTH,
44
44
  TABLE_DEFAULT_WIDTH,
45
45
  MAX_SCALING_PERCENT,
46
+ MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION,
46
47
  } from './consts';