@atlaskit/editor-core 187.42.4 → 187.42.5
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 +6 -0
- package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +5 -3
- package/dist/cjs/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +14 -34
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +5 -3
- package/dist/es2019/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +14 -34
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/media/nodeviews/mediaSingle.js +5 -3
- package/dist/esm/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +14 -34
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +2 -7
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +2 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -358,7 +358,6 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
358
358
|
height: height,
|
|
359
359
|
containerWidth: containerWidth,
|
|
360
360
|
lineLength: contentWidth,
|
|
361
|
-
pctWidth: mediaSingleWidthAttribute,
|
|
362
361
|
fullWidthMode: fullWidthMode,
|
|
363
362
|
hasFallbackContainer: false,
|
|
364
363
|
mediaSingleWidth: (0, _mediaSingle.calcMediaSinglePixelWidth)({
|
|
@@ -410,8 +409,11 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
410
409
|
return canResize ? (0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.extended-resize-experience') ? (0, _react.jsx)(_ResizableMediaSingleNext.default, (0, _extends2.default)({}, resizableMediaSingleProps, {
|
|
411
410
|
showLegacyNotification: widthType !== 'pixel'
|
|
412
411
|
}), MediaChildren) : (0, _react.jsx)(_ResizableMediaSingle.default, (0, _extends2.default)({}, resizableMediaSingleProps, {
|
|
413
|
-
lineLength: contentWidthForLegacyExperience
|
|
414
|
-
|
|
412
|
+
lineLength: contentWidthForLegacyExperience,
|
|
413
|
+
pctWidth: mediaSingleWidthAttribute
|
|
414
|
+
}), MediaChildren) : (0, _react.jsx)(_ui.MediaSingle, (0, _extends2.default)({}, mediaSingleProps, {
|
|
415
|
+
pctWidth: mediaSingleWidthAttribute
|
|
416
|
+
}), MediaChildren);
|
|
415
417
|
}
|
|
416
418
|
}]);
|
|
417
419
|
return MediaSingleNode;
|
|
@@ -66,29 +66,19 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
66
66
|
guidelines: [].concat((0, _toConsumableArray2.default)(defaultGuidelines), (0, _toConsumableArray2.default)(dynamicGuidelines))
|
|
67
67
|
});
|
|
68
68
|
});
|
|
69
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "
|
|
69
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "calcNewLayout", function (newWidth, stop) {
|
|
70
70
|
var _this$props2 = _this.props,
|
|
71
71
|
layout = _this$props2.layout,
|
|
72
72
|
containerWidth = _this$props2.containerWidth,
|
|
73
73
|
lineLength = _this$props2.lineLength,
|
|
74
74
|
fullWidthMode = _this$props2.fullWidthMode;
|
|
75
75
|
var newPct = (0, _ui.calcPctFromPx)(newWidth, lineLength) * 100;
|
|
76
|
-
_this.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var newLayout = _this.calcUnwrappedLayout(newWidth, containerWidth, lineLength, fullWidthMode, _this.isNestedNode());
|
|
80
|
-
if (newPct <= 100) {
|
|
81
|
-
if (_this.wrappedLayout && (stop ? newPct !== 100 : true)) {
|
|
82
|
-
newLayout = layout;
|
|
76
|
+
if (newPct <= 100 && _this.wrappedLayout) {
|
|
77
|
+
if (!stop || newPct !== 100) {
|
|
78
|
+
return layout;
|
|
83
79
|
}
|
|
84
|
-
return {
|
|
85
|
-
layout: newLayout
|
|
86
|
-
};
|
|
87
|
-
} else {
|
|
88
|
-
return {
|
|
89
|
-
layout: newLayout
|
|
90
|
-
};
|
|
91
80
|
}
|
|
81
|
+
return _this.calcUnwrappedLayout(newWidth, containerWidth, lineLength, fullWidthMode, _this.isNestedNode());
|
|
92
82
|
});
|
|
93
83
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "calcUnwrappedLayout", function (width, containerWidth, contentWidth, fullWidthMode, isNestedNode) {
|
|
94
84
|
if (isNestedNode) {
|
|
@@ -185,11 +175,11 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
185
175
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "calculateSizeState", function (size, delta) {
|
|
186
176
|
var onResizeStop = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
187
177
|
var calculatedWidth = Math.round(size.width + delta.width);
|
|
188
|
-
var calculatedWidthWithLayout = _this.
|
|
178
|
+
var calculatedWidthWithLayout = _this.calcNewLayout(calculatedWidth, onResizeStop);
|
|
189
179
|
return {
|
|
190
180
|
width: calculatedWidth,
|
|
191
181
|
height: calculatedWidth / _this.aspectRatio,
|
|
192
|
-
|
|
182
|
+
layout: calculatedWidthWithLayout
|
|
193
183
|
};
|
|
194
184
|
});
|
|
195
185
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "selectCurrentMediaNode", function () {
|
|
@@ -219,7 +209,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
219
209
|
var _this$calculateSizeSt = _this.calculateSizeState(size, delta),
|
|
220
210
|
width = _this$calculateSizeSt.width,
|
|
221
211
|
height = _this$calculateSizeSt.height,
|
|
222
|
-
|
|
212
|
+
newLayout = _this$calculateSizeSt.layout;
|
|
223
213
|
if (_this.isGuidelineEnabled) {
|
|
224
214
|
var guidelineSnaps = (0, _guideline.getGuidelineSnaps)(_this.state.guidelines, lineLength, layout);
|
|
225
215
|
_this.updateActiveGuidelines(width, _this.state.guidelines, guidelineSnaps);
|
|
@@ -242,8 +232,8 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
242
232
|
});
|
|
243
233
|
}
|
|
244
234
|
_this.updateSizeInPluginState(width);
|
|
245
|
-
if (
|
|
246
|
-
updateSize(width,
|
|
235
|
+
if (newLayout !== layout) {
|
|
236
|
+
updateSize(width, newLayout);
|
|
247
237
|
}
|
|
248
238
|
});
|
|
249
239
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleResizeStop", function (size, delta) {
|
|
@@ -254,12 +244,12 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
254
244
|
var _this$calculateSizeSt2 = _this.calculateSizeState(size, delta, true),
|
|
255
245
|
width = _this$calculateSizeSt2.width,
|
|
256
246
|
height = _this$calculateSizeSt2.height,
|
|
257
|
-
|
|
247
|
+
newLayout = _this$calculateSizeSt2.layout;
|
|
258
248
|
if (dispatchAnalyticsEvent) {
|
|
259
249
|
var $pos = _this.$pos;
|
|
260
250
|
var event = (0, _analytics.getMediaResizeAnalyticsEvent)(nodeType || 'mediaSingle', {
|
|
261
251
|
width: width,
|
|
262
|
-
layout:
|
|
252
|
+
layout: newLayout,
|
|
263
253
|
widthType: 'pixel',
|
|
264
254
|
snapType: (0, _guideline.getGuidelineTypeFromKey)(_this.lastSnappedGuidelineKeys, _this.state.guidelines),
|
|
265
255
|
parentNode: $pos ? $pos.parent.type.name : undefined
|
|
@@ -271,7 +261,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
271
261
|
_this.setIsResizing(false);
|
|
272
262
|
_this.displayGuideline([]);
|
|
273
263
|
var newWidth = width;
|
|
274
|
-
if (
|
|
264
|
+
if (newLayout === 'full-width') {
|
|
275
265
|
// When a node reaches full width in current viewport,
|
|
276
266
|
// update its width with 1800 to align with pixel entry
|
|
277
267
|
newWidth = _editorSharedStyles.akEditorFullWidthLayoutWidth;
|
|
@@ -283,7 +273,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
283
273
|
height: height
|
|
284
274
|
}
|
|
285
275
|
}, function () {
|
|
286
|
-
updateSize(newWidth,
|
|
276
|
+
updateSize(newWidth, newLayout);
|
|
287
277
|
});
|
|
288
278
|
});
|
|
289
279
|
var initialWidth = props.mediaSingleWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH;
|
|
@@ -303,13 +293,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
303
293
|
(0, _createClass2.default)(ResizableMediaSingleNext, [{
|
|
304
294
|
key: "componentDidUpdate",
|
|
305
295
|
value: function componentDidUpdate(prevProps) {
|
|
306
|
-
// Handle undo, when the actual pctWidth changed,
|
|
307
|
-
// we sync up with the internal state.
|
|
308
|
-
if (prevProps.pctWidth !== this.props.pctWidth) {
|
|
309
|
-
this.setState({
|
|
310
|
-
resizedPctWidth: this.props.pctWidth
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
296
|
if (prevProps.mediaSingleWidth !== this.props.mediaSingleWidth && this.props.mediaSingleWidth) {
|
|
314
297
|
// update size when lineLength becomes defined later
|
|
315
298
|
// ensures extended experience renders legacy image with the same size as the legacy experience
|
|
@@ -498,7 +481,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
498
481
|
var _this$props8 = this.props,
|
|
499
482
|
origWidth = _this$props8.width,
|
|
500
483
|
layout = _this$props8.layout,
|
|
501
|
-
pctWidth = _this$props8.pctWidth,
|
|
502
484
|
containerWidth = _this$props8.containerWidth,
|
|
503
485
|
fullWidthMode = _this$props8.fullWidthMode,
|
|
504
486
|
selected = _this$props8.selected,
|
|
@@ -520,7 +502,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
520
502
|
|
|
521
503
|
// TODO: Clean up where this lives and how it gets generated
|
|
522
504
|
var className = (0, _classnames.default)(_styles.richMediaClassName, "image-".concat(layout), isResizing ? 'is-resizing' : 'not-resizing', this.props.className, {
|
|
523
|
-
'not-resized': !pctWidth,
|
|
524
505
|
'richMedia-selected': selected,
|
|
525
506
|
'rich-media-wrapped': layout === 'wrap-left' || layout === 'wrap-right'
|
|
526
507
|
});
|
|
@@ -533,7 +514,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
533
514
|
return (0, _react2.jsx)("div", {
|
|
534
515
|
css: (0, _styled.wrapperStyle)({
|
|
535
516
|
layout: layout,
|
|
536
|
-
isResized: !!pctWidth,
|
|
537
517
|
containerWidth: containerWidth || origWidth,
|
|
538
518
|
fullWidthMode: fullWidthMode,
|
|
539
519
|
mediaSingleWidth: this.state.size.width,
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = "@atlaskit/editor-core";
|
|
8
8
|
exports.name = name;
|
|
9
|
-
var version = "187.42.
|
|
9
|
+
var version = "187.42.5";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
@@ -265,7 +265,6 @@ export default class MediaSingleNode extends Component {
|
|
|
265
265
|
height,
|
|
266
266
|
containerWidth: containerWidth,
|
|
267
267
|
lineLength: contentWidth,
|
|
268
|
-
pctWidth: mediaSingleWidthAttribute,
|
|
269
268
|
fullWidthMode,
|
|
270
269
|
hasFallbackContainer: false,
|
|
271
270
|
mediaSingleWidth: calcMediaSinglePixelWidth({
|
|
@@ -320,8 +319,11 @@ export default class MediaSingleNode extends Component {
|
|
|
320
319
|
return canResize ? getBooleanFF('platform.editor.media.extended-resize-experience') ? jsx(ResizableMediaSingleNext, _extends({}, resizableMediaSingleProps, {
|
|
321
320
|
showLegacyNotification: widthType !== 'pixel'
|
|
322
321
|
}), MediaChildren) : jsx(ResizableMediaSingle, _extends({}, resizableMediaSingleProps, {
|
|
323
|
-
lineLength: contentWidthForLegacyExperience
|
|
324
|
-
|
|
322
|
+
lineLength: contentWidthForLegacyExperience,
|
|
323
|
+
pctWidth: mediaSingleWidthAttribute
|
|
324
|
+
}), MediaChildren) : jsx(MediaSingle, _extends({}, mediaSingleProps, {
|
|
325
|
+
pctWidth: mediaSingleWidthAttribute
|
|
326
|
+
}), MediaChildren);
|
|
325
327
|
}
|
|
326
328
|
}
|
|
327
329
|
_defineProperty(MediaSingleNode, "defaultProps", {
|
|
@@ -46,7 +46,7 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
46
46
|
guidelines: [...defaultGuidelines, ...dynamicGuidelines]
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
|
-
_defineProperty(this, "
|
|
49
|
+
_defineProperty(this, "calcNewLayout", (newWidth, stop) => {
|
|
50
50
|
const {
|
|
51
51
|
layout,
|
|
52
52
|
containerWidth,
|
|
@@ -54,22 +54,12 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
54
54
|
fullWidthMode
|
|
55
55
|
} = this.props;
|
|
56
56
|
const newPct = calcPctFromPx(newWidth, lineLength) * 100;
|
|
57
|
-
this.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
let newLayout = this.calcUnwrappedLayout(newWidth, containerWidth, lineLength, fullWidthMode, this.isNestedNode());
|
|
61
|
-
if (newPct <= 100) {
|
|
62
|
-
if (this.wrappedLayout && (stop ? newPct !== 100 : true)) {
|
|
63
|
-
newLayout = layout;
|
|
57
|
+
if (newPct <= 100 && this.wrappedLayout) {
|
|
58
|
+
if (!stop || newPct !== 100) {
|
|
59
|
+
return layout;
|
|
64
60
|
}
|
|
65
|
-
return {
|
|
66
|
-
layout: newLayout
|
|
67
|
-
};
|
|
68
|
-
} else {
|
|
69
|
-
return {
|
|
70
|
-
layout: newLayout
|
|
71
|
-
};
|
|
72
61
|
}
|
|
62
|
+
return this.calcUnwrappedLayout(newWidth, containerWidth, lineLength, fullWidthMode, this.isNestedNode());
|
|
73
63
|
});
|
|
74
64
|
_defineProperty(this, "calcUnwrappedLayout", (width, containerWidth, contentWidth, fullWidthMode, isNestedNode) => {
|
|
75
65
|
if (isNestedNode) {
|
|
@@ -164,11 +154,11 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
164
154
|
});
|
|
165
155
|
_defineProperty(this, "calculateSizeState", (size, delta, onResizeStop = false) => {
|
|
166
156
|
const calculatedWidth = Math.round(size.width + delta.width);
|
|
167
|
-
const calculatedWidthWithLayout = this.
|
|
157
|
+
const calculatedWidthWithLayout = this.calcNewLayout(calculatedWidth, onResizeStop);
|
|
168
158
|
return {
|
|
169
159
|
width: calculatedWidth,
|
|
170
160
|
height: calculatedWidth / this.aspectRatio,
|
|
171
|
-
calculatedWidthWithLayout
|
|
161
|
+
layout: calculatedWidthWithLayout
|
|
172
162
|
};
|
|
173
163
|
});
|
|
174
164
|
_defineProperty(this, "selectCurrentMediaNode", () => {
|
|
@@ -199,7 +189,7 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
199
189
|
const {
|
|
200
190
|
width,
|
|
201
191
|
height,
|
|
202
|
-
|
|
192
|
+
layout: newLayout
|
|
203
193
|
} = this.calculateSizeState(size, delta);
|
|
204
194
|
if (this.isGuidelineEnabled) {
|
|
205
195
|
const guidelineSnaps = getGuidelineSnaps(this.state.guidelines, lineLength, layout);
|
|
@@ -223,8 +213,8 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
223
213
|
});
|
|
224
214
|
}
|
|
225
215
|
this.updateSizeInPluginState(width);
|
|
226
|
-
if (
|
|
227
|
-
updateSize(width,
|
|
216
|
+
if (newLayout !== layout) {
|
|
217
|
+
updateSize(width, newLayout);
|
|
228
218
|
}
|
|
229
219
|
});
|
|
230
220
|
_defineProperty(this, "handleResizeStop", (size, delta) => {
|
|
@@ -236,13 +226,13 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
236
226
|
const {
|
|
237
227
|
width,
|
|
238
228
|
height,
|
|
239
|
-
|
|
229
|
+
layout: newLayout
|
|
240
230
|
} = this.calculateSizeState(size, delta, true);
|
|
241
231
|
if (dispatchAnalyticsEvent) {
|
|
242
232
|
const $pos = this.$pos;
|
|
243
233
|
const event = getMediaResizeAnalyticsEvent(nodeType || 'mediaSingle', {
|
|
244
234
|
width,
|
|
245
|
-
layout:
|
|
235
|
+
layout: newLayout,
|
|
246
236
|
widthType: 'pixel',
|
|
247
237
|
snapType: getGuidelineTypeFromKey(this.lastSnappedGuidelineKeys, this.state.guidelines),
|
|
248
238
|
parentNode: $pos ? $pos.parent.type.name : undefined
|
|
@@ -254,7 +244,7 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
254
244
|
this.setIsResizing(false);
|
|
255
245
|
this.displayGuideline([]);
|
|
256
246
|
let newWidth = width;
|
|
257
|
-
if (
|
|
247
|
+
if (newLayout === 'full-width') {
|
|
258
248
|
// When a node reaches full width in current viewport,
|
|
259
249
|
// update its width with 1800 to align with pixel entry
|
|
260
250
|
newWidth = akEditorFullWidthLayoutWidth;
|
|
@@ -266,7 +256,7 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
266
256
|
height
|
|
267
257
|
}
|
|
268
258
|
}, () => {
|
|
269
|
-
updateSize(newWidth,
|
|
259
|
+
updateSize(newWidth, newLayout);
|
|
270
260
|
});
|
|
271
261
|
});
|
|
272
262
|
const initialWidth = props.mediaSingleWidth || DEFAULT_IMAGE_WIDTH;
|
|
@@ -283,13 +273,6 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
283
273
|
};
|
|
284
274
|
}
|
|
285
275
|
componentDidUpdate(prevProps) {
|
|
286
|
-
// Handle undo, when the actual pctWidth changed,
|
|
287
|
-
// we sync up with the internal state.
|
|
288
|
-
if (prevProps.pctWidth !== this.props.pctWidth) {
|
|
289
|
-
this.setState({
|
|
290
|
-
resizedPctWidth: this.props.pctWidth
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
276
|
if (prevProps.mediaSingleWidth !== this.props.mediaSingleWidth && this.props.mediaSingleWidth) {
|
|
294
277
|
// update size when lineLength becomes defined later
|
|
295
278
|
// ensures extended experience renders legacy image with the same size as the legacy experience
|
|
@@ -414,7 +397,6 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
414
397
|
const {
|
|
415
398
|
width: origWidth,
|
|
416
399
|
layout,
|
|
417
|
-
pctWidth,
|
|
418
400
|
containerWidth,
|
|
419
401
|
fullWidthMode,
|
|
420
402
|
selected,
|
|
@@ -438,7 +420,6 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
438
420
|
|
|
439
421
|
// TODO: Clean up where this lives and how it gets generated
|
|
440
422
|
const className = classnames(richMediaClassName, `image-${layout}`, isResizing ? 'is-resizing' : 'not-resizing', this.props.className, {
|
|
441
|
-
'not-resized': !pctWidth,
|
|
442
423
|
'richMedia-selected': selected,
|
|
443
424
|
'rich-media-wrapped': layout === 'wrap-left' || layout === 'wrap-right'
|
|
444
425
|
});
|
|
@@ -451,7 +432,6 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
451
432
|
return jsx("div", {
|
|
452
433
|
css: wrapperStyle({
|
|
453
434
|
layout,
|
|
454
|
-
isResized: !!pctWidth,
|
|
455
435
|
containerWidth: containerWidth || origWidth,
|
|
456
436
|
fullWidthMode,
|
|
457
437
|
mediaSingleWidth: this.state.size.width,
|
|
@@ -349,7 +349,6 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
349
349
|
height: height,
|
|
350
350
|
containerWidth: containerWidth,
|
|
351
351
|
lineLength: contentWidth,
|
|
352
|
-
pctWidth: mediaSingleWidthAttribute,
|
|
353
352
|
fullWidthMode: fullWidthMode,
|
|
354
353
|
hasFallbackContainer: false,
|
|
355
354
|
mediaSingleWidth: calcMediaSinglePixelWidth({
|
|
@@ -401,8 +400,11 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
401
400
|
return canResize ? getBooleanFF('platform.editor.media.extended-resize-experience') ? jsx(ResizableMediaSingleNext, _extends({}, resizableMediaSingleProps, {
|
|
402
401
|
showLegacyNotification: widthType !== 'pixel'
|
|
403
402
|
}), MediaChildren) : jsx(ResizableMediaSingle, _extends({}, resizableMediaSingleProps, {
|
|
404
|
-
lineLength: contentWidthForLegacyExperience
|
|
405
|
-
|
|
403
|
+
lineLength: contentWidthForLegacyExperience,
|
|
404
|
+
pctWidth: mediaSingleWidthAttribute
|
|
405
|
+
}), MediaChildren) : jsx(MediaSingle, _extends({}, mediaSingleProps, {
|
|
406
|
+
pctWidth: mediaSingleWidthAttribute
|
|
407
|
+
}), MediaChildren);
|
|
406
408
|
}
|
|
407
409
|
}]);
|
|
408
410
|
return MediaSingleNode;
|
|
@@ -59,29 +59,19 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
59
59
|
guidelines: [].concat(_toConsumableArray(defaultGuidelines), _toConsumableArray(dynamicGuidelines))
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
62
|
+
_defineProperty(_assertThisInitialized(_this), "calcNewLayout", function (newWidth, stop) {
|
|
63
63
|
var _this$props2 = _this.props,
|
|
64
64
|
layout = _this$props2.layout,
|
|
65
65
|
containerWidth = _this$props2.containerWidth,
|
|
66
66
|
lineLength = _this$props2.lineLength,
|
|
67
67
|
fullWidthMode = _this$props2.fullWidthMode;
|
|
68
68
|
var newPct = calcPctFromPx(newWidth, lineLength) * 100;
|
|
69
|
-
_this.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var newLayout = _this.calcUnwrappedLayout(newWidth, containerWidth, lineLength, fullWidthMode, _this.isNestedNode());
|
|
73
|
-
if (newPct <= 100) {
|
|
74
|
-
if (_this.wrappedLayout && (stop ? newPct !== 100 : true)) {
|
|
75
|
-
newLayout = layout;
|
|
69
|
+
if (newPct <= 100 && _this.wrappedLayout) {
|
|
70
|
+
if (!stop || newPct !== 100) {
|
|
71
|
+
return layout;
|
|
76
72
|
}
|
|
77
|
-
return {
|
|
78
|
-
layout: newLayout
|
|
79
|
-
};
|
|
80
|
-
} else {
|
|
81
|
-
return {
|
|
82
|
-
layout: newLayout
|
|
83
|
-
};
|
|
84
73
|
}
|
|
74
|
+
return _this.calcUnwrappedLayout(newWidth, containerWidth, lineLength, fullWidthMode, _this.isNestedNode());
|
|
85
75
|
});
|
|
86
76
|
_defineProperty(_assertThisInitialized(_this), "calcUnwrappedLayout", function (width, containerWidth, contentWidth, fullWidthMode, isNestedNode) {
|
|
87
77
|
if (isNestedNode) {
|
|
@@ -178,11 +168,11 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
178
168
|
_defineProperty(_assertThisInitialized(_this), "calculateSizeState", function (size, delta) {
|
|
179
169
|
var onResizeStop = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
180
170
|
var calculatedWidth = Math.round(size.width + delta.width);
|
|
181
|
-
var calculatedWidthWithLayout = _this.
|
|
171
|
+
var calculatedWidthWithLayout = _this.calcNewLayout(calculatedWidth, onResizeStop);
|
|
182
172
|
return {
|
|
183
173
|
width: calculatedWidth,
|
|
184
174
|
height: calculatedWidth / _this.aspectRatio,
|
|
185
|
-
|
|
175
|
+
layout: calculatedWidthWithLayout
|
|
186
176
|
};
|
|
187
177
|
});
|
|
188
178
|
_defineProperty(_assertThisInitialized(_this), "selectCurrentMediaNode", function () {
|
|
@@ -212,7 +202,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
212
202
|
var _this$calculateSizeSt = _this.calculateSizeState(size, delta),
|
|
213
203
|
width = _this$calculateSizeSt.width,
|
|
214
204
|
height = _this$calculateSizeSt.height,
|
|
215
|
-
|
|
205
|
+
newLayout = _this$calculateSizeSt.layout;
|
|
216
206
|
if (_this.isGuidelineEnabled) {
|
|
217
207
|
var guidelineSnaps = getGuidelineSnaps(_this.state.guidelines, lineLength, layout);
|
|
218
208
|
_this.updateActiveGuidelines(width, _this.state.guidelines, guidelineSnaps);
|
|
@@ -235,8 +225,8 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
235
225
|
});
|
|
236
226
|
}
|
|
237
227
|
_this.updateSizeInPluginState(width);
|
|
238
|
-
if (
|
|
239
|
-
updateSize(width,
|
|
228
|
+
if (newLayout !== layout) {
|
|
229
|
+
updateSize(width, newLayout);
|
|
240
230
|
}
|
|
241
231
|
});
|
|
242
232
|
_defineProperty(_assertThisInitialized(_this), "handleResizeStop", function (size, delta) {
|
|
@@ -247,12 +237,12 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
247
237
|
var _this$calculateSizeSt2 = _this.calculateSizeState(size, delta, true),
|
|
248
238
|
width = _this$calculateSizeSt2.width,
|
|
249
239
|
height = _this$calculateSizeSt2.height,
|
|
250
|
-
|
|
240
|
+
newLayout = _this$calculateSizeSt2.layout;
|
|
251
241
|
if (dispatchAnalyticsEvent) {
|
|
252
242
|
var $pos = _this.$pos;
|
|
253
243
|
var event = getMediaResizeAnalyticsEvent(nodeType || 'mediaSingle', {
|
|
254
244
|
width: width,
|
|
255
|
-
layout:
|
|
245
|
+
layout: newLayout,
|
|
256
246
|
widthType: 'pixel',
|
|
257
247
|
snapType: getGuidelineTypeFromKey(_this.lastSnappedGuidelineKeys, _this.state.guidelines),
|
|
258
248
|
parentNode: $pos ? $pos.parent.type.name : undefined
|
|
@@ -264,7 +254,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
264
254
|
_this.setIsResizing(false);
|
|
265
255
|
_this.displayGuideline([]);
|
|
266
256
|
var newWidth = width;
|
|
267
|
-
if (
|
|
257
|
+
if (newLayout === 'full-width') {
|
|
268
258
|
// When a node reaches full width in current viewport,
|
|
269
259
|
// update its width with 1800 to align with pixel entry
|
|
270
260
|
newWidth = akEditorFullWidthLayoutWidth;
|
|
@@ -276,7 +266,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
276
266
|
height: height
|
|
277
267
|
}
|
|
278
268
|
}, function () {
|
|
279
|
-
updateSize(newWidth,
|
|
269
|
+
updateSize(newWidth, newLayout);
|
|
280
270
|
});
|
|
281
271
|
});
|
|
282
272
|
var initialWidth = props.mediaSingleWidth || DEFAULT_IMAGE_WIDTH;
|
|
@@ -296,13 +286,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
296
286
|
_createClass(ResizableMediaSingleNext, [{
|
|
297
287
|
key: "componentDidUpdate",
|
|
298
288
|
value: function componentDidUpdate(prevProps) {
|
|
299
|
-
// Handle undo, when the actual pctWidth changed,
|
|
300
|
-
// we sync up with the internal state.
|
|
301
|
-
if (prevProps.pctWidth !== this.props.pctWidth) {
|
|
302
|
-
this.setState({
|
|
303
|
-
resizedPctWidth: this.props.pctWidth
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
289
|
if (prevProps.mediaSingleWidth !== this.props.mediaSingleWidth && this.props.mediaSingleWidth) {
|
|
307
290
|
// update size when lineLength becomes defined later
|
|
308
291
|
// ensures extended experience renders legacy image with the same size as the legacy experience
|
|
@@ -491,7 +474,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
491
474
|
var _this$props8 = this.props,
|
|
492
475
|
origWidth = _this$props8.width,
|
|
493
476
|
layout = _this$props8.layout,
|
|
494
|
-
pctWidth = _this$props8.pctWidth,
|
|
495
477
|
containerWidth = _this$props8.containerWidth,
|
|
496
478
|
fullWidthMode = _this$props8.fullWidthMode,
|
|
497
479
|
selected = _this$props8.selected,
|
|
@@ -513,7 +495,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
513
495
|
|
|
514
496
|
// TODO: Clean up where this lives and how it gets generated
|
|
515
497
|
var className = classnames(richMediaClassName, "image-".concat(layout), isResizing ? 'is-resizing' : 'not-resizing', this.props.className, {
|
|
516
|
-
'not-resized': !pctWidth,
|
|
517
498
|
'richMedia-selected': selected,
|
|
518
499
|
'rich-media-wrapped': layout === 'wrap-left' || layout === 'wrap-right'
|
|
519
500
|
});
|
|
@@ -526,7 +507,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
526
507
|
return jsx("div", {
|
|
527
508
|
css: wrapperStyle({
|
|
528
509
|
layout: layout,
|
|
529
|
-
isResized: !!pctWidth,
|
|
530
510
|
containerWidth: containerWidth || origWidth,
|
|
531
511
|
fullWidthMode: fullWidthMode,
|
|
532
512
|
mediaSingleWidth: this.state.size.width,
|
|
@@ -8,7 +8,6 @@ import type { Dimensions, HandleResize, HandleResizeStart, Position, Snap } from
|
|
|
8
8
|
import type { GuidelineConfig, RelativeGuides, GuidelineSnapsReference } from '@atlaskit/editor-common/guideline';
|
|
9
9
|
type State = {
|
|
10
10
|
isVideoFile: boolean;
|
|
11
|
-
resizedPctWidth?: number;
|
|
12
11
|
isResizing: boolean;
|
|
13
12
|
size: Dimensions;
|
|
14
13
|
snaps: Snap;
|
|
@@ -36,9 +35,7 @@ declare class ResizableMediaSingleNext extends React.Component<ResizableMediaSin
|
|
|
36
35
|
private getDefaultGuidelines;
|
|
37
36
|
private updateGuidelines;
|
|
38
37
|
checkVideoFile(viewMediaClientConfig?: MediaClientConfig): Promise<void>;
|
|
39
|
-
|
|
40
|
-
layout: MediaSingleLayout;
|
|
41
|
-
};
|
|
38
|
+
calcNewLayout: (newWidth: number, stop: boolean) => MediaSingleLayout;
|
|
42
39
|
calcUnwrappedLayout: (width: number, containerWidth: number, contentWidth: number, fullWidthMode?: boolean, isNestedNode?: boolean) => 'center' | 'wide' | 'full-width';
|
|
43
40
|
calcPxHeight: (newWidth: number) => number;
|
|
44
41
|
private displayGuideline;
|
|
@@ -51,9 +48,7 @@ declare class ResizableMediaSingleNext extends React.Component<ResizableMediaSin
|
|
|
51
48
|
calculateSizeState: (size: Position & Dimensions, delta: Dimensions, onResizeStop?: boolean) => {
|
|
52
49
|
width: number;
|
|
53
50
|
height: number;
|
|
54
|
-
|
|
55
|
-
layout: MediaSingleLayout;
|
|
56
|
-
};
|
|
51
|
+
layout: MediaSingleLayout;
|
|
57
52
|
};
|
|
58
53
|
selectCurrentMediaNode: () => void;
|
|
59
54
|
handleResizeStart: HandleResizeStart;
|
package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ import type { Dimensions, HandleResize, HandleResizeStart, Position, Snap } from
|
|
|
8
8
|
import type { GuidelineConfig, RelativeGuides, GuidelineSnapsReference } from '@atlaskit/editor-common/guideline';
|
|
9
9
|
type State = {
|
|
10
10
|
isVideoFile: boolean;
|
|
11
|
-
resizedPctWidth?: number;
|
|
12
11
|
isResizing: boolean;
|
|
13
12
|
size: Dimensions;
|
|
14
13
|
snaps: Snap;
|
|
@@ -36,9 +35,7 @@ declare class ResizableMediaSingleNext extends React.Component<ResizableMediaSin
|
|
|
36
35
|
private getDefaultGuidelines;
|
|
37
36
|
private updateGuidelines;
|
|
38
37
|
checkVideoFile(viewMediaClientConfig?: MediaClientConfig): Promise<void>;
|
|
39
|
-
|
|
40
|
-
layout: MediaSingleLayout;
|
|
41
|
-
};
|
|
38
|
+
calcNewLayout: (newWidth: number, stop: boolean) => MediaSingleLayout;
|
|
42
39
|
calcUnwrappedLayout: (width: number, containerWidth: number, contentWidth: number, fullWidthMode?: boolean, isNestedNode?: boolean) => 'center' | 'wide' | 'full-width';
|
|
43
40
|
calcPxHeight: (newWidth: number) => number;
|
|
44
41
|
private displayGuideline;
|
|
@@ -51,9 +48,7 @@ declare class ResizableMediaSingleNext extends React.Component<ResizableMediaSin
|
|
|
51
48
|
calculateSizeState: (size: Position & Dimensions, delta: Dimensions, onResizeStop?: boolean) => {
|
|
52
49
|
width: number;
|
|
53
50
|
height: number;
|
|
54
|
-
|
|
55
|
-
layout: MediaSingleLayout;
|
|
56
|
-
};
|
|
51
|
+
layout: MediaSingleLayout;
|
|
57
52
|
};
|
|
58
53
|
selectCurrentMediaNode: () => void;
|
|
59
54
|
handleResizeStart: HandleResizeStart;
|