@atlaskit/renderer 111.1.1 → 111.1.2
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 +9 -0
- package/dist/cjs/react/nodes/table.js +50 -16
- package/dist/cjs/ui/Renderer/breakout-ssr.js +24 -41
- package/dist/cjs/ui/Renderer/index.js +23 -7
- package/dist/es2019/react/nodes/table.js +47 -17
- package/dist/es2019/ui/Renderer/breakout-ssr.js +25 -41
- package/dist/es2019/ui/Renderer/index.js +19 -3
- package/dist/esm/react/nodes/table.js +50 -16
- package/dist/esm/ui/Renderer/breakout-ssr.js +25 -41
- package/dist/esm/ui/Renderer/index.js +24 -8
- package/dist/types/ui/Renderer/breakout-ssr.d.ts +0 -5
- package/dist/types-ts4.5/ui/Renderer/breakout-ssr.d.ts +0 -5
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 111.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#147736](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/147736)
|
|
8
|
+
[`b6868597a50cd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b6868597a50cd) -
|
|
9
|
+
[ux] Fix table resizing when rendering with AK renderer in SSR
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 111.1.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.isTableResizingEnabled = exports.isStickyScrollbarEnabled = exports.default = exports.TableProcessor = exports.TableContainer = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
12
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
@@ -16,6 +17,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
16
17
|
var _react = _interopRequireDefault(require("react"));
|
|
17
18
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
18
19
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
20
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
19
21
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
20
22
|
var _types = require("@atlaskit/editor-common/types");
|
|
21
23
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
@@ -327,32 +329,43 @@ var TableContainer = exports.TableContainer = /*#__PURE__*/function (_React$Comp
|
|
|
327
329
|
// Please consider changes below carefully to not negatively impact SSR
|
|
328
330
|
// `renderWidth` cannot be depended on during SSR
|
|
329
331
|
var isRenderWidthValid = !!renderWidth && renderWidth > 0;
|
|
332
|
+
var renderWidthCSS = rendererAppearance === 'full-page' ? "100cqw - ".concat(_style.FullPagePadding, "px * 2") : "100cqw";
|
|
330
333
|
var calcDefaultLayoutWidthByAppearance = function calcDefaultLayoutWidthByAppearance(rendererAppearance, tableNode) {
|
|
331
334
|
if (rendererAppearance === 'full-width' && !(tableNode !== null && tableNode !== void 0 && tableNode.attrs.width)) {
|
|
332
|
-
return isRenderWidthValid ? Math.min(_editorSharedStyles.akEditorFullWidthLayoutWidth, renderWidth) : _editorSharedStyles.akEditorFullWidthLayoutWidth;
|
|
335
|
+
return [isRenderWidthValid ? Math.min(_editorSharedStyles.akEditorFullWidthLayoutWidth, renderWidth) : _editorSharedStyles.akEditorFullWidthLayoutWidth, "min(".concat(_editorSharedStyles.akEditorFullWidthLayoutWidth, "px, ").concat(renderWidthCSS, ")")];
|
|
333
336
|
} else if (rendererAppearance === 'comment' && allowTableResizing && !(tableNode !== null && tableNode !== void 0 && tableNode.attrs.width)) {
|
|
334
337
|
var tableContainerWidth = (0, _nodeWidth.getTableContainerWidth)(tableNode);
|
|
335
|
-
return isRenderWidthValid ? renderWidth : tableContainerWidth;
|
|
338
|
+
return [isRenderWidthValid ? renderWidth : tableContainerWidth, renderWidthCSS];
|
|
336
339
|
} else {
|
|
337
340
|
// custom width, or width mapped to breakpoint
|
|
338
341
|
var _tableContainerWidth = (0, _nodeWidth.getTableContainerWidth)(tableNode);
|
|
339
|
-
return isRenderWidthValid ? Math.min(_tableContainerWidth, renderWidth) : _tableContainerWidth;
|
|
342
|
+
return [isRenderWidthValid ? Math.min(_tableContainerWidth, renderWidth) : _tableContainerWidth, "min(".concat(_tableContainerWidth, "px, ").concat(renderWidthCSS, ")")];
|
|
340
343
|
}
|
|
341
344
|
};
|
|
342
|
-
var
|
|
345
|
+
var _calcDefaultLayoutWid = calcDefaultLayoutWidthByAppearance(rendererAppearance, tableNode),
|
|
346
|
+
_calcDefaultLayoutWid2 = (0, _slicedToArray2.default)(_calcDefaultLayoutWid, 2),
|
|
347
|
+
tableWidth = _calcDefaultLayoutWid2[0],
|
|
348
|
+
tableWidthCSS = _calcDefaultLayoutWid2[1];
|
|
343
349
|
|
|
344
350
|
// Logic for table alignment in renderer
|
|
345
351
|
var isTableAlignStart = tableNode && tableNode.attrs && tableNode.attrs.layout === 'align-start' && allowTableAlignment;
|
|
346
352
|
var fullWidthLineLength = isRenderWidthValid ? Math.min(_editorSharedStyles.akEditorFullWidthLayoutWidth, renderWidth) : _editorSharedStyles.akEditorFullWidthLayoutWidth;
|
|
353
|
+
var fullWidthLineLengthCSS = "min(".concat(_editorSharedStyles.akEditorFullWidthLayoutWidth, "px, ").concat(renderWidthCSS, ")");
|
|
347
354
|
var commentLineLength = isRenderWidthValid ? renderWidth : lineLengthFixedWidth;
|
|
348
355
|
var isCommentAppearanceAndTableAlignmentEnabled = (0, _appearance.isCommentAppearance)(rendererAppearance) && allowTableAlignment;
|
|
349
356
|
var lineLength = (0, _appearance.isFullWidthAppearance)(rendererAppearance) ? fullWidthLineLength : isCommentAppearanceAndTableAlignmentEnabled ? commentLineLength : lineLengthFixedWidth;
|
|
350
|
-
var
|
|
357
|
+
var lineLengthCSS = (0, _appearance.isFullWidthAppearance)(rendererAppearance) ? fullWidthLineLengthCSS : isCommentAppearanceAndTableAlignmentEnabled ? renderWidthCSS : "".concat(lineLengthFixedWidth, "px");
|
|
358
|
+
var fixTableSSRResizing = (0, _platformFeatureFlags.fg)('platform-fix-table-ssr-resizing');
|
|
359
|
+
var tableWidthNew = fixTableSSRResizing ? (0, _nodeWidth.getTableContainerWidth)(tableNode) : tableWidth;
|
|
360
|
+
var shouldCalculateLeftForAlignment = !isInsideOfBlockNode && isTableAlignStart && ((0, _appearance.isFullPageAppearance)(rendererAppearance) && tableWidthNew <= lineLengthFixedWidth || (0, _appearance.isFullWidthAppearance)(rendererAppearance) || isCommentAppearanceAndTableAlignmentEnabled);
|
|
361
|
+
var leftCSS;
|
|
351
362
|
if (shouldCalculateLeftForAlignment) {
|
|
352
363
|
left = (tableWidth - lineLength) / 2;
|
|
364
|
+
leftCSS = "(".concat(tableWidthCSS, " - ").concat(lineLengthCSS, ") / 2");
|
|
353
365
|
}
|
|
354
|
-
if (!shouldCalculateLeftForAlignment && canUseLinelength(rendererAppearance) &&
|
|
366
|
+
if (!shouldCalculateLeftForAlignment && canUseLinelength(rendererAppearance) && tableWidthNew > lineLengthFixedWidth) {
|
|
355
367
|
left = lineLengthFixedWidth / 2 - tableWidth / 2;
|
|
368
|
+
leftCSS = "".concat(lineLengthCSS, " / 2 - ").concat(tableWidthCSS, " / 2");
|
|
356
369
|
}
|
|
357
370
|
var children = _react.default.Children.toArray(this.props.children);
|
|
358
371
|
|
|
@@ -367,7 +380,14 @@ var TableContainer = exports.TableContainer = /*#__PURE__*/function (_React$Comp
|
|
|
367
380
|
} else {
|
|
368
381
|
updatedLayout = layout;
|
|
369
382
|
}
|
|
370
|
-
var finalTableContainerWidth = allowTableResizing ?
|
|
383
|
+
var finalTableContainerWidth = allowTableResizing ? tableWidthNew : 'inherit';
|
|
384
|
+
|
|
385
|
+
// We can only use CSS to determine the width when we have a known width in container.
|
|
386
|
+
// When appearance is full-page, full-width or comment we use CSS based width calculation.
|
|
387
|
+
// Otherwise it's fixed table width (customized width) or inherit.
|
|
388
|
+
if ((rendererAppearance === 'full-page' || rendererAppearance === 'full-width') && fixTableSSRResizing) {
|
|
389
|
+
finalTableContainerWidth = allowTableResizing ? "calc(".concat(tableWidthCSS, ")") : 'inherit';
|
|
390
|
+
}
|
|
371
391
|
if (rendererAppearance === 'comment' && allowTableResizing && !allowTableAlignment) {
|
|
372
392
|
// If table alignment is disabled and table width is akEditorDefaultLayoutWidth = 760,
|
|
373
393
|
// it is most likely a table created before "Support Table in Comments" FF was enabled
|
|
@@ -376,24 +396,36 @@ var TableContainer = exports.TableContainer = /*#__PURE__*/function (_React$Comp
|
|
|
376
396
|
|
|
377
397
|
// !NOTE: it a table resized to 760 is copied from 'full-page' editor and pasted in comment editor
|
|
378
398
|
// where (allowTableResizing && !allowTableAlignment), the table will loose 760px width.
|
|
379
|
-
finalTableContainerWidth = tableNode !== null && tableNode !== void 0 && tableNode.attrs.width && (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.width) !== _editorSharedStyles.akEditorDefaultLayoutWidth ? tableWidth : 'inherit';
|
|
399
|
+
finalTableContainerWidth = tableNode !== null && tableNode !== void 0 && tableNode.attrs.width && (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.width) !== _editorSharedStyles.akEditorDefaultLayoutWidth ? fixTableSSRResizing ? "calc(".concat(tableWidthCSS, ")") : tableWidth : 'inherit';
|
|
380
400
|
}
|
|
381
401
|
if (rendererAppearance === 'comment' && allowTableResizing && allowTableAlignment) {
|
|
382
402
|
// If table alignment is enabled and layout is not 'align-start' or 'center', we are loading a table that was
|
|
383
403
|
// created before "Support Table in Comments" FF was enabled. So the table should have the same width as renderer container
|
|
384
404
|
// instead of 760 that was set on tableNode when the table had been published.
|
|
385
|
-
finalTableContainerWidth = ((tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.layout) === 'align-start' || (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.layout) === 'center') && tableNode !== null && tableNode !== void 0 && tableNode.attrs.width ? tableWidth : 'inherit';
|
|
405
|
+
finalTableContainerWidth = ((tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.layout) === 'align-start' || (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.layout) === 'center') && tableNode !== null && tableNode !== void 0 && tableNode.attrs.width ? fixTableSSRResizing ? "calc(".concat(tableWidthCSS, ")") : tableWidth : 'inherit';
|
|
406
|
+
}
|
|
407
|
+
var style;
|
|
408
|
+
if (fixTableSSRResizing) {
|
|
409
|
+
style = {
|
|
410
|
+
width: finalTableContainerWidth,
|
|
411
|
+
left: leftCSS ? "calc(".concat(leftCSS, ")") : undefined,
|
|
412
|
+
marginLeft: shouldCalculateLeftForAlignment && leftCSS !== undefined ? "calc(-1 * (".concat(leftCSS, "))") : undefined
|
|
413
|
+
};
|
|
414
|
+
} else {
|
|
415
|
+
style = {
|
|
416
|
+
width: finalTableContainerWidth,
|
|
417
|
+
left: left,
|
|
418
|
+
marginLeft: shouldCalculateLeftForAlignment && left !== undefined ? -left : undefined
|
|
419
|
+
};
|
|
386
420
|
}
|
|
387
421
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
388
422
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
389
423
|
className: "".concat(_styles.TableSharedCssClassName.TABLE_CONTAINER, " ").concat(this.props.shadowClassNames || ''),
|
|
390
424
|
"data-layout": updatedLayout,
|
|
391
|
-
ref: this.props.handleRef
|
|
392
|
-
style
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
marginLeft: shouldCalculateLeftForAlignment && left !== undefined ? -left : undefined
|
|
396
|
-
}
|
|
425
|
+
ref: this.props.handleRef
|
|
426
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
427
|
+
,
|
|
428
|
+
style: style
|
|
397
429
|
}, isStickyScrollbarEnabled(this.props.rendererAppearance) && /*#__PURE__*/_react.default.createElement("div", {
|
|
398
430
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
399
431
|
className: _styles.TableSharedCssClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_TOP,
|
|
@@ -438,8 +470,10 @@ var TableContainer = exports.TableContainer = /*#__PURE__*/function (_React$Comp
|
|
|
438
470
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
439
471
|
height: "var(--ds-space-250, 20px)",
|
|
440
472
|
// MAX_BROWSER_SCROLLBAR_HEIGHT
|
|
473
|
+
// Follow editor to hide by default so it does not show empty gap in SSR
|
|
474
|
+
// https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/browse/platform/packages/editor/editor-plugin-table/src/nodeviews/TableComponent.tsx#957
|
|
441
475
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
442
|
-
display: 'block',
|
|
476
|
+
display: fixTableSSRResizing ? 'none' : 'block',
|
|
443
477
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
444
478
|
width: '100%'
|
|
445
479
|
}
|
|
@@ -38,8 +38,7 @@ function BreakoutSSRInlineScript() {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
function createBreakoutInlineScript(id) {
|
|
41
|
-
|
|
42
|
-
return "\n (function(window){\n ".concat(breakoutInlineScriptContext, ";\n (").concat(applyBreakoutAfterSSR.toString(), ")(\"").concat(id, "\", breakoutConsts, ").concat(shouldFixTableResizing, ");\n })(window);\n");
|
|
41
|
+
return "\n (function(window){\n ".concat(breakoutInlineScriptContext, ";\n (").concat(applyBreakoutAfterSSR.toString(), ")(\"").concat(id, "\", breakoutConsts, ").concat(Boolean((0, _platformFeatureFlags.fg)('platform-fix-table-ssr-resizing')), ");\n })(window);\n");
|
|
43
42
|
}
|
|
44
43
|
var breakoutInlineScriptContext = exports.breakoutInlineScriptContext = "\n var breakoutConsts = ".concat(JSON.stringify(_utils.breakoutConsts), ";\n breakoutConsts.mapBreakpointToLayoutMaxWidth = ").concat(_utils.breakoutConsts.mapBreakpointToLayoutMaxWidth.toString(), ";\n breakoutConsts.getBreakpoint = ").concat(_utils.breakoutConsts.getBreakpoint.toString(), ";\n breakoutConsts.calcBreakoutWidth = ").concat(_utils.breakoutConsts.calcBreakoutWidth.toString(), ";\n breakoutConsts.calcLineLength = ").concat(_utils.breakoutConsts.calcLineLength.toString(), ";\n breakoutConsts.calcWideWidth = ").concat(_utils.breakoutConsts.calcWideWidth.toString(), ";\n breakoutConsts.FullPagePadding = ").concat(_style.FullPagePadding.toString(), ";\n");
|
|
45
44
|
function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
|
|
@@ -80,35 +79,32 @@ function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
|
|
|
80
79
|
if (!mode || !WIDE_LAYOUT_MODES.includes(mode)) {
|
|
81
80
|
return;
|
|
82
81
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
|
|
83
|
+
// 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.
|
|
84
|
+
if (!shouldFixTableResizing) {
|
|
85
|
+
if (node.classList.contains('pm-table-container') && mode === 'custom') {
|
|
86
|
+
var rendererWidth = renderer.offsetWidth;
|
|
87
|
+
var effectiveWidth = rendererWidth - breakoutConsts.padding;
|
|
88
|
+
width = "".concat(Math.min(parseInt(node.style.width), effectiveWidth), "px");
|
|
90
89
|
} else {
|
|
91
|
-
|
|
90
|
+
width = breakoutConsts.calcBreakoutWidth(mode, renderer.offsetWidth);
|
|
92
91
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (node.style.width === width) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
node.style.width = width;
|
|
92
|
+
if (node.style.width === width) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
node.style.width = width;
|
|
101
96
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
97
|
+
// Tables require some special logic, as they are not using common css transform approach,
|
|
98
|
+
// because it breaks with sticky headers. This logic is copied from a table node:
|
|
99
|
+
// https://bitbucket.org/atlassian/atlassian-frontend/src/77938aee0c140d02ff99b98a03849be1236865b4/packages/editor/renderer/src/react/nodes/table.tsx#table.tsx-235:245
|
|
100
|
+
if (node.classList.contains('pm-table-container') && !renderer.classList.contains('is-full-width')) {
|
|
101
|
+
var lineLength = breakoutConsts.calcLineLength();
|
|
102
|
+
var left = lineLength / 2 - parseInt(width) / 2;
|
|
103
|
+
if (left < 0 && parseInt(width) > lineLength) {
|
|
104
|
+
node.style.left = left + 'px';
|
|
105
|
+
} else {
|
|
106
|
+
node.style.left = '';
|
|
107
|
+
}
|
|
112
108
|
}
|
|
113
109
|
}
|
|
114
110
|
});
|
|
@@ -124,16 +120,6 @@ function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
|
|
|
124
120
|
applyMediaBreakout(item.target);
|
|
125
121
|
}
|
|
126
122
|
});
|
|
127
|
-
|
|
128
|
-
// Renderer is initially set to hidden until we figure out the proper width in packages/editor/editor-common/src/ui/WidthProvider/index.tsx
|
|
129
|
-
if (renderer.style.visibility === 'hidden') {
|
|
130
|
-
// Hiding until we get the correct width. But didn't remove them from the DOM so vertical scrollbar can still be correctly calculated.
|
|
131
|
-
renderer.style.visibility = '';
|
|
132
|
-
// Since we don't have a screen width to use as initial value.
|
|
133
|
-
// The width is set to a fix number. This will cause horizontal scrollbar to appear.
|
|
134
|
-
// Hide it until we have the correct width.
|
|
135
|
-
renderer.style.overflowX = '';
|
|
136
|
-
}
|
|
137
123
|
});
|
|
138
124
|
var applyMediaBreakout = function applyMediaBreakout(card) {
|
|
139
125
|
// width was already set by another breakout script
|
|
@@ -164,9 +150,6 @@ function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
|
|
|
164
150
|
childList: true,
|
|
165
151
|
subtree: true
|
|
166
152
|
});
|
|
167
|
-
if (shouldFixTableResizing) {
|
|
168
|
-
window.__SSR_BREAKOUT_OBSERVED = true;
|
|
169
|
-
}
|
|
170
153
|
|
|
171
154
|
/**
|
|
172
155
|
* Using window load event to unsubscribe from mutation observer, as at this stage document is fully rendered.
|
|
@@ -65,7 +65,12 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
65
65
|
var NORMAL_SEVERITY_THRESHOLD = exports.NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
66
66
|
var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
67
67
|
var packageName = "@atlaskit/renderer";
|
|
68
|
-
var packageVersion = "111.1.
|
|
68
|
+
var packageVersion = "111.1.2";
|
|
69
|
+
var setAsQueryContainerStyles = (0, _react2.css)({
|
|
70
|
+
containerName: 'ak-renderer-wrapper',
|
|
71
|
+
containerType: 'inline-size',
|
|
72
|
+
contain: 'layout style inline-size'
|
|
73
|
+
});
|
|
69
74
|
var defaultNodeComponents = exports.defaultNodeComponents = _nodes.nodeToReact;
|
|
70
75
|
|
|
71
76
|
/**
|
|
@@ -499,26 +504,26 @@ var RendererWrapper = /*#__PURE__*/_react.default.memo(function (props) {
|
|
|
499
504
|
// We must check if window is defined, if it isn't we are in a SSR environment
|
|
500
505
|
// and we don't want to add the telepointer
|
|
501
506
|
if (typeof window !== 'undefined' && addTelepointer && innerRef !== null && innerRef !== void 0 && innerRef.current) {
|
|
502
|
-
var
|
|
507
|
+
var _renderer = innerRef.current.querySelector('.ak-renderer-document');
|
|
503
508
|
if (initialUpdate.current) {
|
|
504
|
-
var lastChild =
|
|
509
|
+
var lastChild = _renderer.lastChild;
|
|
505
510
|
lastChild && lastChild.appendChild(createTelepointer());
|
|
506
511
|
}
|
|
507
512
|
var mutateTelepointer = function mutateTelepointer(mutations) {
|
|
508
513
|
mutations.forEach(function (mutation) {
|
|
509
514
|
if (initialUpdate.current) {
|
|
510
|
-
var oldTelepointer =
|
|
515
|
+
var oldTelepointer = _renderer.querySelector("#".concat(_style.TELEPOINTER_ID));
|
|
511
516
|
if (oldTelepointer) {
|
|
512
517
|
oldTelepointer.remove();
|
|
513
518
|
}
|
|
514
|
-
var _lastChild =
|
|
519
|
+
var _lastChild = _renderer.lastChild;
|
|
515
520
|
_lastChild && _lastChild.appendChild(createTelepointer());
|
|
516
521
|
initialUpdate.current = false;
|
|
517
522
|
}
|
|
518
523
|
if (mutation.type === 'characterData') {
|
|
519
524
|
var parentNode = mutation.target.parentElement;
|
|
520
525
|
if (parentNode) {
|
|
521
|
-
var _oldTelepointer =
|
|
526
|
+
var _oldTelepointer = _renderer.querySelector("#".concat(_style.TELEPOINTER_ID));
|
|
522
527
|
if (_oldTelepointer) {
|
|
523
528
|
_oldTelepointer.remove();
|
|
524
529
|
}
|
|
@@ -539,7 +544,7 @@ var RendererWrapper = /*#__PURE__*/_react.default.memo(function (props) {
|
|
|
539
544
|
};
|
|
540
545
|
}
|
|
541
546
|
}, [innerRef, addTelepointer]);
|
|
542
|
-
|
|
547
|
+
var renderer = (0, _react2.jsx)(_ui.WidthProvider
|
|
543
548
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
544
549
|
, {
|
|
545
550
|
className: "ak-renderer-wrapper is-".concat(appearance),
|
|
@@ -564,6 +569,17 @@ var RendererWrapper = /*#__PURE__*/_react.default.memo(function (props) {
|
|
|
564
569
|
allowTableResizing: allowTableResizing
|
|
565
570
|
})
|
|
566
571
|
}, children))));
|
|
572
|
+
|
|
573
|
+
// We can only make the wrapper div query container when we have a known width.
|
|
574
|
+
// This is also required for SSR to work correctly. As WidthProvider/WithConsumer will not have the correct width during SSR.
|
|
575
|
+
//
|
|
576
|
+
// We are setting this wrapper div as query container conditionally.
|
|
577
|
+
// Only apply container-type = inline-size when having a known width in full-page/full-width/comment mode.
|
|
578
|
+
// Otherwise when appearance is unspecified the renderer size is decided by the content.
|
|
579
|
+
// In this case we can't set the container-type = inline-size as it will collapse width to 0.
|
|
580
|
+
return (appearance === 'full-page' || appearance === 'full-width' || appearance === 'comment') && (0, _platformFeatureFlags.fg)('platform-fix-table-ssr-resizing') ? (0, _react2.jsx)("div", {
|
|
581
|
+
css: setAsQueryContainerStyles
|
|
582
|
+
}, renderer) : renderer;
|
|
567
583
|
});
|
|
568
584
|
var RootRendererContext = /*#__PURE__*/_react.default.createContext(null);
|
|
569
585
|
function RendererActionsInternalUpdater(_ref) {
|
|
@@ -3,6 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { TableSharedCssClassName, tableMarginTop } from '@atlaskit/editor-common/styles';
|
|
5
5
|
import { WidthConsumer, overflowShadow } from '@atlaskit/editor-common/ui';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { createCompareNodes, convertProsemirrorTableNodeToArrayOfRows, hasMergedCell, compose } from '@atlaskit/editor-common/utils';
|
|
7
8
|
import { SortOrder } from '@atlaskit/editor-common/types';
|
|
8
9
|
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
@@ -272,32 +273,40 @@ export class TableContainer extends React.Component {
|
|
|
272
273
|
// Please consider changes below carefully to not negatively impact SSR
|
|
273
274
|
// `renderWidth` cannot be depended on during SSR
|
|
274
275
|
const isRenderWidthValid = !!renderWidth && renderWidth > 0;
|
|
276
|
+
const renderWidthCSS = rendererAppearance === 'full-page' ? `100cqw - ${FullPagePadding}px * 2` : `100cqw`;
|
|
275
277
|
const calcDefaultLayoutWidthByAppearance = (rendererAppearance, tableNode) => {
|
|
276
278
|
if (rendererAppearance === 'full-width' && !(tableNode !== null && tableNode !== void 0 && tableNode.attrs.width)) {
|
|
277
|
-
return isRenderWidthValid ? Math.min(akEditorFullWidthLayoutWidth, renderWidth) : akEditorFullWidthLayoutWidth;
|
|
279
|
+
return [isRenderWidthValid ? Math.min(akEditorFullWidthLayoutWidth, renderWidth) : akEditorFullWidthLayoutWidth, `min(${akEditorFullWidthLayoutWidth}px, ${renderWidthCSS})`];
|
|
278
280
|
} else if (rendererAppearance === 'comment' && allowTableResizing && !(tableNode !== null && tableNode !== void 0 && tableNode.attrs.width)) {
|
|
279
281
|
const tableContainerWidth = getTableContainerWidth(tableNode);
|
|
280
|
-
return isRenderWidthValid ? renderWidth : tableContainerWidth;
|
|
282
|
+
return [isRenderWidthValid ? renderWidth : tableContainerWidth, renderWidthCSS];
|
|
281
283
|
} else {
|
|
282
284
|
// custom width, or width mapped to breakpoint
|
|
283
285
|
const tableContainerWidth = getTableContainerWidth(tableNode);
|
|
284
|
-
return isRenderWidthValid ? Math.min(tableContainerWidth, renderWidth) : tableContainerWidth;
|
|
286
|
+
return [isRenderWidthValid ? Math.min(tableContainerWidth, renderWidth) : tableContainerWidth, `min(${tableContainerWidth}px, ${renderWidthCSS})`];
|
|
285
287
|
}
|
|
286
288
|
};
|
|
287
|
-
const tableWidth = calcDefaultLayoutWidthByAppearance(rendererAppearance, tableNode);
|
|
289
|
+
const [tableWidth, tableWidthCSS] = calcDefaultLayoutWidthByAppearance(rendererAppearance, tableNode);
|
|
288
290
|
|
|
289
291
|
// Logic for table alignment in renderer
|
|
290
292
|
const isTableAlignStart = tableNode && tableNode.attrs && tableNode.attrs.layout === 'align-start' && allowTableAlignment;
|
|
291
293
|
const fullWidthLineLength = isRenderWidthValid ? Math.min(akEditorFullWidthLayoutWidth, renderWidth) : akEditorFullWidthLayoutWidth;
|
|
294
|
+
const fullWidthLineLengthCSS = `min(${akEditorFullWidthLayoutWidth}px, ${renderWidthCSS})`;
|
|
292
295
|
const commentLineLength = isRenderWidthValid ? renderWidth : lineLengthFixedWidth;
|
|
293
296
|
const isCommentAppearanceAndTableAlignmentEnabled = isCommentAppearance(rendererAppearance) && allowTableAlignment;
|
|
294
|
-
|
|
295
|
-
const
|
|
297
|
+
const lineLength = isFullWidthAppearance(rendererAppearance) ? fullWidthLineLength : isCommentAppearanceAndTableAlignmentEnabled ? commentLineLength : lineLengthFixedWidth;
|
|
298
|
+
const lineLengthCSS = isFullWidthAppearance(rendererAppearance) ? fullWidthLineLengthCSS : isCommentAppearanceAndTableAlignmentEnabled ? renderWidthCSS : `${lineLengthFixedWidth}px`;
|
|
299
|
+
const fixTableSSRResizing = fg('platform-fix-table-ssr-resizing');
|
|
300
|
+
const tableWidthNew = fixTableSSRResizing ? getTableContainerWidth(tableNode) : tableWidth;
|
|
301
|
+
const shouldCalculateLeftForAlignment = !isInsideOfBlockNode && isTableAlignStart && (isFullPageAppearance(rendererAppearance) && tableWidthNew <= lineLengthFixedWidth || isFullWidthAppearance(rendererAppearance) || isCommentAppearanceAndTableAlignmentEnabled);
|
|
302
|
+
let leftCSS;
|
|
296
303
|
if (shouldCalculateLeftForAlignment) {
|
|
297
304
|
left = (tableWidth - lineLength) / 2;
|
|
305
|
+
leftCSS = `(${tableWidthCSS} - ${lineLengthCSS}) / 2`;
|
|
298
306
|
}
|
|
299
|
-
if (!shouldCalculateLeftForAlignment && canUseLinelength(rendererAppearance) &&
|
|
307
|
+
if (!shouldCalculateLeftForAlignment && canUseLinelength(rendererAppearance) && tableWidthNew > lineLengthFixedWidth) {
|
|
300
308
|
left = lineLengthFixedWidth / 2 - tableWidth / 2;
|
|
309
|
+
leftCSS = `${lineLengthCSS} / 2 - ${tableWidthCSS} / 2`;
|
|
301
310
|
}
|
|
302
311
|
const children = React.Children.toArray(this.props.children);
|
|
303
312
|
|
|
@@ -312,7 +321,14 @@ export class TableContainer extends React.Component {
|
|
|
312
321
|
} else {
|
|
313
322
|
updatedLayout = layout;
|
|
314
323
|
}
|
|
315
|
-
let finalTableContainerWidth = allowTableResizing ?
|
|
324
|
+
let finalTableContainerWidth = allowTableResizing ? tableWidthNew : 'inherit';
|
|
325
|
+
|
|
326
|
+
// We can only use CSS to determine the width when we have a known width in container.
|
|
327
|
+
// When appearance is full-page, full-width or comment we use CSS based width calculation.
|
|
328
|
+
// Otherwise it's fixed table width (customized width) or inherit.
|
|
329
|
+
if ((rendererAppearance === 'full-page' || rendererAppearance === 'full-width') && fixTableSSRResizing) {
|
|
330
|
+
finalTableContainerWidth = allowTableResizing ? `calc(${tableWidthCSS})` : 'inherit';
|
|
331
|
+
}
|
|
316
332
|
if (rendererAppearance === 'comment' && allowTableResizing && !allowTableAlignment) {
|
|
317
333
|
// If table alignment is disabled and table width is akEditorDefaultLayoutWidth = 760,
|
|
318
334
|
// it is most likely a table created before "Support Table in Comments" FF was enabled
|
|
@@ -321,24 +337,36 @@ export class TableContainer extends React.Component {
|
|
|
321
337
|
|
|
322
338
|
// !NOTE: it a table resized to 760 is copied from 'full-page' editor and pasted in comment editor
|
|
323
339
|
// where (allowTableResizing && !allowTableAlignment), the table will loose 760px width.
|
|
324
|
-
finalTableContainerWidth = tableNode !== null && tableNode !== void 0 && tableNode.attrs.width && (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.width) !== akEditorDefaultLayoutWidth ? tableWidth : 'inherit';
|
|
340
|
+
finalTableContainerWidth = tableNode !== null && tableNode !== void 0 && tableNode.attrs.width && (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.width) !== akEditorDefaultLayoutWidth ? fixTableSSRResizing ? `calc(${tableWidthCSS})` : tableWidth : 'inherit';
|
|
325
341
|
}
|
|
326
342
|
if (rendererAppearance === 'comment' && allowTableResizing && allowTableAlignment) {
|
|
327
343
|
// If table alignment is enabled and layout is not 'align-start' or 'center', we are loading a table that was
|
|
328
344
|
// created before "Support Table in Comments" FF was enabled. So the table should have the same width as renderer container
|
|
329
345
|
// instead of 760 that was set on tableNode when the table had been published.
|
|
330
|
-
finalTableContainerWidth = ((tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.layout) === 'align-start' || (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.layout) === 'center') && tableNode !== null && tableNode !== void 0 && tableNode.attrs.width ? tableWidth : 'inherit';
|
|
346
|
+
finalTableContainerWidth = ((tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.layout) === 'align-start' || (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.layout) === 'center') && tableNode !== null && tableNode !== void 0 && tableNode.attrs.width ? fixTableSSRResizing ? `calc(${tableWidthCSS})` : tableWidth : 'inherit';
|
|
347
|
+
}
|
|
348
|
+
let style;
|
|
349
|
+
if (fixTableSSRResizing) {
|
|
350
|
+
style = {
|
|
351
|
+
width: finalTableContainerWidth,
|
|
352
|
+
left: leftCSS ? `calc(${leftCSS})` : undefined,
|
|
353
|
+
marginLeft: shouldCalculateLeftForAlignment && leftCSS !== undefined ? `calc(-1 * (${leftCSS}))` : undefined
|
|
354
|
+
};
|
|
355
|
+
} else {
|
|
356
|
+
style = {
|
|
357
|
+
width: finalTableContainerWidth,
|
|
358
|
+
left: left,
|
|
359
|
+
marginLeft: shouldCalculateLeftForAlignment && left !== undefined ? -left : undefined
|
|
360
|
+
};
|
|
331
361
|
}
|
|
332
362
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
333
363
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
334
364
|
className: `${TableSharedCssClassName.TABLE_CONTAINER} ${this.props.shadowClassNames || ''}`,
|
|
335
365
|
"data-layout": updatedLayout,
|
|
336
|
-
ref: this.props.handleRef
|
|
337
|
-
style
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
marginLeft: shouldCalculateLeftForAlignment && left !== undefined ? -left : undefined
|
|
341
|
-
}
|
|
366
|
+
ref: this.props.handleRef
|
|
367
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
368
|
+
,
|
|
369
|
+
style: style
|
|
342
370
|
}, isStickyScrollbarEnabled(this.props.rendererAppearance) && /*#__PURE__*/React.createElement("div", {
|
|
343
371
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
344
372
|
className: TableSharedCssClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_TOP,
|
|
@@ -383,8 +411,10 @@ export class TableContainer extends React.Component {
|
|
|
383
411
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
384
412
|
height: "var(--ds-space-250, 20px)",
|
|
385
413
|
// MAX_BROWSER_SCROLLBAR_HEIGHT
|
|
414
|
+
// Follow editor to hide by default so it does not show empty gap in SSR
|
|
415
|
+
// https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/browse/platform/packages/editor/editor-plugin-table/src/nodeviews/TableComponent.tsx#957
|
|
386
416
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
387
|
-
display: 'block',
|
|
417
|
+
display: fixTableSSRResizing ? 'none' : 'block',
|
|
388
418
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
389
419
|
width: '100%'
|
|
390
420
|
}
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { breakoutConsts } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
4
|
import { FullPagePadding } from './style';
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* Inline Script that updates breakout node width on client side,
|
|
7
8
|
* before main JavaScript bundle is ready.
|
|
@@ -29,11 +30,10 @@ export function BreakoutSSRInlineScript() {
|
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
export function createBreakoutInlineScript(id) {
|
|
32
|
-
const shouldFixTableResizing = String(Boolean(fg('platform-fix-table-ssr-resizing')));
|
|
33
33
|
return `
|
|
34
34
|
(function(window){
|
|
35
35
|
${breakoutInlineScriptContext};
|
|
36
|
-
(${applyBreakoutAfterSSR.toString()})("${id}", breakoutConsts, ${
|
|
36
|
+
(${applyBreakoutAfterSSR.toString()})("${id}", breakoutConsts, ${Boolean(fg('platform-fix-table-ssr-resizing'))});
|
|
37
37
|
})(window);
|
|
38
38
|
`;
|
|
39
39
|
}
|
|
@@ -84,35 +84,32 @@ function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
|
|
|
84
84
|
if (!mode || !WIDE_LAYOUT_MODES.includes(mode)) {
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
|
|
88
|
+
// 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.
|
|
89
|
+
if (!shouldFixTableResizing) {
|
|
90
|
+
if (node.classList.contains('pm-table-container') && mode === 'custom') {
|
|
91
|
+
const rendererWidth = renderer.offsetWidth;
|
|
92
|
+
const effectiveWidth = rendererWidth - breakoutConsts.padding;
|
|
93
|
+
width = `${Math.min(parseInt(node.style.width), effectiveWidth)}px`;
|
|
94
94
|
} else {
|
|
95
|
-
|
|
95
|
+
width = breakoutConsts.calcBreakoutWidth(mode, renderer.offsetWidth);
|
|
96
96
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (node.style.width === width) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
node.style.width = width;
|
|
97
|
+
if (node.style.width === width) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
node.style.width = width;
|
|
105
101
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
102
|
+
// Tables require some special logic, as they are not using common css transform approach,
|
|
103
|
+
// because it breaks with sticky headers. This logic is copied from a table node:
|
|
104
|
+
// https://bitbucket.org/atlassian/atlassian-frontend/src/77938aee0c140d02ff99b98a03849be1236865b4/packages/editor/renderer/src/react/nodes/table.tsx#table.tsx-235:245
|
|
105
|
+
if (node.classList.contains('pm-table-container') && !renderer.classList.contains('is-full-width')) {
|
|
106
|
+
const lineLength = breakoutConsts.calcLineLength();
|
|
107
|
+
const left = lineLength / 2 - parseInt(width) / 2;
|
|
108
|
+
if (left < 0 && parseInt(width) > lineLength) {
|
|
109
|
+
node.style.left = left + 'px';
|
|
110
|
+
} else {
|
|
111
|
+
node.style.left = '';
|
|
112
|
+
}
|
|
116
113
|
}
|
|
117
114
|
}
|
|
118
115
|
});
|
|
@@ -128,16 +125,6 @@ function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
|
|
|
128
125
|
applyMediaBreakout(item.target);
|
|
129
126
|
}
|
|
130
127
|
});
|
|
131
|
-
|
|
132
|
-
// Renderer is initially set to hidden until we figure out the proper width in packages/editor/editor-common/src/ui/WidthProvider/index.tsx
|
|
133
|
-
if (renderer.style.visibility === 'hidden') {
|
|
134
|
-
// Hiding until we get the correct width. But didn't remove them from the DOM so vertical scrollbar can still be correctly calculated.
|
|
135
|
-
renderer.style.visibility = '';
|
|
136
|
-
// Since we don't have a screen width to use as initial value.
|
|
137
|
-
// The width is set to a fix number. This will cause horizontal scrollbar to appear.
|
|
138
|
-
// Hide it until we have the correct width.
|
|
139
|
-
renderer.style.overflowX = '';
|
|
140
|
-
}
|
|
141
128
|
});
|
|
142
129
|
const applyMediaBreakout = card => {
|
|
143
130
|
// width was already set by another breakout script
|
|
@@ -166,9 +153,6 @@ function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
|
|
|
166
153
|
childList: true,
|
|
167
154
|
subtree: true
|
|
168
155
|
});
|
|
169
|
-
if (shouldFixTableResizing) {
|
|
170
|
-
window.__SSR_BREAKOUT_OBSERVED = true;
|
|
171
|
-
}
|
|
172
156
|
|
|
173
157
|
/**
|
|
174
158
|
* Using window load event to unsubscribe from mutation observer, as at this stage document is fully rendered.
|
|
@@ -6,7 +6,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
6
6
|
*/
|
|
7
7
|
import React, { Fragment, useContext, useLayoutEffect, useRef, PureComponent } from 'react';
|
|
8
8
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
|
-
import { jsx } from '@emotion/react';
|
|
9
|
+
import { css, jsx } from '@emotion/react';
|
|
10
10
|
import { getSchemaBasedOnStage } from '@atlaskit/adf-schema/schema-default';
|
|
11
11
|
import { reduce } from '@atlaskit/adf-utils/traverse';
|
|
12
12
|
import { ProviderFactory, ProviderFactoryProvider } from '@atlaskit/editor-common/provider-factory';
|
|
@@ -45,7 +45,12 @@ import { nodeToReact } from '../../react/nodes';
|
|
|
45
45
|
export const NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
46
46
|
export const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
47
47
|
const packageName = "@atlaskit/renderer";
|
|
48
|
-
const packageVersion = "111.1.
|
|
48
|
+
const packageVersion = "111.1.2";
|
|
49
|
+
const setAsQueryContainerStyles = css({
|
|
50
|
+
containerName: 'ak-renderer-wrapper',
|
|
51
|
+
containerType: 'inline-size',
|
|
52
|
+
contain: 'layout style inline-size'
|
|
53
|
+
});
|
|
49
54
|
export const defaultNodeComponents = nodeToReact;
|
|
50
55
|
|
|
51
56
|
/**
|
|
@@ -511,7 +516,7 @@ const RendererWrapper = /*#__PURE__*/React.memo(props => {
|
|
|
511
516
|
return () => observer.disconnect();
|
|
512
517
|
}
|
|
513
518
|
}, [innerRef, addTelepointer]);
|
|
514
|
-
|
|
519
|
+
const renderer = jsx(WidthProvider
|
|
515
520
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
516
521
|
, {
|
|
517
522
|
className: `ak-renderer-wrapper is-${appearance}`,
|
|
@@ -536,6 +541,17 @@ const RendererWrapper = /*#__PURE__*/React.memo(props => {
|
|
|
536
541
|
allowTableResizing: allowTableResizing
|
|
537
542
|
})
|
|
538
543
|
}, children))));
|
|
544
|
+
|
|
545
|
+
// We can only make the wrapper div query container when we have a known width.
|
|
546
|
+
// This is also required for SSR to work correctly. As WidthProvider/WithConsumer will not have the correct width during SSR.
|
|
547
|
+
//
|
|
548
|
+
// We are setting this wrapper div as query container conditionally.
|
|
549
|
+
// Only apply container-type = inline-size when having a known width in full-page/full-width/comment mode.
|
|
550
|
+
// Otherwise when appearance is unspecified the renderer size is decided by the content.
|
|
551
|
+
// In this case we can't set the container-type = inline-size as it will collapse width to 0.
|
|
552
|
+
return (appearance === 'full-page' || appearance === 'full-width' || appearance === 'comment') && fg('platform-fix-table-ssr-resizing') ? jsx("div", {
|
|
553
|
+
css: setAsQueryContainerStyles
|
|
554
|
+
}, renderer) : renderer;
|
|
539
555
|
});
|
|
540
556
|
const RootRendererContext = /*#__PURE__*/React.createContext(null);
|
|
541
557
|
function RendererActionsInternalUpdater({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
4
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
5
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
@@ -14,6 +15,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
14
15
|
import React from 'react';
|
|
15
16
|
import { TableSharedCssClassName, tableMarginTop } from '@atlaskit/editor-common/styles';
|
|
16
17
|
import { WidthConsumer, overflowShadow } from '@atlaskit/editor-common/ui';
|
|
18
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
19
|
import { createCompareNodes, convertProsemirrorTableNodeToArrayOfRows, hasMergedCell, compose } from '@atlaskit/editor-common/utils';
|
|
18
20
|
import { SortOrder } from '@atlaskit/editor-common/types';
|
|
19
21
|
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
@@ -320,32 +322,43 @@ export var TableContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
320
322
|
// Please consider changes below carefully to not negatively impact SSR
|
|
321
323
|
// `renderWidth` cannot be depended on during SSR
|
|
322
324
|
var isRenderWidthValid = !!renderWidth && renderWidth > 0;
|
|
325
|
+
var renderWidthCSS = rendererAppearance === 'full-page' ? "100cqw - ".concat(FullPagePadding, "px * 2") : "100cqw";
|
|
323
326
|
var calcDefaultLayoutWidthByAppearance = function calcDefaultLayoutWidthByAppearance(rendererAppearance, tableNode) {
|
|
324
327
|
if (rendererAppearance === 'full-width' && !(tableNode !== null && tableNode !== void 0 && tableNode.attrs.width)) {
|
|
325
|
-
return isRenderWidthValid ? Math.min(akEditorFullWidthLayoutWidth, renderWidth) : akEditorFullWidthLayoutWidth;
|
|
328
|
+
return [isRenderWidthValid ? Math.min(akEditorFullWidthLayoutWidth, renderWidth) : akEditorFullWidthLayoutWidth, "min(".concat(akEditorFullWidthLayoutWidth, "px, ").concat(renderWidthCSS, ")")];
|
|
326
329
|
} else if (rendererAppearance === 'comment' && allowTableResizing && !(tableNode !== null && tableNode !== void 0 && tableNode.attrs.width)) {
|
|
327
330
|
var tableContainerWidth = getTableContainerWidth(tableNode);
|
|
328
|
-
return isRenderWidthValid ? renderWidth : tableContainerWidth;
|
|
331
|
+
return [isRenderWidthValid ? renderWidth : tableContainerWidth, renderWidthCSS];
|
|
329
332
|
} else {
|
|
330
333
|
// custom width, or width mapped to breakpoint
|
|
331
334
|
var _tableContainerWidth = getTableContainerWidth(tableNode);
|
|
332
|
-
return isRenderWidthValid ? Math.min(_tableContainerWidth, renderWidth) : _tableContainerWidth;
|
|
335
|
+
return [isRenderWidthValid ? Math.min(_tableContainerWidth, renderWidth) : _tableContainerWidth, "min(".concat(_tableContainerWidth, "px, ").concat(renderWidthCSS, ")")];
|
|
333
336
|
}
|
|
334
337
|
};
|
|
335
|
-
var
|
|
338
|
+
var _calcDefaultLayoutWid = calcDefaultLayoutWidthByAppearance(rendererAppearance, tableNode),
|
|
339
|
+
_calcDefaultLayoutWid2 = _slicedToArray(_calcDefaultLayoutWid, 2),
|
|
340
|
+
tableWidth = _calcDefaultLayoutWid2[0],
|
|
341
|
+
tableWidthCSS = _calcDefaultLayoutWid2[1];
|
|
336
342
|
|
|
337
343
|
// Logic for table alignment in renderer
|
|
338
344
|
var isTableAlignStart = tableNode && tableNode.attrs && tableNode.attrs.layout === 'align-start' && allowTableAlignment;
|
|
339
345
|
var fullWidthLineLength = isRenderWidthValid ? Math.min(akEditorFullWidthLayoutWidth, renderWidth) : akEditorFullWidthLayoutWidth;
|
|
346
|
+
var fullWidthLineLengthCSS = "min(".concat(akEditorFullWidthLayoutWidth, "px, ").concat(renderWidthCSS, ")");
|
|
340
347
|
var commentLineLength = isRenderWidthValid ? renderWidth : lineLengthFixedWidth;
|
|
341
348
|
var isCommentAppearanceAndTableAlignmentEnabled = isCommentAppearance(rendererAppearance) && allowTableAlignment;
|
|
342
349
|
var lineLength = isFullWidthAppearance(rendererAppearance) ? fullWidthLineLength : isCommentAppearanceAndTableAlignmentEnabled ? commentLineLength : lineLengthFixedWidth;
|
|
343
|
-
var
|
|
350
|
+
var lineLengthCSS = isFullWidthAppearance(rendererAppearance) ? fullWidthLineLengthCSS : isCommentAppearanceAndTableAlignmentEnabled ? renderWidthCSS : "".concat(lineLengthFixedWidth, "px");
|
|
351
|
+
var fixTableSSRResizing = fg('platform-fix-table-ssr-resizing');
|
|
352
|
+
var tableWidthNew = fixTableSSRResizing ? getTableContainerWidth(tableNode) : tableWidth;
|
|
353
|
+
var shouldCalculateLeftForAlignment = !isInsideOfBlockNode && isTableAlignStart && (isFullPageAppearance(rendererAppearance) && tableWidthNew <= lineLengthFixedWidth || isFullWidthAppearance(rendererAppearance) || isCommentAppearanceAndTableAlignmentEnabled);
|
|
354
|
+
var leftCSS;
|
|
344
355
|
if (shouldCalculateLeftForAlignment) {
|
|
345
356
|
left = (tableWidth - lineLength) / 2;
|
|
357
|
+
leftCSS = "(".concat(tableWidthCSS, " - ").concat(lineLengthCSS, ") / 2");
|
|
346
358
|
}
|
|
347
|
-
if (!shouldCalculateLeftForAlignment && canUseLinelength(rendererAppearance) &&
|
|
359
|
+
if (!shouldCalculateLeftForAlignment && canUseLinelength(rendererAppearance) && tableWidthNew > lineLengthFixedWidth) {
|
|
348
360
|
left = lineLengthFixedWidth / 2 - tableWidth / 2;
|
|
361
|
+
leftCSS = "".concat(lineLengthCSS, " / 2 - ").concat(tableWidthCSS, " / 2");
|
|
349
362
|
}
|
|
350
363
|
var children = React.Children.toArray(this.props.children);
|
|
351
364
|
|
|
@@ -360,7 +373,14 @@ export var TableContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
360
373
|
} else {
|
|
361
374
|
updatedLayout = layout;
|
|
362
375
|
}
|
|
363
|
-
var finalTableContainerWidth = allowTableResizing ?
|
|
376
|
+
var finalTableContainerWidth = allowTableResizing ? tableWidthNew : 'inherit';
|
|
377
|
+
|
|
378
|
+
// We can only use CSS to determine the width when we have a known width in container.
|
|
379
|
+
// When appearance is full-page, full-width or comment we use CSS based width calculation.
|
|
380
|
+
// Otherwise it's fixed table width (customized width) or inherit.
|
|
381
|
+
if ((rendererAppearance === 'full-page' || rendererAppearance === 'full-width') && fixTableSSRResizing) {
|
|
382
|
+
finalTableContainerWidth = allowTableResizing ? "calc(".concat(tableWidthCSS, ")") : 'inherit';
|
|
383
|
+
}
|
|
364
384
|
if (rendererAppearance === 'comment' && allowTableResizing && !allowTableAlignment) {
|
|
365
385
|
// If table alignment is disabled and table width is akEditorDefaultLayoutWidth = 760,
|
|
366
386
|
// it is most likely a table created before "Support Table in Comments" FF was enabled
|
|
@@ -369,24 +389,36 @@ export var TableContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
369
389
|
|
|
370
390
|
// !NOTE: it a table resized to 760 is copied from 'full-page' editor and pasted in comment editor
|
|
371
391
|
// where (allowTableResizing && !allowTableAlignment), the table will loose 760px width.
|
|
372
|
-
finalTableContainerWidth = tableNode !== null && tableNode !== void 0 && tableNode.attrs.width && (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.width) !== akEditorDefaultLayoutWidth ? tableWidth : 'inherit';
|
|
392
|
+
finalTableContainerWidth = tableNode !== null && tableNode !== void 0 && tableNode.attrs.width && (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.width) !== akEditorDefaultLayoutWidth ? fixTableSSRResizing ? "calc(".concat(tableWidthCSS, ")") : tableWidth : 'inherit';
|
|
373
393
|
}
|
|
374
394
|
if (rendererAppearance === 'comment' && allowTableResizing && allowTableAlignment) {
|
|
375
395
|
// If table alignment is enabled and layout is not 'align-start' or 'center', we are loading a table that was
|
|
376
396
|
// created before "Support Table in Comments" FF was enabled. So the table should have the same width as renderer container
|
|
377
397
|
// instead of 760 that was set on tableNode when the table had been published.
|
|
378
|
-
finalTableContainerWidth = ((tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.layout) === 'align-start' || (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.layout) === 'center') && tableNode !== null && tableNode !== void 0 && tableNode.attrs.width ? tableWidth : 'inherit';
|
|
398
|
+
finalTableContainerWidth = ((tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.layout) === 'align-start' || (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.layout) === 'center') && tableNode !== null && tableNode !== void 0 && tableNode.attrs.width ? fixTableSSRResizing ? "calc(".concat(tableWidthCSS, ")") : tableWidth : 'inherit';
|
|
399
|
+
}
|
|
400
|
+
var style;
|
|
401
|
+
if (fixTableSSRResizing) {
|
|
402
|
+
style = {
|
|
403
|
+
width: finalTableContainerWidth,
|
|
404
|
+
left: leftCSS ? "calc(".concat(leftCSS, ")") : undefined,
|
|
405
|
+
marginLeft: shouldCalculateLeftForAlignment && leftCSS !== undefined ? "calc(-1 * (".concat(leftCSS, "))") : undefined
|
|
406
|
+
};
|
|
407
|
+
} else {
|
|
408
|
+
style = {
|
|
409
|
+
width: finalTableContainerWidth,
|
|
410
|
+
left: left,
|
|
411
|
+
marginLeft: shouldCalculateLeftForAlignment && left !== undefined ? -left : undefined
|
|
412
|
+
};
|
|
379
413
|
}
|
|
380
414
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
381
415
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
382
416
|
className: "".concat(TableSharedCssClassName.TABLE_CONTAINER, " ").concat(this.props.shadowClassNames || ''),
|
|
383
417
|
"data-layout": updatedLayout,
|
|
384
|
-
ref: this.props.handleRef
|
|
385
|
-
style
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
marginLeft: shouldCalculateLeftForAlignment && left !== undefined ? -left : undefined
|
|
389
|
-
}
|
|
418
|
+
ref: this.props.handleRef
|
|
419
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
420
|
+
,
|
|
421
|
+
style: style
|
|
390
422
|
}, isStickyScrollbarEnabled(this.props.rendererAppearance) && /*#__PURE__*/React.createElement("div", {
|
|
391
423
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
392
424
|
className: TableSharedCssClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_TOP,
|
|
@@ -431,8 +463,10 @@ export var TableContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
431
463
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
432
464
|
height: "var(--ds-space-250, 20px)",
|
|
433
465
|
// MAX_BROWSER_SCROLLBAR_HEIGHT
|
|
466
|
+
// Follow editor to hide by default so it does not show empty gap in SSR
|
|
467
|
+
// https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/browse/platform/packages/editor/editor-plugin-table/src/nodeviews/TableComponent.tsx#957
|
|
434
468
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
435
|
-
display: 'block',
|
|
469
|
+
display: fixTableSSRResizing ? 'none' : 'block',
|
|
436
470
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
437
471
|
width: '100%'
|
|
438
472
|
}
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { breakoutConsts } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
4
|
import { FullPagePadding } from './style';
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* Inline Script that updates breakout node width on client side,
|
|
7
8
|
* before main JavaScript bundle is ready.
|
|
@@ -29,8 +30,7 @@ export function BreakoutSSRInlineScript() {
|
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
export function createBreakoutInlineScript(id) {
|
|
32
|
-
|
|
33
|
-
return "\n (function(window){\n ".concat(breakoutInlineScriptContext, ";\n (").concat(applyBreakoutAfterSSR.toString(), ")(\"").concat(id, "\", breakoutConsts, ").concat(shouldFixTableResizing, ");\n })(window);\n");
|
|
33
|
+
return "\n (function(window){\n ".concat(breakoutInlineScriptContext, ";\n (").concat(applyBreakoutAfterSSR.toString(), ")(\"").concat(id, "\", breakoutConsts, ").concat(Boolean(fg('platform-fix-table-ssr-resizing')), ");\n })(window);\n");
|
|
34
34
|
}
|
|
35
35
|
export var breakoutInlineScriptContext = "\n var breakoutConsts = ".concat(JSON.stringify(breakoutConsts), ";\n breakoutConsts.mapBreakpointToLayoutMaxWidth = ").concat(breakoutConsts.mapBreakpointToLayoutMaxWidth.toString(), ";\n breakoutConsts.getBreakpoint = ").concat(breakoutConsts.getBreakpoint.toString(), ";\n breakoutConsts.calcBreakoutWidth = ").concat(breakoutConsts.calcBreakoutWidth.toString(), ";\n breakoutConsts.calcLineLength = ").concat(breakoutConsts.calcLineLength.toString(), ";\n breakoutConsts.calcWideWidth = ").concat(breakoutConsts.calcWideWidth.toString(), ";\n breakoutConsts.FullPagePadding = ").concat(FullPagePadding.toString(), ";\n");
|
|
36
36
|
function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
|
|
@@ -71,35 +71,32 @@ function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
|
|
|
71
71
|
if (!mode || !WIDE_LAYOUT_MODES.includes(mode)) {
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
|
|
75
|
+
// 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.
|
|
76
|
+
if (!shouldFixTableResizing) {
|
|
77
|
+
if (node.classList.contains('pm-table-container') && mode === 'custom') {
|
|
78
|
+
var rendererWidth = renderer.offsetWidth;
|
|
79
|
+
var effectiveWidth = rendererWidth - breakoutConsts.padding;
|
|
80
|
+
width = "".concat(Math.min(parseInt(node.style.width), effectiveWidth), "px");
|
|
81
81
|
} else {
|
|
82
|
-
|
|
82
|
+
width = breakoutConsts.calcBreakoutWidth(mode, renderer.offsetWidth);
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (node.style.width === width) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
node.style.width = width;
|
|
84
|
+
if (node.style.width === width) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
node.style.width = width;
|
|
92
88
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
89
|
+
// Tables require some special logic, as they are not using common css transform approach,
|
|
90
|
+
// because it breaks with sticky headers. This logic is copied from a table node:
|
|
91
|
+
// https://bitbucket.org/atlassian/atlassian-frontend/src/77938aee0c140d02ff99b98a03849be1236865b4/packages/editor/renderer/src/react/nodes/table.tsx#table.tsx-235:245
|
|
92
|
+
if (node.classList.contains('pm-table-container') && !renderer.classList.contains('is-full-width')) {
|
|
93
|
+
var lineLength = breakoutConsts.calcLineLength();
|
|
94
|
+
var left = lineLength / 2 - parseInt(width) / 2;
|
|
95
|
+
if (left < 0 && parseInt(width) > lineLength) {
|
|
96
|
+
node.style.left = left + 'px';
|
|
97
|
+
} else {
|
|
98
|
+
node.style.left = '';
|
|
99
|
+
}
|
|
103
100
|
}
|
|
104
101
|
}
|
|
105
102
|
});
|
|
@@ -115,16 +112,6 @@ function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
|
|
|
115
112
|
applyMediaBreakout(item.target);
|
|
116
113
|
}
|
|
117
114
|
});
|
|
118
|
-
|
|
119
|
-
// Renderer is initially set to hidden until we figure out the proper width in packages/editor/editor-common/src/ui/WidthProvider/index.tsx
|
|
120
|
-
if (renderer.style.visibility === 'hidden') {
|
|
121
|
-
// Hiding until we get the correct width. But didn't remove them from the DOM so vertical scrollbar can still be correctly calculated.
|
|
122
|
-
renderer.style.visibility = '';
|
|
123
|
-
// Since we don't have a screen width to use as initial value.
|
|
124
|
-
// The width is set to a fix number. This will cause horizontal scrollbar to appear.
|
|
125
|
-
// Hide it until we have the correct width.
|
|
126
|
-
renderer.style.overflowX = '';
|
|
127
|
-
}
|
|
128
115
|
});
|
|
129
116
|
var applyMediaBreakout = function applyMediaBreakout(card) {
|
|
130
117
|
// width was already set by another breakout script
|
|
@@ -155,9 +142,6 @@ function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
|
|
|
155
142
|
childList: true,
|
|
156
143
|
subtree: true
|
|
157
144
|
});
|
|
158
|
-
if (shouldFixTableResizing) {
|
|
159
|
-
window.__SSR_BREAKOUT_OBSERVED = true;
|
|
160
|
-
}
|
|
161
145
|
|
|
162
146
|
/**
|
|
163
147
|
* Using window load event to unsubscribe from mutation observer, as at this stage document is fully rendered.
|
|
@@ -16,7 +16,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
16
16
|
*/
|
|
17
17
|
import React, { Fragment, useContext, useLayoutEffect, useRef, PureComponent } from 'react';
|
|
18
18
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
19
|
-
import { jsx } from '@emotion/react';
|
|
19
|
+
import { css, jsx } from '@emotion/react';
|
|
20
20
|
import { getSchemaBasedOnStage } from '@atlaskit/adf-schema/schema-default';
|
|
21
21
|
import { reduce } from '@atlaskit/adf-utils/traverse';
|
|
22
22
|
import { ProviderFactory, ProviderFactoryProvider } from '@atlaskit/editor-common/provider-factory';
|
|
@@ -55,7 +55,12 @@ import { nodeToReact } from '../../react/nodes';
|
|
|
55
55
|
export var NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
56
56
|
export var DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
57
57
|
var packageName = "@atlaskit/renderer";
|
|
58
|
-
var packageVersion = "111.1.
|
|
58
|
+
var packageVersion = "111.1.2";
|
|
59
|
+
var setAsQueryContainerStyles = css({
|
|
60
|
+
containerName: 'ak-renderer-wrapper',
|
|
61
|
+
containerType: 'inline-size',
|
|
62
|
+
contain: 'layout style inline-size'
|
|
63
|
+
});
|
|
59
64
|
export var defaultNodeComponents = nodeToReact;
|
|
60
65
|
|
|
61
66
|
/**
|
|
@@ -489,26 +494,26 @@ var RendererWrapper = /*#__PURE__*/React.memo(function (props) {
|
|
|
489
494
|
// We must check if window is defined, if it isn't we are in a SSR environment
|
|
490
495
|
// and we don't want to add the telepointer
|
|
491
496
|
if (typeof window !== 'undefined' && addTelepointer && innerRef !== null && innerRef !== void 0 && innerRef.current) {
|
|
492
|
-
var
|
|
497
|
+
var _renderer = innerRef.current.querySelector('.ak-renderer-document');
|
|
493
498
|
if (initialUpdate.current) {
|
|
494
|
-
var lastChild =
|
|
499
|
+
var lastChild = _renderer.lastChild;
|
|
495
500
|
lastChild && lastChild.appendChild(createTelepointer());
|
|
496
501
|
}
|
|
497
502
|
var mutateTelepointer = function mutateTelepointer(mutations) {
|
|
498
503
|
mutations.forEach(function (mutation) {
|
|
499
504
|
if (initialUpdate.current) {
|
|
500
|
-
var oldTelepointer =
|
|
505
|
+
var oldTelepointer = _renderer.querySelector("#".concat(TELEPOINTER_ID));
|
|
501
506
|
if (oldTelepointer) {
|
|
502
507
|
oldTelepointer.remove();
|
|
503
508
|
}
|
|
504
|
-
var _lastChild =
|
|
509
|
+
var _lastChild = _renderer.lastChild;
|
|
505
510
|
_lastChild && _lastChild.appendChild(createTelepointer());
|
|
506
511
|
initialUpdate.current = false;
|
|
507
512
|
}
|
|
508
513
|
if (mutation.type === 'characterData') {
|
|
509
514
|
var parentNode = mutation.target.parentElement;
|
|
510
515
|
if (parentNode) {
|
|
511
|
-
var _oldTelepointer =
|
|
516
|
+
var _oldTelepointer = _renderer.querySelector("#".concat(TELEPOINTER_ID));
|
|
512
517
|
if (_oldTelepointer) {
|
|
513
518
|
_oldTelepointer.remove();
|
|
514
519
|
}
|
|
@@ -529,7 +534,7 @@ var RendererWrapper = /*#__PURE__*/React.memo(function (props) {
|
|
|
529
534
|
};
|
|
530
535
|
}
|
|
531
536
|
}, [innerRef, addTelepointer]);
|
|
532
|
-
|
|
537
|
+
var renderer = jsx(WidthProvider
|
|
533
538
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
534
539
|
, {
|
|
535
540
|
className: "ak-renderer-wrapper is-".concat(appearance),
|
|
@@ -554,6 +559,17 @@ var RendererWrapper = /*#__PURE__*/React.memo(function (props) {
|
|
|
554
559
|
allowTableResizing: allowTableResizing
|
|
555
560
|
})
|
|
556
561
|
}, children))));
|
|
562
|
+
|
|
563
|
+
// We can only make the wrapper div query container when we have a known width.
|
|
564
|
+
// This is also required for SSR to work correctly. As WidthProvider/WithConsumer will not have the correct width during SSR.
|
|
565
|
+
//
|
|
566
|
+
// We are setting this wrapper div as query container conditionally.
|
|
567
|
+
// Only apply container-type = inline-size when having a known width in full-page/full-width/comment mode.
|
|
568
|
+
// Otherwise when appearance is unspecified the renderer size is decided by the content.
|
|
569
|
+
// In this case we can't set the container-type = inline-size as it will collapse width to 0.
|
|
570
|
+
return (appearance === 'full-page' || appearance === 'full-width' || appearance === 'comment') && fg('platform-fix-table-ssr-resizing') ? jsx("div", {
|
|
571
|
+
css: setAsQueryContainerStyles
|
|
572
|
+
}, renderer) : renderer;
|
|
557
573
|
});
|
|
558
574
|
var RootRendererContext = /*#__PURE__*/React.createContext(null);
|
|
559
575
|
function RendererActionsInternalUpdater(_ref) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/renderer",
|
|
3
|
-
"version": "111.1.
|
|
3
|
+
"version": "111.1.2",
|
|
4
4
|
"description": "Renderer component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@atlaskit/analytics-next": "^10.1.0",
|
|
30
30
|
"@atlaskit/button": "^20.2.0",
|
|
31
31
|
"@atlaskit/code": "^15.6.0",
|
|
32
|
-
"@atlaskit/editor-common": "^
|
|
32
|
+
"@atlaskit/editor-common": "^93.0.0",
|
|
33
33
|
"@atlaskit/editor-json-transformer": "^8.18.0",
|
|
34
34
|
"@atlaskit/editor-palette": "1.6.1",
|
|
35
35
|
"@atlaskit/editor-prosemirror": "6.0.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@atlaskit/emoji": "^67.8.0",
|
|
38
38
|
"@atlaskit/feature-gate-js-client": "^4.19.0",
|
|
39
39
|
"@atlaskit/icon": "^22.20.0",
|
|
40
|
-
"@atlaskit/link-datasource": "^3.
|
|
40
|
+
"@atlaskit/link-datasource": "^3.3.0",
|
|
41
41
|
"@atlaskit/media-card": "^78.5.0",
|
|
42
42
|
"@atlaskit/media-client": "^28.0.0",
|
|
43
43
|
"@atlaskit/media-client-react": "^2.2.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@atlaskit/theme": "^13.0.0",
|
|
53
53
|
"@atlaskit/tmp-editor-statsig": "*",
|
|
54
54
|
"@atlaskit/tokens": "^2.0.0",
|
|
55
|
-
"@atlaskit/tooltip": "^18.
|
|
55
|
+
"@atlaskit/tooltip": "^18.8.0",
|
|
56
56
|
"@babel/runtime": "^7.0.0",
|
|
57
57
|
"@emotion/react": "^11.7.1",
|
|
58
58
|
"lodash": "^4.17.21",
|