@atlaskit/editor-plugin-media 8.7.2 → 8.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @atlaskit/editor-plugin-media
2
2
 
3
+ ## 8.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`bb5f3706afa84`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/bb5f3706afa84) -
8
+ fix media card dimensions on load for ssr
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 8.8.0
15
+
16
+ ### Minor Changes
17
+
18
+ - [`82d57d01a0f61`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/82d57d01a0f61) -
19
+ Distinguish between collab offline and internet offline cases for connectivity mode
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies
24
+
3
25
  ## 8.7.2
4
26
 
5
27
  ### Patch Changes
@@ -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
  }, {
@@ -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
@@ -10,6 +10,7 @@ var _analytics = require("@atlaskit/editor-common/analytics");
10
10
  var _keymaps = require("@atlaskit/editor-common/keymaps");
11
11
  var _media = require("@atlaskit/editor-common/media");
12
12
  var _messages = require("@atlaskit/editor-common/messages");
13
+ var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
13
14
  var _comment = _interopRequireDefault(require("@atlaskit/icon/core/comment"));
14
15
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
16
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
@@ -52,7 +53,7 @@ var commentButton = exports.commentButton = function commentButton(intl, state,
52
53
  description: title
53
54
  }),
54
55
  supportsViewMode: true,
55
- disabled: (api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode) === 'offline',
56
+ disabled: (0, _editorPluginConnectivity.isOfflineMode)(api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode),
56
57
  onMount: function onMount() {
57
58
  if ((0, _platformFeatureFlags.fg)('confluence_frontend_preload_inline_comment_editor')) {
58
59
  onCommentButtonMount && onCommentButtonMount();
@@ -16,6 +16,7 @@ var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
16
16
  var _mediaInline = require("@atlaskit/editor-common/media-inline");
17
17
  var _messages = _interopRequireWildcard(require("@atlaskit/editor-common/messages"));
18
18
  var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
19
+ var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
19
20
  var _state2 = require("@atlaskit/editor-prosemirror/state");
20
21
  var _utils = require("@atlaskit/editor-prosemirror/utils");
21
22
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
@@ -147,7 +148,7 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
147
148
  api: pluginInjectionApi
148
149
  })) !== null && _handleShowMediaViewe !== void 0 ? _handleShowMediaViewe : false;
149
150
  },
150
- disabled: (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c === void 0 || (_pluginInjectionApi$c = _pluginInjectionApi$c.sharedState) === null || _pluginInjectionApi$c === void 0 || (_pluginInjectionApi$c = _pluginInjectionApi$c.currentState()) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.mode) === 'offline',
151
+ disabled: (0, _editorPluginConnectivity.isOfflineMode)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c === void 0 || (_pluginInjectionApi$c = _pluginInjectionApi$c.sharedState) === null || _pluginInjectionApi$c === void 0 || (_pluginInjectionApi$c = _pluginInjectionApi$c.currentState()) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.mode),
151
152
  supportsViewMode: true
152
153
  };
153
154
  var download = _objectSpread({
@@ -604,7 +605,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
604
605
  mediaPluginState: pluginState
605
606
  })) !== null && _handleShowMediaViewe2 !== void 0 ? _handleShowMediaViewe2 : false;
606
607
  },
607
- disabled: (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c2 === void 0 || (_pluginInjectionApi$c2 = _pluginInjectionApi$c2.sharedState) === null || _pluginInjectionApi$c2 === void 0 || (_pluginInjectionApi$c2 = _pluginInjectionApi$c2.currentState()) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.mode) === 'offline',
608
+ disabled: (0, _editorPluginConnectivity.isOfflineMode)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c2 === void 0 || (_pluginInjectionApi$c2 = _pluginInjectionApi$c2.sharedState) === null || _pluginInjectionApi$c2 === void 0 || (_pluginInjectionApi$c2 = _pluginInjectionApi$c2.currentState()) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.mode),
608
609
  supportsViewMode: true
609
610
  }, {
610
611
  type: 'separator',
@@ -690,7 +691,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
690
691
  mediaPluginState: pluginState
691
692
  })) !== null && _handleShowMediaViewe3 !== void 0 ? _handleShowMediaViewe3 : false;
692
693
  },
693
- disabled: (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c3 = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c3 === void 0 || (_pluginInjectionApi$c3 = _pluginInjectionApi$c3.sharedState) === null || _pluginInjectionApi$c3 === void 0 || (_pluginInjectionApi$c3 = _pluginInjectionApi$c3.currentState()) === null || _pluginInjectionApi$c3 === void 0 ? void 0 : _pluginInjectionApi$c3.mode) === 'offline',
694
+ disabled: (0, _editorPluginConnectivity.isOfflineMode)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c3 = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c3 === void 0 || (_pluginInjectionApi$c3 = _pluginInjectionApi$c3.sharedState) === null || _pluginInjectionApi$c3 === void 0 || (_pluginInjectionApi$c3 = _pluginInjectionApi$c3.currentState()) === null || _pluginInjectionApi$c3 === void 0 ? void 0 : _pluginInjectionApi$c3.mode),
694
695
  supportsViewMode: true
