@atlaskit/editor-plugin-table 12.1.14 → 12.2.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 (137) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/afm-cc/tsconfig.json +6 -0
  3. package/afm-dev-agents/tsconfig.json +6 -0
  4. package/afm-jira/tsconfig.json +6 -0
  5. package/afm-passionfruit/tsconfig.json +120 -0
  6. package/afm-post-office/tsconfig.json +6 -0
  7. package/afm-rovo-extension/tsconfig.json +6 -0
  8. package/afm-townsquare/tsconfig.json +6 -0
  9. package/afm-volt/tsconfig.json +13 -4
  10. package/dist/cjs/nodeviews/TableComponent.js +77 -26
  11. package/dist/cjs/nodeviews/TableContainer.js +270 -10
  12. package/dist/cjs/nodeviews/TableResizer.js +9 -2
  13. package/dist/cjs/nodeviews/TableRow.js +24 -1
  14. package/dist/cjs/nodeviews/table-node-views.js +1 -1
  15. package/dist/cjs/nodeviews/table.js +22 -7
  16. package/dist/cjs/nodeviews/toDOM.js +23 -7
  17. package/dist/cjs/pm-plugins/main.js +57 -22
  18. package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +72 -1
  19. package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +70 -1
  20. package/dist/cjs/tablePlugin.js +17 -3
  21. package/dist/cjs/ui/TableFloatingControls/NumberColumn/index.js +2 -7
  22. package/dist/es2019/nodeviews/TableComponent.js +80 -26
  23. package/dist/es2019/nodeviews/TableContainer.js +256 -2
  24. package/dist/es2019/nodeviews/TableResizer.js +9 -2
  25. package/dist/es2019/nodeviews/TableRow.js +24 -1
  26. package/dist/es2019/nodeviews/table-node-views.js +1 -1
  27. package/dist/es2019/nodeviews/table.js +21 -6
  28. package/dist/es2019/nodeviews/toDOM.js +24 -8
  29. package/dist/es2019/pm-plugins/main.js +57 -22
  30. package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +72 -3
  31. package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +70 -1
  32. package/dist/es2019/tablePlugin.js +17 -3
  33. package/dist/es2019/ui/TableFloatingControls/NumberColumn/index.js +5 -14
  34. package/dist/esm/nodeviews/TableComponent.js +77 -26
  35. package/dist/esm/nodeviews/TableContainer.js +270 -10
  36. package/dist/esm/nodeviews/TableResizer.js +9 -2
  37. package/dist/esm/nodeviews/TableRow.js +24 -1
  38. package/dist/esm/nodeviews/table-node-views.js +1 -1
  39. package/dist/esm/nodeviews/table.js +22 -7
  40. package/dist/esm/nodeviews/toDOM.js +24 -8
  41. package/dist/esm/pm-plugins/main.js +57 -22
  42. package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +74 -3
  43. package/dist/esm/pm-plugins/table-resizing/utils/misc.js +70 -1
  44. package/dist/esm/tablePlugin.js +17 -3
  45. package/dist/esm/ui/TableFloatingControls/NumberColumn/index.js +1 -6
  46. package/dist/types/nodeviews/ExternalDropTargets.d.ts +1 -1
  47. package/dist/types/nodeviews/TableComponent.d.ts +1 -0
  48. package/dist/types/nodeviews/TableContainer.d.ts +7 -2
  49. package/dist/types/nodeviews/TableResizer.d.ts +1 -1
  50. package/dist/types/nodeviews/TableRow.d.ts +3 -1
  51. package/dist/types/nodeviews/table.d.ts +1 -1
  52. package/dist/types/nodeviews/toDOM.d.ts +5 -0
  53. package/dist/types/nodeviews/types.d.ts +1 -0
  54. package/dist/types/pm-plugins/analytics/commands.d.ts +2 -2
  55. package/dist/types/pm-plugins/analytics/plugin-factory.d.ts +1 -1
  56. package/dist/types/pm-plugins/analytics/utils/moved-event.d.ts +1 -1
  57. package/dist/types/pm-plugins/commands/column-resize.d.ts +10 -10
  58. package/dist/types/pm-plugins/commands/commands-with-analytics.d.ts +1 -1
  59. package/dist/types/pm-plugins/commands/go-to-next-cell.d.ts +1 -1
  60. package/dist/types/pm-plugins/commands/misc.d.ts +2 -2
  61. package/dist/types/pm-plugins/commands/selection.d.ts +6 -6
  62. package/dist/types/pm-plugins/drag-and-drop/commands-with-analytics.d.ts +3 -3
  63. package/dist/types/pm-plugins/drag-and-drop/commands.d.ts +1 -1
  64. package/dist/types/pm-plugins/drag-and-drop/plugin-factory.d.ts +1 -1
  65. package/dist/types/pm-plugins/plugin-factory.d.ts +1 -1
  66. package/dist/types/pm-plugins/sticky-headers/plugin-state.d.ts +1 -1
  67. package/dist/types/pm-plugins/table-resizing/plugin-factory.d.ts +1 -1
  68. package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -0
  69. package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +41 -0
  70. package/dist/types/pm-plugins/utils/create.d.ts +10 -10
  71. package/dist/types/pm-plugins/utils/decoration.d.ts +3 -3
  72. package/dist/types/pm-plugins/utils/dom.d.ts +2 -2
  73. package/dist/types/pm-plugins/utils/drag-menu.d.ts +3 -3
  74. package/dist/types/pm-plugins/utils/merged-cells.d.ts +3 -2
  75. package/dist/types/tablePluginType.d.ts +2 -0
  76. package/dist/types/ui/DragHandle/index.d.ts +4 -14
  77. package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -7
  78. package/dist/types/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +4 -14
  79. package/dist/types/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -1
  80. package/dist/types/ui/TableFloatingControls/index.d.ts +1 -7
  81. package/dist/types/ui/global-styles.d.ts +2 -8
  82. package/dist/types/ui/hooks/useInternalTablePluginStateSelector.d.ts +1 -1
  83. package/dist/types-ts4.5/nodeviews/ExternalDropTargets.d.ts +1 -1
  84. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +1 -0
  85. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +7 -2
  86. package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +1 -1
  87. package/dist/types-ts4.5/nodeviews/TableRow.d.ts +3 -1
  88. package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
  89. package/dist/types-ts4.5/nodeviews/toDOM.d.ts +5 -0
  90. package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
  91. package/dist/types-ts4.5/pm-plugins/analytics/commands.d.ts +2 -2
  92. package/dist/types-ts4.5/pm-plugins/analytics/plugin-factory.d.ts +1 -1
  93. package/dist/types-ts4.5/pm-plugins/analytics/utils/moved-event.d.ts +1 -1
  94. package/dist/types-ts4.5/pm-plugins/commands/column-resize.d.ts +10 -10
  95. package/dist/types-ts4.5/pm-plugins/commands/commands-with-analytics.d.ts +1 -1
  96. package/dist/types-ts4.5/pm-plugins/commands/go-to-next-cell.d.ts +1 -1
  97. package/dist/types-ts4.5/pm-plugins/commands/misc.d.ts +2 -2
  98. package/dist/types-ts4.5/pm-plugins/commands/selection.d.ts +6 -6
  99. package/dist/types-ts4.5/pm-plugins/drag-and-drop/commands-with-analytics.d.ts +3 -3
  100. package/dist/types-ts4.5/pm-plugins/drag-and-drop/commands.d.ts +1 -1
  101. package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin-factory.d.ts +1 -1
  102. package/dist/types-ts4.5/pm-plugins/plugin-factory.d.ts +1 -1
  103. package/dist/types-ts4.5/pm-plugins/sticky-headers/plugin-state.d.ts +1 -1
  104. package/dist/types-ts4.5/pm-plugins/table-resizing/plugin-factory.d.ts +1 -1
  105. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -0
  106. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +41 -0
  107. package/dist/types-ts4.5/pm-plugins/utils/create.d.ts +10 -10
  108. package/dist/types-ts4.5/pm-plugins/utils/decoration.d.ts +3 -3
  109. package/dist/types-ts4.5/pm-plugins/utils/dom.d.ts +2 -2
  110. package/dist/types-ts4.5/pm-plugins/utils/drag-menu.d.ts +3 -3
  111. package/dist/types-ts4.5/pm-plugins/utils/merged-cells.d.ts +3 -2
  112. package/dist/types-ts4.5/tablePluginType.d.ts +2 -0
  113. package/dist/types-ts4.5/ui/DragHandle/index.d.ts +4 -14
  114. package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -7
  115. package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +4 -14
  116. package/dist/types-ts4.5/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -1
  117. package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +1 -7
  118. package/dist/types-ts4.5/ui/global-styles.d.ts +2 -8
  119. package/dist/types-ts4.5/ui/hooks/useInternalTablePluginStateSelector.d.ts +1 -1
  120. package/package.json +10 -11
  121. package/src/nodeviews/TableComponent.tsx +113 -23
  122. package/src/nodeviews/TableContainer.tsx +331 -2
  123. package/src/nodeviews/TableResizer.tsx +10 -5
  124. package/src/nodeviews/TableRow.ts +38 -1
  125. package/src/nodeviews/table-node-views.ts +1 -1
  126. package/src/nodeviews/table.tsx +23 -0
  127. package/src/nodeviews/toDOM.ts +75 -9
  128. package/src/nodeviews/types.ts +1 -0
  129. package/src/pm-plugins/main.ts +41 -18
  130. package/src/pm-plugins/table-resizing/utils/colgroup.ts +139 -6
  131. package/src/pm-plugins/table-resizing/utils/misc.ts +87 -0
  132. package/src/tablePlugin.tsx +21 -0
  133. package/src/tablePluginType.ts +2 -0
  134. package/src/ui/TableFloatingControls/NumberColumn/index.tsx +5 -14
  135. package/tsconfig.app.json +6 -0
  136. package/types/package.json +1 -1
  137. package/ui/common-styles/package.json +1 -1
