@atlaskit/renderer 117.0.1 → 118.0.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 +50 -0
- package/dist/cjs/react/index.js +1 -5
- package/dist/cjs/react/nodes/table/sticky.js +47 -3
- package/dist/cjs/react/nodes/table.js +58 -63
- package/dist/cjs/render-document.js +5 -0
- package/dist/cjs/ui/Expand.js +4 -1
- package/dist/cjs/ui/Renderer/index.js +11 -2
- package/dist/es2019/react/index.js +2 -6
- package/dist/es2019/react/nodes/table/sticky.js +45 -2
- package/dist/es2019/react/nodes/table.js +53 -59
- package/dist/es2019/render-document.js +5 -0
- package/dist/es2019/ui/Expand.js +4 -1
- package/dist/es2019/ui/Renderer/index.js +11 -2
- package/dist/esm/react/index.js +2 -6
- package/dist/esm/react/nodes/table/sticky.js +47 -3
- package/dist/esm/react/nodes/table.js +58 -63
- package/dist/esm/render-document.js +5 -0
- package/dist/esm/ui/Expand.js +4 -1
- package/dist/esm/ui/Renderer/index.js +11 -2
- package/dist/types/react/nodes/table/sticky.d.ts +34 -1
- package/dist/types/react/nodes/table.d.ts +33 -0
- package/dist/types/ui/Renderer/index.d.ts +5 -0
- package/dist/types-ts4.5/react/nodes/table/sticky.d.ts +34 -1
- package/dist/types-ts4.5/react/nodes/table.d.ts +33 -0
- package/dist/types-ts4.5/ui/Renderer/index.d.ts +5 -0
- package/package.json +18 -14
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { browser } from '@atlaskit/editor-common/browser';
|
|
5
4
|
import { TableSharedCssClassName, tableMarginTop } from '@atlaskit/editor-common/styles';
|
|
6
5
|
import { WidthConsumer, overflowShadow } from '@atlaskit/editor-common/ui';
|
|
7
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -17,7 +16,6 @@ import { StickyTable, tableStickyPadding, OverflowParent } from './table/sticky'
|
|
|
17
16
|
import { Table } from './table/table';
|
|
18
17
|
import { isCommentAppearance, isFullPageAppearance, isFullWidthAppearance, isFullWidthOrFullPageAppearance } from '../utils/appearance';
|
|
19
18
|
import { TableStickyScrollbar } from './TableStickyScrollbar';
|
|
20
|
-
import { TableProcessorWithContainerStyles } from './tableNew';
|
|
21
19
|
export const isTableResizingEnabled = appearance => isFullWidthOrFullPageAppearance(appearance) || isCommentAppearance(appearance) && editorExperiment('support_table_in_comment', true, {
|
|
22
20
|
exposure: true
|
|
23
21
|
});
|
|
@@ -96,6 +94,9 @@ export const isHeaderRowEnabled = rows => {
|
|
|
96
94
|
export const tableCanBeSticky = (node, children) => {
|
|
97
95
|
return isHeaderRowEnabled(children) && node && node.firstChild && !hasRowspan(node.firstChild);
|
|
98
96
|
};
|
|
97
|
+
/**
|
|
98
|
+
* Class for Tables in Renderer
|
|
99
|
+
*/
|
|
99
100
|
// Ignored via go/ees005
|
|
100
101
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
101
102
|
export class TableContainer extends React.Component {
|
|
@@ -205,6 +206,10 @@ export class TableContainer extends React.Component {
|
|
|
205
206
|
});
|
|
206
207
|
});
|
|
207
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
*/
|
|
208
213
|
componentDidMount() {
|
|
209
214
|
this.resizeObserver = new ResizeObserver(this.applyResizerChange);
|
|
210
215
|
if (this.wrapperRef.current) {
|
|
@@ -224,6 +229,13 @@ export class TableContainer extends React.Component {
|
|
|
224
229
|
this.stickyScrollbar = new TableStickyScrollbar(this.wrapperRef.current);
|
|
225
230
|
}
|
|
226
231
|
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
*
|
|
235
|
+
* @param prevProps
|
|
236
|
+
* @param prevState
|
|
237
|
+
* @example
|
|
238
|
+
*/
|
|
227
239
|
componentDidUpdate(prevProps, prevState) {
|
|
228
240
|
// toggling sticky headers visiblity
|
|
229
241
|
if (this.props.stickyHeaders && !this.overflowParent) {
|
|
@@ -246,12 +258,19 @@ export class TableContainer extends React.Component {
|
|
|
246
258
|
this.onWrapperScrolled();
|
|
247
259
|
}
|
|
248
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
*
|
|
263
|
+
*/
|
|
249
264
|
get pinTop() {
|
|
250
265
|
if (!this.tableRef.current || !this.stickyHeaderRef.current) {
|
|
251
266
|
return;
|
|
252
267
|
}
|
|
253
268
|
return this.tableRef.current.offsetHeight - this.stickyHeaderRef.current.offsetHeight + tableMarginTop - tableStickyPadding;
|
|
254
269
|
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
*
|
|
273
|
+
*/
|
|
255
274
|
get shouldAddOverflowParentOffsetTop_DO_NOT_USE() {
|
|
256
275
|
// IF the StickyHeaderConfig specifies that the default scroll root offsetTop should be added
|
|
257
276
|
// AND the StickyHeaderConfig specifies a default scroll root id
|
|
@@ -259,6 +278,10 @@ export class TableContainer extends React.Component {
|
|
|
259
278
|
// THEN we should add the OverflowParent offset top (RETURN TRUE)
|
|
260
279
|
return this.props.stickyHeaders && !!this.props.stickyHeaders.shouldAddDefaultScrollRootOffsetTop_DO_NOT_USE && !!this.props.stickyHeaders.defaultScrollRootId_DO_NOT_USE && this.overflowParent && this.overflowParent.id === this.props.stickyHeaders.defaultScrollRootId_DO_NOT_USE;
|
|
261
280
|
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
*
|
|
284
|
+
*/
|
|
262
285
|
get stickyTop() {
|
|
263
286
|
switch (this.state.stickyMode) {
|
|
264
287
|
case 'pin-bottom':
|
|
@@ -275,6 +298,11 @@ export class TableContainer extends React.Component {
|
|
|
275
298
|
return undefined;
|
|
276
299
|
}
|
|
277
300
|
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
*/
|
|
278
306
|
render() {
|
|
279
307
|
var _this$tableRef$curren;
|
|
280
308
|
const {
|
|
@@ -326,7 +354,7 @@ export class TableContainer extends React.Component {
|
|
|
326
354
|
const isCommentAppearanceAndTableAlignmentEnabled = isCommentAppearance(rendererAppearance) && allowTableAlignment;
|
|
327
355
|
const lineLength = isFullWidthAppearance(rendererAppearance) ? fullWidthLineLength : isCommentAppearanceAndTableAlignmentEnabled ? commentLineLength : lineLengthFixedWidth;
|
|
328
356
|
const lineLengthCSS = isFullWidthAppearance(rendererAppearance) ? fullWidthLineLengthCSS : isCommentAppearanceAndTableAlignmentEnabled ? renderWidthCSS : `${lineLengthFixedWidth}px`;
|
|
329
|
-
const fixTableSSRResizing = fg('platform-
|
|
357
|
+
const fixTableSSRResizing = fg('platform-ssr-table-resize');
|
|
330
358
|
const tableWidthNew = fixTableSSRResizing ? getTableContainerWidth(tableNode) : tableWidth;
|
|
331
359
|
const shouldCalculateLeftForAlignment = !isInsideOfBlockNode && !isInsideOfTable && isTableAlignStart && (isFullPageAppearance(rendererAppearance) && tableWidthNew <= lineLengthFixedWidth || isFullWidthAppearance(rendererAppearance) || isCommentAppearanceAndTableAlignmentEnabled);
|
|
332
360
|
let leftCSS;
|
|
@@ -424,7 +452,8 @@ export class TableContainer extends React.Component {
|
|
|
424
452
|
rowHeight: this.state.headerRowHeight,
|
|
425
453
|
tableNode: tableNode,
|
|
426
454
|
rendererAppearance: rendererAppearance,
|
|
427
|
-
allowTableResizing: allowTableResizing
|
|
455
|
+
allowTableResizing: allowTableResizing,
|
|
456
|
+
fixTableSSRResizing: fixTableSSRResizing
|
|
428
457
|
}, [children && children[0]]), /*#__PURE__*/React.createElement("div", {
|
|
429
458
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
430
459
|
className: TableSharedCssClassName.TABLE_NODE_WRAPPER,
|
|
@@ -471,6 +500,9 @@ export class TableContainer extends React.Component {
|
|
|
471
500
|
})));
|
|
472
501
|
}
|
|
473
502
|
}
|
|
503
|
+
/**
|
|
504
|
+
*
|
|
505
|
+
*/
|
|
474
506
|
// Ignored via go/ees005
|
|
475
507
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
476
508
|
export class TableProcessor extends React.Component {
|
|
@@ -517,6 +549,10 @@ export class TableProcessor extends React.Component {
|
|
|
517
549
|
});
|
|
518
550
|
});
|
|
519
551
|
}
|
|
552
|
+
/**
|
|
553
|
+
*
|
|
554
|
+
* @example
|
|
555
|
+
*/
|
|
520
556
|
render() {
|
|
521
557
|
const {
|
|
522
558
|
children
|
|
@@ -535,17 +571,6 @@ export class TableProcessor extends React.Component {
|
|
|
535
571
|
}
|
|
536
572
|
}
|
|
537
573
|
|
|
538
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
539
|
-
const TableWithShadowsAndContainerStyles = overflowShadow(TableProcessorWithContainerStyles, {
|
|
540
|
-
/**
|
|
541
|
-
* The :scope is in reference to table container and we are selecting only
|
|
542
|
-
* direct children that match the table node wrapper selector, not their
|
|
543
|
-
* descendants.
|
|
544
|
-
*/
|
|
545
|
-
overflowSelector: `:scope > .${TableSharedCssClassName.TABLE_NODE_WRAPPER}`,
|
|
546
|
-
useShadowObserver: true
|
|
547
|
-
});
|
|
548
|
-
|
|
549
574
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
550
575
|
const TableWithShadows = overflowShadow(TableProcessor, {
|
|
551
576
|
/**
|
|
@@ -556,57 +581,26 @@ const TableWithShadows = overflowShadow(TableProcessor, {
|
|
|
556
581
|
overflowSelector: `:scope > .${TableSharedCssClassName.TABLE_NODE_WRAPPER}`,
|
|
557
582
|
useShadowObserver: true
|
|
558
583
|
});
|
|
559
|
-
|
|
560
|
-
// Legacy tables have only one of the three layouts and do not have a width attribute
|
|
561
|
-
const isLegacyTable = layout => {
|
|
562
|
-
return Boolean(['default', 'wide', 'full-width'].includes(layout));
|
|
563
|
-
};
|
|
564
|
-
const shouldRenderTableWithCSSWidth = (layout, width) => {
|
|
565
|
-
// The CSS width optimization is currently only in place when the table node
|
|
566
|
-
// has a defined width and is not a legacy table
|
|
567
|
-
|
|
568
|
-
// the optimization is also skipped for Safari due to browser limitations with container styles
|
|
569
|
-
if (browser.safari || !width || isLegacyTable(layout)) {
|
|
570
|
-
return false;
|
|
571
|
-
}
|
|
572
|
-
return true;
|
|
573
|
-
};
|
|
574
584
|
const TableWithWidth = props => {
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
585
|
+
return /*#__PURE__*/React.createElement(WidthConsumer, null, ({
|
|
586
|
+
width
|
|
587
|
+
}) => {
|
|
578
588
|
var _props$columnWidths;
|
|
589
|
+
const renderWidth = props.rendererAppearance === 'full-page' ? width - FullPagePadding * 2 : width;
|
|
579
590
|
const colWidthsSum = ((_props$columnWidths = props.columnWidths) === null || _props$columnWidths === void 0 ? void 0 : _props$columnWidths.reduce((total, val) => total + val, 0)) || 0;
|
|
580
591
|
if (colWidthsSum || props.allowTableResizing) {
|
|
581
592
|
// Ignored via go/ees005
|
|
582
593
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
583
|
-
return /*#__PURE__*/React.createElement(
|
|
584
|
-
}
|
|
585
|
-
return /*#__PURE__*/React.createElement(TableProcessorWithContainerStyles
|
|
586
|
-
// Ignored via go/ees005
|
|
587
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
588
|
-
, props);
|
|
589
|
-
} else {
|
|
590
|
-
return /*#__PURE__*/React.createElement(WidthConsumer, null, ({
|
|
591
|
-
width
|
|
592
|
-
}) => {
|
|
593
|
-
var _props$columnWidths2;
|
|
594
|
-
const renderWidth = props.rendererAppearance === 'full-page' ? width - FullPagePadding * 2 : width;
|
|
595
|
-
const colWidthsSum = ((_props$columnWidths2 = props.columnWidths) === null || _props$columnWidths2 === void 0 ? void 0 : _props$columnWidths2.reduce((total, val) => total + val, 0)) || 0;
|
|
596
|
-
if (colWidthsSum || props.allowTableResizing) {
|
|
597
|
-
// Ignored via go/ees005
|
|
598
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
599
|
-
return /*#__PURE__*/React.createElement(TableWithShadows, _extends({
|
|
600
|
-
renderWidth: renderWidth
|
|
601
|
-
}, props));
|
|
602
|
-
}
|
|
603
|
-
// there should not be a case when colWidthsSum is 0 and table is in overflow state - so no need to render shadows in this case
|
|
604
|
-
return /*#__PURE__*/React.createElement(TableProcessor, _extends({
|
|
594
|
+
return /*#__PURE__*/React.createElement(TableWithShadows, _extends({
|
|
605
595
|
renderWidth: renderWidth
|
|
606
|
-
// Ignored via go/ees005
|
|
607
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
608
596
|
}, props));
|
|
609
|
-
}
|
|
610
|
-
|
|
597
|
+
}
|
|
598
|
+
// there should not be a case when colWidthsSum is 0 and table is in overflow state - so no need to render shadows in this case
|
|
599
|
+
return /*#__PURE__*/React.createElement(TableProcessor, _extends({
|
|
600
|
+
renderWidth: renderWidth
|
|
601
|
+
// Ignored via go/ees005
|
|
602
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
603
|
+
}, props));
|
|
604
|
+
});
|
|
611
605
|
};
|
|
612
606
|
export default withSmartCardStorage(TableWithWidth);
|
|
@@ -171,6 +171,11 @@ export const renderDocument = (doc, serializer, schema = defaultSchema, adfStage
|
|
|
171
171
|
const stat = {
|
|
172
172
|
sanitizeTime: 0
|
|
173
173
|
};
|
|
174
|
+
|
|
175
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
176
|
+
if (fg('platform_editor_renderer_rm_usespecbasedvalidator')) {
|
|
177
|
+
useSpecBasedValidator = true;
|
|
178
|
+
}
|
|
174
179
|
const {
|
|
175
180
|
output: validDoc,
|
|
176
181
|
time: sanitizeTime
|
package/dist/es2019/ui/Expand.js
CHANGED
|
@@ -13,6 +13,7 @@ import { akEditorLineHeight, akEditorSwoopCubicBezier, akLayoutGutterOffset } fr
|
|
|
13
13
|
import { default as ChevronRightIconLegacy } from '@atlaskit/icon/glyph/chevron-right';
|
|
14
14
|
import ChevronRightIcon from '@atlaskit/icon/utility/chevron-right';
|
|
15
15
|
import Tooltip from '@atlaskit/tooltip';
|
|
16
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
16
17
|
import _uniqueId from 'lodash/uniqueId';
|
|
17
18
|
import { injectIntl } from 'react-intl-next';
|
|
18
19
|
import { MODE, PLATFORM } from '../analytics/events';
|
|
@@ -240,6 +241,8 @@ function Expand({
|
|
|
240
241
|
className: `${nodeType}-content-wrapper`
|
|
241
242
|
}, jsx(WidthProvider, null, jsx("div", {
|
|
242
243
|
css: clearNextSiblingMarginTopStyle
|
|
243
|
-
}),
|
|
244
|
+
}), editorExperiment('confluence_p2m_style_recalc_and_expand_joint_exp', true, {
|
|
245
|
+
exposure: true
|
|
246
|
+
}) ? expanded && children : children))));
|
|
244
247
|
}
|
|
245
248
|
export default injectIntl(Expand);
|
|
@@ -48,7 +48,7 @@ import { PortalContext } from './PortalContext';
|
|
|
48
48
|
export const NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
49
49
|
export const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
50
50
|
const packageName = "@atlaskit/renderer";
|
|
51
|
-
const packageVersion = "
|
|
51
|
+
const packageVersion = "118.0.0";
|
|
52
52
|
const setAsQueryContainerStyles = css({
|
|
53
53
|
containerName: 'ak-renderer-wrapper',
|
|
54
54
|
containerType: 'inline-size'
|
|
@@ -118,6 +118,9 @@ const handleMouseTripleClickInTables = event => {
|
|
|
118
118
|
* link, call the onUnhandledClick eventHandler (which in Jira for example, may switch the
|
|
119
119
|
* renderer out for the editor).
|
|
120
120
|
* @param event Click event anywhere inside renderer
|
|
121
|
+
* @param props
|
|
122
|
+
* @param mouseDownSelection
|
|
123
|
+
* @example
|
|
121
124
|
*/
|
|
122
125
|
const handleWrapperOnClick = (event, props, mouseDownSelection) => {
|
|
123
126
|
var _props$eventHandlers;
|
|
@@ -463,6 +466,12 @@ const getRendererComponent = nodeComponents => {
|
|
|
463
466
|
}
|
|
464
467
|
return RendererFunctionalComponent;
|
|
465
468
|
};
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
*
|
|
472
|
+
* @param props
|
|
473
|
+
* @example
|
|
474
|
+
*/
|
|
466
475
|
export function Renderer(props) {
|
|
467
476
|
const {
|
|
468
477
|
startPos
|
|
@@ -609,7 +618,7 @@ const RendererWrapper = /*#__PURE__*/React.memo(props => {
|
|
|
609
618
|
// Only apply container-type = inline-size when having a known width in full-page/full-width/comment mode.
|
|
610
619
|
// Otherwise when appearance is unspecified the renderer size is decided by the content.
|
|
611
620
|
// In this case we can't set the container-type = inline-size as it will collapse width to 0.
|
|
612
|
-
return appearance === 'comment' &&
|
|
621
|
+
return (appearance === 'full-page' || appearance === 'full-width' || appearance === 'comment') &&
|
|
613
622
|
// In case of having excerpt-include on page there are multiple renderers nested.
|
|
614
623
|
// Make sure only the root renderer is set to be query container.
|
|
615
624
|
isTopLevelRenderer && fg('platform-ssr-table-resize') ? jsx("div", {
|
package/dist/esm/react/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { Doc, DocWithSelectAllTrap, mergeTextNodes, isTextWrapper, isTextNode, t
|
|
|
15
15
|
import TextWrapperComponent from './nodes/text-wrapper';
|
|
16
16
|
import { toReact as markToReact, isAnnotationMark } from './marks';
|
|
17
17
|
import { getMarksByOrder, isSameMark } from '@atlaskit/editor-common/validator';
|
|
18
|
-
import {
|
|
18
|
+
import { getColumnWidths } from '@atlaskit/editor-common/utils';
|
|
19
19
|
import { getText } from '../utils';
|
|
20
20
|
import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
|
|
21
21
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -400,11 +400,7 @@ var ReactSerializer = /*#__PURE__*/function () {
|
|
|
400
400
|
var stickyHeaders = !isInsideOfTable && !insideBreakoutLayout(path) ? this.stickyHeaders : undefined;
|
|
401
401
|
return _objectSpread(_objectSpread({}, this.getProps(node)), {}, {
|
|
402
402
|
allowColumnSorting: this.allowColumnSorting,
|
|
403
|
-
columnWidths:
|
|
404
|
-
// When allowTableResizing is enabled, the number of columns is required to render
|
|
405
|
-
// the same scaling logic as editor. Some tables can have unequal rows, so the entire
|
|
406
|
-
// table needs to be scanned.
|
|
407
|
-
this.allowTableResizing && fg('platform_editor_table_col_calculation_fix') ? getColumnWidths(node) : calcTableColumnWidths(node),
|
|
403
|
+
columnWidths: getColumnWidths(node),
|
|
408
404
|
tableNode: node,
|
|
409
405
|
stickyHeaders: stickyHeaders,
|
|
410
406
|
isInsideOfBlockNode: isInsideOfBlockNode,
|
|
@@ -93,7 +93,9 @@ export var StickyTable = function StickyTable(_ref) {
|
|
|
93
93
|
rowHeight = _ref.rowHeight,
|
|
94
94
|
tableNode = _ref.tableNode,
|
|
95
95
|
rendererAppearance = _ref.rendererAppearance,
|
|
96
|
-
allowTableResizing = _ref.allowTableResizing
|
|
96
|
+
allowTableResizing = _ref.allowTableResizing,
|
|
97
|
+
_ref$fixTableSSRResiz = _ref.fixTableSSRResizing,
|
|
98
|
+
fixTableSSRResizing = _ref$fixTableSSRResiz === void 0 ? false : _ref$fixTableSSRResiz;
|
|
97
99
|
var styles;
|
|
98
100
|
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
99
101
|
if (allowTableResizing) {
|
|
@@ -126,7 +128,9 @@ export var StickyTable = function StickyTable(_ref) {
|
|
|
126
128
|
className: "".concat(TableSharedCssClassName.TABLE_CONTAINER, " is-sticky ").concat(shadowClassNames || ''),
|
|
127
129
|
"data-layout": layout,
|
|
128
130
|
style: {
|
|
129
|
-
width: tableWidth
|
|
131
|
+
width: tableWidth,
|
|
132
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
133
|
+
marginBottom: fixTableSSRResizing ? 0 : ''
|
|
130
134
|
}
|
|
131
135
|
}, jsx("div", {
|
|
132
136
|
ref: innerRef
|
|
@@ -159,6 +163,9 @@ export var StickyTable = function StickyTable(_ref) {
|
|
|
159
163
|
|
|
160
164
|
/**
|
|
161
165
|
* Traverse DOM Tree upwards looking for table parents with "overflow: scroll".
|
|
166
|
+
* @param table
|
|
167
|
+
* @param defaultScrollRootId
|
|
168
|
+
* @example
|
|
162
169
|
*/
|
|
163
170
|
function findHorizontalOverflowScrollParent(table, defaultScrollRootId) {
|
|
164
171
|
var parent = table;
|
|
@@ -182,17 +189,36 @@ function findHorizontalOverflowScrollParent(table, defaultScrollRootId) {
|
|
|
182
189
|
}
|
|
183
190
|
return null;
|
|
184
191
|
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
*
|
|
195
|
+
*/
|
|
185
196
|
export var OverflowParent = /*#__PURE__*/function () {
|
|
186
197
|
function OverflowParent(ref) {
|
|
187
198
|
_classCallCheck(this, OverflowParent);
|
|
188
199
|
this.ref = ref;
|
|
189
200
|
this.ref = ref;
|
|
190
201
|
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
*
|
|
205
|
+
* @param el
|
|
206
|
+
* @param defaultScrollRootId
|
|
207
|
+
* @example
|
|
208
|
+
*/
|
|
191
209
|
return _createClass(OverflowParent, [{
|
|
192
210
|
key: "isElement",
|
|
193
|
-
get:
|
|
211
|
+
get:
|
|
212
|
+
/**
|
|
213
|
+
*
|
|
214
|
+
*/
|
|
215
|
+
function get() {
|
|
194
216
|
return this.ref instanceof HTMLElement;
|
|
195
217
|
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
*
|
|
221
|
+
*/
|
|
196
222
|
}, {
|
|
197
223
|
key: "id",
|
|
198
224
|
get: function get() {
|
|
@@ -201,6 +227,10 @@ export var OverflowParent = /*#__PURE__*/function () {
|
|
|
201
227
|
}
|
|
202
228
|
return '';
|
|
203
229
|
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
*
|
|
233
|
+
*/
|
|
204
234
|
}, {
|
|
205
235
|
key: "top",
|
|
206
236
|
get: function get() {
|
|
@@ -210,6 +240,13 @@ export var OverflowParent = /*#__PURE__*/function () {
|
|
|
210
240
|
return 0;
|
|
211
241
|
}
|
|
212
242
|
|
|
243
|
+
/**
|
|
244
|
+
*
|
|
245
|
+
* @param type
|
|
246
|
+
* @param cb
|
|
247
|
+
* @param {...any} args
|
|
248
|
+
* @example
|
|
249
|
+
*/
|
|
213
250
|
// Ignored via go/ees005
|
|
214
251
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
215
252
|
}, {
|
|
@@ -224,6 +261,13 @@ export var OverflowParent = /*#__PURE__*/function () {
|
|
|
224
261
|
(_this$ref = this.ref).addEventListener.apply(_this$ref, [type, cb].concat(args));
|
|
225
262
|
}
|
|
226
263
|
|
|
264
|
+
/**
|
|
265
|
+
*
|
|
266
|
+
* @param type
|
|
267
|
+
* @param cb
|
|
268
|
+
* @param {...any} args
|
|
269
|
+
* @example
|
|
270
|
+
*/
|
|
227
271
|
// Ignored via go/ees005
|
|
228
272
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
229
273
|
}, {
|
|
@@ -12,7 +12,6 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
12
12
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
13
13
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
14
14
|
import React from 'react';
|
|
15
|
-
import { browser } from '@atlaskit/editor-common/browser';
|
|
16
15
|
import { TableSharedCssClassName, tableMarginTop } from '@atlaskit/editor-common/styles';
|
|
17
16
|
import { WidthConsumer, overflowShadow } from '@atlaskit/editor-common/ui';
|
|
18
17
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -28,7 +27,6 @@ import { StickyTable, tableStickyPadding, OverflowParent } from './table/sticky'
|
|
|
28
27
|
import { Table } from './table/table';
|
|
29
28
|
import { isCommentAppearance, isFullPageAppearance, isFullWidthAppearance, isFullWidthOrFullPageAppearance } from '../utils/appearance';
|
|
30
29
|
import { TableStickyScrollbar } from './TableStickyScrollbar';
|
|
31
|
-
import { TableProcessorWithContainerStyles } from './tableNew';
|
|
32
30
|
export var isTableResizingEnabled = function isTableResizingEnabled(appearance) {
|
|
33
31
|
return isFullWidthOrFullPageAppearance(appearance) || isCommentAppearance(appearance) && editorExperiment('support_table_in_comment', true, {
|
|
34
32
|
exposure: true
|
|
@@ -120,6 +118,9 @@ export var isHeaderRowEnabled = function isHeaderRowEnabled(rows) {
|
|
|
120
118
|
export var tableCanBeSticky = function tableCanBeSticky(node, children) {
|
|
121
119
|
return isHeaderRowEnabled(children) && node && node.firstChild && !hasRowspan(node.firstChild);
|
|
122
120
|
};
|
|
121
|
+
/**
|
|
122
|
+
* Class for Tables in Renderer
|
|
123
|
+
*/
|
|
123
124
|
// Ignored via go/ees005
|
|
124
125
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
125
126
|
export var TableContainer = /*#__PURE__*/function (_React$Component) {
|
|
@@ -245,7 +246,12 @@ export var TableContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
245
246
|
_inherits(TableContainer, _React$Component);
|
|
246
247
|
return _createClass(TableContainer, [{
|
|
247
248
|
key: "componentDidMount",
|
|
248
|
-
value:
|
|
249
|
+
value:
|
|
250
|
+
/**
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
*/
|
|
254
|
+
function componentDidMount() {
|
|
249
255
|
this.resizeObserver = new ResizeObserver(this.applyResizerChange);
|
|
250
256
|
if (this.wrapperRef.current) {
|
|
251
257
|
this.resizeObserver.observe(this.wrapperRef.current);
|
|
@@ -264,6 +270,13 @@ export var TableContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
264
270
|
this.stickyScrollbar = new TableStickyScrollbar(this.wrapperRef.current);
|
|
265
271
|
}
|
|
266
272
|
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
*
|
|
276
|
+
* @param prevProps
|
|
277
|
+
* @param prevState
|
|
278
|
+
* @example
|
|
279
|
+
*/
|
|
267
280
|
}, {
|
|
268
281
|
key: "componentDidUpdate",
|
|
269
282
|
value: function componentDidUpdate(prevProps, prevState) {
|
|
@@ -290,12 +303,20 @@ export var TableContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
290
303
|
}
|
|
291
304
|
}, {
|
|
292
305
|
key: "pinTop",
|
|
293
|
-
get:
|
|
306
|
+
get:
|
|
307
|
+
/**
|
|
308
|
+
*
|
|
309
|
+
*/
|
|
310
|
+
function get() {
|
|
294
311
|
if (!this.tableRef.current || !this.stickyHeaderRef.current) {
|
|
295
312
|
return;
|
|
296
313
|
}
|
|
297
314
|
return this.tableRef.current.offsetHeight - this.stickyHeaderRef.current.offsetHeight + tableMarginTop - tableStickyPadding;
|
|
298
315
|
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
*
|
|
319
|
+
*/
|
|
299
320
|
}, {
|
|
300
321
|
key: "shouldAddOverflowParentOffsetTop_DO_NOT_USE",
|
|
301
322
|
get: function get() {
|
|
@@ -305,6 +326,10 @@ export var TableContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
305
326
|
// THEN we should add the OverflowParent offset top (RETURN TRUE)
|
|
306
327
|
return this.props.stickyHeaders && !!this.props.stickyHeaders.shouldAddDefaultScrollRootOffsetTop_DO_NOT_USE && !!this.props.stickyHeaders.defaultScrollRootId_DO_NOT_USE && this.overflowParent && this.overflowParent.id === this.props.stickyHeaders.defaultScrollRootId_DO_NOT_USE;
|
|
307
328
|
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
*
|
|
332
|
+
*/
|
|
308
333
|
}, {
|
|
309
334
|
key: "stickyTop",
|
|
310
335
|
get: function get() {
|
|
@@ -323,6 +348,11 @@ export var TableContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
323
348
|
return undefined;
|
|
324
349
|
}
|
|
325
350
|
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
*/
|
|
326
356
|
}, {
|
|
327
357
|
key: "render",
|
|
328
358
|
value: function render() {
|
|
@@ -376,7 +406,7 @@ export var TableContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
376
406
|
var isCommentAppearanceAndTableAlignmentEnabled = isCommentAppearance(rendererAppearance) && allowTableAlignment;
|
|
377
407
|
var lineLength = isFullWidthAppearance(rendererAppearance) ? fullWidthLineLength : isCommentAppearanceAndTableAlignmentEnabled ? commentLineLength : lineLengthFixedWidth;
|
|
378
408
|
var lineLengthCSS = isFullWidthAppearance(rendererAppearance) ? fullWidthLineLengthCSS : isCommentAppearanceAndTableAlignmentEnabled ? renderWidthCSS : "".concat(lineLengthFixedWidth, "px");
|
|
379
|
-
var fixTableSSRResizing = fg('platform-
|
|
409
|
+
var fixTableSSRResizing = fg('platform-ssr-table-resize');
|
|
380
410
|
var tableWidthNew = fixTableSSRResizing ? getTableContainerWidth(tableNode) : tableWidth;
|
|
381
411
|
var shouldCalculateLeftForAlignment = !isInsideOfBlockNode && !isInsideOfTable && isTableAlignStart && (isFullPageAppearance(rendererAppearance) && tableWidthNew <= lineLengthFixedWidth || isFullWidthAppearance(rendererAppearance) || isCommentAppearanceAndTableAlignmentEnabled);
|
|
382
412
|
var leftCSS;
|
|
@@ -474,7 +504,8 @@ export var TableContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
474
504
|
rowHeight: this.state.headerRowHeight,
|
|
475
505
|
tableNode: tableNode,
|
|
476
506
|
rendererAppearance: rendererAppearance,
|
|
477
|
-
allowTableResizing: allowTableResizing
|
|
507
|
+
allowTableResizing: allowTableResizing,
|
|
508
|
+
fixTableSSRResizing: fixTableSSRResizing
|
|
478
509
|
}, [children && children[0]]), /*#__PURE__*/React.createElement("div", {
|
|
479
510
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
480
511
|
className: TableSharedCssClassName.TABLE_NODE_WRAPPER,
|
|
@@ -522,6 +553,9 @@ export var TableContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
522
553
|
}
|
|
523
554
|
}]);
|
|
524
555
|
}(React.Component);
|
|
556
|
+
/**
|
|
557
|
+
*
|
|
558
|
+
*/
|
|
525
559
|
// Ignored via go/ees005
|
|
526
560
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
527
561
|
export var TableProcessor = /*#__PURE__*/function (_React$Component2) {
|
|
@@ -572,7 +606,12 @@ export var TableProcessor = /*#__PURE__*/function (_React$Component2) {
|
|
|
572
606
|
_inherits(TableProcessor, _React$Component2);
|
|
573
607
|
return _createClass(TableProcessor, [{
|
|
574
608
|
key: "render",
|
|
575
|
-
value:
|
|
609
|
+
value:
|
|
610
|
+
/**
|
|
611
|
+
*
|
|
612
|
+
* @example
|
|
613
|
+
*/
|
|
614
|
+
function render() {
|
|
576
615
|
var children = this.props.children;
|
|
577
616
|
if (!children) {
|
|
578
617
|
return null;
|
|
@@ -589,17 +628,6 @@ export var TableProcessor = /*#__PURE__*/function (_React$Component2) {
|
|
|
589
628
|
}]);
|
|
590
629
|
}(React.Component);
|
|
591
630
|
|
|
592
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
593
|
-
var TableWithShadowsAndContainerStyles = overflowShadow(TableProcessorWithContainerStyles, {
|
|
594
|
-
/**
|
|
595
|
-
* The :scope is in reference to table container and we are selecting only
|
|
596
|
-
* direct children that match the table node wrapper selector, not their
|
|
597
|
-
* descendants.
|
|
598
|
-
*/
|
|
599
|
-
overflowSelector: ":scope > .".concat(TableSharedCssClassName.TABLE_NODE_WRAPPER),
|
|
600
|
-
useShadowObserver: true
|
|
601
|
-
});
|
|
602
|
-
|
|
603
631
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
604
632
|
var TableWithShadows = overflowShadow(TableProcessor, {
|
|
605
633
|
/**
|
|
@@ -610,60 +638,27 @@ var TableWithShadows = overflowShadow(TableProcessor, {
|
|
|
610
638
|
overflowSelector: ":scope > .".concat(TableSharedCssClassName.TABLE_NODE_WRAPPER),
|
|
611
639
|
useShadowObserver: true
|
|
612
640
|
});
|
|
613
|
-
|
|
614
|
-
// Legacy tables have only one of the three layouts and do not have a width attribute
|
|
615
|
-
var isLegacyTable = function isLegacyTable(layout) {
|
|
616
|
-
return Boolean(['default', 'wide', 'full-width'].includes(layout));
|
|
617
|
-
};
|
|
618
|
-
var shouldRenderTableWithCSSWidth = function shouldRenderTableWithCSSWidth(layout, width) {
|
|
619
|
-
// The CSS width optimization is currently only in place when the table node
|
|
620
|
-
// has a defined width and is not a legacy table
|
|
621
|
-
|
|
622
|
-
// the optimization is also skipped for Safari due to browser limitations with container styles
|
|
623
|
-
if (browser.safari || !width || isLegacyTable(layout)) {
|
|
624
|
-
return false;
|
|
625
|
-
}
|
|
626
|
-
return true;
|
|
627
|
-
};
|
|
628
641
|
var TableWithWidth = function TableWithWidth(props) {
|
|
629
|
-
|
|
630
|
-
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
631
|
-
if ((shouldRenderTableWithCSSWidth((_props$tableNode$attr = (_props$tableNode = props.tableNode) === null || _props$tableNode === void 0 || (_props$tableNode = _props$tableNode.attrs) === null || _props$tableNode === void 0 ? void 0 : _props$tableNode.layout) !== null && _props$tableNode$attr !== void 0 ? _props$tableNode$attr : '', (_props$tableNode2 = props.tableNode) === null || _props$tableNode2 === void 0 || (_props$tableNode2 = _props$tableNode2.attrs) === null || _props$tableNode2 === void 0 ? void 0 : _props$tableNode2.width) || props.rendererAppearance === 'comment') && fg('platform-ssr-table-resize')) {
|
|
642
|
+
return /*#__PURE__*/React.createElement(WidthConsumer, null, function (_ref2) {
|
|
632
643
|
var _props$columnWidths;
|
|
644
|
+
var width = _ref2.width;
|
|
645
|
+
var renderWidth = props.rendererAppearance === 'full-page' ? width - FullPagePadding * 2 : width;
|
|
633
646
|
var colWidthsSum = ((_props$columnWidths = props.columnWidths) === null || _props$columnWidths === void 0 ? void 0 : _props$columnWidths.reduce(function (total, val) {
|
|
634
647
|
return total + val;
|
|
635
648
|
}, 0)) || 0;
|
|
636
649
|
if (colWidthsSum || props.allowTableResizing) {
|
|
637
650
|
// Ignored via go/ees005
|
|
638
651
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
639
|
-
return /*#__PURE__*/React.createElement(
|
|
640
|
-
}
|
|
641
|
-
return /*#__PURE__*/React.createElement(TableProcessorWithContainerStyles
|
|
642
|
-
// Ignored via go/ees005
|
|
643
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
644
|
-
, props);
|
|
645
|
-
} else {
|
|
646
|
-
return /*#__PURE__*/React.createElement(WidthConsumer, null, function (_ref2) {
|
|
647
|
-
var _props$columnWidths2;
|
|
648
|
-
var width = _ref2.width;
|
|
649
|
-
var renderWidth = props.rendererAppearance === 'full-page' ? width - FullPagePadding * 2 : width;
|
|
650
|
-
var colWidthsSum = ((_props$columnWidths2 = props.columnWidths) === null || _props$columnWidths2 === void 0 ? void 0 : _props$columnWidths2.reduce(function (total, val) {
|
|
651
|
-
return total + val;
|
|
652
|
-
}, 0)) || 0;
|
|
653
|
-
if (colWidthsSum || props.allowTableResizing) {
|
|
654
|
-
// Ignored via go/ees005
|
|
655
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
656
|
-
return /*#__PURE__*/React.createElement(TableWithShadows, _extends({
|
|
657
|
-
renderWidth: renderWidth
|
|
658
|
-
}, props));
|
|
659
|
-
}
|
|
660
|
-
// there should not be a case when colWidthsSum is 0 and table is in overflow state - so no need to render shadows in this case
|
|
661
|
-
return /*#__PURE__*/React.createElement(TableProcessor, _extends({
|
|
652
|
+
return /*#__PURE__*/React.createElement(TableWithShadows, _extends({
|
|
662
653
|
renderWidth: renderWidth
|
|
663
|
-
// Ignored via go/ees005
|
|
664
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
665
654
|
}, props));
|
|
666
|
-
}
|
|
667
|
-
|
|
655
|
+
}
|
|
656
|
+
// there should not be a case when colWidthsSum is 0 and table is in overflow state - so no need to render shadows in this case
|
|
657
|
+
return /*#__PURE__*/React.createElement(TableProcessor, _extends({
|
|
658
|
+
renderWidth: renderWidth
|
|
659
|
+
// Ignored via go/ees005
|
|
660
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
661
|
+
}, props));
|
|
662
|
+
});
|
|
668
663
|
};
|
|
669
664
|
export default withSmartCardStorage(TableWithWidth);
|
|
@@ -205,6 +205,11 @@ export var renderDocument = function renderDocument(doc, serializer) {
|
|
|
205
205
|
var stat = {
|
|
206
206
|
sanitizeTime: 0
|
|
207
207
|
};
|
|
208
|
+
|
|
209
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
210
|
+
if (fg('platform_editor_renderer_rm_usespecbasedvalidator')) {
|
|
211
|
+
useSpecBasedValidator = true;
|
|
212
|
+
}
|
|
208
213
|
var _withStopwatch = withStopwatch(function () {
|
|
209
214
|
return memoValidation(doc, schema, adfStage, useSpecBasedValidator, dispatchAnalyticsEvent, skipValidation);
|
|
210
215
|
}),
|