@atlaskit/renderer 114.11.2 → 114.12.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/dist/cjs/react/nodes/blockCard.js +24 -8
  4. package/dist/cjs/react/nodes/table/colgroup.js +5 -2
  5. package/dist/cjs/react/nodes/table/table.js +6 -1
  6. package/dist/cjs/react/nodes/table.js +51 -23
  7. package/dist/cjs/react/nodes/tableNew.js +550 -0
  8. package/dist/cjs/react/utils/EditorMediaClientProvider.js +23 -8
  9. package/dist/cjs/ui/Renderer/breakout-ssr.js +22 -22
  10. package/dist/cjs/ui/Renderer/index.js +1 -1
  11. package/dist/es2019/react/nodes/blockCard.js +24 -8
  12. package/dist/es2019/react/nodes/table/colgroup.js +5 -2
  13. package/dist/es2019/react/nodes/table/table.js +6 -1
  14. package/dist/es2019/react/nodes/table.js +50 -22
  15. package/dist/es2019/react/nodes/tableNew.js +501 -0
  16. package/dist/es2019/react/utils/EditorMediaClientProvider.js +25 -10
  17. package/dist/es2019/ui/Renderer/breakout-ssr.js +22 -22
  18. package/dist/es2019/ui/Renderer/index.js +1 -1
  19. package/dist/esm/react/nodes/blockCard.js +24 -8
  20. package/dist/esm/react/nodes/table/colgroup.js +5 -2
  21. package/dist/esm/react/nodes/table/table.js +6 -1
  22. package/dist/esm/react/nodes/table.js +51 -21
  23. package/dist/esm/react/nodes/tableNew.js +544 -0
  24. package/dist/esm/react/utils/EditorMediaClientProvider.js +25 -10
  25. package/dist/esm/ui/Renderer/breakout-ssr.js +22 -22
  26. package/dist/esm/ui/Renderer/index.js +1 -1
  27. package/dist/types/react/nodes/table.d.ts +35 -254
  28. package/dist/types/react/nodes/tableNew.d.ts +83 -0
  29. package/dist/types/ui/Renderer/breakout-ssr.d.ts +1 -2
  30. package/dist/types-ts4.5/react/nodes/table.d.ts +35 -254
  31. package/dist/types-ts4.5/react/nodes/tableNew.d.ts +83 -0
  32. package/dist/types-ts4.5/ui/Renderer/breakout-ssr.d.ts +1 -2
  33. package/package.json +13 -3
