@atlaskit/editor-plugin-media 2.6.7 → 2.7.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 (61) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/mediaPlugin.js +21 -6
  3. package/dist/cjs/nodeviews/mediaGroup.js +21 -6
  4. package/dist/cjs/nodeviews/mediaInline.js +55 -13
  5. package/dist/cjs/nodeviews/mediaNodeUpdater.js +24 -18
  6. package/dist/cjs/nodeviews/mediaNodeView/index.js +11 -3
  7. package/dist/cjs/nodeviews/mediaSingle.js +88 -49
  8. package/dist/cjs/nodeviews/mediaSingleNext.js +5 -4
  9. package/dist/cjs/pm-plugins/utils/media-files.js +64 -6
  10. package/dist/cjs/ui/CommentBadge/index.js +44 -14
  11. package/dist/cjs/ui/MediaPicker/index.js +15 -3
  12. package/dist/cjs/ui/MediaViewer/MediaViewerContainer.js +3 -3
  13. package/dist/cjs/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +2 -1
  14. package/dist/cjs/ui/ToolbarMedia/index.js +17 -5
  15. package/dist/cjs/ui/hooks/useMediaProvider.js +11 -3
  16. package/dist/cjs/ui/toolbar/utils.js +6 -4
  17. package/dist/es2019/mediaPlugin.js +21 -6
  18. package/dist/es2019/nodeviews/mediaGroup.js +21 -6
  19. package/dist/es2019/nodeviews/mediaInline.js +54 -12
  20. package/dist/es2019/nodeviews/mediaNodeUpdater.js +5 -1
  21. package/dist/es2019/nodeviews/mediaNodeView/index.js +11 -3
  22. package/dist/es2019/nodeviews/mediaSingle.js +60 -25
  23. package/dist/es2019/nodeviews/mediaSingleNext.js +5 -4
  24. package/dist/es2019/pm-plugins/utils/media-files.js +63 -5
  25. package/dist/es2019/ui/CommentBadge/index.js +40 -10
  26. package/dist/es2019/ui/MediaPicker/index.js +15 -3
  27. package/dist/es2019/ui/MediaViewer/MediaViewerContainer.js +4 -4
  28. package/dist/es2019/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +2 -1
  29. package/dist/es2019/ui/ToolbarMedia/index.js +17 -5
  30. package/dist/es2019/ui/hooks/useMediaProvider.js +11 -3
  31. package/dist/es2019/ui/toolbar/utils.js +5 -3
  32. package/dist/esm/mediaPlugin.js +21 -6
  33. package/dist/esm/nodeviews/mediaGroup.js +21 -6
  34. package/dist/esm/nodeviews/mediaInline.js +55 -13
  35. package/dist/esm/nodeviews/mediaNodeUpdater.js +24 -18
  36. package/dist/esm/nodeviews/mediaNodeView/index.js +11 -3
  37. package/dist/esm/nodeviews/mediaSingle.js +88 -49
  38. package/dist/esm/nodeviews/mediaSingleNext.js +5 -4
  39. package/dist/esm/pm-plugins/utils/media-files.js +63 -5
  40. package/dist/esm/ui/CommentBadge/index.js +44 -14
  41. package/dist/esm/ui/MediaPicker/index.js +15 -3
  42. package/dist/esm/ui/MediaViewer/MediaViewerContainer.js +4 -4
  43. package/dist/esm/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +2 -1
  44. package/dist/esm/ui/ToolbarMedia/index.js +17 -5
  45. package/dist/esm/ui/hooks/useMediaProvider.js +11 -3
  46. package/dist/esm/ui/toolbar/utils.js +5 -3
  47. package/dist/types/nodeviews/mediaInline.d.ts +7 -2
  48. package/dist/types/nodeviews/mediaSingleNext.d.ts +3 -4
  49. package/dist/types/nodeviews/types.d.ts +3 -4
  50. package/dist/types/pm-plugins/utils/media-files.d.ts +3 -2
  51. package/dist/types/types/index.d.ts +17 -0
  52. package/dist/types/ui/MediaViewer/MediaViewerContainer.d.ts +4 -3
  53. package/dist/types/ui/toolbar/utils.d.ts +1 -0
  54. package/dist/types-ts4.5/nodeviews/mediaInline.d.ts +7 -2
  55. package/dist/types-ts4.5/nodeviews/mediaSingleNext.d.ts +3 -4
  56. package/dist/types-ts4.5/nodeviews/types.d.ts +3 -4
  57. package/dist/types-ts4.5/pm-plugins/utils/media-files.d.ts +3 -2
  58. package/dist/types-ts4.5/types/index.d.ts +17 -0
  59. package/dist/types-ts4.5/ui/MediaViewer/MediaViewerContainer.d.ts +4 -3
  60. package/dist/types-ts4.5/ui/toolbar/utils.d.ts +1 -0
  61. package/package.json +9 -3
@@ -31,6 +31,7 @@ var _utils2 = require("@atlaskit/editor-prosemirror/utils");
31
31
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
32
32
  var _mediaClient = require("@atlaskit/media-client");
