@atlaskit/renderer 108.18.0 → 108.20.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.
Files changed (97) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/afm-cc/tsconfig.json +109 -0
  3. package/dist/cjs/react/marks/alignment.js +3 -2
  4. package/dist/cjs/react/marks/breakout.js +3 -2
  5. package/dist/cjs/react/marks/link.js +4 -3
  6. package/dist/cjs/react/nodes/blockCard.js +13 -11
  7. package/dist/cjs/react/nodes/codeBlock/codeBlock.js +5 -2
  8. package/dist/cjs/react/nodes/codeBlock/components/codeBlockButtonContainer.js +6 -4
  9. package/dist/cjs/react/nodes/codeBlock/components/codeBlockContainer.js +3 -2
  10. package/dist/cjs/react/nodes/codeBlock/components/codeBlockCopyButton.js +11 -8
  11. package/dist/cjs/react/nodes/codeBlock/components/codeBlockWrapButton.js +11 -8
  12. package/dist/cjs/react/nodes/codeBlock/components/lightWeightCodeBlock.js +8 -7
  13. package/dist/cjs/react/nodes/codeBlock/windowedCodeBlock.js +6 -5
  14. package/dist/cjs/react/nodes/embedCard.js +9 -8
  15. package/dist/cjs/react/nodes/heading-anchor.js +5 -4
  16. package/dist/cjs/react/nodes/layoutColumn.js +3 -2
  17. package/dist/cjs/react/nodes/media/index.js +11 -8
  18. package/dist/cjs/react/nodes/mediaInline.js +47 -20
  19. package/dist/cjs/react/nodes/mediaSingle/index.js +6 -3
  20. package/dist/cjs/react/nodes/mediaSingle/styles.js +1 -0
  21. package/dist/cjs/react/nodes/panel.js +9 -7
  22. package/dist/cjs/react/nodes/table/sticky.js +7 -6
  23. package/dist/cjs/ui/Expand.js +18 -16
  24. package/dist/cjs/ui/MediaCard.js +74 -71
  25. package/dist/cjs/ui/Renderer/index.js +28 -35
  26. package/dist/cjs/ui/Renderer/truncated-wrapper.js +3 -2
  27. package/dist/cjs/ui/SortingIcon.js +5 -4
  28. package/dist/cjs/ui/annotations/draft/component.js +9 -8
  29. package/dist/cjs/ui/annotations/element/mark.js +2 -1
  30. package/dist/es2019/react/marks/alignment.js +4 -3
  31. package/dist/es2019/react/marks/breakout.js +4 -3
  32. package/dist/es2019/react/marks/link.js +5 -4
  33. package/dist/es2019/react/nodes/blockCard.js +13 -12
  34. package/dist/es2019/react/nodes/codeBlock/codeBlock.js +4 -2
  35. package/dist/es2019/react/nodes/codeBlock/components/codeBlockButtonContainer.js +6 -5
  36. package/dist/es2019/react/nodes/codeBlock/components/codeBlockContainer.js +4 -3
  37. package/dist/es2019/react/nodes/codeBlock/components/codeBlockCopyButton.js +7 -5
  38. package/dist/es2019/react/nodes/codeBlock/components/codeBlockWrapButton.js +9 -7
  39. package/dist/es2019/react/nodes/codeBlock/components/lightWeightCodeBlock.js +9 -8
  40. package/dist/es2019/react/nodes/codeBlock/windowedCodeBlock.js +6 -4
  41. package/dist/es2019/react/nodes/embedCard.js +10 -9
  42. package/dist/es2019/react/nodes/heading-anchor.js +6 -5
  43. package/dist/es2019/react/nodes/layoutColumn.js +4 -3
  44. package/dist/es2019/react/nodes/media/index.js +13 -7
  45. package/dist/es2019/react/nodes/mediaInline.js +20 -12
  46. package/dist/es2019/react/nodes/mediaSingle/index.js +6 -3
  47. package/dist/es2019/react/nodes/mediaSingle/styles.js +1 -0
  48. package/dist/es2019/react/nodes/panel.js +8 -7
  49. package/dist/es2019/react/nodes/table/sticky.js +8 -7
  50. package/dist/es2019/ui/Expand.js +17 -16
  51. package/dist/es2019/ui/MediaCard.js +29 -25
  52. package/dist/es2019/ui/Renderer/index.js +31 -36
  53. package/dist/es2019/ui/Renderer/truncated-wrapper.js +4 -3
  54. package/dist/es2019/ui/SortingIcon.js +6 -5
  55. package/dist/es2019/ui/annotations/draft/component.js +10 -9
  56. package/dist/es2019/ui/annotations/element/mark.js +3 -2
  57. package/dist/esm/react/marks/alignment.js +4 -3
  58. package/dist/esm/react/marks/breakout.js +4 -3
  59. package/dist/esm/react/marks/link.js +5 -4
  60. package/dist/esm/react/nodes/blockCard.js +13 -12
  61. package/dist/esm/react/nodes/codeBlock/codeBlock.js +4 -2
  62. package/dist/esm/react/nodes/codeBlock/components/codeBlockButtonContainer.js +6 -5
  63. package/dist/esm/react/nodes/codeBlock/components/codeBlockContainer.js +4 -3
  64. package/dist/esm/react/nodes/codeBlock/components/codeBlockCopyButton.js +7 -5
  65. package/dist/esm/react/nodes/codeBlock/components/codeBlockWrapButton.js +9 -7
  66. package/dist/esm/react/nodes/codeBlock/components/lightWeightCodeBlock.js +9 -8
  67. package/dist/esm/react/nodes/codeBlock/windowedCodeBlock.js +6 -4
  68. package/dist/esm/react/nodes/embedCard.js +10 -9
  69. package/dist/esm/react/nodes/heading-anchor.js +6 -5
  70. package/dist/esm/react/nodes/layoutColumn.js +4 -3
  71. package/dist/esm/react/nodes/media/index.js +14 -8
  72. package/dist/esm/react/nodes/mediaInline.js +48 -21
  73. package/dist/esm/react/nodes/mediaSingle/index.js +6 -3
  74. package/dist/esm/react/nodes/mediaSingle/styles.js +1 -0
  75. package/dist/esm/react/nodes/panel.js +8 -7
  76. package/dist/esm/react/nodes/table/sticky.js +8 -7
  77. package/dist/esm/ui/Expand.js +17 -16
  78. package/dist/esm/ui/MediaCard.js +74 -71
  79. package/dist/esm/ui/Renderer/index.js +31 -36
  80. package/dist/esm/ui/Renderer/truncated-wrapper.js +4 -3
  81. package/dist/esm/ui/SortingIcon.js +6 -5
  82. package/dist/esm/ui/annotations/draft/component.js +10 -9
  83. package/dist/esm/ui/annotations/element/mark.js +3 -2
  84. package/dist/types/react/nodes/media/index.d.ts +3 -2
  85. package/dist/types/react/nodes/mediaInline.d.ts +1 -2
  86. package/dist/types/ui/MediaCard.d.ts +5 -6
  87. package/dist/types/ui/Renderer/index.d.ts +1 -2
  88. package/dist/types-ts4.5/react/nodes/media/index.d.ts +3 -2
  89. package/dist/types-ts4.5/react/nodes/mediaInline.d.ts +1 -2
  90. package/dist/types-ts4.5/ui/MediaCard.d.ts +5 -6
  91. package/dist/types-ts4.5/ui/Renderer/index.d.ts +1 -2
  92. package/package.json +2 -1
  93. package/dist/cjs/react/utils/EditorMediaClientProvider.js +0 -40
  94. package/dist/es2019/react/utils/EditorMediaClientProvider.js +0 -27
  95. package/dist/esm/react/utils/EditorMediaClientProvider.js +0 -30
  96. package/dist/types/react/utils/EditorMediaClientProvider.d.ts +0 -5
  97. package/dist/types-ts4.5/react/utils/EditorMediaClientProvider.d.ts +0 -5
