@atlaskit/editor-plugin-media 2.7.0 → 2.7.2

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 (59) hide show
  1. package/CHANGELOG.md +24 -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/mediaNodeView/index.js +11 -3
  6. package/dist/cjs/nodeviews/mediaSingle.js +87 -48
  7. package/dist/cjs/nodeviews/mediaSingleNext.js +5 -4
  8. package/dist/cjs/pm-plugins/utils/media-files.js +64 -6
  9. package/dist/cjs/ui/CommentBadge/index.js +44 -14
  10. package/dist/cjs/ui/ImageBorder/styles.js +1 -2
  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/mediaNodeView/index.js +11 -3
  21. package/dist/es2019/nodeviews/mediaSingle.js +59 -24
  22. package/dist/es2019/nodeviews/mediaSingleNext.js +5 -4
  23. package/dist/es2019/pm-plugins/utils/media-files.js +63 -5
  24. package/dist/es2019/ui/CommentBadge/index.js +40 -10
  25. package/dist/es2019/ui/ImageBorder/styles.js +1 -2
  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/mediaNodeView/index.js +11 -3
  36. package/dist/esm/nodeviews/mediaSingle.js +87 -48
  37. package/dist/esm/nodeviews/mediaSingleNext.js +5 -4
  38. package/dist/esm/pm-plugins/utils/media-files.js +63 -5
  39. package/dist/esm/ui/CommentBadge/index.js +44 -14
  40. package/dist/esm/ui/ImageBorder/styles.js +1 -2
  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/ui/MediaViewer/MediaViewerContainer.d.ts +4 -3
  52. package/dist/types/ui/toolbar/utils.d.ts +1 -0
  53. package/dist/types-ts4.5/nodeviews/mediaInline.d.ts +7 -2
  54. package/dist/types-ts4.5/nodeviews/mediaSingleNext.d.ts +3 -4
  55. package/dist/types-ts4.5/nodeviews/types.d.ts +3 -4
  56. package/dist/types-ts4.5/pm-plugins/utils/media-files.d.ts +3 -2
  57. package/dist/types-ts4.5/ui/MediaViewer/MediaViewerContainer.d.ts +4 -3
  58. package/dist/types-ts4.5/ui/toolbar/utils.d.ts +1 -0
  59. package/package.json +10 -4
@@ -10,10 +10,12 @@ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
10
10
  import { MediaInlineImageCard } from '@atlaskit/editor-common/media-inline';
11
11
  import { WithProviders } from '@atlaskit/editor-common/provider-factory';
12
12
  import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
13
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
13
14
  import { MediaInlineCard } from '@atlaskit/media-card';
14
15
  import { getMediaClient } from '@atlaskit/media-client-react';
15
16
  import { MediaInlineCardLoadingView } from '@atlaskit/media-ui';
16
17
  import { fg } from '@atlaskit/platform-feature-flags';
18
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
17
19
  import { isImage } from '../pm-plugins/utils/is-type';
18
20
  import { MediaViewerContainer } from '../ui/MediaViewer/MediaViewerContainer';
19
21
  import { MediaNodeUpdater } from './mediaNodeUpdater';
