@atlaskit/editor-plugin-media 8.8.0 → 8.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/mediaPlugin.js +44 -77
  3. package/dist/cjs/nodeviews/mediaNodeView/index.js +92 -7
  4. package/dist/cjs/nodeviews/mediaSingle.js +8 -1
  5. package/dist/cjs/pm-plugins/commands.js +1 -23
  6. package/dist/cjs/pm-plugins/main.js +0 -16
  7. package/dist/cjs/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +16 -2
  8. package/dist/cjs/ui/ResizableMediaSingle/index.js +11 -0
  9. package/dist/cjs/ui/toolbar/index.js +3 -2
  10. package/dist/es2019/mediaPlugin.js +4 -39
  11. package/dist/es2019/nodeviews/mediaNodeView/index.js +88 -8
  12. package/dist/es2019/nodeviews/mediaSingle.js +8 -1
  13. package/dist/es2019/pm-plugins/commands.js +0 -22
  14. package/dist/es2019/pm-plugins/main.js +0 -14
  15. package/dist/es2019/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +13 -2
  16. package/dist/es2019/ui/ResizableMediaSingle/index.js +11 -0
  17. package/dist/es2019/ui/toolbar/index.js +3 -2
  18. package/dist/esm/mediaPlugin.js +45 -78
  19. package/dist/esm/nodeviews/mediaNodeView/index.js +92 -7
  20. package/dist/esm/nodeviews/mediaSingle.js +8 -1
  21. package/dist/esm/pm-plugins/commands.js +0 -22
  22. package/dist/esm/pm-plugins/main.js +0 -16
  23. package/dist/esm/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +16 -2
  24. package/dist/esm/ui/ResizableMediaSingle/index.js +11 -0
  25. package/dist/esm/ui/toolbar/index.js +3 -2
  26. package/dist/types/mediaPluginType.d.ts +3 -3
  27. package/dist/types/nodeviews/mediaNodeView/index.d.ts +13 -4
  28. package/dist/types/nodeviews/mediaSingle.d.ts +1 -0
  29. package/dist/types/pm-plugins/commands.d.ts +0 -2
  30. package/dist/types/pm-plugins/main.d.ts +1 -4
  31. package/dist/types/pm-plugins/types.d.ts +0 -3
  32. package/dist/types/ui/ResizableMediaSingle/index.d.ts +1 -0
  33. package/dist/types-ts4.5/mediaPluginType.d.ts +3 -3
  34. package/dist/types-ts4.5/nodeviews/mediaNodeView/index.d.ts +13 -4
  35. package/dist/types-ts4.5/nodeviews/mediaSingle.d.ts +1 -0
  36. package/dist/types-ts4.5/pm-plugins/commands.d.ts +0 -2
  37. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -4
  38. package/dist/types-ts4.5/pm-plugins/types.d.ts +0 -3
  39. package/dist/types-ts4.5/ui/ResizableMediaSingle/index.d.ts +1 -0
  40. package/package.json +3 -4
  41. package/dist/cjs/ui/ImageEditor/ModalWrapper.js +0 -69
  42. package/dist/cjs/ui/ImageEditor/index.js +0 -62
  43. package/dist/es2019/ui/ImageEditor/ModalWrapper.js +0 -58
  44. package/dist/es2019/ui/ImageEditor/index.js +0 -53
  45. package/dist/esm/ui/ImageEditor/ModalWrapper.js +0 -60
  46. package/dist/esm/ui/ImageEditor/index.js +0 -52
  47. package/dist/types/ui/ImageEditor/ModalWrapper.d.ts +0 -13
  48. package/dist/types/ui/ImageEditor/index.d.ts +0 -12
  49. package/dist/types-ts4.5/ui/ImageEditor/ModalWrapper.d.ts +0 -13
  50. package/dist/types-ts4.5/ui/ImageEditor/index.d.ts +0 -12
