@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
@@ -15,6 +15,7 @@ var _utils2 = require("@atlaskit/editor-prosemirror/utils");
15
15
  var _editorTables = require("@atlaskit/editor-tables");
16
16
  var _utils3 = require("@atlaskit/editor-tables/utils");
17
17
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
18
19
  var _tableNodeViews = require("../nodeviews/table-node-views");
19
20
  var _plugin = require("../pm-plugins/decorations/plugin");
20
21
  var _types = require("../types");
@@ -59,29 +60,63 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
59
60
  }
60
61
  return editorView.state;
61
62
  };
62
- var nodeViews = (0, _coreUtils.isSSR)() && (0, _platformFeatureFlags.fg)('platform_editor_table_fallback_to_dom_on_ssr') ? undefined : {
63
- table: (0, _tableNodeViews.tableView)({
64
- portalProviderAPI: portalProviderAPI,
65
- eventDispatcher: eventDispatcher,
66
- getEditorContainerWidth: getEditorContainerWidth,
67
- getEditorFeatureFlags: getEditorFeatureFlags,
68
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
69
- pluginInjectionApi: pluginInjectionApi,
70
- isCommentEditor: isCommentEditor,
71
- isChromelessEditor: isChromelessEditor
72
- }),
73
- tableRow: (0, _tableNodeViews.tableRowView)({
74
- eventDispatcher: eventDispatcher
75
- }),
76
- tableCell: (0, _tableNodeViews.tableCellView)({
77
- eventDispatcher: eventDispatcher,
78
- pluginInjectionApi: pluginInjectionApi
79
- }),
80
- tableHeader: (0, _tableNodeViews.tableHeaderView)({
81
- eventDispatcher: eventDispatcher,
82
- pluginInjectionApi: pluginInjectionApi
83
- })
63
+ var getNodeView = function getNodeView() {
64
+ // 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
65
+ if ((0, _expValEquals.expValEquals)('platform_editor_tables_scaling_css', 'isEnabled', true)) {
66
+ return {
67
+ table: (0, _tableNodeViews.tableView)({
68
+ portalProviderAPI: portalProviderAPI,
69
+ eventDispatcher: eventDispatcher,
70
+ getEditorContainerWidth: getEditorContainerWidth,
71
+ getEditorFeatureFlags: getEditorFeatureFlags,
72
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
73
+ pluginInjectionApi: pluginInjectionApi,
74
+ isCommentEditor: isCommentEditor,
75
+ isChromelessEditor: isChromelessEditor
76
+ }),
77
+ tableRow: (0, _tableNodeViews.tableRowView)({
78
+ eventDispatcher: eventDispatcher,
79
+ pluginInjectionApi: pluginInjectionApi
80
+ }),
81
+ tableCell: (0, _tableNodeViews.tableCellView)({
82
+ eventDispatcher: eventDispatcher,
83
+ pluginInjectionApi: pluginInjectionApi
84
+ }),
85
+ tableHeader: (0, _tableNodeViews.tableHeaderView)({
86
+ eventDispatcher: eventDispatcher,
87
+ pluginInjectionApi: pluginInjectionApi
88
+ })
89
+ };
90
+ }
91
+ if ((0, _coreUtils.isSSR)() && (0, _platformFeatureFlags.fg)('platform_editor_table_fallback_to_dom_on_ssr')) {
92
+ return undefined;
93
+ }
94
+ return {
95
+ table: (0, _tableNodeViews.tableView)({
96
+ portalProviderAPI: portalProviderAPI,
97
+ eventDispatcher: eventDispatcher,
98
+ getEditorContainerWidth: getEditorContainerWidth,
99
+ getEditorFeatureFlags: getEditorFeatureFlags,
100
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
101
+ pluginInjectionApi: pluginInjectionApi,
102
+ isCommentEditor: isCommentEditor,
103
+ isChromelessEditor: isChromelessEditor
104
+ }),
105
+ tableRow: (0, _tableNodeViews.tableRowView)({
106
+ eventDispatcher: eventDispatcher,
107
+ pluginInjectionApi: pluginInjectionApi
108
+ }),
109
+ tableCell: (0, _tableNodeViews.tableCellView)({
110
+ eventDispatcher: eventDispatcher,
111
+ pluginInjectionApi: pluginInjectionApi
112
+ }),
113
+ tableHeader: (0, _tableNodeViews.tableHeaderView)({
114
+ eventDispatcher: eventDispatcher,
115
+ pluginInjectionApi: pluginInjectionApi
116
+ })
117
+ };
84
118
  };
119
+ var nodeViews = getNodeView();
85
120
  return new _safePlugin.SafePlugin({
86
121
  state: state,
87
122
  key: _pluginKey.pluginKey,
@@ -4,11 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.isMinCellWidthTable = exports.insertColgroupFromNode = exports.hasTableColumnBeenResized = exports.hasTableBeenResized = exports.getResizerMinWidth = exports.getColgroupChildrenLength = exports.getColWidthFix = exports.generateColgroup = void 0;
7
+ exports.isMinCellWidthTable = exports.insertColgroupFromNode = exports.hasTableColumnBeenResized = exports.hasTableBeenResized = exports.getResizerMinWidth = exports.getColgroupChildrenLength = exports.getColWidthFix = exports.generateColgroupFromNode = exports.generateColgroup = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _styles = require("@atlaskit/editor-common/styles");
10
10
  var _utils = require("@atlaskit/editor-common/utils");
11
11
  var _model = require("@atlaskit/editor-prosemirror/model");
12
+ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
12
13
  var _tableMap = require("@atlaskit/editor-tables/table-map");
13
14
  var _consts = require("./consts");
14
15
  var _misc = require("./misc");
@@ -21,6 +22,75 @@ var _misc = require("./misc");
21
22
  var getColWidthFix = exports.getColWidthFix = function getColWidthFix(colwidth, tableColumnCount) {
22
23
  return colwidth - 1 / tableColumnCount;
23
24
  };
25
+ var generateColStyle = function generateColStyle(fixedColWidth, tableWidth, isCommentEditor, isChromelessEditor, isNested, shouldUseIncreasedScalingPercent, isNumberColumnEnabled, isTableHasWidth, hasTableBeenResized) {
26
+ var maxScalingPercent = shouldUseIncreasedScalingPercent ? _consts.MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION : _consts.MAX_SCALING_PERCENT;
27
+ var maxScaledRatio = 1 - maxScalingPercent;
28
+ var isFullPageEditor = !isChromelessEditor && !isCommentEditor;
29
+
30
+ // for nested tables, or chromeless editor, which used non resizable table container
31
+ if (isNested || isChromelessEditor) {
32
+ if (hasTableBeenResized) {
33
+ return "width: max(".concat(fixedColWidth, "px, ").concat(_styles.tableCellMinWidth, "px)");
34
+ }
35
+ return "width: ".concat(_styles.tableCellMinWidth, "px)");
36
+ }
37
+ if (isFullPageEditor || !isFullPageEditor && isTableHasWidth) {
38
+ var scaledPercent = isNumberColumnEnabled ? "calc(calc(var(--ak-editor-table-width) - ".concat(_editorSharedStyles.akEditorTableNumberColumnWidth, "px - 1px)/").concat(tableWidth, ")") : "calc(calc(var(--ak-editor-table-width) - 1px)/".concat(tableWidth, ")");
39
+ return "width: max(calc(".concat(fixedColWidth, "px * ").concat(maxScaledRatio, "), calc(").concat(fixedColWidth, " * ").concat(scaledPercent, "), ").concat(_styles.tableCellMinWidth, "px)");
40
+ }
41
+ // table resized to full-width in comment editor
42
+ // it doesn't have a width attribute, and cols has been resized
43
+ if (hasTableBeenResized) {
44
+ var _scaledPercent = isNumberColumnEnabled ? "calc(calc(var(--ak-editor-table-width) - ".concat(_editorSharedStyles.akEditorTableNumberColumnWidth, "px - 1px)/").concat(tableWidth, ")") : "calc(calc(var(--ak-editor-table-width) - 1px)/".concat(tableWidth, ")");
45
+ return "width: max(calc(".concat(fixedColWidth, " * ").concat(_scaledPercent, "), ").concat(_styles.tableCellMinWidth, "px)");
46
+ }
47
+ return "width: ".concat(_styles.tableCellMinWidth, "px");
48
+ };
49
+ var generateColgroupFromNode = exports.generateColgroupFromNode = function generateColgroupFromNode(table, isCommentEditor, isChromelessEditor, isNested, isTableScalingEnabled, shouldUseIncreasedScalingPercent) {
50
+ var cols = [];
51
+ var map = _tableMap.TableMap.get(table);
52
+ var isTableHasWidth = !!table.attrs.width;
53
+ var isNumberColumnEnabled = table.attrs.isNumberColumnEnabled || false;
54
+ var isFullPageEditor = !isChromelessEditor && !isCommentEditor;
55
+
56
+ // Ignored via go/ees005
57
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
58
+ table.content.firstChild.content.forEach(function (cell) {
59
+ var colspan = cell.attrs.colspan || 1;
60
+ // if the table has been resized
61
+ if (Array.isArray(cell.attrs.colwidth)) {
62
+ cell.attrs.colwidth.slice(0, colspan).forEach(function (width) {
63
+ // existing logic for calculating the width of the column
64
+ var fixedColWidth = getColWidthFix(width, map.width);
65
+ var tableWidth = isFullPageEditor || !isFullPageEditor && isTableHasWidth ? (0, _misc.getTableContainerElementWidth)(table) : (0, _utils.calcTableColumnWidths)(table).reduce(function (sum, width) {
66
+ return sum + width;
67
+ }, 0);
68
+ if (isTableScalingEnabled) {
69
+ cols.push(['col', {
70
+ style: generateColStyle(fixedColWidth, tableWidth, isCommentEditor, isChromelessEditor, isNested, shouldUseIncreasedScalingPercent, isNumberColumnEnabled, isTableHasWidth, true)
71
+ }]);
72
+ } else {
73
+ cols.push(['col', {
74
+ style: "width: max(".concat(fixedColWidth, "px, ").concat(_styles.tableCellMinWidth, "px)")
75
+ }]);
76
+ }
77
+ });
78
+ } else {
79
+ // columns has not been resized, so distribute the width evenly
80
+ cols.push.apply(cols, (0, _toConsumableArray2.default)(Array.from({
81
+ length: colspan
82
+ }, function (_) {
83
+ var tableWidth = (0, _misc.getTableContainerElementWidth)(table);
84
+ var columnWidth = tableWidth / map.width || 0;
85
+ var fixedColWidth = getColWidthFix(columnWidth, map.width || 0);
86
+ return ['col', {
87
+ style: generateColStyle(fixedColWidth, tableWidth, isCommentEditor, isChromelessEditor, isNested, shouldUseIncreasedScalingPercent, isNumberColumnEnabled, isTableHasWidth)
88
+ }];
89
+ })));
90
+ }
91
+ });
92
+ return cols;
93
+ };
24
94
  var generateColgroup = exports.generateColgroup = function generateColgroup(table, tableRef, shouldUseIncreasedScalingPercent, isCommentEditor) {
25
95
  var cols = [];
26
96
  var map = _tableMap.TableMap.get(table);
@@ -42,6 +112,7 @@ var generateColgroup = exports.generateColgroup = function generateColgroup(tabl
42
112
  scalePercent = (0, _misc.getTableScalingPercent)(table, tableRef, shouldUseIncreasedScalingPercent);
43
113
  }
44
114
  cell.attrs.colwidth.slice(0, colspan).forEach(function (width) {
115
+ // existing logic for calculating the width of the column
45
116
  var fixedColWidth = getColWidthFix(width, map.width);
46
117
  var scaledWidth = fixedColWidth * scalePercent;
47
118
  var finalWidth = Math.max(scaledWidth, _styles.tableCellMinWidth);
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.currentColWidth = currentColWidth;
7
7
  exports.getLayoutSize = getLayoutSize;
8
- exports.getTableScalingPercent = exports.getTableMaxWidth = exports.getTableElementWidth = exports.getTableContainerElementWidth = exports.getStaticTableScalingPercent = exports.getScalingPercentForTableWithoutWidth = void 0;
8
+ exports.getTableScalingPercent = exports.getTableResizerItemWidthInCSS = exports.getTableResizerItemWidth = exports.getTableResizerContainerMaxWidthInCSS = exports.getTableResizerContainerForFullPageWidthInCSS = exports.getTableMaxWidth = exports.getTableElementWidth = exports.getTableContainerElementWidth = exports.getStaticTableScalingPercent = exports.getScalingPercentForTableWithoutWidth = void 0;
9
9
  exports.pointsAtCell = pointsAtCell;
10
10
  var _nodeWidth = require("@atlaskit/editor-common/node-width");
11
11
  var _styles = require("@atlaskit/editor-common/styles");
@@ -93,6 +93,75 @@ var getTableElementWidth = exports.getTableElementWidth = function getTableEleme
93
93
  var getTableContainerElementWidth = exports.getTableContainerElementWidth = function getTableContainerElementWidth(table) {
94
94
  return (0, _nodeWidth.getTableContainerWidth)(table);
95
95
  };
96
+
97
+ // eslint-disable-next-line jsdoc/require-example
98
+ /**
99
+ * This function is used to set the max width for table resizer container.
100
+ * @param isCommentEditor Whether the editor is in comment mode.
101
+ * @param isChromelessEditor Whether the editor is chromeless.
102
+ * @param isTableScalingEnabled Whether table scaling is enabled.
103
+ * @returns The CSS max-width value
104
+ */
105
+ var getTableResizerContainerMaxWidthInCSS = exports.getTableResizerContainerMaxWidthInCSS = function getTableResizerContainerMaxWidthInCSS(isCommentEditor, isChromelessEditor, isTableScalingEnabled) {
106
+ var maxResizerWidthForNonCommentEditor = isTableScalingEnabled ? "min(calc(100cqw - calc(var(--ak-editor--large-gutter-padding) * 2)), ".concat(_consts.TABLE_MAX_WIDTH, "px)") : "min(calc(100cqw - calc(var(--ak-editor--large-gutter-padding) * 2) - var(--ak-editor--resizer-handle-spacing)), ".concat(_consts.TABLE_MAX_WIDTH, "px)");
107
+ return isCommentEditor || isChromelessEditor ? '100%' : maxResizerWidthForNonCommentEditor;
108
+ };
109
+
110
+ // eslint-disable-next-line jsdoc/require-example
111
+ /**
112
+ * This function is used in NodeView for TableResizer to set the max width for table resizer container
113
+ * @param node The ProseMirror node representing the table.
114
+ * @param isCommentEditor Whether the editor is in comment mode.
115
+ * @param isChromelessEditor Whether the editor is chromeless.
116
+ * @returns The CSS max-width value for the table resizer container.
117
+ */
118
+ var getTableResizerItemWidth = exports.getTableResizerItemWidth = function getTableResizerItemWidth(node, isCommentEditor, isChromelessEditor) {
119
+ var tableWidthAttribute = (0, _nodeWidth.getTableContainerWidth)(node);
120
+ if (!node.attrs.width && (isCommentEditor || isChromelessEditor)) {
121
+ // width undefined would make .resizer-item width to be `auto`
122
+ return undefined;
123
+ }
124
+ return tableWidthAttribute;
125
+ };
126
+
127
+ // eslint-disable-next-line jsdoc/require-example
128
+ /**
129
+ * This function is used to set the CSS width value for the table resizer-item.
130
+ * Because comment and chromeless editors don't have container-type: inline-size set,
131
+ * we need to calculate the width based on the table node width.
132
+ * If the table node width is not set, it will return 'auto'.
133
+ * This is used in table toDOM
134
+ * @param node The ProseMirror node representing the table.
135
+ * @param isCommentEditor Whether the editor is in comment mode.
136
+ * @param isChromelessEditor Whether the editor is chromeless.
137
+ * @returns The CSS width value for the table container.
138
+ */
139
+ var getTableResizerItemWidthInCSS = exports.getTableResizerItemWidthInCSS = function getTableResizerItemWidthInCSS(node, isCommentEditor, isChromelessEditor) {
140
+ var tableWidthAttribute = getTableResizerItemWidth(node, isCommentEditor, isChromelessEditor);
141
+ return tableWidthAttribute ? "".concat(tableWidthAttribute, "px") : 'auto';
142
+ };
143
+
144
+ // eslint-disable-next-line jsdoc/require-example
145
+ /**
146
+ * This function is used to set the table width --ak-editor-table-width CSS property for full page editor.
147
+ * Which is applied to the table resizer container.
148
+ * For Full page appearance, we don't need to use containerWidth from JS, as we can use cqw value.
149
+ * So we set dynamic containerWidth from JS to CSS property.
150
+ * @param node The ProseMirror node representing the table.
151
+ * @param isCommentEditor Whether the editor is in comment mode.
152
+ * @param isChromelessEditor Whether the editor is chromeless.
153
+ * @param isTableScalingEnabled Whether table scaling is enabled.
154
+ * @param tableWidthFromJS The width of the container element. In toDOM it'd be undefined, but will have a value from nodeView.
155
+ * @returns The CSS width value for the table.
156
+ */
157
+ var getTableResizerContainerForFullPageWidthInCSS = exports.getTableResizerContainerForFullPageWidthInCSS = function getTableResizerContainerForFullPageWidthInCSS(node, isTableScalingEnabled) {
158
+ var tableWidth = getTableContainerElementWidth(node);
159
+ // for full page appearance
160
+ if (isTableScalingEnabled) {
161
+ return "min(calc(100cqw - calc(var(--ak-editor--large-gutter-padding) * 2)), ".concat(tableWidth, "px)");
162
+ }
163
+ return "min(calc(100cqw - calc(var(--ak-editor--large-gutter-padding) * 2) - var(--ak-editor--resizer-handle-spacing)), ".concat(tableWidth, "px)");
164
+ };
96
165
  var getTableScalingPercent = exports.getTableScalingPercent = function getTableScalingPercent(table, tableRef, shouldUseIncreasedScalingPercent) {
97
166
  var _tableRef$parentEleme;
98
167
  var maxScalingPercent = shouldUseIncreasedScalingPercent ? _consts.MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION : _consts.MAX_SCALING_PERCENT;
@@ -240,18 +240,28 @@ var tablePlugin = function tablePlugin(_ref) {
240
240
  } : (0, _insert.insertTableWithSize)(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, options === null || options === void 0 ? void 0 : options.tableOptions.allowTableAlignment, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, options === null || options === void 0 ? void 0 : options.isCommentEditor)
241
241
  },
242
242
  nodes: function nodes() {
243
- var _options$tableOptions2;
243
+ var _options$tableOptions2, _options$getEditorFea3;
244
244
  var _pluginConfig = (0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions),
245
245
  allowColumnResizing = _pluginConfig.allowColumnResizing;
246
246
  // TODO: ED-25901 - We need to move this into a plugin config option so we don't accidentally enable nested nodes in Jira
247
247
  var isNestingSupported = Boolean(options === null || options === void 0 || (_options$tableOptions2 = options.tableOptions) === null || _options$tableOptions2 === void 0 ? void 0 : _options$tableOptions2.allowNestedTables);
248
+ var isTableFixedColumnWidthsOptionEnabled = (options === null || options === void 0 || (_options$getEditorFea3 = options.getEditorFeatureFlags) === null || _options$getEditorFea3 === void 0 ? void 0 : _options$getEditorFea3.call(options).tableWithFixedColumnWidthsOption) || false;
249
+ var shouldUseIncreasedScalingPercent = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && (isTableFixedColumnWidthsOptionEnabled || ( // When in comment editor, we need the scaling percent to be 40% while tableWithFixedColumnWidthsOption is not visible
250
+ options === null || options === void 0 ? void 0 : options.isCommentEditor));
251
+ var isTableScalingEnabled = options === null || options === void 0 ? void 0 : options.isTableScalingEnabled;
252
+ var isCommentEditor = options === null || options === void 0 ? void 0 : options.isCommentEditor;
253
+ var isChromelessEditor = options === null || options === void 0 ? void 0 : options.isChromelessEditor;
248
254
  return isNestingSupported ? [{
249
255
  name: 'table',
250
256
  node: (0, _toDOM.tableNodeSpecWithFixedToDOM)({
251
257
  allowColumnResizing: Boolean(allowColumnResizing),
252
258
  tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing),
253
259
  getEditorContainerWidth: defaultGetEditorContainerWidth,
254
- isNestingSupported: isNestingSupported
260
+ isNestingSupported: isNestingSupported,
261
+ isTableScalingEnabled: isTableScalingEnabled,
262
+ shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent,
263
+ isCommentEditor: isCommentEditor,
264
+ isChromelessEditor: isChromelessEditor
255
265
  })
256
266
  }, {
257
267
  name: 'tableHeader',
@@ -268,7 +278,11 @@ var tablePlugin = function tablePlugin(_ref) {
268
278
  allowColumnResizing: Boolean(allowColumnResizing),
269
279
  tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing),
270
280
  getEditorContainerWidth: defaultGetEditorContainerWidth,
271
- isNestingSupported: isNestingSupported
281
+ isNestingSupported: isNestingSupported,
282
+ isTableScalingEnabled: isTableScalingEnabled,
283
+ shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent,
284
+ isCommentEditor: isCommentEditor,
285
+ isChromelessEditor: isChromelessEditor
272
286
  })
273
287
  }, {
274
288
  name: 'tableHeader',
@@ -13,10 +13,9 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
13
13
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
14
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
15
  var _react = _interopRequireWildcard(require("react"));
16
- var _classnames3 = _interopRequireDefault(require("classnames"));
16
+ var _classnames2 = _interopRequireDefault(require("classnames"));
17
17
  var _state = require("@atlaskit/editor-prosemirror/state");
18
18
  var _utils = require("@atlaskit/editor-tables/utils");
19
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
20
19
  var _commands = require("../../../pm-plugins/commands");
21
20
  var _rowControls = require("../../../pm-plugins/utils/row-controls");
22
21
  var _types = require("../../../types");
@@ -94,11 +93,7 @@ var NumberColumn = exports.default = /*#__PURE__*/function (_Component) {
94
93
  isResizing = _this$props4.isResizing,
95
94
  tableActive = _this$props4.tableActive;
96
95
  var isActive = (0, _utils.isRowSelected)(index)(editorView.state.selection) || (hoveredRows || []).indexOf(index) !== -1 && !isResizing;
97
- if ((0, _platformFeatureFlags.fg)('platform_editor_nested_tables_number_column_fixes')) {
98
- return (0, _classnames3.default)(_types.TableCssClassName.NUMBERED_COLUMN_BUTTON, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _types.TableCssClassName.NUMBERED_COLUMN_BUTTON_DISABLED, isButtonDisabled), _types.TableCssClassName.HOVERED_CELL_IN_DANGER, tableActive && isActive && isInDanger), _types.TableCssClassName.HOVERED_CELL_ACTIVE, tableActive && isActive));
99
- } else {
100
- return (0, _classnames3.default)(_types.TableCssClassName.NUMBERED_COLUMN_BUTTON, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _types.TableCssClassName.NUMBERED_COLUMN_BUTTON_DISABLED, isButtonDisabled), _types.TableCssClassName.HOVERED_CELL_IN_DANGER, isActive && isInDanger), _types.TableCssClassName.HOVERED_CELL_ACTIVE, isActive));
101
- }
96
+ return (0, _classnames2.default)(_types.TableCssClassName.NUMBERED_COLUMN_BUTTON, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _types.TableCssClassName.NUMBERED_COLUMN_BUTTON_DISABLED, isButtonDisabled), _types.TableCssClassName.HOVERED_CELL_IN_DANGER, tableActive && isActive && isInDanger), _types.TableCssClassName.HOVERED_CELL_ACTIVE, tableActive && isActive));
102
97
  });