@@ -0,0 +1,501 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ /* eslint-disable @atlaskit/ui-styling-standard/no-classname-prop, @atlaskit/ui-styling-standard/enforce-style-prop */
3
+ import React from 'react';
4
+ import { TableSharedCssClassName, tableMarginTop } from '@atlaskit/editor-common/styles';
5
+ import { createCompareNodes, convertProsemirrorTableNodeToArrayOfRows, hasMergedCell, compose } from '@atlaskit/editor-common/utils';
6
+ import { SortOrder } from '@atlaskit/editor-common/types';
7
+ import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
8
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
9
+ import { TableHeader } from './tableCell';
10
+ import { StickyTable, tableStickyPadding, OverflowParent } from './table/sticky';
11
+ import { Table } from './table/table';
12
+ import { TableMap } from '@atlaskit/editor-tables/table-map';
13
+ import { isCommentAppearance, isFullWidthOrFullPageAppearance } from '../utils/appearance';
14
+ import { TableStickyScrollbar } from './TableStickyScrollbar';
15
+ const getResizerMinWidth = node => {
16
+ const currentColumnCount = getColgroupChildrenLength(node);
17
+ const minColumnWidth = Math.min(3, currentColumnCount) * COLUMN_MIN_WIDTH;
18
+ // add an extra pixel as the scale table logic will scale columns to be tableContainerWidth - 1
19
+ // the table can't scale past its min-width, so instead restrict table container min width to avoid that situation
20
+ return minColumnWidth + 1;
21
+ };
22
+ const getColgroupChildrenLength = table => {
23
+ const map = TableMap.get(table);
24
+ return map.width;
25
+ };
26
+ const gutterPadding = akEditorGutterPaddingDynamic() * 2;
27
+ const COLUMN_MIN_WIDTH = 48;
28
+ export const isTableResizingEnabled = appearance => isFullWidthOrFullPageAppearance(appearance) || isCommentAppearance(appearance) && editorExperiment('support_table_in_comment', true, {
29
+ exposure: true
30
+ });
31
+ export const isStickyScrollbarEnabled = appearance => isFullWidthOrFullPageAppearance(appearance) && editorExperiment('platform_renderer_table_sticky_scrollbar', true, {
32
+ exposure: true
33
+ });
34
+ export const orderChildren = (children, tableNode, smartCardStorage, tableOrderStatus) => {
35
+ if (!tableOrderStatus || tableOrderStatus.order === SortOrder.NO_ORDER) {
36
+ return children;
37
+ }
38
+ const {
39
+ order,
40
+ columnIndex
41
+ } = tableOrderStatus;
42
+ const compareNodesInOrder = createCompareNodes({
43
+ getInlineCardTextFromStore(attrs) {
44
+ const {
45
+ url
46
+ } = attrs;
47
+ if (!url) {
48
+ return null;
49
+ }
50
+ return smartCardStorage.get(url) || null;
51
+ }
52
+ }, order);
53
+ const tableArray = convertProsemirrorTableNodeToArrayOfRows(tableNode);
54
+ const tableArrayWithChildren = tableArray.map((rowNodes, index) => ({
55
+ rowNodes,
56
+ rowReact: children[index]
57
+ }));
58
+ const headerRow = tableArrayWithChildren.shift();
59
+ const sortedTable = tableArrayWithChildren.sort((rowA, rowB) => compareNodesInOrder(rowA.rowNodes[columnIndex], rowB.rowNodes[columnIndex]));
60
+ if (headerRow) {
61
+ sortedTable.unshift(headerRow);
62
+ }
63
+ return sortedTable.map(elem => elem.rowReact);
64
+ };
65
+ export const hasRowspan = row => {
66
+ let hasRowspan = false;
67
+ row.forEach(cell => hasRowspan = hasRowspan || cell.attrs.rowspan > 1);
68
+ return hasRowspan;
69
+ };
70
+ export const getRefTop = refElement => {
71
+ return Math.round(refElement.getBoundingClientRect().top);
72
+ };
73
+ export const shouldHeaderStick = (scrollTop, tableTop, tableBottom, rowHeight) => tableTop <= scrollTop && !(tableBottom - rowHeight <= scrollTop);
74
+ export const shouldHeaderPinBottom = (scrollTop, tableBottom, rowHeight) => tableBottom - rowHeight <= scrollTop && !(tableBottom < scrollTop);
75
+ export const addSortableColumn = (rows, tableOrderStatus, onSorting) => {
76
+ return React.Children.map(rows, (row, index) => {
77
+ if (index === 0) {
78
+ return /*#__PURE__*/React.cloneElement(React.Children.only(row), {
79
+ tableOrderStatus,
80
+ onSorting
81
+ });
82
+ }
83
+ return row;
84
+ });
85
+ };
86
+ export const isHeaderRowEnabled = rows => {
87
+ if (!rows.length) {
88
+ return false;
89
+ }
90
+ // Ignored via go/ees005
91
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
92
+ const {
93
+ children
94
+ } = rows[0].props;
95
+ if (!children.length) {
96
+ return false;
97
+ }
98
+ if (children.length === 1) {
99
+ return children[0].type === TableHeader;
100
+ }
101
+ return children.every(node => node.type === TableHeader);
102
+ };
103
+ export const tableCanBeSticky = (node, children) => {
104
+ return isHeaderRowEnabled(children) && node && node.firstChild && !hasRowspan(node.firstChild);
105
+ };
106
+ // Ignored via go/ees005
107
+ // eslint-disable-next-line @repo/internal/react/no-class-components
108
+ export class TableContainer extends React.Component {
109
+ constructor(...args) {
110
+ super(...args);
111
+ _defineProperty(this, "state", {
112
+ stickyMode: 'none',
113
+ wrapperWidth: 0,
114
+ headerRowHeight: 0
115
+ });
116
+ _defineProperty(this, "tableRef", /*#__PURE__*/React.createRef());
117
+ _defineProperty(this, "stickyHeaderRef", /*#__PURE__*/React.createRef());
118
+ _defineProperty(this, "stickyScrollbarRef", /*#__PURE__*/React.createRef());
119
+ // used for sync scroll + copying wrapper width to sticky header
120
+ _defineProperty(this, "stickyWrapperRef", /*#__PURE__*/React.createRef());
121
+ _defineProperty(this, "wrapperRef", /*#__PURE__*/React.createRef());
122
+ _defineProperty(this, "overflowParent", null);
123
+ _defineProperty(this, "updatedLayout", 'custom');
124
+ _defineProperty(this, "resizeObserver", null);
125
+ _defineProperty(this, "applyResizerChange", entries => {
126
+ let wrapperWidth = this.state.wrapperWidth;
127
+ let headerRowHeight = this.state.headerRowHeight;
128
+ for (const entry of entries) {
129
+ if (entry.target === this.wrapperRef.current) {
130
+ wrapperWidth = entry.contentRect.width;
131
+ } else if (entry.target === this.stickyHeaderRef.current) {
132
+ headerRowHeight = Math.round(entry.contentRect.height);
133
+ }
134
+ }
135
+ if (headerRowHeight !== this.state.headerRowHeight || wrapperWidth !== this.state.wrapperWidth) {
136
+ this.setState({
137
+ wrapperWidth,
138
+ headerRowHeight
139
+ });
140
+ }
141
+ });
142
+ _defineProperty(this, "componentWillUnmount", () => {
143
+ if (this.overflowParent) {
144
+ // Ignored via go/ees005
145
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
146
+ this.overflowParent.removeEventListener('scroll', this.onScroll);
147
+ }
148
+ if (this.nextFrame) {
149
+ cancelAnimationFrame(this.nextFrame);
150
+ }
151
+ if (this.resizeObserver) {
152
+ this.resizeObserver.disconnect();
153
+ }
154
+ if (this.stickyScrollbar) {
155
+ this.stickyScrollbar.dispose();
156
+ }
157
+ });
158
+ _defineProperty(this, "getScrollTop", () => {
159
+ const {
160
+ stickyHeaders
161
+ } = this.props;
162
+ const offsetTop = stickyHeaders && stickyHeaders.offsetTop || 0;
163
+ return (this.overflowParent ? this.overflowParent.top : 0) + offsetTop;
164
+ });
165
+ _defineProperty(this, "updateSticky", () => {
166
+ const tableElem = this.tableRef.current;
167
+ const refElem = this.stickyHeaderRef.current;
168
+ if (!tableElem || !refElem) {
169
+ return;
170
+ }
171
+ const scrollTop = this.getScrollTop() + tableStickyPadding;
172
+ const tableTop = getRefTop(tableElem);
173
+ const tableBottom = tableTop + tableElem.clientHeight;
174
+ const shouldSticky = shouldHeaderStick(scrollTop, tableTop, tableBottom, refElem.clientHeight);
175
+ const shouldPin = shouldHeaderPinBottom(scrollTop, tableBottom, refElem.clientHeight);
176
+ let stickyMode = 'none';
177
+ if (shouldPin) {
178
+ stickyMode = 'pin-bottom';
179
+ } else if (shouldSticky) {
180
+ stickyMode = 'stick';
181
+ }
182
+ if (this.state.stickyMode !== stickyMode) {
183
+ this.setState({
184
+ stickyMode
185
+ });
186
+ }
187
+ this.nextFrame = undefined;
188
+ });
189
+ _defineProperty(this, "onScroll", () => {
190
+ if (!this.nextFrame) {
191
+ this.nextFrame = requestAnimationFrame(this.updateSticky);
192
+ }
193
+ });
194
+ _defineProperty(this, "onWrapperScrolled", () => {
195
+ if (!this.wrapperRef.current || !this.stickyWrapperRef.current) {
196
+ return;
197
+ }
198
+ this.stickyWrapperRef.current.scrollLeft = this.wrapperRef.current.scrollLeft;
199
+ if (this.stickyScrollbarRef.current) {
200
+ this.stickyScrollbarRef.current.scrollLeft = this.wrapperRef.current.scrollLeft;
201
+ }
202
+ });
203
+ _defineProperty(this, "grabFirstRowRef", children => {
204
+ // Ignored via go/ees005
205
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
206
+ return React.Children.map(children || false, (child, idx) => {
207
+ if (idx === 0 && /*#__PURE__*/React.isValidElement(child)) {
208
+ return /*#__PURE__*/React.cloneElement(child, {
209
+ innerRef: this.stickyHeaderRef
210
+ });
211
+ }
212
+ return child;
213
+ });
214
+ });
215
+ }
216
+ componentDidMount() {
217
+ this.resizeObserver = new ResizeObserver(this.applyResizerChange);
218
+ if (this.wrapperRef.current) {
219
+ this.resizeObserver.observe(this.wrapperRef.current);
220
+ }
221
+ if (this.stickyHeaderRef.current) {
222
+ this.resizeObserver.observe(this.stickyHeaderRef.current);
223
+ }
224
+ if (this.props.stickyHeaders) {
225
+ var _this$props$stickyHea;
226
+ 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);
227
+ // Ignored via go/ees005
228
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
229
+ this.overflowParent.addEventListener('scroll', this.onScroll);
230
+ }
231
+ if (this.wrapperRef.current && isStickyScrollbarEnabled(this.props.rendererAppearance)) {
232
+ this.stickyScrollbar = new TableStickyScrollbar(this.wrapperRef.current);
233
+ }
234
+ }
235
+ componentDidUpdate(prevProps, prevState) {
236
+ // toggling sticky headers visiblity
237
+ if (this.props.stickyHeaders && !this.overflowParent) {
238
+ var _this$props$stickyHea2;
239
+ 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);
240
+ } else if (!this.props.stickyHeaders && this.overflowParent) {
241
+ // Ignored via go/ees005
242
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
243
+ this.overflowParent.removeEventListener('scroll', this.onScroll);
244
+ this.overflowParent = null;
245
+ }
246
+
247
+ // offsetTop might have changed, re-position sticky header
248
+ if (this.props.stickyHeaders !== prevProps.stickyHeaders) {
249
+ this.updateSticky();
250
+ }
251
+
252
+ // sync horizontal scroll in floating div when toggling modes
253
+ if (prevState.stickyMode !== this.state.stickyMode) {
254
+ this.onWrapperScrolled();
255
+ }
256
+ }
257
+ get pinTop() {
258
+ if (!this.tableRef.current || !this.stickyHeaderRef.current) {
259
+ return;
260
+ }
261
+ return this.tableRef.current.offsetHeight - this.stickyHeaderRef.current.offsetHeight + tableMarginTop - tableStickyPadding;
262
+ }
263
+ get shouldAddOverflowParentOffsetTop_DO_NOT_USE() {
264
+ // IF the StickyHeaderConfig specifies that the default scroll root offsetTop should be added
265
+ // AND the StickyHeaderConfig specifies a default scroll root id
266
+ // AND the OverflowParent is the corresponding element
267
+ // THEN we should add the OverflowParent offset top (RETURN TRUE)
268
+ 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;
269
+ }
270
+ get stickyTop() {
271
+ switch (this.state.stickyMode) {
272
+ case 'pin-bottom':
273
+ return this.pinTop;
274
+ case 'stick':
275
+ const offsetTop = this.props.stickyHeaders && this.props.stickyHeaders.offsetTop;
276
+ if (typeof offsetTop === 'number' && this.shouldAddOverflowParentOffsetTop_DO_NOT_USE) {
277
+ const overflowParentOffsetTop = this.overflowParent ? this.overflowParent.top : 0;
278
+ return offsetTop + overflowParentOffsetTop;
279
+ } else {
280
+ return offsetTop;
281
+ }
282
+ default:
283
+ return undefined;
284
+ }
285
+ }
286
+ render() {
287
+ var _this$tableRef$curren;
288
+ const {
289
+ isNumberColumnEnabled,
290
+ layout,
291
+ renderWidth,
292
+ columnWidths,
293
+ stickyHeaders,
294
+ tableNode,
295
+ rendererAppearance,
296
+ isInsideOfBlockNode,
297
+ isInsideOfTable,
298
+ isinsideMultiBodiedExtension,
299
+ allowTableResizing,
300
+ isPresentational
301
+ } = this.props;
302
+ const {
303
+ stickyMode
304
+ } = this.state;
305
+ const tableWidthAttribute = tableNode !== null && tableNode !== void 0 && tableNode.attrs.width ? `${tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.width}px` : `100%`;
306
+ const children = React.Children.toArray(this.props.children);
307
+ let tableMinWidth;
308
+ if (tableNode) {
309
+ tableMinWidth = getResizerMinWidth(tableNode);
310
+ }
311
+
312
+ // Historically, tables in the full-width renderer had their layout set to 'default' which is deceiving.
313
+ // This check caters for those tables and helps with SSR logic
314
+ const isFullWidth = !(tableNode !== null && tableNode !== void 0 && tableNode.attrs.width) && rendererAppearance === 'full-width' && layout !== 'full-width';
315
+ if (isFullWidth) {
316
+ this.updatedLayout = 'full-width';
317
+ // if table has width explicity set, ensure SSR is handled
318
+ } else if (tableNode !== null && tableNode !== void 0 && tableNode.attrs.width) {
319
+ this.updatedLayout = 'custom';
320
+ } else {
321
+ this.updatedLayout = layout;
322
+ }
323
+ return /*#__PURE__*/React.createElement("div", {
324
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
325
+ className: "table-alignment-container"
326
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
327
+ ,
328
+ style: {
329
+ display: 'flex',
330
+ justifyContent: 'center'
331
+ }
332
+ }, /*#__PURE__*/React.createElement("div", {
333
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
334
+ className: "pm-table-resizer-container"
335
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
336
+ ,
337
+ style: {
338
+ width: `min(calc(100cqw - ${gutterPadding}px) ${tableWidthAttribute}`
339
+ }
340
+ }, /*#__PURE__*/React.createElement("div", {
341
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
342
+ className: "resizer-item display-handle",
343
+ style: {
344
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
345
+ position: 'relative',
346
+ userSelect: 'auto',
347
+ boxSizing: 'border-box',
348
+ ['--ak-editor-table-gutter-padding']: `${gutterPadding}px`,
349
+ ['--ak-editor-table-max-width']: `1800px`,
350
+ ['--ak-editor-table-min-width']: `${tableMinWidth}px`,
351
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
352
+ minWidth: 'var(--ak-editor-table-min-width)',
353
+ maxWidth: `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))`,
354
+ width: `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ${tableWidthAttribute})`
355
+ }
356
+ }, /*#__PURE__*/React.createElement("span", {
357
+ className: "resizer-hover-zone"
358
+ }, /*#__PURE__*/React.createElement("div", {
359
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
360
+ className: `${TableSharedCssClassName.TABLE_CONTAINER} ${this.props.shadowClassNames || ''}`,
361
+ "data-number-column": tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.isNumberColumnEnabled,
362
+ "data-layout": this.updatedLayout,
363
+ "data-testid": "table-container",
364
+ ref: this.props.handleRef
365
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
366
+ }, isStickyScrollbarEnabled(this.props.rendererAppearance) && /*#__PURE__*/React.createElement("div", {
367
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
368
+ className: TableSharedCssClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_TOP,
369
+ "data-testid": "sticky-scrollbar-sentinel-top"
370
+ }), stickyHeaders && tableNode && tableCanBeSticky(tableNode, children) && /*#__PURE__*/React.createElement(StickyTable, {
371
+ isNumberColumnEnabled: isNumberColumnEnabled,
372
+ renderWidth: renderWidth,
373
+ tableWidth: "inherit",
374
+ layout: layout,
375
+ handleRef: this.props.handleRef,
376
+ shadowClassNames: this.props.shadowClassNames,
377
+ top: this.stickyTop,
378
+ mode: stickyMode,
379
+ innerRef: this.stickyWrapperRef,
380
+ wrapperWidth: this.state.wrapperWidth,
381
+ columnWidths: columnWidths,
382
+ rowHeight: this.state.headerRowHeight,
383
+ tableNode: tableNode,
384
+ rendererAppearance: rendererAppearance,
385
+ allowTableResizing: allowTableResizing
386
+ }, [children && children[0]]), /*#__PURE__*/React.createElement("div", {
387
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
388
+ className: TableSharedCssClassName.TABLE_NODE_WRAPPER,
389
+ ref: this.wrapperRef,
390
+ "data-number-column": tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.isNumberColumnEnabled,
391
+ "data-layout": tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.layout,
392
+ "data-autosize": tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.__autoSize,
393
+ "data-table-local-id": tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.localId,
394
+ "data-table-width": tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.width,
395
+ "data-vc": "table-node-wrapper",
396
+ onScroll: this.props.stickyHeaders && this.onWrapperScrolled
397
+ }, /*#__PURE__*/React.createElement(Table, {
398
+ innerRef: this.tableRef,
399
+ columnWidths: columnWidths,
400
+ layout: layout,
401
+ isNumberColumnEnabled: isNumberColumnEnabled,
402
+ renderWidth: renderWidth,
403
+ tableNode: tableNode,
404
+ rendererAppearance: rendererAppearance,
405
+ isInsideOfBlockNode: isInsideOfBlockNode,
406
+ isInsideOfTable: isInsideOfTable,
407
+ isinsideMultiBodiedExtension: isinsideMultiBodiedExtension,
408
+ allowTableResizing: allowTableResizing,
409
+ isPresentational: isPresentational
410
+ }, this.grabFirstRowRef(children))), isStickyScrollbarEnabled(this.props.rendererAppearance) && /*#__PURE__*/React.createElement("div", {
411
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
412
+ className: TableSharedCssClassName.TABLE_STICKY_SCROLLBAR_CONTAINER,
413
+ ref: this.stickyScrollbarRef,
414
+ "data-vc": "table-sticky-scrollbar-container",
415
+ style: {
416
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
417
+ height: "var(--ds-space-250, 20px)",
418
+ // MAX_BROWSER_SCROLLBAR_HEIGHT
419
+ // Follow editor to hide by default so it does not show empty gap in SSR
420
+ // https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/browse/platform/packages/editor/editor-plugin-table/src/nodeviews/TableComponent.tsx#957
421
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
422
+ display: 'block',
423
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
424
+ width: '100%'
425
+ }
426
+ }, /*#__PURE__*/React.createElement("div", {
427
+ style: {
428
+ width: (_this$tableRef$curren = this.tableRef.current) === null || _this$tableRef$curren === void 0 ? void 0 : _this$tableRef$curren.clientWidth,
429
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
430
+ height: '100%'
431
+ }
432
+ })), isStickyScrollbarEnabled(this.props.rendererAppearance) && /*#__PURE__*/React.createElement("div", {
433
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
434
+ className: TableSharedCssClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_BOTTOM,
435
+ "data-testid": "sticky-scrollbar-sentinel-bottom"
436
+ }))))));
437
+ }
438
+ }
439
+ // Ignored via go/ees005
440
+ // eslint-disable-next-line @repo/internal/react/no-class-components
441
+ export class TableProcessorWithContainerStyles extends React.Component {
442
+ constructor(...args) {
443
+ super(...args);
444
+ _defineProperty(this, "state", {
445
+ tableOrderStatus: undefined
446
+ });
447
+ // adds sortable + re-orders children
448
+ _defineProperty(this, "addSortableColumn", childrenArray => {
449
+ const {
450
+ tableNode,
451
+ allowColumnSorting,
452
+ smartCardStorage
453
+ } = this.props;
454
+ const {
455
+ tableOrderStatus
456
+ } = this.state;
457
+ if (allowColumnSorting && isHeaderRowEnabled(childrenArray) && tableNode && !hasMergedCell(tableNode)) {
458
+ return addSortableColumn(orderChildren(childrenArray, tableNode, smartCardStorage, tableOrderStatus), tableOrderStatus, this.changeSortOrder);
459
+ }
460
+ return childrenArray;
461
+ });
462
+ _defineProperty(this, "changeSortOrder", (columnIndex, sortOrder) => {
463
+ this.setState({
464
+ tableOrderStatus: {
465
+ columnIndex,
466
+ order: sortOrder
467
+ }
468
+ });
469
+ });
470
+ // Ignored via go/ees005
471
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
472
+ _defineProperty(this, "addNumberColumnIndexes", rows => {
473
+ const {
474
+ isNumberColumnEnabled
475
+ } = this.props;
476
+ const headerRowEnabled = isHeaderRowEnabled(rows);
477
+ return React.Children.map(rows, (row, index) => {
478
+ return /*#__PURE__*/React.cloneElement(React.Children.only(row), {
479
+ isNumberColumnEnabled,
480
+ index: headerRowEnabled ? index === 0 ? '' : index : index + 1
481
+ });
482
+ });
483
+ });
484
+ }
485
+ render() {
486
+ const {
487
+ children
488
+ } = this.props;
489
+ if (!children) {
490
+ return null;
491
+ }
492
+ const childrenArray = React.Children.toArray(children);
493
+ const orderedChildren = compose(this.addNumberColumnIndexes, this.addSortableColumn
494
+ // @ts-expect-error TS2345: Argument of type '(ReactChild | ReactFragment | ReactPortal)[]' is not assignable to parameter of type 'ReactElement<any, string | JSXElementConstructor<any>>[]'
495
+ )(childrenArray);
496
+
497
+ // Ignored via go/ees005
498
+ // eslint-disable-next-line react/jsx-props-no-spreading
499
+ return /*#__PURE__*/React.createElement(TableContainer, this.props, orderedChildren);
500
+ }
501
+ }
@@ -1,18 +1,20 @@
1
- import React, { useContext, useEffect, useMemo, useState } from 'react';
1
+ import React, { useContext, useEffect, useLayoutEffect, useMemo, useState } from 'react';
2
2
  import { MediaClientContext, getMediaClient } from '@atlaskit/media-client-react';