@@ -37,7 +39,7 @@ const createMediaNodeUpdater = props => {
37
39
  const updateMediaNodeAttributes = async (props, mediaNodeUpdater) => {
38
40
  const {
39
41
  addPendingTask
40
- } = props.mediaPluginState;
42
+ } = props;
41
43
  const node = props.node;
42
44
  if (!node) {
43
45
  return;
@@ -64,10 +66,10 @@ const updateMediaNodeAttributes = async (props, mediaNodeUpdater) => {
64
66
  export const handleNewNode = props => {
65
67
  const {
66
68
  node,
67
- mediaPluginState,
69
+ handleMediaNodeMount,
68
70
  getPos
69
71
  } = props;
70
- mediaPluginState.handleMediaNodeMount(node, () => getPos());
72
+ handleMediaNodeMount(node, () => getPos());
71
73
  };
72
74
  export const MediaInline = props => {
73
75
  var _props$node, _props$node$marks;
@@ -81,9 +83,9 @@ export const MediaInline = props => {
81
83
  updateViewMediaClientConfig(props);
82
84
  return () => {
83
85
  const {
84
- mediaPluginState
86
+ handleMediaNodeUnmount
85
87
  } = props;
86
- mediaPluginState.handleMediaNodeUnmount(props.node);
88
+ handleMediaNodeUnmount(props.node);
87
89
  };
88
90
  }, [props]);
89
91
  const updateViewMediaClientConfig = async props => {
@@ -124,7 +126,7 @@ export const MediaInline = props => {
124
126
  }
125
127
  const {
126
128
  allowInlineImages
127
- } = props.mediaPluginState;
129
+ } = props;
128
130
  const borderMark = (_props$node = props.node) === null || _props$node === void 0 ? void 0 : (_props$node$marks = _props$node.marks) === null || _props$node$marks === void 0 ? void 0 : _props$node$marks.find(mark => mark.type.name === 'border');
129
131
  if (allowInlineImages && isImage(type)) {
130
132
  return jsx(MediaInlineImageCard, {
@@ -143,7 +145,8 @@ export const MediaInline = props => {
143
145
  }
144
146
  return jsx(MediaViewerContainer, {
145
147
  mediaNode: props.node,
146
- mediaPluginState: props.mediaPluginState,
148
+ selectedMediaContainerNode: props.selectedMediaContainerNode,
149
+ mediaClientConfig: props.mediaClientConfig,
147
150
  isEditorViewMode: props.editorViewMode,
148
151
  isSelected: props.isSelected,
149
152
  isInline: fg('platform_editor_render_media_viewer_as_inline')
@@ -165,21 +168,60 @@ const MediaInlineSharedState = ({
165
168
  const {
166
169
  editorViewModeState,
167
170
  mediaState
168
- } = useSharedPluginState(api, ['editorViewMode', 'media']);
169
- const newMediaProvider = useMemo(() => mediaState !== null && mediaState !== void 0 && mediaState.mediaProvider ? Promise.resolve(mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider) : undefined, [mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider]);
170
- if (!mediaState || !newMediaProvider) {
171
+ } = useSharedPluginState(api, ['editorViewMode', 'media'], {
172
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
173
+ });
174
+ const viewModeSelector = useSharedPluginStateSelector(api, 'editorViewMode.mode', {
175
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
176
+ });
177
+ const mediaProviderSelector = useSharedPluginStateSelector(api, 'media.mediaProvider', {
178
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
179
+ });
180
+ const handleMediaNodeMountSelector = useSharedPluginStateSelector(api, 'media.handleMediaNodeMount', {
181
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
182
+ });
183
+ const handleMediaNodeUnmountSelector = useSharedPluginStateSelector(api, 'media.handleMediaNodeUnmount', {
184
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
185
+ });
186
+ const allowInlineImagesSelector = useSharedPluginStateSelector(api, 'media.allowInlineImages', {
187
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
188
+ });
189
+ const addPendingTaskSelector = useSharedPluginStateSelector(api, 'media.addPendingTask', {
190
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
191
+ });
192
+ const selectedMediaContainerNodeSelector = useSharedPluginStateSelector(api, 'media.selectedMediaContainerNode', {
193
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
194
+ });
195
+ const mediaClientConfigSelector = useSharedPluginStateSelector(api, 'media.mediaClientConfig', {
196
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
197
+ });
198
+ const viewMode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? viewModeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
199
+ const mediaProvider = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? mediaProviderSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider;
200
+ const handleMediaNodeMount = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? handleMediaNodeMountSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.handleMediaNodeMount;
201
+ const handleMediaNodeUnmount = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? handleMediaNodeUnmountSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.handleMediaNodeUnmount;
202
+ const allowInlineImages = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? allowInlineImagesSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.allowInlineImages;
203
+ const addPendingTask = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? addPendingTaskSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.addPendingTask;
204
+ const selectedMediaContainerNode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectedMediaContainerNodeSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.selectedMediaContainerNode;
205
+ const mediaClientConfig = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? mediaClientConfigSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaClientConfig;
206
+ const newMediaProvider = useMemo(() => mediaProvider ? Promise.resolve(mediaProvider) : undefined, [mediaProvider]);
207
+ if (!handleMediaNodeMount || !handleMediaNodeUnmount || !addPendingTask || !selectedMediaContainerNode || !mediaClientConfig || !newMediaProvider) {
171
208
  return null;
172
209
  }
173
210
  return jsx(MediaInline, {
174
211
  identifier: identifier,
175
212
  mediaProvider: newMediaProvider,
176
- mediaPluginState: mediaState,
213
+ handleMediaNodeMount: handleMediaNodeMount,
214
+ handleMediaNodeUnmount: handleMediaNodeUnmount,
215
+ allowInlineImages: allowInlineImages,
216
+ addPendingTask: addPendingTask,
217
+ selectedMediaContainerNode: selectedMediaContainerNode,
218
+ mediaClientConfig: mediaClientConfig,
177
219
  node: node,
178
220
  isSelected: isSelected,
179
221
  view: view,
180
222
  getPos: getPos,
181
223
  contextIdentifierProvider: contextIdentifierProvider,
182
- editorViewMode: (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view'
224
+ editorViewMode: viewMode === 'view'
183
225
  });
184
226
  };
185
227
  export class MediaInlineNodeView extends SelectionBasedNodeView {
@@ -4,7 +4,9 @@ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
4
  import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
5
5
  import { WithProviders } from '@atlaskit/editor-common/provider-factory';
6
6
  import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
7
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
7
8
  import { getAttrsFromUrl } from '@atlaskit/media-client';
9
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
10
  import { updateCurrentMediaNodeAttrs } from '../../pm-plugins/commands/helpers';
9
11
  import { isMediaBlobUrlFromAttrs } from '../../pm-plugins/utils/media-common';
10
12
  // Ignored via go/ees005
@@ -17,10 +19,16 @@ const MediaNodeWithProviders = ({
17
19
  const {
18
20
  widthState,
19
21
  mediaState
20
- } = useSharedPluginState(pluginInjectionApi, ['width', 'media']);
22
+ } = useSharedPluginState(pluginInjectionApi, ['width', 'media'], {
23
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
24
+ });
25
+ const mediaProviderSelector = useSharedPluginStateSelector(pluginInjectionApi, 'media.mediaProvider', {
26
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
27
+ });
28
+ const mediaProvider = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? mediaProviderSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider;
21
29
  return innerComponent({
22
- width: widthState,
23
- mediaProvider: mediaState !== null && mediaState !== void 0 && mediaState.mediaProvider ? Promise.resolve(mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider) : undefined
30
+ width: editorExperiment('platform_editor_usesharedpluginstateselector', true) ? widthState : undefined,
31
+ mediaProvider: mediaProvider ? Promise.resolve(mediaProvider) : undefined
24
32
  });
25
33
  };
26
34
  function isMediaDecorationSpec(decoration) {
@@ -23,6 +23,7 @@ import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/u
23
23
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
24
24
  import { getAttrsFromUrl } from '@atlaskit/media-client';
25
25
  import { fg } from '@atlaskit/platform-feature-flags';
26
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
26
27
  import { insertAndSelectCaptionFromMediaSinglePos } from '../pm-plugins/commands/captions';
27
28
  import { MEDIA_CONTENT_WRAP_CLASS_NAME } from '../pm-plugins/main';
28
29
  import { isMediaBlobUrlFromAttrs } from '../pm-plugins/utils/media-common';
@@ -85,7 +86,10 @@ export default class MediaSingleNode extends Component {
85
86
  this.createOrUpdateMediaNodeUpdater(props);
86
87
  const {
87
88
  addPendingTask
88
- } = this.props.mediaPluginState;
89
+ } = this.props;
90
+ if (!addPendingTask) {
91
+ return;
92
+ }
89
93
 
90
94
  // we want the first child of MediaSingle (type "media")
91
95
  const node = this.props.node.firstChild;
@@ -267,7 +271,8 @@ export default class MediaSingleNode extends Component {
267
271
  dispatchAnalyticsEvent,
268
272
  editorViewMode,
269
273
  editorDisabled,
270
- annotationPluginState,
274
+ isDrafting,
275
+ targetNodeId,
271
276
  editorAppearance
272
277
  } = this.props;
273
278
  const {
@@ -376,7 +381,7 @@ export default class MediaSingleNode extends Component {
376
381
  const badgeOffsetRight = isBadgePosOffsetRight();
377
382
  let shouldShowPlaceholder = mediaOptions.allowCaptions && node.childCount !== 2 && isSelected && state.selection instanceof NodeSelection;
378
383
  shouldShowPlaceholder = !editorDisabled && shouldShowPlaceholder;
379
- const isCurrentNodeDrafting = (annotationPluginState === null || annotationPluginState === void 0 ? void 0 : annotationPluginState.isDrafting) && (annotationPluginState === null || annotationPluginState === void 0 ? void 0 : annotationPluginState.targetNodeId) === (node === null || node === void 0 ? void 0 : (_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.attrs.id);
384
+ const isCurrentNodeDrafting = Boolean(isDrafting && targetNodeId === (node === null || node === void 0 ? void 0 : (_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.attrs.id));
380
385
  const pos = getPos();
381
386
  const isInsideTable = pos !== undefined && findParentNodeOfTypeClosestToPos(state.doc.resolve(pos), [state.schema.nodes.table]);
382
387
  const currentMediaElement = () => {
@@ -479,14 +484,48 @@ const MediaSingleNodeWrapper = ({
479
484
  annotationState,
480
485
  editorDisabledState,
481
486
  editorViewModeState
482
- } = useSharedPluginState(pluginInjectionApi, ['width', 'media', 'annotation', 'editorDisabled', 'editorViewMode']);
487
+ } = useSharedPluginState(pluginInjectionApi, ['width', 'media', 'annotation', 'editorDisabled', 'editorViewMode'], {
488
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
489
+ });
490
+ const mediaProviderSelector = useSharedPluginStateSelector(pluginInjectionApi, 'media.mediaProvider', {
491
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
492
+ });
493
+ const addPendingTaskSelector = useSharedPluginStateSelector(pluginInjectionApi, 'media.addPendingTask', {
494
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
495
+ });
496
+ const isDraftingSelector = useSharedPluginStateSelector(pluginInjectionApi, 'annotation.isDrafting', {
497
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
498
+ });
499
+ const targetNodeIdSelector = useSharedPluginStateSelector(pluginInjectionApi, 'annotation.targetNodeId', {
500
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
501
+ });
502
+ const widthSelector = useSharedPluginStateSelector(pluginInjectionApi, 'width.width', {
503
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
504
+ });
505
+ const lineLengthSelector = useSharedPluginStateSelector(pluginInjectionApi, 'width.lineLength', {
506
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
507
+ });
508
+ const editorDisabledSelector = useSharedPluginStateSelector(pluginInjectionApi, 'editorDisabled.editorDisabled', {
509
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
510
+ });
511
+ const viewModeSelector = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode', {
512
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
513
+ });
514
+ const mediaProviderState = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? mediaProviderSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider;
515
+ const addPendingTask = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? addPendingTaskSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.addPendingTask;
516
+ const isDrafting = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isDraftingSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isDrafting;
517
+ const targetNodeId = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? targetNodeIdSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.targetNodeId;
518
+ const width = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? widthSelector : widthState === null || widthState === void 0 ? void 0 : widthState.width;
519
+ const lineLength = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? lineLengthSelector : widthState === null || widthState === void 0 ? void 0 : widthState.lineLength;
520
+ const editorDisabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? editorDisabledSelector : editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled;
521
+ const viewMode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? viewModeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
483
522
  const hasHadInteraction = useSharedPluginStateSelector(pluginInjectionApi, 'interaction.hasHadInteraction');
484
- const mediaProvider = useMemo(() => mediaState !== null && mediaState !== void 0 && mediaState.mediaProvider ? Promise.resolve(mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider) : undefined, [mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider]);
523
+ const mediaProvider = useMemo(() => mediaProviderState ? Promise.resolve(mediaProviderState) : undefined, [mediaProviderState]);
485
524
  const isSelectedAndInteracted = useCallback(() => Boolean(selected() && hasHadInteraction !== false), [hasHadInteraction, selected]);
486
525
  if (fg('platform_editor_react18_phase2__media_single') || fg('platform_editor_react18_phase2__media_single_jira')) {
487
526
  return jsx(MediaSingleNodeNext, {
488
- width: (widthState === null || widthState === void 0 ? void 0 : widthState.width) || 0,
489
- lineLength: (widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || 0,
527
+ width: width || 0,
528
+ lineLength: lineLength || 0,
490
529
  node: node,
491
530
  getPos: getPos,
492
531
  mediaProvider: mediaProvider,
@@ -496,25 +535,20 @@ const MediaSingleNodeWrapper = ({
496
535
  fullWidthMode: fullWidthMode,
497
536
  selected: fg('platform_editor_no_selection_until_interaction') ? isSelectedAndInteracted : selected,
498
537
  eventDispatcher: eventDispatcher,
499
- mediaPluginState: mediaState !== null && mediaState !== void 0 ? mediaState : undefined,
500
- annotationPluginState: annotationState !== null && annotationState !== void 0 ? annotationState : undefined,
538
+ addPendingTask: addPendingTask,
539
+ isDrafting: isDrafting,
540
+ targetNodeId: targetNodeId,
501
541
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
502
542
  forwardRef: forwardRef,
503
543
  pluginInjectionApi: pluginInjectionApi,
504
- editorDisabled: editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled,
505
- editorViewMode: (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view',
544
+ editorDisabled: editorDisabled,
545
+ editorViewMode: viewMode === 'view',
506
546
  editorAppearance: editorAppearance
507
547
  });
508
548
  }
509
- return jsx(MediaSingleNode
510
- // Ignored via go/ees005
511
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
512
- , {
513
- width: widthState.width
514
- // Ignored via go/ees005
515
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
516
- ,
517
- lineLength: widthState.lineLength,
549
+ return jsx(MediaSingleNode, {
550
+ width: width,
551
+ lineLength: lineLength,
518
552
  node: node,
519
553
  getPos: getPos,
520
554
  mediaProvider: mediaProvider,
@@ -524,13 +558,14 @@ const MediaSingleNodeWrapper = ({
524
558
  fullWidthMode: fullWidthMode,
525
559
  selected: fg('platform_editor_no_selection_until_interaction') ? isSelectedAndInteracted : selected,
526
560
  eventDispatcher: eventDispatcher,
527
- mediaPluginState: mediaState !== null && mediaState !== void 0 ? mediaState : undefined,
528
- annotationPluginState: annotationState !== null && annotationState !== void 0 ? annotationState : undefined,
561
+ addPendingTask: addPendingTask,
562
+ isDrafting: isDrafting,
563
+ targetNodeId: targetNodeId,
529
564
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
530
565
  forwardRef: forwardRef,
531
566
  pluginInjectionApi: pluginInjectionApi,
532
- editorDisabled: editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled,
533
- editorViewMode: (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view',
567
+ editorDisabled: editorDisabled,
568
+ editorViewMode: viewMode === 'view',
534
569
  editorAppearance: editorAppearance
535
570
  });
536
571
  };
@@ -261,12 +261,13 @@ export const MediaSingleNodeNext = mediaSingleNodeNextProps => {
261
261
  dispatchAnalyticsEvent,
262
262
  editorViewMode,
263
263
  editorDisabled,
264
- annotationPluginState,
264
+ isDrafting,
265
+ targetNodeId,
265
266
  editorAppearance,
266
267
  mediaProvider: mediaProviderPromise,
267
268
  forwardRef,
268
269
  contextIdentifierProvider: contextIdentifierProviderPromise,
269
- mediaPluginState
270
+ addPendingTask
270
271
  } = mediaSingleNodeNextProps;
271
272
  const [mediaProvider, setMediaProvider] = React.useState(null);
272
273
  const [_contextIdentifierProvider, setContextIdentifierProvider] = React.useState(null);
@@ -286,7 +287,7 @@ export const MediaSingleNodeNext = mediaSingleNodeNextProps => {
286
287
  mediaNodeUpdater,
287
288
  getPos,
288
289
  mediaNode,
289
- addPendingTask: (mediaPluginState === null || mediaPluginState === void 0 ? void 0 : mediaPluginState.addPendingTask) || noop
290
+ addPendingTask: addPendingTask || noop
290
291
  });
291
292
  React.useLayoutEffect(() => {
292
293
  mountedRef.current = true;
@@ -398,7 +399,7 @@ export const MediaSingleNodeNext = mediaSingleNodeNextProps => {
398
399
  }, [mediaSingleWidthAttribute, widthType, width, layout, contentWidthForLegacyExperience, containerWidth]);
399
400
  const currentMaxWidth = isSelected ? pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$m = pluginInjectionApi.media) === null || _pluginInjectionApi$m === void 0 ? void 0 : (_pluginInjectionApi$m2 = _pluginInjectionApi$m.sharedState.currentState()) === null || _pluginInjectionApi$m2 === void 0 ? void 0 : _pluginInjectionApi$m2.currentMaxWidth : undefined;
400
401
  const contentWidth = currentMaxWidth || lineLength;
401
- const 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 ? void 0 : (_mediaNode$firstChild = mediaNode.firstChild) === null || _mediaNode$firstChild === void 0 ? void 0 : _mediaNode$firstChild.attrs.id));
402
+ const isCurrentNodeDrafting = Boolean(isDrafting && targetNodeId === (mediaNode === null || mediaNode === void 0 ? void 0 : (_mediaNode$firstChild = mediaNode.firstChild) === null || _mediaNode$firstChild === void 0 ? void 0 : _mediaNode$firstChild.attrs.id));
402
403
  const mediaSingleWrapperRef = /*#__PURE__*/React.createRef();
403
404
  const captionPlaceHolderRef = /*#__PURE__*/React.createRef();
404
405
  const onMediaSingleClicked = React.useCallback(event => {
@@ -3,7 +3,9 @@ import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-comm
3
3
  import { atTheBeginningOfBlock, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, startPositionOfParent } from '@atlaskit/editor-common/selection';
4
4
  import { findFarthestParentNode, insideTableCell, isInLayoutColumn, isInListItem, isSupportedInParent, setNodeSelection, setTextSelection } from '@atlaskit/editor-common/utils';
5
5
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
6
+ import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
6
7
  import { canInsert, hasParentNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
7
9
  import { isImage } from './is-type';
8
10
  import { copyOptionalAttrsFromMediaState, isInsidePotentialEmptyParagraph, isSelectionNonMediaBlockNode, posOfMediaGroupNearby, posOfParentMediaGroup, posOfPrecedingMediaGroup } from './media-common';
9
11
  import { isInSupportedInlineImageParent } from './media-inline';
@@ -46,7 +48,21 @@ const getInsertMediaInlineAnalytics = (mediaState, inputMethod, insertMediaVia)
46
48
  eventType: EVENT_TYPE.TRACK
47
49
  };
48
50
  };
49
-
51
+ export const getFailToInsertAnalytics = (mediaState, actionSubjectId, inputMethod, insertMediaVia, reason) => {
52
+ const media = mediaState.fileMimeType || 'unknown';
53
+ return {
54
+ action: ACTION.FAILED_TO_INSERT,
55
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
56
+ actionSubjectId,
57
+ attributes: {
58
+ inputMethod,
59
+ fileExtension: media,
60
+ insertMediaVia,
61
+ reason
62
+ },
63
+ eventType: EVENT_TYPE.OPERATIONAL
64
+ };
65
+ };
50
66
  /**
51
67
  * Check if current editor selections is a media group or not.
52
68
  * @param state Editor state
@@ -77,6 +93,27 @@ function shouldAppendParagraph(state, node) {
77
93
  return (insideTableCell(state) || isInListItem(state) || isInLayoutColumn(state) || atTheEndOfDoc(state) && (!posOfPrecedingMediaGroup(state) || isSelectionNonMediaBlockNode(state))) && !wasMediaNode;
78
94
  }
79
95
 
96
+ /**
97
+ * Check if node of type has been inserted successfully
98
+ */
99
+ const hasInsertedNodeOfType = (tr, nodeType) => {
100
+ var _tr$doc$nodeAt;
101
+ let insertPos = -1;
102
+ tr.steps.forEach(step => {
103
+ if (step instanceof ReplaceStep) {
104
+ step.slice.content.forEach(node => {
105
+ if (node.type.name === nodeType) {
106
+ insertPos = step.from;
107
+ }
108
+ });
109
+ }
110
+ });
111
+ if (insertPos === -1 || ((_tr$doc$nodeAt = tr.doc.nodeAt(insertPos)) === null || _tr$doc$nodeAt === void 0 ? void 0 : _tr$doc$nodeAt.type.name) !== nodeType) {
112
+ return false;
113
+ }
114
+ return true;
115
+ };
116
+
80
117
  /**
81
118
  * Create a new media inline to insert the new media.
82
119
  * @param view Editor view
@@ -138,12 +175,33 @@ export const insertMediaInlineNode = editorAnalyticsAPI => (view, mediaState, co
138
175
 
139
176
  // Delete the selection if a selection is made
140
177
  const deleteRange = findDeleteRange(state);
141
- if (!deleteRange) {
142
- tr.insert(pos, content);
178
+ if (fg('platform_editor_track_media_fail_to_insert')) {
179
+ let payload;
180
+ try {
181
+ if (!deleteRange) {
182
+ tr.insert(pos, content);
183
+ } else {
184
+ tr.insert(pos, content).deleteRange(deleteRange.start, deleteRange.end);
185
+ }
186
+ if (hasInsertedNodeOfType(tr, 'mediaInline')) {
187
+ payload = getInsertMediaInlineAnalytics(mediaState, inputMethod, insertMediaVia);
188
+ } else {
189
+ payload = getFailToInsertAnalytics(mediaState, ACTION_SUBJECT_ID.MEDIA_INLINE, inputMethod, insertMediaVia);
190
+ }
191
+ } catch (error) {
192
+ payload = getFailToInsertAnalytics(mediaState, ACTION_SUBJECT_ID.MEDIA_INLINE, inputMethod, insertMediaVia,
193
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
194
+ error.toString());
195
+ }
196
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
143
197
  } else {
144
- tr.insert(pos, content).deleteRange(deleteRange.start, deleteRange.end);
198
+ if (!deleteRange) {
199
+ tr.insert(pos, content);
200
+ } else {
201
+ tr.insert(pos, content).deleteRange(deleteRange.start, deleteRange.end);
202
+ }
203
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaInlineAnalytics(mediaState, inputMethod, insertMediaVia))(tr);
145
204
  }
146
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaInlineAnalytics(mediaState, inputMethod, insertMediaVia))(tr);
147
205
  dispatch(tr);
148
206
  return true;
149
207
  };
@@ -3,6 +3,8 @@ import { injectIntl } from 'react-intl-next';
3
3
  import { VIEW_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
5
  import { CommentBadge as CommentBadgeComponent, CommentBadgeNext } from '@atlaskit/editor-common/media-single';
6
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
7
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
6
8
  const CommentBadgeWrapper = ({
7
9
  api,
8
10
  mediaNode,
@@ -15,7 +17,21 @@ const CommentBadgeWrapper = ({
15
17
  const [entered, setEntered] = useState(false);
16
18
  const {
17
19
  annotationState
18
- } = useSharedPluginState(api, ['annotation']);
20
+ } = useSharedPluginState(api, ['annotation'], {
21
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
22
+ });
23
+ const selectedAnnotationsSelector = useSharedPluginStateSelector(api, 'annotation.selectedAnnotations', {
24
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
25
+ });
26
+ const isInlineCommentViewClosedSelector = useSharedPluginStateSelector(api, 'annotation.isInlineCommentViewClosed', {
27
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
28
+ });
29
+ const annotationsSelector = useSharedPluginStateSelector(api, 'annotation.annotations', {
30
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
31
+ });
32
+ const selectedAnnotations = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectedAnnotationsSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.selectedAnnotations;
33
+ const isInlineCommentViewClosed = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isInlineCommentViewClosedSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isInlineCommentViewClosed;
34
+ const annotations = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? annotationsSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations;
19
35
  const {
20
36
  state: {
21
37
  schema: {
@@ -31,11 +47,11 @@ const CommentBadgeWrapper = ({
31
47
  dispatch
32
48
  } = view;
33
49
  const status = useMemo(() => {
34
- if (!(annotationState !== null && annotationState !== void 0 && annotationState.selectedAnnotations) || !mediaNode) {
50
+ if (!selectedAnnotations || !mediaNode) {
35
51
  return 'default';
36
52
  }
37
- return annotationState.selectedAnnotations.some(annotation => !!mediaNode.marks.find(mark => mark.attrs.id === annotation.id)) && !annotationState.isInlineCommentViewClosed ? 'active' : 'default';
38
- }, [annotationState, mediaNode]);
53
+ return selectedAnnotations.some(annotation => !!mediaNode.marks.find(mark => mark.attrs.id === annotation.id)) && !isInlineCommentViewClosed ? 'active' : 'default';
54
+ }, [selectedAnnotations, isInlineCommentViewClosed, mediaNode]);
39
55
  const onClick = useCallback(() => {
40
56
  if (api.annotation && mediaNode) {
41
57
  const {
@@ -45,7 +61,7 @@ const CommentBadgeWrapper = ({
45
61
  }
46
62
  }, [api.annotation, dispatch, mediaNode, state]);
47
63
  const pos = getPos();
48
- const hasNoComments = !Number.isFinite(pos) || !(annotationState !== null && annotationState !== void 0 && annotationState.annotations) || !mediaNode || mediaNode.type !== media || mediaNode.marks.every(maybeAnnotation => maybeAnnotation.type !== annotation || !(maybeAnnotation.attrs.id in annotationState.annotations) || annotationState.annotations[maybeAnnotation.attrs.id]);
64
+ const hasNoComments = !Number.isFinite(pos) || !annotations || !mediaNode || mediaNode.type !== media || mediaNode.marks.every(maybeAnnotation => maybeAnnotation.type !== annotation || !(maybeAnnotation.attrs.id in annotations) || annotations[maybeAnnotation.attrs.id]);
49
65
  if (!isDrafting && hasNoComments || !mediaNode) {
50
66
  return null;
51
67
  }
@@ -87,7 +103,21 @@ export const CommentBadgeNextWrapper = ({
87
103
  const [entered, setEntered] = useState(false);
88
104
  const {
89
105
  annotationState
90
- } = useSharedPluginState(api, ['annotation']);
106
+ } = useSharedPluginState(api, ['annotation'], {
107
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
108
+ });
109
+ const selectedAnnotationsSelector = useSharedPluginStateSelector(api, 'annotation.selectedAnnotations', {
110
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
111
+ });
112
+ const isInlineCommentViewClosedSelector = useSharedPluginStateSelector(api, 'annotation.isInlineCommentViewClosed', {
113
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
114
+ });
115
+ const annotationsSelector = useSharedPluginStateSelector(api, 'annotation.annotations', {
116
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
117
+ });
118
+ const selectedAnnotations = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectedAnnotationsSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.selectedAnnotations;
119
+ const isInlineCommentViewClosed = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isInlineCommentViewClosedSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isInlineCommentViewClosed;
120
+ const annotations = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? annotationsSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations;
91
121
  const {
92
122
  state: {
93
123
  schema: {
@@ -103,11 +133,11 @@ export const CommentBadgeNextWrapper = ({
103
133
  dispatch
104
134
  } = view;
105
135
  const status = useMemo(() => {
106
- if (!(annotationState !== null && annotationState !== void 0 && annotationState.selectedAnnotations) || !mediaNode) {
136
+ if (!selectedAnnotations || !mediaNode) {
107
137
  return 'default';
108
138
  }
109
- return annotationState.selectedAnnotations.some(annotation => !!mediaNode.marks.find(mark => mark.attrs.id === annotation.id)) && !annotationState.isInlineCommentViewClosed ? 'active' : 'default';
110
- }, [annotationState, mediaNode]);
139
+ return selectedAnnotations.some(annotation => !!mediaNode.marks.find(mark => mark.attrs.id === annotation.id)) && !isInlineCommentViewClosed ? 'active' : 'default';
140
+ }, [selectedAnnotations, isInlineCommentViewClosed, mediaNode]);
111
141
  const onClick = useCallback(() => {
112
142
  if (api.annotation && mediaNode) {
113
143
  const {
@@ -117,7 +147,7 @@ export const CommentBadgeNextWrapper = ({
117
147
  }
118
148
  }, [api.annotation, dispatch, mediaNode, state]);
119
149
  const pos = getPos();
120
- const hasNoComments = !Number.isFinite(pos) || !(annotationState !== null && annotationState !== void 0 && annotationState.annotations) || !mediaNode || mediaNode.type !== media || mediaNode.marks.every(maybeAnnotation => maybeAnnotation.type !== annotation || !(maybeAnnotation.attrs.id in annotationState.annotations) || annotationState.annotations[maybeAnnotation.attrs.id]);
150
+ const hasNoComments = !Number.isFinite(pos) || !annotations || !mediaNode || mediaNode.type !== media || mediaNode.marks.every(maybeAnnotation => maybeAnnotation.type !== annotation || !(maybeAnnotation.attrs.id in annotations) || annotations[maybeAnnotation.attrs.id]);
121
151
  if (!isDrafting && hasNoComments || !mediaNode) {
122
152
  return null;
123
153
  }
@@ -67,7 +67,6 @@ export const buttonStyle = selected => css`
67
67
  display: block;
68
68
  `;
69
69
 
70
- /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
71
70
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
72
71
  export const buttonWrapperStyle = css`
73
72
  border: 1px solid transparent;
@@ -80,7 +79,7 @@ export const buttonWrapperStyle = css`
80
79
  &:focus-within,
81
80
  &:focus,
82
81
  &:hover {
83
- border-color: ${N50} !important;
82
+ border-color: ${`var(--ds-border, ${N50})`} !important;
84
83
  }
85
84
  `;
86
85
  export const line = (size, selected) => css`
@@ -1,6 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
3
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
6
  import { BrowserWrapper } from './BrowserWrapper';
5
7
  import { ClipboardWrapper } from './ClipboardWrapper';
6
8
  import { DropzoneWrapper } from './DropzoneWrapper';
@@ -16,7 +18,17 @@ const MediaPicker = ({
16
18
  const {
17
19
  focusState,
18
20
  connectivityState
19
- } = useSharedPluginState(api, ['focus', 'connectivity']);
21
+ } = useSharedPluginState(api, ['focus', 'connectivity'], {
22
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
23
+ });
24
+ const hasFocusSelector = useSharedPluginStateSelector(api, 'focus.hasFocus', {
25
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
26
+ });
27
+ const connectivityModeSelector = useSharedPluginStateSelector(api, 'connectivity.mode', {
28
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
29
+ });
30
+ const hasFocus = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? hasFocusSelector : focusState === null || focusState === void 0 ? void 0 : focusState.hasFocus;
31
+ const connectivityMode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? connectivityModeSelector : connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode;
20
32
  const featureFlags = mediaState.mediaOptions && mediaState.mediaOptions.featureFlags;
21
33
 
22
34
  // Ignored via go/ees005
@@ -31,7 +43,7 @@ const MediaPicker = ({
31
43
  * as stopImmediatePropagation could cause race condition issues
32
44
  */
33
45
  const container = editorParent;
34
- const clipboard = focusState !== null && focusState !== void 0 && focusState.hasFocus ? /*#__PURE__*/React.createElement(ClipboardWrapper, {
46
+ const clipboard = hasFocus ? /*#__PURE__*/React.createElement(ClipboardWrapper, {
35
47
  mediaState: mediaState,
36
48
  featureFlags: featureFlags,
37
49
  container: container
@@ -40,7 +52,7 @@ const MediaPicker = ({
40
52
  mediaState: mediaState,
41
53
  isActive: !isPopupOpened &&
42
54
  // If we're offline don't show the dropzone
43
- (connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode) !== 'offline',
55
+ connectivityMode !== 'offline',
44
56
  featureFlags: featureFlags,
45
57
  editorDomElement: editorDomElement,
46
58
  appearance: appearance
@@ -8,7 +8,7 @@ import React, { Fragment, useEffect, useState } from 'react';
8
8
  import { css, jsx } from '@emotion/react';
9
9
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
10
  import { isVideo } from '../../pm-plugins/utils/is-type';
11
- import { getSelectedNearestMediaContainerNodeAttrs } from '../../ui/toolbar/utils';
11
+ import { getSelectedNearestMediaContainerNodeAttrsFunction } from '../../ui/toolbar/utils';
12
12
  import { RenderMediaViewer } from './PortalWrapper';
13
13
  const interactiveStyles = css({
14
14
  cursor: 'pointer'
@@ -16,7 +16,8 @@ const interactiveStyles = css({
16
16
  const mediaViewerContainerTestID = 'media-viewer-container-test';
17
17
  export const MediaViewerContainer = ({
18
18
  mediaNode,
19
- mediaPluginState,
19
+ selectedMediaContainerNode,
20
+ mediaClientConfig,
20
21
  isEditorViewMode = false,
21
22
  isSelected = true,
22
23
  isInline = false,
@@ -27,8 +28,7 @@ export const MediaViewerContainer = ({
27
28
  useEffect(() => {
28
29
  setShowMediaViewer(isSelected);
29
30
  }, [isSelected]);
30
- const selectedNodeAttrs = getSelectedNearestMediaContainerNodeAttrs(mediaPluginState);
31
- const mediaClientConfig = mediaPluginState.mediaClientConfig;
31
+ const selectedNodeAttrs = getSelectedNearestMediaContainerNodeAttrsFunction(selectedMediaContainerNode);
32
32
  const showMediaViewer = () => {
33
33
  setShowMediaViewer(true);
34
34
  };