@@ -9,7 +9,7 @@ import React, { useEffect, useState, useCallback } from 'react';
9
9
  import { MediaInlineCard } from '@atlaskit/media-card';
10
10
  import { MediaInlineCardErroredView, MediaInlineCardLoadingView, messages } from '@atlaskit/media-ui';
11
11
  import { WithProviders } from '@atlaskit/editor-common/provider-factory';
12
- import { MediaClientContext } from '@atlaskit/media-client-react';
12
+ import { getMediaClient } from '@atlaskit/media-client-react';
13
13
  import { getClipboardAttrs, mediaIdentifierMap } from '../../ui/MediaCard';
14
14
  import { createIntl, injectIntl } from 'react-intl-next';
15
15
  export var RenderMediaInline = function RenderMediaInline(_ref) {
@@ -18,6 +18,7 @@ export var RenderMediaInline = function RenderMediaInline(_ref) {
18
18
  clipboardAttrs = _ref.clipboardAttrs,
19
19
  mediaInlineProviders = _ref.mediaInlineProviders,
20
20
  collectionName = _ref.collection,
21
+ featureFlags = _ref.featureFlags,
21
22
  eventHandlers = _ref.eventHandlers,
22
23
  identifier = _ref.identifier;
23
24
  var _useState = useState(),
@@ -26,9 +27,12 @@ export var RenderMediaInline = function RenderMediaInline(_ref) {
26
27
  setContextIdentifierProvider = _useState2[1];
27
28
  var _useState3 = useState(),
28
29
  _useState4 = _slicedToArray(_useState3, 2),
29
- fileState = _useState4[0],
30
- setFileState = _useState4[1];
31
- var mediaClient = React.useContext(MediaClientContext);
30
+ viewMediaClientConfigState = _useState4[0],
31
+ setViewMediaClientConfigState = _useState4[1];
32
+ var _useState5 = useState(),
33
+ _useState6 = _slicedToArray(_useState5, 2),
34
+ fileState = _useState6[0],
35
+ setFileState = _useState6[1];
32
36
  var updateContext = /*#__PURE__*/function () {
33
37
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(contextIdentifierProvider) {
34
38
  var resolvedContextID;
@@ -55,40 +59,36 @@ export var RenderMediaInline = function RenderMediaInline(_ref) {
55
59
  };
56
60
  }();
57
61
  var updateFileState = useCallback( /*#__PURE__*/function () {
58
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id) {
59
- var options, _fileState;
62
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id, mediaClientConfig) {
63
+ var mediaClient, options, _fileState;
60
64
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
61
65
  while (1) switch (_context2.prev = _context2.next) {
62
66
  case 0:
67
+ mediaClient = getMediaClient(mediaClientConfig);
63
68
  options = {
64
69
  collectionName: collectionName
65
70
  };
66
- _context2.prev = 1;
67
- if (!mediaClient) {
68
- _context2.next = 7;
69
- break;
70
- }
71
+ _context2.prev = 2;
71
72
  _context2.next = 5;
72
73
  return mediaClient.file.getCurrentState(id, options);
73
74
  case 5:
74
75
  _fileState = _context2.sent;
75
76
  setFileState(_fileState);
76
- case 7:
77
77
  _context2.next = 11;
78
78
  break;
79
79
  case 9:
80
80
  _context2.prev = 9;
81
- _context2.t0 = _context2["catch"](1);
81
+ _context2.t0 = _context2["catch"](2);
82
82
  case 11:
83
83
  case "end":
84
84
  return _context2.stop();
85
85
  }
86
- }, _callee2, null, [[1, 9]]);
86
+ }, _callee2, null, [[2, 9]]);
87
87
  }));
