@atlaskit/renderer 153.5.0 → 153.6.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.
- package/CHANGELOG.md +22 -0
- package/dist/cjs/react/nodes/ForgeBodiedExtensionHandoff.js +4 -2
- package/dist/cjs/react/nodes/bodiedExtension.js +50 -23
- package/dist/cjs/react/nodes/table/colgroup.js +36 -16
- package/dist/cjs/react/nodes/table/table.js +16 -1
- package/dist/cjs/react/nodes/table.js +83 -18
- package/dist/cjs/ui/Renderer/index.js +1 -1
- package/dist/es2019/react/nodes/ForgeBodiedExtensionHandoff.js +3 -2
- package/dist/es2019/react/nodes/bodiedExtension.js +46 -23
- package/dist/es2019/react/nodes/table/colgroup.js +34 -17
- package/dist/es2019/react/nodes/table/table.js +17 -2
- package/dist/es2019/react/nodes/table.js +70 -10
- package/dist/es2019/ui/Renderer/index.js +1 -1
- package/dist/esm/react/nodes/ForgeBodiedExtensionHandoff.js +4 -2
- package/dist/esm/react/nodes/bodiedExtension.js +51 -24
- package/dist/esm/react/nodes/table/colgroup.js +36 -16
- package/dist/esm/react/nodes/table/table.js +17 -2
- package/dist/esm/react/nodes/table.js +79 -14
- package/dist/esm/ui/Renderer/index.js +1 -1
- package/dist/types/react/nodes/ForgeBodiedExtensionHandoff.d.ts +2 -1
- package/dist/types/react/nodes/bodiedExtension.d.ts +2 -0
- package/dist/types/react/nodes/table/types.d.ts +3 -0
- package/dist/types/react/nodes/table.d.ts +2 -0
- package/package.json +5 -5
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
2
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
3
3
|
import { tableCellBorderWidth, tableCellMinWidth } from '@atlaskit/editor-common/styles/table';
|
|
4
|
+
import { normalizeTableColumnWidths } from '@atlaskit/editor-common/table/normalize-column-widths';
|
|
4
5
|
import { WidthContext } from '@atlaskit/editor-common/WidthProvider';
|
|
5
6
|
import { akEditorTableNumberColumnWidth, akEditorTableLegacyCellMinWidth, akEditorTableCellMinWidth } from '@atlaskit/editor-shared-styles/constants';
|
|
6
7
|
import { useRendererContext } from '../../../renderer-context';
|
|
@@ -304,10 +305,11 @@ const renderScaleDownColgroup = props => {
|
|
|
304
305
|
});
|
|
305
306
|
};
|
|
306
307
|
export const Colgroup = props => {
|
|
307
|
-
var _props$allowFixedColu
|
|
308
|
+
var _props$allowFixedColu;
|
|
308
309
|
const {
|
|
309
310
|
isTopLevelRenderer,
|
|
310
|
-
nestedRendererType
|
|
311
|
+
nestedRendererType,
|
|
312
|
+
isPerformanceModeActive = false
|
|
311
313
|
} = useRendererContext();
|
|
312
314
|
const {
|
|
313
315
|
columnWidths,
|
|
@@ -328,21 +330,36 @@ export const Colgroup = props => {
|
|
|
328
330
|
|
|
329
331
|
// renderSyncBlockColgroup returns null when not applicable (flag off, SSR, not a sync block),
|
|
330
332
|
// in which case ?? falls back to the standard renderScaleDownColgroup path.
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
333
|
+
let colStyles;
|
|
334
|
+
if (isPerformanceModeActive) {
|
|
335
|
+
var _props$tableWidth;
|
|
336
|
+
// Keep authored widths without viewport-driven scaling, including sync blocks.
|
|
337
|
+
colStyles = normalizeTableColumnWidths({
|
|
338
|
+
columnWidths,
|
|
339
|
+
isNumberColumnEnabled: !!isNumberColumnEnabled,
|
|
340
|
+
skipMinWidth: !!(props.isInsideOfTable && isInsideOfSyncBlock),
|
|
341
|
+
tableWidth: (_props$tableWidth = props.tableWidth) !== null && _props$tableWidth !== void 0 ? _props$tableWidth : getTableContainerWidth(props.tableNode)
|
|
342
|
+
}).map(width => ({
|
|
343
|
+
width: `${width}px`
|
|
344
|
+
}));
|
|
345
|
+
} else {
|
|
346
|
+
var _renderSyncBlockColgr;
|
|
347
|
+
colStyles = (_renderSyncBlockColgr = renderSyncBlockColgroup({
|
|
348
|
+
isInsideOfSyncBlock,
|
|
349
|
+
isInsideOfTable: !!props.isInsideOfTable,
|
|
350
|
+
tableNode: props.tableNode,
|
|
351
|
+
columnWidths,
|
|
352
|
+
isNumberColumnEnabled: !!isNumberColumnEnabled,
|
|
353
|
+
renderWidth: props.renderWidth,
|
|
354
|
+
contextWidth
|
|
355
|
+
})) !== null && _renderSyncBlockColgr !== void 0 ? _renderSyncBlockColgr : renderScaleDownColgroup({
|
|
356
|
+
...props,
|
|
357
|
+
isTopLevelRenderer,
|
|
358
|
+
isInsideOfSyncBlock,
|
|
359
|
+
isTableScalingEnabled: props.rendererAppearance === 'full-page' || props.rendererAppearance === 'full-width' || props.rendererAppearance === 'max' || props.rendererAppearance === 'comment',
|
|
360
|
+
isTableFixedColumnWidthsOptionEnabled: isTableFixedColumnWidthsOptionEnabled && (props.rendererAppearance === 'full-page' || props.rendererAppearance === 'full-width' || props.rendererAppearance === 'max')
|
|
361
|
+
});
|
|
362
|
+
}
|
|
346
363
|
if (!colStyles) {
|
|
347
364
|
return null;
|
|
348
365
|
}
|
|
@@ -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
|
-
|
|
410
|
-
|
|
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
|
-
|
|
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.
|
|
67
|
+
const packageVersion = "153.5.1";
|
|
68
68
|
const setAsQueryContainerStyles = css({
|
|
69
69
|
containerName: 'ak-renderer-wrapper',
|
|
70
70
|
containerType: 'inline-size'
|
|
@@ -17,7 +17,9 @@ export default function ForgeBodiedExtensionHandoff(_ref) {
|
|
|
17
17
|
localId = _ref.localId,
|
|
18
18
|
result = _ref.result,
|
|
19
19
|
_ref$preserveContentU = _ref.preserveContentUntilReady,
|
|
20
|
-
preserveContentUntilReady = _ref$preserveContentU === void 0 ? false : _ref$preserveContentU
|
|
20
|
+
preserveContentUntilReady = _ref$preserveContentU === void 0 ? false : _ref$preserveContentU,
|
|
21
|
+
_ref$suppressInitialF = _ref.suppressInitialFallback,
|
|
22
|
+
suppressInitialFallback = _ref$suppressInitialF === void 0 ? false : _ref$suppressInitialF;
|
|
21
23
|
var _useState = useState(false),
|
|
22
24
|
_useState2 = _slicedToArray(_useState, 2),
|
|
23
25
|
ready = _useState2[0],
|
|
@@ -60,7 +62,7 @@ export default function ForgeBodiedExtensionHandoff(_ref) {
|
|
|
60
62
|
}, (!ready || !hasResult) && /*#__PURE__*/React.createElement("div", {
|
|
61
63
|
"aria-hidden": hasResult && !showNativeBody || undefined,
|
|
62
64
|
className: ax([styles.layer, hasResult && !showNativeBody && styles.reservation])
|
|
63
|
-
}, fallback), /*#__PURE__*/React.createElement("div", {
|
|
65
|
+
}, suppressInitialFallback && !ready ? null : fallback), /*#__PURE__*/React.createElement("div", {
|
|
64
66
|
"aria-hidden": showNativeBody || undefined,
|
|
65
67
|
className: ax([styles.layer, showNativeBody && styles.reservation])
|
|
66
68
|
}, /*#__PURE__*/React.createElement(ForgeBodiedExtensionHandoffReadyContext.Provider, {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
-
import React, { useContext, useMemo } from 'react';
|
|
6
|
+
import React, { useContext, useEffect, useMemo, useState } from 'react';
|
|
6
7
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next/useAnalyticsEvents';
|
|
7
8
|
import { ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics/types/enums';
|
|
8
9
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
@@ -17,8 +18,26 @@ import ForgeBodiedExtensionHandoff from './ForgeBodiedExtensionHandoff';
|
|
|
17
18
|
import { getForgeBodiedExtensionHandoffMode } from './forgeBodiedExtensionHandoffConfig';
|
|
18
19
|
import { ForgeBodiedExtensionHandoffContext } from './forgeBodiedExtensionHandoffContext';
|
|
19
20
|
import { useNodeHeight } from './useNodeHeight';
|
|
21
|
+
/** Restore the normal fallback after the renderer has committed its first app result. */
|
|
22
|
+
var InitialBodiedExtensionFallback = function InitialBodiedExtensionFallback(_ref) {
|
|
23
|
+
var hasResult = _ref.hasResult,
|
|
24
|
+
fallback = _ref.fallback,
|
|
25
|
+
render = _ref.render;
|
|
26
|
+
var _useState = useState(false),
|
|
27
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
+
hasRenderedApp = _useState2[0],
|
|
29
|
+
setHasRenderedApp = _useState2[1];
|
|
30
|
+
useEffect(function () {
|
|
31
|
+
if (hasResult) {
|
|
32
|
+
setHasRenderedApp(true);
|
|
33
|
+
}
|
|
34
|
+
}, [hasResult]);
|
|
35
|
+
return render(hasRenderedApp ? fallback : null);
|
|
36
|
+
};
|
|
20
37
|
var BodiedExtensionContent = function BodiedExtensionContent(props) {
|
|
21
38
|
var children = props.children,
|
|
39
|
+
_props$suppressInitia = props.suppressInitialFallback,
|
|
40
|
+
suppressInitialFallback = _props$suppressInitia === void 0 ? false : _props$suppressInitia,
|
|
22
41
|
_props$layout = props.layout,
|
|
23
42
|
layout = _props$layout === void 0 ? 'default' : _props$layout,
|
|
24
43
|
_props$path = props.path,
|
|
@@ -65,9 +84,9 @@ var BodiedExtensionContent = function BodiedExtensionContent(props) {
|
|
|
65
84
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
66
85
|
, _extends({}, props, {
|
|
67
86
|
type: "bodiedExtension"
|
|
68
|
-
}), function (
|
|
69
|
-
var node =
|
|
70
|
-
result =
|
|
87
|
+
}), function (_ref2) {
|
|
88
|
+
var node = _ref2.node,
|
|
89
|
+
result = _ref2.result;
|
|
71
90
|
var handoffMode = getForgeBodiedExtensionHandoffMode({
|
|
72
91
|
extensionType: extensionType,
|
|
73
92
|
extensionKey: extensionKey,
|
|
@@ -83,6 +102,7 @@ var BodiedExtensionContent = function BodiedExtensionContent(props) {
|
|
|
83
102
|
localId: localId,
|
|
84
103
|
preserveContentUntilReady: handoffMode === 'preserve-until-ready',
|
|
85
104
|
fallback: children,
|
|
105
|
+
suppressInitialFallback: suppressInitialFallback,
|
|
86
106
|
result: /*#__PURE__*/React.isValidElement(result) ? result : null
|
|
87
107
|
}), layout, {
|
|
88
108
|
isTopLevel: path.length < 1,
|
|
@@ -91,28 +111,35 @@ var BodiedExtensionContent = function BodiedExtensionContent(props) {
|
|
|
91
111
|
fireAnalyticsEvent: fireAnalyticsEvent
|
|
92
112
|
}, removeOverflow, parameters === null || parameters === void 0 ? void 0 : parameters.extensionId, extensionViewportSizes, undefined, localId, shouldDisplayExtensionAsInline, node);
|
|
93
113
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
114
|
+
var renderResult = function renderResult(fallbackBody) {
|
|
115
|
+
try {
|
|
116
|
+
if (result && /*#__PURE__*/React.isValidElement(result)) {
|
|
117
|
+
// Return the content directly if it's a valid JSX.Element
|
|
118
|
+
return renderExtension(result, layout, _objectSpread(_objectSpread({}, presetOptions), {}, {
|
|
119
|
+
isTopLevel: path.length < 1,
|
|
120
|
+
marks: isBreakoutResizingEnabled ? props.marks : undefined,
|
|
121
|
+
rendererAppearance: props.rendererAppearance,
|
|
122
|
+
fireAnalyticsEvent: fireAnalyticsEvent
|
|
123
|
+
}), removeOverflow, parameters === null || parameters === void 0 ? void 0 : parameters.extensionId, extensionViewportSizes, presetMinHeight, localId, shouldDisplayExtensionAsInline, node);
|
|
124
|
+
}
|
|
125
|
+
} catch (_unused) {
|
|
126
|
+
/** We don't want this error to block renderer */
|
|
127
|
+
/** Keep rendering the configured fallback. */
|
|
103
128
|
}
|
|
104
|
-
} catch (_unused) {
|
|
105
|
-
/** We don't want this error to block renderer */
|
|
106
|
-
/** We keep rendering the default content */
|
|
107
|
-
}
|
|
108
129
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
130
|
+
// Render the configured body fallback when no app output is available.
|
|
131
|
+
return renderExtension(fallbackBody, layout, _objectSpread(_objectSpread({}, presetOptions), {}, {
|
|
132
|
+
isTopLevel: path.length < 1,
|
|
133
|
+
marks: isBreakoutResizingEnabled ? props.marks : undefined,
|
|
134
|
+
rendererAppearance: props.rendererAppearance,
|
|
135
|
+
fireAnalyticsEvent: fireAnalyticsEvent
|
|
136
|
+
}), removeOverflow, parameters === null || parameters === void 0 ? void 0 : parameters.extensionId, extensionViewportSizes, presetMinHeight, localId, shouldDisplayExtensionAsInline, node);
|
|
137
|
+
};
|
|
138
|
+
return suppressInitialFallback ? /*#__PURE__*/React.createElement(InitialBodiedExtensionFallback, {
|
|
139
|
+
hasResult: /*#__PURE__*/React.isValidElement(result),
|
|
140
|
+
fallback: children,
|
|
141
|
+
render: renderResult
|
|
142
|
+
}) : renderResult(children);
|
|
116
143
|
}))));
|
|
117
144
|
};
|
|
118
145
|
var BodiedExtensionWithTemporarySizing = function BodiedExtensionWithTemporarySizing(props) {
|
|
@@ -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
|
|
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
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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,
|