33
33
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
34
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
34
35
  var _captions = require("../pm-plugins/commands/captions");
35
36
  var _main = require("../pm-plugins/main");
36
37
  var _mediaCommon = require("../pm-plugins/utils/media-common");
@@ -128,78 +129,85 @@ var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
128
129
  while (1) switch (_context2.prev = _context2.next) {
129
130
  case 0:
130
131
  _this.createOrUpdateMediaNodeUpdater(props);
131
- addPendingTask = _this.props.mediaPluginState.addPendingTask; // we want the first child of MediaSingle (type "media")
132
+ addPendingTask = _this.props.addPendingTask;
133
+ if (addPendingTask) {
134
+ _context2.next = 4;
135
+ break;
136
+ }
137
+ return _context2.abrupt("return");
138
+ case 4:
139
+ // we want the first child of MediaSingle (type "media")
132
140
  node = _this.props.node.firstChild;
133
141
  if (node) {
134
- _context2.next = 5;
142
+ _context2.next = 7;
135
143
  break;
136
144
  }
137
145
  return _context2.abrupt("return");
138
- case 5:
139
- _context2.next = 7;
140
- return (_this$mediaNodeUpdate2 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate2 === void 0 ? void 0 : _this$mediaNodeUpdate2.getRemoteDimensions();
141
146
  case 7:
147
+ _context2.next = 9;
148
+ return (_this$mediaNodeUpdate2 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate2 === void 0 ? void 0 : _this$mediaNodeUpdate2.getRemoteDimensions();
149
+ case 9:
142
150
  updatedDimensions = _context2.sent;
143
151
  currentAttrs = (_this$props$node$firs = _this.props.node.firstChild) === null || _this$props$node$firs === void 0 ? void 0 : _this$props$node$firs.attrs;
144
152
  if (updatedDimensions && ((currentAttrs === null || currentAttrs === void 0 ? void 0 : currentAttrs.width) !== updatedDimensions.width || (currentAttrs === null || currentAttrs === void 0 ? void 0 : currentAttrs.height) !== updatedDimensions.height)) {
145
153
  (_this$mediaNodeUpdate3 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate3 === void 0 || _this$mediaNodeUpdate3.updateDimensions(updatedDimensions);
146
154
  }
147
155
  if (!(node.attrs.type === 'external' && node.attrs.__external)) {
148
- _context2.next = 16;
156
+ _context2.next = 18;
149
157
  break;
150
158
  }
151
159
  // Ignored via go/ees005
152
160
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
153
161
  updatingNode = _this.mediaNodeUpdater.handleExternalMedia(_this.props.getPos);
154
162
  addPendingTask(updatingNode);
155
- _context2.next = 15;
163
+ _context2.next = 17;
156
164
  return updatingNode;
157
- case 15:
165
+ case 17:
158
166
  return _context2.abrupt("return");
159
- case 16:
167
+ case 18:
160
168
  contextId = (_this$mediaNodeUpdate4 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate4 === void 0 ? void 0 : _this$mediaNodeUpdate4.getNodeContextId();
161
169
  if (contextId) {
162
- _context2.next = 20;
170
+ _context2.next = 22;
163
171
  break;
164
172
  }
165
- _context2.next = 20;
166
- return (_this$mediaNodeUpdate5 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate5 === void 0 ? void 0 : _this$mediaNodeUpdate5.updateContextId();
167
- case 20:
168
173
  _context2.next = 22;
169
- return (_this$mediaNodeUpdate6 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate6 === void 0 ? void 0 : _this$mediaNodeUpdate6.shouldNodeBeDeepCopied();
174
+ return (_this$mediaNodeUpdate5 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate5 === void 0 ? void 0 : _this$mediaNodeUpdate5.updateContextId();
170
175
  case 22:
176
+ _context2.next = 24;
177
+ return (_this$mediaNodeUpdate6 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate6 === void 0 ? void 0 : _this$mediaNodeUpdate6.shouldNodeBeDeepCopied();
178
+ case 24:
171
179
  shouldNodeBeDeepCopied = _context2.sent;
172
180
  if (!shouldNodeBeDeepCopied) {
173
- _context2.next = 35;
181
+ _context2.next = 37;
174
182
  break;
175
183
  }
176
184
  _this.setState({
177
185
  isCopying: true
178
186
  });
179
- _context2.prev = 25;
187
+ _context2.prev = 27;
180
188
  // Ignored via go/ees005
181
189
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
182
190
  copyNode = _this.mediaNodeUpdater.copyNode({
183
191
  traceId: node.attrs.__mediaTraceId
184
192
  });
185
193
  addPendingTask(copyNode);
186
- _context2.next = 30;
194
+ _context2.next = 32;
187
195
  return copyNode;
188
- case 30:
189
- _context2.next = 35;
190
- break;
191
196
  case 32:
192
- _context2.prev = 32;
193
- _context2.t0 = _context2["catch"](25);
197
+ _context2.next = 37;
198
+ break;
199
+ case 34:
200
+ _context2.prev = 34;
201
+ _context2.t0 = _context2["catch"](27);
194
202
  // if copyNode fails, let's set isCopying false so we can show the eventual error
195
203
  _this.setState({
196
204
  isCopying: false
197
205
  });
198
- case 35:
206
+ case 37:
199
207
  case "end":
200
208
  return _context2.stop();
201
209
  }
202
- }, _callee2, null, [[25, 32]]);
210
+ }, _callee2, null, [[27, 34]]);
203
211
  }));
204
212
  return function (_x2) {
205
213
  return _ref2.apply(this, arguments);
@@ -362,7 +370,8 @@ var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
362
370
  dispatchAnalyticsEvent = _this$props2.dispatchAnalyticsEvent,
363
371
  editorViewMode = _this$props2.editorViewMode,
364
372
  editorDisabled = _this$props2.editorDisabled,
365
- annotationPluginState = _this$props2.annotationPluginState,
373
+ isDrafting = _this$props2.isDrafting,
374
+ targetNodeId = _this$props2.targetNodeId,
366
375
  editorAppearance = _this$props2.editorAppearance;
367
376
  var _ref4 = node.attrs,
368
377
  layout = _ref4.layout,
@@ -459,7 +468,7 @@ var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
459
468
  var badgeOffsetRight = isBadgePosOffsetRight();
460
469
  var shouldShowPlaceholder = mediaOptions.allowCaptions && node.childCount !== 2 && isSelected && state.selection instanceof _state.NodeSelection;
461
470
  shouldShowPlaceholder = !editorDisabled && shouldShowPlaceholder;
462
- var isCurrentNodeDrafting = (annotationPluginState === null || annotationPluginState === void 0 ? void 0 : annotationPluginState.isDrafting) && (annotationPluginState === null || annotationPluginState === void 0 ? void 0 : annotationPluginState.targetNodeId) === (node === null || node === void 0 || (_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.attrs.id);
471
+ var isCurrentNodeDrafting = Boolean(isDrafting && targetNodeId === (node === null || node === void 0 || (_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.attrs.id));
463
472
  var pos = getPos();
464
473
  var isInsideTable = pos !== undefined && (0, _utils2.findParentNodeOfTypeClosestToPos)(state.doc.resolve(pos), [state.schema.nodes.table]);
465
474
  var currentMediaElement = function currentMediaElement() {
@@ -557,23 +566,57 @@ var MediaSingleNodeWrapper = function MediaSingleNodeWrapper(_ref6) {
557
566
  dispatchAnalyticsEvent = _ref6.dispatchAnalyticsEvent,
558
567
  forwardRef = _ref6.forwardRef,
559
568
  editorAppearance = _ref6.editorAppearance;
560
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['width', 'media', 'annotation', 'editorDisabled', 'editorViewMode']),
569
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['width', 'media', 'annotation', 'editorDisabled', 'editorViewMode'], {
570
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
571
+ }),
561
572
  widthState = _useSharedPluginState.widthState,
562
573
  mediaState = _useSharedPluginState.mediaState,
563
574
  annotationState = _useSharedPluginState.annotationState,
564
575
  editorDisabledState = _useSharedPluginState.editorDisabledState,
565
576
  editorViewModeState = _useSharedPluginState.editorViewModeState;
577
+ var mediaProviderSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'media.mediaProvider', {
578
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
579
+ });
580
+ var addPendingTaskSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'media.addPendingTask', {
581
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
582
+ });
583
+ var isDraftingSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'annotation.isDrafting', {
584
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
585
+ });
586
+ var targetNodeIdSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'annotation.targetNodeId', {
587
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
588
+ });
589
+ var widthSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'width.width', {
590
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
591
+ });
592
+ var lineLengthSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'width.lineLength', {
593
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
594
+ });
595
+ var editorDisabledSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'editorDisabled.editorDisabled', {
596
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
597
+ });
598
+ var viewModeSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'editorViewMode.mode', {
599
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
600
+ });
601
+ var mediaProviderState = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? mediaProviderSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider;
602
+ var addPendingTask = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? addPendingTaskSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.addPendingTask;
603
+ var isDrafting = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? isDraftingSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isDrafting;
604
+ var targetNodeId = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? targetNodeIdSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.targetNodeId;
605
+ var width = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? widthSelector : widthState === null || widthState === void 0 ? void 0 : widthState.width;
606
+ var lineLength = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? lineLengthSelector : widthState === null || widthState === void 0 ? void 0 : widthState.lineLength;
607
+ var editorDisabled = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? editorDisabledSelector : editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled;
608
+ var viewMode = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? viewModeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
566
609
  var hasHadInteraction = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'interaction.hasHadInteraction');
