@atlaskit/editor-plugin-media 8.2.0 → 8.3.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 CHANGED
@@ -1,5 +1,26 @@
1
1
  # @atlaskit/editor-plugin-media
2
2
 
3
+ ## 8.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`e5f402044b1c6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e5f402044b1c6) -
8
+ Add media render error analytics
9
+
10
+ ### Patch Changes
11
+
12
+ - [`2352f7c910f27`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2352f7c910f27) -
13
+ upgrade use of browser util
14
+ - Updated dependencies
15
+
16
+ ## 8.2.1
17
+
18
+ ### Patch Changes
19
+
20
+ - [`5771b6f88f16a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5771b6f88f16a) -
21
+ Clean up platform_editor_fix_image_size_diff_during_ssr
22
+ - Updated dependencies
23
+
3
24
  ## 8.2.0
4
25
 
5
26
  ### Minor Changes
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.mediaPlugin = void 0;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
+ var _analytics = require("@atlaskit/editor-common/analytics");
10
11
  var _hooks = require("@atlaskit/editor-common/hooks");
11
12
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
12
13
  var _state = require("@atlaskit/editor-prosemirror/state");
@@ -108,6 +109,7 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
108
109
  options = _ref3$config === void 0 ? {} : _ref3$config,
109
110
  api = _ref3.api;
110
111
  var previousMediaProvider;
112
+ var mediaErrorLocalIds = new Set();
111
113
  return {
112
114
  name: 'media',
113
115
  getSharedState: function getSharedState(editorState) {
@@ -117,9 +119,27 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
117
119
  return _pluginKey.stateKey.getState(editorState) || null;
118
120
  },
119
121
  actions: {
120
- insertMediaAsMediaSingle: function insertMediaAsMediaSingle(view, node, inputMethod, insertMediaVia) {
122
+ handleMediaNodeRenderError: function handleMediaNodeRenderError(node, reason) {
121
123
  var _api$analytics;
122
- return (0, _mediaSingle2.insertMediaAsMediaSingle)(view, node, inputMethod, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, insertMediaVia, options === null || options === void 0 ? void 0 : options.allowPixelResizing);
124
+ // Only fire the errored event once per media node
125
+ if (mediaErrorLocalIds.has(node.attrs.localId)) {
126
+ return;
127
+ }
128
+ mediaErrorLocalIds.add(node.attrs.localId);
129
+ api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
130
+ action: _analytics.ACTION.ERRORED,
131
+ actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
132
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.MEDIA,
133
+ eventType: _analytics.EVENT_TYPE.UI,
134
+ attributes: {
135
+ reason: reason,
136
+ external: node.attrs.__external
137
+ }
138
+ });
139
+ },
140
+ insertMediaAsMediaSingle: function insertMediaAsMediaSingle(view, node, inputMethod, insertMediaVia) {
141
+ var _api$analytics2;
142
+ return (0, _mediaSingle2.insertMediaAsMediaSingle)(view, node, inputMethod, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, insertMediaVia, options === null || options === void 0 ? void 0 : options.allowPixelResizing);
123
143
  },
124
144
  setProvider: function setProvider(provider) {
125
145
  var _api$core$actions$exe;
@@ -214,9 +234,9 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
214
234
  }, {
215
235
  name: 'mediaKeymap',
216
236
  plugin: function plugin(_ref7) {
217
- var _api$analytics2, _api$selection;
237
+ var _api$analytics3, _api$selection;
218
238
  var getIntl = _ref7.getIntl;
219
- return (0, _keymap2.default)(options, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.actions, api === null || api === void 0 ? void 0 : api.width, getIntl);
239
+ return (0, _keymap2.default)(options, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.actions, api === null || api === void 0 ? void 0 : api.width, getIntl);
220
240
  }
221
241
  }];
222
242
  if (options && options.allowMediaSingle) {
@@ -236,9 +256,9 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
236
256
  pmPlugins.push({
237
257
  name: 'mediaAltTextKeymap',
238
258
  plugin: function plugin(_ref9) {
239
- var _api$analytics3;
259
+ var _api$analytics4;
240
260
  var schema = _ref9.schema;
241
- return (0, _keymap.default)(schema, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
261
+ return (0, _keymap.default)(schema, api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
242
262
  }
243
263
  });
244
264
  }
@@ -109,7 +109,9 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
109
109
  height: height
110
110
  };
111
111
  var isSelectedAndInteracted = _this.nodeInsideSelection() && interactionState !== 'hasNotHadInteraction';
112
+ var pluginInjectionApi = _this.reactComponentProps.pluginInjectionApi;
112
113
  return /*#__PURE__*/_react.default.createElement(_media.default, {
114
+ api: pluginInjectionApi,
113
115
  view: _this.view,
114
116
  node: _this.node,
115
117
  getPos: getPos,
@@ -22,6 +22,7 @@ var _utils = require("@atlaskit/editor-common/utils");
22
22
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
23
23
  var _mediaCard = require("@atlaskit/media-card");
24
24
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
25
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
25
26
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
26
27
  var _pluginKey = require("../../pm-plugins/plugin-key");
27
28
  var _styles = require("../styles");
@@ -243,7 +244,8 @@ var MediaNode = exports.MediaNode = /*#__PURE__*/function (_Component) {
243
244
  originalDimensions = _this$props.originalDimensions,
244
245
  isLoading = _this$props.isLoading,
245
246
  maxDimensions = _this$props.maxDimensions,
246
- mediaOptions = _this$props.mediaOptions;
247
+ mediaOptions = _this$props.mediaOptions,
248
+ api = _this$props.api;
247
249
  var borderMark = node.marks.find(function (m) {
248
250
  return m.type.name === 'border';
249
251
  });
@@ -324,7 +326,10 @@ var MediaNode = exports.MediaNode = /*#__PURE__*/function (_Component) {
324
326
  ssr: ssr,
325
327
  mediaSettings: {
326
328
  canUpdateVideoCaptions: (0, _platformFeatureFlags.fg)('platform_media_video_captions') ? !!viewAndUploadMediaClientConfig : false
327
- }
329
+ },
330
+ onError: (0, _expValEquals.expValEquals)('platform_editor_media_error_analytics', 'isEnabled', true) ? function (reason) {
331
+ return api === null || api === void 0 ? void 0 : api.media.actions.handleMediaNodeRenderError(node, reason);
332
+ } : undefined
328
333
  })));
329
334
  }
330
335
  }]);
@@ -12,15 +12,16 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
12
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
13
  var _react = _interopRequireWildcard(require("react"));
14
14
  var _react2 = require("@emotion/react");
15
+ var _browser = require("@atlaskit/editor-common/browser");
15
16
  var _hooks = require("@atlaskit/editor-common/hooks");
16
17
  var _media = require("@atlaskit/editor-common/media");
17
18
  var _mediaSingle = require("@atlaskit/editor-common/media-single");
18
19
  var _ui = require("@atlaskit/editor-common/ui");
19
- var _utils = require("@atlaskit/editor-common/utils");
20
20
  var _state = require("@atlaskit/editor-prosemirror/state");
21
- var _utils2 = require("@atlaskit/editor-prosemirror/utils");
21
+ var _utils = require("@atlaskit/editor-prosemirror/utils");
22
22
  var _mediaClient = require("@atlaskit/media-client");
23
23
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
24
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
24
25
  var _captions = require("../pm-plugins/commands/captions");
25
26
  var _mediaCommon = require("../pm-plugins/utils/media-common");
26
27
  var _CaptionPlaceholder = require("../ui/CaptionPlaceholder");
@@ -393,7 +394,7 @@ var MediaSingleNodeNext = exports.MediaSingleNodeNext = function MediaSingleNode
393
394
  // If resizing not allowed in tables, check parents for tables
394
395
  var $pos = view.state.doc.resolve(pos);
395
396
  var table = view.state.schema.nodes.table;
396
- var disabledNode = !!(0, _utils2.findParentNodeOfTypeClosestToPos)($pos, [table]);
397
+ var disabledNode = !!(0, _utils.findParentNodeOfTypeClosestToPos)($pos, [table]);
397
398
  return Boolean(result && !disabledNode);
398
399
  }, [mediaOptions, pos, view, editorDisabled, editorViewMode]);
399
400
  var shouldShowPlaceholder = _react.default.useMemo(function () {
@@ -404,7 +405,7 @@ var MediaSingleNodeNext = exports.MediaSingleNodeNext = function MediaSingleNode
404
405
  if (typeof pos !== 'number') {
405
406
  return false;
406
407
  }
407
- return (0, _utils2.findParentNodeOfTypeClosestToPos)(view.state.doc.resolve(pos), [view.state.schema.nodes.table]);
408
+ return (0, _utils.findParentNodeOfTypeClosestToPos)(view.state.doc.resolve(pos), [view.state.schema.nodes.table]);
408
409
  }, [pos, view]);
409
410
  var currentMediaElement = _react.default.useCallback(function () {
410
411
  if (typeof pos !== 'number') {
@@ -433,9 +434,10 @@ var MediaSingleNodeNext = exports.MediaSingleNodeNext = function MediaSingleNode
433
434
  var captionPlaceHolderRef = /*#__PURE__*/_react.default.createRef();
434
435
  var onMediaSingleClicked = _react.default.useCallback(function (event) {
435
436
  var _captionPlaceHolderRe;
437
+ var browser = (0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) ? (0, _browser.getBrowserInfo)() : _browser.browser;
436
438
  // Workaround for iOS 16 Caption selection issue
437
439
  // @see https://product-fabric.atlassian.net/browse/MEX-2012
438
- if (!_utils.browser.ios) {
440
+ if (!browser.ios) {
439
441
  return;
440
442
  }
441
443
  if (mediaSingleWrapperRef.current !== event.target) {
@@ -1,4 +1,5 @@
1
1
  import React, { useMemo } from 'react';
2
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
2
3
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
3
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
5
  import { NodeSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
@@ -103,6 +104,7 @@ export const mediaPlugin = ({
103
104
  api
104
105
  }) => {
105
106
  let previousMediaProvider;
107
+ const mediaErrorLocalIds = new Set();
106
108
  return {
107
109
  name: 'media',
108
110
  getSharedState(editorState) {
@@ -112,9 +114,27 @@ export const mediaPlugin = ({
112
114
  return stateKey.getState(editorState) || null;
113
115
  },
114
116
  actions: {
115
- insertMediaAsMediaSingle: (view, node, inputMethod, insertMediaVia) => {
117
+ handleMediaNodeRenderError: (node, reason) => {
116
118
  var _api$analytics;
117
- return insertMediaAsMediaSingle(view, node, inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, insertMediaVia, options === null || options === void 0 ? void 0 : options.allowPixelResizing);
119
+ // Only fire the errored event once per media node
120
+ if (mediaErrorLocalIds.has(node.attrs.localId)) {
121
+ return;
122
+ }
123
+ mediaErrorLocalIds.add(node.attrs.localId);
124
+ api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent({
125
+ action: ACTION.ERRORED,
126
+ actionSubject: ACTION_SUBJECT.EDITOR,
127
+ actionSubjectId: ACTION_SUBJECT_ID.MEDIA,
128
+ eventType: EVENT_TYPE.UI,
129
+ attributes: {
130
+ reason,
131
+ external: node.attrs.__external
132
+ }
133
+ });
134
+ },
135
+ insertMediaAsMediaSingle: (view, node, inputMethod, insertMediaVia) => {
136
+ var _api$analytics2;
137
+ return insertMediaAsMediaSingle(view, node, inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, insertMediaVia, options === null || options === void 0 ? void 0 : options.allowPixelResizing);
118
138
  },
119
139
  setProvider: provider => {
120
140
  var _api$core$actions$exe;
@@ -209,8 +229,8 @@ export const mediaPlugin = ({
209
229
  plugin: ({
210
230
  getIntl
211
231
  }) => {
212
- var _api$analytics2, _api$selection;
213
- return keymapPlugin(options, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 ? void 0 : (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.actions, api === null || api === void 0 ? void 0 : api.width, getIntl);
232
+ var _api$analytics3, _api$selection;
233
+ return keymapPlugin(options, api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, api === null || api === void 0 ? void 0 : (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.actions, api === null || api === void 0 ? void 0 : api.width, getIntl);
214
234
  }
215
235
  }];
216
236
  if (options && options.allowMediaSingle) {
@@ -231,8 +251,8 @@ export const mediaPlugin = ({
231
251
  plugin: ({
232
252
  schema
233
253
  }) => {
234
- var _api$analytics3;
235
- return keymapMediaAltTextPlugin(schema, api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
254
+ var _api$analytics4;
255
+ return keymapMediaAltTextPlugin(schema, api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
236
256
  }
237
257
  });
238
258
  }
@@ -96,7 +96,11 @@ class MediaNodeView extends SelectionBasedNodeView {
96
96
  height
97
97
  };
98
98
  const isSelectedAndInteracted = this.nodeInsideSelection() && interactionState !== 'hasNotHadInteraction';
99
+ const {
100
+ pluginInjectionApi
101
+ } = this.reactComponentProps;
99
102
  return /*#__PURE__*/React.createElement(MediaNode, {
103
+ api: pluginInjectionApi,
100
104
  view: this.view,
101
105
  node: this.node,
102
106
  getPos: getPos,
@@ -7,6 +7,7 @@ import { setNodeSelection, setTextSelection, withImageLoader } from '@atlaskit/e
7
7
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
8
8
  import { Card, CardLoading } from '@atlaskit/media-card';
9
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
10
11
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
11
12
  import { stateKey as mediaStateKey } from '../../pm-plugins/plugin-key';
12
13
  import { MediaCardWrapper } from '../styles';
@@ -184,7 +185,8 @@ export class MediaNode extends Component {
184
185
  originalDimensions,
185
186
  isLoading,
186
187
  maxDimensions,
187
- mediaOptions
188
+ mediaOptions,
189
+ api
188
190
  } = this.props;
189
191
  const borderMark = node.marks.find(m => m.type.name === 'border');
190
192
  const {
@@ -266,7 +268,8 @@ export class MediaNode extends Component {
266
268
  ssr: ssr,
267
269
  mediaSettings: {
268
270
  canUpdateVideoCaptions: fg('platform_media_video_captions') ? !!viewAndUploadMediaClientConfig : false
269
- }
271
+ },
272
+ onError: expValEquals('platform_editor_media_error_analytics', 'isEnabled', true) ? reason => api === null || api === void 0 ? void 0 : api.media.actions.handleMediaNodeRenderError(node, reason) : undefined
270
273
  })));
271
274
  }
272
275
  }
@@ -7,15 +7,16 @@ import React, { Fragment } from 'react';
7
7
 
8
8
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
9
9
  import { css, jsx } from '@emotion/react';
10
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
10
11
  import { usePreviousState } from '@atlaskit/editor-common/hooks';
11
12
  import { captionMessages } from '@atlaskit/editor-common/media';
12
13
  import { calcMediaSinglePixelWidth, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH, ExternalImageBadge, getMaxWidthForNestedNode, MEDIA_SINGLE_GUTTER_SIZE, MediaBadges } from '@atlaskit/editor-common/media-single';
13
14
  import { MediaSingle } from '@atlaskit/editor-common/ui';
14
- import { browser } from '@atlaskit/editor-common/utils';
15
15
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
16
16
  import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
17
17
  import { getAttrsFromUrl } from '@atlaskit/media-client';
18
18
  import { fg } from '@atlaskit/platform-feature-flags';
19
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
19
20
  import { insertAndSelectCaptionFromMediaSinglePos } from '../pm-plugins/commands/captions';
20
21
  import { isMediaBlobUrlFromAttrs } from '../pm-plugins/utils/media-common';
21
22
  import { CaptionPlaceholder, CaptionPlaceholderButton } from '../ui/CaptionPlaceholder';
@@ -393,6 +394,7 @@ export const MediaSingleNodeNext = mediaSingleNodeNextProps => {
393
394
  const captionPlaceHolderRef = /*#__PURE__*/React.createRef();
394
395
  const onMediaSingleClicked = React.useCallback(event => {
395
396
  var _captionPlaceHolderRe;
397
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
396
398
  // Workaround for iOS 16 Caption selection issue
397
399
  // @see https://product-fabric.atlassian.net/browse/MEX-2012
398
400
  if (!browser.ios) {
@@ -1,4 +1,5 @@
1
1
  import React, { useMemo } from 'react';
2
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
2
3
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
3
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
5
  import { NodeSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
@@ -99,6 +100,7 @@ export var mediaPlugin = function mediaPlugin(_ref3) {
99
100
  options = _ref3$config === void 0 ? {} : _ref3$config,
100
101
  api = _ref3.api;
101
102
  var previousMediaProvider;
103
+ var mediaErrorLocalIds = new Set();
102
104
  return {
103
105
  name: 'media',
104
106
  getSharedState: function getSharedState(editorState) {
@@ -108,9 +110,27 @@ export var mediaPlugin = function mediaPlugin(_ref3) {
108
110
  return stateKey.getState(editorState) || null;
109
111
  },
110
112
  actions: {
111
- insertMediaAsMediaSingle: function insertMediaAsMediaSingle(view, node, inputMethod, insertMediaVia) {
113
+ handleMediaNodeRenderError: function handleMediaNodeRenderError(node, reason) {
112
114
  var _api$analytics;
113
- return _insertMediaAsMediaSingle(view, node, inputMethod, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, insertMediaVia, options === null || options === void 0 ? void 0 : options.allowPixelResizing);
115
+ // Only fire the errored event once per media node
116
+ if (mediaErrorLocalIds.has(node.attrs.localId)) {
117
+ return;
118
+ }
119
+ mediaErrorLocalIds.add(node.attrs.localId);
120
+ api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
121
+ action: ACTION.ERRORED,
122
+ actionSubject: ACTION_SUBJECT.EDITOR,
123
+ actionSubjectId: ACTION_SUBJECT_ID.MEDIA,
124
+ eventType: EVENT_TYPE.UI,
125
+ attributes: {
126
+ reason: reason,
127
+ external: node.attrs.__external
128
+ }
129
+ });
130
+ },
131
+ insertMediaAsMediaSingle: function insertMediaAsMediaSingle(view, node, inputMethod, insertMediaVia) {
132
+ var _api$analytics2;
133
+ return _insertMediaAsMediaSingle(view, node, inputMethod, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, insertMediaVia, options === null || options === void 0 ? void 0 : options.allowPixelResizing);
114
134
  },
115
135
  setProvider: function setProvider(provider) {
116
136
  var _api$core$actions$exe;
@@ -205,9 +225,9 @@ export var mediaPlugin = function mediaPlugin(_ref3) {
205
225
  }, {
206
226
  name: 'mediaKeymap',
207
227
  plugin: function plugin(_ref7) {
208
- var _api$analytics2, _api$selection;
228
+ var _api$analytics3, _api$selection;
209
229
  var getIntl = _ref7.getIntl;
210
- return keymapPlugin(options, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.actions, api === null || api === void 0 ? void 0 : api.width, getIntl);
230
+ return keymapPlugin(options, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.actions, api === null || api === void 0 ? void 0 : api.width, getIntl);
211
231
  }
212
232
  }];
213
233
  if (options && options.allowMediaSingle) {
@@ -227,9 +247,9 @@ export var mediaPlugin = function mediaPlugin(_ref3) {
227
247
  pmPlugins.push({
228
248
  name: 'mediaAltTextKeymap',
229
249
  plugin: function plugin(_ref9) {
230
- var _api$analytics3;
250
+ var _api$analytics4;
231
251
  var schema = _ref9.schema;
232
- return keymapMediaAltTextPlugin(schema, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
252
+ return keymapMediaAltTextPlugin(schema, api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
233
253
  }
234
254
  });
235
255
  }
@@ -103,7 +103,9 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
103
103
  height: height
104
104
  };
105
105
  var isSelectedAndInteracted = _this.nodeInsideSelection() && interactionState !== 'hasNotHadInteraction';
106
+ var pluginInjectionApi = _this.reactComponentProps.pluginInjectionApi;
106
107
  return /*#__PURE__*/React.createElement(MediaNode, {
108
+ api: pluginInjectionApi,
107
109
  view: _this.view,
108
110
  node: _this.node,
109
111
  getPos: getPos,
@@ -16,6 +16,7 @@ import { setNodeSelection, setTextSelection, withImageLoader } from '@atlaskit/e
16
16
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
17
17
  import { Card, CardLoading } from '@atlaskit/media-card';
18
18
  import { fg } from '@atlaskit/platform-feature-flags';
19
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
19
20
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
20
21
  import { stateKey as mediaStateKey } from '../../pm-plugins/plugin-key';
21
22
  import { MediaCardWrapper } from '../styles';
@@ -235,7 +236,8 @@ export var MediaNode = /*#__PURE__*/function (_Component) {
235
236
  originalDimensions = _this$props.originalDimensions,
236
237
  isLoading = _this$props.isLoading,
237
238
  maxDimensions = _this$props.maxDimensions,
238
- mediaOptions = _this$props.mediaOptions;
239
+ mediaOptions = _this$props.mediaOptions,
240
+ api = _this$props.api;
239
241
  var borderMark = node.marks.find(function (m) {
240
242
  return m.type.name === 'border';
241
243
  });
@@ -316,7 +318,10 @@ export var MediaNode = /*#__PURE__*/function (_Component) {
316
318
  ssr: ssr,
317
319
  mediaSettings: {
318
320
  canUpdateVideoCaptions: fg('platform_media_video_captions') ? !!viewAndUploadMediaClientConfig : false
319
- }
321
+ },
322
+ onError: expValEquals('platform_editor_media_error_analytics', 'isEnabled', true) ? function (reason) {
323
+ return api === null || api === void 0 ? void 0 : api.media.actions.handleMediaNodeRenderError(node, reason);
324
+ } : undefined
320
325
  })));
321
326
  }
322
327
  }]);
@@ -13,15 +13,16 @@ import React, { Fragment } from 'react';
13
13
 
14
14
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
15
15
  import { css, jsx } from '@emotion/react';
16
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
16
17
  import { usePreviousState } from '@atlaskit/editor-common/hooks';
17
18
  import { captionMessages } from '@atlaskit/editor-common/media';
18
19
  import { calcMediaSinglePixelWidth, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH, ExternalImageBadge, getMaxWidthForNestedNode, MEDIA_SINGLE_GUTTER_SIZE, MediaBadges } from '@atlaskit/editor-common/media-single';
19
20
  import { MediaSingle } from '@atlaskit/editor-common/ui';
20
- import { browser } from '@atlaskit/editor-common/utils';
21
21
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
22
22
  import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
23
23
  import { getAttrsFromUrl } from '@atlaskit/media-client';
24
24
  import { fg } from '@atlaskit/platform-feature-flags';
25
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
25
26
  import { insertAndSelectCaptionFromMediaSinglePos } from '../pm-plugins/commands/captions';
26
27
  import { isMediaBlobUrlFromAttrs } from '../pm-plugins/utils/media-common';
27
28
  import { CaptionPlaceholder, CaptionPlaceholderButton } from '../ui/CaptionPlaceholder';
@@ -427,6 +428,7 @@ export var MediaSingleNodeNext = function MediaSingleNodeNext(mediaSingleNodeNex
427
428
  var captionPlaceHolderRef = /*#__PURE__*/React.createRef();
428
429
  var onMediaSingleClicked = React.useCallback(function (event) {
429
430
  var _captionPlaceHolderRe;
431
+ var browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
430
432
  // Workaround for iOS 16 Caption selection issue
431
433
  // @see https://product-fabric.atlassian.net/browse/MEX-2012
432
434
  if (!browser.ios) {
@@ -17,6 +17,7 @@ import type { InteractionPlugin } from '@atlaskit/editor-plugin-interaction';
17
17
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
18
18
  import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
19
19
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
20
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
20
21
  import type { MediaPluginState } from './pm-plugins/types';
21
22
  import type { InsertMediaAsMediaSingle } from './pm-plugins/utils/media-single';
22
23
  import type { MediaOptions } from './types';
@@ -41,6 +42,10 @@ export type MediaPluginDependencies = [
41
42
  ];
42
43
  export type MediaNextEditorPluginType = NextEditorPlugin<'media', {
43
44
  actions: {
45
+ /**
46
+ * Callback to be called when there is an error rendering a media node.
47
+ */
48
+ handleMediaNodeRenderError: (node: PMNode, reason: string) => void;
44
49
  insertMediaAsMediaSingle: InsertMediaAsMediaSingle;
45
50
  /**
46
51
  * Used to update the initial provider passed to the media plugin.
@@ -1,15 +1,18 @@
1
1
  import React, { Component } from 'react';
2
2
  import type { UnbindFn } from 'bind-event-listener';
3
3
  import type { ContextIdentifierProvider, MediaProvider } from '@atlaskit/editor-common/provider-factory';
4
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
5
  import type { ImageLoaderProps } from '@atlaskit/editor-common/utils';
5
6
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
6
7
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
7
8
  import type { CardDimensions, CardOnClickCallback, NumericalCardDimensions } from '@atlaskit/media-card';
8
9
  import type { MediaClientConfig } from '@atlaskit/media-core';
10
+ import type { MediaNextEditorPluginType } from '../../mediaPluginType';
9
11
  import type { MediaOptions, getPosHandler as ProsemirrorGetPosHandler, ReactNodeProps } from '../../types';
10
12
  export declare const MEDIA_HEIGHT = 125;
11
13
  export declare const FILE_WIDTH = 156;
12
14
  export interface MediaNodeProps extends ReactNodeProps, ImageLoaderProps {
15
+ api?: ExtractInjectionAPI<MediaNextEditorPluginType>;
13
16
  contextIdentifierProvider?: Promise<ContextIdentifierProvider>;
14
17
  getPos: ProsemirrorGetPosHandler;
15
18
  isLoading?: boolean;
@@ -17,6 +17,7 @@ import type { InteractionPlugin } from '@atlaskit/editor-plugin-interaction';
17
17
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
18
18
  import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
19
19
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
20
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
20
21
  import type { MediaPluginState } from './pm-plugins/types';
21
22
  import type { InsertMediaAsMediaSingle } from './pm-plugins/utils/media-single';
22
23
  import type { MediaOptions } from './types';
@@ -41,6 +42,10 @@ export type MediaPluginDependencies = [
41
42
  ];
42
43
  export type MediaNextEditorPluginType = NextEditorPlugin<'media', {
43
44
  actions: {
45
+ /**
46
+ * Callback to be called when there is an error rendering a media node.
47
+ */
48
+ handleMediaNodeRenderError: (node: PMNode, reason: string) => void;
44
49
  insertMediaAsMediaSingle: InsertMediaAsMediaSingle;
45
50
  /**
46
51
  * Used to update the initial provider passed to the media plugin.
@@ -1,15 +1,18 @@
1
1
  import React, { Component } from 'react';
2
2
  import type { UnbindFn } from 'bind-event-listener';
3
3
  import type { ContextIdentifierProvider, MediaProvider } from '@atlaskit/editor-common/provider-factory';
4
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
5
  import type { ImageLoaderProps } from '@atlaskit/editor-common/utils';
5
6
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
6
7
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
7
8
  import type { CardDimensions, CardOnClickCallback, NumericalCardDimensions } from '@atlaskit/media-card';
8
9
  import type { MediaClientConfig } from '@atlaskit/media-core';
10
+ import type { MediaNextEditorPluginType } from '../../mediaPluginType';
9
11
  import type { MediaOptions, getPosHandler as ProsemirrorGetPosHandler, ReactNodeProps } from '../../types';
10
12
  export declare const MEDIA_HEIGHT = 125;
11
13
  export declare const FILE_WIDTH = 156;
12
14
  export interface MediaNodeProps extends ReactNodeProps, ImageLoaderProps {
15
+ api?: ExtractInjectionAPI<MediaNextEditorPluginType>;
13
16
  contextIdentifierProvider?: Promise<ContextIdentifierProvider>;
14
17
  getPos: ProsemirrorGetPosHandler;
15
18
  isLoading?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media",
3
- "version": "8.2.0",
3
+ "version": "8.3.0",
4
4
  "description": "Media plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -49,12 +49,12 @@
49
49
  "@atlaskit/editor-plugin-toolbar": "^3.3.0",
50
50
  "@atlaskit/editor-plugin-width": "^7.0.0",
51
51
  "@atlaskit/editor-prosemirror": "7.0.0",
52
- "@atlaskit/editor-shared-styles": "^3.7.0",
52
+ "@atlaskit/editor-shared-styles": "^3.8.0",
53
53
  "@atlaskit/editor-tables": "^2.9.0",
54
54
  "@atlaskit/form": "^14.2.0",
55
55
  "@atlaskit/icon": "^28.5.0",
56
56
  "@atlaskit/icon-lab": "^5.10.0",
57
- "@atlaskit/media-card": "^79.5.0",
57
+ "@atlaskit/media-card": "^79.6.0",
58
58
  "@atlaskit/media-client": "^35.5.0",
59
59
  "@atlaskit/media-client-react": "^4.1.0",
60
60
  "@atlaskit/media-common": "^12.3.0",
@@ -66,9 +66,9 @@
66
66
  "@atlaskit/primitives": "^16.0.0",
67
67
  "@atlaskit/textfield": "^8.0.0",
68
68
  "@atlaskit/theme": "^21.0.0",
69
- "@atlaskit/tmp-editor-statsig": "^13.13.0",
69
+ "@atlaskit/tmp-editor-statsig": "^13.17.0",
70
70
  "@atlaskit/tokens": "^7.0.0",
71
- "@atlaskit/tooltip": "^20.5.0",
71
+ "@atlaskit/tooltip": "^20.6.0",
72
72
  "@babel/runtime": "^7.0.0",
73
73
  "@emotion/react": "^11.7.1",
74
74
  "bind-event-listener": "^3.0.0",
@@ -78,7 +78,7 @@
78
78
  "uuid": "^3.1.0"
79
79
  },
80
80
  "peerDependencies": {
81
- "@atlaskit/editor-common": "^110.14.0",
81
+ "@atlaskit/editor-common": "^110.16.0",
82
82
  "@atlaskit/media-core": "^37.0.0",
83
83
  "react": "^18.2.0",
84
84
  "react-dom": "^18.2.0",
@@ -151,9 +151,6 @@
151
151
  "platform_editor_ssr_media": {
152
152
  "type": "boolean"
153
153
  },
154
- "platform_editor_fix_image_size_diff_during_ssr": {
155
- "type": "boolean"
156
- },
157
154
  "platform_editor_track_media_fail_to_insert": {
158
155
  "type": "boolean"
159
156
  },