@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @atlaskit/editor-plugin-media
2
2
 
3
+ ## 8.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`3323827ca91e6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3323827ca91e6) -
8
+ [ux] EDITOR-4139 Refactor existing image editing functionality into its own plugin
9
+ editor-plugin-media-editing
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 8.9.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [`bb5f3706afa84`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/bb5f3706afa84) -
20
+ fix media card dimensions on load for ssr
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies
25
+
3
26
  ## 8.8.0
4
27
 
5
28
  ### Minor Changes
@@ -14,7 +14,6 @@ var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
14
14
  var _state = require("@atlaskit/editor-prosemirror/state");
15
15
  var _mediaCommon = require("@atlaskit/media-common");
16
16
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
- var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
18
17
  var _lazyMedia = require("./nodeviews/lazy-media");
19
18
  var _lazyMediaGroup = require("./nodeviews/lazy-media-group");
20
19
  var _lazyMediaInline = require("./nodeviews/lazy-media-inline");
@@ -35,7 +34,6 @@ var _pixelResizing = require("./pm-plugins/pixel-resizing");
35
34
  var _pluginKey = require("./pm-plugins/plugin-key");
36
35
  var _mediaCommon2 = require("./pm-plugins/utils/media-common");
37
36
  var _mediaSingle2 = require("./pm-plugins/utils/media-single");
38
- var _ModalWrapper = require("./ui/ImageEditor/ModalWrapper");
39
37
  var _MediaPicker = require("./ui/MediaPicker");
40
38
  var _PortalWrapper = require("./ui/MediaViewer/PortalWrapper");
41
39
  var _toolbar = require("./ui/toolbar");
@@ -106,36 +104,10 @@ var MediaViewerFunctionalComponent = function MediaViewerFunctionalComponent(_re
106
104
  items: mediaItems
107
105
  });
108
106
  };