@@ -136,6 +136,7 @@ interface ComponentProps {
136
136
  isTableHovered?: boolean;
137
137
  isWholeTableInDanger?: boolean;
138
138
  selection?: Selection;
139
+ limitedMode?: boolean;
139
140
  }
140
141
 
141
142
  interface TableState {
@@ -146,6 +147,7 @@ interface TableState {
146
147
  [ShadowEvent.SHOW_AFTER_SHADOW]: boolean;
147
148
  tableWrapperWidth?: number;
148
149
  tableWrapperHeight?: number;
150
+ windowResized?: boolean;
149
151
  }
150
152
 
151
153
  // Generate a unique ID to prevent collisions when multiple plugin versions exist on the same page
@@ -171,6 +173,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
171
173
  [ShadowEvent.SHOW_AFTER_SHADOW]: false,
172
174
  tableWrapperWidth: undefined,
173
175
  tableWrapperHeight: undefined,
176
+ windowResized: false,
174
177
  };
175
178
 
176
179
  private wrapper?: HTMLDivElement | null;
@@ -307,16 +310,18 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
307
310
 
308
311
  const { tableWithFixedColumnWidthsOption = false } = getEditorFeatureFlags();
309
312
 
310
- if (isTableScalingEnabled && !tableWithFixedColumnWidthsOption) {
311
- this.handleColgroupUpdates(true);
312
- }
313
+ if (!expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true)) {
314
+ if (isTableScalingEnabled && !tableWithFixedColumnWidthsOption) {
315
+ this.handleColgroupUpdates(true);
316
+ }
313
317
 
314
- if (
315
- isTableScalingEnabled &&
316
- tableWithFixedColumnWidthsOption &&
317
- getNode().attrs.displayMode !== 'fixed'
318
- ) {
319
- this.handleColgroupUpdates(true);
318
+ if (
319
+ isTableScalingEnabled &&
320
+ tableWithFixedColumnWidthsOption &&
321
+ getNode().attrs.displayMode !== 'fixed'
322
+ ) {
323
+ this.handleColgroupUpdates(true);
324
+ }
320
325
  }
321
326
 
322
327
  if (this.wrapper) {
@@ -366,6 +371,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
366
371
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
367
372
  window.addEventListener('resize', this.handleWindowResizeDebounced);
368
373
  }
374
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
375
+ window.addEventListener('resize', this.handleWindowResizeNewDebounced);
369
376
  this.handleTableResizingDebounced();
370
377
  }
