@atlaskit/media-card 78.16.1 → 78.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/card/card.js +1 -1
  3. package/dist/cjs/card/cardAnalytics.js +1 -10
  4. package/dist/cjs/card/cardView.js +5 -5
  5. package/dist/cjs/card/externalImageCard.js +14 -36
  6. package/dist/cjs/card/fileCard.js +5 -24
  7. package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
  8. package/dist/cjs/card/ui/actionsBar/styles.js +1 -1
  9. package/dist/cjs/inline/loader.js +1 -1
  10. package/dist/cjs/inline/mediaInlineCard.js +12 -0
  11. package/dist/cjs/utils/analytics/analytics.js +1 -10
  12. package/dist/cjs/utils/analytics/index.js +0 -6
  13. package/dist/cjs/utils/ufoExperiences.js +1 -1
  14. package/dist/es2019/card/card.js +1 -1
  15. package/dist/es2019/card/cardAnalytics.js +1 -10
  16. package/dist/es2019/card/cardView.js +4 -5
  17. package/dist/es2019/card/externalImageCard.js +1 -20
  18. package/dist/es2019/card/fileCard.js +6 -25
  19. package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
  20. package/dist/es2019/card/ui/actionsBar/styles.js +1 -1
  21. package/dist/es2019/inline/loader.js +1 -1
  22. package/dist/es2019/inline/mediaInlineCard.js +13 -0
  23. package/dist/es2019/utils/analytics/analytics.js +0 -7
  24. package/dist/es2019/utils/analytics/index.js +1 -1
  25. package/dist/es2019/utils/ufoExperiences.js +1 -1
  26. package/dist/esm/card/card.js +1 -1
  27. package/dist/esm/card/cardAnalytics.js +1 -10
  28. package/dist/esm/card/cardView.js +5 -5
  29. package/dist/esm/card/externalImageCard.js +15 -37
  30. package/dist/esm/card/fileCard.js +6 -25
  31. package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
  32. package/dist/esm/card/ui/actionsBar/styles.js +1 -1
  33. package/dist/esm/inline/loader.js +1 -1
  34. package/dist/esm/inline/mediaInlineCard.js +12 -0
  35. package/dist/esm/utils/analytics/analytics.js +0 -9
  36. package/dist/esm/utils/analytics/index.js +1 -1
  37. package/dist/esm/utils/ufoExperiences.js +1 -1
  38. package/dist/types/card/cardAnalytics.d.ts +0 -1
  39. package/dist/types/card/cardView.d.ts +1 -1
  40. package/dist/types/utils/analytics/analytics.d.ts +0 -1
  41. package/dist/types/utils/analytics/index.d.ts +1 -1
  42. package/dist/types-ts4.5/card/cardAnalytics.d.ts +0 -1
  43. package/dist/types-ts4.5/card/cardView.d.ts +1 -1
  44. package/dist/types-ts4.5/utils/analytics/analytics.d.ts +0 -1
  45. package/dist/types-ts4.5/utils/analytics/index.d.ts +1 -1
  46. package/package.json +6 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @atlaskit/media-card
2
2
 