109
- var imageEditorStateSelector = function imageEditorStateSelector(states) {
110
- var _states$mediaState6, _states$mediaState7, _states$mediaState8;
111
- return {
112
- isImageEditorVisible: (_states$mediaState6 = states.mediaState) === null || _states$mediaState6 === void 0 ? void 0 : _states$mediaState6.isImageEditorVisible,
113
- imageEditorSelectedMedia: (_states$mediaState7 = states.mediaState) === null || _states$mediaState7 === void 0 ? void 0 : _states$mediaState7.imageEditorSelectedMedia,
114
- mediaClientConfig: (_states$mediaState8 = states.mediaState) === null || _states$mediaState8 === void 0 ? void 0 : _states$mediaState8.mediaClientConfig
115
- };
116
- };
117
- var ImageEditorFunctionalComponent = function ImageEditorFunctionalComponent(_ref3) {
118
- var api = _ref3.api;
119
- var _useSharedPluginState3 = (0, _hooks.useSharedPluginStateWithSelector)(api, ['media'], imageEditorStateSelector),
120
- isImageEditorVisible = _useSharedPluginState3.isImageEditorVisible,
121
- imageEditorSelectedMedia = _useSharedPluginState3.imageEditorSelectedMedia,
122
- mediaClientConfig = _useSharedPluginState3.mediaClientConfig;
123
- if (!isImageEditorVisible || !imageEditorSelectedMedia || !mediaClientConfig) {
124
- return null;
125
- }
126
- var handleOnClose = function handleOnClose() {
127
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.media.commands.hideImageEditor);
128
- };
129
- return /*#__PURE__*/_react.default.createElement(_ModalWrapper.RenderImageEditor, {
130
- mediaClientConfig: mediaClientConfig,
131
- onClose: handleOnClose,
132
- selectedNodeAttrs: imageEditorSelectedMedia
133
- });
134
- };
135
- var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref4) {
136
- var _ref4$config = _ref4.config,
137
- options = _ref4$config === void 0 ? {} : _ref4$config,
138
- api = _ref4.api;
107
+ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
108
+ var _ref3$config = _ref3.config,
109
+ options = _ref3$config === void 0 ? {} : _ref3$config,
110
+ api = _ref3.api;
139
111
  var previousMediaProvider;
140
112
  var mediaErrorLocalIds = new Set();
141
113
  return {
@@ -176,8 +148,8 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref4) {
176
148
  return false;
177
149
  }
178
150
  previousMediaProvider = provider;
179
- return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref5) {
180
- var tr = _ref5.tr;
151
+ return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref4) {
152
+ var tr = _ref4.tr;
181
153
  return tr.setMeta(_pluginKey.stateKey, {
182
154
  mediaProvider: provider
183
155
  });
@@ -187,21 +159,19 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref4) {
187
159
  commands: {
188
160
  showMediaViewer: _commands.showMediaViewer,
189
161
  hideMediaViewer: _commands.hideMediaViewer,
190
- trackMediaPaste: _commands.trackMediaPaste,
191
- showImageEditor: _commands.showImageEditor,
192
- hideImageEditor: _commands.hideImageEditor
162
+ trackMediaPaste: _commands.trackMediaPaste
193
163
  },
194
164
  nodes: function nodes() {
195
- var _ref6 = options || {},
196
- _ref6$allowMediaGroup = _ref6.allowMediaGroup,
197
- allowMediaGroup = _ref6$allowMediaGroup === void 0 ? true : _ref6$allowMediaGroup,
198
- _ref6$allowMediaSingl = _ref6.allowMediaSingle,
199
- allowMediaSingle = _ref6$allowMediaSingl === void 0 ? false : _ref6$allowMediaSingl,
200
- _ref6$allowPixelResiz = _ref6.allowPixelResizing,
201
- allowPixelResizing = _ref6$allowPixelResiz === void 0 ? false : _ref6$allowPixelResiz,
202
- allowCaptions = _ref6.allowCaptions,
203
- allowMediaInlineImages = _ref6.allowMediaInlineImages,
204
- mediaFeatureFlags = _ref6.featureFlags;
165
+ var _ref5 = options || {},
166
+ _ref5$allowMediaGroup = _ref5.allowMediaGroup,
167
+ allowMediaGroup = _ref5$allowMediaGroup === void 0 ? true : _ref5$allowMediaGroup,
168
+ _ref5$allowMediaSingl = _ref5.allowMediaSingle,
169
+ allowMediaSingle = _ref5$allowMediaSingl === void 0 ? false : _ref5$allowMediaSingl,
170
+ _ref5$allowPixelResiz = _ref5.allowPixelResizing,
171
+ allowPixelResizing = _ref5$allowPixelResiz === void 0 ? false : _ref5$allowPixelResiz,
172
+ allowCaptions = _ref5.allowCaptions,
173
+ allowMediaInlineImages = _ref5.allowMediaInlineImages,
174
+ mediaFeatureFlags = _ref5.featureFlags;
205
175
  var allowMediaInline = (0, _platformFeatureFlags.fg)('platform_editor_remove_media_inline_feature_flag') ? allowMediaInlineImages : (0, _mediaCommon.getMediaFeatureFlag)('mediaInline', mediaFeatureFlags);
206
176
  var mediaSingleOption = {
207
177
  withCaption: allowCaptions,
@@ -235,16 +205,16 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref4) {
235
205
  pmPlugins: function pmPlugins() {
236
206
  var pmPlugins = [{
237
207
  name: 'media',
238
- plugin: function plugin(_ref7) {
239
- var schema = _ref7.schema,
240
- dispatch = _ref7.dispatch,
241
- getIntl = _ref7.getIntl,
242
- eventDispatcher = _ref7.eventDispatcher,
243
- providerFactory = _ref7.providerFactory,
244
- errorReporter = _ref7.errorReporter,
245
- portalProviderAPI = _ref7.portalProviderAPI,
246
- dispatchAnalyticsEvent = _ref7.dispatchAnalyticsEvent,
247
- nodeViewPortalProviderAPI = _ref7.nodeViewPortalProviderAPI;
208
+ plugin: function plugin(_ref6) {
209
+ var schema = _ref6.schema,
210
+ dispatch = _ref6.dispatch,
211
+ getIntl = _ref6.getIntl,
212
+ eventDispatcher = _ref6.eventDispatcher,
213
+ providerFactory = _ref6.providerFactory,
214
+ errorReporter = _ref6.errorReporter,
215
+ portalProviderAPI = _ref6.portalProviderAPI,
216
+ dispatchAnalyticsEvent = _ref6.dispatchAnalyticsEvent,
217
+ nodeViewPortalProviderAPI = _ref6.nodeViewPortalProviderAPI;
248
218
  return (0, _main.createPlugin)(schema, {
249
219
  providerFactory: providerFactory,
250
220
  nodeViews: {
@@ -263,17 +233,17 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref4) {
263
233
  }
264
234
  }, {
265
235
  name: 'mediaKeymap',
266
- plugin: function plugin(_ref8) {
236
+ plugin: function plugin(_ref7) {
267
237
  var _api$analytics3, _api$selection;
268
- var getIntl = _ref8.getIntl;
238
+ var getIntl = _ref7.getIntl;
269
239
  return (0, _keymap2.default)(options, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.actions, api === null || api === void 0 ? void 0 : api.width, getIntl);
270
240
  }
271
241
  }];
272
242
  if (options && options.allowMediaSingle) {
273
243
  pmPlugins.push({
274
244
  name: 'mediaSingleKeymap',
275
- plugin: function plugin(_ref9) {
276
- var schema = _ref9.schema;
245
+ plugin: function plugin(_ref8) {
246
+ var schema = _ref8.schema;
277
247
  return (0, _keymapMedia.default)(schema);
278
248
  }
279
249
  });
@@ -285,9 +255,9 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref4) {
285
255
  });
286
256
  pmPlugins.push({
287
257
  name: 'mediaAltTextKeymap',
288
- plugin: function plugin(_ref0) {
258
+ plugin: function plugin(_ref9) {
289
259
  var _api$analytics4;
290
- var schema = _ref0.schema;
260
+ var schema = _ref9.schema;
291
261
  return (0, _keymap.default)(schema, api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
292
262
  }
293
263
  });
@@ -295,15 +265,15 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref4) {
295
265
  if (options && options.allowLinking) {
296
266
  pmPlugins.push({
297
267
  name: 'mediaLinking',
298
- plugin: function plugin(_ref1) {
299
- var dispatch = _ref1.dispatch;
268
+ plugin: function plugin(_ref0) {
269
+ var dispatch = _ref0.dispatch;
300
270
  return (0, _linking.default)(dispatch);
301
271
  }
302
272
  });
303
273
  pmPlugins.push({
304
274
  name: 'mediaLinkingKeymap',
305
- plugin: function plugin(_ref10) {
306
- var schema = _ref10.schema;
275
+ plugin: function plugin(_ref1) {
276
+ var schema = _ref1.schema;
307
277
  return (0, _keymap3.default)(schema);
308
278
  }
309
279
  });
@@ -345,16 +315,13 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref4) {
345
315
  });
346
316
  return pmPlugins;
347
317
  },
348
- contentComponent: function contentComponent(_ref11) {
349
- var editorView = _ref11.editorView,
350
- appearance = _ref11.appearance;
318
+ contentComponent: function contentComponent(_ref10) {
319
+ var editorView = _ref10.editorView,
320
+ appearance = _ref10.appearance;
351
321
  if (!editorView) {
352
322
  return null;
353
323
  }
354
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (options === null || options === void 0 ? void 0 : options.allowImageEditing) && (0, _expValEquals.expValEquals)('platform_editor_add_image_editing', 'isEnabled', true) && /*#__PURE__*/_react.default.createElement(ImageEditorFunctionalComponent, {
355
- api: api,
356
- editorView: editorView
357
- }), /*#__PURE__*/_react.default.createElement(MediaViewerFunctionalComponent, {
324
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(MediaViewerFunctionalComponent, {
358
325
  api: api,
359
326
  editorView: editorView
360
327
  }), /*#__PURE__*/_react.default.createElement(MediaPickerFunctionalComponent, {
@@ -363,8 +330,8 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref4) {
363
330
  api: api
364
331
  }));
365
332
  },
366
- secondaryToolbarComponent: function secondaryToolbarComponent(_ref12) {
367
- var disabled = _ref12.disabled;
333
+ secondaryToolbarComponent: function secondaryToolbarComponent(_ref11) {
334
+ var disabled = _ref11.disabled;
368
335
  return /*#__PURE__*/_react.default.createElement(_ToolbarMedia.default, {
369
336
  isDisabled: disabled,
370
337
  isReducedSpacing: true,
@@ -386,7 +353,7 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref4) {
386
353
  allowLinking: options && options.allowLinking,
387
354
  allowAdvancedToolBarOptions: options && options.allowAdvancedToolBarOptions,
388
355
  allowAltTextOnImages: options && options.allowAltTextOnImages,
389
- allowImageEditing: options && options.allowImageEditing,
356
+ allowImageEditing: !!(api !== null && api !== void 0 && api.mediaEditing) && options && options.allowImageEditing,
390
357
  allowImagePreview: options && options.allowImagePreview,
391
358
  altTextValidator: options && options.altTextValidator,
392
359
  fullWidthEnabled: options && options.fullWidthEnabled,
@@ -14,12 +14,15 @@ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
14
14
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
15
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
16
  var _react = _interopRequireDefault(require("react"));
17
+ var _bindEventListener = require("bind-event-listener");
17
18
  var _hooks = require("@atlaskit/editor-common/hooks");
18
19
  var _mediaSingle = require("@atlaskit/editor-common/media-single");
19
20
  var _providerFactory = require("@atlaskit/editor-common/provider-factory");
20
21
  var _selectionBasedNodeView = require("@atlaskit/editor-common/selection-based-node-view");
21
22
  var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
23
+ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
22
24
  var _mediaClient = require("@atlaskit/media-client");
25
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
23
26
  var _helpers = require("../../pm-plugins/commands/helpers");
24
27
  var _mediaCommon = require("../../pm-plugins/utils/media-common");
25
28
  var _media = _interopRequireDefault(require("./media"));
@@ -59,6 +62,13 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
59
62
  }
60
63
  _this = _callSuper(this, MediaNodeView, [].concat(args));
61
64
  (0, _defineProperty2.default)(_this, "isSelected", false);
65
+ (0, _defineProperty2.default)(_this, "hasBeenResized", false);
66
+ (0, _defineProperty2.default)(_this, "hasResizedListener", function () {
67
+ if (!_this.hasBeenResized) {
68
+ _this.hasBeenResized = true;
69
+ _this.update(_this.node, _this.decorations);
70
+ }
71
+ });
62
72
  (0, _defineProperty2.default)(_this, "onExternalImageLoaded", function (dimensions) {
63
73
  var getPos = _this.getPos;
64
74
  var _this$getAttrs = _this.getAttrs(),
@@ -75,11 +85,39 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
75
85
  }, true)(_this.view.state, _this.view.dispatch);
76
86
  }
77
87
  });
88
+ (0, _defineProperty2.default)(_this, "getMaxCardDimensions", function () {
89
+ var flexibleDimensions = {
90
+ width: '100%',
91
+ height: '100%'
92
+ };
93
+ if ((0, _expValEquals.expValEquals)('platform_editor_media_vc_fixes', 'isEnabled', true)) {
94
+ var pos = _this.getPos();
95
+ if (typeof pos !== 'number') {
96
+ return flexibleDimensions;
97
+ }
98
+ if (_this.hasBeenResized) {
99
+ return flexibleDimensions;
100
+ }
101
+ var mediaSingleNodeParent = _this.getMediaSingleNode(_this.getPos);
102
+
103
+ // If media parent not found, return default
104
+ if (!mediaSingleNodeParent) {
105
+ return flexibleDimensions;
106
+ }
107
+
108
+ // Compute normal dimensions
109
+ var maxWidth = _this.getMaxWidthFromMediaSingleNode(mediaSingleNodeParent);
110
+ return {
111
+ width: "".concat(maxWidth, "px"),
112
+ height: '100%'
113
+ };
114
+ }
115
+ return flexibleDimensions;
116
+ });
78
117
  (0, _defineProperty2.default)(_this, "renderMediaNodeWithState", function (contextIdentifierProvider) {
79
118
  return function (_ref2) {
80
119
  var _this$reactComponentP;
81
- var editorWidth = _ref2.width,
82
- mediaProvider = _ref2.mediaProvider,
120
+ var mediaProvider = _ref2.mediaProvider,
83
121
  interactionState = _ref2.interactionState;
84
122
  var getPos = _this.getPos;
85
123
  var mediaOptions = _this.reactComponentProps.mediaOptions;
@@ -98,18 +136,15 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
98
136
  }
99
137
  width = width || _mediaSingle.DEFAULT_IMAGE_WIDTH;
100
138
  height = height || _mediaSingle.DEFAULT_IMAGE_HEIGHT;
139
+ var pluginInjectionApi = _this.reactComponentProps.pluginInjectionApi;
101
140
 
102
141
  // mediaSingle defines the max dimensions, so we don't need to constrain twice.
103
- var maxDimensions = {
104
- width: "100%",
105
- height: "100%"
106
- };
142
+ var maxDimensions = _this.getMaxCardDimensions();
107
143
  var originalDimensions = {
108
144
  width: width,
109
145
  height: height
110
146
  };
111
147
  var isSelectedAndInteracted = _this.nodeInsideSelection() && interactionState !== 'hasNotHadInteraction';
112
- var pluginInjectionApi = _this.reactComponentProps.pluginInjectionApi;
113
148
  return /*#__PURE__*/_react.default.createElement(_media.default, {
114
149
  api: pluginInjectionApi,
115
150
  view: _this.view,
@@ -140,6 +175,42 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
140
175
  }
141
176
  (0, _inherits2.default)(MediaNodeView, _SelectionBasedNodeVi);
142
177
  return (0, _createClass2.default)(MediaNodeView, [{
178
+ key: "getMediaSingleNode",
179
+ value: function getMediaSingleNode(getPos) {
180
+ var pos = getPos();
181
+ if (typeof pos !== 'number') {
182
+ return null;
183
+ }
184
+ var $pos = this.view.state.doc.resolve(pos);
185
+
186
+ // The parent of the media node should be mediaSingle
187
+ if ($pos.parent && $pos.parent.type.name === 'mediaSingle') {
188
+ return $pos.parent;
189
+ }
190
+ return null;
191
+ }
192
+ }, {
193
+ key: "getMaxWidthFromMediaSingleNode",
194
+ value: function getMaxWidthFromMediaSingleNode(mediaSingleNode) {
195
+ var _mediaSingleNode$attr = mediaSingleNode.attrs,
196
+ widthAttr = _mediaSingleNode$attr.width,
197
+ widthTypeAttr = _mediaSingleNode$attr.widthType,
198
+ layoutAttr = _mediaSingleNode$attr.layout;
199
+ // for extended mediaSingle nodes with width and widthType attributes ( default behaviour )
200
+ if (widthAttr && widthTypeAttr === 'pixel') {
201
+ return widthAttr;
202
+ }
203
+ // for legacy mediaSingle nodes without widthType attribute
204
+ switch (layoutAttr) {
205
+ case 'full-width':
206
+ return _editorSharedStyles.akEditorFullWidthLayoutWidth;
207
+ case 'wide':
208
+ return _editorSharedStyles.akEditorCalculatedWideLayoutWidth;
209
+ default:
210
+ return _editorSharedStyles.akEditorDefaultLayoutWidth;
211
+ }
212
+ }
213
+ }, {
143
214
  key: "createDomRef",
144
215
  value: function createDomRef() {
145
216
  var domRef = document.createElement('div');
@@ -148,6 +219,12 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
148
219
  // see also: https://github.com/ProseMirror/prosemirror/issues/884
149
220
  domRef.contentEditable = 'true';
150
221
  }
222
+ if ((0, _expValEquals.expValEquals)('platform_editor_media_vc_fixes', 'isEnabled', true)) {
223
+ this.resizeListenerBinding = (0, _bindEventListener.bind)(domRef, {
224
+ type: 'resized',
225
+ listener: this.hasResizedListener
226
+ });
227
+ }
151
228
  return domRef;
152
229
  }
153
230
  }, {
@@ -199,6 +276,14 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
199
276
  renderNode: this.renderMediaNodeWithProviders
200
277
  });
201
278
  }
279
+ }, {
280
+ key: "destroy",
281
+ value: function destroy() {
282
+ if (this.resizeListenerBinding) {
283
+ this.resizeListenerBinding();
284
+ }
285
+ _superPropGet(MediaNodeView, "destroy", this, 3)([]);
286
+ }
202
287
  }]);
203
288
  }(_selectionBasedNodeView.SelectionBasedNodeView);
204
289
  var ReactMediaNode = exports.ReactMediaNode = function ReactMediaNode(portalProviderAPI, eventDispatcher, providerFactory) {
@@ -19,6 +19,7 @@ var _providerFactory = require("@atlaskit/editor-common/provider-factory");
19
19
  var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
20
20
  var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
21
21
  var _utils = require("@atlaskit/editor-common/utils");
22
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
22
23
  var _main = require("../pm-plugins/main");
23
24
  var _mediaSingleNext = require("./mediaSingleNext");
24
25
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
@@ -104,6 +105,7 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
104
105
  (0, _defineProperty2.default)(_this, "lastOffsetLeft", 0);
105
106
  (0, _defineProperty2.default)(_this, "forceViewUpdate", false);
106
107
  (0, _defineProperty2.default)(_this, "selectionType", null);
108
+ (0, _defineProperty2.default)(_this, "hasResized", false);
107
109
  (0, _defineProperty2.default)(_this, "checkAndUpdateSelectionType", function () {
108
110
  var getPos = _this.getPos;
109
111
  var selection = _this.view.state.selection;
@@ -116,7 +118,7 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
116
118
  var pos;
117
119
  try {
118
120
  pos = getPos ? getPos() : undefined;
119
- } catch (e) {
121
+ } catch (_unused) {
120
122
  pos = undefined;
121
123
  }
122
124
  var isNodeSelected = (0, _utils.isNodeSelectedOrInRange)(selection.$anchor.pos, selection.$head.pos, pos, _this.node.nodeSize);
@@ -228,6 +230,11 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
228
230
  return _this3.getNodeMediaId(currentNode) === _this3.getNodeMediaId(newNode);
229
231
  };
230
232
  }
233
+ // Detect mediaSingle width attribute changes and signal child media node to update
234
+ if (!this.hasResized && this.node.attrs.width !== node.attrs.width && (0, _expValEquals.expValEquals)('platform_editor_media_vc_fixes', 'isEnabled', true)) {
235
+ var target = this.dom.querySelector('div[data-prosemirror-node-name="media"]');
236
+ target === null || target === void 0 || target.dispatchEvent(new CustomEvent('resized'));
237
+ }
231
238
  return _superPropGet(MediaSingleNodeView, "update", this, 3)([node, decorations, _innerDecorations, isValidUpdate]);
232
239
  }
233
240
  }, {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.trackMediaPaste = exports.showMediaViewer = exports.showImageEditor = exports.hideMediaViewer = exports.hideImageEditor = void 0;
6
+ exports.trackMediaPaste = exports.showMediaViewer = exports.hideMediaViewer = void 0;
7
7
  var _actions = require("../pm-plugins/actions");
8
8
  var _pluginKey = require("../pm-plugins/plugin-key");
9
9
  var _mediaCommon = require("../pm-plugins/utils/media-common");
@@ -37,26 +37,4 @@ var trackMediaPaste = exports.trackMediaPaste = function trackMediaPaste(attrs)
37
37
  });
38
38
  return tr;
39
39
  };
40
- };
41
- var showImageEditor = exports.showImageEditor = function showImageEditor(media) {
42
- return function (_ref4) {
43
- var tr = _ref4.tr;
44
- tr.setMeta(_pluginKey.stateKey, {
45
- type: _actions.ACTIONS.SHOW_IMAGE_EDITOR,
46
- imageEditorSelectedMedia: media,
47
- isImageEditorVisible: true
48
- });
49
- tr.setMeta('addToHistory', false);
50
- return tr;
51
- };
52
- };
53
- var hideImageEditor = exports.hideImageEditor = function hideImageEditor(_ref5) {
54
- var tr = _ref5.tr;
55
- tr.setMeta(_pluginKey.stateKey, {
56
- type: _actions.ACTIONS.HIDE_IMAGE_EDITOR,
57
- imageEditorSelectedMedia: null,
58
- isImageEditorVisible: false
59
- });
60
- tr.setMeta('addToHistory', false);
61
- return tr;
62
40
  };
@@ -90,7 +90,6 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
90
90
  (0, _defineProperty2.default)(this, "allowInlineImages", false);
91
91
  (0, _defineProperty2.default)(this, "uploadInProgressSubscriptions", []);
92
92
  (0, _defineProperty2.default)(this, "uploadInProgressSubscriptionsNotified", false);
93
- (0, _defineProperty2.default)(this, "isImageEditorVisible", false);
94
93
  // this is only a temporary variable, which gets cleared after the last inserted node has been selected
95
94
  (0, _defineProperty2.default)(this, "lastAddedMediaSingleFileIds", []);
96
95
  (0, _defineProperty2.default)(this, "destroyed", false);
@@ -638,11 +637,6 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
638
637
  value: function setResizingWidth(width) {
639
638
  this.resizingWidth = width;
640
639
  }
641
- }, {
642
- key: "setImageEditorVisibility",
643
- value: function setImageEditorVisibility(isVisible) {
644
- this.isImageEditorVisible = isVisible;
645
- }
646
640
  }, {
647
641
  key: "updateElement",
648
642
  value: function updateElement() {
@@ -884,16 +878,6 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
884
878
  nextPluginState = pluginState.clone();
885
879
  }
886
880
  break;
887
- case _actions.ACTIONS.SHOW_IMAGE_EDITOR:
888
- pluginState.imageEditorSelectedMedia = meta.imageEditorSelectedMedia;
889
- pluginState.isImageEditorVisible = meta.isImageEditorVisible;
890
- nextPluginState = nextPluginState.clone();
891
- break;
892
- case _actions.ACTIONS.HIDE_IMAGE_EDITOR:
893
- pluginState.imageEditorSelectedMedia = undefined;
894
- pluginState.isImageEditorVisible = meta.isImageEditorVisible;
895
- nextPluginState = nextPluginState.clone();
896
- break;
897
881
  }
898
882
 
899
883
  // NOTE: We're not calling passing new state to the Editor, because we depend on the view.state reference
@@ -199,6 +199,10 @@ var ResizableMediaSingleNextFunctional = exports.ResizableMediaSingleNextFunctio
199
199
  _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
200
200
  isVideoFile = _useState8[0],
201
201
  setIsVideoFile = _useState8[1];
202
+ var _useState9 = (0, _react.useState)(false),
203
+ _useState0 = (0, _slicedToArray2.default)(_useState9, 2),
204
+ hasResized = _useState0[0],
205
+ setHasResized = _useState0[1];
202
206
  var nodePosition = (0, _react.useMemo)(function () {
203
207
  if (typeof getPos !== 'function') {
204
208
  return null;
@@ -368,6 +372,7 @@ var ResizableMediaSingleNextFunctional = exports.ResizableMediaSingleNextFunctio
368
372
  width: props.width,
369
373
  height: props.height
370
374
  }));
375
+ var resizerContainerRef = (0, _react.useRef)(null);
371
376
  var handleResize = (0, _react.useCallback)(function (size, delta) {
372
377
  var _calculateSizeState = calculateSizeState({
373
378
  layout: layout,
@@ -379,6 +384,14 @@ var ResizableMediaSingleNextFunctional = exports.ResizableMediaSingleNextFunctio
379
384
  width = _calculateSizeState.width,
380
385
  height = _calculateSizeState.height,
381
386
  newLayout = _calculateSizeState.layout;
387
+ var resizerDomEl = resizerContainerRef.current;
388
+ if (resizerDomEl && !hasResized && (0, _expValEquals.expValEquals)('platform_editor_media_vc_fixes', 'isEnabled', true)) {
389
+ // dispatch resize event to media node DOM element inside resizerDom
390
+ var mediaDomEl = resizerDomEl.querySelector('div[data-prosemirror-node-name="media"]');
391
+ var event = new CustomEvent('resized');
392
+ mediaDomEl === null || mediaDomEl === void 0 || mediaDomEl.dispatchEvent(event);
393
+ setHasResized(true);
394
+ }
382
395
  if (isGuidelineEnabled) {
383
396
  var guidelineSnaps = (0, _guideline.getGuidelineSnaps)(guidelinesRef.current, lineLength, layout);
384
397
  updateActiveGuidelines(width, guidelinesRef.current, guidelineSnaps);
@@ -398,7 +411,7 @@ var ResizableMediaSingleNextFunctional = exports.ResizableMediaSingleNextFunctio
398
411
  if (newLayout !== layout) {
399
412
  updateSize(width, newLayout);
400
413
  }
401
- }, [view, updateSize, layout, isGuidelineEnabled, containerWidth, lineLength, fullWidthMode, isAdjacentMode, updateActiveGuidelines]);
414
+ }, [layout, containerWidth, lineLength, fullWidthMode, isAdjacentMode, hasResized, isGuidelineEnabled, view, updateActiveGuidelines, updateSize]);
402
415
  var handleResizeStop = (0, _react.useCallback)(function (size, delta) {
403
416
  var _pluginInjectionApi$g3;
404
417
  if (typeof nodePosition !== 'number') {
@@ -490,7 +503,8 @@ var ResizableMediaSingleNextFunctional = exports.ResizableMediaSingleNextFunctio
490
503
  }, [forceHandlePositioning, isAdjacentMode]);
491
504
  return (0, _react2.jsx)("div", {
492
505
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
493
- css: memoizedCss
506
+ css: memoizedCss,
507
+ ref: resizerContainerRef
494
508
  }, (0, _react2.jsx)(_resizer.ResizerNext, {
495
509
  minWidth: minViewWidth,
496
510
  maxWidth: maxWidth
@@ -22,6 +22,7 @@ var _utils = require("@atlaskit/editor-common/utils");
22
22
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
23
23
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
24
24
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
25
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
25
26
  var _checkMediaType = require("../../pm-plugins/utils/check-media-type");
26
27
  var _styled = require("./styled");
27
28
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
@@ -38,6 +39,7 @@ var ResizableMediaSingle = exports.default = /*#__PURE__*/function (_React$Compo
38
39
  args[_key] = arguments[_key];
39
40
  }
40
41
  _this = _callSuper(this, ResizableMediaSingle, [].concat(args));
42
+ (0, _defineProperty2.default)(_this, "hasResized", false);
41
43
  (0, _defineProperty2.default)(_this, "state", {
42
44
  offsetLeft: (0, _mediaSingle.calculateOffsetLeft)(_this.insideInlineLike, _this.insideLayout, _this.props.view.dom, undefined),
43
45
  isVideoFile: !(0, _platformFeatureFlags.fg)('platform_editor_media_video_check_fix')
@@ -57,6 +59,15 @@ var ResizableMediaSingle = exports.default = /*#__PURE__*/function (_React$Compo
57
59
  var _this$props2 = _this.props,
58
60
  layout = _this$props2.layout,
59
61
  state = _this$props2.view.state;
62
+ if (!_this.hasResized && (0, _expValEquals.expValEquals)('platform_editor_media_vc_fixes', 'isEnabled', true)) {
63
+ var _this$wrapper;
64
+ var mediaDomEl = (_this$wrapper = _this.wrapper) === null || _this$wrapper === void 0 ? void 0 : _this$wrapper.querySelector('div[data-prosemirror-node-name="media"]');
65
+ if (mediaDomEl) {
66
+ var event = new CustomEvent('resized');
67
+ mediaDomEl === null || mediaDomEl === void 0 || mediaDomEl.dispatchEvent(event);
68
+ }
69
+ _this.hasResized = true;
70
+ }
60
71
  var newPct = (0, _ui.calcPctFromPx)(newWidth, _this.props.lineLength) * 100;
61
72
  _this.setState({
62
73
  resizedPctWidth: newPct
@@ -123,13 +123,14 @@ var handleShowMediaViewer = exports.handleShowMediaViewer = function handleShowM
123
123
  api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.media.commands.showMediaViewer(selectedNodeAttrs));
124
124
  };
125
125
  var handleShowImageEditor = exports.handleShowImageEditor = function handleShowImageEditor(_ref2) {
126
+ var _api$mediaEditing;
126
127
  var api = _ref2.api,
127
128
  mediaPluginState = _ref2.mediaPluginState;
128
129
  var selectedNodeAttrs = (0, _utils2.getSelectedNearestMediaContainerNodeAttrs)(mediaPluginState);
129
130
  if (!selectedNodeAttrs) {
130
131
  return false;
131
132
  }
132
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.media.commands.showImageEditor(selectedNodeAttrs));
133
+ 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));
133
134
  };
134
135
  var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, editorAnalyticsAPI, forceFocusSelector, isViewOnly) {
135
136
  var _pluginInjectionApi$c;
@@ -563,7 +564,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
563
564
  });
564
565
  }
565
566
  // Image Editing Support
566
- if (allowImageEditing && (0, _expValEquals.expValEquals)('platform_editor_add_image_editing', 'isEnabled', true)) {
567
+ if (!!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.mediaEditing) && allowImageEditing && (0, _expValEquals.expValEquals)('platform_editor_add_image_editing', 'isEnabled', true)) {
567
568
  var _mediaNode$attrs;
568
569
  var _selectedMediaSingleNode = (0, _utils2.getSelectedMediaSingle)(state);
569
570
  var mediaNode = _selectedMediaSingleNode === null || _selectedMediaSingleNode === void 0 ? void 0 : _selectedMediaSingleNode.node.content.firstChild;