@@ -6,7 +6,6 @@ import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-che
6
6
  import { NodeSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
7
7
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
10
9
  import { lazyMediaView } from './nodeviews/lazy-media';
11
10
  import { lazyMediaGroupView } from './nodeviews/lazy-media-group';
12
11
  import { lazyMediaInlineView } from './nodeviews/lazy-media-inline';
@@ -17,7 +16,7 @@ import { mediaInlineSpecWithFixedToDOM } from './nodeviews/toDOM-fixes/mediaInli
17
16
  import { mediaSingleSpecWithFixedToDOM } from './nodeviews/toDOM-fixes/mediaSingle';
18
17
  import { createPlugin as createMediaAltTextPlugin } from './pm-plugins/alt-text';
19
18
  import keymapMediaAltTextPlugin from './pm-plugins/alt-text/keymap';
20
- import { hideMediaViewer, showMediaViewer, trackMediaPaste, hideImageEditor, showImageEditor } from './pm-plugins/commands';
19
+ import { hideMediaViewer, showMediaViewer, trackMediaPaste } from './pm-plugins/commands';
21
20
  import keymapPlugin from './pm-plugins/keymap';
22
21
  import keymapMediaSinglePlugin from './pm-plugins/keymap-media';
23
22
  import linkingPlugin from './pm-plugins/linking';
@@ -27,7 +26,6 @@ import { createPlugin as createMediaPixelResizingPlugin } from './pm-plugins/pix
27
26
  import { stateKey } from './pm-plugins/plugin-key';
28
27
  import { createMediaIdentifierArray, extractMediaNodes } from './pm-plugins/utils/media-common';
29
28
  import { insertMediaAsMediaSingle as _insertMediaAsMediaSingle } from './pm-plugins/utils/media-single';
30
- import { RenderImageEditor } from './ui/ImageEditor/ModalWrapper';
31
29
  import { MediaPickerComponents } from './ui/MediaPicker';
32
30
  import { RenderMediaViewer } from './ui/MediaViewer/PortalWrapper';
33
31
  import { floatingToolbar as _floatingToolbar } from './ui/toolbar';
@@ -97,36 +95,10 @@ var MediaViewerFunctionalComponent = function MediaViewerFunctionalComponent(_re
97
95
  items: mediaItems
98
96
  });
99
97
  };