88
- return function (_x2) {
88
+ return function (_x2, _x3) {
89
89
  return _ref3.apply(this, arguments);
90
90
  };
91
- }(), [collectionName, mediaClient]);
91
+ }(), [collectionName]);
92
92
  useEffect(function () {
93
93
  var id = identifier.id;
94
94
  var nodeIsInCache = id && mediaIdentifierMap.has(id);
@@ -102,17 +102,44 @@ export var RenderMediaInline = function RenderMediaInline(_ref) {
102
102
  };
103
103
  }, [identifier, collectionName]);
104
104
  useEffect(function () {
105
- var contextIdentifierProvider = mediaInlineProviders.contextIdentifierProvider;
105
+ var mediaProvider = mediaInlineProviders.mediaProvider,
106
+ contextIdentifierProvider = mediaInlineProviders.contextIdentifierProvider;
106
107
  var id = clipboardAttrs.id;
108
+ updateViewMediaClientConfigState(mediaProvider);
107
109
  updateContext(contextIdentifierProvider);
108
- id && updateFileState(id);
109
- }, [mediaInlineProviders, contextIdentifierProvider, clipboardAttrs, updateFileState]);
110
+ id && viewMediaClientConfigState && updateFileState(id, viewMediaClientConfigState);
111
+ }, [mediaInlineProviders, contextIdentifierProvider, clipboardAttrs, viewMediaClientConfigState, updateFileState]);
112
+ var updateViewMediaClientConfigState = /*#__PURE__*/function () {
113
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(mediaProvider) {
114
+ var mediaClientConfig;
115
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
116
+ while (1) switch (_context3.prev = _context3.next) {
117
+ case 0:
118
+ if (!mediaProvider) {
119
+ _context3.next = 5;
120
+ break;
121
+ }
122
+ _context3.next = 3;
123
+ return mediaProvider;
124
+ case 3:
125
+ mediaClientConfig = _context3.sent;
126
+ setViewMediaClientConfigState(mediaClientConfig.viewMediaClientConfig);
127
+ case 5:
128
+ case "end":
129
+ return _context3.stop();
130
+ }
131
+ }, _callee3);
132
+ }));
133
+ return function updateViewMediaClientConfigState(_x4) {
134
+ return _ref4.apply(this, arguments);
135
+ };
136
+ }();
110
137
 
111
138
  /*
112
139
  * Only show the loading view if the media provider is not ready
113
140
  * prevents calling the media API before the provider is ready
114
141
  */
