@atlaskit/editor-core 187.32.1 → 187.32.2
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/toolbar/index.js +2 -9
- package/dist/cjs/plugins/media/ui/PixelEntry/index.js +14 -25
- package/dist/cjs/plugins/media/utils/media-single.js +1 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/media/toolbar/index.js +2 -9
- package/dist/es2019/plugins/media/ui/PixelEntry/index.js +14 -25
- package/dist/es2019/plugins/media/utils/media-single.js +2 -2
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/media/toolbar/index.js +2 -9
- package/dist/esm/plugins/media/ui/PixelEntry/index.js +14 -25
- package/dist/esm/plugins/media/utils/media-single.js +2 -2
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/media/ui/PixelEntry/index.d.ts +1 -1
- package/dist/types/plugins/media/ui/PixelEntry/types.d.ts +7 -2
- package/dist/types-ts4.5/plugins/media/ui/PixelEntry/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/ui/PixelEntry/types.d.ts +7 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 187.32.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`eab48233583`](https://bitbucket.org/atlassian/atlassian-frontend/commits/eab48233583) - Calculate parent content width properly when inserting a nested media single node
|
|
8
|
+
|
|
3
9
|
## 187.32.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -304,19 +304,12 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
304
304
|
mediaHeight: mediaHeight || _mediaSingle2.DEFAULT_IMAGE_HEIGHT,
|
|
305
305
|
minWidth: minWidth,
|
|
306
306
|
maxWidth: maxWidth,
|
|
307
|
-
|
|
308
|
-
if (
|
|
307
|
+
onChange: function onChange(valid) {
|
|
308
|
+
if (valid) {
|
|
309
309
|
hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true, 'warning')(editorView.state, dispatch, editorView);
|
|
310
310
|
} else {
|
|
311
|
-
// remove decoration when:
|
|
312
|
-
// input is within min-max range or
|
|
313
|
-
// input is empty
|
|
314
311
|
hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false)(editorView.state, dispatch, editorView);
|
|
315
312
|
}
|
|
316
|
-
if (value === '') {
|
|
317
|
-
return false;
|
|
318
|
-
}
|
|
319
|
-
return true;
|
|
320
313
|
},
|
|
321
314
|
onSubmit: function onSubmit(_ref2) {
|
|
322
315
|
var width = _ref2.width;
|
|
@@ -26,9 +26,9 @@ var PixelEntry = function PixelEntry(_ref) {
|
|
|
26
26
|
mediaWidth = _ref.mediaWidth,
|
|
27
27
|
mediaHeight = _ref.mediaHeight,
|
|
28
28
|
onSubmit = _ref.onSubmit,
|
|
29
|
-
validate = _ref.validate,
|
|
30
29
|
minWidth = _ref.minWidth,
|
|
31
30
|
maxWidth = _ref.maxWidth,
|
|
31
|
+
onChange = _ref.onChange,
|
|
32
32
|
formatMessage = _ref.intl.formatMessage,
|
|
33
33
|
showMigration = _ref.showMigration,
|
|
34
34
|
onMigrate = _ref.onMigrate;
|
|
@@ -55,6 +55,9 @@ var PixelEntry = function PixelEntry(_ref) {
|
|
|
55
55
|
|
|
56
56
|
// Handle submit when user presses enter in form
|
|
57
57
|
var handleOnSubmit = function handleOnSubmit(data) {
|
|
58
|
+
if (data.inputWidth === '' || data.inputHeight === '') {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
58
61
|
if (onSubmit) {
|
|
59
62
|
var widthToBeSumitted = data.inputWidth;
|
|
60
63
|
var isInvalidInput = false;
|
|
@@ -80,46 +83,33 @@ var PixelEntry = function PixelEntry(_ref) {
|
|
|
80
83
|
}
|
|
81
84
|
};
|
|
82
85
|
|
|
83
|
-
// Syncronous validation returning undefined for valid and string for invalid
|
|
84
|
-
var handleValidateWidth = (0, _react2.useCallback)(function (value) {
|
|
85
|
-
if (!validate || value === undefined) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
if (validate) {
|
|
89
|
-
return validate(value) === true ? undefined : formatMessage(_messages.messages.validationFailedMessage);
|
|
90
|
-
}
|
|
91
|
-
return;
|
|
92
|
-
}, [validate, formatMessage]);
|
|
93
|
-
|
|
94
86
|
// Handle updating computed fields based on
|
|
95
87
|
var handleOnChange = (0, _react2.useCallback)(function (type) {
|
|
96
88
|
return function (event) {
|
|
97
89
|
var value = parseInt(event.currentTarget.value);
|
|
98
|
-
var newInputValue = isNaN(value) ? '' :
|
|
90
|
+
var newInputValue = isNaN(value) ? '' : value;
|
|
91
|
+
var newWidth = '';
|
|
99
92
|
switch (type) {
|
|
100
93
|
case 'inputWidth':
|
|
101
94
|
{
|
|
95
|
+
newWidth = newInputValue;
|
|
102
96
|
setComputedWidth(newInputValue);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
} else {
|
|
106
|
-
setComputedHeight('');
|
|
107
|
-
}
|
|
97
|
+
var newHeight = newInputValue !== '' ? Math.round(ratioWidth * newInputValue) : '';
|
|
98
|
+
setComputedHeight(newHeight);
|
|
108
99
|
break;
|
|
109
100
|
}
|
|
110
101
|
case 'inputHeight':
|
|
111
102
|
{
|
|
112
103
|
setComputedHeight(newInputValue);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
} else {
|
|
116
|
-
setComputedWidth('');
|
|
117
|
-
}
|
|
104
|
+
newWidth = newInputValue !== '' ? Math.round(ratioHeight * newInputValue) : '';
|
|
105
|
+
setComputedWidth(newWidth);
|
|
118
106
|
break;
|
|
119
107
|
}
|
|
120
108
|
}
|
|
109
|
+
var isInvalidInputValid = newWidth !== '' && (newWidth < minWidth || newWidth > maxWidth);
|
|
110
|
+
onChange && onChange(isInvalidInputValid);
|
|
121
111
|
};
|
|
122
|
-
}, [
|
|
112
|
+
}, [minWidth, maxWidth, onChange, ratioWidth, ratioHeight]);
|
|
123
113
|
if (showMigration) {
|
|
124
114
|
return (0, _react.jsx)(_tooltip.default, {
|
|
125
115
|
content: formatMessage(_messages.messages.migrationButtonTooltip)
|
|
@@ -141,7 +131,6 @@ var PixelEntry = function PixelEntry(_ref) {
|
|
|
141
131
|
}, (0, _react.jsx)(_form.Field, {
|
|
142
132
|
key: "inputWidth",
|
|
143
133
|
name: "inputWidth",
|
|
144
|
-
validate: handleValidateWidth,
|
|
145
134
|
defaultValue: computedWidth
|
|
146
135
|
}, function (_ref3) {
|
|
147
136
|
var fieldProps = _ref3.fieldProps;
|
|
@@ -103,7 +103,7 @@ var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inp
|
|
|
103
103
|
|
|
104
104
|
// add undefined as fallback as we don't want media single width to have upper limit as 0
|
|
105
105
|
// if widthPluginState.width is 0, default 760 will be used
|
|
106
|
-
var contentWidth = (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.lineLength) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.width) || undefined;
|
|
106
|
+
var contentWidth = (0, _mediaSingle.getMaxWidthForNestedNodeNext)(view, state.selection.$from.pos, true) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.lineLength) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.width) || undefined;
|
|
107
107
|
var node = createMediaSingleNode(state.schema, collection, contentWidth, mediaState.status !== 'error' && isVideo(mediaState.fileMimeType) ? _mediaSingle.MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH : _mediaSingle.MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, alignLeftOnInsert)(mediaState);
|
|
108
108
|
var fileExtension;
|
|
109
109
|
if (mediaState.fileName) {
|
|
@@ -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.32.
|
|
9
|
+
var version = "187.32.2";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
@@ -310,19 +310,12 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
310
310
|
mediaHeight: mediaHeight || DEFAULT_IMAGE_HEIGHT,
|
|
311
311
|
minWidth: minWidth,
|
|
312
312
|
maxWidth: maxWidth,
|
|
313
|
-
|
|
314
|
-
if (
|
|
313
|
+
onChange: valid => {
|
|
314
|
+
if (valid) {
|
|
315
315
|
hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true, 'warning')(editorView.state, dispatch, editorView);
|
|
316
316
|
} else {
|
|
317
|
-
// remove decoration when:
|
|
318
|
-
// input is within min-max range or
|
|
319
|
-
// input is empty
|
|
320
317
|
hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false)(editorView.state, dispatch, editorView);
|
|
321
318
|
}
|
|
322
|
-
if (value === '') {
|
|
323
|
-
return false;
|
|
324
|
-
}
|
|
325
|
-
return true;
|
|
326
319
|
},
|
|
327
320
|
onSubmit: ({
|
|
328
321
|
width
|
|
@@ -14,9 +14,9 @@ export const PixelEntry = ({
|
|
|
14
14
|
mediaWidth,
|
|
15
15
|
mediaHeight,
|
|
16
16
|
onSubmit,
|
|
17
|
-
validate,
|
|
18
17
|
minWidth,
|
|
19
18
|
maxWidth,
|
|
19
|
+
onChange,
|
|
20
20
|
intl: {
|
|
21
21
|
formatMessage
|
|
22
22
|
},
|
|
@@ -40,6 +40,9 @@ export const PixelEntry = ({
|
|
|
40
40
|
|
|
41
41
|
// Handle submit when user presses enter in form
|
|
42
42
|
const handleOnSubmit = data => {
|
|
43
|
+
if (data.inputWidth === '' || data.inputHeight === '') {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
43
46
|
if (onSubmit) {
|
|
44
47
|
let widthToBeSumitted = data.inputWidth;
|
|
45
48
|
let isInvalidInput = false;
|
|
@@ -65,44 +68,31 @@ export const PixelEntry = ({
|
|
|
65
68
|
}
|
|
66
69
|
};
|
|
67
70
|
|
|
68
|
-
// Syncronous validation returning undefined for valid and string for invalid
|
|
69
|
-
const handleValidateWidth = useCallback(value => {
|
|
70
|
-
if (!validate || value === undefined) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
if (validate) {
|
|
74
|
-
return validate(value) === true ? undefined : formatMessage(messages.validationFailedMessage);
|
|
75
|
-
}
|
|
76
|
-
return;
|
|
77
|
-
}, [validate, formatMessage]);
|
|
78
|
-
|
|
79
71
|
// Handle updating computed fields based on
|
|
80
72
|
const handleOnChange = useCallback(type => event => {
|
|
81
73
|
const value = parseInt(event.currentTarget.value);
|
|
82
|
-
const newInputValue = isNaN(value) ? '' :
|
|
74
|
+
const newInputValue = isNaN(value) ? '' : value;
|
|
75
|
+
let newWidth = '';
|
|
83
76
|
switch (type) {
|
|
84
77
|
case 'inputWidth':
|
|
85
78
|
{
|
|
79
|
+
newWidth = newInputValue;
|
|
86
80
|
setComputedWidth(newInputValue);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
} else {
|
|
90
|
-
setComputedHeight('');
|
|
91
|
-
}
|
|
81
|
+
const newHeight = newInputValue !== '' ? Math.round(ratioWidth * newInputValue) : '';
|
|
82
|
+
setComputedHeight(newHeight);
|
|
92
83
|
break;
|
|
93
84
|
}
|
|
94
85
|
case 'inputHeight':
|
|
95
86
|
{
|
|
96
87
|
setComputedHeight(newInputValue);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
} else {
|
|
100
|
-
setComputedWidth('');
|
|
101
|
-
}
|
|
88
|
+
newWidth = newInputValue !== '' ? Math.round(ratioHeight * newInputValue) : '';
|
|
89
|
+
setComputedWidth(newWidth);
|
|
102
90
|
break;
|
|
103
91
|
}
|
|
104
92
|
}
|
|
105
|
-
|
|
93
|
+
const isInvalidInputValid = newWidth !== '' && (newWidth < minWidth || newWidth > maxWidth);
|
|
94
|
+
onChange && onChange(isInvalidInputValid);
|
|
95
|
+
}, [minWidth, maxWidth, onChange, ratioWidth, ratioHeight]);
|
|
106
96
|
if (showMigration) {
|
|
107
97
|
return jsx(Tooltip, {
|
|
108
98
|
content: formatMessage(messages.migrationButtonTooltip)
|
|
@@ -125,7 +115,6 @@ export const PixelEntry = ({
|
|
|
125
115
|
}, jsx(Field, {
|
|
126
116
|
key: "inputWidth",
|
|
127
117
|
name: "inputWidth",
|
|
128
|
-
validate: handleValidateWidth,
|
|
129
118
|
defaultValue: computedWidth
|
|
130
119
|
}, ({
|
|
131
120
|
fieldProps
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { safeInsert as pmSafeInsert, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
3
3
|
import { checkNodeDown } from '../../../utils';
|
|
4
|
-
import { getMediaSingleInitialWidth, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
4
|
+
import { getMediaSingleInitialWidth, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH, getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
|
|
5
5
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
|
|
7
7
|
import { mapSlice } from '../../../utils/slice';
|
|
@@ -93,7 +93,7 @@ export const insertMediaSingleNode = (view, mediaState, inputMethod, collection,
|
|
|
93
93
|
|
|
94
94
|
// add undefined as fallback as we don't want media single width to have upper limit as 0
|
|
95
95
|
// if widthPluginState.width is 0, default 760 will be used
|
|
96
|
-
const contentWidth = (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.lineLength) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.width) || undefined;
|
|
96
|
+
const contentWidth = getMaxWidthForNestedNodeNext(view, state.selection.$from.pos, true) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.lineLength) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.width) || undefined;
|
|
97
97
|
const node = createMediaSingleNode(state.schema, collection, contentWidth, mediaState.status !== 'error' && isVideo(mediaState.fileMimeType) ? MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH : MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, alignLeftOnInsert)(mediaState);
|
|
98
98
|
let fileExtension;
|
|
99
99
|
if (mediaState.fileName) {
|
|
@@ -297,19 +297,12 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
297
297
|
mediaHeight: mediaHeight || DEFAULT_IMAGE_HEIGHT,
|
|
298
298
|
minWidth: minWidth,
|
|
299
299
|
maxWidth: maxWidth,
|
|
300
|
-
|
|
301
|
-
if (
|
|
300
|
+
onChange: function onChange(valid) {
|
|
301
|
+
if (valid) {
|
|
302
302
|
hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true, 'warning')(editorView.state, dispatch, editorView);
|
|
303
303
|
} else {
|
|
304
|
-
// remove decoration when:
|
|
305
|
-
// input is within min-max range or
|
|
306
|
-
// input is empty
|
|
307
304
|
hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false)(editorView.state, dispatch, editorView);
|
|
308
305
|
}
|
|
309
|
-
if (value === '') {
|
|
310
|
-
return false;
|
|
311
|
-
}
|
|
312
|
-
return true;
|
|
313
306
|
},
|
|
314
307
|
onSubmit: function onSubmit(_ref2) {
|
|
315
308
|
var width = _ref2.width;
|
|
@@ -15,9 +15,9 @@ export var PixelEntry = function PixelEntry(_ref) {
|
|
|
15
15
|
mediaWidth = _ref.mediaWidth,
|
|
16
16
|
mediaHeight = _ref.mediaHeight,
|
|
17
17
|
onSubmit = _ref.onSubmit,
|
|
18
|
-
validate = _ref.validate,
|
|
19
18
|
minWidth = _ref.minWidth,
|
|
20
19
|
maxWidth = _ref.maxWidth,
|
|
20
|
+
onChange = _ref.onChange,
|
|
21
21
|
formatMessage = _ref.intl.formatMessage,
|
|
22
22
|
showMigration = _ref.showMigration,
|
|
23
23
|
onMigrate = _ref.onMigrate;
|
|
@@ -44,6 +44,9 @@ export var PixelEntry = function PixelEntry(_ref) {
|
|
|
44
44
|
|
|
45
45
|
// Handle submit when user presses enter in form
|
|
46
46
|
var handleOnSubmit = function handleOnSubmit(data) {
|
|
47
|
+
if (data.inputWidth === '' || data.inputHeight === '') {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
47
50
|
if (onSubmit) {
|
|
48
51
|
var widthToBeSumitted = data.inputWidth;
|
|
49
52
|
var isInvalidInput = false;
|
|
@@ -69,46 +72,33 @@ export var PixelEntry = function PixelEntry(_ref) {
|
|
|
69
72
|
}
|
|
70
73
|
};
|
|
71
74
|
|
|
72
|
-
// Syncronous validation returning undefined for valid and string for invalid
|
|
73
|
-
var handleValidateWidth = useCallback(function (value) {
|
|
74
|
-
if (!validate || value === undefined) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (validate) {
|
|
78
|
-
return validate(value) === true ? undefined : formatMessage(messages.validationFailedMessage);
|
|
79
|
-
}
|
|
80
|
-
return;
|
|
81
|
-
}, [validate, formatMessage]);
|
|
82
|
-
|
|
83
75
|
// Handle updating computed fields based on
|
|
84
76
|
var handleOnChange = useCallback(function (type) {
|
|
85
77
|
return function (event) {
|
|
86
78
|
var value = parseInt(event.currentTarget.value);
|
|
87
|
-
var newInputValue = isNaN(value) ? '' :
|
|
79
|
+
var newInputValue = isNaN(value) ? '' : value;
|
|
80
|
+
var newWidth = '';
|
|
88
81
|
switch (type) {
|
|
89
82
|
case 'inputWidth':
|
|
90
83
|
{
|
|
84
|
+
newWidth = newInputValue;
|
|
91
85
|
setComputedWidth(newInputValue);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
} else {
|
|
95
|
-
setComputedHeight('');
|
|
96
|
-
}
|
|
86
|
+
var newHeight = newInputValue !== '' ? Math.round(ratioWidth * newInputValue) : '';
|
|
87
|
+
setComputedHeight(newHeight);
|
|
97
88
|
break;
|
|
98
89
|
}
|
|
99
90
|
case 'inputHeight':
|
|
100
91
|
{
|
|
101
92
|
setComputedHeight(newInputValue);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
} else {
|
|
105
|
-
setComputedWidth('');
|
|
106
|
-
}
|
|
93
|
+
newWidth = newInputValue !== '' ? Math.round(ratioHeight * newInputValue) : '';
|
|
94
|
+
setComputedWidth(newWidth);
|
|
107
95
|
break;
|
|
108
96
|
}
|
|
109
97
|
}
|
|
98
|
+
var isInvalidInputValid = newWidth !== '' && (newWidth < minWidth || newWidth > maxWidth);
|
|
99
|
+
onChange && onChange(isInvalidInputValid);
|
|
110
100
|
};
|
|
111
|
-
}, [
|
|
101
|
+
}, [minWidth, maxWidth, onChange, ratioWidth, ratioHeight]);
|
|
112
102
|
if (showMigration) {
|
|
113
103
|
return jsx(Tooltip, {
|
|
114
104
|
content: formatMessage(messages.migrationButtonTooltip)
|
|
@@ -130,7 +120,6 @@ export var PixelEntry = function PixelEntry(_ref) {
|
|
|
130
120
|
}, jsx(Field, {
|
|
131
121
|
key: "inputWidth",
|
|
132
122
|
name: "inputWidth",
|
|
133
|
-
validate: handleValidateWidth,
|
|
134
123
|
defaultValue: computedWidth
|
|
135
124
|
}, function (_ref3) {
|
|
136
125
|
var fieldProps = _ref3.fieldProps;
|
|
@@ -4,7 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import { safeInsert as pmSafeInsert, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
6
|
import { checkNodeDown } from '../../../utils';
|
|
7
|
-
import { getMediaSingleInitialWidth, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
7
|
+
import { getMediaSingleInitialWidth, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH, getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
|
|
8
8
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
9
9
|
import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
|
|
10
10
|
import { mapSlice } from '../../../utils/slice';
|
|
@@ -91,7 +91,7 @@ export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaSta
|
|
|
91
91
|
|
|
92
92
|
// add undefined as fallback as we don't want media single width to have upper limit as 0
|
|
93
93
|
// if widthPluginState.width is 0, default 760 will be used
|
|
94
|
-
var contentWidth = (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.lineLength) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.width) || undefined;
|
|
94
|
+
var contentWidth = getMaxWidthForNestedNodeNext(view, state.selection.$from.pos, true) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.lineLength) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.width) || undefined;
|
|
95
95
|
var node = createMediaSingleNode(state.schema, collection, contentWidth, mediaState.status !== 'error' && isVideo(mediaState.fileMimeType) ? MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH : MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, alignLeftOnInsert)(mediaState);
|
|
96
96
|
var fileExtension;
|
|
97
97
|
if (mediaState.fileName) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
4
|
import type { IntlShape } from 'react-intl-next';
|
|
5
5
|
import type { PixelEntryProps } from './types';
|
|
6
|
-
export declare const PixelEntry: ({ width, mediaWidth, mediaHeight, onSubmit,
|
|
6
|
+
export declare const PixelEntry: ({ width, mediaWidth, mediaHeight, onSubmit, minWidth, maxWidth, onChange, intl: { formatMessage }, showMigration, onMigrate, }: PixelEntryProps) => jsx.JSX.Element;
|
|
7
7
|
export declare const FullWidthDisplay: React.FC<{
|
|
8
8
|
intl: IntlShape;
|
|
9
9
|
}>;
|
|
@@ -24,6 +24,11 @@ export type PixelEntryProps = {
|
|
|
24
24
|
* The maximum acceptable width input
|
|
25
25
|
*/
|
|
26
26
|
maxWidth: number;
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* Handler for valid input
|
|
30
|
+
*/
|
|
31
|
+
onChange?: (valid: boolean) => void;
|
|
27
32
|
/**
|
|
28
33
|
* show migration button to convert to pixels for legacy image resize experience
|
|
29
34
|
*/
|
|
@@ -43,8 +48,8 @@ export type PixelEntryProps = {
|
|
|
43
48
|
onMigrate?: () => void;
|
|
44
49
|
};
|
|
45
50
|
export type PixelEntryFormValues = {
|
|
46
|
-
inputWidth: number;
|
|
47
|
-
inputHeight: number;
|
|
51
|
+
inputWidth: number | '';
|
|
52
|
+
inputHeight: number | '';
|
|
48
53
|
};
|
|
49
54
|
export type PixelEntryFormData = {
|
|
50
55
|
width: number;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
4
|
import type { IntlShape } from 'react-intl-next';
|
|
5
5
|
import type { PixelEntryProps } from './types';
|
|
6
|
-
export declare const PixelEntry: ({ width, mediaWidth, mediaHeight, onSubmit,
|
|
6
|
+
export declare const PixelEntry: ({ width, mediaWidth, mediaHeight, onSubmit, minWidth, maxWidth, onChange, intl: { formatMessage }, showMigration, onMigrate, }: PixelEntryProps) => jsx.JSX.Element;
|
|
7
7
|
export declare const FullWidthDisplay: React.FC<{
|
|
8
8
|
intl: IntlShape;
|
|
9
9
|
}>;
|
|
@@ -24,6 +24,11 @@ export type PixelEntryProps = {
|
|
|
24
24
|
* The maximum acceptable width input
|
|
25
25
|
*/
|
|
26
26
|
maxWidth: number;
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* Handler for valid input
|
|
30
|
+
*/
|
|
31
|
+
onChange?: (valid: boolean) => void;
|
|
27
32
|
/**
|
|
28
33
|
* show migration button to convert to pixels for legacy image resize experience
|
|
29
34
|
*/
|
|
@@ -43,8 +48,8 @@ export type PixelEntryProps = {
|
|
|
43
48
|
onMigrate?: () => void;
|
|
44
49
|
};
|
|
45
50
|
export type PixelEntryFormValues = {
|
|
46
|
-
inputWidth: number;
|
|
47
|
-
inputHeight: number;
|
|
51
|
+
inputWidth: number | '';
|
|
52
|
+
inputHeight: number | '';
|
|
48
53
|
};
|
|
49
54
|
export type PixelEntryFormData = {
|
|
50
55
|
width: number;
|