103
98
  return _this;
104
99
  }
@@ -78,7 +78,8 @@ class TableComponent extends React.Component {
78
78
  [ShadowEvent.SHOW_BEFORE_SHADOW]: false,
79
79
  [ShadowEvent.SHOW_AFTER_SHADOW]: false,
80
80
  tableWrapperWidth: undefined,
81
- tableWrapperHeight: undefined
81
+ tableWrapperHeight: undefined,
82
+ windowResized: false
82
83
  });
83
84
  _defineProperty(this, "holdCompleted", false);
84
85
  _defineProperty(this, "dispatchEventName", `tableResized-${generateUniqueTableId()}`);
@@ -330,6 +331,16 @@ class TableComponent extends React.Component {
330
331
  parentWidth: parentWidth
331
332
  });
332
333
  });
334
+ // This is a new handler for window resize events that sets the windowResized state immediately
335
+ // This is needed to update colgroup on window resize, to enforce the table scaling
336
+ _defineProperty(this, "handleWindowResizeNew", () => {
337
+ // Set resizing to true immediately
338
+ if (!this.state.windowResized) {
339
+ this.setState({
340
+ windowResized: true
341
+ });
342
+ }
343
+ });
333
344
  _defineProperty(this, "getParentNodeWidth", () => {
334
345
  const {
335
346
  getPos,
@@ -352,11 +363,31 @@ class TableComponent extends React.Component {
352
363
  });
353
364
  });