371
378
 
@@ -418,6 +425,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
418
425
  if (!allowTableResizing) {
419
426
  this.handleWindowResizeDebounced.cancel();
420
427
  }
428
+ this.handleWindowResizeNewDebounced.cancel();
421
429
 
422
430
  if (!allowTableResizing && allowColumnResizing) {
423
431
  // Ignored via go/ees005
@@ -425,6 +433,11 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
425
433
  window.removeEventListener('resize', this.handleWindowResizeDebounced);
426
434
  }
427
435
 
436
+ if (allowColumnResizing) {
437
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
438
+ window.removeEventListener('resize', this.handleWindowResizeNewDebounced);
439
+ }
440
+
428
441
  // Ignored via go/ees005
429
442
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
430
443
  this?.table?.removeEventListener('mouseenter', this.handleMouseEnter);
@@ -530,7 +543,9 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
530
543
  isTableWidthChanged ||
531
544
  (isTableResizedFullWidth && !options?.isCommentEditor) ||
532
545
  isNumberColumnChanged ||
533
- isNumberOfColumnsChanged;
546
+ isNumberOfColumnsChanged ||
547
+ (expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) &&
548
+ this.state.windowResized);
534
549
 
535
550
  if (force || maybeScale || isFullWidthModeAndLineLengthChanged) {
536
551
  const isWidthChanged = this.containerWidth?.width !== containerWidthValue;
@@ -538,15 +553,18 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
538
553
  const isTableResized = hasTableBeenResized(tableNode);
539
554
  const isColumnsDistributed = wasTableResized && !isTableResized;
540
555
  const isTableDisplayModeChanged = this.node.attrs.displayMode !== tableNode.attrs.displayMode;
541
- const shouldUpdateColgroup =
542
- isWidthChanged ||
543
- isColumnsDistributed ||
544
- isTableResizedFullWidth ||
545
- isTableWidthChanged ||
546
- isTableDisplayModeChanged ||
547
- isNumberColumnChanged ||
548
- isNumberOfColumnsChanged ||
549
- isFullWidthModeAndLineLengthChanged;
556
+
557
+ const shouldUpdateColgroup = this.shouldUpdateColgroup({
558
+ isWindowResized: this.state.windowResized,
559
+ isWidthChanged,
560
+ isTableWidthChanged,
561
+ isColumnsDistributed,
562
+ isTableResizedFullWidth,
563
+ isTableDisplayModeChanged,
564
+ isNumberColumnChanged,
565
+ isNumberOfColumnsChanged,
566
+ isFullWidthModeAndLineLengthChanged,
567
+ });
550
568
 
551
569
  const { tableWithFixedColumnWidthsOption = false } = getEditorFeatureFlags();
552
570
 
@@ -691,6 +709,13 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
691
709
  shouldHandleColgroupUpdates = true;
692
710
  }
693
711
 
712
+ if (
713
+ expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) &&
714
+ this.state.windowResized
715
+ ) {
716
+ shouldHandleColgroupUpdates = true;
717
+ }
718
+
694
719
  if (shouldHandleColgroupUpdates) {
695
720
  this.handleColgroupUpdates();
696
721
  }