115
- if (!mediaClient) {
142
+ if (!viewMediaClientConfigState) {
116
143
  return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
117
144
  message: "",
118
145
  isSelected: false
@@ -142,7 +169,7 @@ export var RenderMediaInline = function RenderMediaInline(_ref) {
142
169
  onClick: handleMediaInlineClick,
143
170
  shouldOpenMediaViewer: shouldOpenMediaViewer,
144
171
  shouldDisplayToolTip: shouldDisplayToolTip,
145
- mediaClientConfig: mediaClient.mediaClientConfig,
172
+ mediaClientConfig: viewMediaClientConfigState,
146
173
  mediaViewerItems: Array.from(mediaIdentifierMap.values())
147
174
  }) : /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
148
175
  message: (intl || createIntl({
@@ -1,5 +1,8 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ /** @jsx jsx */
3
+
2
4
  import { default as React, Fragment } from 'react';
5
+ import { jsx } from '@emotion/react';
3
6
  import { injectIntl } from 'react-intl-next';
4
7
  import { MediaSingle as UIMediaSingle, WidthConsumer } from '@atlaskit/editor-common/ui';
5
8
  import { akEditorFullWidthLayoutWidth, akEditorDefaultLayoutWidth, akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
@@ -154,7 +157,7 @@ var MediaSingle = function MediaSingle(props) {
154
157
  featureFlags: featureFlags
155
158
  });
156
159
  var uiMediaSingleStyles = layout === 'full-width' || layout === 'wide' ? [uiMediaSingleBaseStyles, uiMediaSingleLayoutStyles] : [uiMediaSingleBaseStyles];
157
- return /*#__PURE__*/React.createElement(UIMediaSingle, {
160
+ return jsx(UIMediaSingle, {
158
161
  css: uiMediaSingleStyles,
159
162
  handleMediaSingleRef: ref,
160
163
  layout: layout,
@@ -167,9 +170,9 @@ var MediaSingle = function MediaSingle(props) {
167
170
  widthType: widthType
168
171
  },
169
172
  fullWidthMode: isFullWidth
170
- }, /*#__PURE__*/React.createElement(Fragment, null, mediaComponent), allowCaptions && caption);
173
+ }, jsx(Fragment, null, mediaComponent), allowCaptions && caption);
171
174
  };
172
- return /*#__PURE__*/React.createElement(WidthConsumer, null, function (_ref3) {
175
+ return jsx(WidthConsumer, null, function (_ref3) {
173
176
  var width = _ref3.width;
174
177
  // Note: in SSR mode the `window` object is not defined,
175
178
  // therefore width here is 0, see:
@@ -1,5 +1,6 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
2
  var _templateObject, _templateObject2;
3
+ /** @jsx jsx */
3
4
  import { css } from '@emotion/react';
4
5
  export var uiMediaSingleBaseStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n transition: all 0.1s linear;\n"])));
5
6
  export var uiMediaSingleLayoutStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n margin-left: 50%;\n transform: translateX(-50%);\n"])));
@@ -3,8 +3,9 @@ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  var _templateObject, _templateObject2;
5
5
  var _excluded = ["backgroundColor", "hasIcon"];
6
+ /** @jsx jsx */
6
7
  import React from 'react';
7
- import { css } from '@emotion/react';
8
+ import { css, jsx } from '@emotion/react';
8
9
  import TipIcon from '@atlaskit/icon/glyph/editor/hint';
9
10
  import { PanelType } from '@atlaskit/adf-schema';
10
11
  import { getPanelBackgroundDarkModeColors, panelSharedStylesWithoutPrefix, PanelSharedCssClassName } from '@atlaskit/editor-common/panel';
@@ -38,7 +39,7 @@ var PanelStyled = function PanelStyled(_ref) {
38
39
  }), PanelType.CUSTOM, customStyle, hasIcon ? '' : 'padding-left: 12px;');
39
40
  };
40
41
  }
41
- return /*#__PURE__*/React.createElement("div", _extends({
42
+ return jsx("div", _extends({
42
43
  css: styles
43
44
  }, props), props.children);
44
45
  };
@@ -67,7 +68,7 @@ var Panel = function Panel(props) {
67
68
  var getIcon = function getIcon() {
68
69
  if (panelType === PanelType.CUSTOM) {
69
70
  if (panelIcon && providers) {
70
- return /*#__PURE__*/React.createElement(EmojiItem, {
71
+ return jsx(EmojiItem, {
71
72
  id: panelIconId,
72
73
  text: panelIconText,
73
74
  shortName: panelIcon,
@@ -77,19 +78,19 @@ var Panel = function Panel(props) {
77
78
  return null;
78
79
  }
79
80
  var Icon = panelIcons[panelType];
80
- return /*#__PURE__*/React.createElement(Icon, {
81
+ return jsx(Icon, {
81
82
  label: "Panel ".concat(panelType)
82
83
  });
83
84
  };
84
85
  var icon = getIcon();
85
86
  var renderIcon = function renderIcon() {
86
87
  if (icon) {
87
- return /*#__PURE__*/React.createElement("div", {
88
+ return jsx("div", {
88
89
  className: PanelSharedCssClassName.icon
89
90
  }, icon);
90
91
  }
91
92
  };
92
- return /*#__PURE__*/React.createElement(PanelStyled, {
93
+ return jsx(PanelStyled, {
93
94
  className: PanelSharedCssClassName.prefix,
94
95
  "data-panel-type": panelType,
95
96
  "data-panel-color": panelColor,
@@ -98,7 +99,7 @@ var Panel = function Panel(props) {
98
99
  "data-panel-icon-text": panelIconText,
99
100
  backgroundColor: panelColor,
100
101
  hasIcon: Boolean(icon)
101
- }, renderIcon(), /*#__PURE__*/React.createElement("div", {
102
+ }, renderIcon(), jsx("div", {
102
103
  className: PanelSharedCssClassName.content
103
104
  }, children));
104
105
  };
@@ -3,8 +3,9 @@ import _createClass from "@babel/runtime/helpers/createClass";
3
3
  import _extends from "@babel/runtime/helpers/extends";
4
4
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
5
5
  var _templateObject, _templateObject2, _templateObject3, _templateObject4;
6
+ /** @jsx jsx */
6
7
  import React from 'react';
7
- import { css } from '@emotion/react';
8
+ import { css, jsx } from '@emotion/react';
8
9
  import { TableSharedCssClassName } from '@atlaskit/editor-common/styles';
9
10
  import { akEditorStickyHeaderZIndex } from '@atlaskit/editor-shared-styles';
10
11
  import { N40A } from '@atlaskit/theme/colors';
@@ -37,7 +38,7 @@ export var FixedTableDiv = function FixedTableDiv(props) {
37
38
  var attrs = {
38
39
  mode: mode
39
40
  };
40
- return /*#__PURE__*/React.createElement("div", _extends({}, attrs, {
41
+ return jsx("div", _extends({}, attrs, {
41
42
  "data-testid": "sticky-table-fixed",
42
43
  css: fixedTableCss
43
44
  }), props.children);
@@ -73,26 +74,26 @@ export var StickyTable = function StickyTable(_ref) {
73
74
  });
74
75
  }
75
76
  /* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
76
- return /*#__PURE__*/React.createElement("div", {
77
+ return jsx("div", {
77
78
  css: styles
78
- }, /*#__PURE__*/React.createElement(FixedTableDiv, {
79
+ }, jsx(FixedTableDiv, {
79
80
  top: mode === 'stick' ? top : undefined,
80
81
  mode: rowHeight > 300 ? 'none' : mode,
81
82
  wrapperWidth: wrapperWidth,
82
83
  rendererAppearance: rendererAppearance
83
- }, /*#__PURE__*/React.createElement("div", {
84
+ }, jsx("div", {
84
85
  className: "".concat(TableSharedCssClassName.TABLE_CONTAINER, " is-sticky ").concat(shadowClassNames || ''),
85
86
  "data-layout": layout,
86
87
  style: {
87
88
  width: tableWidth
88
89
  }
89
- }, /*#__PURE__*/React.createElement("div", {
90
+ }, jsx("div", {
90
91
  ref: innerRef,
91
92
  className: "".concat(TableSharedCssClassName.TABLE_STICKY_WRAPPER),
92
93
  style: {
93
94
  overflow: 'hidden'
94
95
  }
95
- }, /*#__PURE__*/React.createElement(Table, {
96
+ }, jsx(Table, {
96
97
  columnWidths: columnWidths,
97
98
  layout: layout,
98
99
  isNumberColumnEnabled: isNumberColumnEnabled,
@@ -2,8 +2,9 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
4
4
  var _templateObject, _templateObject2, _templateObject3, _templateObject4;
5
+ /** @jsx jsx */
5
6
  import React, { useRef, useCallback, useMemo } from 'react';
6
- import { css } from '@emotion/react';
7
+ import { css, jsx } from '@emotion/react';
7
8
  // eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
8
9
  import { gridSize, fontSize } from '@atlaskit/theme/constants';
9
10
  import ChevronRightIcon from '@atlaskit/icon/glyph/chevron-right';
@@ -25,7 +26,7 @@ var Container = function Container(props) {
25
26
  theme: themeProps
26
27
  }), paddingBottom);
27
28
  };
28
- return /*#__PURE__*/React.createElement("div", _extends({
29
+ return jsx("div", _extends({
29
30
  css: styles
30
31
  }, props), props.children);
31
32
  };
@@ -36,7 +37,7 @@ var TitleContainer = function TitleContainer(props) {
36
37
  theme: themeProps
37
38
  }), "var(--ds-space-100, 8px)", paddingBottom);
38
39
  };
39
- return /*#__PURE__*/React.createElement("button", _extends({
40
+ return jsx("button", _extends({
40
41
  css: styles
41
42
  }, props), props.children);
42
43
  };
@@ -49,7 +50,7 @@ var ContentContainer = function ContentContainer(props) {
49
50
  theme: themeProps
50
51
  }), "var(--ds-space-200, 16px)", gridSize() * 5 - gridSize() / 2, visibility);
51
52
  };
52
- return /*#__PURE__*/React.createElement("div", _extends({
53
+ return jsx("div", _extends({
53
54
  css: styles
54
55
  }, props), props.children);
55
56
  };
@@ -96,18 +97,18 @@ function Expand(_ref) {
96
97
  var handleBlur = useCallback(function () {
97
98
  return setFocused(false);
98
99
  }, []);
99
- return /*#__PURE__*/React.createElement(Container, {
100
+ return jsx(Container, {
100
101
  "data-node-type": nodeType,
101
102
  "data-title": title,
102
103
  "data-expanded": expanded,
103
104
  expanded: expanded,
104
105
  focused: focused
105
- }, nestedHeaderIds && nestedHeaderIds.length > 0 ? /*#__PURE__*/React.createElement(ActiveHeaderIdConsumer, {
106
+ }, nestedHeaderIds && nestedHeaderIds.length > 0 ? jsx(ActiveHeaderIdConsumer, {
106
107
  nestedHeaderIds: nestedHeaderIds,
107
108
  onNestedHeaderIdMatch: function onNestedHeaderIdMatch() {
108
109
  return setExpanded(true);
109
110
  }
110
- }) : null, /*#__PURE__*/React.createElement(TitleContainer, {
111
+ }) : null, jsx(TitleContainer, {
111
112
  onClick: function onClick(e) {
112
113
  e.stopPropagation();
113
114
  fireExpandToggleAnalytics(nodeType, expanded, fireAnalyticsEvent);
@@ -122,27 +123,27 @@ function Expand(_ref) {
122
123
  "aria-expanded": expanded,
123
124
  contentEditable: false,
124
125
  expanded: expanded
125
- }, isMobile ? /*#__PURE__*/React.createElement(ExpandIconWrapper, {
126
+ }, isMobile ? jsx(ExpandIconWrapper, {
126
127
  expanded: expanded
127
- }, /*#__PURE__*/React.createElement(ChevronRightIcon, {
128
+ }, jsx(ChevronRightIcon, {
128
129
  label: label
129
- })) : /*#__PURE__*/React.createElement(Tooltip, {
130
+ })) : jsx(Tooltip, {
130
131
  content: label,
131
132
  position: "top",
132
133
  tag: ExpandLayoutWrapperWithRef,
133
134
  testId: 'tooltip'
134
- }, /*#__PURE__*/React.createElement(ExpandIconWrapper, {
135
+ }, jsx(ExpandIconWrapper, {
135
136
  expanded: expanded
136
- }, /*#__PURE__*/React.createElement(ChevronRightIcon, {
137
+ }, jsx(ChevronRightIcon, {
137
138
  label: label
138
- }))), /*#__PURE__*/React.createElement("span", {
139
+ }))), jsx("span", {
139
140
  css: titleStyles,
140
141
  id: id
141
- }, title || intl.formatMessage(expandMessages.expandDefaultTitle))), /*#__PURE__*/React.createElement(ContentContainer, {
142
+ }, title || intl.formatMessage(expandMessages.expandDefaultTitle))), jsx(ContentContainer, {
142
143
  expanded: expanded
143
- }, /*#__PURE__*/React.createElement("div", {
144
+ }, jsx("div", {
144
145
  className: "".concat(nodeType, "-content-wrapper")
145
- }, /*#__PURE__*/React.createElement(WidthProvider, null, /*#__PURE__*/React.createElement("div", {
146
+ }, jsx(WidthProvider, null, jsx("div", {
146
147
  css: clearNextSiblingMarginTopStyle
147
148
  }), children))));
148
149
  }
@@ -1,4 +1,3 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
3
  import _createClass from "@babel/runtime/helpers/createClass";
@@ -15,7 +14,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
15
14
  import React, { Component } from 'react';
16
15
  import { filter } from '@atlaskit/adf-utils/traverse';
17
16
  import { Card, CardLoading, CardError } from '@atlaskit/media-card';
18
- import { MediaClientContext } from '@atlaskit/media-client-react';
17
+ import { getMediaClient } from '@atlaskit/media-client-react';
19
18
  import { withImageLoader } from '@atlaskit/editor-common/utils';
20
19
  export var mediaIdentifierMap = new Map();
21
20
  export var getListOfIdentifiersFromDoc = function getListOfIdentifiersFromDoc(doc) {
@@ -46,32 +45,29 @@ export var getListOfIdentifiersFromDoc = function getListOfIdentifiersFromDoc(do
46
45
  return identifierList;
47
46
  }, []);
48
47
  };
49
- export var MediaCardView = /*#__PURE__*/function (_Component) {
50
- _inherits(MediaCardView, _Component);
51
- var _super = _createSuper(MediaCardView);
52
- function MediaCardView() {
48
+ export var MediaCardInternal = /*#__PURE__*/function (_Component) {
49
+ _inherits(MediaCardInternal, _Component);
50
+ var _super = _createSuper(MediaCardInternal);
51
+ function MediaCardInternal() {
53
52
  var _this;
54
- _classCallCheck(this, MediaCardView);
53
+ _classCallCheck(this, MediaCardInternal);
55
54
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
56
55
  args[_key] = arguments[_key];
57
56
  }
58
57
  _this = _super.call.apply(_super, [this].concat(args));
59
58
  _defineProperty(_assertThisInitialized(_this), "state", {});
60
59
  _defineProperty(_assertThisInitialized(_this), "saveFileState", /*#__PURE__*/function () {
61
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(id) {
62
- var _this$props, collectionName, mediaClient, options, fileState;
60
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(id, mediaClientConfig) {
61
+ var collectionName, mediaClient, options, fileState;
63
62
  return _regeneratorRuntime.wrap(function _callee$(_context) {
64
63
  while (1) switch (_context.prev = _context.next) {
65
64
  case 0:
66
- _this$props = _this.props, collectionName = _this$props.collection, mediaClient = _this$props.mediaClient;
65
+ collectionName = _this.props.collection;
66
+ mediaClient = getMediaClient(mediaClientConfig);
67
67
  options = {
68
68
  collectionName: collectionName
69
69
  };
70
- _context.prev = 2;
71
- if (!mediaClient) {
72
- _context.next = 8;
73
- break;
74
- }
70
+ _context.prev = 3;
75
71
  _context.next = 6;
76
72
  return mediaClient.file.getCurrentState(id, options);
77
73
  case 6:
@@ -79,19 +75,18 @@ export var MediaCardView = /*#__PURE__*/function (_Component) {
79
75
  _this.setState({
80
76
  fileState: fileState
81
77
  });
82
- case 8:
83
78
  _context.next = 12;
84
79
  break;
85
80
  case 10:
86
81
  _context.prev = 10;
87
- _context.t0 = _context["catch"](2);
82
+ _context.t0 = _context["catch"](3);
88
83
  case 12:
89
84
  case "end":
90
85
  return _context.stop();
91
86
  }
92
- }, _callee, null, [[2, 10]]);
87
+ }, _callee, null, [[3, 10]]);
93
88
  }));
94
- return function (_x) {
89
+ return function (_x, _x2) {
95
90
  return _ref.apply(this, arguments);
96
91
  };
97
92
  }());
@@ -122,29 +117,40 @@ export var MediaCardView = /*#__PURE__*/function (_Component) {
122
117
  });
123
118
  return _this;
124
119
  }
125
- _createClass(MediaCardView, [{
120
+ _createClass(MediaCardInternal, [{
126
121
  key: "componentDidMount",
127
122
  value: function () {
128
123
  var _componentDidMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
129
- var _this$props2, rendererContext, contextIdentifierProvider, id, url, collectionName, nodeIsInCache;
124
+ var _this$props, rendererContext, mediaProvider, contextIdentifierProvider, id, url, collectionName, mediaProviderObject, mediaClientConfig, nodeIsInCache;
130
125
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
131
126
  while (1) switch (_context2.prev = _context2.next) {
132
127
  case 0:
133
- _this$props2 = this.props, rendererContext = _this$props2.rendererContext, contextIdentifierProvider = _this$props2.contextIdentifierProvider, id = _this$props2.id, url = _this$props2.url, collectionName = _this$props2.collection;
128
+ _this$props = this.props, rendererContext = _this$props.rendererContext, mediaProvider = _this$props.mediaProvider, contextIdentifierProvider = _this$props.contextIdentifierProvider, id = _this$props.id, url = _this$props.url, collectionName = _this$props.collection;
129
+ if (mediaProvider) {
130
+ _context2.next = 3;
131
+ break;
132
+ }
133
+ return _context2.abrupt("return");
134
+ case 3:
134
135
  if (!contextIdentifierProvider) {
135
- _context2.next = 8;
136
+ _context2.next = 10;
136
137
  break;
137
138
  }
138
139
  _context2.t0 = this;
139
- _context2.next = 5;
140
+ _context2.next = 7;
140
141
  return contextIdentifierProvider;
141
- case 5:
142
+ case 7:
142
143
  _context2.t1 = _context2.sent;
143
144
  _context2.t2 = {
144
145
  contextIdentifierProvider: _context2.t1
145
146
  };
146
147
  _context2.t0.setState.call(_context2.t0, _context2.t2);
147
- case 8:
148
+ case 10:
149
+ _context2.next = 12;
150
+ return mediaProvider;
151
+ case 12:
152
+ mediaProviderObject = _context2.sent;
153
+ mediaClientConfig = mediaProviderObject.viewMediaClientConfig;
148
154
  nodeIsInCache = id && mediaIdentifierMap.has(id) || url && mediaIdentifierMap.has(url);
149
155
  if (rendererContext && rendererContext.adDoc && !nodeIsInCache) {
150
156
  getListOfIdentifiersFromDoc(rendererContext.adDoc).forEach(function (identifier) {
@@ -157,10 +163,13 @@ export var MediaCardView = /*#__PURE__*/function (_Component) {
157
163
  }
158
164
  });
159
165
  }
166
+ this.setState({
167
+ mediaClientConfig: mediaClientConfig
168
+ });
160
169
  if (id) {
161
- this.saveFileState(id);
170
+ this.saveFileState(id, mediaClientConfig);
162
171
  }
163
- case 11:
172
+ case 18:
164
173
  case "end":
165
174
  return _context2.stop();
166
175
  }
@@ -174,17 +183,18 @@ export var MediaCardView = /*#__PURE__*/function (_Component) {
174
183
  }, {
175
184
  key: "UNSAFE_componentWillReceiveProps",
176
185
  value: function UNSAFE_componentWillReceiveProps(newProps) {
186
+ var mediaClientConfig = this.state.mediaClientConfig;
177
187
  var newId = newProps.id;
178
- if (newId && newId !== this.props.id) {
179
- this.saveFileState(newId);
188
+ if (mediaClientConfig && newId && newId !== this.props.id) {
189
+ this.saveFileState(newId, mediaClientConfig);
180
190
  }
181
191
  }
182
192
  }, {
183
193
  key: "componentWillUnmount",
184
194
  value: function componentWillUnmount() {
185
- var _this$props3 = this.props,
186
- id = _this$props3.id,
187
- dataURI = _this$props3.url;
195
+ var _this$props2 = this.props,
196
+ id = _this$props2.id,
197
+ dataURI = _this$props2.url;
188
198
  if (id) {
189
199
  mediaIdentifierMap.delete(id);
190
200
  } else if (dataURI) {
@@ -194,18 +204,18 @@ export var MediaCardView = /*#__PURE__*/function (_Component) {
194
204
  }, {
195
205
  key: "renderExternal",
196
206
  value: function renderExternal(shouldOpenMediaViewer) {
197
- var _this$props$mediaClie;
198
- var _this$props4 = this.props,
199
- cardDimensions = _this$props4.cardDimensions,
200
- resizeMode = _this$props4.resizeMode,
201
- appearance = _this$props4.appearance,
202
- url = _this$props4.url,
203
- imageStatus = _this$props4.imageStatus,
204
- disableOverlay = _this$props4.disableOverlay,
205
- alt = _this$props4.alt,
206
- featureFlags = _this$props4.featureFlags,
207
- ssr = _this$props4.ssr,
208
- rendererAppearance = _this$props4.rendererAppearance;
207
+ var mediaClientConfig = this.state.mediaClientConfig;
208
+ var _this$props3 = this.props,
209
+ cardDimensions = _this$props3.cardDimensions,
210
+ resizeMode = _this$props3.resizeMode,
211
+ appearance = _this$props3.appearance,
212
+ url = _this$props3.url,
213
+ imageStatus = _this$props3.imageStatus,
214
+ disableOverlay = _this$props3.disableOverlay,
215
+ alt = _this$props3.alt,
216
+ featureFlags = _this$props3.featureFlags,
217
+ ssr = _this$props3.ssr,
218
+ rendererAppearance = _this$props3.rendererAppearance;
209
219
  if (imageStatus === 'loading' || !url) {
210
220
  return this.renderLoadingCard();
211
221
  }
@@ -214,7 +224,6 @@ export var MediaCardView = /*#__PURE__*/function (_Component) {
214
224
  name: url,
215
225
  mediaItemType: 'external-image'
216
226
  };
217
- var mediaClientConfig = (_this$props$mediaClie = this.props.mediaClient) === null || _this$props$mediaClie === void 0 ? void 0 : _this$props$mediaClie.mediaClientConfig;
218
227
  return /*#__PURE__*/React.createElement(Card
219
228
  // TODO MPT-315: clean up after we move mediaClientConfig into FileIdentifier
220
229
  // context is not really used when the type is external and we want to render the component asap
@@ -236,26 +245,26 @@ export var MediaCardView = /*#__PURE__*/function (_Component) {
236
245
  }, {
237
246
  key: "render",
238
247
  value: function render() {
239
- var _this$props$mediaClie2;
240
248
  var _this$state = this.state,
241
249
  contextIdentifierProvider = _this$state.contextIdentifierProvider,
250
+ mediaClientConfigInState = _this$state.mediaClientConfig,
242
251
  fileState = _this$state.fileState;
243
- var _this$props5 = this.props,
244
- id = _this$props5.id,
245
- alt = _this$props5.alt,
246
- type = _this$props5.type,
247
- collection = _this$props5.collection,
248
- occurrenceKey = _this$props5.occurrenceKey,
249
- cardDimensions = _this$props5.cardDimensions,
250
- resizeMode = _this$props5.resizeMode,
251
- rendererAppearance = _this$props5.rendererAppearance,
252
- disableOverlay = _this$props5.disableOverlay,
253
- useInlinePlayer = _this$props5.useInlinePlayer,
254
- originalDimensions = _this$props5.originalDimensions,
255
- forceOpenMediaViewer = _this$props5.shouldOpenMediaViewer,
256
- featureFlags = _this$props5.featureFlags,
257
- shouldEnableDownloadButton = _this$props5.shouldEnableDownloadButton,
258
- ssr = _this$props5.ssr;
252
+ var _this$props4 = this.props,
253
+ id = _this$props4.id,
254
+ alt = _this$props4.alt,
255
+ type = _this$props4.type,
256
+ collection = _this$props4.collection,
257
+ occurrenceKey = _this$props4.occurrenceKey,
258
+ cardDimensions = _this$props4.cardDimensions,
259
+ resizeMode = _this$props4.resizeMode,
260
+ rendererAppearance = _this$props4.rendererAppearance,
261
+ disableOverlay = _this$props4.disableOverlay,
262
+ useInlinePlayer = _this$props4.useInlinePlayer,
263
+ originalDimensions = _this$props4.originalDimensions,
264
+ forceOpenMediaViewer = _this$props4.shouldOpenMediaViewer,
265
+ featureFlags = _this$props4.featureFlags,
266
+ shouldEnableDownloadButton = _this$props4.shouldEnableDownloadButton,
267
+ ssr = _this$props4.ssr;
259
268
  var isMobile = rendererAppearance === 'mobile';
260
269
  var shouldPlayInline = useInlinePlayer !== undefined ? useInlinePlayer : true;
261
270
  var isInlinePlayer = isMobile ? false : shouldPlayInline;
@@ -267,7 +276,7 @@ export var MediaCardView = /*#__PURE__*/function (_Component) {
267
276
  if (type === 'link') {
268
277
  return null;
269
278
  }
270
- var mediaClientConfig = !!ssr ? ssr.config : (_this$props$mediaClie2 = this.props.mediaClient) === null || _this$props$mediaClie2 === void 0 ? void 0 : _this$props$mediaClie2.mediaClientConfig;
279
+ var mediaClientConfig = !!ssr ? ssr.config : mediaClientConfigInState;
271
280
  if (!mediaClientConfig || !id) {
272
281
  return this.renderLoadingCard();
273
282
  }
@@ -311,7 +320,7 @@ export var MediaCardView = /*#__PURE__*/function (_Component) {
311
320
  }));
312
321
  }
313
322
  }]);
314
- return MediaCardView;
323
+ return MediaCardInternal;
315
324
  }(Component);
316
325
  // Needed for copy & paste
317
326
  export var getClipboardAttrs = function getClipboardAttrs(_ref2) {
@@ -346,10 +355,4 @@ export var getClipboardAttrs = function getClipboardAttrs(_ref2) {
346
355
  'data-alt': alt
347
356
  };
348
357
  };
349
- export var MediaCardInternal = function MediaCardInternal(props) {
350
- var mediaClient = React.useContext(MediaClientContext);
351
- return /*#__PURE__*/React.createElement(MediaCardView, _extends({}, props, {
352
- mediaClient: mediaClient
353
- }));
354
- };
355
358
  export var MediaCard = withImageLoader(MediaCardInternal);