3
+ ## 78.17.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#98553](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/98553)
8
+ [`d3cdb7e8e6bfb`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d3cdb7e8e6bfb) -
9
+ Fixed Media Card Actions click through. Media Viewer opens correctly
10
+
11
+ ## 78.17.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [#98696](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/98696)
16
+ [`396ff0958321d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/396ff0958321d) -
17
+ Adding the ability to register copy intents to enable cross site / product copy and paste for
18
+ media by forwarding the ref from useCopyIntent / useFilePreview
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies
23
+
3
24
  ## 78.16.1
4
25
 
5
26
  ### Patch Changes
@@ -21,7 +21,7 @@ var _excluded = ["identifier"];
21
21
  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); }
22
22
  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; }
23
23
  var packageName = "@atlaskit/media-card";
24
- var packageVersion = "78.16.1";
24
+ var packageVersion = "78.17.1";
25
25
  var CardBase = exports.CardBase = function CardBase(_ref) {
26
26
  var identifier = _ref.identifier,
27
27
  otherProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.fireScreenEvent = exports.fireOperationalEvent = exports.fireNonCriticalErrorEvent = exports.fireDownloadSucceededEvent = exports.fireDownloadFailedEvent = exports.fireCopiedEvent = void 0;
6
+ exports.fireScreenEvent = exports.fireOperationalEvent = exports.fireNonCriticalErrorEvent = exports.fireDownloadSucceededEvent = exports.fireDownloadFailedEvent = void 0;
7
7
  var _analytics = require("../utils/analytics");
8
8
  var _errors = require("../errors");
9
9
  var fireOperationalEvent = exports.fireOperationalEvent = function fireOperationalEvent(createAnalyticsEvent, status, fileAttributes, performanceAttributes, ssrReliability) {
@@ -25,15 +25,6 @@ var fireOperationalEvent = exports.fireOperationalEvent = function fireOperation
25
25
  break;
26
26
  }
27
27
  };
28
- var fireCopiedEvent = exports.fireCopiedEvent = function fireCopiedEvent(createAnalyticsEvent, fileId, cardRef) {
29
- if (typeof window.getSelection === 'function') {
30
- var _selection$containsNo;
31
- var selection = window.getSelection();
32
- if (selection !== null && selection !== void 0 && (_selection$containsNo = selection.containsNode) !== null && _selection$containsNo !== void 0 && _selection$containsNo.call(selection, cardRef, true)) {
33
- (0, _analytics.fireMediaCardEvent)((0, _analytics.getCopiedFilePayload)(fileId), createAnalyticsEvent);
34
- }
35
- }
36
- };
37
28
  var fireScreenEvent = exports.fireScreenEvent = function fireScreenEvent(createAnalyticsEvent, fileAttributes) {
38
29
  (0, _analytics.fireMediaCardEvent)((0, _analytics.getRenderPreviewableCardPayload)(fileAttributes), createAnalyticsEvent);
39
30
  };
@@ -14,6 +14,7 @@ var _analyticsNext = require("@atlaskit/analytics-next");
14
14
  var _mimeTypeIcon = require("@atlaskit/media-ui/mime-type-icon");
15
15
  var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
16
16
  var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
17
+ var _useCallbackRef = require("use-callback-ref");
17
18
  var _mediaUi = require("@atlaskit/media-ui");
18
19
  var _analytics = require("../utils/analytics");
19
20
  var _imageRenderer = require("./ui/imageRenderer/imageRenderer");
@@ -42,7 +43,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
42
43
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
43
44
  var CardViewBase = exports.CardViewBase = function CardViewBase(_ref) {
44
45
  var identifier = _ref.identifier,
45
- innerRef = _ref.innerRef,
46
+ _ref$innerRef = _ref.innerRef,
47
+ innerRef = _ref$innerRef === void 0 ? null : _ref$innerRef,
46
48
  onImageLoad = _ref.onImageLoad,
47
49
  onImageError = _ref.onImageError,
48
50
  dimensions = _ref.dimensions,
@@ -85,9 +87,6 @@ var CardViewBase = exports.CardViewBase = function CardViewBase(_ref) {
85
87
  var divRef = (0, _react2.useRef)(null);
86
88
  var prevCardPreviewRef = (0, _react2.useRef)();
87
89
  var breakpoint = (0, _useBreakpoint.useBreakpoint)(dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, divRef);
88
- (0, _react2.useEffect)(function () {
89
- innerRef && !!divRef.current && innerRef(divRef.current);
90
- }, [innerRef]);
91
90
  (0, _react2.useEffect)(function () {
92
91
  // We should only switch didImageRender to false when cardPreview goes undefined, not when it is changed. as this method could be triggered after onImageLoad callback, falling on a race condition
93
92
  if (prevCardPreviewRef.current && !cardPreview) {
@@ -123,6 +122,7 @@ var CardViewBase = exports.CardViewBase = function CardViewBase(_ref) {
123
122
  }
124
123
  return true;
125
124
  };
125
+ var mergedRef = (0, _useCallbackRef.useMergeRefs)([divRef, innerRef]);
126
126
  var getRenderConfigByStatus = function getRenderConfigByStatus() {
127
127
  var _ref3 = metadata || {},
128
128
  name = _ref3.name,
@@ -320,7 +320,7 @@ var CardViewBase = exports.CardViewBase = function CardViewBase(_ref) {
320
320
  dimensions: dimensions,
321
321
  onClick: onClick,
322
322
  onMouseEnter: onMouseEnter,
323
- innerRef: divRef,
323
+ innerRef: mergedRef,
324
324
  breakpoint: breakpoint,
325
325
  mediaCardCursor: mediaCardCursor,
326
326
  disableOverlay: !!disableOverlay,
@@ -15,7 +15,6 @@ var _mediaViewer = require("@atlaskit/media-viewer");
15
15
  var _react = _interopRequireWildcard(require("react"));
16
16
  var _reactDom = _interopRequireDefault(require("react-dom"));
17
17
  var _errors = require("../errors");
18
- var _document = _interopRequireDefault(require("../utils/document"));
19
18
  var _generateUniqueId = require("../utils/generateUniqueId");
20
19
  var _getMediaCardCursor = require("../utils/getMediaCardCursor");
21
20
  var _ufoExperiences = require("../utils/ufoExperiences");
@@ -70,10 +69,6 @@ var ExternalImageCard = exports.ExternalImageCard = function ExternalImageCard(_
70
69
  traceId: (0, _mediaCommon.getRandomHex)(8)
71
70
  };
72
71
  }, []);
73
- var _useState = (0, _react.useState)(null),
74
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
75
- cardElement = _useState2[0],
76
- setCardElement = _useState2[1];
77
72
  var fileStateFlagsRef = (0, _react.useRef)({
78
73
  wasStatusUploading: false,
79
74
  wasStatusProcessing: false
@@ -81,10 +76,10 @@ var ExternalImageCard = exports.ExternalImageCard = function ExternalImageCard(_
81
76
  var startUfoExperienceRef = (0, _useCurrentValueRef.useCurrentValueRef)(function () {
82
77
  (0, _ufoExperiences.startUfoExperience)(internalOccurrenceKey);
83
78
  });
84
- var _useState3 = (0, _react.useState)('loading-preview'),
85
- _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
86
- status = _useState4[0],
87
- setStatus = _useState4[1];
79
+ var _useState = (0, _react.useState)('loading-preview'),
80
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
81
+ status = _useState2[0],
82
+ setStatus = _useState2[1];
88
83
  var cardPreview = (0, _react.useMemo)(function () {
89
84
  return {
90
85
  dataURI: identifier.dataURI,
@@ -111,18 +106,18 @@ var ExternalImageCard = exports.ExternalImageCard = function ExternalImageCard(_
111
106
  status: 'unknown'
112
107
  }
113
108
  };
114
- var _useState5 = (0, _react.useState)(false),
109
+ var _useState3 = (0, _react.useState)(false),
110
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
111
+ previewDidRender = _useState4[0],
112
+ setPreviewDidRender = _useState4[1];
113
+ var _useState5 = (0, _react.useState)(),
115
114
  _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
116
- previewDidRender = _useState6[0],
117
- setPreviewDidRender = _useState6[1];
118
- var _useState7 = (0, _react.useState)(),
115
+ error = _useState6[0],
116
+ setError = _useState6[1];
117
+ var _useState7 = (0, _react.useState)(null),
119
118
  _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
120
- error = _useState8[0],
121
- setError = _useState8[1];
122
- var _useState9 = (0, _react.useState)(null),
123
- _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
124
- mediaViewerSelectedItem = _useState10[0],
125
- setMediaViewerSelectedItem = _useState10[1];
119
+ mediaViewerSelectedItem = _useState8[0],
120
+ setMediaViewerSelectedItem = _useState8[1];
126
121
 
127
122
  //----------------------------------------------------------------//
128
123
  //---------------------- Analytics ------------------------------//
@@ -159,22 +154,6 @@ var ExternalImageCard = exports.ExternalImageCard = function ExternalImageCard(_
159
154
  (0, _react.useEffect)(function () {
160
155
  startUfoExperienceRef.current();
161
156
  }, [startUfoExperienceRef]);
162
- (0, _react.useEffect)(function () {
163
- var _getDocument;
164
- var fireCopiedCardEvent = function fireCopiedCardEvent() {
165
- cardElement && createAnalyticsEvent && (0, _cardAnalytics.fireCopiedEvent)(createAnalyticsEvent, metadata.id, cardElement);
166
- };
167
-
168
- // we add a listener for each of the cards on the page
169
- // and then check if the triggered listener is from the card
170
- // that contains a div in current window.getSelection()
171
- // won't work in IE11
172
- (_getDocument = (0, _document.default)()) === null || _getDocument === void 0 || _getDocument.addEventListener('copy', fireCopiedCardEvent);
173
- return function () {
174
- var _getDocument2;
175
- (_getDocument2 = (0, _document.default)()) === null || _getDocument2 === void 0 || _getDocument2.removeEventListener('copy', fireCopiedCardEvent);
176
- };
177
- }, [cardElement, createAnalyticsEvent, metadata.id]);
178
157
  var prevStatus = (0, _usePrevious.usePrevious)(status);
179
158
  (0, _react.useEffect)(function () {
180
159
  if (prevStatus !== undefined && status !== prevStatus) {
@@ -270,7 +249,6 @@ var ExternalImageCard = exports.ExternalImageCard = function ExternalImageCard(_
270
249
  viewingLevel: 'minimal'
271
250
  }, payloadPart));
272
251
  },
273
- innerRef: setCardElement,
274
252
  testId: testId,
275
253
  titleBoxBgColor: titleBoxBgColor,
276
254
  titleBoxIcon: titleBoxIcon,
@@ -18,9 +18,9 @@ var _mediaCommon = require("@atlaskit/media-common");
18
18
  var _mediaViewer = require("@atlaskit/media-viewer");
19
19
  var _react = _interopRequireWildcard(require("react"));
20
20
  var _reactDom = _interopRequireDefault(require("react-dom"));
21
+ var _useCallbackRef = require("use-callback-ref");
21
22
  var _errors = require("../errors");
22
23
  var _types = require("../types");
23
- var _document = _interopRequireDefault(require("../utils/document"));
24
24
  var _generateUniqueId = require("../utils/generateUniqueId");
25
25
  var _getDataURIDimension = require("../utils/getDataURIDimension");
26
26
  var _getMediaCardCursor = require("../utils/getMediaCardCursor");
@@ -197,7 +197,8 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
197
197
  ssrReliability = _useFilePreview.ssrReliability,
198
198
  onImageErrorBase = _useFilePreview.onImageError,
199
199
  onImageLoadBase = _useFilePreview.onImageLoad,
200
- getSsrScriptProps = _useFilePreview.getSsrScriptProps;
200
+ getSsrScriptProps = _useFilePreview.getSsrScriptProps,
201
+ copyNodeRef = _useFilePreview.copyNodeRef;
201
202
  var _useState13 = (0, _react.useState)(),
202
203
  _useState14 = (0, _slicedToArray2.default)(_useState13, 2),
203
204
  error = _useState14[0],
@@ -394,27 +395,6 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
394
395
  }
395
396
  };
396
397
 
397
- //----------------------------------------------------------------//
398
- //------------------------ handle fireCopiedEvent --------------//
399
- //----------------------------------------------------------------//
400
-
401
- (0, _react.useEffect)(function () {
402
- var _getDocument;
403
- var fireCopiedCardEvent = function fireCopiedCardEvent() {
404
- cardElement && createAnalyticsEvent && (0, _cardAnalytics.fireCopiedEvent)(createAnalyticsEvent, metadata.id, cardElement);
405
- };
406
-
407
- // we add a listener for each of the cards on the page
408
- // and then check if the triggered listener is from the card
409
- // that contains a div in current window.getSelection()
410
- // won't work in IE11
411
- (_getDocument = (0, _document.default)()) === null || _getDocument === void 0 || _getDocument.addEventListener('copy', fireCopiedCardEvent);
412
- return function () {
413
- var _getDocument2;
414
- (_getDocument2 = (0, _document.default)()) === null || _getDocument2 === void 0 || _getDocument2.removeEventListener('copy', fireCopiedCardEvent);
415
- };
416
- }, [cardElement, createAnalyticsEvent, metadata.id]);
417
-
418
398
  //----------------------------------------------------------------//
419
399
  //----------------- update status flags --------------------------//
420
400
  //----------------------------------------------------------------//
@@ -535,6 +515,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
535
515
  }
536
516
  }
537
517
  });
518
+ var mergedRef = (0, _useCallbackRef.useMergeRefs)([setCardElement, copyNodeRef]);
538
519
  (0, _react.useEffect)(function () {
539
520
  updateFileStateRef.current();
540
521
  }, [fileState, preview, previewStatus, updateFileStateRef, previewDidRender, finalStatus]);
@@ -598,7 +579,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
598
579
  viewingLevel: 'minimal'
599
580
  }, payloadPart));
600
581
  } : undefined,
601
- innerRef: setCardElement,
582
+ innerRef: mergedRef,
602
583
  testId: testId,
603
584
  titleBoxBgColor: titleBoxBgColor,
604
585
  titleBoxIcon: titleBoxIcon,
@@ -87,7 +87,7 @@ var WrappedMediaCardAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Compo
87
87
  }(_react.default.Component);
88
88
  (0, _defineProperty2.default)(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
89
89
  var packageName = "@atlaskit/media-card";
90
- var packageVersion = "78.16.1";
90
+ var packageVersion = "78.17.1";
91
91
 
92
92
  // @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
93
93
  var MediaCardAnalyticsErrorBoundary = (0, _mediaCommon.withMediaAnalyticsContext)({
@@ -16,10 +16,10 @@ var wrapperStyles = exports.wrapperStyles = function wrapperStyles(isFixed) {
16
16
  (0, _react.css)(isFixed ? fixedActionBarStyles : 'opacity: 0;', (0, _styles.transition)(), {
17
17
  position: 'absolute',
18
18
  top: 0,
19
+ right: 0,
19
20
  display: 'flex',
20
21
  flexFlow: 'row nowrap',
21
22
  justifyContent: 'right',
22
- width: '100%',
23
23
  padding: "var(--ds-space-100, 8px)",
24
24
  gap: "var(--ds-space-100, 8px)"
25
25
  })
@@ -117,7 +117,7 @@ var MediaInlineCardLoader = exports.default = /*#__PURE__*/function (_React$Pure
117
117
  ErrorBoundary = _this$state.ErrorBoundary;
118
118
  var analyticsContext = {
119
119
  packageVersion: "@atlaskit/media-card",
120
- packageName: "78.16.1",
120
+ packageName: "78.17.1",
121
121
  componentName: 'mediaInlineCard',
122
122
  component: 'mediaInlineCard'
123
123
  };
@@ -20,6 +20,7 @@ var _reactIntlNext = require("react-intl-next");
20
20
  var _errors = require("../errors");
21
21
  var _analytics = require("../utils/analytics");
22
22
  var _mediaInlineCardAnalytics = require("./mediaInlineCardAnalytics");
23
+ var _mediaClientReact = require("@atlaskit/media-client-react");
23
24
  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); }
24
25
  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; }
25
26
  // UI component which renders an inline link in the appropiate state based on a media file
@@ -67,6 +68,10 @@ var MediaInlineCardInternal = exports.MediaInlineCardInternal = function MediaIn
67
68
  setIsSucceededEventSent(true);
68
69
  (0, _analytics.fireMediaCardEvent)(payload, createAnalyticsEvent);
69
70
  };
71
+ var _useCopyIntent = (0, _mediaClientReact.useCopyIntent)(identifier.id, {
72
+ collectionName: identifier.collectionName
73
+ }),
74
+ copyNodeRef = _useCopyIntent.copyNodeRef;
70
75
  var onMediaInlineCardClick = function onMediaInlineCardClick(event) {
71
76
  if (onClick) {
72
77
  var inlineCardEvent = {
@@ -124,6 +129,7 @@ var MediaInlineCardInternal = exports.MediaInlineCardInternal = function MediaIn
124
129
  var errorReason = (fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'uploading' ? 'upload' : 'metadata-fetch';
125
130
  !isFailedEventSent && fireFailedOperationalEvent(new _errors.MediaCardError(errorReason, subscribeError));
126
131
  return /*#__PURE__*/_react.default.createElement(_mediaUi.MediaInlineCardErroredView, {
132
+ innerRef: copyNodeRef,
127
133
  message: (intl || defaultIntl).formatMessage(errorMessage),
128
134
  isSelected: isSelected
129
135
  });
@@ -132,6 +138,7 @@ var MediaInlineCardInternal = exports.MediaInlineCardInternal = function MediaIn
132
138
  var error = new _errors.MediaCardError('error-file-state', new Error(fileState.message));
133
139
  !isFailedEventSent && fireFailedOperationalEvent(error);
134
140
  return /*#__PURE__*/_react.default.createElement(_mediaUi.MediaInlineCardErroredView, {
141
+ innerRef: copyNodeRef,
135
142
  message: (intl || defaultIntl).formatMessage(_mediaUi.messages.couldnt_load_file),
136
143
  isSelected: isSelected
137
144
  });
@@ -142,18 +149,21 @@ var MediaInlineCardInternal = exports.MediaInlineCardInternal = function MediaIn
142
149
  var _error = new _errors.MediaCardError('metadata-fetch', new _mediaClient.FileFetcherError('emptyFileName', fileState.id));
143
150
  !isFailedEventSent && fireFailedOperationalEvent(_error);
144
151
  return /*#__PURE__*/_react.default.createElement(_mediaUi.MediaInlineCardErroredView, {
152
+ innerRef: copyNodeRef,
145
153
  message: (intl || defaultIntl).formatMessage(_mediaUi.messages.couldnt_load_file),
146
154
  isSelected: isSelected
147
155
  });
148
156
  }
149
157
  if ((fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'uploading') {
150
158
  return /*#__PURE__*/_react.default.createElement(_mediaUi.MediaInlineCardLoadingView, {
159
+ innerRef: copyNodeRef,
151
160
  message: fileState.name,
152
161
  isSelected: isSelected
153
162
  });
154
163
  }
155
164
  if (!fileState) {
156
165
  return /*#__PURE__*/_react.default.createElement(_mediaUi.MediaInlineCardLoadingView, {
166
+ innerRef: copyNodeRef,
157
167
  message: (intl || defaultIntl).formatMessage(_mediaUi.messages.loading_file),
158
168
  isSelected: isSelected
159
169
  });
@@ -192,6 +202,7 @@ var MediaInlineCardInternal = exports.MediaInlineCardInternal = function MediaIn
192
202
  content: formattedDate,
193
203
  tag: "span"
194
204
  }, /*#__PURE__*/_react.default.createElement(_mediaUi.MediaInlineCardLoadedView, {
205
+ innerRef: copyNodeRef,
195
206
  icon: linkIcon,
196
207
  title: name,
197
208
  onClick: onMediaInlineCardClick,
@@ -199,6 +210,7 @@ var MediaInlineCardInternal = exports.MediaInlineCardInternal = function MediaIn
199
210
  })), mediaViewer));
200
211
  } else {
201
212
  return renderContent( /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_mediaUi.MediaInlineCardLoadedView, {
213
+ innerRef: copyNodeRef,
202
214
  icon: linkIcon,
203
215
  title: name,
204
216
  onClick: onMediaInlineCardClick,
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.extractErrorInfo = exports.createAndFireMediaCardEvent = void 0;
8
8
  exports.fireMediaCardEvent = fireMediaCardEvent;
9
- exports.getRenderSucceededEventPayload = exports.getRenderPreviewableCardPayload = exports.getRenderFailedFileStatusPayload = exports.getRenderFailedExternalUriPayload = exports.getRenderErrorRequestMetadata = exports.getRenderErrorFailReason = exports.getRenderErrorEventPayload = exports.getRenderErrorErrorReason = exports.getRenderErrorErrorDetail = exports.getRemoteSuccessEventPayload = exports.getFileAttributes = exports.getErrorTraceContext = exports.getErrorEventPayload = exports.getDownloadSucceededEventPayload = exports.getDownloadFailedEventPayload = exports.getCopiedFilePayload = exports.getCacheHitEventPayload = void 0;
9
+ exports.getRenderSucceededEventPayload = exports.getRenderPreviewableCardPayload = exports.getRenderFailedFileStatusPayload = exports.getRenderFailedExternalUriPayload = exports.getRenderErrorRequestMetadata = exports.getRenderErrorFailReason = exports.getRenderErrorEventPayload = exports.getRenderErrorErrorReason = exports.getRenderErrorErrorDetail = exports.getRemoteSuccessEventPayload = exports.getFileAttributes = exports.getErrorTraceContext = exports.getErrorEventPayload = exports.getDownloadSucceededEventPayload = exports.getDownloadFailedEventPayload = exports.getCacheHitEventPayload = void 0;
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _mediaClient = require("@atlaskit/media-client");
12
12
  var _mediaClientReact = require("@atlaskit/media-client-react");
@@ -216,15 +216,6 @@ var getRenderFailedFileStatusPayload = exports.getRenderFailedFileStatusPayload
216
216
  }
217
217
  };
218
218
  };
219
- var getCopiedFilePayload = exports.getCopiedFilePayload = function getCopiedFilePayload(fileId) {
220
- return {
221
- eventType: 'ui',
222
- action: 'copied',
223
- actionSubject: 'file',
224
- actionSubjectId: fileId,
225
- attributes: {}
226
- };
227
- };
228
219
  function fireMediaCardEvent(payload, createAnalyticsEvent) {
229
220
  if (createAnalyticsEvent) {
230
221
  var event = createAnalyticsEvent((0, _analytics.sanitiseAnalyticsPayload)(payload));
@@ -27,12 +27,6 @@ Object.defineProperty(exports, "getCacheHitEventPayload", {
27
27
  return _analytics.getCacheHitEventPayload;
28
28
  }
29
29
  });
30
- Object.defineProperty(exports, "getCopiedFilePayload", {
31
- enumerable: true,
32
- get: function get() {
33
- return _analytics.getCopiedFilePayload;
34
- }
35
- });
36
30
  Object.defineProperty(exports, "getDownloadFailedEventPayload", {
37
31
  enumerable: true,
38
32
  get: function get() {
@@ -15,7 +15,7 @@ var _mediaClient = require("@atlaskit/media-client");
15
15
  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; }
16
16
  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; }
17
17
  var packageName = "@atlaskit/media-card";
18
- var packageVersion = "78.16.1";
18
+ var packageVersion = "78.17.1";
19
19
  var concurrentExperience;
20
20
  var getExperience = function getExperience(id) {
21
21
  if (!concurrentExperience) {
@@ -9,7 +9,7 @@ import { startResourceObserver, setAnalyticsContext } from '../utils/mediaPerfor
9
9
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
10
10
  import UFOLabel from '@atlaskit/react-ufo/label';
11
11
  const packageName = "@atlaskit/media-card";
12
- const packageVersion = "78.16.1";
12
+ const packageVersion = "78.17.1";
13
13
  export const CardBase = ({
14
14
  identifier,
15
15
  ...otherProps
@@ -1,4 +1,4 @@
1
- import { fireMediaCardEvent, getRenderSucceededEventPayload, getRenderErrorEventPayload, getRenderFailedFileStatusPayload, getCopiedFilePayload, getRenderPreviewableCardPayload, getErrorEventPayload, getDownloadSucceededEventPayload, getDownloadFailedEventPayload } from '../utils/analytics';
1
+ import { fireMediaCardEvent, getRenderSucceededEventPayload, getRenderErrorEventPayload, getRenderFailedFileStatusPayload, getRenderPreviewableCardPayload, getErrorEventPayload, getDownloadSucceededEventPayload, getDownloadFailedEventPayload } from '../utils/analytics';
2
2
  import { MediaCardError } from '../errors';
3
3
  export const fireOperationalEvent = (createAnalyticsEvent, status, fileAttributes, performanceAttributes, ssrReliability, error = new MediaCardError('missing-error-data'), traceContext, metadataTraceContext) => {
4
4
  const fireEvent = payload => fireMediaCardEvent(payload, createAnalyticsEvent);
@@ -14,15 +14,6 @@ export const fireOperationalEvent = (createAnalyticsEvent, status, fileAttribute
14
14
  break;
15
15
  }
16
16
  };
17
- export const fireCopiedEvent = (createAnalyticsEvent, fileId, cardRef) => {
18
- if (typeof window.getSelection === 'function') {
19
- var _selection$containsNo;
20
- const selection = window.getSelection();
21
- if (selection !== null && selection !== void 0 && (_selection$containsNo = selection.containsNode) !== null && _selection$containsNo !== void 0 && _selection$containsNo.call(selection, cardRef, true)) {
22
- fireMediaCardEvent(getCopiedFilePayload(fileId), createAnalyticsEvent);
23
- }
24
- }
25
- };
26
17
  export const fireScreenEvent = (createAnalyticsEvent, fileAttributes) => {
27
18
  fireMediaCardEvent(getRenderPreviewableCardPayload(fileAttributes), createAnalyticsEvent);
28
19
  };
@@ -9,6 +9,7 @@ import { withAnalyticsEvents } from '@atlaskit/analytics-next';
9
9
  import { MimeTypeIcon } from '@atlaskit/media-ui/mime-type-icon';
10
10
  import SpinnerIcon from '@atlaskit/spinner';
11
11
  import Tooltip from '@atlaskit/tooltip';
12
+ import { useMergeRefs } from 'use-callback-ref';
12
13
  import { messages } from '@atlaskit/media-ui';
13
14
  import { createAndFireMediaCardEvent } from '../utils/analytics';
14
15
  import { ImageRenderer } from './ui/imageRenderer/imageRenderer';
@@ -30,7 +31,7 @@ import { useCurrentValueRef } from '../utils/useCurrentValueRef';
30
31
  import { SvgView } from './svgView';
31
32
  export const CardViewBase = ({
32
33
  identifier,
33
- innerRef,
34
+ innerRef = null,
34
35
  onImageLoad,
35
36
  onImageError,
36
37
  dimensions,
@@ -67,9 +68,6 @@ export const CardViewBase = ({
67
68
  const divRef = useRef(null);
68
69
  const prevCardPreviewRef = useRef();
69
70
  const breakpoint = useBreakpoint(dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, divRef);
70
- useEffect(() => {
71
- innerRef && !!divRef.current && innerRef(divRef.current);
72
- }, [innerRef]);
73
71
  useEffect(() => {
74
72
  // We should only switch didImageRender to false when cardPreview goes undefined, not when it is changed. as this method could be triggered after onImageLoad callback, falling on a race condition
75
73
  if (prevCardPreviewRef.current && !cardPreview) {
@@ -106,6 +104,7 @@ export const CardViewBase = ({
106
104
  }
107
105
  return true;
108
106
  };
107
+ const mergedRef = useMergeRefs([divRef, innerRef]);
109
108
  const getRenderConfigByStatus = () => {
110
109
  const {
111
110
  name,
@@ -311,7 +310,7 @@ export const CardViewBase = ({
311
310
  dimensions: dimensions,
312
311
  onClick: onClick,
313
312
  onMouseEnter: onMouseEnter,
314
- innerRef: divRef,
313
+ innerRef: mergedRef,
315
314
  breakpoint: breakpoint,
316
315
  mediaCardCursor: mediaCardCursor,
317
316
  disableOverlay: !!disableOverlay,
@@ -5,14 +5,13 @@ import { MediaViewer } from '@atlaskit/media-viewer';
5
5
  import React, { useEffect, useMemo, useRef, useState } from 'react';
6
6
  import ReactDOM from 'react-dom';
7
7
  import { ImageLoadError } from '../errors';
8
- import getDocument from '../utils/document';
9
8
  import { generateUniqueId } from '../utils/generateUniqueId';
10
9
  import { getMediaCardCursor } from '../utils/getMediaCardCursor';
11
10
  import { abortUfoExperience, completeUfoExperience, startUfoExperience } from '../utils/ufoExperiences';
12
11
  import { useCurrentValueRef } from '../utils/useCurrentValueRef';
13
12
  import { getDefaultCardDimensions } from '../utils/cardDimensions';
14
13
  import { usePrevious } from '../utils/usePrevious';
15
- import { fireCopiedEvent, fireOperationalEvent, fireScreenEvent } from './cardAnalytics';
14
+ import { fireOperationalEvent, fireScreenEvent } from './cardAnalytics';
16
15
  import { CardView } from './cardView';
17
16
  import { performanceNow } from './performance';
18
17
  export const ExternalImageCard = ({
@@ -49,7 +48,6 @@ export const ExternalImageCard = ({
49
48
  const traceContext = useMemo(() => ({
50
49
  traceId: getRandomHex(8)
51
50
  }), []);
52
- const [cardElement, setCardElement] = useState(null);
53
51
  const fileStateFlagsRef = useRef({
54
52
  wasStatusUploading: false,
55
53
  wasStatusProcessing: false
@@ -121,22 +119,6 @@ export const ExternalImageCard = ({
121
119
  useEffect(() => {
122
120
  startUfoExperienceRef.current();
123
121
  }, [startUfoExperienceRef]);
124
- useEffect(() => {
125
- var _getDocument;
126
- const fireCopiedCardEvent = () => {
127
- cardElement && createAnalyticsEvent && fireCopiedEvent(createAnalyticsEvent, metadata.id, cardElement);
128
- };
129
-
130
- // we add a listener for each of the cards on the page
131
- // and then check if the triggered listener is from the card
132
- // that contains a div in current window.getSelection()
133
- // won't work in IE11
134
- (_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.addEventListener('copy', fireCopiedCardEvent);
135
- return () => {
136
- var _getDocument2;
137
- (_getDocument2 = getDocument()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.removeEventListener('copy', fireCopiedCardEvent);
138
- };
139
- }, [cardElement, createAnalyticsEvent, metadata.id]);
140
122
  const prevStatus = usePrevious(status);
141
123
  useEffect(() => {
142
124
  if (prevStatus !== undefined && status !== prevStatus) {
@@ -233,7 +215,6 @@ export const ExternalImageCard = ({
233
215
  ...payloadPart
234
216
  });
235
217
  },
236
- innerRef: setCardElement,
237
218
  testId: testId,
238
219
  titleBoxBgColor: titleBoxBgColor,
239
220
  titleBoxIcon: titleBoxIcon,
@@ -5,9 +5,9 @@ import { getRandomHex, isMimeTypeSupportedByBrowser, isVideoMimeTypeSupportedByB
5
5
  import { MediaViewer } from '@atlaskit/media-viewer';
6
6
  import React, { Suspense, useEffect, useMemo, useRef, useState } from 'react';
7
7
  import ReactDOM from 'react-dom';
8
+ import { useMergeRefs } from 'use-callback-ref';
8
9
  import { MediaCardError } from '../errors';
9
10
  import { isSSRPreview } from '../types';
10
- import getDocument from '../utils/document';
11
11
  import { generateUniqueId } from '../utils/generateUniqueId';
12
12
  import { resolveCardPreviewDimensions } from '../utils/getDataURIDimension';
13
13
  import { getMediaCardCursor } from '../utils/getMediaCardCursor';
@@ -17,7 +17,7 @@ import { useCurrentValueRef } from '../utils/useCurrentValueRef';
17
17
  import { usePrevious } from '../utils/usePrevious';
18
18
  import { ViewportDetector } from '../utils/viewportDetector';
19
19
  import { getDefaultCardDimensions } from '../utils/cardDimensions';
20
- import { fireCopiedEvent, fireNonCriticalErrorEvent, fireOperationalEvent, fireScreenEvent, fireDownloadSucceededEvent, fireDownloadFailedEvent } from './cardAnalytics';
20
+ import { fireNonCriticalErrorEvent, fireOperationalEvent, fireScreenEvent, fireDownloadSucceededEvent, fireDownloadFailedEvent } from './cardAnalytics';
21
21
  import { CardView } from './cardView';
22
22
  import { InlinePlayerLazy } from './inlinePlayerLazy';
23
23
  import { useFilePreview } from '@atlaskit/media-file-preview';
@@ -148,7 +148,8 @@ export const FileCard = ({
148
148
  ssrReliability,
149
149
  onImageError: onImageErrorBase,
150
150
  onImageLoad: onImageLoadBase,
151
- getSsrScriptProps
151
+ getSsrScriptProps,
152
+ copyNodeRef
152
153
  } = useFilePreview({
153
154
  mediaBlobUrlAttrs,
154
155
  resizeMode: imageResizeModeToFileImageMode(resizeMode),
@@ -330,27 +331,6 @@ export const FileCard = ({
330
331
  }
331
332
  };
332
333
 
333
- //----------------------------------------------------------------//
334
- //------------------------ handle fireCopiedEvent --------------//
335
- //----------------------------------------------------------------//
336
-
337
- useEffect(() => {
338
- var _getDocument;
339
- const fireCopiedCardEvent = () => {
340
- cardElement && createAnalyticsEvent && fireCopiedEvent(createAnalyticsEvent, metadata.id, cardElement);
341
- };
342
-
343
- // we add a listener for each of the cards on the page
344
- // and then check if the triggered listener is from the card
345
- // that contains a div in current window.getSelection()
346
- // won't work in IE11
347
- (_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.addEventListener('copy', fireCopiedCardEvent);
348
- return () => {
349
- var _getDocument2;
350
- (_getDocument2 = getDocument()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.removeEventListener('copy', fireCopiedCardEvent);
351
- };
352
- }, [cardElement, createAnalyticsEvent, metadata.id]);
353
-
354
334
  //----------------------------------------------------------------//
355
335
  //----------------- update status flags --------------------------//
356
336
  //----------------------------------------------------------------//
@@ -472,6 +452,7 @@ export const FileCard = ({
472
452
  }
473
453
  }
474
454
  });
455
+ const mergedRef = useMergeRefs([setCardElement, copyNodeRef]);
475
456
  useEffect(() => {
476
457
  updateFileStateRef.current();
477
458
  }, [fileState, preview, previewStatus, updateFileStateRef, previewDidRender, finalStatus]);
@@ -535,7 +516,7 @@ export const FileCard = ({
535
516
  ...payloadPart
536
517
  });
537
518
  } : undefined,
538
- innerRef: setCardElement,
519
+ innerRef: mergedRef,
539
520
  testId: testId,
540
521
  titleBoxBgColor: titleBoxBgColor,
541
522
  titleBoxIcon: titleBoxIcon,
@@ -66,7 +66,7 @@ class WrappedMediaCardAnalyticsErrorBoundary extends React.Component {
66
66
  }
67
67
  _defineProperty(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
68
68
  const packageName = "@atlaskit/media-card";
69
- const packageVersion = "78.16.1";
69
+ const packageVersion = "78.17.1";
70
70
 
71
71
  // @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
72
72
  const MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({