@@ -917,7 +942,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
917
942
  // pass `selection` and `tableHeight` to control re-render
918
943
  selection={view.state.selection}
919
944
  headerRowHeight={headerRow ? headerRow.offsetHeight : undefined}
920
- stickyHeader={this.state.stickyHeader}
945
+ stickyHeader={!this.props.limitedMode ? this.state.stickyHeader : undefined}
921
946
  tableWrapperWidth={this.state.tableWrapperWidth}
922
947
  api={pluginInjectionApi}
923
948
  isChromelessEditor={options?.isChromelessEditor}
@@ -940,7 +965,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
940
965
  // pass `selection` to control re-render
941
966
  selection={view.state.selection}
942
967
  headerRowHeight={headerRow ? headerRow.offsetHeight : undefined}
943
- stickyHeader={this.state.stickyHeader}
968
+ stickyHeader={!this.props.limitedMode ? this.state.stickyHeader : undefined}
944
969
  getEditorFeatureFlags={getEditorFeatureFlags}
945
970
  tableContainerWidth={tableContainerWidth}
946
971
  isNumberColumnEnabled={node.attrs.isNumberColumnEnabled}
@@ -975,7 +1000,9 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
975
1000
  const topOffset = 0;
976
1001
 
977
1002
  const topStickyShadowPosition =
978
- this.state.stickyHeader && topOffset + this.state.stickyHeader.padding + topShadowPadding + 2;
1003
+ !this.props.limitedMode &&
1004
+ this.state.stickyHeader &&
1005
+ topOffset + this.state.stickyHeader.padding + topShadowPadding + 2;
979
1006
 
980
1007
  const { tableWithFixedColumnWidthsOption = false } = getEditorFeatureFlags();
981
1008
 
@@ -988,7 +1015,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
988
1015
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
989
1016
  className={classnames(ClassName.TABLE_CONTAINER, {
990
1017
  [ClassName.WITH_CONTROLS]: allowControls && tableActive,
991
- [ClassName.TABLE_STICKY]: this.state.stickyHeader && hasHeaderRow,
1018
+ [ClassName.TABLE_STICKY]:
1019
+ !this.props.limitedMode && this.state.stickyHeader && hasHeaderRow,
992
1020
  [ClassName.HOVERED_DELETE_BUTTON]: isInDanger,
993
1021
  [ClassName.TABLE_SELECTED]: isTableSelected(selection ?? view.state.selection),
994
1022
  [ClassName.NESTED_TABLE_WITH_CONTROLS]:
@@ -1006,6 +1034,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
1006
1034
  tableWrapperHeight={this.state.tableWrapperHeight}
1007
1035
  isTableResizingEnabled={allowTableResizing}
1008
1036
  isResizing={isResizing}
1037
+ isWindowResized={this.state.windowResized}
1009
1038
  isTableScalingEnabled={isTableScalingEnabled}
1010
1039
  isTableWithFixedColumnWidthsOptionEnabled={tableWithFixedColumnWidthsOption}
1011
1040
  isWholeTableInDanger={isWholeTableInDanger}
@@ -1418,6 +1447,17 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
1418
1447
  });
1419
1448
  };
1420
1449
 
1450
+ // This is a new handler for window resize events that sets the windowResized state immediately
1451
+ // This is needed to update colgroup on window resize, to enforce the table scaling
1452
+ private handleWindowResizeNew = () => {
1453
+ // Set resizing to true immediately
1454
+ if (!this.state.windowResized) {
1455
+ this.setState({
1456
+ windowResized: true,
1457
+ });
1458
+ }
1459
+ };
1460
+
1421
1461
  private getParentNodeWidth = () => {
1422
1462
  const {
1423
1463
  getPos,
@@ -1450,11 +1490,61 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
1450
1490
  options || this.props.options || {},
1451
1491
  );
1452
1492
 
1493
+ private shouldUpdateColgroup = (params: {
1494
+ isWindowResized: boolean | undefined;
1495
+ isWidthChanged: boolean;
1496
+ isTableWidthChanged: boolean;
1497
+ isColumnsDistributed: boolean;
1498
+ isTableResizedFullWidth: boolean | undefined;
1499
+ isTableDisplayModeChanged: boolean;
1500
+ isNumberColumnChanged: boolean;
1501
+ isNumberOfColumnsChanged: boolean;
1502
+ isFullWidthModeAndLineLengthChanged: boolean | undefined;
1503
+ }): boolean => {
1504
+ const {
1505
+ isWindowResized,
1506
+ isWidthChanged,
1507
+ isTableWidthChanged,
1508
+ isColumnsDistributed,
1509
+ isTableResizedFullWidth,
1510
+ isTableDisplayModeChanged,
1511
+ isNumberColumnChanged,
1512
+ isNumberOfColumnsChanged,
1513
+ isFullWidthModeAndLineLengthChanged,
1514
+ } = params;
1515
+
1516
+ const isFullPageEditor =
1517
+ !this.props.options?.isCommentEditor && !this.props.options?.isChromelessEditor;
1518
+
1519
+ if (expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) && isFullPageEditor) {
1520
+ return (
1521
+ !!isWindowResized ||
1522
+ isColumnsDistributed ||
1523
+ !!isTableResizedFullWidth ||
1524
+ isTableDisplayModeChanged ||
1525
+ isNumberColumnChanged ||
1526
+ isNumberOfColumnsChanged ||
1527
+ !!isFullWidthModeAndLineLengthChanged
1528
+ );
1529
+ }
1530
+ return (
1531
+ isWidthChanged ||
1532
+ isTableWidthChanged ||
1533
+ isColumnsDistributed ||
1534
+ !!isTableResizedFullWidth ||
1535
+ isTableDisplayModeChanged ||
1536
+ isNumberColumnChanged ||
1537
+ isNumberOfColumnsChanged ||
1538
+ !!isFullWidthModeAndLineLengthChanged
1539
+ );
1540
+ };
1541
+
1453
1542
  private scaleTableDebounced = rafSchedule(this.scaleTable);
