@atlaskit/renderer 153.4.7 → 153.5.1

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.
@@ -2,8 +2,9 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
3
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
4
4
  import { isTableInContentMode } from '@atlaskit/editor-common/table/content-mode';
5
- import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles/constants';
5
+ import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorMaxWidthLayoutWidth } from '@atlaskit/editor-shared-styles/constants';
6
6
  import { fg } from '@atlaskit/platform-feature-flags/fg';
7
+ import { useRendererContext } from '../../../renderer-context';
7
8
  import { Colgroup, colWidthSum } from './colgroup';
8
9
  import { isContentModeSupported } from './content-mode';
9
10
  export const Table = /*#__PURE__*/React.memo(({
@@ -25,7 +26,17 @@ export const Table = /*#__PURE__*/React.memo(({
25
26
  allowFixedColumnWidthOption = false
26
27
  }) => {
27
28
  var _tableNode$attrs;
29
+ const {
30
+ isPerformanceModeActive = false
31
+ } = useRendererContext();
28
32
  let tableWidth = tableNode ? getTableContainerWidth(tableNode) : akEditorDefaultLayoutWidth;
33
+ if (isPerformanceModeActive && !(tableNode !== null && tableNode !== void 0 && tableNode.attrs.width)) {
34
+ if (rendererAppearance === 'full-width') {
35
+ tableWidth = akEditorFullWidthLayoutWidth;
36
+ } else if (rendererAppearance === 'max') {
37
+ tableWidth = akEditorMaxWidthLayoutWidth;
38
+ }
39
+ }
29
40
  let tableColumnWidths = columnWidths;
30
41
  if (rendererAppearance === 'comment' && allowTableResizing && tableNode && !((_tableNode$attrs = tableNode.attrs) !== null && _tableNode$attrs !== void 0 && _tableNode$attrs.width)) {
31
42
  tableWidth = 'inherit';
@@ -56,9 +67,13 @@ export const Table = /*#__PURE__*/React.memo(({
56
67
  "data-initial-width-mode": isContentMode ? 'content' : undefined,
57
68
  ref: innerRef,
58
69
  style: {
59
- marginTop: fixTableSSRResizing ? '0px' : ''
70
+ marginTop: fixTableSSRResizing ? '0px' : '',
71
+ // Keep the table's saved width while its outer viewport can still shrink and scroll.
72
+ minWidth: isPerformanceModeActive && !isContentMode && typeof tableWidth === 'number' ? tableWidth : undefined,
73
+ width: isPerformanceModeActive && !isContentMode && typeof tableWidth === 'number' ? tableWidth : undefined
60
74
  }
61
75
  }), /*#__PURE__*/React.createElement(Colgroup, {
76
+ tableWidth: isPerformanceModeActive && typeof tableWidth === 'number' ? tableWidth : undefined,
62
77
  columnWidths: tableColumnWidths,
63
78
  layout: layout,
64
79
  isNumberColumnEnabled: isNumberColumnEnabled,
@@ -3,6 +3,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  /* eslint-disable @atlaskit/ui-styling-standard/no-classname-prop, @atlaskit/ui-styling-standard/enforce-style-prop, @repo/internal/react/no-class-components */
4
4
 
5
5
  import React from 'react';
6
+ import { IntlContext } from 'react-intl';
7
+ import { messages } from '@atlaskit/editor-common/messages/table';
6
8
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
7
9
  import overflowShadow from '@atlaskit/editor-common/OverflowShadow';
8
10
  import { TableSharedCssClassName } from '@atlaskit/editor-common/styles';
@@ -192,6 +194,9 @@ export class TableContainer extends React.Component {
192
194
  _defineProperty(this, "lastComputedStyle", {});
193
195
  _defineProperty(this, "resizeObserver", null);
194
196
  _defineProperty(this, "applyResizerChange", entries => {
197
+ if (this.props.isPerformanceModeActive) {
198
+ return;
199
+ }
195
200
  let wrapperWidth = this.state.wrapperWidth;
196
201
  let headerRowHeight = this.state.headerRowHeight;
197
202
  for (const entry of entries) {
@@ -253,6 +258,9 @@ export class TableContainer extends React.Component {
253
258
  return (this.overflowParent ? this.overflowParent.top : 0) + offsetTop;
254
259
  });
255
260
  _defineProperty(this, "updateSticky", () => {
261
+ if (this.props.isPerformanceModeActive) {
262
+ return;
263
+ }
256
264
  const tableElem = this.tableRef.current;
257
265
  const refElem = this.stickyHeaderRef.current;
258
266
  if (!tableElem || !refElem) {
@@ -282,6 +290,12 @@ export class TableContainer extends React.Component {
282
290
  }
283
291
  });
284
292
  _defineProperty(this, "onWrapperScrolled", () => {
293
+ if (this.props.isPerformanceModeActive) {
294
+ if (this.wrapperRef.current && this.stickyScrollbarRef.current) {
295
+ this.stickyScrollbarRef.current.scrollLeft = this.wrapperRef.current.scrollLeft;
296
+ }
297
+ return;
298
+ }
285
299
  if (!this.wrapperRef.current || !this.stickyWrapperRef.current) {
286
300
  return;
287
301
  }
@@ -406,17 +420,12 @@ export class TableContainer extends React.Component {
406
420
  * @example
407
421
  */
408
422
  componentDidMount() {
409
- this.resizeObserver = new ResizeObserver(this.applyResizerChange);
410
- if (this.wrapperRef.current) {
411
- this.resizeObserver.observe(this.wrapperRef.current);
412
- }
413
- if (this.stickyHeaderRef.current) {
414
- this.resizeObserver.observe(this.stickyHeaderRef.current);
423
+ if (!this.props.isPerformanceModeActive) {
424
+ this.observeDimensions();
415
425
  }
416
426
  if (this.props.stickyHeaders) {
417
427
  var _this$props$stickyHea;
418
428
  this.overflowParent = OverflowParent.fromElement(this.tableRef.current, (_this$props$stickyHea = this.props.stickyHeaders) === null || _this$props$stickyHea === void 0 ? void 0 : _this$props$stickyHea.defaultScrollRootId_DO_NOT_USE);
419
- // Ignored via go/ees005
420
429
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
421
430
  this.overflowParent.addEventListener('scroll', this.onScroll);
422
431
  }
@@ -425,6 +434,23 @@ export class TableContainer extends React.Component {
425
434
  }
426
435
  this.applyNestedRendererTableFix();
427
436
  }
437
+ observeDimensions() {
438
+ this.resizeObserver = new ResizeObserver(this.applyResizerChange);
439
+ if (this.wrapperRef.current) {
440
+ this.resizeObserver.observe(this.wrapperRef.current);
441
+ }
442
+ if (this.stickyHeaderRef.current) {
443
+ this.resizeObserver.observe(this.stickyHeaderRef.current);
444
+ }
445
+ }
446
+ static getDerivedStateFromProps(props, state) {
447
+ if (props.isPerformanceModeActive && state.stickyMode !== 'none') {
448
+ return {
449
+ stickyMode: 'none'
450
+ };
451
+ }
452
+ return null;
453
+ }
428
454
 
429
455
  /**
430
456
  * Updates sticky header wiring and scroll synchronization after prop or state changes.
@@ -434,10 +460,27 @@ export class TableContainer extends React.Component {
434
460
  * @example
435
461
  */
436
462
  componentDidUpdate(prevProps, prevState) {
463
+ if (this.props.isPerformanceModeActive !== prevProps.isPerformanceModeActive) {
464
+ if (this.props.isPerformanceModeActive) {
465
+ var _this$resizeObserver;
466
+ (_this$resizeObserver = this.resizeObserver) === null || _this$resizeObserver === void 0 ? void 0 : _this$resizeObserver.disconnect();
467
+ this.resizeObserver = null;
468
+ if (this.nextFrame) {
469
+ cancelAnimationFrame(this.nextFrame);
470
+ this.nextFrame = undefined;
471
+ }
472
+ } else if (prevProps.isPerformanceModeActive) {
473
+ this.observeDimensions();
474
+ }
475
+ }
437
476
  // toggling sticky headers visiblity
438
477
  if (this.props.stickyHeaders && !this.overflowParent) {
439
478
  var _this$props$stickyHea2;
440
479
  this.overflowParent = OverflowParent.fromElement(this.tableRef.current, (_this$props$stickyHea2 = this.props.stickyHeaders) === null || _this$props$stickyHea2 === void 0 ? void 0 : _this$props$stickyHea2.defaultScrollRootId_DO_NOT_USE);
480
+ if (prevProps.isPerformanceModeActive) {
481
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
482
+ this.overflowParent.addEventListener('scroll', this.onScroll);
483
+ }
441
484
  } else if (!this.props.stickyHeaders && this.overflowParent) {
442
485
  // Ignored via go/ees005
443
486
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
@@ -665,7 +708,10 @@ export class TableContainer extends React.Component {
665
708
  "data-table-local-id": tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.localId,
666
709
  "data-table-width": tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.width,
667
710
  "data-vc": "table-node-wrapper",
668
- onScroll: this.props.stickyHeaders && this.onWrapperScrolled
711
+ tabIndex: this.props.isPerformanceModeActive ? 0 : undefined,
712
+ role: this.props.isPerformanceModeActive ? 'region' : undefined,
713
+ "aria-label": this.props.isPerformanceModeActive ? this.props.scrollRegionLabel : undefined,
714
+ onScroll: (this.props.isPerformanceModeActive || this.props.stickyHeaders) && this.onWrapperScrolled
669
715
  }, /*#__PURE__*/React.createElement(Table, {
670
716
  innerRef: this.tableRef,
671
717
  columnWidths: columnWidths,
@@ -887,6 +933,8 @@ export class TableProcessorWithContainerStyles extends React.Component {
887
933
  isNumberColumnEnabled,
888
934
  isPresentational,
889
935
  layout,
936
+ isPerformanceModeActive,
937
+ scrollRegionLabel,
890
938
  rendererAppearance,
891
939
  renderWidth,
892
940
  shadowClassNames,
@@ -917,6 +965,8 @@ export class TableProcessorWithContainerStyles extends React.Component {
917
965
  isInsideOfTable: isInsideOfTable,
918
966
  isNumberColumnEnabled: isNumberColumnEnabled,
919
967
  isPresentational: isPresentational,
968
+ isPerformanceModeActive: isPerformanceModeActive,
969
+ scrollRegionLabel: scrollRegionLabel,
920
970
  layout: layout,
921
971
  rendererAppearance: rendererAppearance,
922
972
  renderWidth: renderWidth,
@@ -940,11 +990,14 @@ const TableWithShadowsAndContainerStyles = overflowShadow(TableProcessorWithCont
940
990
  useShadowObserver: true
941
991
  });
942
992
  const TableWithWidth = props => {
943
- var _props$columnWidths;
993
+ var _intl$formatMessage, _props$columnWidths;
944
994
  const {
945
- isTopLevelRenderer
995
+ isTopLevelRenderer,
996
+ isPerformanceModeActive = false
946
997
  } = useRendererContext();
998
+ const intl = React.useContext(IntlContext);
947
999
  const isInsideOfNestedRenderer = isTopLevelRenderer === false;
1000
+ const scrollRegionLabel = isPerformanceModeActive ? (_intl$formatMessage = intl === null || intl === void 0 ? void 0 : intl.formatMessage(messages.tableScrollRegion)) !== null && _intl$formatMessage !== void 0 ? _intl$formatMessage : messages.tableScrollRegion.defaultMessage : undefined;
948
1001
  const colWidthsSum =
949
1002
  // eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- Ignored via go/ees017 (to be fixed)
950
1003
  ((_props$columnWidths = props.columnWidths) === null || _props$columnWidths === void 0 ? void 0 : _props$columnWidths.reduce((total, val) => total + val, 0)) || 0;
@@ -953,6 +1006,10 @@ const TableWithWidth = props => {
953
1006
  // Ignored via go/ees005
954
1007
  // eslint-disable-next-line react/jsx-props-no-spreading
955
1008
  , _extends({}, props, {
1009
+ isPerformanceModeActive: isPerformanceModeActive,
1010
+ scrollRegionLabel: scrollRegionLabel,
1011
+ stickyHeaders: isPerformanceModeActive ? undefined : props.stickyHeaders,
1012
+ disableShadowTracking: isPerformanceModeActive,
956
1013
  isInsideOfNestedRenderer: isInsideOfNestedRenderer
957
1014
  }));
958
1015
  }
@@ -960,6 +1017,9 @@ const TableWithWidth = props => {
960
1017
  // Ignored via go/ees005
961
1018
  // eslint-disable-next-line react/jsx-props-no-spreading
962
1019
  , _extends({}, props, {
1020
+ isPerformanceModeActive: isPerformanceModeActive,
1021
+ scrollRegionLabel: scrollRegionLabel,
1022
+ stickyHeaders: isPerformanceModeActive ? undefined : props.stickyHeaders,
963
1023
  isInsideOfNestedRenderer: isInsideOfNestedRenderer
964
1024
  }));
965
1025
  };
@@ -64,7 +64,7 @@ export const DEGRADED_SEVERITY_THRESHOLD = 3000;
64
64
  const TABLE_INFO_TIMEOUT = 10000;
65
65
  const RENDER_EVENT_SAMPLE_RATE = 0.1;
66
66
  const packageName = "@atlaskit/renderer";
67
- const packageVersion = "153.4.6";
67
+ const packageVersion = "153.5.0";
68
68
  const setAsQueryContainerStyles = css({
69
69
  containerName: 'ak-renderer-wrapper',
70
70
  containerType: 'inline-size'
@@ -1,6 +1,11 @@
1
1
  import React, { createContext, useCallback, useContext, useMemo, useReducer, useRef } from 'react';
2
2
  import { fg } from '@atlaskit/platform-feature-flags/fg';
3
3
 
4
+ /**
5
+ * The range a draft should act on, published by the selection/hover mounters so the manager can
6
+ * resolve its target without reading the ambient `range`, which flips between selection and hover.
7
+ */
8
+
4
9
  // oxlint-disable-next-line eslint/no-redeclare
5
10
 
6
11
  // oxlint-disable-next-line eslint/no-redeclare
@@ -12,7 +17,10 @@ const initialState = {
12
17
  selectionDraftRange: null,
13
18
  hoverDraftRange: null,
14
19
  selectionDraftDocumentPosition: null,
15
- hoverDraftDocumentPosition: null
20
+ hoverDraftDocumentPosition: null,
21
+ draftIntentSource: null,
22
+ selectionDraftTarget: null,
23
+ hoverDraftTarget: null
16
24
  };
17
25
  function reducer(state, action) {
18
26
  switch (action.type) {
@@ -97,6 +105,30 @@ function reducer(state, action) {
97
105
  };
98
106
  }
99
107
  return state;
108
+ case 'setDraftIntentSource':
109
+ if (state.draftIntentSource !== action.source) {
110
+ return {
111
+ ...state,
112
+ draftIntentSource: action.source
113
+ };
114
+ }
115
+ return state;
116
+ case 'setSelectionDraftTarget':
117
+ if (state.selectionDraftTarget !== action.target) {
118
+ return {
119
+ ...state,
120
+ selectionDraftTarget: action.target
121
+ };
122
+ }
123
+ return state;
124
+ case 'setHoverDraftTarget':
125
+ if (state.hoverDraftTarget !== action.target) {
126
+ return {
127
+ ...state,
128
+ hoverDraftTarget: action.target
129
+ };
130
+ }
131
+ return state;
100
132
  }
101
133
  }
102
134
  export const AnnotationRangeStateContext = /*#__PURE__*/createContext({
@@ -105,7 +137,10 @@ export const AnnotationRangeStateContext = /*#__PURE__*/createContext({
105
137
  selectionDraftRange: null,
106
138
  hoverDraftRange: null,
107
139
  selectionDraftDocumentPosition: null,
108
- hoverDraftDocumentPosition: null
140
+ hoverDraftDocumentPosition: null,
141
+ draftIntentSource: null,
142
+ selectionDraftTarget: null,
143
+ hoverDraftTarget: null
109
144
  });
110
145
  export const AnnotationRangeDispatchContext = /*#__PURE__*/createContext({
111
146
  clearSelectionRange: () => {},
@@ -114,7 +149,10 @@ export const AnnotationRangeDispatchContext = /*#__PURE__*/createContext({
114
149
  promoteSelectionToDraft: () => {},
115
150
  promoteHoverToDraft: () => {},
116
151
  clearSelectionDraft: () => {},
117
- clearHoverDraft: () => {}
152
+ clearHoverDraft: () => {},
153
+ setDraftIntentSource: () => {},
154
+ setSelectionDraftTarget: () => {},
155
+ setHoverDraftTarget: () => {}
118
156
  });
119
157
  export const AnnotationRangeProviderInner = ({
120
158
  children,
@@ -129,7 +167,10 @@ export const AnnotationRangeProviderInner = ({
129
167
  selectionDraftRange,
130
168
  selectionDraftDocumentPosition,
131
169
  hoverDraftRange,
132
- hoverDraftDocumentPosition
170
+ hoverDraftDocumentPosition,
171
+ draftIntentSource,
172
+ selectionDraftTarget,
173
+ hoverDraftTarget
133
174
  }, dispatch] = useReducer(reducer, initialState);
134
175
  const clearSelectionRange = useCallback(() => dispatch({
135
176
  type: 'clearSelection'
@@ -189,6 +230,24 @@ export const AnnotationRangeProviderInner = ({
189
230
  type: 'clearHoverDraft'
190
231
  });
191
232
  }, []);
233
+ const setDraftIntentSource = useCallback(source => {
234
+ dispatch({
235
+ type: 'setDraftIntentSource',
236
+ source
237
+ });
238
+ }, []);
239
+ const setSelectionDraftTarget = useCallback(target => {
240
+ dispatch({
241
+ type: 'setSelectionDraftTarget',
242
+ target
243
+ });
244
+ }, []);
245
+ const setHoverDraftTarget = useCallback(target => {
246
+ dispatch({
247
+ type: 'setHoverDraftTarget',
248
+ target
249
+ });
250
+ }, []);
192
251
  const stateData = useMemo(() => {
193
252
  return {
194
253
  // We techinically have two ranges, however we only want to expose one of them at a time, because only one draft
@@ -198,9 +257,12 @@ export const AnnotationRangeProviderInner = ({
198
257
  selectionDraftRange,
199
258
  hoverDraftRange,
200
259
  selectionDraftDocumentPosition,
201
- hoverDraftDocumentPosition
260
+ hoverDraftDocumentPosition,
261
+ draftIntentSource,
262
+ selectionDraftTarget,
263
+ hoverDraftTarget
202
264
  };
203
- }, [selectionRange, hoverRange, type, selectionDraftRange, selectionDraftDocumentPosition, hoverDraftRange, hoverDraftDocumentPosition]);
265
+ }, [selectionRange, hoverRange, type, selectionDraftRange, selectionDraftDocumentPosition, hoverDraftRange, hoverDraftDocumentPosition, draftIntentSource, selectionDraftTarget, hoverDraftTarget]);
204
266
  const dispatchData = useMemo(() => ({
205
267
  clearSelectionRange,
206
268
  clearHoverRange,
@@ -209,8 +271,11 @@ export const AnnotationRangeProviderInner = ({
209
271
  promoteSelectionToDraft,
210
272
  promoteHoverToDraft,
211
273
  clearSelectionDraft,
212
- clearHoverDraft
213
- }), [allowCommentsOnMedia, extensionCommentsEnabled, clearSelectionRange, clearHoverRange, setSelectionRange, setHoverTarget, promoteSelectionToDraft, promoteHoverToDraft, clearSelectionDraft, clearHoverDraft]);
274
+ clearHoverDraft,
275
+ setDraftIntentSource,
276
+ setSelectionDraftTarget,
277
+ setHoverDraftTarget
278
+ }), [allowCommentsOnMedia, extensionCommentsEnabled, clearSelectionRange, clearHoverRange, setSelectionRange, setHoverTarget, promoteSelectionToDraft, promoteHoverToDraft, clearSelectionDraft, clearHoverDraft, setDraftIntentSource, setSelectionDraftTarget, setHoverDraftTarget]);
214
279
  return /*#__PURE__*/React.createElement(AnnotationRangeStateContext.Provider, {
215
280
  value: stateData
216
281
  }, /*#__PURE__*/React.createElement(AnnotationRangeDispatchContext.Provider, {
@@ -27,7 +27,9 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
27
27
  } = props;
28
28
  const {
29
29
  promoteSelectionToDraft,
30
- clearSelectionDraft
30
+ clearSelectionDraft,
31
+ setSelectionDraftTarget,
32
+ setDraftIntentSource
31
33
  } = useAnnotationRangeDispatch();
32
34
  const {
33
35
  selectionDraftDocumentPosition
@@ -186,6 +188,34 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
186
188
  removeDraftModeCallback();
187
189
  onCloseProps();
188
190
  }, [onCloseProps, removeDraftModeCallback, createAnalyticsEvent, inlineNodeTypes]);
191
+
192
+ // Publish the range this mounter owns, so a draft can be resolved against the surface the user
193
+ // engaged rather than the ambient range, which flips between selection and hover. During a draft
194
+ // the selection range has been promoted away, and skipping the publish then keeps the target a
195
+ // draft captured.
196
+ useEffect(() => {
197
+ if (!annotationManager || !range) {
198
+ return;
199
+ }
200
+ setSelectionDraftTarget({
201
+ range,
202
+ documentPosition,
203
+ isAnnotationAllowed,
204
+ source: 'selection'
205
+ });
206
+ setDraftIntentSource('selection');
207
+ }, [annotationManager, range, documentPosition, isAnnotationAllowed, setSelectionDraftTarget, setDraftIntentSource]);
208
+
209
+ // Unmounting means the selection was cleared, so drop the published target.
210
+ useEffect(() => {
211
+ return () => {
212
+ if (annotationManager) {
213
+ setSelectionDraftTarget(null);
214
+ }
215
+ };
216
+ // Cleanup on unmount only; both dependencies are stable for this component's lifetime.
217
+ // eslint-disable-next-line react-hooks/exhaustive-deps
218
+ }, []);
189
219
  useEffect(() => {
190
220
  if (annotationManager) {
191
221
  const allowAnnotation = () => {
@@ -4,6 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import React, { useContext } from 'react';
5
5
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
6
6
  import { tableCellBorderWidth, tableCellMinWidth } from '@atlaskit/editor-common/styles/table';
7
+ import { normalizeTableColumnWidths } from '@atlaskit/editor-common/table/normalize-column-widths';
7
8
  import { WidthContext } from '@atlaskit/editor-common/WidthProvider';
8
9
  import { akEditorTableNumberColumnWidth, akEditorTableLegacyCellMinWidth, akEditorTableCellMinWidth } from '@atlaskit/editor-shared-styles/constants';
9
10
  import { useRendererContext } from '../../../renderer-context';
@@ -328,10 +329,12 @@ var renderScaleDownColgroup = function renderScaleDownColgroup(props) {
328
329
  });
329
330
  };
330
331
  export var Colgroup = function Colgroup(props) {
331
- var _props$allowFixedColu, _renderSyncBlockColgr;
332
+ var _props$allowFixedColu;
332
333
  var _useRendererContext = useRendererContext(),
333
334
  isTopLevelRenderer = _useRendererContext.isTopLevelRenderer,
334
- nestedRendererType = _useRendererContext.nestedRendererType;
335
+ nestedRendererType = _useRendererContext.nestedRendererType,
336
+ _useRendererContext$i = _useRendererContext.isPerformanceModeActive,
337
+ isPerformanceModeActive = _useRendererContext$i === void 0 ? false : _useRendererContext$i;
335
338
  var columnWidths = props.columnWidths,
336
339
  isNumberColumnEnabled = props.isNumberColumnEnabled;
337
340
  var _useContext = useContext(WidthContext),
@@ -348,20 +351,37 @@ export var Colgroup = function Colgroup(props) {
348
351
 
349
352
  // renderSyncBlockColgroup returns null when not applicable (flag off, SSR, not a sync block),
350
353
  // in which case ?? falls back to the standard renderScaleDownColgroup path.
351
- var colStyles = (_renderSyncBlockColgr = renderSyncBlockColgroup({
352
- isInsideOfSyncBlock: isInsideOfSyncBlock,
353
- isInsideOfTable: !!props.isInsideOfTable,
354
- tableNode: props.tableNode,
355
- columnWidths: columnWidths,
356
- isNumberColumnEnabled: !!isNumberColumnEnabled,
357
- renderWidth: props.renderWidth,
358
- contextWidth: contextWidth
359
- })) !== null && _renderSyncBlockColgr !== void 0 ? _renderSyncBlockColgr : renderScaleDownColgroup(_objectSpread(_objectSpread({}, props), {}, {
360
- isTopLevelRenderer: isTopLevelRenderer,
361
- isInsideOfSyncBlock: isInsideOfSyncBlock,
362
- isTableScalingEnabled: props.rendererAppearance === 'full-page' || props.rendererAppearance === 'full-width' || props.rendererAppearance === 'max' || props.rendererAppearance === 'comment',
363
- isTableFixedColumnWidthsOptionEnabled: isTableFixedColumnWidthsOptionEnabled && (props.rendererAppearance === 'full-page' || props.rendererAppearance === 'full-width' || props.rendererAppearance === 'max')
364
- }));
354
+ var colStyles;
355
+ if (isPerformanceModeActive) {
356
+ var _props$tableWidth;
357
+ // Keep authored widths without viewport-driven scaling, including sync blocks.
358
+ colStyles = normalizeTableColumnWidths({
359
+ columnWidths: columnWidths,
360
+ isNumberColumnEnabled: !!isNumberColumnEnabled,
361
+ skipMinWidth: !!(props.isInsideOfTable && isInsideOfSyncBlock),
362
+ tableWidth: (_props$tableWidth = props.tableWidth) !== null && _props$tableWidth !== void 0 ? _props$tableWidth : getTableContainerWidth(props.tableNode)
363
+ }).map(function (width) {
364
+ return {
365
+ width: "".concat(width, "px")
366
+ };
367
+ });
368
+ } else {
369
+ var _renderSyncBlockColgr;
370
+ colStyles = (_renderSyncBlockColgr = renderSyncBlockColgroup({
371
+ isInsideOfSyncBlock: isInsideOfSyncBlock,
372
+ isInsideOfTable: !!props.isInsideOfTable,
373
+ tableNode: props.tableNode,
374
+ columnWidths: columnWidths,
375
+ isNumberColumnEnabled: !!isNumberColumnEnabled,
376
+ renderWidth: props.renderWidth,
377
+ contextWidth: contextWidth
378
+ })) !== null && _renderSyncBlockColgr !== void 0 ? _renderSyncBlockColgr : renderScaleDownColgroup(_objectSpread(_objectSpread({}, props), {}, {
379
+ isTopLevelRenderer: isTopLevelRenderer,
380
+ isInsideOfSyncBlock: isInsideOfSyncBlock,
381
+ isTableScalingEnabled: props.rendererAppearance === 'full-page' || props.rendererAppearance === 'full-width' || props.rendererAppearance === 'max' || props.rendererAppearance === 'comment',
382
+ isTableFixedColumnWidthsOptionEnabled: isTableFixedColumnWidthsOptionEnabled && (props.rendererAppearance === 'full-page' || props.rendererAppearance === 'full-width' || props.rendererAppearance === 'max')
383
+ }));
384
+ }
365
385
  if (!colStyles) {
366
386
  return null;
367
387
  }
@@ -2,8 +2,9 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
3
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
4
4
  import { isTableInContentMode } from '@atlaskit/editor-common/table/content-mode';
5
- import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles/constants';
5
+ import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorMaxWidthLayoutWidth } from '@atlaskit/editor-shared-styles/constants';
6
6
  import { fg } from '@atlaskit/platform-feature-flags/fg';
7
+ import { useRendererContext } from '../../../renderer-context';
7
8
  import { Colgroup, colWidthSum } from './colgroup';
8
9
  import { isContentModeSupported } from './content-mode';
9
10
  export var Table = /*#__PURE__*/React.memo(function (_ref) {
@@ -26,7 +27,17 @@ export var Table = /*#__PURE__*/React.memo(function (_ref) {
26
27
  fixTableSSRResizing = _ref$fixTableSSRResiz === void 0 ? false : _ref$fixTableSSRResiz,
27
28
  _ref$allowFixedColumn = _ref.allowFixedColumnWidthOption,
28
29
  allowFixedColumnWidthOption = _ref$allowFixedColumn === void 0 ? false : _ref$allowFixedColumn;
30
+ var _useRendererContext = useRendererContext(),
31
+ _useRendererContext$i = _useRendererContext.isPerformanceModeActive,
32
+ isPerformanceModeActive = _useRendererContext$i === void 0 ? false : _useRendererContext$i;
29
33
  var tableWidth = tableNode ? getTableContainerWidth(tableNode) : akEditorDefaultLayoutWidth;
34
+ if (isPerformanceModeActive && !(tableNode !== null && tableNode !== void 0 && tableNode.attrs.width)) {
35
+ if (rendererAppearance === 'full-width') {
36
+ tableWidth = akEditorFullWidthLayoutWidth;
37
+ } else if (rendererAppearance === 'max') {
38
+ tableWidth = akEditorMaxWidthLayoutWidth;
39
+ }
40
+ }
30
41
  var tableColumnWidths = columnWidths;
31
42
  if (rendererAppearance === 'comment' && allowTableResizing && tableNode && !((_tableNode$attrs = tableNode.attrs) !== null && _tableNode$attrs !== void 0 && _tableNode$attrs.width)) {
32
43
  tableWidth = 'inherit';
@@ -57,9 +68,13 @@ export var Table = /*#__PURE__*/React.memo(function (_ref) {
57
68
  "data-initial-width-mode": isContentMode ? 'content' : undefined,
58
69
  ref: innerRef,
59
70
  style: {
60
- marginTop: fixTableSSRResizing ? '0px' : ''
71
+ marginTop: fixTableSSRResizing ? '0px' : '',
72
+ // Keep the table's saved width while its outer viewport can still shrink and scroll.
73
+ minWidth: isPerformanceModeActive && !isContentMode && typeof tableWidth === 'number' ? tableWidth : undefined,
74
+ width: isPerformanceModeActive && !isContentMode && typeof tableWidth === 'number' ? tableWidth : undefined
61
75
  }
62
76
  }), /*#__PURE__*/React.createElement(Colgroup, {
77
+ tableWidth: isPerformanceModeActive && typeof tableWidth === 'number' ? tableWidth : undefined,
63
78
  columnWidths: tableColumnWidths,
64
79
  layout: layout,
65
80
  isNumberColumnEnabled: isNumberColumnEnabled,