354
365
  _defineProperty(this, "tableNodeLayoutSize", (node, containerWidth, options) => getLayoutSize(node.attrs.layout, containerWidth || this.props.containerWidth.width, options || this.props.options || {}));
366
+ _defineProperty(this, "shouldUpdateColgroup", params => {
367
+ var _this$props$options, _this$props$options2;
368
+ const {
369
+ isWindowResized,
370
+ isWidthChanged,
371
+ isTableWidthChanged,
372
+ isColumnsDistributed,
373
+ isTableResizedFullWidth,
374
+ isTableDisplayModeChanged,
375
+ isNumberColumnChanged,
376
+ isNumberOfColumnsChanged,
377
+ isFullWidthModeAndLineLengthChanged
378
+ } = params;
379
+ const isFullPageEditor = !((_this$props$options = this.props.options) !== null && _this$props$options !== void 0 && _this$props$options.isCommentEditor) && !((_this$props$options2 = this.props.options) !== null && _this$props$options2 !== void 0 && _this$props$options2.isChromelessEditor);
380
+ if (expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) && isFullPageEditor) {
381
+ return !!isWindowResized || isColumnsDistributed || !!isTableResizedFullWidth || isTableDisplayModeChanged || isNumberColumnChanged || isNumberOfColumnsChanged || !!isFullWidthModeAndLineLengthChanged;
382
+ }
383
+ return isWidthChanged || isTableWidthChanged || isColumnsDistributed || !!isTableResizedFullWidth || isTableDisplayModeChanged || isNumberColumnChanged || isNumberOfColumnsChanged || !!isFullWidthModeAndLineLengthChanged;
384
+ });
355
385
  _defineProperty(this, "scaleTableDebounced", rafSchedule(this.scaleTable));
