@atlaskit/renderer 115.0.6 → 115.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/react/nodes/blockCard.js +2 -1
- package/dist/cjs/react/nodes/embedCard.js +4 -1
- package/dist/cjs/react/nodes/inlineCard.js +2 -1
- package/dist/cjs/react/nodes/mediaSingle/index.js +2 -2
- package/dist/cjs/ui/Renderer/PortalContext.js +24 -0
- package/dist/cjs/ui/Renderer/index.js +28 -6
- package/dist/es2019/react/nodes/blockCard.js +2 -1
- package/dist/es2019/react/nodes/embedCard.js +4 -1
- package/dist/es2019/react/nodes/inlineCard.js +2 -1
- package/dist/es2019/react/nodes/mediaSingle/index.js +2 -2
- package/dist/es2019/ui/Renderer/PortalContext.js +15 -0
- package/dist/es2019/ui/Renderer/index.js +28 -6
- package/dist/esm/react/nodes/blockCard.js +2 -1
- package/dist/esm/react/nodes/embedCard.js +4 -1
- package/dist/esm/react/nodes/inlineCard.js +2 -1
- package/dist/esm/react/nodes/mediaSingle/index.js +2 -2
- package/dist/esm/ui/Renderer/PortalContext.js +15 -0
- package/dist/esm/ui/Renderer/index.js +28 -6
- package/dist/types/ui/Renderer/PortalContext.d.ts +6 -0
- package/dist/types/ui/Renderer/index.d.ts +0 -3
- package/dist/types-ts4.5/ui/Renderer/PortalContext.d.ts +6 -0
- package/dist/types-ts4.5/ui/Renderer/index.d.ts +0 -3
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 115.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#151824](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/151824)
|
|
8
|
+
[`0828a5f0b032e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0828a5f0b032e) -
|
|
9
|
+
Extract portal to a context when custom nodeComponents are not passed in.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#152820](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/152820)
|
|
14
|
+
[`00eda15128c75`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/00eda15128c75) -
|
|
15
|
+
ED-27923:Fix embeded card width during SSR
|
|
16
|
+
|
|
3
17
|
## 115.0.6
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -18,6 +18,7 @@ var _ssr = require("@atlaskit/smart-card/ssr");
|
|
|
18
18
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
19
19
|
var _colors = require("@atlaskit/theme/colors");
|
|
20
20
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
21
|
+
var _PortalContext = require("../../ui/Renderer/PortalContext");
|
|
21
22
|
/**
|
|
22
23
|
* @jsxRuntime classic
|
|
23
24
|
* @jsx jsx
|
|
@@ -37,9 +38,9 @@ function BlockCard(props) {
|
|
|
37
38
|
var url = props.url,
|
|
38
39
|
data = props.data,
|
|
39
40
|
eventHandlers = props.eventHandlers,
|
|
40
|
-
portal = props.portal,
|
|
41
41
|
smartLinks = props.smartLinks,
|
|
42
42
|
isNodeNested = props.isNodeNested;
|
|
43
|
+
var portal = (0, _PortalContext.usePortal)(props);
|
|
43
44
|
var _ref = smartLinks || {},
|
|
44
45
|
actionOptions = _ref.actionOptions;
|
|
45
46
|
var onClick = (0, _getCardClickHandler.getCardClickHandler)(eventHandlers, url);
|
|
@@ -19,6 +19,7 @@ var _fallback = require("./fallback");
|
|
|
19
19
|
var _style = require("../../ui/Renderer/style");
|
|
20
20
|
var _getCardClickHandler = require("../utils/getCardClickHandler");
|
|
21
21
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
22
|
+
var _PortalContext = require("../../ui/Renderer/PortalContext");
|
|
22
23
|
/**
|
|
23
24
|
* @jsxRuntime classic
|
|
24
25
|
* @jsx jsx
|
|
@@ -38,6 +39,8 @@ var embedCardWrapperStyles = (0, _react.css)({
|
|
|
38
39
|
},
|
|
39
40
|
margin: '0 auto'
|
|
40
41
|
});
|
|
42
|
+
|
|
43
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
41
44
|
var uIMediaSingleLayoutStyles = (0, _react.css)({
|
|
42
45
|
// eslint-disable-next-line @atlaskit/design-system/use-tokens-space
|
|
43
46
|
marginLeft: '50%',
|
|
@@ -48,13 +51,13 @@ function EmbedCard(props) {
|
|
|
48
51
|
var url = props.url,
|
|
49
52
|
data = props.data,
|
|
50
53
|
eventHandlers = props.eventHandlers,
|
|
51
|
-
portal = props.portal,
|
|
52
54
|
layout = props.layout,
|
|
53
55
|
width = props.width,
|
|
54
56
|
isInsideOfBlockNode = props.isInsideOfBlockNode,
|
|
55
57
|
rendererAppearance = props.rendererAppearance,
|
|
56
58
|
smartLinks = props.smartLinks,
|
|
57
59
|
isInsideOfInlineExtension = props.isInsideOfInlineExtension;
|
|
60
|
+
var portal = (0, _PortalContext.usePortal)(props);
|
|
58
61
|
var embedIframeRef = (0, _react2.useRef)(null);
|
|
59
62
|
var onClick = (0, _getCardClickHandler.getCardClickHandler)(eventHandlers, url);
|
|
60
63
|
var _ref = smartLinks || {},
|
|
@@ -16,6 +16,7 @@ var _SmartCardStorage = require("../../ui/SmartCardStorage");
|
|
|
16
16
|
var _getCardClickHandler = require("../utils/getCardClickHandler");
|
|
17
17
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
18
18
|
var _useInlineAnnotationProps = require("../../ui/annotations/element/useInlineAnnotationProps");
|
|
19
|
+
var _PortalContext = require("../../ui/Renderer/PortalContext");
|
|
19
20
|
/**
|
|
20
21
|
* @jsxRuntime classic
|
|
21
22
|
* @jsx jsx
|
|
@@ -26,8 +27,8 @@ var InlineCard = function InlineCard(props) {
|
|
|
26
27
|
var url = props.url,
|
|
27
28
|
data = props.data,
|
|
28
29
|
eventHandlers = props.eventHandlers,
|
|
29
|
-
portal = props.portal,
|
|
30
30
|
smartLinks = props.smartLinks;
|
|
31
|
+
var portal = (0, _PortalContext.usePortal)(props);
|
|
31
32
|
var onClick = (0, _getCardClickHandler.getCardClickHandler)(eventHandlers, url);
|
|
32
33
|
var cardProps = {
|
|
33
34
|
url: url,
|
|
@@ -141,7 +141,7 @@ var MediaSingleWithChildren = function MediaSingleWithChildren(props) {
|
|
|
141
141
|
var padding = isFullPage ? _style.FullPagePadding * 2 : 0;
|
|
142
142
|
var calcDimensions = (0, _react.useCallback)(function (mediaContainerWidth) {
|
|
143
143
|
var containerWidth = getMediaContainerWidth(mediaContainerWidth, layout);
|
|
144
|
-
var maxWidth = (0, _coreUtils.isSSR)() && widthAttr && (0, _platformFeatureFlags.fg)('platform_editor_fix_image_size_diff_during_ssr') ? Math.max(widthAttr, containerWidth) : containerWidth;
|
|
144
|
+
var maxWidth = (0, _coreUtils.isSSR)() && widthAttr && typeof widthAttr === 'number' && widthType === 'pixel' && (0, _platformFeatureFlags.fg)('platform_editor_fix_image_size_diff_during_ssr') ? Math.max(widthAttr, containerWidth) : containerWidth;
|
|
145
145
|
var maxHeight = height / width * maxWidth;
|
|
146
146
|
var cardDimensions = {
|
|
147
147
|
width: "".concat(maxWidth, "px"),
|
|
@@ -162,7 +162,7 @@ var MediaSingleWithChildren = function MediaSingleWithChildren(props) {
|
|
|
162
162
|
cardDimensions: cardDimensions,
|
|
163
163
|
lineLength: lineLength
|
|
164
164
|
};
|
|
165
|
-
}, [height, isFullWidth, isInsideOfBlockNode, layout, padding, rendererAppearance, width, widthAttr]);
|
|
165
|
+
}, [height, isFullWidth, isInsideOfBlockNode, layout, padding, rendererAppearance, width, widthAttr, widthType]);
|
|
166
166
|
var originalDimensions = (0, _react.useMemo)(function () {
|
|
167
167
|
return {
|
|
168
168
|
width: width,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.usePortal = exports.PortalContext = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
|
+
var PortalContext = exports.PortalContext = /*#__PURE__*/_react.default.createContext(undefined);
|
|
13
|
+
var usePortal = exports.usePortal = function usePortal() {
|
|
14
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
15
|
+
portalFromProps = _ref.portal;
|
|
16
|
+
var portalFromContext = (0, _react.useContext)(PortalContext);
|
|
17
|
+
if (portalFromProps) {
|
|
18
|
+
return portalFromProps;
|
|
19
|
+
}
|
|
20
|
+
if ((0, _platformFeatureFlags.fg)('cc_complexit_reduce_portal_rerenders')) {
|
|
21
|
+
return portalFromContext;
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
};
|
|
@@ -9,6 +9,7 @@ exports.NORMAL_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = void 0
|
|
|
9
9
|
exports.Renderer = Renderer;
|
|
10
10
|
exports.default = exports.RendererWithAnalytics = exports.RendererFunctionalComponent = void 0;
|
|
11
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
12
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
15
|
var _schemaDefault = require("@atlaskit/adf-schema/schema-default");
|
|
@@ -49,6 +50,8 @@ var _RendererStyleContainer = require("./RendererStyleContainer");
|
|
|
49
50
|
var _getBaseFontSize = require("./get-base-font-size");
|
|
50
51
|
var _rendererHelper = require("./rendererHelper");
|
|
51
52
|
var _useMemoFromPropsDerivative = require("./useMemoFromPropsDerivative");
|
|
53
|
+
var _PortalContext = require("./PortalContext");
|
|
54
|
+
var _excluded = ["portal"];
|
|
52
55
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
53
56
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
54
57
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -60,7 +63,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
60
63
|
var NORMAL_SEVERITY_THRESHOLD = exports.NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
61
64
|
var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
62
65
|
var packageName = "@atlaskit/renderer";
|
|
63
|
-
var packageVersion = "115.0
|
|
66
|
+
var packageVersion = "115.1.0";
|
|
64
67
|
var setAsQueryContainerStyles = (0, _react2.css)({
|
|
65
68
|
containerName: 'ak-renderer-wrapper',
|
|
66
69
|
containerType: 'inline-size'
|
|
@@ -171,10 +174,6 @@ var handleWrapperOnClick = function handleWrapperOnClick(event, props, mouseDown
|
|
|
171
174
|
props.eventHandlers.onUnhandledClick(event);
|
|
172
175
|
}
|
|
173
176
|
};
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Exported due to enzyme test reliance on this component.
|
|
177
|
-
*/
|
|
178
177
|
var RendererFunctionalComponent = exports.RendererFunctionalComponent = function RendererFunctionalComponent(props) {
|
|
179
178
|
var createAnalyticsEvent = props.createAnalyticsEvent;
|
|
180
179
|
var mouseDownSelection = (0, _react.useRef)(undefined);
|
|
@@ -457,6 +456,29 @@ var RendererFunctionalComponent = exports.RendererFunctionalComponent = function
|
|
|
457
456
|
}
|
|
458
457
|
};
|
|
459
458
|
var RendererFunctionalComponentMemoized = /*#__PURE__*/_react.default.memo(RendererFunctionalComponent);
|
|
459
|
+
var RendererFunctionalComponentWithPortalContext = function RendererFunctionalComponentWithPortalContext(props) {
|
|
460
|
+
var portal = props.portal,
|
|
461
|
+
propsWithoutPortal = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
462
|
+
return (0, _react2.jsx)(_PortalContext.PortalContext.Provider, {
|
|
463
|
+
value: portal
|
|
464
|
+
}, (0, _react2.jsx)(RendererFunctionalComponent, propsWithoutPortal));
|
|
465
|
+
};
|
|
466
|
+
var RendererFunctionalComponentWithPortalContextMemoized = /*#__PURE__*/_react.default.memo(RendererFunctionalComponentWithPortalContext);
|
|
467
|
+
var getRendererComponent = function getRendererComponent(nodeComponents) {
|
|
468
|
+
// If nodeComponents are provided, for now we don't want to remove portal from props
|
|
469
|
+
// and use context instead because at this time we cannot guarantee that existing
|
|
470
|
+
// consumers of Atlaskit Renderer will update to use the new portal context.
|
|
471
|
+
if (!Boolean(nodeComponents) && (0, _platformFeatureFlags.fg)('cc_complexit_reduce_portal_rerenders')) {
|
|
472
|
+
if ((0, _platformFeatureFlags.fg)('cc_perf_reduce_rerenders')) {
|
|
473
|
+
return RendererFunctionalComponentWithPortalContextMemoized;
|
|
474
|
+
}
|
|
475
|
+
return RendererFunctionalComponentWithPortalContext;
|
|
476
|
+
}
|
|
477
|
+
if ((0, _platformFeatureFlags.fg)('cc_perf_reduce_rerenders')) {
|
|
478
|
+
return RendererFunctionalComponentMemoized;
|
|
479
|
+
}
|
|
480
|
+
return RendererFunctionalComponent;
|
|
481
|
+
};
|
|
460
482
|
function Renderer(props) {
|
|
461
483
|
var _React$useContext = _react.default.useContext(_annotations.AnnotationsPositionContext),
|
|
462
484
|
startPos = _React$useContext.startPos;
|
|
@@ -464,7 +486,7 @@ function Renderer(props) {
|
|
|
464
486
|
isTopLevelRenderer = _useRendererContext.isTopLevelRenderer;
|
|
465
487
|
var _ref = (0, _react.useContext)(_ValidationContext.ValidationContext) || {},
|
|
466
488
|
skipValidation = _ref.skipValidation;
|
|
467
|
-
var RendererComponent = (
|
|
489
|
+
var RendererComponent = getRendererComponent(props.nodeComponents);
|
|
468
490
|
return (0, _react2.jsx)(RendererComponent
|
|
469
491
|
// Ignored via go/ees005
|
|
470
492
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
@@ -16,6 +16,7 @@ import { CardSSR } from '@atlaskit/smart-card/ssr';
|
|
|
16
16
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
17
|
import { N40 } from '@atlaskit/theme/colors';
|
|
18
18
|
import { calcBreakoutWidth, canRenderDatasource } from '@atlaskit/editor-common/utils';
|
|
19
|
+
import { usePortal } from '../../ui/Renderer/PortalContext';
|
|
19
20
|
const datasourceContainerStyle = css({
|
|
20
21
|
borderRadius: `${"var(--ds-border-radius-200, 8px)"}`,
|
|
21
22
|
border: `1px solid ${`var(--ds-border, ${N40})`}`,
|
|
@@ -30,10 +31,10 @@ export default function BlockCard(props) {
|
|
|
30
31
|
url,
|
|
31
32
|
data,
|
|
32
33
|
eventHandlers,
|
|
33
|
-
portal,
|
|
34
34
|
smartLinks,
|
|
35
35
|
isNodeNested
|
|
36
36
|
} = props;
|
|
37
|
+
const portal = usePortal(props);
|
|
37
38
|
const {
|
|
38
39
|
actionOptions
|
|
39
40
|
} = smartLinks || {};
|
|
@@ -16,6 +16,7 @@ import { CardErrorBoundary } from './fallback';
|
|
|
16
16
|
import { FullPagePadding } from '../../ui/Renderer/style';
|
|
17
17
|
import { getCardClickHandler } from '../utils/getCardClickHandler';
|
|
18
18
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
19
|
+
import { usePortal } from '../../ui/Renderer/PortalContext';
|
|
19
20
|
const embedCardWrapperStyles = css({
|
|
20
21
|
width: '100%',
|
|
21
22
|
height: '100%',
|
|
@@ -29,6 +30,8 @@ const embedCardWrapperStyles = css({
|
|
|
29
30
|
},
|
|
30
31
|
margin: '0 auto'
|
|
31
32
|
});
|
|
33
|
+
|
|
34
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
32
35
|
const uIMediaSingleLayoutStyles = css({
|
|
33
36
|
// eslint-disable-next-line @atlaskit/design-system/use-tokens-space
|
|
34
37
|
marginLeft: '50%',
|
|
@@ -40,7 +43,6 @@ export default function EmbedCard(props) {
|
|
|
40
43
|
url,
|
|
41
44
|
data,
|
|
42
45
|
eventHandlers,
|
|
43
|
-
portal,
|
|
44
46
|
layout,
|
|
45
47
|
width,
|
|
46
48
|
isInsideOfBlockNode,
|
|
@@ -48,6 +50,7 @@ export default function EmbedCard(props) {
|
|
|
48
50
|
smartLinks,
|
|
49
51
|
isInsideOfInlineExtension
|
|
50
52
|
} = props;
|
|
53
|
+
const portal = usePortal(props);
|
|
51
54
|
const embedIframeRef = useRef(null);
|
|
52
55
|
const onClick = getCardClickHandler(eventHandlers, url);
|
|
53
56
|
const {
|
|
@@ -14,14 +14,15 @@ import { withSmartCardStorage } from '../../ui/SmartCardStorage';
|
|
|
14
14
|
import { getCardClickHandler } from '../utils/getCardClickHandler';
|
|
15
15
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
16
16
|
import { useInlineAnnotationProps } from '../../ui/annotations/element/useInlineAnnotationProps';
|
|
17
|
+
import { usePortal } from '../../ui/Renderer/PortalContext';
|
|
17
18
|
const InlineCard = props => {
|
|
18
19
|
const {
|
|
19
20
|
url,
|
|
20
21
|
data,
|
|
21
22
|
eventHandlers,
|
|
22
|
-
portal,
|
|
23
23
|
smartLinks
|
|
24
24
|
} = props;
|
|
25
|
+
const portal = usePortal(props);
|
|
25
26
|
const onClick = getCardClickHandler(eventHandlers, url);
|
|
26
27
|
const cardProps = {
|
|
27
28
|
url,
|
|
@@ -127,7 +127,7 @@ const MediaSingleWithChildren = props => {
|
|
|
127
127
|
const padding = isFullPage ? FullPagePadding * 2 : 0;
|
|
128
128
|
const calcDimensions = useCallback(mediaContainerWidth => {
|
|
129
129
|
const containerWidth = getMediaContainerWidth(mediaContainerWidth, layout);
|
|
130
|
-
const maxWidth = isSSR() && widthAttr && fg('platform_editor_fix_image_size_diff_during_ssr') ? Math.max(widthAttr, containerWidth) : containerWidth;
|
|
130
|
+
const maxWidth = isSSR() && widthAttr && typeof widthAttr === 'number' && widthType === 'pixel' && fg('platform_editor_fix_image_size_diff_during_ssr') ? Math.max(widthAttr, containerWidth) : containerWidth;
|
|
131
131
|
const maxHeight = height / width * maxWidth;
|
|
132
132
|
const cardDimensions = {
|
|
133
133
|
width: `${maxWidth}px`,
|
|
@@ -148,7 +148,7 @@ const MediaSingleWithChildren = props => {
|
|
|
148
148
|
cardDimensions,
|
|
149
149
|
lineLength
|
|
150
150
|
};
|
|
151
|
-
}, [height, isFullWidth, isInsideOfBlockNode, layout, padding, rendererAppearance, width, widthAttr]);
|
|
151
|
+
}, [height, isFullWidth, isInsideOfBlockNode, layout, padding, rendererAppearance, width, widthAttr, widthType]);
|
|
152
152
|
const originalDimensions = useMemo(() => ({
|
|
153
153
|
width,
|
|
154
154
|
height
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
export const PortalContext = /*#__PURE__*/React.createContext(undefined);
|
|
4
|
+
export const usePortal = ({
|
|
5
|
+
portal: portalFromProps
|
|
6
|
+
} = {}) => {
|
|
7
|
+
const portalFromContext = useContext(PortalContext);
|
|
8
|
+
if (portalFromProps) {
|
|
9
|
+
return portalFromProps;
|
|
10
|
+
}
|
|
11
|
+
if (fg('cc_complexit_reduce_portal_rerenders')) {
|
|
12
|
+
return portalFromContext;
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
};
|
|
@@ -44,10 +44,11 @@ import { RendererStyleContainer } from './RendererStyleContainer';
|
|
|
44
44
|
import { getBaseFontSize } from './get-base-font-size';
|
|
45
45
|
import { removeEmptySpaceAroundContent } from './rendererHelper';
|
|
46
46
|
import { useMemoFromPropsDerivative } from './useMemoFromPropsDerivative';
|
|
47
|
+
import { PortalContext } from './PortalContext';
|
|
47
48
|
export const NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
48
49
|
export const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
49
50
|
const packageName = "@atlaskit/renderer";
|
|
50
|
-
const packageVersion = "115.0
|
|
51
|
+
const packageVersion = "115.1.0";
|
|
51
52
|
const setAsQueryContainerStyles = css({
|
|
52
53
|
containerName: 'ak-renderer-wrapper',
|
|
53
54
|
containerType: 'inline-size'
|
|
@@ -160,10 +161,6 @@ const handleWrapperOnClick = (event, props, mouseDownSelection) => {
|
|
|
160
161
|
props.eventHandlers.onUnhandledClick(event);
|
|
161
162
|
}
|
|
162
163
|
};
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Exported due to enzyme test reliance on this component.
|
|
166
|
-
*/
|
|
167
164
|
export const RendererFunctionalComponent = props => {
|
|
168
165
|
const {
|
|
169
166
|
createAnalyticsEvent
|
|
@@ -441,6 +438,31 @@ export const RendererFunctionalComponent = props => {
|
|
|
441
438
|
}
|
|
442
439
|
};
|
|
443
440
|
const RendererFunctionalComponentMemoized = /*#__PURE__*/React.memo(RendererFunctionalComponent);
|
|
441
|
+
const RendererFunctionalComponentWithPortalContext = props => {
|
|
442
|
+
const {
|
|
443
|
+
portal,
|
|
444
|
+
...propsWithoutPortal
|
|
445
|
+
} = props;
|
|
446
|
+
return jsx(PortalContext.Provider, {
|
|
447
|
+
value: portal
|
|
448
|
+
}, jsx(RendererFunctionalComponent, propsWithoutPortal));
|
|
449
|
+
};
|
|
450
|
+
const RendererFunctionalComponentWithPortalContextMemoized = /*#__PURE__*/React.memo(RendererFunctionalComponentWithPortalContext);
|
|
451
|
+
const getRendererComponent = nodeComponents => {
|
|
452
|
+
// If nodeComponents are provided, for now we don't want to remove portal from props
|
|
453
|
+
// and use context instead because at this time we cannot guarantee that existing
|
|
454
|
+
// consumers of Atlaskit Renderer will update to use the new portal context.
|
|
455
|
+
if (!Boolean(nodeComponents) && fg('cc_complexit_reduce_portal_rerenders')) {
|
|
456
|
+
if (fg('cc_perf_reduce_rerenders')) {
|
|
457
|
+
return RendererFunctionalComponentWithPortalContextMemoized;
|
|
458
|
+
}
|
|
459
|
+
return RendererFunctionalComponentWithPortalContext;
|
|
460
|
+
}
|
|
461
|
+
if (fg('cc_perf_reduce_rerenders')) {
|
|
462
|
+
return RendererFunctionalComponentMemoized;
|
|
463
|
+
}
|
|
464
|
+
return RendererFunctionalComponent;
|
|
465
|
+
};
|
|
444
466
|
export function Renderer(props) {
|
|
445
467
|
const {
|
|
446
468
|
startPos
|
|
@@ -451,7 +473,7 @@ export function Renderer(props) {
|
|
|
451
473
|
const {
|
|
452
474
|
skipValidation
|
|
453
475
|
} = useContext(ValidationContext) || {};
|
|
454
|
-
const RendererComponent =
|
|
476
|
+
const RendererComponent = getRendererComponent(props.nodeComponents);
|
|
455
477
|
return jsx(RendererComponent
|
|
456
478
|
// Ignored via go/ees005
|
|
457
479
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
@@ -16,6 +16,7 @@ import { CardSSR } from '@atlaskit/smart-card/ssr';
|
|
|
16
16
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
17
|
import { N40 } from '@atlaskit/theme/colors';
|
|
18
18
|
import { calcBreakoutWidth, canRenderDatasource } from '@atlaskit/editor-common/utils';
|
|
19
|
+
import { usePortal } from '../../ui/Renderer/PortalContext';
|
|
19
20
|
var datasourceContainerStyle = css({
|
|
20
21
|
borderRadius: "var(--ds-border-radius-200, 8px)",
|
|
21
22
|
border: "1px solid ".concat("var(--ds-border, ".concat(N40, ")")),
|
|
@@ -29,9 +30,9 @@ export default function BlockCard(props) {
|
|
|
29
30
|
var url = props.url,
|
|
30
31
|
data = props.data,
|
|
31
32
|
eventHandlers = props.eventHandlers,
|
|
32
|
-
portal = props.portal,
|
|
33
33
|
smartLinks = props.smartLinks,
|
|
34
34
|
isNodeNested = props.isNodeNested;
|
|
35
|
+
var portal = usePortal(props);
|
|
35
36
|
var _ref = smartLinks || {},
|
|
36
37
|
actionOptions = _ref.actionOptions;
|
|
37
38
|
var onClick = getCardClickHandler(eventHandlers, url);
|
|
@@ -17,6 +17,7 @@ import { CardErrorBoundary } from './fallback';
|
|
|
17
17
|
import { FullPagePadding } from '../../ui/Renderer/style';
|
|
18
18
|
import { getCardClickHandler } from '../utils/getCardClickHandler';
|
|
19
19
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
20
|
+
import { usePortal } from '../../ui/Renderer/PortalContext';
|
|
20
21
|
var embedCardWrapperStyles = css({
|
|
21
22
|
width: '100%',
|
|
22
23
|
height: '100%',
|
|
@@ -30,6 +31,8 @@ var embedCardWrapperStyles = css({
|
|
|
30
31
|
},
|
|
31
32
|
margin: '0 auto'
|
|
32
33
|
});
|
|
34
|
+
|
|
35
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
33
36
|
var uIMediaSingleLayoutStyles = css({
|
|
34
37
|
// eslint-disable-next-line @atlaskit/design-system/use-tokens-space
|
|
35
38
|
marginLeft: '50%',
|
|
@@ -40,13 +43,13 @@ export default function EmbedCard(props) {
|
|
|
40
43
|
var url = props.url,
|
|
41
44
|
data = props.data,
|
|
42
45
|
eventHandlers = props.eventHandlers,
|
|
43
|
-
portal = props.portal,
|
|
44
46
|
layout = props.layout,
|
|
45
47
|
width = props.width,
|
|
46
48
|
isInsideOfBlockNode = props.isInsideOfBlockNode,
|
|
47
49
|
rendererAppearance = props.rendererAppearance,
|
|
48
50
|
smartLinks = props.smartLinks,
|
|
49
51
|
isInsideOfInlineExtension = props.isInsideOfInlineExtension;
|
|
52
|
+
var portal = usePortal(props);
|
|
50
53
|
var embedIframeRef = useRef(null);
|
|
51
54
|
var onClick = getCardClickHandler(eventHandlers, url);
|
|
52
55
|
var _ref = smartLinks || {},
|
|
@@ -14,12 +14,13 @@ import { withSmartCardStorage } from '../../ui/SmartCardStorage';
|
|
|
14
14
|
import { getCardClickHandler } from '../utils/getCardClickHandler';
|
|
15
15
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
16
16
|
import { useInlineAnnotationProps } from '../../ui/annotations/element/useInlineAnnotationProps';
|
|
17
|
+
import { usePortal } from '../../ui/Renderer/PortalContext';
|
|
17
18
|
var InlineCard = function InlineCard(props) {
|
|
18
19
|
var url = props.url,
|
|
19
20
|
data = props.data,
|
|
20
21
|
eventHandlers = props.eventHandlers,
|
|
21
|
-
portal = props.portal,
|
|
22
22
|
smartLinks = props.smartLinks;
|
|
23
|
+
var portal = usePortal(props);
|
|
23
24
|
var onClick = getCardClickHandler(eventHandlers, url);
|
|
24
25
|
var cardProps = {
|
|
25
26
|
url: url,
|
|
@@ -130,7 +130,7 @@ var MediaSingleWithChildren = function MediaSingleWithChildren(props) {
|
|
|
130
130
|
var padding = isFullPage ? FullPagePadding * 2 : 0;
|
|
131
131
|
var calcDimensions = useCallback(function (mediaContainerWidth) {
|
|
132
132
|
var containerWidth = getMediaContainerWidth(mediaContainerWidth, layout);
|
|
133
|
-
var maxWidth = isSSR() && widthAttr && fg('platform_editor_fix_image_size_diff_during_ssr') ? Math.max(widthAttr, containerWidth) : containerWidth;
|
|
133
|
+
var maxWidth = isSSR() && widthAttr && typeof widthAttr === 'number' && widthType === 'pixel' && fg('platform_editor_fix_image_size_diff_during_ssr') ? Math.max(widthAttr, containerWidth) : containerWidth;
|
|
134
134
|
var maxHeight = height / width * maxWidth;
|
|
135
135
|
var cardDimensions = {
|
|
136
136
|
width: "".concat(maxWidth, "px"),
|
|
@@ -151,7 +151,7 @@ var MediaSingleWithChildren = function MediaSingleWithChildren(props) {
|
|
|
151
151
|
cardDimensions: cardDimensions,
|
|
152
152
|
lineLength: lineLength
|
|
153
153
|
};
|
|
154
|
-
}, [height, isFullWidth, isInsideOfBlockNode, layout, padding, rendererAppearance, width, widthAttr]);
|
|
154
|
+
}, [height, isFullWidth, isInsideOfBlockNode, layout, padding, rendererAppearance, width, widthAttr, widthType]);
|
|
155
155
|
var originalDimensions = useMemo(function () {
|
|
156
156
|
return {
|
|
157
157
|
width: width,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
export var PortalContext = /*#__PURE__*/React.createContext(undefined);
|
|
4
|
+
export var usePortal = function usePortal() {
|
|
5
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
6
|
+
portalFromProps = _ref.portal;
|
|
7
|
+
var portalFromContext = useContext(PortalContext);
|
|
8
|
+
if (portalFromProps) {
|
|
9
|
+
return portalFromProps;
|
|
10
|
+
}
|
|
11
|
+
if (fg('cc_complexit_reduce_portal_rerenders')) {
|
|
12
|
+
return portalFromContext;
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
var _excluded = ["portal"];
|
|
3
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
7
|
/**
|
|
@@ -47,10 +49,11 @@ import { RendererStyleContainer } from './RendererStyleContainer';
|
|
|
47
49
|
import { getBaseFontSize } from './get-base-font-size';
|
|
48
50
|
import { removeEmptySpaceAroundContent } from './rendererHelper';
|
|
49
51
|
import { useMemoFromPropsDerivative } from './useMemoFromPropsDerivative';
|
|
52
|
+
import { PortalContext } from './PortalContext';
|
|
50
53
|
export var NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
51
54
|
export var DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
52
55
|
var packageName = "@atlaskit/renderer";
|
|
53
|
-
var packageVersion = "115.0
|
|
56
|
+
var packageVersion = "115.1.0";
|
|
54
57
|
var setAsQueryContainerStyles = css({
|
|
55
58
|
containerName: 'ak-renderer-wrapper',
|
|
56
59
|
containerType: 'inline-size'
|
|
@@ -161,10 +164,6 @@ var handleWrapperOnClick = function handleWrapperOnClick(event, props, mouseDown
|
|
|
161
164
|
props.eventHandlers.onUnhandledClick(event);
|
|
162
165
|
}
|
|
163
166
|
};
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Exported due to enzyme test reliance on this component.
|
|
167
|
-
*/
|
|
168
167
|
export var RendererFunctionalComponent = function RendererFunctionalComponent(props) {
|
|
169
168
|
var createAnalyticsEvent = props.createAnalyticsEvent;
|
|
170
169
|
var mouseDownSelection = useRef(undefined);
|
|
@@ -447,6 +446,29 @@ export var RendererFunctionalComponent = function RendererFunctionalComponent(pr
|
|
|
447
446
|
}
|
|
448
447
|
};
|
|
449
448
|
var RendererFunctionalComponentMemoized = /*#__PURE__*/React.memo(RendererFunctionalComponent);
|
|
449
|
+
var RendererFunctionalComponentWithPortalContext = function RendererFunctionalComponentWithPortalContext(props) {
|
|
450
|
+
var portal = props.portal,
|
|
451
|
+
propsWithoutPortal = _objectWithoutProperties(props, _excluded);
|
|
452
|
+
return jsx(PortalContext.Provider, {
|
|
453
|
+
value: portal
|
|
454
|
+
}, jsx(RendererFunctionalComponent, propsWithoutPortal));
|
|
455
|
+
};
|
|
456
|
+
var RendererFunctionalComponentWithPortalContextMemoized = /*#__PURE__*/React.memo(RendererFunctionalComponentWithPortalContext);
|
|
457
|
+
var getRendererComponent = function getRendererComponent(nodeComponents) {
|
|
458
|
+
// If nodeComponents are provided, for now we don't want to remove portal from props
|
|
459
|
+
// and use context instead because at this time we cannot guarantee that existing
|
|
460
|
+
// consumers of Atlaskit Renderer will update to use the new portal context.
|
|
461
|
+
if (!Boolean(nodeComponents) && fg('cc_complexit_reduce_portal_rerenders')) {
|
|
462
|
+
if (fg('cc_perf_reduce_rerenders')) {
|
|
463
|
+
return RendererFunctionalComponentWithPortalContextMemoized;
|
|
464
|
+
}
|
|
465
|
+
return RendererFunctionalComponentWithPortalContext;
|
|
466
|
+
}
|
|
467
|
+
if (fg('cc_perf_reduce_rerenders')) {
|
|
468
|
+
return RendererFunctionalComponentMemoized;
|
|
469
|
+
}
|
|
470
|
+
return RendererFunctionalComponent;
|
|
471
|
+
};
|
|
450
472
|
export function Renderer(props) {
|
|
451
473
|
var _React$useContext = React.useContext(AnnotationsPositionContext),
|
|
452
474
|
startPos = _React$useContext.startPos;
|
|
@@ -454,7 +476,7 @@ export function Renderer(props) {
|
|
|
454
476
|
isTopLevelRenderer = _useRendererContext.isTopLevelRenderer;
|
|
455
477
|
var _ref = useContext(ValidationContext) || {},
|
|
456
478
|
skipValidation = _ref.skipValidation;
|
|
457
|
-
var RendererComponent =
|
|
479
|
+
var RendererComponent = getRendererComponent(props.nodeComponents);
|
|
458
480
|
return jsx(RendererComponent
|
|
459
481
|
// Ignored via go/ees005
|
|
460
482
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RendererProps } from '../renderer-props';
|
|
3
|
+
export declare const PortalContext: React.Context<HTMLElement | undefined>;
|
|
4
|
+
export declare const usePortal: ({ portal: portalFromProps, }?: {
|
|
5
|
+
portal?: RendererProps['portal'];
|
|
6
|
+
}) => HTMLElement | undefined;
|
|
@@ -9,9 +9,6 @@ import type { RendererProps } from '../renderer-props';
|
|
|
9
9
|
import type { RendererAppearance } from './types';
|
|
10
10
|
export declare const NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
11
11
|
export declare const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
12
|
-
/**
|
|
13
|
-
* Exported due to enzyme test reliance on this component.
|
|
14
|
-
*/
|
|
15
12
|
export declare const RendererFunctionalComponent: (props: RendererProps & {
|
|
16
13
|
startPos?: number;
|
|
17
14
|
skipValidation?: boolean;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RendererProps } from '../renderer-props';
|
|
3
|
+
export declare const PortalContext: React.Context<HTMLElement | undefined>;
|
|
4
|
+
export declare const usePortal: ({ portal: portalFromProps, }?: {
|
|
5
|
+
portal?: RendererProps['portal'];
|
|
6
|
+
}) => HTMLElement | undefined;
|
|
@@ -9,9 +9,6 @@ import type { RendererProps } from '../renderer-props';
|
|
|
9
9
|
import type { RendererAppearance } from './types';
|
|
10
10
|
export declare const NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
11
11
|
export declare const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
12
|
-
/**
|
|
13
|
-
* Exported due to enzyme test reliance on this component.
|
|
14
|
-
*/
|
|
15
12
|
export declare const RendererFunctionalComponent: (props: RendererProps & {
|
|
16
13
|
startPos?: number;
|
|
17
14
|
skipValidation?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/renderer",
|
|
3
|
-
"version": "115.0
|
|
3
|
+
"version": "115.1.0",
|
|
4
4
|
"description": "Renderer component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -129,6 +129,9 @@
|
|
|
129
129
|
"cc_complexit_fe_improve_table_sorting": {
|
|
130
130
|
"type": "boolean"
|
|
131
131
|
},
|
|
132
|
+
"cc_complexit_reduce_portal_rerenders": {
|
|
133
|
+
"type": "boolean"
|
|
134
|
+
},
|
|
132
135
|
"cc_perf_reduce_rerenders": {
|
|
133
136
|
"type": "boolean"
|
|
134
137
|
},
|