3
- import { useProvider } from '@atlaskit/editor-common/provider-factory';
3
+ import { useProviderLayout, useProvider } from '@atlaskit/editor-common/provider-factory';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
4
5
  export const EditorMediaClientProvider = ({
5
6
  children,
6
7
  ssr
7
8
  }) => {
8
9
  const [mediaClientConfig, setMediaClientConfig] = useState();
9
- const mediaProvider = useProvider('mediaProvider');
10
+ const oldMediaProvider = useProvider('mediaProvider');
11
+ const mediaProvider = useProviderLayout('mediaProvider');
10
12
 
11
13
  /**
12
14
  * If a mediaClientConfig is provided then we will force
13
15
  * skip the mediaClient from context
14
16
  */
15
- const shouldSkipContext = Boolean((ssr === null || ssr === void 0 ? void 0 : ssr.config) || mediaProvider);
17
+ const shouldSkipContext = Boolean((ssr === null || ssr === void 0 ? void 0 : ssr.config) || oldMediaProvider || mediaProvider);
16
18
  const contextMediaClient = useContext(MediaClientContext);
17
19
 
18
20
  // MediaClientProvider currently requires a mediaClientConfig
@@ -25,12 +27,25 @@ export const EditorMediaClientProvider = ({
25
27
  // and provide a top level mediaClient context
26
28
  // This is useful for testing and creating examples.
27
29
  useEffect(() => {
28
- if (ssr !== null && ssr !== void 0 && ssr.config) {
29
- setMediaClientConfig(ssr.config);
30
- } else if (mediaProvider) {
31
- mediaProvider.then(provider => {
32
- setMediaClientConfig(provider.viewMediaClientConfig);
33
- });
30
+ if (!fg('platform_editor_speedup_media_client')) {
31
+ if (ssr !== null && ssr !== void 0 && ssr.config) {
32
+ setMediaClientConfig(ssr.config);
33
+ } else if (oldMediaProvider) {
34
+ oldMediaProvider.then(provider => {
35
+ setMediaClientConfig(provider.viewMediaClientConfig);
36
+ });
37
+ }
38
+ }
39
+ }, [oldMediaProvider, ssr]);
40
+ useLayoutEffect(() => {
41
+ if (fg('platform_editor_speedup_media_client')) {
42
+ if (ssr !== null && ssr !== void 0 && ssr.config) {
43
+ setMediaClientConfig(ssr.config);
44
+ } else if (mediaProvider) {
45
+ mediaProvider.then(provider => {
46
+ setMediaClientConfig(provider.viewMediaClientConfig);
47
+ });
48
+ }
34
49
  }
35
50
  }, [mediaProvider, ssr]);
36
51
  return /*#__PURE__*/React.createElement(MediaClientContext.Provider, {
@@ -5,7 +5,6 @@ import { FullPagePadding } from './style';
5
5
  /**
6
6
  * Inline Script that updates breakout node width on client side,
7
7
  * before main JavaScript bundle is ready.
8
- *
9
8
  * More info: https://product-fabric.atlassian.net/wiki/spaces/E/pages/1216218119/Renderer+SSR+for+Breakout+Nodes
10
9
  */
11
10
  export function BreakoutSSRInlineScript({
@@ -26,26 +25,25 @@ export function BreakoutSSRInlineScript({
26
25
  }
27
26
  }
28
27
  const id = Math.floor(Math.random() * (9999999999 - 9999 + 1)) + 9999;
29
- const context = createBreakoutInlineScript(id);
30
28
  return /*#__PURE__*/React.createElement("script", {
31
29
  "data-breakout-script-id": id
32
30
  // To investigate if we can replace this.
33
31
  // eslint-disable-next-line react/no-danger
34
32
  ,
35
33
  dangerouslySetInnerHTML: {
36
- __html: context
34
+ __html: fg('platform-ssr-table-resize') ? createBreakoutInlineScript(id, true) : createBreakoutInlineScript(id)
37
35
  },
38
36
  "data-testid": "breakout-ssr-inline-script"
39
37
  });
40
38
  }
41
- export function createBreakoutInlineScript(id) {
39
+ export function createBreakoutInlineScript(id, optionalFlagArg) {
42
40
  return `
43
41
  (function(window){
44
42
  if(typeof window !== 'undefined' && window.__RENDERER_BYPASS_BREAKOUT_SSR__) {
45
43
  return;
46
44
  }
47
45
  ${breakoutInlineScriptContext};
48
- (${applyBreakoutAfterSSR.toString()})("${id}", breakoutConsts, ${Boolean(fg('platform-fix-table-ssr-resizing'))});
46
+ (${applyBreakoutAfterSSR.toString()})("${id}", breakoutConsts, ${optionalFlagArg !== null && optionalFlagArg !== void 0 ? optionalFlagArg : false});
49
47
  })(window);
50
48
  `;
51
49
  }
@@ -62,7 +60,7 @@ export const breakoutInlineScriptContext = `
62
60
 
63
61
  // Ignored via go/ees005
64
62
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
- function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
63
+ function applyBreakoutAfterSSR(id, breakoutConsts, isFeatureFlagEnabled) {
66
64
  const MEDIA_NODE_TYPE = 'mediaSingle';
67
65
  const WIDE_LAYOUT_MODES = ['full-width', 'wide', 'custom'];
68
66
  function findUp(element, condition) {
@@ -76,7 +74,7 @@ function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
76
74
  element = element.parentElement;
77
75
  }
78
76
  }
79
- const renderer = findUp(document.querySelector('[data-breakout-script-id="' + id + '"]'), elem => {
77
+ const renderer = findUp(document.querySelector(`[data-breakout-script-id="${id}"]`), elem => {
80
78
  var _elem$parentElement;
81
79
  return !!((_elem$parentElement = elem.parentElement) !== null && _elem$parentElement !== void 0 && _elem$parentElement.classList.contains('ak-renderer-wrapper'));
82
80
  });
@@ -88,7 +86,23 @@ function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
88
86
  if (item.target.nodeType !== Node.ELEMENT_NODE) {
89
87
  return;
90
88
  }
89
+ if (
90
+ /**
91
+ * The mutation observer is only called once per added node.
92
+ * The above condition only deals with direct children of <div class="ak-renderer-document" />
93
+ * When it is initially called on the direct children, not all the sub children have loaded.
94
+ * So nested media elements which are not immediately loaded as sub children are not available in the above conditional.
95
+ * Thus adding this conditional to deal with all media elements directly.
96
+ */
97
+ // Ignored via go/ees005
98
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
99
+ item.target.dataset.nodeType === MEDIA_NODE_TYPE) {
100
+ // Ignored via go/ees005
101
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
102
+ applyMediaBreakout(item.target);
103
+ }
91
104
 
105
+ // Remove with feature gate 'platform-ssr-table-resize'
92
106
  // Ignored via go/ees005
93
107
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
94
108
  if (item.target.classList.contains('ak-renderer-document')) {
@@ -108,7 +122,7 @@ function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
108
122
  }
109
123
 
110
124
  // When flag is on we are using CSS to calculate the table width thus don't need logic below to set the width and left.
111
- if (!shouldFixTableResizing) {
125
+ if (!isFeatureFlagEnabled) {
112
126
  if (node.classList.contains('pm-table-container') && mode === 'custom') {
113
127
  // Ignored via go/ees005
114
128
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -147,20 +161,6 @@ function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
147
161
  }
148
162
  }
149
163
  });
150
- } else if (
151
- /**
152
- * The mutation observer is only called once per added node.
153
- * The above condition only deals with direct children of <div class="ak-renderer-document" />
154
- * When it is initially called on the direct children, not all the sub children have loaded.
155
- * So nested media elements which are not immediately loaded as sub children are not available in the above conditional.
156
- * Thus adding this conditional to deal with all media elements directly.
157
- */
158
- // Ignored via go/ees005
159
- // eslint-disable-next-line @atlaskit/editor/no-as-casting
160
- item.target.dataset.nodeType === MEDIA_NODE_TYPE) {
161
- // Ignored via go/ees005
162
- // eslint-disable-next-line @atlaskit/editor/no-as-casting
163
- applyMediaBreakout(item.target);
164
164
  }
165
165
  });
166
166
  });
@@ -46,7 +46,7 @@ import { removeEmptySpaceAroundContent } from './rendererHelper';
46
46
  export const NORMAL_SEVERITY_THRESHOLD = 2000;
47
47
  export const DEGRADED_SEVERITY_THRESHOLD = 3000;
48
48
  const packageName = "@atlaskit/renderer";
49
- const packageVersion = "114.11.2";
49
+ const packageVersion = "114.12.1";
50
50
  const setAsQueryContainerStyles = css({
51
51
  containerName: 'ak-renderer-wrapper',
52
52
  containerType: 'inline-size',