356
386
  _defineProperty(this, "handleTableResizingDebounced", rafSchedule(this.handleTableResizing));
357
387
  _defineProperty(this, "handleScrollDebounced", rafSchedule(this.handleScroll));
358
388
  _defineProperty(this, "handleAutoSizeDebounced", rafSchedule(this.handleAutoSize));
359
389
  _defineProperty(this, "handleWindowResizeDebounced", rafSchedule(this.handleWindowResize));
390
+ _defineProperty(this, "handleWindowResizeNewDebounced", rafSchedule(this.handleWindowResizeNew));
360
391
  _defineProperty(this, "updateShadowStateDebounced", rafSchedule(this.updateShadowState));
361
392
  const {
362
393
  options: _options,
@@ -445,11 +476,13 @@ class TableComponent extends React.Component {
445
476
  const {
446
477
  tableWithFixedColumnWidthsOption = false
447
478
  } = getEditorFeatureFlags();
448
- if (isTableScalingEnabled && !tableWithFixedColumnWidthsOption) {
449
- this.handleColgroupUpdates(true);
450
- }
451
- if (isTableScalingEnabled && tableWithFixedColumnWidthsOption && getNode().attrs.displayMode !== 'fixed') {
452
- this.handleColgroupUpdates(true);
479
+ if (!expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true)) {
480
+ if (isTableScalingEnabled && !tableWithFixedColumnWidthsOption) {
481
+ this.handleColgroupUpdates(true);
482
+ }
483
+ if (isTableScalingEnabled && tableWithFixedColumnWidthsOption && getNode().attrs.displayMode !== 'fixed') {
484
+ this.handleColgroupUpdates(true);
485
+ }
453
486
  }
454
487
  if (this.wrapper) {
455
488
  this.wrapperReisizeObserver = new ResizeObserver(entries => {
@@ -492,6 +525,8 @@ class TableComponent extends React.Component {
492
525
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
493
526
  window.addEventListener('resize', this.handleWindowResizeDebounced);
494
527
  }
528
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
529
+ window.addEventListener('resize', this.handleWindowResizeNewDebounced);
495
530
  this.handleTableResizingDebounced();
496
531
  }
497
532
  const currentStickyState = stickyHeadersPluginKey.getState(this.props.view.state);
@@ -538,11 +573,16 @@ class TableComponent extends React.Component {
538
573
  if (!allowTableResizing) {
539
574
  this.handleWindowResizeDebounced.cancel();
540
575
  }
576
+ this.handleWindowResizeNewDebounced.cancel();
541
577
  if (!allowTableResizing && allowColumnResizing) {
542
578
  // Ignored via go/ees005
543
579
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
544
580
  window.removeEventListener('resize', this.handleWindowResizeDebounced);
545
581
  }
582
+ if (allowColumnResizing) {
583
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
584
+ window.removeEventListener('resize', this.handleWindowResizeNewDebounced);
585
+ }
546
586
 
547
587
  // Ignored via go/ees005
548
588
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
@@ -629,22 +669,32 @@ class TableComponent extends React.Component {
629
669
  } = containerWidth;
630
670
  const isLineLengthChanged = ((_this$containerWidth = this.containerWidth) === null || _this$containerWidth === void 0 ? void 0 : _this$containerWidth.lineLength) !== containerLineLength;
631
671
  const isFullWidthModeAndLineLengthChanged = this.updateColGroupFromFullWidthChange && isLineLengthChanged && fg('platform_editor_table_overflow_in_full_width_fix');
632
- const maybeScale = isTableSquashed || isTableWidthChanged || isTableResizedFullWidth && !(options !== null && options !== void 0 && options.isCommentEditor) || isNumberColumnChanged || isNumberOfColumnsChanged;
672
+ const maybeScale = isTableSquashed || isTableWidthChanged || isTableResizedFullWidth && !(options !== null && options !== void 0 && options.isCommentEditor) || isNumberColumnChanged || isNumberOfColumnsChanged || expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) && this.state.windowResized;
633
673
  if (force || maybeScale || isFullWidthModeAndLineLengthChanged) {
634
- var _this$containerWidth2, _this$props$options, _this$props$options2, _this$props$options3;
674
+ var _this$containerWidth2, _this$props$options3, _this$props$options4, _this$props$options5;
635
675
  const isWidthChanged = ((_this$containerWidth2 = this.containerWidth) === null || _this$containerWidth2 === void 0 ? void 0 : _this$containerWidth2.width) !== containerWidthValue;
636
676
  const wasTableResized = hasTableBeenResized(this.node);
637
677
  const isTableResized = hasTableBeenResized(tableNode);
638
678
  const isColumnsDistributed = wasTableResized && !isTableResized;
639
679
  const isTableDisplayModeChanged = this.node.attrs.displayMode !== tableNode.attrs.displayMode;
640
- const shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged || isNumberColumnChanged || isNumberOfColumnsChanged || isFullWidthModeAndLineLengthChanged;
680
+ const shouldUpdateColgroup = this.shouldUpdateColgroup({
681
+ isWindowResized: this.state.windowResized,
682
+ isWidthChanged,
683
+ isTableWidthChanged,
684
+ isColumnsDistributed,
685
+ isTableResizedFullWidth,
686
+ isTableDisplayModeChanged,
687
+ isNumberColumnChanged,
688
+ isNumberOfColumnsChanged,
689
+ isFullWidthModeAndLineLengthChanged
690
+ });
641
691
  const {
642
692
  tableWithFixedColumnWidthsOption = false
643
693
  } = getEditorFeatureFlags();
644
- const isTableScalingWithFixedColumnWidthsOptionEnabled = !!((_this$props$options = this.props.options) !== null && _this$props$options !== void 0 && _this$props$options.isTableScalingEnabled) && tableWithFixedColumnWidthsOption;
645
- const shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled || !!((_this$props$options2 = this.props.options) !== null && _this$props$options2 !== void 0 && _this$props$options2.isTableScalingEnabled) && !!((_this$props$options3 = this.props.options) !== null && _this$props$options3 !== void 0 && _this$props$options3.isCommentEditor);
694
+ const isTableScalingWithFixedColumnWidthsOptionEnabled = !!((_this$props$options3 = this.props.options) !== null && _this$props$options3 !== void 0 && _this$props$options3.isTableScalingEnabled) && tableWithFixedColumnWidthsOption;
695
+ const shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled || !!((_this$props$options4 = this.props.options) !== null && _this$props$options4 !== void 0 && _this$props$options4.isTableScalingEnabled) && !!((_this$props$options5 = this.props.options) !== null && _this$props$options5 !== void 0 && _this$props$options5.isCommentEditor);
646
696
  if (force || !isResizing && shouldUpdateColgroup) {
647
- var _this$props$options4, _this$props$options5, _this$props$options6, _this$props$options7;
697
+ var _this$props$options6, _this$props$options7, _this$props$options8, _this$props$options9;
648
698
  const resizeState = getResizeState({
649
699
  minWidth: COLUMN_MIN_WIDTH,
650
700
  // When numbered column enabled, we need to subtract the width of the numbered column
@@ -655,25 +705,25 @@ class TableComponent extends React.Component {
655
705
  domAtPos: view.domAtPos.bind(view),
656
706
  isTableScalingEnabled: true,
657
707
  shouldUseIncreasedScalingPercent,
658
- isCommentEditor: !!((_this$props$options4 = this.props.options) !== null && _this$props$options4 !== void 0 && _this$props$options4.isCommentEditor)
708
+ isCommentEditor: !!((_this$props$options6 = this.props.options) !== null && _this$props$options6 !== void 0 && _this$props$options6.isCommentEditor)
659
709
  });
660
710
  let shouldScaleOnColgroupUpdate = false;
661
- if ((_this$props$options5 = this.props.options) !== null && _this$props$options5 !== void 0 && _this$props$options5.isTableScalingEnabled && !tableWithFixedColumnWidthsOption) {
711
+ if ((_this$props$options7 = this.props.options) !== null && _this$props$options7 !== void 0 && _this$props$options7.isTableScalingEnabled && !tableWithFixedColumnWidthsOption) {
662
712
  shouldScaleOnColgroupUpdate = true;
663
713
  }
664
714
  if (isTableScalingWithFixedColumnWidthsOptionEnabled && tableNode.attrs.displayMode !== 'fixed') {
665
715
  shouldScaleOnColgroupUpdate = true;
666
716
  }
667
- if ((_this$props$options6 = this.props.options) !== null && _this$props$options6 !== void 0 && _this$props$options6.isTableScalingEnabled && (_this$props$options7 = this.props.options) !== null && _this$props$options7 !== void 0 && _this$props$options7.isCommentEditor) {
717
+ if ((_this$props$options8 = this.props.options) !== null && _this$props$options8 !== void 0 && _this$props$options8.isTableScalingEnabled && (_this$props$options9 = this.props.options) !== null && _this$props$options9 !== void 0 && _this$props$options9.isCommentEditor) {
668
718
  shouldScaleOnColgroupUpdate = true;
669
719
  }
670
720
  let scalePercent = 1;
671
721
  requestAnimationFrame(() => {
672
- var _this$props$options8, _this$props$options9;
722
+ var _this$props$options0, _this$props$options1;
673
723
  // Scaling percent has to be calculated inside requestAnimationFrame, otherwise
674
724
  // renderWidth calculated as `tableRef?.parentElement?.clientWidth`
675
725
  // inside of getTableScalingPercent returns 0.
676
- if (!((_this$props$options8 = this.props.options) !== null && _this$props$options8 !== void 0 && _this$props$options8.isCommentEditor) || (_this$props$options9 = this.props.options) !== null && _this$props$options9 !== void 0 && _this$props$options9.isCommentEditor && tableNode.attrs.width) {
726
+ if (!((_this$props$options0 = this.props.options) !== null && _this$props$options0 !== void 0 && _this$props$options0.isCommentEditor) || (_this$props$options1 = this.props.options) !== null && _this$props$options1 !== void 0 && _this$props$options1.isCommentEditor && tableNode.attrs.width) {
677
727
  scalePercent = getTableScalingPercent(tableNode,
678
728
  // Ignored via go/ees005
679
729
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -711,7 +761,7 @@ class TableComponent extends React.Component {
711
761
  // Ignored via go/ees005
712
762
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
713
763
  componentDidUpdate(_, prevState) {
714
- var _this$props$options0, _this$props$options1, _this$wrapper2;
764
+ var _this$props$options10, _this$props$options11, _this$wrapper2;
715
765
  const {
716
766
  view,
717
767
  getNode,
@@ -743,18 +793,21 @@ class TableComponent extends React.Component {
743
793
  shouldHandleColgroupUpdates = true;
744
794
  }
745
795
  const isTableScalingWithFixedColumnWidthsOptionEnabled = !!isTableScalingEnabled && tableWithFixedColumnWidthsOption;
746
- const shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled || !!isTableScalingEnabled && !!((_this$props$options0 = this.props.options) !== null && _this$props$options0 !== void 0 && _this$props$options0.isCommentEditor);
796
+ const shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled || !!isTableScalingEnabled && !!((_this$props$options10 = this.props.options) !== null && _this$props$options10 !== void 0 && _this$props$options10.isCommentEditor);
747
797
  if (isTableScalingWithFixedColumnWidthsOptionEnabled && getNode().attrs.displayMode !== 'fixed') {
748
798
  shouldScale = true;
749
799
  shouldHandleColgroupUpdates = true;
750
800
  }
801
+ if (expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) && this.state.windowResized) {
802
+ shouldHandleColgroupUpdates = true;
803
+ }
751
804
  if (shouldHandleColgroupUpdates) {
752
805
  this.handleColgroupUpdates();
753
806
  }
754
807
  if (isInDanger && !table) {
755
808
  clearHoverSelection()(view.state, view.dispatch);
756
809
  }
757
- if ((_this$props$options1 = this.props.options) !== null && _this$props$options1 !== void 0 && _this$props$options1.isCommentEditor && allowTableResizing && !(options !== null && options !== void 0 && options.isTableScalingEnabled)) {
810
+ if ((_this$props$options11 = this.props.options) !== null && _this$props$options11 !== void 0 && _this$props$options11.isCommentEditor && allowTableResizing && !(options !== null && options !== void 0 && options.isTableScalingEnabled)) {
758
811
  this.removeInlineTableWidth();
759
812
  }
760
813
  if ((_this$wrapper2 = this.wrapper) !== null && _this$wrapper2 !== void 0 && _this$wrapper2.parentElement && this.table && !this.overflowShadowsObserver) {
@@ -844,7 +897,7 @@ class TableComponent extends React.Component {
844
897
  }
845
898
  }
846
899
  render() {
847
- var _this$props$options10;
900
+ var _this$props$options12;
848
901
  const {
849
902
  view,
850
903
  getNode,
@@ -909,7 +962,7 @@ class TableComponent extends React.Component {
909
962
  ,
910
963
  selection: view.state.selection,
911
964
  headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
912
- stickyHeader: this.state.stickyHeader,
965
+ stickyHeader: !this.props.limitedMode ? this.state.stickyHeader : undefined,
913
966
  tableWrapperWidth: this.state.tableWrapperWidth,
914
967
  api: pluginInjectionApi,
915
968
  isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor
@@ -931,7 +984,7 @@ class TableComponent extends React.Component {
931
984
  ,
932
985
  selection: view.state.selection,
933
986
  headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
934
- stickyHeader: this.state.stickyHeader,
987
+ stickyHeader: !this.props.limitedMode ? this.state.stickyHeader : undefined,
935
988
  getEditorFeatureFlags: getEditorFeatureFlags,
936
989
  tableContainerWidth: tableContainerWidth,
937
990
  isNumberColumnEnabled: node.attrs.isNumberColumnEnabled,
@@ -962,17 +1015,17 @@ class TableComponent extends React.Component {
962
1015
  const isNested = isTableNested(view.state, tablePos);
963
1016
  const topShadowPadding = isDragAndDropEnabled ? 0 : shadowPadding;
964
1017
  const topOffset = 0;
965
- const topStickyShadowPosition = this.state.stickyHeader && topOffset + this.state.stickyHeader.padding + topShadowPadding + 2;
1018
+ const topStickyShadowPosition = !this.props.limitedMode && this.state.stickyHeader && topOffset + this.state.stickyHeader.padding + topShadowPadding + 2;
966
1019
  const {
967
1020
  tableWithFixedColumnWidthsOption = false
968
1021
  } = getEditorFeatureFlags();
969
- const shouldUseIncreasedScalingPercent = !!isTableScalingEnabled && (tableWithFixedColumnWidthsOption || !!((_this$props$options10 = this.props.options) !== null && _this$props$options10 !== void 0 && _this$props$options10.isCommentEditor));
1022
+ const shouldUseIncreasedScalingPercent = !!isTableScalingEnabled && (tableWithFixedColumnWidthsOption || !!((_this$props$options12 = this.props.options) !== null && _this$props$options12 !== void 0 && _this$props$options12.isCommentEditor));
970
1023
  return /*#__PURE__*/React.createElement(TableContainer
971
1024
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
972
1025
  , {
973
1026
  className: classnames(ClassName.TABLE_CONTAINER, {
974
1027
  [ClassName.WITH_CONTROLS]: allowControls && tableActive,
975
- [ClassName.TABLE_STICKY]: this.state.stickyHeader && hasHeaderRow,
1028
+ [ClassName.TABLE_STICKY]: !this.props.limitedMode && this.state.stickyHeader && hasHeaderRow,
976
1029
  [ClassName.HOVERED_DELETE_BUTTON]: isInDanger,
977
1030
  [ClassName.TABLE_SELECTED]: isTableSelected(selection !== null && selection !== void 0 ? selection : view.state.selection),
978
1031
  [ClassName.NESTED_TABLE_WITH_CONTROLS]: tableActive && allowControls && this.isNestedInTable
@@ -990,6 +1043,7 @@ class TableComponent extends React.Component {
990
1043
  tableWrapperHeight: this.state.tableWrapperHeight,
991
1044
  isTableResizingEnabled: allowTableResizing,
992
1045
  isResizing: isResizing,
1046
+ isWindowResized: this.state.windowResized,
993
1047
  isTableScalingEnabled: isTableScalingEnabled,
994
1048
  isTableWithFixedColumnWidthsOptionEnabled: tableWithFixedColumnWidthsOption,
995
1049
  isWholeTableInDanger: isWholeTableInDanger,