100
- var imageEditorStateSelector = function imageEditorStateSelector(states) {
101
- var _states$mediaState6, _states$mediaState7, _states$mediaState8;
102
- return {
103
- isImageEditorVisible: (_states$mediaState6 = states.mediaState) === null || _states$mediaState6 === void 0 ? void 0 : _states$mediaState6.isImageEditorVisible,
104
- imageEditorSelectedMedia: (_states$mediaState7 = states.mediaState) === null || _states$mediaState7 === void 0 ? void 0 : _states$mediaState7.imageEditorSelectedMedia,
105
- mediaClientConfig: (_states$mediaState8 = states.mediaState) === null || _states$mediaState8 === void 0 ? void 0 : _states$mediaState8.mediaClientConfig
106
- };
107
- };
108
- var ImageEditorFunctionalComponent = function ImageEditorFunctionalComponent(_ref3) {
109
- var api = _ref3.api;
110
- var _useSharedPluginState3 = useSharedPluginStateWithSelector(api, ['media'], imageEditorStateSelector),
111
- isImageEditorVisible = _useSharedPluginState3.isImageEditorVisible,
112
- imageEditorSelectedMedia = _useSharedPluginState3.imageEditorSelectedMedia,
113
- mediaClientConfig = _useSharedPluginState3.mediaClientConfig;
114
- if (!isImageEditorVisible || !imageEditorSelectedMedia || !mediaClientConfig) {
115
- return null;
116
- }
117
- var handleOnClose = function handleOnClose() {
118
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.media.commands.hideImageEditor);
119
- };
120
- return /*#__PURE__*/React.createElement(RenderImageEditor, {
121
- mediaClientConfig: mediaClientConfig,
122
- onClose: handleOnClose,
123
- selectedNodeAttrs: imageEditorSelectedMedia
124
- });
125
- };
126
- export var mediaPlugin = function mediaPlugin(_ref4) {
127
- var _ref4$config = _ref4.config,
128
- options = _ref4$config === void 0 ? {} : _ref4$config,
129
- api = _ref4.api;
98
+ export var mediaPlugin = function mediaPlugin(_ref3) {
99
+ var _ref3$config = _ref3.config,
100
+ options = _ref3$config === void 0 ? {} : _ref3$config,
101
+ api = _ref3.api;
130
102
  var previousMediaProvider;
131
103
  var mediaErrorLocalIds = new Set();
132
104
  return {
@@ -167,8 +139,8 @@ export var mediaPlugin = function mediaPlugin(_ref4) {
167
139
  return false;
168
140
  }
169
141
  previousMediaProvider = provider;
170
- return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref5) {
171
- var tr = _ref5.tr;
142
+ return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref4) {
143
+ var tr = _ref4.tr;
172
144
  return tr.setMeta(stateKey, {
173
145
  mediaProvider: provider
174
146
  });
@@ -178,21 +150,19 @@ export var mediaPlugin = function mediaPlugin(_ref4) {
178
150
  commands: {
179
151
  showMediaViewer: showMediaViewer,
180
152
  hideMediaViewer: hideMediaViewer,
181
- trackMediaPaste: trackMediaPaste,
182
- showImageEditor: showImageEditor,
183
- hideImageEditor: hideImageEditor
153
+ trackMediaPaste: trackMediaPaste
184
154
  },
185
155
  nodes: function nodes() {
186
- var _ref6 = options || {},
187
- _ref6$allowMediaGroup = _ref6.allowMediaGroup,
188
- allowMediaGroup = _ref6$allowMediaGroup === void 0 ? true : _ref6$allowMediaGroup,
189
- _ref6$allowMediaSingl = _ref6.allowMediaSingle,
190
- allowMediaSingle = _ref6$allowMediaSingl === void 0 ? false : _ref6$allowMediaSingl,
191
- _ref6$allowPixelResiz = _ref6.allowPixelResizing,
192
- allowPixelResizing = _ref6$allowPixelResiz === void 0 ? false : _ref6$allowPixelResiz,
193
- allowCaptions = _ref6.allowCaptions,
194
- allowMediaInlineImages = _ref6.allowMediaInlineImages,
195
- mediaFeatureFlags = _ref6.featureFlags;
156
+ var _ref5 = options || {},
157
+ _ref5$allowMediaGroup = _ref5.allowMediaGroup,
158
+ allowMediaGroup = _ref5$allowMediaGroup === void 0 ? true : _ref5$allowMediaGroup,
159
+ _ref5$allowMediaSingl = _ref5.allowMediaSingle,
160
+ allowMediaSingle = _ref5$allowMediaSingl === void 0 ? false : _ref5$allowMediaSingl,
161
+ _ref5$allowPixelResiz = _ref5.allowPixelResizing,
162
+ allowPixelResizing = _ref5$allowPixelResiz === void 0 ? false : _ref5$allowPixelResiz,
163
+ allowCaptions = _ref5.allowCaptions,
164
+ allowMediaInlineImages = _ref5.allowMediaInlineImages,
165
+ mediaFeatureFlags = _ref5.featureFlags;
196
166
  var allowMediaInline = fg('platform_editor_remove_media_inline_feature_flag') ? allowMediaInlineImages : getMediaFeatureFlag('mediaInline', mediaFeatureFlags);
197
167
  var mediaSingleOption = {
198
168
  withCaption: allowCaptions,
@@ -226,16 +196,16 @@ export var mediaPlugin = function mediaPlugin(_ref4) {
226
196
  pmPlugins: function pmPlugins() {
227
197
  var pmPlugins = [{
228
198
  name: 'media',
229
- plugin: function plugin(_ref7) {
230
- var schema = _ref7.schema,
231
- dispatch = _ref7.dispatch,
232
- getIntl = _ref7.getIntl,
233
- eventDispatcher = _ref7.eventDispatcher,
234
- providerFactory = _ref7.providerFactory,
235
- errorReporter = _ref7.errorReporter,
236
- portalProviderAPI = _ref7.portalProviderAPI,
237
- dispatchAnalyticsEvent = _ref7.dispatchAnalyticsEvent,
238
- nodeViewPortalProviderAPI = _ref7.nodeViewPortalProviderAPI;
199
+ plugin: function plugin(_ref6) {
200
+ var schema = _ref6.schema,
201
+ dispatch = _ref6.dispatch,
202
+ getIntl = _ref6.getIntl,
203
+ eventDispatcher = _ref6.eventDispatcher,
204
+ providerFactory = _ref6.providerFactory,
205
+ errorReporter = _ref6.errorReporter,
206
+ portalProviderAPI = _ref6.portalProviderAPI,
207
+ dispatchAnalyticsEvent = _ref6.dispatchAnalyticsEvent,
208
+ nodeViewPortalProviderAPI = _ref6.nodeViewPortalProviderAPI;
239
209
  return createPlugin(schema, {
240
210
  providerFactory: providerFactory,
241
211
  nodeViews: {
@@ -254,17 +224,17 @@ export var mediaPlugin = function mediaPlugin(_ref4) {
254
224
  }
255
225
  }, {
256
226
  name: 'mediaKeymap',
257
- plugin: function plugin(_ref8) {
227
+ plugin: function plugin(_ref7) {
258
228
  var _api$analytics3, _api$selection;
259
- var getIntl = _ref8.getIntl;
229
+ var getIntl = _ref7.getIntl;
260
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);
261
231
  }
262
232
  }];
263
233
  if (options && options.allowMediaSingle) {
264
234
  pmPlugins.push({
265
235
  name: 'mediaSingleKeymap',
266
- plugin: function plugin(_ref9) {
267
- var schema = _ref9.schema;
236
+ plugin: function plugin(_ref8) {
237
+ var schema = _ref8.schema;
268
238
  return keymapMediaSinglePlugin(schema);
269
239
  }
270
240
  });
@@ -276,9 +246,9 @@ export var mediaPlugin = function mediaPlugin(_ref4) {
276
246
  });
277
247
  pmPlugins.push({
278
248
  name: 'mediaAltTextKeymap',
279
- plugin: function plugin(_ref0) {
249
+ plugin: function plugin(_ref9) {
280
250
  var _api$analytics4;
281
- var schema = _ref0.schema;
251
+ var schema = _ref9.schema;
282
252
  return keymapMediaAltTextPlugin(schema, api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
283
253
  }
284
254
  });
@@ -286,15 +256,15 @@ export var mediaPlugin = function mediaPlugin(_ref4) {
286
256
  if (options && options.allowLinking) {
287
257
  pmPlugins.push({
288
258
  name: 'mediaLinking',
289
- plugin: function plugin(_ref1) {
290
- var dispatch = _ref1.dispatch;
259
+ plugin: function plugin(_ref0) {
260
+ var dispatch = _ref0.dispatch;
291
261
  return linkingPlugin(dispatch);
292
262
  }
293
263
  });
294
264
  pmPlugins.push({
295
265
  name: 'mediaLinkingKeymap',
296
- plugin: function plugin(_ref10) {
297
- var schema = _ref10.schema;
266
+ plugin: function plugin(_ref1) {
267
+ var schema = _ref1.schema;
298
268
  return keymapLinkingPlugin(schema);
299
269
  }
300
270
  });
@@ -336,16 +306,13 @@ export var mediaPlugin = function mediaPlugin(_ref4) {
336
306
  });
337
307
  return pmPlugins;
338
308
  },
339
- contentComponent: function contentComponent(_ref11) {
340
- var editorView = _ref11.editorView,
341
- appearance = _ref11.appearance;
309
+ contentComponent: function contentComponent(_ref10) {
310
+ var editorView = _ref10.editorView,
311
+ appearance = _ref10.appearance;
342
312
  if (!editorView) {
343
313
  return null;
344
314
  }
345
- return /*#__PURE__*/React.createElement(React.Fragment, null, (options === null || options === void 0 ? void 0 : options.allowImageEditing) && expValEquals('platform_editor_add_image_editing', 'isEnabled', true) && /*#__PURE__*/React.createElement(ImageEditorFunctionalComponent, {
346
- api: api,
347
- editorView: editorView
348
- }), /*#__PURE__*/React.createElement(MediaViewerFunctionalComponent, {
315
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MediaViewerFunctionalComponent, {
349
316
  api: api,
350
317
  editorView: editorView
351
318
  }), /*#__PURE__*/React.createElement(MediaPickerFunctionalComponent, {
@@ -354,8 +321,8 @@ export var mediaPlugin = function mediaPlugin(_ref4) {
354
321
  api: api
355
322
  }));
356
323
  },
357
- secondaryToolbarComponent: function secondaryToolbarComponent(_ref12) {
358
- var disabled = _ref12.disabled;
324
+ secondaryToolbarComponent: function secondaryToolbarComponent(_ref11) {
325
+ var disabled = _ref11.disabled;
359
326
  return /*#__PURE__*/React.createElement(ToolbarMedia, {
360
327
  isDisabled: disabled,
361
328
  isReducedSpacing: true,
@@ -377,7 +344,7 @@ export var mediaPlugin = function mediaPlugin(_ref4) {
377
344
  allowLinking: options && options.allowLinking,
378
345
  allowAdvancedToolBarOptions: options && options.allowAdvancedToolBarOptions,
379
346
  allowAltTextOnImages: options && options.allowAltTextOnImages,
380
- allowImageEditing: options && options.allowImageEditing,
347
+ allowImageEditing: !!(api !== null && api !== void 0 && api.mediaEditing) && options && options.allowImageEditing,
381
348
  allowImagePreview: options && options.allowImagePreview,
382
349
  altTextValidator: options && options.altTextValidator,
383
350
  fullWidthEnabled: options && options.fullWidthEnabled,
@@ -13,12 +13,15 @@ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstruct
13
13
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
14
14
  function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
15
15
  import React from 'react';
16
+ import { bind } from 'bind-event-listener';
16
17
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
17
18
  import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
18
19
  import { WithProviders } from '@atlaskit/editor-common/provider-factory';
19
20
  import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
20
21
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
22
+ import { akEditorFullWidthLayoutWidth, akEditorDefaultLayoutWidth, akEditorCalculatedWideLayoutWidth } from '@atlaskit/editor-shared-styles';
21
23
  import { getAttrsFromUrl } from '@atlaskit/media-client';
24
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
22
25
  import { updateCurrentMediaNodeAttrs } from '../../pm-plugins/commands/helpers';
23
26
  import { isMediaBlobUrlFromAttrs } from '../../pm-plugins/utils/media-common';
24
27
  // Ignored via go/ees005
@@ -53,6 +56,13 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
53
56
  }
54
57
  _this = _callSuper(this, MediaNodeView, [].concat(args));
55
58
  _defineProperty(_this, "isSelected", false);
59
+ _defineProperty(_this, "hasBeenResized", false);
60
+ _defineProperty(_this, "hasResizedListener", function () {
61
+ if (!_this.hasBeenResized) {
62
+ _this.hasBeenResized = true;
63
+ _this.update(_this.node, _this.decorations);
64
+ }
65
+ });
56
66
  _defineProperty(_this, "onExternalImageLoaded", function (dimensions) {
57
67
  var getPos = _this.getPos;
58
68
  var _this$getAttrs = _this.getAttrs(),
@@ -69,11 +79,39 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
69
79
  }, true)(_this.view.state, _this.view.dispatch);
70
80
  }
71
81
  });
82
+ _defineProperty(_this, "getMaxCardDimensions", function () {
83
+ var flexibleDimensions = {
84
+ width: '100%',
85
+ height: '100%'
86
+ };
87
+ if (expValEquals('platform_editor_media_vc_fixes', 'isEnabled', true)) {
88
+ var pos = _this.getPos();
89
+ if (typeof pos !== 'number') {
90
+ return flexibleDimensions;
91
+ }
92
+ if (_this.hasBeenResized) {
93
+ return flexibleDimensions;
94
+ }
95
+ var mediaSingleNodeParent = _this.getMediaSingleNode(_this.getPos);
96
+
97
+ // If media parent not found, return default
98
+ if (!mediaSingleNodeParent) {
99
+ return flexibleDimensions;
100
+ }
101
+
102
+ // Compute normal dimensions
103
+ var maxWidth = _this.getMaxWidthFromMediaSingleNode(mediaSingleNodeParent);
104
+ return {
105
+ width: "".concat(maxWidth, "px"),
106
+ height: '100%'
107
+ };
108
+ }
109
+ return flexibleDimensions;
110
+ });
72
111
  _defineProperty(_this, "renderMediaNodeWithState", function (contextIdentifierProvider) {
73
112
  return function (_ref2) {
74
113
  var _this$reactComponentP;
75
- var editorWidth = _ref2.width,
76
- mediaProvider = _ref2.mediaProvider,
114
+ var mediaProvider = _ref2.mediaProvider,
77
115
  interactionState = _ref2.interactionState;
78
116
  var getPos = _this.getPos;
79
117
  var mediaOptions = _this.reactComponentProps.mediaOptions;
@@ -92,18 +130,15 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
92
130
  }
93
131
  width = width || DEFAULT_IMAGE_WIDTH;
94
132
  height = height || DEFAULT_IMAGE_HEIGHT;
133
+ var pluginInjectionApi = _this.reactComponentProps.pluginInjectionApi;
95
134
 
96
135
  // mediaSingle defines the max dimensions, so we don't need to constrain twice.
97
- var maxDimensions = {
98
- width: "100%",
99
- height: "100%"
100
- };
136
+ var maxDimensions = _this.getMaxCardDimensions();
101
137
  var originalDimensions = {
102
138
  width: width,
103
139
  height: height
104
140
  };
105
141
  var isSelectedAndInteracted = _this.nodeInsideSelection() && interactionState !== 'hasNotHadInteraction';
106
- var pluginInjectionApi = _this.reactComponentProps.pluginInjectionApi;
107
142
  return /*#__PURE__*/React.createElement(MediaNode, {
108
143
  api: pluginInjectionApi,
109
144
  view: _this.view,
@@ -134,6 +169,42 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
134
169
  }
135
170
  _inherits(MediaNodeView, _SelectionBasedNodeVi);
136
171
  return _createClass(MediaNodeView, [{
172
+ key: "getMediaSingleNode",
173
+ value: function getMediaSingleNode(getPos) {
174
+ var pos = getPos();
175
+ if (typeof pos !== 'number') {
176
+ return null;
177
+ }
178
+ var $pos = this.view.state.doc.resolve(pos);
179
+
180
+ // The parent of the media node should be mediaSingle
181
+ if ($pos.parent && $pos.parent.type.name === 'mediaSingle') {
182
+ return $pos.parent;
183
+ }
184
+ return null;
185
+ }
186
+ }, {
187
+ key: "getMaxWidthFromMediaSingleNode",
188
+ value: function getMaxWidthFromMediaSingleNode(mediaSingleNode) {
189
+ var _mediaSingleNode$attr = mediaSingleNode.attrs,
190
+ widthAttr = _mediaSingleNode$attr.width,
191
+ widthTypeAttr = _mediaSingleNode$attr.widthType,
192
+ layoutAttr = _mediaSingleNode$attr.layout;
193
+ // for extended mediaSingle nodes with width and widthType attributes ( default behaviour )
194
+ if (widthAttr && widthTypeAttr === 'pixel') {
195
+ return widthAttr;
196
+ }
197
+ // for legacy mediaSingle nodes without widthType attribute
198
+ switch (layoutAttr) {
199
+ case 'full-width':
200
+ return akEditorFullWidthLayoutWidth;
201
+ case 'wide':
202
+ return akEditorCalculatedWideLayoutWidth;
203
+ default:
204
+ return akEditorDefaultLayoutWidth;
205
+ }
206
+ }
207
+ }, {
137
208
  key: "createDomRef",
138
209
  value: function createDomRef() {
139
210
  var domRef = document.createElement('div');
@@ -142,6 +213,12 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
142
213
  // see also: https://github.com/ProseMirror/prosemirror/issues/884
143
214
  domRef.contentEditable = 'true';
144
215
  }
216
+ if (expValEquals('platform_editor_media_vc_fixes', 'isEnabled', true)) {
217
+ this.resizeListenerBinding = bind(domRef, {
218
+ type: 'resized',
219
+ listener: this.hasResizedListener
220
+ });
221
+ }
145
222
  return domRef;
146
223
  }
147
224
  }, {
@@ -193,6 +270,14 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
193
270
  renderNode: this.renderMediaNodeWithProviders
194
271
  });
195
272
  }
273
+ }, {
274
+ key: "destroy",
275
+ value: function destroy() {
276
+ if (this.resizeListenerBinding) {
277
+ this.resizeListenerBinding();
278
+ }
279
+ _superPropGet(MediaNodeView, "destroy", this, 3)([]);
280
+ }
196
281
  }]);
197
282
  }(SelectionBasedNodeView);
198
283
  export var ReactMediaNode = function ReactMediaNode(portalProviderAPI, eventDispatcher, providerFactory) {
@@ -22,6 +22,7 @@ import { WithProviders } from '@atlaskit/editor-common/provider-factory';
22
22
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
23
23
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
24
24
  import { isNodeSelectedOrInRange } from '@atlaskit/editor-common/utils';
25
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
25
26
  import { MEDIA_CONTENT_WRAP_CLASS_NAME } from '../pm-plugins/main';
26
27
  import { MediaSingleNodeNext } from './mediaSingleNext';
27
28
  var selector = function selector(states) {
@@ -100,6 +101,7 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
100
101
  _defineProperty(_this, "lastOffsetLeft", 0);
101
102
  _defineProperty(_this, "forceViewUpdate", false);
102
103
  _defineProperty(_this, "selectionType", null);
104
+ _defineProperty(_this, "hasResized", false);
103
105
  _defineProperty(_this, "checkAndUpdateSelectionType", function () {
104
106
  var getPos = _this.getPos;
105
107
  var selection = _this.view.state.selection;
@@ -112,7 +114,7 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
112
114
  var pos;
113
115
  try {
114
116
  pos = getPos ? getPos() : undefined;
115
- } catch (e) {
117
+ } catch (_unused) {
116
118
  pos = undefined;
117
119
  }
118
120
  var isNodeSelected = isNodeSelectedOrInRange(selection.$anchor.pos, selection.$head.pos, pos, _this.node.nodeSize);
@@ -224,6 +226,11 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
224
226
  return _this3.getNodeMediaId(currentNode) === _this3.getNodeMediaId(newNode);
225
227
  };
226
228
  }
229
+ // Detect mediaSingle width attribute changes and signal child media node to update
230
+ if (!this.hasResized && this.node.attrs.width !== node.attrs.width && expValEquals('platform_editor_media_vc_fixes', 'isEnabled', true)) {
231
+ var target = this.dom.querySelector('div[data-prosemirror-node-name="media"]');
232
+ target === null || target === void 0 || target.dispatchEvent(new CustomEvent('resized'));
233
+ }
227
234
  return _superPropGet(MediaSingleNodeView, "update", this, 3)([node, decorations, _innerDecorations, isValidUpdate]);
228
235
  }
229
236
  }, {
@@ -31,26 +31,4 @@ export var trackMediaPaste = function trackMediaPaste(attrs) {
31
31
  });
32
32
  return tr;
33
33
  };
34
- };
35
- export var showImageEditor = function showImageEditor(media) {
36
- return function (_ref4) {
37
- var tr = _ref4.tr;
38
- tr.setMeta(stateKey, {
39
- type: ACTIONS.SHOW_IMAGE_EDITOR,
40
- imageEditorSelectedMedia: media,
41
- isImageEditorVisible: true
42
- });
43
- tr.setMeta('addToHistory', false);
44
- return tr;
45
- };
46
- };
47
- export var hideImageEditor = function hideImageEditor(_ref5) {
48
- var tr = _ref5.tr;
49
- tr.setMeta(stateKey, {
50
- type: ACTIONS.HIDE_IMAGE_EDITOR,
51
- imageEditorSelectedMedia: null,
52
- isImageEditorVisible: false
53
- });
54
- tr.setMeta('addToHistory', false);
55
- return tr;
56
34
  };
@@ -82,7 +82,6 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
82
82
  _defineProperty(this, "allowInlineImages", false);
83
83
  _defineProperty(this, "uploadInProgressSubscriptions", []);
84
84
  _defineProperty(this, "uploadInProgressSubscriptionsNotified", false);
85
- _defineProperty(this, "isImageEditorVisible", false);
86
85
  // this is only a temporary variable, which gets cleared after the last inserted node has been selected
87
86
  _defineProperty(this, "lastAddedMediaSingleFileIds", []);
88
87
  _defineProperty(this, "destroyed", false);
@@ -630,11 +629,6 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
630
629
  value: function setResizingWidth(width) {
631
630
  this.resizingWidth = width;
632
631
  }
633
- }, {
634
- key: "setImageEditorVisibility",
635
- value: function setImageEditorVisibility(isVisible) {
636
- this.isImageEditorVisible = isVisible;
637
- }
638
632
  }, {
639
633
  key: "updateElement",
640
634
  value: function updateElement() {
@@ -876,16 +870,6 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
876
870
  nextPluginState = pluginState.clone();
877
871
  }
878
872
  break;
879
- case ACTIONS.SHOW_IMAGE_EDITOR:
880
- pluginState.imageEditorSelectedMedia = meta.imageEditorSelectedMedia;
881
- pluginState.isImageEditorVisible = meta.isImageEditorVisible;
882
- nextPluginState = nextPluginState.clone();
883
- break;
884
- case ACTIONS.HIDE_IMAGE_EDITOR:
885
- pluginState.imageEditorSelectedMedia = undefined;
886
- pluginState.isImageEditorVisible = meta.isImageEditorVisible;
887
- nextPluginState = nextPluginState.clone();
888
- break;
889
873
  }
890
874
 
891
875
  // NOTE: We're not calling passing new state to the Editor, because we depend on the view.state reference
@@ -189,6 +189,10 @@ export var ResizableMediaSingleNextFunctional = function ResizableMediaSingleNex
189
189
  _useState8 = _slicedToArray(_useState7, 2),
190
190
  isVideoFile = _useState8[0],
191
191
  setIsVideoFile = _useState8[1];
192
+ var _useState9 = useState(false),
193
+ _useState0 = _slicedToArray(_useState9, 2),
194
+ hasResized = _useState0[0],
195
+ setHasResized = _useState0[1];
192
196
  var nodePosition = useMemo(function () {
193
197
  if (typeof getPos !== 'function') {
194
198
  return null;
@@ -358,6 +362,7 @@ export var ResizableMediaSingleNextFunctional = function ResizableMediaSingleNex
358
362
  width: props.width,
359
363
  height: props.height
360
364
  }));
365
+ var resizerContainerRef = useRef(null);
361
366
  var handleResize = useCallback(function (size, delta) {
362
367
  var _calculateSizeState = calculateSizeState({
363
368
  layout: layout,
@@ -369,6 +374,14 @@ export var ResizableMediaSingleNextFunctional = function ResizableMediaSingleNex
369
374
  width = _calculateSizeState.width,
370
375
  height = _calculateSizeState.height,
371
376
  newLayout = _calculateSizeState.layout;
377
+ var resizerDomEl = resizerContainerRef.current;
378
+ if (resizerDomEl && !hasResized && expValEquals('platform_editor_media_vc_fixes', 'isEnabled', true)) {
379
+ // dispatch resize event to media node DOM element inside resizerDom
380
+ var mediaDomEl = resizerDomEl.querySelector('div[data-prosemirror-node-name="media"]');
381
+ var event = new CustomEvent('resized');
382
+ mediaDomEl === null || mediaDomEl === void 0 || mediaDomEl.dispatchEvent(event);
383
+ setHasResized(true);
384
+ }
372
385
  if (isGuidelineEnabled) {
373
386
  var guidelineSnaps = getGuidelineSnaps(guidelinesRef.current, lineLength, layout);
374
387
  updateActiveGuidelines(width, guidelinesRef.current, guidelineSnaps);
@@ -388,7 +401,7 @@ export var ResizableMediaSingleNextFunctional = function ResizableMediaSingleNex
388
401
  if (newLayout !== layout) {
389
402
  updateSize(width, newLayout);
390
403
  }
391
- }, [view, updateSize, layout, isGuidelineEnabled, containerWidth, lineLength, fullWidthMode, isAdjacentMode, updateActiveGuidelines]);
404
+ }, [layout, containerWidth, lineLength, fullWidthMode, isAdjacentMode, hasResized, isGuidelineEnabled, view, updateActiveGuidelines, updateSize]);
392
405
  var handleResizeStop = useCallback(function (size, delta) {
393
406
  var _pluginInjectionApi$g3;
394
407
  if (typeof nodePosition !== 'number') {
@@ -480,7 +493,8 @@ export var ResizableMediaSingleNextFunctional = function ResizableMediaSingleNex
480
493
  }, [forceHandlePositioning, isAdjacentMode]);
481
494
  return jsx("div", {
482
495
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
483
- css: memoizedCss
496
+ css: memoizedCss,
497
+ ref: resizerContainerRef
484
498
  }, jsx(ResizerNext, {
485
499
  minWidth: minViewWidth,
486
500
  maxWidth: maxWidth
@@ -23,6 +23,7 @@ import { calculateSnapPoints } from '@atlaskit/editor-common/utils';
23
23
  import { findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
24
24
  import { akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
25
25
  import { fg } from '@atlaskit/platform-feature-flags';
26
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
26
27
  import { checkMediaType } from '../../pm-plugins/utils/check-media-type';
27
28
  import { wrapperStyle } from './styled';
28
29
  // eslint-disable-next-line @repo/internal/react/no-class-components
@@ -34,6 +35,7 @@ var ResizableMediaSingle = /*#__PURE__*/function (_React$Component) {
34
35
  args[_key] = arguments[_key];
35
36
  }
36
37
  _this = _callSuper(this, ResizableMediaSingle, [].concat(args));
38
+ _defineProperty(_this, "hasResized", false);
37
39
  _defineProperty(_this, "state", {
38
40
  offsetLeft: calculateOffsetLeft(_this.insideInlineLike, _this.insideLayout, _this.props.view.dom, undefined),
39
41
  isVideoFile: !fg('platform_editor_media_video_check_fix')
@@ -53,6 +55,15 @@ var ResizableMediaSingle = /*#__PURE__*/function (_React$Component) {
53
55
  var _this$props2 = _this.props,
54
56
  layout = _this$props2.layout,
55
57
  state = _this$props2.view.state;
58
+ if (!_this.hasResized && expValEquals('platform_editor_media_vc_fixes', 'isEnabled', true)) {
59
+ var _this$wrapper;
60
+ var mediaDomEl = (_this$wrapper = _this.wrapper) === null || _this$wrapper === void 0 ? void 0 : _this$wrapper.querySelector('div[data-prosemirror-node-name="media"]');
61
+ if (mediaDomEl) {
62
+ var event = new CustomEvent('resized');
63
+ mediaDomEl === null || mediaDomEl === void 0 || mediaDomEl.dispatchEvent(event);
64
+ }
65
+ _this.hasResized = true;
66
+ }
56
67
  var newPct = calcPctFromPx(newWidth, _this.props.lineLength) * 100;
57
68
  _this.setState({
58
69
  resizedPctWidth: newPct
@@ -114,13 +114,14 @@ export var handleShowMediaViewer = function handleShowMediaViewer(_ref) {
114
114
  api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.media.commands.showMediaViewer(selectedNodeAttrs));
115
115
  };
116
116
  export var handleShowImageEditor = function handleShowImageEditor(_ref2) {
117
+ var _api$mediaEditing;
117
118
  var api = _ref2.api,
118
119
  mediaPluginState = _ref2.mediaPluginState;
119
120
  var selectedNodeAttrs = getSelectedNearestMediaContainerNodeAttrs(mediaPluginState);
120
121
  if (!selectedNodeAttrs) {
121
122
  return false;
122
123
  }
123
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.media.commands.showImageEditor(selectedNodeAttrs));
124
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$mediaEditing = api.mediaEditing) === null || _api$mediaEditing === void 0 ? void 0 : _api$mediaEditing.commands.showImageEditor(selectedNodeAttrs));
124
125
  };
125
126
  var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, editorAnalyticsAPI, forceFocusSelector, isViewOnly) {
126
127
  var _pluginInjectionApi$c;
@@ -554,7 +555,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
554
555
  });
555
556
  }
556
557
  // Image Editing Support
557
- if (allowImageEditing && expValEquals('platform_editor_add_image_editing', 'isEnabled', true)) {
558
+ if (!!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.mediaEditing) && allowImageEditing && expValEquals('platform_editor_add_image_editing', 'isEnabled', true)) {
558
559
  var _mediaNode$attrs;
559
560
  var _selectedMediaSingleNode = getSelectedMediaSingle(state);
560
561
  var mediaNode = _selectedMediaSingleNode === null || _selectedMediaSingleNode === void 0 ? void 0 : _selectedMediaSingleNode.node.content.firstChild;
@@ -14,6 +14,7 @@ import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
14
14
  import type { GridPlugin } from '@atlaskit/editor-plugin-grid';
15
15
  import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
16
16
  import type { InteractionPlugin } from '@atlaskit/editor-plugin-interaction';
17
+ import type { MediaEditingPlugin } from '@atlaskit/editor-plugin-media-editing';
17
18
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
18
19
  import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
19
20
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
@@ -38,7 +39,8 @@ export type MediaPluginDependencies = [
38
39
  OptionalPlugin<FeatureFlagsPlugin>,
39
40
  OptionalPlugin<ConnectivityPlugin>,
40
41
  OptionalPlugin<InteractionPlugin>,
41
- OptionalPlugin<ToolbarPlugin>
42
+ OptionalPlugin<ToolbarPlugin>,
43
+ OptionalPlugin<MediaEditingPlugin>
42
44
  ];
43
45
  export type MediaNextEditorPluginType = NextEditorPlugin<'media', {
44
46
  actions: {
@@ -59,9 +61,7 @@ export type MediaNextEditorPluginType = NextEditorPlugin<'media', {
59
61
  setProvider: (provider: Promise<MediaProvider>) => boolean;
60
62
  };
61
63
  commands: {
62
- hideImageEditor: EditorCommand;
63
64
  hideMediaViewer: EditorCommand;
64
- showImageEditor: (media: MediaADFAttrs) => EditorCommand;
65
65
  showMediaViewer: (media: MediaADFAttrs) => EditorCommand;
66
66
  trackMediaPaste: (attrs: MediaADFAttrs) => EditorCommand;
67
67
  };