@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
@@ -2,14 +2,17 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
+ import { isSSR } from '@atlaskit/editor-common/core-utils';
5
6
  import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
6
7
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
7
8
  import { akEditorDefaultLayoutWidth, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
8
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
+ import { componentWithCondition } from '@atlaskit/platform-feature-flags-react';
9
11
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
10
12
  import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
11
13
  import { getPluginState } from '../pm-plugins/plugin-factory';
12
14
  import { TABLE_MAX_WIDTH, TABLE_OFFSET_IN_COMMENT_EDITOR } from '../pm-plugins/table-resizing/utils/consts';
15
+ import { getTableResizerContainerMaxWidthInCSS, getTableResizerContainerForFullPageWidthInCSS } from '../pm-plugins/table-resizing/utils/misc';
13
16
  import { ALIGN_CENTER, ALIGN_START } from '../pm-plugins/utils/alignment';
14
17
  import { TableCssClassName as ClassName } from '../types';
15
18
  import { getAlignmentStyle } from './table-container-styles';
@@ -159,7 +162,7 @@ const useSharedState = sharedPluginStateHookMigratorFactory(api => {
159
162
  const getPadding = containerWidth => {
160
163
  return containerWidth <= akEditorFullPageNarrowBreakout && expValEquals('platform_editor_preview_panel_responsiveness', 'isEnabled', true) ? akEditorGutterPaddingReduced : akEditorGutterPaddingDynamic();
161
164
  };
162
- export const ResizableTableContainer = /*#__PURE__*/React.memo(({
165
+ const ResizableTableContainerLegacy = /*#__PURE__*/React.memo(({
163
166
  children,
164
167
  className,
165
168
  node,
@@ -352,6 +355,254 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
352
355
  node: node
353
356
  }, children)) : null));
354
357
  });
358
+ const ResizableTableContainerNext = /*#__PURE__*/React.memo(({
359
+ children,
360
+ className,
361
+ node,
362
+ containerWidth,
363
+ lineLength,
364
+ editorView,
365
+ getPos,
366
+ tableRef,
367
+ isResizing,
368
+ isWindowResized,
369
+ pluginInjectionApi,
370
+ tableWrapperHeight,
371
+ isWholeTableInDanger,
372
+ isTableScalingEnabled,
373
+ isTableWithFixedColumnWidthsOptionEnabled,
374
+ isTableAlignmentEnabled,
375
+ shouldUseIncreasedScalingPercent,
376
+ isCommentEditor,
377
+ isChromelessEditor
378
+ }) => {
379
+ const tableWidth = getTableContainerWidth(node);
380
+ const containerRef = useRef(null);
381
+ const tableWidthRef = useRef(akEditorDefaultLayoutWidth);
382
+ const [resizing, setIsResizing] = useState(false);
383
+ const [tableMaxWidthForFullPageOnLoad, setTableMaxWidthForFullPageOnLoad] = useState(tableWidth);
384
+ const {
385
+ tableState,
386
+ editorViewModeState
387
+ } = useSharedState(pluginInjectionApi);
388
+ const isFullWidthModeEnabled = tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled;
389
+ const mode = editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
390
+ const updateContainerHeight = useCallback(height => {
391
+ var _containerRef$current3;
392
+ // current StickyHeader State is not stable to be fetch.
393
+ // we need to update stickyHeader plugin to make sure state can be
394
+ // consistently fetch and refactor below
395
+ const stickyHeaders = (_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.getElementsByClassName('pm-table-sticky');
396
+ if (!stickyHeaders || stickyHeaders.length < 1) {
397
+ // when starting to drag, we need to keep the original space,
398
+ // -- When sticky header not appear, margin top(24px) and margin bottom(16px), should be 40px,
399
+ // 1px is border width but collapse make it 0.5.
400
+ // -- When sticky header appear, we should add first row height but reduce
401
+ // collapsed border
402
+ return typeof height === 'number' ? `${height + 40.5}px` : 'auto';
403
+ } else {
404
+ var _containerRef$current4;
405
+ const stickyHeaderHeight = ((_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.getElementsByTagName('th')[0].getBoundingClientRect().height) || 0;
406
+ return typeof height === 'number' ? `${height + stickyHeaderHeight + 39.5}px` : 'auto';
407
+ }
408
+ }, []);
409
+ const onResizeStart = useCallback(() => {
410
+ setIsResizing(true);
411
+ }, []);
412
+ const onResizeStop = useCallback(() => {
413
+ setIsResizing(false);
414
+ }, []);
415
+ const updateWidth = useCallback(width => {
416
+ if (!containerRef.current) {
417
+ return;
418
+ }
419
+
420
+ // make sure during resizing
421
+ // the pm-table-resizer-container width is the same as its child div resizer-item
422
+ // otherwise when resize table from wider to narrower , pm-table-resizer-container stays wider
423
+ // and cause the fabric-editor-popup-scroll-parent to overflow
424
+ if (containerRef.current.style.width !== `${width}px`) {
425
+ containerRef.current.style.width = `${width}px`;
426
+ }
427
+ }, []);
428
+ const displayGuideline = useCallback(guidelines => {
429
+ var _pluginInjectionApi$g4, _pluginInjectionApi$g5, _pluginInjectionApi$g6;
430
+ return (_pluginInjectionApi$g4 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$g5 = pluginInjectionApi.guideline) === null || _pluginInjectionApi$g5 === void 0 ? void 0 : (_pluginInjectionApi$g6 = _pluginInjectionApi$g5.actions) === null || _pluginInjectionApi$g6 === void 0 ? void 0 : _pluginInjectionApi$g6.displayGuideline(editorView)({
431
+ guidelines
432
+ })) !== null && _pluginInjectionApi$g4 !== void 0 ? _pluginInjectionApi$g4 : false;
433
+ }, [pluginInjectionApi, editorView]);
434
+ const attachAnalyticsEvent = useCallback(payload => {
435
+ var _pluginInjectionApi$a3;
436
+ return pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions.attachAnalyticsEvent(payload);
437
+ }, [pluginInjectionApi]);
438
+ const displayGapCursor = useCallback(toggle => {
439
+ var _pluginInjectionApi$c3, _pluginInjectionApi$c4, _pluginInjectionApi$s2;
440
+ return (_pluginInjectionApi$c3 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c4 = pluginInjectionApi.core) === null || _pluginInjectionApi$c4 === void 0 ? void 0 : _pluginInjectionApi$c4.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$s2 = pluginInjectionApi.selection) === null || _pluginInjectionApi$s2 === void 0 ? void 0 : _pluginInjectionApi$s2.commands.displayGapCursor(toggle))) !== null && _pluginInjectionApi$c3 !== void 0 ? _pluginInjectionApi$c3 : false;
441
+ }, [pluginInjectionApi]);
442
+ const isFullPageAppearance = !isCommentEditor && !isChromelessEditor;
443
+ let responsiveContainerWidth = 0;
444
+ const resizeHandleSpacing = 12;
445
+ const padding = getPadding(containerWidth);
446
+ // When Full width editor enabled, a Mac OS user can change "ak-editor-content-area" width by
447
+ // updating Settings -> Appearance -> Show scroll bars from "When scrolling" to "Always". It causes
448
+ // issues when viwport width is less than full width Editor's width. To detect avoid them
449
+ // we need to use lineLength to defined responsiveWidth instead of containerWidth
450
+ // (which does not get updated when Mac setting changes) in Full-width editor.
451
+ if (isFullWidthModeEnabled) {
452
+ // When: Show scroll bars -> containerWidth = akEditorGutterPadding * 2 + lineLength;
453
+ // When: Always -> containerWidth = akEditorGutterPadding * 2 + lineLength + scrollbarWidth;
454
+ // scrollbarWidth can vary. Values can be 14, 15, 16 and up to 20px;
455
+ responsiveContainerWidth = isTableScalingEnabled ? lineLength : containerWidth - padding * 2 - resizeHandleSpacing;
456
+
457
+ // platform_editor_table_fw_numcol_overflow_fix:
458
+ // lineLength is undefined on first paint → width: NaN → wrapper expands to page
459
+ // width. rAF col-sizing then runs before the number-column padding and
460
+ // the final shrink, so column widths are locked in wrong.
461
+ // With the flag ON, if the value isn’t finite we fall back to gutterWidth
462
+ // for that first frame—no flash, no premature rAF.
463
+ //
464
+ // Type clean-up comes later:
465
+ // 1) ship this runtime guard (quick fix, no breakage);
466
+ // 2) TODO: widen lineLength to `number|undefined` and remove this block.
467
+ if (fg('platform_editor_table_fw_numcol_overflow_fix')) {
468
+ if (isTableScalingEnabled && !Number.isFinite(responsiveContainerWidth)) {
469
+ responsiveContainerWidth = containerWidth - padding * 2 - resizeHandleSpacing;
470
+ }
471
+ }
472
+ } else if (isCommentEditor) {
473
+ responsiveContainerWidth = containerWidth - TABLE_OFFSET_IN_COMMENT_EDITOR;
474
+ } else {
475
+ // 76 is currently an accepted padding value considering the spacing for resizer handle
476
+ // containerWidth = width of a DIV with test id="ak-editor-fp-content-area". It is a parent of
477
+ // a DIV with className="ak-editor-content-area". This DIV has padding left and padding right.
478
+ // padding left = padding right = akEditorGutterPadding = 32
479
+ responsiveContainerWidth = isTableScalingEnabled ? containerWidth - padding * 2 : containerWidth - padding * 2 - resizeHandleSpacing;
480
+ }
481
+ const width = !node.attrs.width && isCommentEditor ? responsiveContainerWidth : Math.min(tableWidth, responsiveContainerWidth);
482
+ if (!isResizing) {
483
+ tableWidthRef.current = width;
484
+ }
485
+ const maxResizerWidth = isCommentEditor ? responsiveContainerWidth : Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
486
+
487
+ // CSS solution for table resizer item width
488
+ // The `width` is used for .resizer-item in <TableResizer>, and it has to be a number
489
+ // So we can't use min(var(--ak-editor-table-width), ${tableWidth}px) here
490
+ // We get the correct width from CSS value on page load
491
+ // After window resize, we use the width from plugin state
492
+ // After table resize, the table width attribute is used
493
+ const tableResizerItemWidth = useMemo(() => {
494
+ // if not on full page editor, we just rely on the width calculated from plugin state
495
+ // if on full page editor and after window resize, we use the width from plugin state
496
+ if (!isFullPageAppearance || isFullPageAppearance && isWindowResized) {
497
+ return width;
498
+ }
499
+ if (isResizing) {
500
+ return tableWidth;
501
+ }
502
+ // if on full page editor and on page load, we use the computed value from CSS
503
+ return Math.min(tableWidth, tableMaxWidthForFullPageOnLoad);
504
+ }, [isWindowResized, isResizing, isFullPageAppearance, tableMaxWidthForFullPageOnLoad, tableWidth, width]);
505
+
506
+ // CSS Solution for table resizer container width
507
+ const tableResizerContainerWidth = useMemo(() => {
508
+ return getTableResizerContainerForFullPageWidthInCSS(node, isTableScalingEnabled);
509
+ }, [node, isTableScalingEnabled]);
510
+
511
+ // CSS Solution for table resizer max width
512
+ const tableResizerMaxWidth = React.useMemo(() => {
513
+ const isFullPageAppearance = !isCommentEditor && !isChromelessEditor;
514
+ const nonResizingMaxWidth = isFullPageAppearance ? getTableResizerContainerMaxWidthInCSS(isCommentEditor, isChromelessEditor, isTableScalingEnabled) : maxResizerWidth;
515
+ // isResizing is needed, otherwise we can't resize table.
516
+ // when not resizing, maxWidth is calculated based on the container width via CSS
517
+ return !isResizing ? nonResizingMaxWidth : maxResizerWidth;
518
+ }, [isCommentEditor, isChromelessEditor, isTableScalingEnabled, isResizing, maxResizerWidth]);
519
+
520
+ // on SSR, the width would be the default state, which is tableWidth
521
+ // but because we have maxWidth set to the editor container width via CSS
522
+ // So it would work just fine
523
+ useEffect(() => {
524
+ var _containerRef$current5;
525
+ if (!isSSR() && isFullPageAppearance && (_containerRef$current5 = containerRef.current) !== null && _containerRef$current5 !== void 0 && _containerRef$current5.firstElementChild) {
526
+ // get the computed value of max-width from '.resizer-item', because it uses `cqw` unit in CSS
527
+ const computedStyle = window.getComputedStyle(containerRef.current.firstElementChild);
528
+ const containerWidth = computedStyle.maxWidth ? parseFloat(computedStyle.maxWidth) : tableWidth;
529
+ setTableMaxWidthForFullPageOnLoad(Math.min(containerWidth, tableWidth));
530
+ }
531
+ }, [tableWidthRef, tableWidth, isFullPageAppearance]);
532
+ const tableResizerProps = {
533
+ width: tableResizerItemWidth,
534
+ maxWidth: tableResizerMaxWidth,
535
+ containerWidth,
536
+ lineLength,
537
+ updateWidth,
538
+ editorView,
539
+ getPos,
540
+ node,
541
+ tableRef,
542
+ displayGuideline,
543
+ attachAnalyticsEvent,
544
+ displayGapCursor,
545
+ isTableAlignmentEnabled,
546
+ isFullWidthModeEnabled,
547
+ isTableScalingEnabled,
548
+ isTableWithFixedColumnWidthsOptionEnabled,
549
+ isWholeTableInDanger,
550
+ shouldUseIncreasedScalingPercent,
551
+ pluginInjectionApi,
552
+ onResizeStart,
553
+ onResizeStop,
554
+ isCommentEditor
555
+ };
556
+ const isLivePageViewMode = mode === 'view';
557
+ return /*#__PURE__*/React.createElement(AlignmentTableContainerWrapper, {
558
+ isTableAlignmentEnabled: isTableAlignmentEnabled,
559
+ node: node,
560
+ pluginInjectionApi: pluginInjectionApi,
561
+ getPos: getPos,
562
+ editorView: editorView
563
+ }, /*#__PURE__*/React.createElement("div", {
564
+ style: {
565
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
566
+ '--ak-editor-table-gutter-padding': 'calc(var(--ak-editor--large-gutter-padding) * 2)',
567
+ '--ak-editor-table-width': isFullPageAppearance ? tableResizerContainerWidth : `${tableWidthRef.current}px`,
568
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
569
+ width: 'var(--ak-editor-table-width)',
570
+ height: resizing ? updateContainerHeight(tableWrapperHeight !== null && tableWrapperHeight !== void 0 ? tableWrapperHeight : 'auto') : 'auto',
571
+ position: isLivePageViewMode ? 'relative' : 'unset'
572
+ }
573
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
574
+ ,
575
+ className: ClassName.TABLE_RESIZER_CONTAINER,
576
+ ref: containerRef
577
+ }, fg('platform_editor_live_page_prevent_table_recreation') ? null : isLivePageViewMode ? /*#__PURE__*/React.createElement(InnerContainer
578
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
579
+ , {
580
+ className: className,
581
+ node: node
582
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
583
+ ,
584
+ style: {
585
+ width: 'inherit'
586
+ }
587
+ }, children) :
588
+ /*#__PURE__*/
589
+ // Ignored via go/ees005
590
+ // eslint-disable-next-line react/jsx-props-no-spreading
591
+ React.createElement(TableResizer, tableResizerProps, /*#__PURE__*/React.createElement(InnerContainer, {
592
+ className: className,
593
+ node: node
594
+ }, children)), fg('platform_editor_live_page_prevent_table_recreation') ?
595
+ /*#__PURE__*/
596
+ // Ignored via go/ees005
597
+ // eslint-disable-next-line react/jsx-props-no-spreading
598
+ React.createElement(TableResizer, _extends({}, tableResizerProps, {
599
+ disabled: isLivePageViewMode
600
+ }), /*#__PURE__*/React.createElement(InnerContainer, {
601
+ className: className,
602
+ node: node
603
+ }, children)) : null));
604
+ });
605
+ export const ResizableTableContainer = componentWithCondition(() => expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true), ResizableTableContainerNext, ResizableTableContainerLegacy);
355
606
  export const TableContainer = ({
356
607
  children,
357
608
  node,
@@ -366,6 +617,7 @@ export const TableContainer = ({
366
617
  isNested,
367
618
  tableWrapperHeight,
368
619
  isResizing,
620
+ isWindowResized,
369
621
  pluginInjectionApi,
370
622
  isWholeTableInDanger,
371
623
  isTableResizingEnabled,
@@ -395,13 +647,15 @@ export const TableContainer = ({
395
647
  tableRef: tableRef,
396
648
  tableWrapperHeight: tableWrapperHeight,
397
649
  isResizing: isResizing,
650
+ isWindowResized: isWindowResized,
398
651
  pluginInjectionApi: pluginInjectionApi,
399
652
  isTableScalingEnabled: isTableScalingEnabled,
400
653
  isTableWithFixedColumnWidthsOptionEnabled: isTableWithFixedColumnWidthsOptionEnabled,
401
654
  isWholeTableInDanger: isWholeTableInDanger,
402
655
  isTableAlignmentEnabled: isTableAlignmentEnabled,
403
656
  shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent,
404
- isCommentEditor: isCommentEditor
657
+ isCommentEditor: isCommentEditor,
658
+ isChromelessEditor: isChromelessEditor
405
659
  }, children);
406
660
  }
407
661
  const {
@@ -404,8 +404,15 @@ export const TableResizer = ({
404
404
  }, [editorView, getPos, node, isCommentEditor, widthToWidest, endMeasure, displayGapCursor, displayGuideline, updateWidth, scheduleResize, onResizeStop, attachAnalyticsEvent, tableRef, pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent, formatMessage]);
405
405
  const handleTableSizeChangeOnKeypress = useCallback(step => {
406
406
  const newWidth = width + step;
407
- if (newWidth > maxWidth || newWidth < resizerMinWidth) {
408
- return;
407
+ if (expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true)) {
408
+ if (newWidth < resizerMinWidth) {
409
+ return;
410
+ }
411
+ } else {
412
+ // maxWidth when platform_editor_tables_scaling_css off is always a number
413
+ if (newWidth > maxWidth || newWidth < resizerMinWidth) {
414
+ return;
415
+ }
409
416
  }
410
417
  handleResizeStop({
411
418
  width: width,
@@ -21,8 +21,23 @@ const HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
21
21
  // if too short it would trigger too many dom updates.
22
22
  const HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT = 400;
23
23
  export default class TableRow extends TableNodeView {
24
- constructor(node, view, getPos, eventDispatcher) {
24
+ constructor(node, view, getPos, eventDispatcher, api) {
25
+ var _api$limitedMode, _api$limitedMode$shar, _api$limitedMode$shar2;
25
26
  super(node, view, getPos, eventDispatcher);
27
+ _defineProperty(this, "cleanup", () => {
28
+ if (this.isStickyHeaderEnabled) {
29
+ this.unsubscribe();
30
+ this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
31
+ const tree = getTree(this.dom);
32
+ if (tree) {
33
+ this.makeRowHeaderNotSticky(tree.table, true);
34
+ }
35
+ this.emitOff(false);
36
+ }
37
+ if (this.tableContainerObserver) {
38
+ this.tableContainerObserver.disconnect();
39
+ }
40
+ });
26
41
  _defineProperty(this, "colControlsOffset", 0);
27
42
  _defineProperty(this, "focused", false);
28
43
  _defineProperty(this, "topPosEditorElement", 0);
@@ -63,6 +78,11 @@ export default class TableRow extends TableNodeView {
63
78
  pluginConfig
64
79
  } = getPluginState(view.state);
65
80
  this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
81
+ if (api !== null && api !== void 0 && (_api$limitedMode = api.limitedMode) !== null && _api$limitedMode !== void 0 && (_api$limitedMode$shar = _api$limitedMode.sharedState.currentState()) !== null && _api$limitedMode$shar !== void 0 && (_api$limitedMode$shar2 = _api$limitedMode$shar.limitedModePluginKey.getState(view.state)) !== null && _api$limitedMode$shar2 !== void 0 && _api$limitedMode$shar2.documentSizeBreachesThreshold) {
82
+ this.isStickyHeaderEnabled = false;
83
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
84
+ document.addEventListener('limited-mode-activated', this.cleanup);
85
+ }
66
86
  const pos = this.getPos();
67
87
  this.isInNestedTable = false;
68
88
  if (pos) {
@@ -138,6 +158,9 @@ export default class TableRow extends TableNodeView {
138
158
  }
139
159
  this.emitOff(true);
140
160
  }
161
+
162
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
163
+ document.removeEventListener('limited-mode-activated', this.cleanup);
141
164
  if (this.tableContainerObserver) {
142
165
  this.tableContainerObserver.disconnect();
143
166
  }
@@ -21,6 +21,6 @@ export const tableHeaderView = options => {
21
21
  };
22
22
  export const tableRowView = options => {
23
23
  return (node, view, getPos) => {
24
- return new TableRow(node, view, getPos, options.eventDispatcher);
24
+ return new TableRow(node, view, getPos, options.eventDispatcher, options.pluginInjectionApi);
25
25
  };
26
26
  };
@@ -50,7 +50,9 @@ const handleInlineTableWidth = (table, width) => {
50
50
  };
51
51
  export default class TableView extends ReactNodeView {
52
52
  constructor(props) {
53
- super(props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props);
53
+ super(props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props, undefined, undefined,
54
+ // @portal-render-immediately
55
+ true);
54
56
  _defineProperty(this, "getNode", () => {
55
57
  return this.node;
56
58
  });
@@ -62,10 +64,17 @@ export default class TableView extends ReactNodeView {
62
64
  this.handleRef = node => this._handleTableRef(node);
63
65
  }
64
66
  getContentDOM() {
67
+ var _this$reactComponentP, _this$reactComponentP2, _this$reactComponentP3, _this$reactComponentP4;
68
+ const isNested = isTableNested(this.view.state, this.getPos());
65
69
  const tableDOMStructure = tableNodeSpecWithFixedToDOM({
66
70
  allowColumnResizing: !!this.reactComponentProps.allowColumnResizing,
67
71
  tableResizingEnabled: !!this.reactComponentProps.allowTableResizing,
68
- getEditorContainerWidth: this.reactComponentProps.getEditorContainerWidth
72
+ getEditorContainerWidth: this.reactComponentProps.getEditorContainerWidth,
73
+ isTableScalingEnabled: (_this$reactComponentP = this.reactComponentProps.options) === null || _this$reactComponentP === void 0 ? void 0 : _this$reactComponentP.isTableScalingEnabled,
74
+ shouldUseIncreasedScalingPercent: (_this$reactComponentP2 = this.reactComponentProps.options) === null || _this$reactComponentP2 === void 0 ? void 0 : _this$reactComponentP2.shouldUseIncreasedScalingPercent,
75
+ isCommentEditor: (_this$reactComponentP3 = this.reactComponentProps.options) === null || _this$reactComponentP3 === void 0 ? void 0 : _this$reactComponentP3.isCommentEditor,
76
+ isChromelessEditor: (_this$reactComponentP4 = this.reactComponentProps.options) === null || _this$reactComponentP4 === void 0 ? void 0 : _this$reactComponentP4.isChromelessEditor,
77
+ isNested
69
78
  }).toDOM(this.node);
70
79
  const rendered = DOMSerializer.renderSpec(document, tableDOMStructure);
71
80
  if (rendered.dom) {
@@ -169,6 +178,7 @@ export default class TableView extends ReactNodeView {
169
178
  }
170
179
  }
171
180
  render(props, forwardRef) {
181
+ var _props$pluginInjectio, _props$pluginInjectio2, _props$pluginInjectio3;
172
182
  if (fg('platform_editor_table_use_shared_state_hook_fg')) {
173
183
  return /*#__PURE__*/React.createElement(TableComponentWithSharedState, {
174
184
  forwardRef: forwardRef,
@@ -214,11 +224,12 @@ export default class TableView extends ReactNodeView {
214
224
  tableWidthPluginState: tableWidthPluginKey,
215
225
  widthPlugin: fakePluginKey,
216
226
  mediaState: fakeMediaPluginKey,
217
- tableDragAndDropState: tableDragAndDropPluginKey
227
+ tableDragAndDropState: tableDragAndDropPluginKey,
228
+ limitedModePlugin: (_props$pluginInjectio = props.pluginInjectionApi) === null || _props$pluginInjectio === void 0 ? void 0 : (_props$pluginInjectio2 = _props$pluginInjectio.limitedMode) === null || _props$pluginInjectio2 === void 0 ? void 0 : (_props$pluginInjectio3 = _props$pluginInjectio2.sharedState.currentState()) === null || _props$pluginInjectio3 === void 0 ? void 0 : _props$pluginInjectio3.limitedModePluginKey
218
229
  },
219
230
  editorView: props.view,
220
231
  render: pluginStates => {
221
- var _props$options;
232
+ var _props$options, _pluginStates$limited, _pluginStates$limited2;
222
233
  const {
223
234
  tableResizingPluginState,
224
235
  tableWidthPluginState,
@@ -287,7 +298,8 @@ export default class TableView extends ReactNodeView {
287
298
  contentDOM: forwardRef,
288
299
  getEditorFeatureFlags: props.getEditorFeatureFlags,
289
300
  dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
290
- pluginInjectionApi: props.pluginInjectionApi
301
+ pluginInjectionApi: props.pluginInjectionApi,
302
+ limitedMode: (_pluginStates$limited = (_pluginStates$limited2 = pluginStates.limitedModePlugin) === null || _pluginStates$limited2 === void 0 ? void 0 : _pluginStates$limited2.documentSizeBreachesThreshold) !== null && _pluginStates$limited !== void 0 ? _pluginStates$limited : false
291
303
  });
292
304
  }
293
305
  });
@@ -369,6 +381,8 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
369
381
  allowTableResizing,
370
382
  allowTableAlignment
371
383
  } = getPluginConfig(pluginConfig);
384
+ const isTableFixedColumnWidthsOptionEnabled = (getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags().tableWithFixedColumnWidthsOption) || false;
385
+ const shouldUseIncreasedScalingPercent = isTableScalingEnabled && (isTableFixedColumnWidthsOptionEnabled || isCommentEditor);
372
386
  return new TableView({
373
387
  node,
374
388
  view,
@@ -386,7 +400,8 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
386
400
  isTableScalingEnabled,
387
401
  // same as options.isTableScalingEnabled
388
402
  isCommentEditor,
389
- isChromelessEditor
403
+ isChromelessEditor,
404
+ shouldUseIncreasedScalingPercent
390
405
  },
391
406
  getEditorContainerWidth,
392
407
  getEditorFeatureFlags,
@@ -3,14 +3,16 @@ import { table, tableWithNestedTable } from '@atlaskit/adf-schema';
3
3
  import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
4
4
  import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
5
5
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
- import { generateColgroup, getResizerMinWidth } from '../pm-plugins/table-resizing/utils/colgroup';
6
+ import { generateColgroup, generateColgroupFromNode, getResizerMinWidth } from '../pm-plugins/table-resizing/utils/colgroup';
7
7
  import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils/consts';
8
+ import { getTableResizerContainerMaxWidthInCSS, getTableResizerContainerForFullPageWidthInCSS, getTableResizerItemWidthInCSS } from '../pm-plugins/table-resizing/utils/misc';
8
9
  import { getAlignmentStyle } from './table-container-styles';
9
10
  export const tableNodeSpecWithFixedToDOM = config => {
10
11
  const tableNode = config.isNestingSupported ? tableWithNestedTable : table;
11
12
  return {
12
13
  ...tableNode,
13
14
  toDOM: node => {
15
+ var _node$attrs$width;
14
16
  const gutterPadding = () => {
15
17
  if (expValEquals('platform_editor_preview_panel_responsiveness', 'isEnabled', true)) {
16
18
  return 'calc(var(--ak-editor--large-gutter-padding) * 2)';
@@ -20,6 +22,8 @@ export const tableNodeSpecWithFixedToDOM = config => {
20
22
  };
21
23
  const alignmentStyle = Object.entries(getAlignmentStyle(node.attrs.layout)).map(([k, v]) => `${kebabCase(k)}: ${kebabCase(v)}`).join(';');
22
24
  const tableMinWidth = getResizerMinWidth(node);
25
+ const tableWidthAttribute = node.attrs.width ? `${node.attrs.width}px` : `100%`;
26
+ const isFullPageEditor = !config.isChromelessEditor && !config.isCommentEditor;
23
27
  const attrs = {
24
28
  'data-number-column': node.attrs.isNumberColumnEnabled,
25
29
  'data-layout': node.attrs.layout,
@@ -27,10 +31,20 @@ export const tableNodeSpecWithFixedToDOM = config => {
27
31
  'data-table-local-id': node.attrs.localId,
28
32
  'data-table-width': node.attrs.width
29
33
  };
34
+
35
+ // This would be used for table scaling in colgroup CSS
36
+ // cqw, or px is well supported
37
+ const resizableTableWidth = expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) ? isFullPageEditor ? getTableResizerContainerForFullPageWidthInCSS(node, config.isTableScalingEnabled) : `calc(100cqw - calc(var(--ak-editor--large-gutter-padding) * 2))` : `min(calc(100cqw - calc(var(--ak-editor--large-gutter-padding) * 2)), ${(_node$attrs$width = node.attrs.width) !== null && _node$attrs$width !== void 0 ? _node$attrs$width : '100%'})`;
30
38
  let colgroup = '';
31
39
  if (config.allowColumnResizing) {
32
- colgroup = ['colgroup', {}, ...generateColgroup(node)];
40
+ if (expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true)) {
41
+ colgroup = ['colgroup', {}, ...generateColgroupFromNode(node, config.isCommentEditor, config.isChromelessEditor, config.isNested, config.isTableScalingEnabled, config.shouldUseIncreasedScalingPercent)];
42
+ } else {
43
+ colgroup = ['colgroup', {}, ...generateColgroup(node)];
44
+ }
33
45
  }
46
+
47
+ // For Chromeless editor, and nested tables in full page editor
34
48
  const tableContainerDiv = ['div', {
35
49
  class: 'pm-table-container',
36
50
  'data-number-column': node.attrs.isNumberColumnEnabled,
@@ -57,31 +71,33 @@ export const tableNodeSpecWithFixedToDOM = config => {
57
71
  class: 'pm-table-sticky-sentinel-bottom',
58
72
  'data-testid': 'sticky-sentinel-bottom'
59
73
  }]];
60
- if (!config.tableResizingEnabled) {
74
+ if (!config.tableResizingEnabled || expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) && config.isNested) {
61
75
  return ['div', {
62
76
  class: 'tableView-content-wrap',
63
77
  'data-prosemirror-initial-toDOM-render': 'true'
64
78
  }, tableContainerDiv];
65
79
  }
66
- const tableWidthAttribute = node.attrs.width ? `${node.attrs.width}px` : `100%`;
67
80
  const tableResizingDiv = ['div', {
68
81
  'data-testid': 'table-alignment-container',
69
82
  style: alignmentStyle
70
83
  }, ['div', {
71
84
  class: 'pm-table-resizer-container',
72
- style: `width: min(calc(100cqw - ${gutterPadding()}), ${tableWidthAttribute});`
85
+ style: convertToInlineCss({
86
+ '--ak-editor-table-gutter-padding': config.isTableScalingEnabled ? 'calc(var(--ak-editor--large-gutter-padding) * 2)' : 'calc(var(--ak-editor--large-gutter-padding) * 2 - var(--ak-editor-resizer-handle-spacing))',
87
+ '--ak-editor-table-width': resizableTableWidth,
88
+ width: expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) ? `var(--ak-editor-table-width)` : `min(calc(100cqw - ${gutterPadding()}), ${tableWidthAttribute})`
89
+ })
73
90
  }, ['div', {
74
91
  class: 'resizer-item display-handle',
75
92
  style: convertToInlineCss({
76
93
  position: 'relative',
77
94
  userSelect: 'auto',
78
95
  boxSizing: 'border-box',
79
- '--ak-editor-table-gutter-padding': `${gutterPadding()}`,
80
96
  '--ak-editor-table-max-width': `${TABLE_MAX_WIDTH}px`,
81
97
  '--ak-editor-table-min-width': `${tableMinWidth}px`,
82
98
  minWidth: 'var(--ak-editor-table-min-width)',
83
- maxWidth: `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))`,
84
- width: `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ${tableWidthAttribute})`
99
+ maxWidth: expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) ? getTableResizerContainerMaxWidthInCSS(config.isCommentEditor, config.isChromelessEditor, config.isTableScalingEnabled) : `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))`,
100
+ width: expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) ? getTableResizerItemWidthInCSS(node, config.isCommentEditor, config.isChromelessEditor) : `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ${tableWidthAttribute})`
85
101
  })
86
102
  }, ['span', {
87
103
  class: 'resizer-hover-zone'
@@ -7,6 +7,7 @@ import { findParentDomRefOfType, findParentNodeOfType } from '@atlaskit/editor-p
7
7
  import { TableMap } from '@atlaskit/editor-tables';
8
8
  import { findTable } from '@atlaskit/editor-tables/utils';
9
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
10
11
  import { tableCellView, tableHeaderView, tableRowView, tableView } from '../nodeviews/table-node-views';
11
12
  import { pluginKey as decorationsPluginKey } from '../pm-plugins/decorations/plugin';
12
13
  import { TableCssClassName as ClassName } from '../types';
@@ -50,29 +51,63 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
50
51
  }
51
52
  return editorView.state;
52
53
  };
53
- const nodeViews = isSSR() && fg('platform_editor_table_fallback_to_dom_on_ssr') ? undefined : {
54
- table: tableView({
55
- portalProviderAPI,
56
- eventDispatcher,
57
- getEditorContainerWidth,
58
- getEditorFeatureFlags,
59
- dispatchAnalyticsEvent,
60
- pluginInjectionApi,
61
- isCommentEditor,
62
- isChromelessEditor
63
- }),
64
- tableRow: tableRowView({
65
- eventDispatcher
66
- }),
67
- tableCell: tableCellView({
68
- eventDispatcher,
69
- pluginInjectionApi
70
- }),
71
- tableHeader: tableHeaderView({
72
- eventDispatcher,
73
- pluginInjectionApi
74
- })
54
+ const getNodeView = () => {
55
+ // Because the layout shift issues has been fixed under experiment platform_editor_tables_scaling_css, so still want to load nodeview on SSR if experiment is enabled
56
+ if (expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true)) {
57
+ return {
58
+ table: tableView({
59
+ portalProviderAPI,
60
+ eventDispatcher,
61
+ getEditorContainerWidth,
62
+ getEditorFeatureFlags,
63
+ dispatchAnalyticsEvent,
64
+ pluginInjectionApi,
65
+ isCommentEditor,
66
+ isChromelessEditor
67
+ }),
68
+ tableRow: tableRowView({
69
+ eventDispatcher,
70
+ pluginInjectionApi
71
+ }),
72
+ tableCell: tableCellView({
73
+ eventDispatcher,
74
+ pluginInjectionApi
75
+ }),
76
+ tableHeader: tableHeaderView({
77
+ eventDispatcher,
78
+ pluginInjectionApi
79
+ })
80
+ };
81
+ }
82
+ if (isSSR() && fg('platform_editor_table_fallback_to_dom_on_ssr')) {
83
+ return undefined;
84
+ }
85
+ return {
86
+ table: tableView({
87
+ portalProviderAPI,
88
+ eventDispatcher,
89
+ getEditorContainerWidth,
90
+ getEditorFeatureFlags,
91
+ dispatchAnalyticsEvent,
92
+ pluginInjectionApi,
93
+ isCommentEditor,
94
+ isChromelessEditor
95
+ }),
96
+ tableRow: tableRowView({
97
+ eventDispatcher,
98
+ pluginInjectionApi
99
+ }),
100
+ tableCell: tableCellView({
101
+ eventDispatcher,
102
+ pluginInjectionApi
103
+ }),
104
+ tableHeader: tableHeaderView({
105
+ eventDispatcher,
106
+ pluginInjectionApi
107
+ })
108
+ };
75
109
  };
110
+ const nodeViews = getNodeView();
76
111
  return new SafePlugin({
77
112
  state: state,
78
113
  key: pluginKey,