@atlaskit/editor-core 187.35.0 → 187.35.1
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 +7 -0
- package/dist/cjs/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +36 -26
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +35 -26
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +37 -27
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -3
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 187.35.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`b1e03fb86a1`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b1e03fb86a1) - Update layout and width calculation for resizing
|
|
8
|
+
- [`6f85651b350`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6f85651b350) - Reduce the gap between handles when image is a nested node
|
|
9
|
+
|
|
3
10
|
## 187.35.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
|
@@ -78,7 +78,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
78
78
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "calcNewSize", function (newWidth, stop) {
|
|
79
79
|
var _this$props2 = _this.props,
|
|
80
80
|
layout = _this$props2.layout,
|
|
81
|
-
state = _this$props2.view.state,
|
|
82
81
|
containerWidth = _this$props2.containerWidth,
|
|
83
82
|
lineLength = _this$props2.lineLength,
|
|
84
83
|
fullWidthMode = _this$props2.fullWidthMode;
|
|
@@ -86,29 +85,32 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
86
85
|
_this.setState({
|
|
87
86
|
resizedPctWidth: newPct
|
|
88
87
|
});
|
|
89
|
-
var newLayout =
|
|
88
|
+
var newLayout = _this.calcUnwrappedLayout(newWidth, containerWidth, lineLength, fullWidthMode, _this.isNestedNode());
|
|
90
89
|
if (newPct <= 100) {
|
|
91
90
|
if (_this.wrappedLayout && (stop ? newPct !== 100 : true)) {
|
|
92
91
|
newLayout = layout;
|
|
93
92
|
}
|
|
94
93
|
return {
|
|
95
|
-
width: newPct,
|
|
96
94
|
layout: newLayout
|
|
97
95
|
};
|
|
98
96
|
} else {
|
|
99
97
|
return {
|
|
100
|
-
width: _this.props.pctWidth || null,
|
|
101
98
|
layout: newLayout
|
|
102
99
|
};
|
|
103
100
|
}
|
|
104
101
|
});
|
|
105
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "calcUnwrappedLayout", function (width, containerWidth, contentWidth, fullWidthMode) {
|
|
102
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "calcUnwrappedLayout", function (width, containerWidth, contentWidth, fullWidthMode, isNestedNode) {
|
|
103
|
+
if (isNestedNode) {
|
|
104
|
+
return 'center';
|
|
105
|
+
}
|
|
106
106
|
if (fullWidthMode) {
|
|
107
107
|
if (width < contentWidth) {
|
|
108
108
|
return 'center';
|
|
109
109
|
}
|
|
110
110
|
return 'full-width';
|
|
111
111
|
}
|
|
112
|
+
|
|
113
|
+
// handle top-level node in fixed-width editor
|
|
112
114
|
if (width <= contentWidth) {
|
|
113
115
|
return 'center';
|
|
114
116
|
}
|
|
@@ -154,7 +156,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
154
156
|
return dispatch(tr);
|
|
155
157
|
}, _mediaSingle.MEDIA_SINGLE_RESIZE_THROTTLE_TIME));
|
|
156
158
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "calcMaxWidth", (0, _memoizeOne.default)(function (contentWidth, containerWidth, fullWidthMode) {
|
|
157
|
-
if (fullWidthMode) {
|
|
159
|
+
if (_this.isNestedNode() || fullWidthMode) {
|
|
158
160
|
return contentWidth;
|
|
159
161
|
}
|
|
160
162
|
return (0, _mediaSingle.calcMediaSingleMaxWidth)(containerWidth);
|
|
@@ -269,14 +271,20 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
269
271
|
}
|
|
270
272
|
_this.setIsResizing(false);
|
|
271
273
|
_this.displayGuideline([]);
|
|
274
|
+
var newWidth = width;
|
|
275
|
+
if (calculatedWidthWithLayout.layout === 'full-width') {
|
|
276
|
+
// When a node reaches full width in current viewport,
|
|
277
|
+
// update its width with 1800 to align with pixel entry
|
|
278
|
+
newWidth = _editorSharedStyles.akEditorFullWidthLayoutWidth;
|
|
279
|
+
}
|
|
272
280
|
_this.setState({
|
|
273
281
|
isResizing: false,
|
|
274
282
|
size: {
|
|
275
|
-
width:
|
|
283
|
+
width: newWidth,
|
|
276
284
|
height: height
|
|
277
285
|
}
|
|
278
286
|
}, function () {
|
|
279
|
-
updateSize(
|
|
287
|
+
updateSize(newWidth, calculatedWidthWithLayout.layout);
|
|
280
288
|
});
|
|
281
289
|
});
|
|
282
290
|
var initialWidth = props.mediaSingleWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH;
|
|
@@ -298,7 +306,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
298
306
|
(0, _createClass2.default)(ResizableMediaSingleNext, [{
|
|
299
307
|
key: "componentDidUpdate",
|
|
300
308
|
value: function componentDidUpdate(prevProps) {
|
|
301
|
-
var _this2 = this;
|
|
302
309
|
var offsetLeft = (0, _mediaSingle.calculateOffsetLeft)(this.insideInlineLike, this.insideLayout, this.props.view.dom, this.wrapper);
|
|
303
310
|
if (offsetLeft !== this.state.offsetLeft && offsetLeft >= 0) {
|
|
304
311
|
this.setState({
|
|
@@ -324,18 +331,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
324
331
|
}
|
|
325
332
|
});
|
|
326
333
|
}
|
|
327
|
-
if (this.props.layout === 'full-width' && !this.isNestedNode() && prevProps.containerWidth !== this.props.containerWidth) {
|
|
328
|
-
// To achieve edge-to-edge for full-width, we need to update its width according to containerWidth
|
|
329
|
-
// Update state to allow resizer to get most up-to-date width to avoid jumping when start resizing
|
|
330
|
-
this.setState(function (prevState) {
|
|
331
|
-
return {
|
|
332
|
-
size: {
|
|
333
|
-
width: (0, _mediaSingle.calcMediaSingleMaxWidth)(_this2.props.containerWidth),
|
|
334
|
-
height: prevState.size.height
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
334
|
return true;
|
|
340
335
|
}
|
|
341
336
|
}, {
|
|
@@ -503,7 +498,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
503
498
|
}, {
|
|
504
499
|
key: "render",
|
|
505
500
|
value: function render() {
|
|
506
|
-
var
|
|
501
|
+
var _this2 = this;
|
|
507
502
|
var _this$props8 = this.props,
|
|
508
503
|
origWidth = _this$props8.width,
|
|
509
504
|
layout = _this$props8.layout,
|
|
@@ -521,7 +516,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
521
516
|
_ui.handleSides.forEach(function (side) {
|
|
522
517
|
var oppositeSide = side === 'left' ? 'right' : 'left';
|
|
523
518
|
enable[side] = _utils2.nonWrappedLayouts.concat("wrap-".concat(oppositeSide)).concat("align-".concat(_ui.imageAlignmentMap[oppositeSide])).indexOf(layout) > -1;
|
|
524
|
-
if (side === 'left' &&
|
|
519
|
+
if (side === 'left' && _this2.insideInlineLike) {
|
|
525
520
|
enable[side] = false;
|
|
526
521
|
}
|
|
527
522
|
});
|
|
@@ -533,9 +528,23 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
533
528
|
'rich-media-wrapped': layout === 'wrap-left' || layout === 'wrap-right'
|
|
534
529
|
});
|
|
535
530
|
var resizerNextClassName = (0, _classnames.default)(className, _styles.resizerStyles);
|
|
536
|
-
var maxWidth = this.isNestedNode() ?
|
|
537
|
-
|
|
531
|
+
var maxWidth = !isResizing && this.isNestedNode() ?
|
|
532
|
+
// set undefined to fall back to 100%
|
|
533
|
+
undefined : this.calcMaxWidth(lineLength, containerWidth, fullWidthMode);
|
|
538
534
|
var minWidth = this.calcMinWidth(isVideoFile, lineLength);
|
|
535
|
+
var nestedHandleStyles = function nestedHandleStyles(isNestedNode) {
|
|
536
|
+
if (!isNestedNode) {
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
return {
|
|
540
|
+
left: {
|
|
541
|
+
left: "calc(".concat("var(--ds-space-075, 0.375em)", " * -1)")
|
|
542
|
+
},
|
|
543
|
+
right: {
|
|
544
|
+
right: "calc(".concat("var(--ds-space-075, 0.375em)", " * -1)")
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
};
|
|
539
548
|
return (0, _react2.jsx)("div", {
|
|
540
549
|
ref: this.saveWrapper,
|
|
541
550
|
css: (0, _styled.wrapperStyle)({
|
|
@@ -561,7 +570,8 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
561
570
|
resizeRatio: _utils2.nonWrappedLayouts.includes(layout) ? 2 : 1,
|
|
562
571
|
handleComponent: handleComponent,
|
|
563
572
|
"data-testid": resizerNextTestId,
|
|
564
|
-
isHandleVisible: selected
|
|
573
|
+
isHandleVisible: selected,
|
|
574
|
+
handleStyles: nestedHandleStyles(this.isNestedNode())
|
|
565
575
|
}, children));
|
|
566
576
|
}
|
|
567
577
|
}]);
|
|
@@ -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.35.
|
|
9
|
+
var version = "187.35.1";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { jsx } from '@emotion/react';
|
|
5
|
-
import { findParentNodeOfTypeClosestToPos
|
|
5
|
+
import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
6
6
|
import { getMediaClient } from '@atlaskit/media-client';
|
|
7
7
|
import { calcPctFromPx, wrappedLayouts, handleSides, imageAlignmentMap } from '@atlaskit/editor-common/ui';
|
|
8
8
|
import { nonWrappedLayouts, setNodeSelection } from '@atlaskit/editor-common/utils';
|
|
@@ -58,9 +58,6 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
58
58
|
_defineProperty(this, "calcNewSize", (newWidth, stop) => {
|
|
59
59
|
const {
|
|
60
60
|
layout,
|
|
61
|
-
view: {
|
|
62
|
-
state
|
|
63
|
-
},
|
|
64
61
|
containerWidth,
|
|
65
62
|
lineLength,
|
|
66
63
|
fullWidthMode
|
|
@@ -69,29 +66,32 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
69
66
|
this.setState({
|
|
70
67
|
resizedPctWidth: newPct
|
|
71
68
|
});
|
|
72
|
-
let newLayout =
|
|
69
|
+
let newLayout = this.calcUnwrappedLayout(newWidth, containerWidth, lineLength, fullWidthMode, this.isNestedNode());
|
|
73
70
|
if (newPct <= 100) {
|
|
74
71
|
if (this.wrappedLayout && (stop ? newPct !== 100 : true)) {
|
|
75
72
|
newLayout = layout;
|
|
76
73
|
}
|
|
77
74
|
return {
|
|
78
|
-
width: newPct,
|
|
79
75
|
layout: newLayout
|
|
80
76
|
};
|
|
81
77
|
} else {
|
|
82
78
|
return {
|
|
83
|
-
width: this.props.pctWidth || null,
|
|
84
79
|
layout: newLayout
|
|
85
80
|
};
|
|
86
81
|
}
|
|
87
82
|
});
|
|
88
|
-
_defineProperty(this, "calcUnwrappedLayout", (width, containerWidth, contentWidth, fullWidthMode) => {
|
|
83
|
+
_defineProperty(this, "calcUnwrappedLayout", (width, containerWidth, contentWidth, fullWidthMode, isNestedNode) => {
|
|
84
|
+
if (isNestedNode) {
|
|
85
|
+
return 'center';
|
|
86
|
+
}
|
|
89
87
|
if (fullWidthMode) {
|
|
90
88
|
if (width < contentWidth) {
|
|
91
89
|
return 'center';
|
|
92
90
|
}
|
|
93
91
|
return 'full-width';
|
|
94
92
|
}
|
|
93
|
+
|
|
94
|
+
// handle top-level node in fixed-width editor
|
|
95
95
|
if (width <= contentWidth) {
|
|
96
96
|
return 'center';
|
|
97
97
|
}
|
|
@@ -137,7 +137,7 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
137
137
|
return dispatch(tr);
|
|
138
138
|
}, MEDIA_SINGLE_RESIZE_THROTTLE_TIME));
|
|
139
139
|
_defineProperty(this, "calcMaxWidth", memoizeOne((contentWidth, containerWidth, fullWidthMode) => {
|
|
140
|
-
if (fullWidthMode) {
|
|
140
|
+
if (this.isNestedNode() || fullWidthMode) {
|
|
141
141
|
return contentWidth;
|
|
142
142
|
}
|
|
143
143
|
return calcMediaSingleMaxWidth(containerWidth);
|
|
@@ -252,14 +252,20 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
252
252
|
}
|
|
253
253
|
this.setIsResizing(false);
|
|
254
254
|
this.displayGuideline([]);
|
|
255
|
+
let newWidth = width;
|
|
256
|
+
if (calculatedWidthWithLayout.layout === 'full-width') {
|
|
257
|
+
// When a node reaches full width in current viewport,
|
|
258
|
+
// update its width with 1800 to align with pixel entry
|
|
259
|
+
newWidth = akEditorFullWidthLayoutWidth;
|
|
260
|
+
}
|
|
255
261
|
this.setState({
|
|
256
262
|
isResizing: false,
|
|
257
263
|
size: {
|
|
258
|
-
width,
|
|
264
|
+
width: newWidth,
|
|
259
265
|
height
|
|
260
266
|
}
|
|
261
267
|
}, () => {
|
|
262
|
-
updateSize(
|
|
268
|
+
updateSize(newWidth, calculatedWidthWithLayout.layout);
|
|
263
269
|
});
|
|
264
270
|
});
|
|
265
271
|
const initialWidth = props.mediaSingleWidth || DEFAULT_IMAGE_WIDTH;
|
|
@@ -303,18 +309,6 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
303
309
|
}
|
|
304
310
|
});
|
|
305
311
|
}
|
|
306
|
-
if (this.props.layout === 'full-width' && !this.isNestedNode() && prevProps.containerWidth !== this.props.containerWidth) {
|
|
307
|
-
// To achieve edge-to-edge for full-width, we need to update its width according to containerWidth
|
|
308
|
-
// Update state to allow resizer to get most up-to-date width to avoid jumping when start resizing
|
|
309
|
-
this.setState(prevState => {
|
|
310
|
-
return {
|
|
311
|
-
size: {
|
|
312
|
-
width: calcMediaSingleMaxWidth(this.props.containerWidth),
|
|
313
|
-
height: prevState.size.height
|
|
314
|
-
}
|
|
315
|
-
};
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
312
|
return true;
|
|
319
313
|
}
|
|
320
314
|
async componentDidMount() {
|
|
@@ -452,9 +446,23 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
452
446
|
'rich-media-wrapped': layout === 'wrap-left' || layout === 'wrap-right'
|
|
453
447
|
});
|
|
454
448
|
const resizerNextClassName = classnames(className, resizerStyles);
|
|
455
|
-
const maxWidth = this.isNestedNode() ?
|
|
456
|
-
|
|
449
|
+
const maxWidth = !isResizing && this.isNestedNode() ?
|
|
450
|
+
// set undefined to fall back to 100%
|
|
451
|
+
undefined : this.calcMaxWidth(lineLength, containerWidth, fullWidthMode);
|
|
457
452
|
const minWidth = this.calcMinWidth(isVideoFile, lineLength);
|
|
453
|
+
const nestedHandleStyles = isNestedNode => {
|
|
454
|
+
if (!isNestedNode) {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
return {
|
|
458
|
+
left: {
|
|
459
|
+
left: `calc(${"var(--ds-space-075, 0.375em)"} * -1)`
|
|
460
|
+
},
|
|
461
|
+
right: {
|
|
462
|
+
right: `calc(${"var(--ds-space-075, 0.375em)"} * -1)`
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
};
|
|
458
466
|
return jsx("div", {
|
|
459
467
|
ref: this.saveWrapper,
|
|
460
468
|
css: wrapperStyle({
|
|
@@ -480,7 +488,8 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
480
488
|
resizeRatio: nonWrappedLayouts.includes(layout) ? 2 : 1,
|
|
481
489
|
handleComponent: handleComponent,
|
|
482
490
|
"data-testid": resizerNextTestId,
|
|
483
|
-
isHandleVisible: selected
|
|
491
|
+
isHandleVisible: selected,
|
|
492
|
+
handleStyles: nestedHandleStyles(this.isNestedNode())
|
|
484
493
|
}, children));
|
|
485
494
|
}
|
|
486
495
|
}
|
|
@@ -13,7 +13,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
13
13
|
/** @jsx jsx */
|
|
14
14
|
import React from 'react';
|
|
15
15
|
import { jsx } from '@emotion/react';
|
|
16
|
-
import { findParentNodeOfTypeClosestToPos
|
|
16
|
+
import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
17
17
|
import { getMediaClient } from '@atlaskit/media-client';
|
|
18
18
|
import { calcPctFromPx, wrappedLayouts, handleSides, imageAlignmentMap } from '@atlaskit/editor-common/ui';
|
|
19
19
|
import { nonWrappedLayouts, setNodeSelection } from '@atlaskit/editor-common/utils';
|
|
@@ -71,7 +71,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
71
71
|
_defineProperty(_assertThisInitialized(_this), "calcNewSize", function (newWidth, stop) {
|
|
72
72
|
var _this$props2 = _this.props,
|
|
73
73
|
layout = _this$props2.layout,
|
|
74
|
-
state = _this$props2.view.state,
|
|
75
74
|
containerWidth = _this$props2.containerWidth,
|
|
76
75
|
lineLength = _this$props2.lineLength,
|
|
77
76
|
fullWidthMode = _this$props2.fullWidthMode;
|
|
@@ -79,29 +78,32 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
79
78
|
_this.setState({
|
|
80
79
|
resizedPctWidth: newPct
|
|
81
80
|
});
|
|
82
|
-
var newLayout =
|
|
81
|
+
var newLayout = _this.calcUnwrappedLayout(newWidth, containerWidth, lineLength, fullWidthMode, _this.isNestedNode());
|
|
83
82
|
if (newPct <= 100) {
|
|
84
83
|
if (_this.wrappedLayout && (stop ? newPct !== 100 : true)) {
|
|
85
84
|
newLayout = layout;
|
|
86
85
|
}
|
|
87
86
|
return {
|
|
88
|
-
width: newPct,
|
|
89
87
|
layout: newLayout
|
|
90
88
|
};
|
|
91
89
|
} else {
|
|
92
90
|
return {
|
|
93
|
-
width: _this.props.pctWidth || null,
|
|
94
91
|
layout: newLayout
|
|
95
92
|
};
|
|
96
93
|
}
|
|
97
94
|
});
|
|
98
|
-
_defineProperty(_assertThisInitialized(_this), "calcUnwrappedLayout", function (width, containerWidth, contentWidth, fullWidthMode) {
|
|
95
|
+
_defineProperty(_assertThisInitialized(_this), "calcUnwrappedLayout", function (width, containerWidth, contentWidth, fullWidthMode, isNestedNode) {
|
|
96
|
+
if (isNestedNode) {
|
|
97
|
+
return 'center';
|
|
98
|
+
}
|
|
99
99
|
if (fullWidthMode) {
|
|
100
100
|
if (width < contentWidth) {
|
|
101
101
|
return 'center';
|
|
102
102
|
}
|
|
103
103
|
return 'full-width';
|
|
104
104
|
}
|
|
105
|
+
|
|
106
|
+
// handle top-level node in fixed-width editor
|
|
105
107
|
if (width <= contentWidth) {
|
|
106
108
|
return 'center';
|
|
107
109
|
}
|
|
@@ -147,7 +149,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
147
149
|
return dispatch(tr);
|
|
148
150
|
}, MEDIA_SINGLE_RESIZE_THROTTLE_TIME));
|
|
149
151
|
_defineProperty(_assertThisInitialized(_this), "calcMaxWidth", memoizeOne(function (contentWidth, containerWidth, fullWidthMode) {
|
|
150
|
-
if (fullWidthMode) {
|
|
152
|
+
if (_this.isNestedNode() || fullWidthMode) {
|
|
151
153
|
return contentWidth;
|
|
152
154
|
}
|
|
153
155
|
return calcMediaSingleMaxWidth(containerWidth);
|
|
@@ -262,14 +264,20 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
262
264
|
}
|
|
263
265
|
_this.setIsResizing(false);
|
|
264
266
|
_this.displayGuideline([]);
|
|
267
|
+
var newWidth = width;
|
|
268
|
+
if (calculatedWidthWithLayout.layout === 'full-width') {
|
|
269
|
+
// When a node reaches full width in current viewport,
|
|
270
|
+
// update its width with 1800 to align with pixel entry
|
|
271
|
+
newWidth = akEditorFullWidthLayoutWidth;
|
|
272
|
+
}
|
|
265
273
|
_this.setState({
|
|
266
274
|
isResizing: false,
|
|
267
275
|
size: {
|
|
268
|
-
width:
|
|
276
|
+
width: newWidth,
|
|
269
277
|
height: height
|
|
270
278
|
}
|
|
271
279
|
}, function () {
|
|
272
|
-
updateSize(
|
|
280
|
+
updateSize(newWidth, calculatedWidthWithLayout.layout);
|
|
273
281
|
});
|
|
274
282
|
});
|
|
275
283
|
var initialWidth = props.mediaSingleWidth || DEFAULT_IMAGE_WIDTH;
|
|
@@ -291,7 +299,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
291
299
|
_createClass(ResizableMediaSingleNext, [{
|
|
292
300
|
key: "componentDidUpdate",
|
|
293
301
|
value: function componentDidUpdate(prevProps) {
|
|
294
|
-
var _this2 = this;
|
|
295
302
|
var offsetLeft = calculateOffsetLeft(this.insideInlineLike, this.insideLayout, this.props.view.dom, this.wrapper);
|
|
296
303
|
if (offsetLeft !== this.state.offsetLeft && offsetLeft >= 0) {
|
|
297
304
|
this.setState({
|
|
@@ -317,18 +324,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
317
324
|
}
|
|
318
325
|
});
|
|
319
326
|
}
|
|
320
|
-
if (this.props.layout === 'full-width' && !this.isNestedNode() && prevProps.containerWidth !== this.props.containerWidth) {
|
|
321
|
-
// To achieve edge-to-edge for full-width, we need to update its width according to containerWidth
|
|
322
|
-
// Update state to allow resizer to get most up-to-date width to avoid jumping when start resizing
|
|
323
|
-
this.setState(function (prevState) {
|
|
324
|
-
return {
|
|
325
|
-
size: {
|
|
326
|
-
width: calcMediaSingleMaxWidth(_this2.props.containerWidth),
|
|
327
|
-
height: prevState.size.height
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
327
|
return true;
|
|
333
328
|
}
|
|
334
329
|
}, {
|
|
@@ -496,7 +491,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
496
491
|
}, {
|
|
497
492
|
key: "render",
|
|
498
493
|
value: function render() {
|
|
499
|
-
var
|
|
494
|
+
var _this2 = this;
|
|
500
495
|
var _this$props8 = this.props,
|
|
501
496
|
origWidth = _this$props8.width,
|
|
502
497
|
layout = _this$props8.layout,
|
|
@@ -514,7 +509,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
514
509
|
handleSides.forEach(function (side) {
|
|
515
510
|
var oppositeSide = side === 'left' ? 'right' : 'left';
|
|
516
511
|
enable[side] = nonWrappedLayouts.concat("wrap-".concat(oppositeSide)).concat("align-".concat(imageAlignmentMap[oppositeSide])).indexOf(layout) > -1;
|
|
517
|
-
if (side === 'left' &&
|
|
512
|
+
if (side === 'left' && _this2.insideInlineLike) {
|
|
518
513
|
enable[side] = false;
|
|
519
514
|
}
|
|
520
515
|
});
|
|
@@ -526,9 +521,23 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
526
521
|
'rich-media-wrapped': layout === 'wrap-left' || layout === 'wrap-right'
|
|
527
522
|
});
|
|
528
523
|
var resizerNextClassName = classnames(className, resizerStyles);
|
|
529
|
-
var maxWidth = this.isNestedNode() ?
|
|
530
|
-
|
|
524
|
+
var maxWidth = !isResizing && this.isNestedNode() ?
|
|
525
|
+
// set undefined to fall back to 100%
|
|
526
|
+
undefined : this.calcMaxWidth(lineLength, containerWidth, fullWidthMode);
|
|
531
527
|
var minWidth = this.calcMinWidth(isVideoFile, lineLength);
|
|
528
|
+
var nestedHandleStyles = function nestedHandleStyles(isNestedNode) {
|
|
529
|
+
if (!isNestedNode) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
return {
|
|
533
|
+
left: {
|
|
534
|
+
left: "calc(".concat("var(--ds-space-075, 0.375em)", " * -1)")
|
|
535
|
+
},
|
|
536
|
+
right: {
|
|
537
|
+
right: "calc(".concat("var(--ds-space-075, 0.375em)", " * -1)")
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
};
|
|
532
541
|
return jsx("div", {
|
|
533
542
|
ref: this.saveWrapper,
|
|
534
543
|
css: wrapperStyle({
|
|
@@ -554,7 +563,8 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
554
563
|
resizeRatio: nonWrappedLayouts.includes(layout) ? 2 : 1,
|
|
555
564
|
handleComponent: handleComponent,
|
|
556
565
|
"data-testid": resizerNextTestId,
|
|
557
|
-
isHandleVisible: selected
|
|
566
|
+
isHandleVisible: selected,
|
|
567
|
+
handleStyles: nestedHandleStyles(this.isNestedNode())
|
|
558
568
|
}, children));
|
|
559
569
|
}
|
|
560
570
|
}]);
|
|
@@ -36,10 +36,9 @@ declare class ResizableMediaSingleNext extends React.Component<ResizableMediaSin
|
|
|
36
36
|
private updateGuidelines;
|
|
37
37
|
checkVideoFile(viewMediaClientConfig?: MediaClientConfig): Promise<void>;
|
|
38
38
|
calcNewSize: (newWidth: number, stop: boolean) => {
|
|
39
|
-
width: number | null;
|
|
40
39
|
layout: MediaSingleLayout;
|
|
41
40
|
};
|
|
42
|
-
calcUnwrappedLayout: (width: number, containerWidth: number, contentWidth: number, fullWidthMode?: boolean) => 'center' | 'wide' | 'full-width';
|
|
41
|
+
calcUnwrappedLayout: (width: number, containerWidth: number, contentWidth: number, fullWidthMode?: boolean, isNestedNode?: boolean) => 'center' | 'wide' | 'full-width';
|
|
43
42
|
calcPxHeight: (newWidth: number) => number;
|
|
44
43
|
private saveWrapper;
|
|
45
44
|
private displayGuideline;
|
|
@@ -53,7 +52,6 @@ declare class ResizableMediaSingleNext extends React.Component<ResizableMediaSin
|
|
|
53
52
|
width: number;
|
|
54
53
|
height: number;
|
|
55
54
|
calculatedWidthWithLayout: {
|
|
56
|
-
width: number | null;
|
|
57
55
|
layout: MediaSingleLayout;
|
|
58
56
|
};
|
|
59
57
|
};
|
package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts
CHANGED
|
@@ -36,10 +36,9 @@ declare class ResizableMediaSingleNext extends React.Component<ResizableMediaSin
|
|
|
36
36
|
private updateGuidelines;
|
|
37
37
|
checkVideoFile(viewMediaClientConfig?: MediaClientConfig): Promise<void>;
|
|
38
38
|
calcNewSize: (newWidth: number, stop: boolean) => {
|
|
39
|
-
width: number | null;
|
|
40
39
|
layout: MediaSingleLayout;
|
|
41
40
|
};
|
|
42
|
-
calcUnwrappedLayout: (width: number, containerWidth: number, contentWidth: number, fullWidthMode?: boolean) => 'center' | 'wide' | 'full-width';
|
|
41
|
+
calcUnwrappedLayout: (width: number, containerWidth: number, contentWidth: number, fullWidthMode?: boolean, isNestedNode?: boolean) => 'center' | 'wide' | 'full-width';
|
|
43
42
|
calcPxHeight: (newWidth: number) => number;
|
|
44
43
|
private saveWrapper;
|
|
45
44
|
private displayGuideline;
|
|
@@ -53,7 +52,6 @@ declare class ResizableMediaSingleNext extends React.Component<ResizableMediaSin
|
|
|
53
52
|
width: number;
|
|
54
53
|
height: number;
|
|
55
54
|
calculatedWidthWithLayout: {
|
|
56
|
-
width: number | null;
|
|
57
55
|
layout: MediaSingleLayout;
|
|
58
56
|
};
|
|
59
57
|
};
|