1454
1543
  private handleTableResizingDebounced = rafSchedule(this.handleTableResizing);
1455
1544
  private handleScrollDebounced = rafSchedule(this.handleScroll);
1456
1545
  private handleAutoSizeDebounced = rafSchedule(this.handleAutoSize);
1457
1546
  private handleWindowResizeDebounced = rafSchedule(this.handleWindowResize);
1547
+ private handleWindowResizeNewDebounced = rafSchedule(this.handleWindowResizeNew);
1458
1548
  private updateShadowStateDebounced = rafSchedule(this.updateShadowState);
1459
1549
  }
1460
1550
 
@@ -8,6 +8,7 @@ import {
8
8
  INPUT_METHOD,
9
9
  type TableEventPayload,
10
10
  } from '@atlaskit/editor-common/analytics';
11
+ import { isSSR } from '@atlaskit/editor-common/core-utils';
11
12
  import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
12
13
  import {
13
14
  type NamedPluginStatesFromInjectionAPI,
@@ -27,6 +28,7 @@ import {
27
28
  akEditorMobileBreakoutPoint,
28
29
  } from '@atlaskit/editor-shared-styles';
29
30
  import { fg } from '@atlaskit/platform-feature-flags';
31
+ import { componentWithCondition } from '@atlaskit/platform-feature-flags-react';
30
32
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
31
33
 
32
34
  import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
@@ -35,6 +37,10 @@ import {
35
37
  TABLE_MAX_WIDTH,
36
38
  TABLE_OFFSET_IN_COMMENT_EDITOR,
37
39
  } from '../pm-plugins/table-resizing/utils/consts';
40
+ import {
41
+ getTableResizerContainerMaxWidthInCSS,
42
+ getTableResizerContainerForFullPageWidthInCSS,
43
+ } from '../pm-plugins/table-resizing/utils/misc';
38
44
  import { ALIGN_CENTER, ALIGN_START } from '../pm-plugins/utils/alignment';
39
45
  import type tablePlugin from '../tablePlugin';
40
46
  import type { PluginInjectionAPI, TableSharedStateInternal } from '../types';
@@ -210,6 +216,7 @@ type ResizableTableContainerProps = {
210
216
  getPos: () => number | undefined;
211
217
  tableRef: HTMLTableElement;
212
218
  isResizing?: boolean;
219
+ isWindowResized?: boolean;
213
220
  pluginInjectionApi?: PluginInjectionAPI;
214
221
  tableWrapperHeight?: number;
215
222
  isWholeTableInDanger?: boolean;
@@ -219,6 +226,7 @@ type ResizableTableContainerProps = {
219
226
  isTableAlignmentEnabled?: boolean;
220
227
  shouldUseIncreasedScalingPercent?: boolean;
221
228
  isCommentEditor?: boolean;
229
+ isChromelessEditor?: boolean;
222
230
  };
223
231
 
224
232
  const selector = (
@@ -264,7 +272,7 @@ const getPadding = (containerWidth: number) => {
264
272
  : akEditorGutterPaddingDynamic();
265
273
  };
266
274
 
267
- export const ResizableTableContainer = React.memo(
275
+ const ResizableTableContainerLegacy = React.memo(
268
276
  ({
269
277
  children,
270
278
  className,
@@ -500,6 +508,324 @@ export const ResizableTableContainer = React.memo(
500
508
  },
501
509
  );
502
510
 
511
+ const ResizableTableContainerNext = React.memo(
512
+ ({
513
+ children,
514
+ className,
515
+ node,
516
+ containerWidth,
517
+ lineLength,
518
+ editorView,
519
+ getPos,
520
+ tableRef,
521
+ isResizing,
522
+ isWindowResized,
523
+ pluginInjectionApi,
524
+ tableWrapperHeight,
525
+ isWholeTableInDanger,
526
+ isTableScalingEnabled,
527
+ isTableWithFixedColumnWidthsOptionEnabled,
528
+ isTableAlignmentEnabled,
529
+ shouldUseIncreasedScalingPercent,
530
+ isCommentEditor,
531
+ isChromelessEditor,
532
+ }: PropsWithChildren<ResizableTableContainerProps>) => {
533
+ const tableWidth = getTableContainerWidth(node);
534
+ const containerRef = useRef<HTMLDivElement | null>(null);
535
+ const tableWidthRef = useRef<number>(akEditorDefaultLayoutWidth);
536
+ const [resizing, setIsResizing] = useState(false);
537
+ const [tableMaxWidthForFullPageOnLoad, setTableMaxWidthForFullPageOnLoad] =
538
+ useState<number>(tableWidth);
539
+
540
+ const { tableState, editorViewModeState } = useSharedState(pluginInjectionApi);
541
+ const isFullWidthModeEnabled = tableState?.isFullWidthModeEnabled;
542
+ const mode = editorViewModeState?.mode;
543
+
544
+ const updateContainerHeight = useCallback((height: number | 'auto') => {
545
+ // current StickyHeader State is not stable to be fetch.
546
+ // we need to update stickyHeader plugin to make sure state can be
547
+ // consistently fetch and refactor below
548
+ const stickyHeaders = containerRef.current?.getElementsByClassName('pm-table-sticky');
549
+ if (!stickyHeaders || stickyHeaders.length < 1) {
550
+ // when starting to drag, we need to keep the original space,
551
+ // -- When sticky header not appear, margin top(24px) and margin bottom(16px), should be 40px,
552
+ // 1px is border width but collapse make it 0.5.
553
+ // -- When sticky header appear, we should add first row height but reduce
554
+ // collapsed border
555
+ return typeof height === 'number' ? `${height + 40.5}px` : 'auto';
556
+ } else {
557
+ const stickyHeaderHeight =
558
+ containerRef.current?.getElementsByTagName('th')[0].getBoundingClientRect().height || 0;
559
+
560
+ return typeof height === 'number' ? `${height + stickyHeaderHeight + 39.5}px` : 'auto';
561
+ }
562
+ }, []);
563
+
564
+ const onResizeStart = useCallback(() => {
565
+ setIsResizing(true);
566
+ }, []);
567
+
568
+ const onResizeStop = useCallback(() => {
569
+ setIsResizing(false);
570
+ }, []);
571
+
572
+ const updateWidth = useCallback((width?: number) => {
573
+ if (!containerRef.current) {
574
+ return;
575
+ }
576
+
577
+ // make sure during resizing
578
+ // the pm-table-resizer-container width is the same as its child div resizer-item
579
+ // otherwise when resize table from wider to narrower , pm-table-resizer-container stays wider
580
+ // and cause the fabric-editor-popup-scroll-parent to overflow
581
+ if (containerRef.current.style.width !== `${width}px`) {
582
+ containerRef.current.style.width = `${width}px`;
583
+ }
584
+ }, []);
585
+
586
+ const displayGuideline = useCallback(
587
+ (guidelines: GuidelineConfig[]) => {
588
+ return (
589
+ pluginInjectionApi?.guideline?.actions?.displayGuideline(editorView)({
590
+ guidelines,
591
+ }) ?? false
592
+ );
593
+ },
594
+ [pluginInjectionApi, editorView],
595
+ );
596
+
597
+ const attachAnalyticsEvent = useCallback(
598
+ (payload: TableEventPayload) => {
599
+ return pluginInjectionApi?.analytics?.actions.attachAnalyticsEvent(payload);
600
+ },
601
+ [pluginInjectionApi],
602
+ );
603
+
604
+ const displayGapCursor = useCallback(
605
+ (toggle: boolean) => {
606
+ return (
607
+ pluginInjectionApi?.core?.actions.execute(
608
+ pluginInjectionApi?.selection?.commands.displayGapCursor(toggle),
609
+ ) ?? false
610
+ );
611
+ },
612
+ [pluginInjectionApi],
613
+ );
614
+
615
+ const isFullPageAppearance = !isCommentEditor && !isChromelessEditor;
616
+
617
+ let responsiveContainerWidth = 0;
618
+ const resizeHandleSpacing = 12;
619
+ const padding = getPadding(containerWidth);
620
+ // When Full width editor enabled, a Mac OS user can change "ak-editor-content-area" width by
621
+ // updating Settings -> Appearance -> Show scroll bars from "When scrolling" to "Always". It causes
622
+ // issues when viwport width is less than full width Editor's width. To detect avoid them
623
+ // we need to use lineLength to defined responsiveWidth instead of containerWidth
624
+ // (which does not get updated when Mac setting changes) in Full-width editor.
625
+ if (isFullWidthModeEnabled) {
626
+ // When: Show scroll bars -> containerWidth = akEditorGutterPadding * 2 + lineLength;
627
+ // When: Always -> containerWidth = akEditorGutterPadding * 2 + lineLength + scrollbarWidth;
628
+ // scrollbarWidth can vary. Values can be 14, 15, 16 and up to 20px;
629
+ responsiveContainerWidth = isTableScalingEnabled
630
+ ? lineLength
631
+ : containerWidth - padding * 2 - resizeHandleSpacing;
632
+
633
+ // platform_editor_table_fw_numcol_overflow_fix:
634
+ // lineLength is undefined on first paint → width: NaN → wrapper expands to page
635
+ // width. rAF col-sizing then runs before the number-column padding and
636
+ // the final shrink, so column widths are locked in wrong.
637
+ // With the flag ON, if the value isn’t finite we fall back to gutterWidth
638
+ // for that first frame—no flash, no premature rAF.
639
+ //
640
+ // Type clean-up comes later:
641
+ // 1) ship this runtime guard (quick fix, no breakage);
642
+ // 2) TODO: widen lineLength to `number|undefined` and remove this block.
643
+ if (fg('platform_editor_table_fw_numcol_overflow_fix')) {
644
+ if (isTableScalingEnabled && !Number.isFinite(responsiveContainerWidth)) {
645
+ responsiveContainerWidth = containerWidth - padding * 2 - resizeHandleSpacing;
646
+ }
647
+ }
648
+ } else if (isCommentEditor) {
649
+ responsiveContainerWidth = containerWidth - TABLE_OFFSET_IN_COMMENT_EDITOR;
650
+ } else {
651
+ // 76 is currently an accepted padding value considering the spacing for resizer handle
652
+ // containerWidth = width of a DIV with test id="ak-editor-fp-content-area". It is a parent of
653
+ // a DIV with className="ak-editor-content-area". This DIV has padding left and padding right.
654
+ // padding left = padding right = akEditorGutterPadding = 32
655
+ responsiveContainerWidth = isTableScalingEnabled
656
+ ? containerWidth - padding * 2
657
+ : containerWidth - padding * 2 - resizeHandleSpacing;
658
+ }
659
+
660
+ const width =
661
+ !node.attrs.width && isCommentEditor
662
+ ? responsiveContainerWidth
663
+ : Math.min(tableWidth, responsiveContainerWidth);
664
+
665
+ if (!isResizing) {
666
+ tableWidthRef.current = width;
667
+ }
668
+
669
+ const maxResizerWidth = isCommentEditor
670
+ ? responsiveContainerWidth
671
+ : Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
672
+
673
+ // CSS solution for table resizer item width
674
+ // The `width` is used for .resizer-item in <TableResizer>, and it has to be a number
675
+ // So we can't use min(var(--ak-editor-table-width), ${tableWidth}px) here
676
+ // We get the correct width from CSS value on page load
677
+ // After window resize, we use the width from plugin state
678
+ // After table resize, the table width attribute is used
679
+ const tableResizerItemWidth = useMemo(() => {
680
+ // if not on full page editor, we just rely on the width calculated from plugin state
681
+ // if on full page editor and after window resize, we use the width from plugin state
682
+ if (!isFullPageAppearance || (isFullPageAppearance && isWindowResized)) {
683
+ return width;
684
+ }
685
+ if (isResizing) {
686
+ return tableWidth;
687
+ }
688
+ // if on full page editor and on page load, we use the computed value from CSS
689
+ return Math.min(tableWidth, tableMaxWidthForFullPageOnLoad);
690
+ }, [
691
+ isWindowResized,
692
+ isResizing,
693
+ isFullPageAppearance,
694
+ tableMaxWidthForFullPageOnLoad,
695
+ tableWidth,
696
+ width,
697
+ ]);
698
+
699
+ // CSS Solution for table resizer container width
700
+ const tableResizerContainerWidth = useMemo(() => {
701
+ return getTableResizerContainerForFullPageWidthInCSS(node, isTableScalingEnabled);
702
+ }, [node, isTableScalingEnabled]);
703
+
704
+ // CSS Solution for table resizer max width
705
+ const tableResizerMaxWidth = React.useMemo(() => {
706
+ const isFullPageAppearance = !isCommentEditor && !isChromelessEditor;
707
+ const nonResizingMaxWidth = isFullPageAppearance
708
+ ? getTableResizerContainerMaxWidthInCSS(
709
+ isCommentEditor,
710
+ isChromelessEditor,
711
+ isTableScalingEnabled,
712
+ )
713
+ : maxResizerWidth;
714
+ // isResizing is needed, otherwise we can't resize table.
715
+ // when not resizing, maxWidth is calculated based on the container width via CSS
716
+ return !isResizing ? nonResizingMaxWidth : maxResizerWidth;
717
+ }, [isCommentEditor, isChromelessEditor, isTableScalingEnabled, isResizing, maxResizerWidth]);
718
+
719
+ // on SSR, the width would be the default state, which is tableWidth
720
+ // but because we have maxWidth set to the editor container width via CSS
721
+ // So it would work just fine
722
+ useEffect(() => {
723
+ if (!isSSR() && isFullPageAppearance && containerRef.current?.firstElementChild) {
724
+ // get the computed value of max-width from '.resizer-item', because it uses `cqw` unit in CSS
725
+ const computedStyle = window.getComputedStyle(containerRef.current.firstElementChild);
726
+ const containerWidth = computedStyle.maxWidth
727
+ ? parseFloat(computedStyle.maxWidth)
728
+ : tableWidth;
729
+ setTableMaxWidthForFullPageOnLoad(Math.min(containerWidth, tableWidth));
730
+ }
731
+ }, [tableWidthRef, tableWidth, isFullPageAppearance]);
732
+
733
+ const tableResizerProps = {
734
+ width: tableResizerItemWidth,
735
+ maxWidth: tableResizerMaxWidth,
736
+ containerWidth,
737
+ lineLength,
738
+ updateWidth,
739
+ editorView,
740
+ getPos,
741
+ node,
742
+ tableRef,
743
+ displayGuideline,
744
+ attachAnalyticsEvent,
745
+ displayGapCursor,
746
+ isTableAlignmentEnabled,
747
+ isFullWidthModeEnabled,
748
+ isTableScalingEnabled,
749
+ isTableWithFixedColumnWidthsOptionEnabled,
750
+ isWholeTableInDanger,
751
+ shouldUseIncreasedScalingPercent,
752
+ pluginInjectionApi,
753
+ onResizeStart,
754
+ onResizeStop,
755
+ isCommentEditor,
756
+ };
757
+
758
+ const isLivePageViewMode = mode === 'view';
759
+
760
+ return (
761
+ <AlignmentTableContainerWrapper
762
+ isTableAlignmentEnabled={isTableAlignmentEnabled}
763
+ node={node}
764
+ pluginInjectionApi={pluginInjectionApi}
765
+ getPos={getPos}
766
+ editorView={editorView}
767
+ >
768
+ <div
769
+ style={
770
+ {
771
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
772
+ '--ak-editor-table-gutter-padding':
773
+ 'calc(var(--ak-editor--large-gutter-padding) * 2)',
774
+ '--ak-editor-table-width': isFullPageAppearance
775
+ ? tableResizerContainerWidth
776
+ : `${tableWidthRef.current}px`,
777
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
778
+ width: 'var(--ak-editor-table-width)',
779
+ height: resizing ? updateContainerHeight(tableWrapperHeight ?? 'auto') : 'auto',
780
+ position: isLivePageViewMode ? 'relative' : 'unset',
781
+ } as React.CSSProperties
782
+ }
783
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
784
+ className={ClassName.TABLE_RESIZER_CONTAINER}
785
+ ref={containerRef}
786
+ >
787
+ {fg('platform_editor_live_page_prevent_table_recreation') ? null : isLivePageViewMode ? (
788
+ <InnerContainer
789
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
790
+ className={className}
791
+ node={node}
792
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
793
+ style={{ width: 'inherit' }}
794
+ >
795
+ {children}
796
+ </InnerContainer>
797
+ ) : (
798
+ // Ignored via go/ees005
799
+ // eslint-disable-next-line react/jsx-props-no-spreading
800
+ <TableResizer {...tableResizerProps}>
801
+ {/* eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766 */}
802
+ <InnerContainer className={className} node={node}>
803
+ {children}
804
+ </InnerContainer>
805
+ </TableResizer>
806
+ )}
807
+ {fg('platform_editor_live_page_prevent_table_recreation') ? (
808
+ // Ignored via go/ees005
809
+ // eslint-disable-next-line react/jsx-props-no-spreading
810
+ <TableResizer {...tableResizerProps} disabled={isLivePageViewMode}>
811
+ {/* eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766 */}
812
+ <InnerContainer className={className} node={node}>
813
+ {children}
814
+ </InnerContainer>
815
+ </TableResizer>
816
+ ) : null}
817
+ </div>
818
+ </AlignmentTableContainerWrapper>
819
+ );
820
+ },
821
+ );
822
+
823
+ export const ResizableTableContainer = componentWithCondition(
824
+ () => expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true),
825
+ ResizableTableContainerNext,
826
+ ResizableTableContainerLegacy,
827
+ );
828
+
503
829
  type TableContainerProps = {
504
830
  node: PMNode;
505
831
  className: string;
@@ -509,6 +835,7 @@ type TableContainerProps = {
509
835
  tableRef: HTMLTableElement;
510
836
  isNested: boolean;
511
837
  isResizing?: boolean;
838
+ isWindowResized?: boolean;
512
839
  pluginInjectionApi?: PluginInjectionAPI;
513
840
  tableWrapperHeight?: number;
514
841
  isWholeTableInDanger?: boolean;
@@ -533,6 +860,7 @@ export const TableContainer = ({
533
860
  isNested,
534
861
  tableWrapperHeight,
535
862
  isResizing,
863
+ isWindowResized,
536
864
  pluginInjectionApi,
537
865
  isWholeTableInDanger,
538
866
  isTableResizingEnabled,
@@ -560,6 +888,7 @@ export const TableContainer = ({
560
888
  tableRef={tableRef}
561
889
  tableWrapperHeight={tableWrapperHeight}
562
890
  isResizing={isResizing}
891
+ isWindowResized={isWindowResized}
563
892
  pluginInjectionApi={pluginInjectionApi}
564
893
  isTableScalingEnabled={isTableScalingEnabled}
565
894
  isTableWithFixedColumnWidthsOptionEnabled={isTableWithFixedColumnWidthsOptionEnabled}
@@ -567,6 +896,7 @@ export const TableContainer = ({
567
896
  isTableAlignmentEnabled={isTableAlignmentEnabled}
568
897
  shouldUseIncreasedScalingPercent={shouldUseIncreasedScalingPercent}
569
898
  isCommentEditor={isCommentEditor}
899
+ isChromelessEditor={isChromelessEditor}
570
900
  >
571
901
  {children}
572
902
  </ResizableTableContainer>
@@ -574,7 +904,6 @@ export const TableContainer = ({
574
904
  }
575
905
 
576
906
  const { isDragAndDropEnabled } = getPluginState(editorView.state);
577
-
578
907
  return (
579
908
  <InnerContainer
580
909
  node={node}