@atlaskit/renderer 111.1.1 → 111.1.3

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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/renderer
2
2
 
3
+ ## 111.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#148476](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/148476)
8
+ [`4a3547a1691e2`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4a3547a1691e2) -
9
+ Reverting change to add onLoadComplete callback for useLoadAnnotations annotations hook
10
+
11
+ ## 111.1.2
12
+
13
+ ### Patch Changes
14
+
15
+ - [#147736](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/147736)
16
+ [`b6868597a50cd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b6868597a50cd) -
17
+ [ux] Fix table resizing when rendering with AK renderer in SSR
18
+ - Updated dependencies
19
+
3
20
  ## 111.1.1
4
21
 
5
22
  ### 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 tableWidth = calcDefaultLayoutWidthByAppearance(rendererAppearance, tableNode);
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 shouldCalculateLeftForAlignment = !isInsideOfBlockNode && isTableAlignStart && ((0, _appearance.isFullPageAppearance)(rendererAppearance) && tableWidth <= lineLengthFixedWidth || (0, _appearance.isFullWidthAppearance)(rendererAppearance) || isCommentAppearanceAndTableAlignmentEnabled);
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) && tableWidth > lineLengthFixedWidth) {
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 ? tableWidth : 'inherit';
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
- width: finalTableContainerWidth,
394
- left: left,
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
- var shouldFixTableResizing = String(Boolean((0, _platformFeatureFlags.fg)('platform-fix-table-ssr-resizing')));
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
- if (node.classList.contains('pm-table-container') && mode === 'custom') {
84
- var isFullPage = renderer.classList.contains('is-full-page');
85
- var rendererWidth = renderer.offsetWidth;
86
- var effectiveWidth;
87
- if (shouldFixTableResizing) {
88
- // Logic from https://stash.atlassian.com/projects/atlassian/repos/atlassian-frontend-monorepo/browse/platform/packages/editor/renderer/src/react/nodes/table.tsx?at=d3af2ef54521ccf10e9b094996ad9528ec05c7e3#610
89
- effectiveWidth = isFullPage ? rendererWidth - 2 * breakoutConsts.FullPagePadding : rendererWidth;
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
- effectiveWidth = rendererWidth - breakoutConsts.padding;
90
+ width = breakoutConsts.calcBreakoutWidth(mode, renderer.offsetWidth);
92
91
  }
93
- width = "".concat(Math.min(parseInt(node.style.width), effectiveWidth), "px");
94
- } else {
95
- width = breakoutConsts.calcBreakoutWidth(mode, renderer.offsetWidth);
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
- // 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
- var lineLength = breakoutConsts.calcLineLength();
107
- var 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 = '';
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.1";
68
+ var packageVersion = "111.1.3";
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 renderer = innerRef.current.querySelector('.ak-renderer-document');
507
+ var _renderer = innerRef.current.querySelector('.ak-renderer-document');
503
508
  if (initialUpdate.current) {
504
- var lastChild = renderer.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 = renderer.querySelector("#".concat(_style.TELEPOINTER_ID));
515
+ var oldTelepointer = _renderer.querySelector("#".concat(_style.TELEPOINTER_ID));
511
516
  if (oldTelepointer) {
512
517
  oldTelepointer.remove();
513
518
  }
514
- var _lastChild = renderer.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 = renderer.querySelector("#".concat(_style.TELEPOINTER_ID));
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
- return (0, _react2.jsx)(_ui.WidthProvider
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) {
@@ -14,8 +14,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
14
14
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
15
  var useLoadAnnotations = exports.useLoadAnnotations = function useLoadAnnotations(_ref) {
16
16
  var adfDocument = _ref.adfDocument,
17
- isNestedRender = _ref.isNestedRender,
18
- onLoadComplete = _ref.onLoadComplete;
17
+ isNestedRender = _ref.isNestedRender;
19
18
  var actions = (0, _react.useContext)(_RendererActionsContext.RendererContext);
20
19
  var providers = (0, _react.useContext)(_context.ProvidersContext);
21
20
  (0, _react.useEffect)(function () {
@@ -28,9 +27,6 @@ var useLoadAnnotations = exports.useLoadAnnotations = function useLoadAnnotation
28
27
  var annotations = actions.getAnnotationMarks();
29
28
  // we don't want to request integrators for state with an empty list of ids.
30
29
  if (!annotations.length) {
31
- onLoadComplete && onLoadComplete({
32
- numberOfUnresolvedInlineComments: 0
33
- });
34
30
  return;
35
31
  }
36
32
  var ids = annotations.map(function (mark) {
@@ -44,12 +40,7 @@ var useLoadAnnotations = exports.useLoadAnnotations = function useLoadAnnotation
44
40
  return _objectSpread(_objectSpread({}, acc), {}, (0, _defineProperty2.default)({}, value.id, value));
45
41
  }, {});
46
42
  updateSubscriberInlineComment.emit(_types.AnnotationUpdateEvent.SET_ANNOTATION_STATE, payload);
47
- onLoadComplete && onLoadComplete({
48
- numberOfUnresolvedInlineComments: data.filter(function (data) {
49
- return data.state === 'active';
50
- }).length
51
- });
52
43
  };
53
44
  inlineCommentGetState(ids, isNestedRender).then(cb);
54
- }, [actions, providers, adfDocument, isNestedRender, onLoadComplete]);
45
+ }, [actions, providers, adfDocument, isNestedRender]);
55
46
  };
@@ -31,12 +31,10 @@ var _draft = require("./draft");
31
31
  var _element = require("./element");
32
32
  var LoadAnnotations = /*#__PURE__*/_react.default.memo(function (_ref) {
33
33
  var adfDocument = _ref.adfDocument,
34
- isNestedRender = _ref.isNestedRender,
35
- onLoadComplete = _ref.onLoadComplete;
34
+ isNestedRender = _ref.isNestedRender;
36
35
  (0, _useLoadAnnotations.useLoadAnnotations)({
37
36
  adfDocument: adfDocument,
38
- isNestedRender: isNestedRender,
39
- onLoadComplete: onLoadComplete
37
+ isNestedRender: isNestedRender
40
38
  });
41
39
  return null;
42
40
  });
@@ -54,8 +52,7 @@ var AnnotationsWrapper = exports.AnnotationsWrapper = function AnnotationsWrappe
54
52
  annotationProvider = props.annotationProvider,
55
53
  rendererRef = props.rendererRef,
56
54
  adfDocument = props.adfDocument,
57
- isNestedRender = props.isNestedRender,
58
- onLoadComplete = props.onLoadComplete;
55
+ isNestedRender = props.isNestedRender;
59
56
  var updateSubscriber = annotationProvider && annotationProvider.inlineComment && annotationProvider.inlineComment.updateSubscriber;
60
57
  var inlineCommentAnnotationsState = (0, _useEvents.useAnnotationStateByTypeEvent)({
61
58
  type: _adfSchema.AnnotationTypes.INLINE_COMMENT,
@@ -74,8 +71,7 @@ var AnnotationsWrapper = exports.AnnotationsWrapper = function AnnotationsWrappe
74
71
  rendererRef: rendererRef
75
72
  }, /*#__PURE__*/_react.default.createElement(LoadAnnotations, {
76
73
  adfDocument: adfDocument,
77
- isNestedRender: isNestedRender,
78
- onLoadComplete: onLoadComplete
74
+ isNestedRender: isNestedRender
79
75
  }), /*#__PURE__*/_react.default.createElement(_view.AnnotationView, {
80
76
  createAnalyticsEvent: createAnalyticsEvent
81
77
  }), children)))));
@@ -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
- let lineLength = isFullWidthAppearance(rendererAppearance) ? fullWidthLineLength : isCommentAppearanceAndTableAlignmentEnabled ? commentLineLength : lineLengthFixedWidth;
295
- const shouldCalculateLeftForAlignment = !isInsideOfBlockNode && isTableAlignStart && (isFullPageAppearance(rendererAppearance) && tableWidth <= lineLengthFixedWidth || isFullWidthAppearance(rendererAppearance) || isCommentAppearanceAndTableAlignmentEnabled);
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) && tableWidth > lineLengthFixedWidth) {
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 ? tableWidth : 'inherit';
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
- width: finalTableContainerWidth,
339
- left: left,
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
  }