567
610
  var mediaProvider = (0, _react.useMemo)(function () {
568
- return mediaState !== null && mediaState !== void 0 && mediaState.mediaProvider ? Promise.resolve(mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider) : undefined;
569
- }, [mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider]);
611
+ return mediaProviderState ? Promise.resolve(mediaProviderState) : undefined;
612
+ }, [mediaProviderState]);
570
613
  var isSelectedAndInteracted = (0, _react.useCallback)(function () {
571
- return Boolean(selected() && hasHadInteraction);
614
+ return Boolean(selected() && hasHadInteraction !== false);
572
615
  }, [hasHadInteraction, selected]);
573
616
  if ((0, _platformFeatureFlags.fg)('platform_editor_react18_phase2__media_single') || (0, _platformFeatureFlags.fg)('platform_editor_react18_phase2__media_single_jira')) {
574
617
  return (0, _react2.jsx)(_mediaSingleNext.MediaSingleNodeNext, {
575
- width: (widthState === null || widthState === void 0 ? void 0 : widthState.width) || 0,
576
- lineLength: (widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || 0,
618
+ width: width || 0,
619
+ lineLength: lineLength || 0,
577
620
  node: node,
578
621
  getPos: getPos,
579
622
  mediaProvider: mediaProvider,
@@ -583,25 +626,20 @@ var MediaSingleNodeWrapper = function MediaSingleNodeWrapper(_ref6) {
583
626
  fullWidthMode: fullWidthMode,
584
627
  selected: (0, _platformFeatureFlags.fg)('platform_editor_no_selection_until_interaction') ? isSelectedAndInteracted : selected,
585
628
  eventDispatcher: eventDispatcher,
586
- mediaPluginState: mediaState !== null && mediaState !== void 0 ? mediaState : undefined,
587
- annotationPluginState: annotationState !== null && annotationState !== void 0 ? annotationState : undefined,
629
+ addPendingTask: addPendingTask,
630
+ isDrafting: isDrafting,
631
+ targetNodeId: targetNodeId,
588
632
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
589
633
  forwardRef: forwardRef,
590
634
  pluginInjectionApi: pluginInjectionApi,
591
- editorDisabled: editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled,
592
- editorViewMode: (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view',
635
+ editorDisabled: editorDisabled,
636
+ editorViewMode: viewMode === 'view',
593
637
  editorAppearance: editorAppearance
594
638
  });
595
639
  }
596
- return (0, _react2.jsx)(MediaSingleNode
597
- // Ignored via go/ees005
598
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
599
- , {
600
- width: widthState.width
601
- // Ignored via go/ees005
602
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
603
- ,
604
- lineLength: widthState.lineLength,
640
+ return (0, _react2.jsx)(MediaSingleNode, {
641
+ width: width,
642
+ lineLength: lineLength,
605
643
  node: node,
606
644
  getPos: getPos,
607
645
  mediaProvider: mediaProvider,
@@ -611,13 +649,14 @@ var MediaSingleNodeWrapper = function MediaSingleNodeWrapper(_ref6) {
611
649
  fullWidthMode: fullWidthMode,
612
650
  selected: (0, _platformFeatureFlags.fg)('platform_editor_no_selection_until_interaction') ? isSelectedAndInteracted : selected,
613
651
  eventDispatcher: eventDispatcher,
614
- mediaPluginState: mediaState !== null && mediaState !== void 0 ? mediaState : undefined,
615
- annotationPluginState: annotationState !== null && annotationState !== void 0 ? annotationState : undefined,
652
+ addPendingTask: addPendingTask,
653
+ isDrafting: isDrafting,
654
+ targetNodeId: targetNodeId,
616
655
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
617
656
  forwardRef: forwardRef,
618
657
  pluginInjectionApi: pluginInjectionApi,
619
- editorDisabled: editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled,
620
- editorViewMode: (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view',
658
+ editorDisabled: editorDisabled,
659
+ editorViewMode: viewMode === 'view',
621
660
  editorAppearance: editorAppearance
622
661
  });
623
662
  };
@@ -300,12 +300,13 @@ var MediaSingleNodeNext = exports.MediaSingleNodeNext = function MediaSingleNode
300
300
  dispatchAnalyticsEvent = mediaSingleNodeNextProps.dispatchAnalyticsEvent,
301
301
  editorViewMode = mediaSingleNodeNextProps.editorViewMode,
302
302
  editorDisabled = mediaSingleNodeNextProps.editorDisabled,
303
- annotationPluginState = mediaSingleNodeNextProps.annotationPluginState,
303
+ isDrafting = mediaSingleNodeNextProps.isDrafting,
304
+ targetNodeId = mediaSingleNodeNextProps.targetNodeId,
304
305
  editorAppearance = mediaSingleNodeNextProps.editorAppearance,
305
306
  mediaProviderPromise = mediaSingleNodeNextProps.mediaProvider,
306
307
  forwardRef = mediaSingleNodeNextProps.forwardRef,
307
308
  contextIdentifierProviderPromise = mediaSingleNodeNextProps.contextIdentifierProvider,
308
- mediaPluginState = mediaSingleNodeNextProps.mediaPluginState;
309
+ addPendingTask = mediaSingleNodeNextProps.addPendingTask;
309
310
  var _React$useState3 = _react.default.useState(null),
310
311
  _React$useState4 = (0, _slicedToArray2.default)(_React$useState3, 2),
311
312
  mediaProvider = _React$useState4[0],
@@ -333,7 +334,7 @@ var MediaSingleNodeNext = exports.MediaSingleNodeNext = function MediaSingleNode
333
334
  mediaNodeUpdater: mediaNodeUpdater,
334
335
  getPos: getPos,
335
336
  mediaNode: mediaNode,
336
- addPendingTask: (mediaPluginState === null || mediaPluginState === void 0 ? void 0 : mediaPluginState.addPendingTask) || noop
337
+ addPendingTask: addPendingTask || noop
337
338
  });
338
339
  _react.default.useLayoutEffect(function () {
339
340
  mountedRef.current = true;
@@ -437,7 +438,7 @@ var MediaSingleNodeNext = exports.MediaSingleNodeNext = function MediaSingleNode
437
438
  }, [mediaSingleWidthAttribute, widthType, width, layout, contentWidthForLegacyExperience, containerWidth]);
438
439
  var currentMaxWidth = isSelected ? pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.media) === null || _pluginInjectionApi$m === void 0 || (_pluginInjectionApi$m = _pluginInjectionApi$m.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth : undefined;
439
440
  var contentWidth = currentMaxWidth || lineLength;
440
- var isCurrentNodeDrafting = Boolean((annotationPluginState === null || annotationPluginState === void 0 ? void 0 : annotationPluginState.isDrafting) && (annotationPluginState === null || annotationPluginState === void 0 ? void 0 : annotationPluginState.targetNodeId) === (mediaNode === null || mediaNode === void 0 || (_mediaNode$firstChild = mediaNode.firstChild) === null || _mediaNode$firstChild === void 0 ? void 0 : _mediaNode$firstChild.attrs.id));
441
+ var isCurrentNodeDrafting = Boolean(isDrafting && targetNodeId === (mediaNode === null || mediaNode === void 0 || (_mediaNode$firstChild = mediaNode.firstChild) === null || _mediaNode$firstChild === void 0 ? void 0 : _mediaNode$firstChild.attrs.id));
441
442
  var mediaSingleWrapperRef = /*#__PURE__*/_react.default.createRef();
442
443
  var captionPlaceHolderRef = /*#__PURE__*/_react.default.createRef();
443
444
  var onMediaSingleClicked = _react.default.useCallback(function (event) {
@@ -3,13 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.insertMediaInlineNode = exports.insertMediaGroupNode = exports.getPosInList = exports.canInsertMediaInline = void 0;
6
+ exports.insertMediaInlineNode = exports.insertMediaGroupNode = exports.getPosInList = exports.getFailToInsertAnalytics = exports.canInsertMediaInline = void 0;
7
7
  var _analytics = require("@atlaskit/editor-common/analytics");
8
8
  var _mediaInline = require("@atlaskit/editor-common/media-inline");
9
9
  var _selection = require("@atlaskit/editor-common/selection");
10
10
  var _utils = require("@atlaskit/editor-common/utils");
11
11
  var _model = require("@atlaskit/editor-prosemirror/model");
12
+ var _transform = require("@atlaskit/editor-prosemirror/transform");
12
13
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
14
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
15
  var _isType = require("./is-type");
14
16
  var _mediaCommon = require("./media-common");
15
17
  var _mediaInline2 = require("./media-inline");
@@ -52,7 +54,21 @@ var getInsertMediaInlineAnalytics = function getInsertMediaInlineAnalytics(media
52
54
  eventType: _analytics.EVENT_TYPE.TRACK
53
55
  };
54
56
  };
55
-
57
+ var getFailToInsertAnalytics = exports.getFailToInsertAnalytics = function getFailToInsertAnalytics(mediaState, actionSubjectId, inputMethod, insertMediaVia, reason) {
58
+ var media = mediaState.fileMimeType || 'unknown';
59
+ return {
60
+ action: _analytics.ACTION.FAILED_TO_INSERT,
61
+ actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
62
+ actionSubjectId: actionSubjectId,
63
+ attributes: {
64
+ inputMethod: inputMethod,
65
+ fileExtension: media,
66
+ insertMediaVia: insertMediaVia,
67
+ reason: reason
68
+ },
69
+ eventType: _analytics.EVENT_TYPE.OPERATIONAL
70
+ };
71
+ };
56
72
  /**
57
73
  * Check if current editor selections is a media group or not.
58
74
  * @param state Editor state
@@ -75,6 +91,27 @@ function shouldAppendParagraph(state, node) {
75
91
  return ((0, _utils.insideTableCell)(state) || (0, _utils.isInListItem)(state) || (0, _utils.isInLayoutColumn)(state) || (0, _selection.atTheEndOfDoc)(state) && (!(0, _mediaCommon.posOfPrecedingMediaGroup)(state) || (0, _mediaCommon.isSelectionNonMediaBlockNode)(state))) && !wasMediaNode;
76
92
  }
77
93
 
94
+ /**
95
+ * Check if node of type has been inserted successfully
96
+ */
97
+ var hasInsertedNodeOfType = function hasInsertedNodeOfType(tr, nodeType) {
98
+ var _tr$doc$nodeAt;
99
+ var insertPos = -1;
100
+ tr.steps.forEach(function (step) {
101
+ if (step instanceof _transform.ReplaceStep) {
102
+ step.slice.content.forEach(function (node) {
103
+ if (node.type.name === nodeType) {
104
+ insertPos = step.from;
105
+ }
106
+ });
107
+ }
108
+ });
109
+ if (insertPos === -1 || ((_tr$doc$nodeAt = tr.doc.nodeAt(insertPos)) === null || _tr$doc$nodeAt === void 0 ? void 0 : _tr$doc$nodeAt.type.name) !== nodeType) {
110
+ return false;
111
+ }
112
+ return true;
113
+ };
114
+
78
115
  /**
79
116
  * Create a new media inline to insert the new media.
80
117
  * @param view Editor view
@@ -129,12 +166,33 @@ var insertMediaInlineNode = exports.insertMediaInlineNode = function insertMedia
129
166
 
130
167
  // Delete the selection if a selection is made
131
168
  var deleteRange = findDeleteRange(state);
132
- if (!deleteRange) {
133
- tr.insert(pos, content);
169
+ if ((0, _platformFeatureFlags.fg)('platform_editor_track_media_fail_to_insert')) {
170
+ var payload;
171
+ try {
172
+ if (!deleteRange) {
173
+ tr.insert(pos, content);
174
+ } else {
175
+ tr.insert(pos, content).deleteRange(deleteRange.start, deleteRange.end);
176
+ }
177
+ if (hasInsertedNodeOfType(tr, 'mediaInline')) {
178
+ payload = getInsertMediaInlineAnalytics(mediaState, inputMethod, insertMediaVia);
179
+ } else {
180
+ payload = getFailToInsertAnalytics(mediaState, _analytics.ACTION_SUBJECT_ID.MEDIA_INLINE, inputMethod, insertMediaVia);
181
+ }
182
+ } catch (error) {
183
+ payload = getFailToInsertAnalytics(mediaState, _analytics.ACTION_SUBJECT_ID.MEDIA_INLINE, inputMethod, insertMediaVia,
184
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
185
+ error.toString());
186
+ }
187
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
134
188
  } else {
135
- tr.insert(pos, content).deleteRange(deleteRange.start, deleteRange.end);
189
+ if (!deleteRange) {
190
+ tr.insert(pos, content);
191
+ } else {
192
+ tr.insert(pos, content).deleteRange(deleteRange.start, deleteRange.end);
193
+ }
194
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaInlineAnalytics(mediaState, inputMethod, insertMediaVia))(tr);
136
195
  }
137
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaInlineAnalytics(mediaState, inputMethod, insertMediaVia))(tr);
138
196
  dispatch(tr);
139
197
  return true;
140
198
  };
@@ -12,6 +12,8 @@ var _reactIntlNext = require("react-intl-next");
12
12
  var _analytics = require("@atlaskit/editor-common/analytics");
13
13
  var _hooks = require("@atlaskit/editor-common/hooks");
14
14
  var _mediaSingle = require("@atlaskit/editor-common/media-single");
15
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
16
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
15
17
  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); }
16
18
  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; }
17
19
  var CommentBadgeWrapper = function CommentBadgeWrapper(_ref) {
@@ -26,23 +28,37 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref) {
26
28
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
27
29
  entered = _useState2[0],
28
30
  setEntered = _useState2[1];
29
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['annotation']),
31
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['annotation'], {
32
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
33
+ }),
30
34
  annotationState = _useSharedPluginState.annotationState;
35
+ var selectedAnnotationsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.selectedAnnotations', {
36
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
37
+ });
38
+ var isInlineCommentViewClosedSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.isInlineCommentViewClosed', {
39
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
40
+ });
41
+ var annotationsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.annotations', {
42
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
43
+ });
44
+ var selectedAnnotations = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? selectedAnnotationsSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.selectedAnnotations;
45
+ var isInlineCommentViewClosed = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? isInlineCommentViewClosedSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isInlineCommentViewClosed;
46
+ var annotations = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? annotationsSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations;
31
47
  var _view$state$schema = view.state.schema,
32
48
  media = _view$state$schema.nodes.media,
33
49
  annotation = _view$state$schema.marks.annotation,
34
50
  state = view.state,
35
51
  dispatch = view.dispatch;
36
52
  var status = (0, _react.useMemo)(function () {
37
- if (!(annotationState !== null && annotationState !== void 0 && annotationState.selectedAnnotations) || !mediaNode) {
53
+ if (!selectedAnnotations || !mediaNode) {
38
54
  return 'default';
39
55
  }
40
- return annotationState.selectedAnnotations.some(function (annotation) {
56
+ return selectedAnnotations.some(function (annotation) {
41
57
  return !!mediaNode.marks.find(function (mark) {
42
58
  return mark.attrs.id === annotation.id;
43
59
  });
44
- }) && !annotationState.isInlineCommentViewClosed ? 'active' : 'default';
45
- }, [annotationState, mediaNode]);
60
+ }) && !isInlineCommentViewClosed ? 'active' : 'default';
61
+ }, [selectedAnnotations, isInlineCommentViewClosed, mediaNode]);
46
62
  var onClick = (0, _react.useCallback)(function () {
47
63
  if (api.annotation && mediaNode) {
48
64
  var showCommentForBlockNode = api.annotation.actions.showCommentForBlockNode;
@@ -50,8 +66,8 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref) {
50
66
  }
51
67
  }, [api.annotation, dispatch, mediaNode, state]);
52
68
  var pos = getPos();
53
- var hasNoComments = !Number.isFinite(pos) || !(annotationState !== null && annotationState !== void 0 && annotationState.annotations) || !mediaNode || mediaNode.type !== media || mediaNode.marks.every(function (maybeAnnotation) {
54
- return maybeAnnotation.type !== annotation || !(maybeAnnotation.attrs.id in annotationState.annotations) || annotationState.annotations[maybeAnnotation.attrs.id];
69
+ var hasNoComments = !Number.isFinite(pos) || !annotations || !mediaNode || mediaNode.type !== media || mediaNode.marks.every(function (maybeAnnotation) {
70
+ return maybeAnnotation.type !== annotation || !(maybeAnnotation.attrs.id in annotations) || annotations[maybeAnnotation.attrs.id];
55
71
  });
56
72
  if (!isDrafting && hasNoComments || !mediaNode) {
57
73
  return null;
@@ -98,23 +114,37 @@ var CommentBadgeNextWrapper = exports.CommentBadgeNextWrapper = function Comment
98
114
  _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
99
115
  entered = _useState4[0],
100
116
  setEntered = _useState4[1];
101
- var _useSharedPluginState2 = (0, _hooks.useSharedPluginState)(api, ['annotation']),
117
+ var _useSharedPluginState2 = (0, _hooks.useSharedPluginState)(api, ['annotation'], {
118
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
119
+ }),
102
120
  annotationState = _useSharedPluginState2.annotationState;
121
+ var selectedAnnotationsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.selectedAnnotations', {
122
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
123
+ });
124
+ var isInlineCommentViewClosedSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.isInlineCommentViewClosed', {
125
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
126
+ });
127
+ var annotationsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.annotations', {
128
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
129
+ });
130
+ var selectedAnnotations = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? selectedAnnotationsSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.selectedAnnotations;
131
+ var isInlineCommentViewClosed = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? isInlineCommentViewClosedSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isInlineCommentViewClosed;
132
+ var annotations = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? annotationsSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations;
103
133
  var _view$state$schema2 = view.state.schema,
104
134
  media = _view$state$schema2.nodes.media,
105
135
  annotation = _view$state$schema2.marks.annotation,
106
136
  state = view.state,
107
137
  dispatch = view.dispatch;
108
138
  var status = (0, _react.useMemo)(function () {
109
- if (!(annotationState !== null && annotationState !== void 0 && annotationState.selectedAnnotations) || !mediaNode) {
139
+ if (!selectedAnnotations || !mediaNode) {
110
140
  return 'default';
111
141
  }
112
- return annotationState.selectedAnnotations.some(function (annotation) {
142
+ return selectedAnnotations.some(function (annotation) {
113
143
  return !!mediaNode.marks.find(function (mark) {
114
144
  return mark.attrs.id === annotation.id;
115
145
  });
116
- }) && !annotationState.isInlineCommentViewClosed ? 'active' : 'default';
117
- }, [annotationState, mediaNode]);
146
+ }) && !isInlineCommentViewClosed ? 'active' : 'default';
147
+ }, [selectedAnnotations, isInlineCommentViewClosed, mediaNode]);
118
148
  var onClick = (0, _react.useCallback)(function () {
119
149
  if (api.annotation && mediaNode) {
120
150
  var showCommentForBlockNode = api.annotation.actions.showCommentForBlockNode;
@@ -122,8 +152,8 @@ var CommentBadgeNextWrapper = exports.CommentBadgeNextWrapper = function Comment
122
152
  }
123
153
  }, [api.annotation, dispatch, mediaNode, state]);
124
154
  var pos = getPos();
125
- var hasNoComments = !Number.isFinite(pos) || !(annotationState !== null && annotationState !== void 0 && annotationState.annotations) || !mediaNode || mediaNode.type !== media || mediaNode.marks.every(function (maybeAnnotation) {
126
- return maybeAnnotation.type !== annotation || !(maybeAnnotation.attrs.id in annotationState.annotations) || annotationState.annotations[maybeAnnotation.attrs.id];
155
+ var hasNoComments = !Number.isFinite(pos) || !annotations || !mediaNode || mediaNode.type !== media || mediaNode.marks.every(function (maybeAnnotation) {
156
+ return maybeAnnotation.type !== annotation || !(maybeAnnotation.attrs.id in annotations) || annotations[maybeAnnotation.attrs.id];
127
157
  });
128
158
  if (!isDrafting && hasNoComments || !mediaNode) {
129
159
  return null;
@@ -13,6 +13,8 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
13
13
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
14
  var _react = _interopRequireDefault(require("react"));
15
15
  var _hooks = require("@atlaskit/editor-common/hooks");
16
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
17
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
16
18
  var _BrowserWrapper = require("./BrowserWrapper");
17
19
  var _ClipboardWrapper = require("./ClipboardWrapper");
18
20
  var _DropzoneWrapper = require("./DropzoneWrapper");
@@ -26,9 +28,19 @@ var MediaPicker = function MediaPicker(_ref) {
26
28
  mediaState = _ref.mediaState,
27
29
  onBrowseFn = _ref.onBrowseFn,
28
30
  editorDomElement = _ref.editorDomElement;
29
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['focus', 'connectivity']),
31
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['focus', 'connectivity'], {
32
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
33
+ }),
30
34
  focusState = _useSharedPluginState.focusState,
31
35
  connectivityState = _useSharedPluginState.connectivityState;
36
+ var hasFocusSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'focus.hasFocus', {
37
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
38
+ });
39
+ var connectivityModeSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'connectivity.mode', {
40
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
41
+ });
42
+ var hasFocus = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? hasFocusSelector : focusState === null || focusState === void 0 ? void 0 : focusState.hasFocus;
43
+ var connectivityMode = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? connectivityModeSelector : connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode;
32
44
  var featureFlags = mediaState.mediaOptions && mediaState.mediaOptions.featureFlags;
33
45
 
34
46
  // Ignored via go/ees005
@@ -43,7 +55,7 @@ var MediaPicker = function MediaPicker(_ref) {
43
55
  * as stopImmediatePropagation could cause race condition issues
44
56
  */
45
57
  var container = editorParent;
46
- var clipboard = focusState !== null && focusState !== void 0 && focusState.hasFocus ? /*#__PURE__*/_react.default.createElement(_ClipboardWrapper.ClipboardWrapper, {
58
+ var clipboard = hasFocus ? /*#__PURE__*/_react.default.createElement(_ClipboardWrapper.ClipboardWrapper, {
47
59
  mediaState: mediaState,
48
60
  featureFlags: featureFlags,
49
61
  container: container
@@ -52,7 +64,7 @@ var MediaPicker = function MediaPicker(_ref) {
52
64
  mediaState: mediaState,
53
65
  isActive: !isPopupOpened &&
54
66
  // If we're offline don't show the dropzone
55
- (connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode) !== 'offline',
67
+ connectivityMode !== 'offline',
56
68
  featureFlags: featureFlags,
57
69
  editorDomElement: editorDomElement,
58
70
  appearance: appearance
@@ -29,7 +29,8 @@ var mediaViewerContainerTestID = 'media-viewer-container-test';
29
29
  var MediaViewerContainer = exports.MediaViewerContainer = function MediaViewerContainer(_ref) {
30
30
  var _mediaNode$firstChild;
31
31
  var mediaNode = _ref.mediaNode,
32
- mediaPluginState = _ref.mediaPluginState,
32
+ selectedMediaContainerNode = _ref.selectedMediaContainerNode,
33
+ mediaClientConfig = _ref.mediaClientConfig,
33
34
  _ref$isEditorViewMode = _ref.isEditorViewMode,
34
35
  isEditorViewMode = _ref$isEditorViewMode === void 0 ? false : _ref$isEditorViewMode,
35
36
  _ref$isSelected = _ref.isSelected,
@@ -44,8 +45,7 @@ var MediaViewerContainer = exports.MediaViewerContainer = function MediaViewerCo
44
45
  (0, _react.useEffect)(function () {
45
46
  setShowMediaViewer(isSelected);
46
47
  }, [isSelected]);
47
- var selectedNodeAttrs = (0, _utils.getSelectedNearestMediaContainerNodeAttrs)(mediaPluginState);
48
- var mediaClientConfig = mediaPluginState.mediaClientConfig;
48
+ var selectedNodeAttrs = (0, _utils.getSelectedNearestMediaContainerNodeAttrsFunction)(selectedMediaContainerNode);
49
49
  var showMediaViewer = function showMediaViewer() {
50
50
  setShowMediaViewer(true);
51
51
  };
@@ -21,6 +21,7 @@ var _react2 = require("@emotion/react");
21
21
  var _classnames = _interopRequireDefault(require("classnames"));
22
22
  var _throttle = _interopRequireDefault(require("lodash/throttle"));
23
23
  var _memoizeOne = _interopRequireDefault(require("memoize-one"));
24
+ var _coreUtils = require("@atlaskit/editor-common/core-utils");
24
25
  var _guideline = require("@atlaskit/editor-common/guideline");
25
26
  var _mediaSingle = require("@atlaskit/editor-common/media-single");
26
27
  var _resizer = require("@atlaskit/editor-common/resizer");
@@ -543,7 +544,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
543
544
  var resizerNextClassName = (0, _classnames.default)(className, _styles.resizerStyles);
544
545
  var isNestedNode = this.isAdjacentMode();
545
546
  var handlePositioning = this.getHandlePositioning();
546
- var maxWidth = this.getMaxWidth();
547
+ var maxWidth = (0, _coreUtils.isSSR)() && size.width && (0, _platformFeatureFlags.fg)('platform_editor_fix_image_size_diff_during_ssr') ? undefined : this.getMaxWidth();
547
548
  var minWidth = this.calcMinWidth(isVideoFile, lineLength);
548
549
 
549
550
  // while is not resizing, we take 100% as min-width if the container width is less than the min-width