695
696
  }, {
696
697
  type: 'separator',
@@ -1,11 +1,14 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
+ import { bind } from 'bind-event-listener';
3
4
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
5
  import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
5
6
  import { WithProviders } from '@atlaskit/editor-common/provider-factory';
6
7
  import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
7
8
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
9
+ import { akEditorFullWidthLayoutWidth, akEditorDefaultLayoutWidth, akEditorCalculatedWideLayoutWidth } from '@atlaskit/editor-shared-styles';
8
10
  import { getAttrsFromUrl } from '@atlaskit/media-client';
11
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
9
12
  import { updateCurrentMediaNodeAttrs } from '../../pm-plugins/commands/helpers';
10
13
  import { isMediaBlobUrlFromAttrs } from '../../pm-plugins/utils/media-common';
11
14
  // Ignored via go/ees005
@@ -37,6 +40,13 @@ class MediaNodeView extends SelectionBasedNodeView {
37
40
  constructor(...args) {
38
41
  super(...args);
39
42
  _defineProperty(this, "isSelected", false);
43
+ _defineProperty(this, "hasBeenResized", false);
44
+ _defineProperty(this, "hasResizedListener", () => {
45
+ if (!this.hasBeenResized) {
46
+ this.hasBeenResized = true;
47
+ this.update(this.node, this.decorations);
48
+ }
49
+ });
40
50
  _defineProperty(this, "onExternalImageLoaded", dimensions => {
41
51
  const getPos = this.getPos;
42
52
  const {
@@ -55,9 +65,37 @@ class MediaNodeView extends SelectionBasedNodeView {
55
65
  }, true)(this.view.state, this.view.dispatch);
56
66
  }
57
67
  });
68
+ _defineProperty(this, "getMaxCardDimensions", () => {
69
+ const flexibleDimensions = {
70
+ width: '100%',
71
+ height: '100%'
72
+ };
73
+ if (expValEquals('platform_editor_media_vc_fixes', 'isEnabled', true)) {
74
+ const pos = this.getPos();
75
+ if (typeof pos !== 'number') {
76
+ return flexibleDimensions;
77
+ }
78
+ if (this.hasBeenResized) {
79
+ return flexibleDimensions;
80
+ }
81
+ const mediaSingleNodeParent = this.getMediaSingleNode(this.getPos);
82
+
83
+ // If media parent not found, return default
84
+ if (!mediaSingleNodeParent) {
85
+ return flexibleDimensions;
86
+ }
87
+
88
+ // Compute normal dimensions
89
+ const maxWidth = this.getMaxWidthFromMediaSingleNode(mediaSingleNodeParent);
90
+ return {
91
+ width: `${maxWidth}px`,
92
+ height: '100%'
93
+ };
94
+ }
95
+ return flexibleDimensions;
96
+ });
58
97
  _defineProperty(this, "renderMediaNodeWithState", contextIdentifierProvider => {
59
98
  return ({
60
- width: editorWidth,
61
99
  mediaProvider,
62
100
  interactionState
63
101
  }) => {
@@ -85,20 +123,17 @@ class MediaNodeView extends SelectionBasedNodeView {
85
123
  }
86
124
  width = width || DEFAULT_IMAGE_WIDTH;
87
125
  height = height || DEFAULT_IMAGE_HEIGHT;
126
+ const {
127
+ pluginInjectionApi
128
+ } = this.reactComponentProps;
88
129
 
89
130
  // mediaSingle defines the max dimensions, so we don't need to constrain twice.
90
- const maxDimensions = {
91
- width: `100%`,
92
- height: `100%`
93
- };
131
+ const maxDimensions = this.getMaxCardDimensions();
94
132
  const originalDimensions = {
95
133
  width,
96
134
  height
97
135
  };
98
136
  const isSelectedAndInteracted = this.nodeInsideSelection() && interactionState !== 'hasNotHadInteraction';
99
- const {
100
- pluginInjectionApi
101
- } = this.reactComponentProps;
102
137
  return /*#__PURE__*/React.createElement(MediaNode, {
103
138
  api: pluginInjectionApi,
104
139
  view: this.view,
@@ -129,6 +164,39 @@ class MediaNodeView extends SelectionBasedNodeView {
129
164
  });
130
165
  });
131
166
  }
167
+ getMediaSingleNode(getPos) {
168
+ const pos = getPos();
169
+ if (typeof pos !== 'number') {
170
+ return null;
171
+ }
172
+ const $pos = this.view.state.doc.resolve(pos);
173
+
174
+ // The parent of the media node should be mediaSingle
175
+ if ($pos.parent && $pos.parent.type.name === 'mediaSingle') {
176
+ return $pos.parent;
177
+ }
178
+ return null;
179
+ }
180
+ getMaxWidthFromMediaSingleNode(mediaSingleNode) {
181
+ const {
182
+ width: widthAttr,
183
+ widthType: widthTypeAttr,
184
+ layout: layoutAttr
185
+ } = mediaSingleNode.attrs;
186
+ // for extended mediaSingle nodes with width and widthType attributes ( default behaviour )
187
+ if (widthAttr && widthTypeAttr === 'pixel') {
188
+ return widthAttr;
189
+ }
190
+ // for legacy mediaSingle nodes without widthType attribute
191
+ switch (layoutAttr) {
192
+ case 'full-width':
193
+ return akEditorFullWidthLayoutWidth;
194
+ case 'wide':
195
+ return akEditorCalculatedWideLayoutWidth;
196
+ default:
197
+ return akEditorDefaultLayoutWidth;
198
+ }
199
+ }
132
200
  createDomRef() {
133
201
  const domRef = document.createElement('div');
134
202
  if (this.reactComponentProps.mediaOptions && this.reactComponentProps.mediaOptions.allowMediaSingleEditable) {
@@ -136,6 +204,12 @@ class MediaNodeView extends SelectionBasedNodeView {
136
204
  // see also: https://github.com/ProseMirror/prosemirror/issues/884
137
205
  domRef.contentEditable = 'true';
138
206
  }
207
+ if (expValEquals('platform_editor_media_vc_fixes', 'isEnabled', true)) {
208
+ this.resizeListenerBinding = bind(domRef, {
209
+ type: 'resized',
210
+ listener: this.hasResizedListener
211
+ });
212
+ }
139
213
  return domRef;
140
214
  }
141
215
  viewShouldUpdate(nextNode, decorations) {
@@ -179,6 +253,12 @@ class MediaNodeView extends SelectionBasedNodeView {
179
253
  renderNode: this.renderMediaNodeWithProviders
180
254
  });
181
255
  }
256
+ destroy() {
257
+ if (this.resizeListenerBinding) {
258
+ this.resizeListenerBinding();
259
+ }
260
+ super.destroy();
261
+ }
182
262
  }
183
263
  export const ReactMediaNode = (portalProviderAPI, eventDispatcher, providerFactory, mediaOptions = {}, pluginInjectionApi) => (node, view, getPos) => {
184
264
  return new MediaNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, {
@@ -13,6 +13,7 @@ import { WithProviders } from '@atlaskit/editor-common/provider-factory';
13
13
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
14
14
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
15
15
  import { isNodeSelectedOrInRange } from '@atlaskit/editor-common/utils';
16
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
16
17
  import { MEDIA_CONTENT_WRAP_CLASS_NAME } from '../pm-plugins/main';
17
18
  import { MediaSingleNodeNext } from './mediaSingleNext';
18
19
  const selector = states => {
@@ -84,6 +85,7 @@ class MediaSingleNodeView extends ReactNodeView {
84
85
  _defineProperty(this, "lastOffsetLeft", 0);
85
86
  _defineProperty(this, "forceViewUpdate", false);
86
87
  _defineProperty(this, "selectionType", null);
88
+ _defineProperty(this, "hasResized", false);
87
89
  _defineProperty(this, "checkAndUpdateSelectionType", () => {
88
90
  const getPos = this.getPos;
89
91
  const {
@@ -98,7 +100,7 @@ class MediaSingleNodeView extends ReactNodeView {
98
100
  let pos;
99
101
  try {
100
102
  pos = getPos ? getPos() : undefined;
101
- } catch (e) {
103
+ } catch {
102
104
  pos = undefined;
103
105
  }
104
106
  const isNodeSelected = isNodeSelectedOrInRange(selection.$anchor.pos, selection.$head.pos, pos, this.node.nodeSize);
@@ -188,6 +190,11 @@ class MediaSingleNodeView extends ReactNodeView {
188
190
  if (!isValidUpdate) {
189
191
  isValidUpdate = (currentNode, newNode) => this.getNodeMediaId(currentNode) === this.getNodeMediaId(newNode);
190
192
  }
193
+ // Detect mediaSingle width attribute changes and signal child media node to update
194
+ if (!this.hasResized && this.node.attrs.width !== node.attrs.width && expValEquals('platform_editor_media_vc_fixes', 'isEnabled', true)) {
195
+ const target = this.dom.querySelector('div[data-prosemirror-node-name="media"]');
196
+ target === null || target === void 0 ? void 0 : target.dispatchEvent(new CustomEvent('resized'));
197
+ }
191
198
  return super.update(node, decorations, _innerDecorations, isValidUpdate);
192
199
  }
193
200
  render(props, forwardRef) {
@@ -179,6 +179,7 @@ export const ResizableMediaSingleNextFunctional = props => {
179
179
  const [snaps, setSnaps] = useState({});
180
180
  const [isResizing, setIsResizing] = useState(false);
181
181
  const [isVideoFile, setIsVideoFile] = useState(!(fg('platform_editor_media_video_check_fix') || fg('platform_editor_ssr_media')));
182
+ const [hasResized, setHasResized] = useState(false);
182
183
  const nodePosition = useMemo(() => {
183
184
  if (typeof getPos !== 'function') {
184
185
  return null;
@@ -348,6 +349,7 @@ export const ResizableMediaSingleNextFunctional = props => {
348
349
  width: props.width,
349
350
  height: props.height
350
351
  }));
352
+ const resizerContainerRef = useRef(null);
351
353
  const handleResize = useCallback((size, delta) => {
352
354
  const {
353
355
  width,
@@ -360,6 +362,14 @@ export const ResizableMediaSingleNextFunctional = props => {
360
362
  fullWidthMode,
361
363
  isNestedNode: isAdjacentMode
362
364
  })(size, delta, false, aspectRatioRef.current);
365
+ const resizerDomEl = resizerContainerRef.current;
366
+ if (resizerDomEl && !hasResized && expValEquals('platform_editor_media_vc_fixes', 'isEnabled', true)) {
367
+ // dispatch resize event to media node DOM element inside resizerDom
368
+ const mediaDomEl = resizerDomEl.querySelector('div[data-prosemirror-node-name="media"]');
369
+ const event = new CustomEvent('resized');
370
+ mediaDomEl === null || mediaDomEl === void 0 ? void 0 : mediaDomEl.dispatchEvent(event);
371
+ setHasResized(true);
372
+ }
363
373
  if (isGuidelineEnabled) {
364
374
  const guidelineSnaps = getGuidelineSnaps(guidelinesRef.current, lineLength, layout);
365
375
  updateActiveGuidelines(width, guidelinesRef.current, guidelineSnaps);
@@ -379,7 +389,7 @@ export const ResizableMediaSingleNextFunctional = props => {
379
389
  if (newLayout !== layout) {
380
390
  updateSize(width, newLayout);
381
391
  }
382
- }, [view, updateSize, layout, isGuidelineEnabled, containerWidth, lineLength, fullWidthMode, isAdjacentMode, updateActiveGuidelines]);
392
+ }, [layout, containerWidth, lineLength, fullWidthMode, isAdjacentMode, hasResized, isGuidelineEnabled, view, updateActiveGuidelines, updateSize]);
383
393
  const handleResizeStop = useCallback((size, delta) => {
384
394
  var _pluginInjectionApi$g5, _pluginInjectionApi$g6;
385
395
  if (typeof nodePosition !== 'number') {
@@ -472,7 +482,8 @@ export const ResizableMediaSingleNextFunctional = props => {
472
482
  }, [forceHandlePositioning, isAdjacentMode]);
473
483
  return jsx("div", {
474
484
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
475
- css: memoizedCss
485
+ css: memoizedCss,
486
+ ref: resizerContainerRef
476
487
  }, jsx(ResizerNext, {
477
488
  minWidth: minViewWidth,
478
489
  maxWidth: maxWidth
@@ -14,12 +14,14 @@ import { calculateSnapPoints } from '@atlaskit/editor-common/utils';
14
14
  import { findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
15
15
  import { akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
16
16
  import { fg } from '@atlaskit/platform-feature-flags';
17
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
17
18
  import { checkMediaType } from '../../pm-plugins/utils/check-media-type';
18
19
  import { wrapperStyle } from './styled';
19
20
  // eslint-disable-next-line @repo/internal/react/no-class-components
20
21
  export default class ResizableMediaSingle extends React.Component {
21
22
  constructor(...args) {
22
23
  super(...args);
24
+ _defineProperty(this, "hasResized", false);
23
25
  _defineProperty(this, "state", {
24
26
  offsetLeft: calculateOffsetLeft(this.insideInlineLike, this.insideLayout, this.props.view.dom, undefined),
25
27
  isVideoFile: !fg('platform_editor_media_video_check_fix')
@@ -43,6 +45,15 @@ export default class ResizableMediaSingle extends React.Component {
43
45
  state
44
46
  }
45
47
  } = this.props;
48
+ if (!this.hasResized && expValEquals('platform_editor_media_vc_fixes', 'isEnabled', true)) {
49
+ var _this$wrapper;
50
+ const mediaDomEl = (_this$wrapper = this.wrapper) === null || _this$wrapper === void 0 ? void 0 : _this$wrapper.querySelector('div[data-prosemirror-node-name="media"]');
51
+ if (mediaDomEl) {
52
+ const event = new CustomEvent('resized');
53
+ mediaDomEl === null || mediaDomEl === void 0 ? void 0 : mediaDomEl.dispatchEvent(event);
54
+ }
55
+ this.hasResized = true;
56
+ }
46
57
  const newPct = calcPctFromPx(newWidth, this.props.lineLength) * 100;
47
58
  this.setState({
48
59
  resizedPctWidth: newPct
@@ -3,6 +3,7 @@ import { INPUT_METHOD, VIEW_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
4
4
  import { commentMessages as messages } from '@atlaskit/editor-common/media';
5
5
  import { annotationMessages } from '@atlaskit/editor-common/messages';
6
+ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
6
7
  import CommentIcon from '@atlaskit/icon/core/comment';
7
8
  import { fg } from '@atlaskit/platform-feature-flags';
8
9
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
@@ -44,7 +45,7 @@ export const commentButton = (intl, state, api, onCommentButtonMount) => {
44
45
  description: title
45
46
  }),
46
47
  supportsViewMode: true,
47
- disabled: (api === null || api === void 0 ? void 0 : (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 ? void 0 : (_api$connectivity$sha = _api$connectivity.sharedState) === null || _api$connectivity$sha === void 0 ? void 0 : (_api$connectivity$sha2 = _api$connectivity$sha.currentState()) === null || _api$connectivity$sha2 === void 0 ? void 0 : _api$connectivity$sha2.mode) === 'offline',
48
+ disabled: isOfflineMode(api === null || api === void 0 ? void 0 : (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 ? void 0 : (_api$connectivity$sha = _api$connectivity.sharedState) === null || _api$connectivity$sha === void 0 ? void 0 : (_api$connectivity$sha2 = _api$connectivity$sha.currentState()) === null || _api$connectivity$sha2 === void 0 ? void 0 : _api$connectivity$sha2.mode),
48
49
  onMount: () => {
49
50
  if (fg('confluence_frontend_preload_inline_comment_editor')) {
50
51
  onCommentButtonMount && onCommentButtonMount();
@@ -6,6 +6,7 @@ import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
6
6
  import { mediaInlineImagesEnabled } from '@atlaskit/editor-common/media-inline';
7
7
  import commonMessages, { cardMessages, mediaAndEmbedToolbarMessages } from '@atlaskit/editor-common/messages';
8
8
  import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
9
+ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
9
10
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
10
11
  import { contains, findParentNodeOfType, hasParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
11
12
  import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
@@ -136,7 +137,7 @@ const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState, hoverDe
136
137
  api: pluginInjectionApi
137
138
  })) !== null && _handleShowMediaViewe !== void 0 ? _handleShowMediaViewe : false;
138
139
  },
139
- disabled: (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c === void 0 ? void 0 : (_pluginInjectionApi$c2 = _pluginInjectionApi$c.sharedState) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : (_pluginInjectionApi$c3 = _pluginInjectionApi$c2.currentState()) === null || _pluginInjectionApi$c3 === void 0 ? void 0 : _pluginInjectionApi$c3.mode) === 'offline',
140
+ disabled: isOfflineMode(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c === void 0 ? void 0 : (_pluginInjectionApi$c2 = _pluginInjectionApi$c.sharedState) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : (_pluginInjectionApi$c3 = _pluginInjectionApi$c2.currentState()) === null || _pluginInjectionApi$c3 === void 0 ? void 0 : _pluginInjectionApi$c3.mode),
140
141
  supportsViewMode: true
141
142
  };
142
143
  const download = {
@@ -603,7 +604,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
603
604
  mediaPluginState: pluginState
604
605
  })) !== null && _handleShowMediaViewe2 !== void 0 ? _handleShowMediaViewe2 : false;
605
606
  },
606
- disabled: (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c4 = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c4 === void 0 ? void 0 : (_pluginInjectionApi$c5 = _pluginInjectionApi$c4.sharedState) === null || _pluginInjectionApi$c5 === void 0 ? void 0 : (_pluginInjectionApi$c6 = _pluginInjectionApi$c5.currentState()) === null || _pluginInjectionApi$c6 === void 0 ? void 0 : _pluginInjectionApi$c6.mode) === 'offline',
607
+ disabled: isOfflineMode(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c4 = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c4 === void 0 ? void 0 : (_pluginInjectionApi$c5 = _pluginInjectionApi$c4.sharedState) === null || _pluginInjectionApi$c5 === void 0 ? void 0 : (_pluginInjectionApi$c6 = _pluginInjectionApi$c5.currentState()) === null || _pluginInjectionApi$c6 === void 0 ? void 0 : _pluginInjectionApi$c6.mode),
607
608
  supportsViewMode: true
608
609
  }, {
609
610
  type: 'separator',
@@ -689,7 +690,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
689
690
  mediaPluginState: pluginState
690
691
  })) !== null && _handleShowMediaViewe3 !== void 0 ? _handleShowMediaViewe3 : false;
691
692
  },
692
- disabled: (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c7 = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c7 === void 0 ? void 0 : (_pluginInjectionApi$c8 = _pluginInjectionApi$c7.sharedState) === null || _pluginInjectionApi$c8 === void 0 ? void 0 : (_pluginInjectionApi$c9 = _pluginInjectionApi$c8.currentState()) === null || _pluginInjectionApi$c9 === void 0 ? void 0 : _pluginInjectionApi$c9.mode) === 'offline',
693
+ disabled: isOfflineMode(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c7 = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c7 === void 0 ? void 0 : (_pluginInjectionApi$c8 = _pluginInjectionApi$c7.sharedState) === null || _pluginInjectionApi$c8 === void 0 ? void 0 : (_pluginInjectionApi$c9 = _pluginInjectionApi$c8.currentState()) === null || _pluginInjectionApi$c9 === void 0 ? void 0 : _pluginInjectionApi$c9.mode),
693
694
  supportsViewMode: true
694
695
  }, {
695
696
  type: 'separator',
@@ -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
  }, {
@@ -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
@@ -3,6 +3,7 @@ import { INPUT_METHOD, VIEW_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
4
4
  import { commentMessages as messages } from '@atlaskit/editor-common/media';
5
5
  import { annotationMessages } from '@atlaskit/editor-common/messages';
6
+ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
6
7
  import CommentIcon from '@atlaskit/icon/core/comment';
7
8
  import { fg } from '@atlaskit/platform-feature-flags';
8
9
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
@@ -45,7 +46,7 @@ export var commentButton = function commentButton(intl, state, api, onCommentBut
45
46
  description: title
46
47
  }),
47
48
  supportsViewMode: true,
48
- disabled: (api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode) === 'offline',
49
+ disabled: isOfflineMode(api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode),
49
50
  onMount: function onMount() {
50
51
  if (fg('confluence_frontend_preload_inline_comment_editor')) {
51
52
  onCommentButtonMount && onCommentButtonMount();
@@ -10,6 +10,7 @@ import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
10
10
  import { mediaInlineImagesEnabled } from '@atlaskit/editor-common/media-inline';
11
11
  import commonMessages, { cardMessages, mediaAndEmbedToolbarMessages } from '@atlaskit/editor-common/messages';
12
12
  import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
13
+ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
13
14
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
14
15
  import { contains, findParentNodeOfType, hasParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
15
16
  import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
@@ -138,7 +139,7 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
138
139
  api: pluginInjectionApi
139
140
  })) !== null && _handleShowMediaViewe !== void 0 ? _handleShowMediaViewe : false;
140
141
  },
141
- disabled: (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c === void 0 || (_pluginInjectionApi$c = _pluginInjectionApi$c.sharedState) === null || _pluginInjectionApi$c === void 0 || (_pluginInjectionApi$c = _pluginInjectionApi$c.currentState()) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.mode) === 'offline',
142
+ disabled: isOfflineMode(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c === void 0 || (_pluginInjectionApi$c = _pluginInjectionApi$c.sharedState) === null || _pluginInjectionApi$c === void 0 || (_pluginInjectionApi$c = _pluginInjectionApi$c.currentState()) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.mode),
142
143
  supportsViewMode: true
143
144
  };
144
145
  var download = _objectSpread({
@@ -595,7 +596,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
595
596
  mediaPluginState: pluginState
596
597
  })) !== null && _handleShowMediaViewe2 !== void 0 ? _handleShowMediaViewe2 : false;
597
598
  },
598
- disabled: (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c2 === void 0 || (_pluginInjectionApi$c2 = _pluginInjectionApi$c2.sharedState) === null || _pluginInjectionApi$c2 === void 0 || (_pluginInjectionApi$c2 = _pluginInjectionApi$c2.currentState()) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.mode) === 'offline',
599
+ disabled: isOfflineMode(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c2 === void 0 || (_pluginInjectionApi$c2 = _pluginInjectionApi$c2.sharedState) === null || _pluginInjectionApi$c2 === void 0 || (_pluginInjectionApi$c2 = _pluginInjectionApi$c2.currentState()) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.mode),
599
600
  supportsViewMode: true
600
601
  }, {
601
602
  type: 'separator',
@@ -681,7 +682,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
681
682
  mediaPluginState: pluginState
682
683
  })) !== null && _handleShowMediaViewe3 !== void 0 ? _handleShowMediaViewe3 : false;
683
684
  },
684
- disabled: (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c3 = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c3 === void 0 || (_pluginInjectionApi$c3 = _pluginInjectionApi$c3.sharedState) === null || _pluginInjectionApi$c3 === void 0 || (_pluginInjectionApi$c3 = _pluginInjectionApi$c3.currentState()) === null || _pluginInjectionApi$c3 === void 0 ? void 0 : _pluginInjectionApi$c3.mode) === 'offline',
685
+ disabled: isOfflineMode(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c3 = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c3 === void 0 || (_pluginInjectionApi$c3 = _pluginInjectionApi$c3.sharedState) === null || _pluginInjectionApi$c3 === void 0 || (_pluginInjectionApi$c3 = _pluginInjectionApi$c3.currentState()) === null || _pluginInjectionApi$c3 === void 0 ? void 0 : _pluginInjectionApi$c3.mode),
685
686
  supportsViewMode: true
686
687
  }, {
687
688
  type: 'separator',
@@ -4,20 +4,24 @@ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
4
4
  import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
5
5
  import type { ContextIdentifierProvider, MediaProvider, ProviderFactory, Providers } from '@atlaskit/editor-common/provider-factory';
6
6
  import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
7
- import type { ExtractInjectionAPI, EditorContainerWidth as WidthPluginState } from '@atlaskit/editor-common/types';
7
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
8
8
  import type { SharedInteractionState } from '@atlaskit/editor-plugin-interaction';
9
9
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
10
10
  import type { Decoration, EditorView } from '@atlaskit/editor-prosemirror/view';
11
11
  import type { MediaNextEditorPluginType } from '../../mediaPluginType';
12
- import type { getPosHandler, MediaOptions } from '../../types';
12
+ import type { getPosHandler, getPosHandlerNode, MediaOptions } from '../../types';
13
13
  import type { MediaNodeViewProps } from '../types';
14
14
  interface MediaNodeWithPluginStateComponentProps {
15
15
  interactionState?: SharedInteractionState['interactionState'];
16
16
  mediaProvider?: Promise<MediaProvider>;
17
- width?: WidthPluginState;
18
17
  }
19
18
  declare class MediaNodeView extends SelectionBasedNodeView<MediaNodeViewProps> {
20
19
  private isSelected;
20
+ private hasBeenResized;
21
+ private resizeListenerBinding?;
22
+ getMediaSingleNode(getPos: getPosHandlerNode): PMNode | null;
23
+ getMaxWidthFromMediaSingleNode(mediaSingleNode: PMNode): number;
24
+ hasResizedListener: () => void;
21
25
  createDomRef(): HTMLElement;
22
26
  viewShouldUpdate(nextNode: PMNode, decorations: Decoration[]): boolean;
23
27
  stopEvent(event: Event): boolean;
@@ -27,9 +31,14 @@ declare class MediaNodeView extends SelectionBasedNodeView<MediaNodeViewProps> {
27
31
  height: number;
28
32
  width: number;
29
33
  }) => void;
30
- renderMediaNodeWithState: (contextIdentifierProvider?: Promise<ContextIdentifierProvider>) => ({ width: editorWidth, mediaProvider, interactionState, }: MediaNodeWithPluginStateComponentProps) => React.JSX.Element;
34
+ getMaxCardDimensions: () => {
35
+ width: string;
36
+ height: string;
37
+ };
38
+ renderMediaNodeWithState: (contextIdentifierProvider?: Promise<ContextIdentifierProvider>) => ({ mediaProvider, interactionState, }: MediaNodeWithPluginStateComponentProps) => React.JSX.Element;
31
39
  renderMediaNodeWithProviders: ({ contextIdentifierProvider }: Providers) => React.JSX.Element;
32
40
  render(): React.JSX.Element;
41
+ destroy(): void;
33
42
  }
34
43
  export declare const ReactMediaNode: (portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, mediaOptions: MediaOptions | undefined, pluginInjectionApi: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined) => (node: PMNode, view: EditorView, getPos: getPosHandler) => MediaNodeView;
35
44
  export {};
@@ -15,6 +15,7 @@ declare class MediaSingleNodeView extends ReactNodeView<MediaSingleNodeViewProps
15
15
  forceViewUpdate: boolean;
16
16
  selectionType: number | null;
17
17
  unsubscribeToViewModeChange: (() => void) | undefined;
18
+ hasResized: boolean;
18
19
  createDomRef(): HTMLElement;
19
20
  getContentDOM(): {
20
21
  dom: HTMLDivElement;
@@ -13,6 +13,7 @@ type State = {
13
13
  resizedPctWidth?: number;
14
14
  };
15
15
  export default class ResizableMediaSingle extends React.Component<Props, State> {
16
+ private hasResized;
16
17
  state: State;
17
18
  componentDidUpdate(prevProps: Props): boolean;
18
19
  private displayGrid;
@@ -4,20 +4,24 @@ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
4
4
  import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
5
5
  import type { ContextIdentifierProvider, MediaProvider, ProviderFactory, Providers } from '@atlaskit/editor-common/provider-factory';
6
6
  import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
7
- import type { ExtractInjectionAPI, EditorContainerWidth as WidthPluginState } from '@atlaskit/editor-common/types';
7
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
8
8
  import type { SharedInteractionState } from '@atlaskit/editor-plugin-interaction';
9
9
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
10
10
  import type { Decoration, EditorView } from '@atlaskit/editor-prosemirror/view';
11
11
  import type { MediaNextEditorPluginType } from '../../mediaPluginType';
12
- import type { getPosHandler, MediaOptions } from '../../types';
12
+ import type { getPosHandler, getPosHandlerNode, MediaOptions } from '../../types';
13
13
  import type { MediaNodeViewProps } from '../types';
14
14
  interface MediaNodeWithPluginStateComponentProps {
15
15
  interactionState?: SharedInteractionState['interactionState'];
16
16
  mediaProvider?: Promise<MediaProvider>;
17
- width?: WidthPluginState;
18
17
  }
19
18
  declare class MediaNodeView extends SelectionBasedNodeView<MediaNodeViewProps> {
20
19
  private isSelected;
20
+ private hasBeenResized;
21
+ private resizeListenerBinding?;
22
+ getMediaSingleNode(getPos: getPosHandlerNode): PMNode | null;
23
+ getMaxWidthFromMediaSingleNode(mediaSingleNode: PMNode): number;
24
+ hasResizedListener: () => void;
21
25
  createDomRef(): HTMLElement;
22
26
  viewShouldUpdate(nextNode: PMNode, decorations: Decoration[]): boolean;
23
27
  stopEvent(event: Event): boolean;
@@ -27,9 +31,14 @@ declare class MediaNodeView extends SelectionBasedNodeView<MediaNodeViewProps> {
27
31
  height: number;
28
32
  width: number;
29
33
  }) => void;
30
- renderMediaNodeWithState: (contextIdentifierProvider?: Promise<ContextIdentifierProvider>) => ({ width: editorWidth, mediaProvider, interactionState, }: MediaNodeWithPluginStateComponentProps) => React.JSX.Element;
34
+ getMaxCardDimensions: () => {
35
+ width: string;
36
+ height: string;
37
+ };
38
+ renderMediaNodeWithState: (contextIdentifierProvider?: Promise<ContextIdentifierProvider>) => ({ mediaProvider, interactionState, }: MediaNodeWithPluginStateComponentProps) => React.JSX.Element;
31
39
  renderMediaNodeWithProviders: ({ contextIdentifierProvider }: Providers) => React.JSX.Element;
32
40
  render(): React.JSX.Element;
41
+ destroy(): void;
33
42
  }
34
43
  export declare const ReactMediaNode: (portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, mediaOptions: MediaOptions | undefined, pluginInjectionApi: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined) => (node: PMNode, view: EditorView, getPos: getPosHandler) => MediaNodeView;
35
44
  export {};
@@ -15,6 +15,7 @@ declare class MediaSingleNodeView extends ReactNodeView<MediaSingleNodeViewProps
15
15
  forceViewUpdate: boolean;
16
16
  selectionType: number | null;
17
17
  unsubscribeToViewModeChange: (() => void) | undefined;
18
+ hasResized: boolean;
18
19
  createDomRef(): HTMLElement;
19
20
  getContentDOM(): {
20
21
  dom: HTMLDivElement;
@@ -13,6 +13,7 @@ type State = {
13
13
  resizedPctWidth?: number;
14
14
  };
15
15
  export default class ResizableMediaSingle extends React.Component<Props, State> {
16
+ private hasResized;
16
17
  state: State;
17
18
  componentDidUpdate(prevProps: Props): boolean;
18
19
  private displayGrid;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media",
3
- "version": "8.7.2",
3
+ "version": "8.9.0",
4
4
  "description": "Media plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,8 +35,8 @@
35
35
  "@atlaskit/button": "^23.9.0",
36
36
  "@atlaskit/editor-palette": "^2.1.0",
37
37
  "@atlaskit/editor-plugin-analytics": "^6.2.0",
38
- "@atlaskit/editor-plugin-annotation": "^6.3.0",
39
- "@atlaskit/editor-plugin-connectivity": "^6.0.0",
38
+ "@atlaskit/editor-plugin-annotation": "^6.4.0",
39
+ "@atlaskit/editor-plugin-connectivity": "^6.1.0",
40
40
  "@atlaskit/editor-plugin-decorations": "^6.1.0",
41
41
  "@atlaskit/editor-plugin-editor-disabled": "^6.1.0",
42
42
  "@atlaskit/editor-plugin-editor-viewmode": "^8.0.0",
@@ -46,12 +46,12 @@
46
46
  "@atlaskit/editor-plugin-guideline": "^6.0.0",
47
47
  "@atlaskit/editor-plugin-interaction": "^11.0.0",
48
48
  "@atlaskit/editor-plugin-selection": "^6.1.0",
49
- "@atlaskit/editor-plugin-toolbar": "^3.4.0",
49
+ "@atlaskit/editor-plugin-toolbar": "^3.5.0",
50
50
  "@atlaskit/editor-plugin-width": "^7.0.0",
51
51
  "@atlaskit/editor-prosemirror": "^7.2.0",
52
52
  "@atlaskit/editor-shared-styles": "^3.10.0",
53
53
  "@atlaskit/editor-tables": "^2.9.0",
54
- "@atlaskit/form": "^15.1.0",
54
+ "@atlaskit/form": "^15.2.0",
55
55
  "@atlaskit/icon": "^29.3.0",
56
56
  "@atlaskit/icon-lab": "^5.13.0",
57
57
  "@atlaskit/media-card": "^79.11.0",
@@ -67,7 +67,7 @@
67
67
  "@atlaskit/primitives": "^17.0.0",
68
68
  "@atlaskit/textfield": "^8.2.0",
69
69
  "@atlaskit/theme": "^21.0.0",
70
- "@atlaskit/tmp-editor-statsig": "^16.0.0",
70
+ "@atlaskit/tmp-editor-statsig": "^16.1.0",
71
71
  "@atlaskit/tokens": "^9.0.0",
72
72
  "@atlaskit/tooltip": "^20.11.0",
73
73
  "@babel/runtime": "^7.0.0",
@@ -79,7 +79,7 @@
79
79
  "uuid": "^3.1.0"
80
80
  },
81
81
  "peerDependencies": {
82
- "@atlaskit/editor-common": "^110.46.0",
82
+ "@atlaskit/editor-common": "^110.48.0",
83
83
  "@atlaskit/media-core": "^37.0.0",
84
84
  "react": "^18.2.0",
85
85
  "react-dom": "^18.2.0",