@atlaskit/editor-core 187.30.4 → 187.30.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 187.30.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`ef2d5662e05`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ef2d5662e05) - [ux] Implement pixel entry input validation when submitting and render warning decoration for invalid input
8
+
3
9
  ## 187.30.4
4
10
 
5
11
  ### Patch Changes
@@ -12,7 +12,7 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
12
12
  var _colors = require("@atlaskit/theme/colors");
13
13
  var _mediaCard = require("@atlaskit/media-card");
14
14
  var _templateObject;
15
- var mediaStyles = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .ProseMirror {\n ", " & [layout='full-width'] .", ",\n & [layout='wide'] .", " {\n margin-left: 50%;\n transform: translateX(-50%);\n }\n\n .media-extended-resize-experience[layout^='wrap-'] {\n // override 'overflow: auto' when viewport <= 410 set by mediaSingleSharedStyle\n // to prevent scroll bar\n overflow: visible !important;\n }\n\n & [layout^='wrap-'] + [layout^='wrap-'] {\n clear: none;\n & + p,\n & + div[class^='fabric-editor-align'],\n & + ul,\n & + ol,\n & + h1,\n & + h2,\n & + h3,\n & + h4,\n & + h5,\n & + h6 {\n clear: both !important;\n }\n & .", " {\n margin-left: 0;\n margin-right: 0;\n }\n }\n\n .mediaSingleView-content-wrap[layout^='wrap-'] {\n max-width: 100%;\n // overwrite default Prosemirror setting making it clear: both\n clear: inherit;\n }\n\n .mediaSingleView-content-wrap[layout='wrap-left'] {\n float: left;\n }\n\n .mediaSingleView-content-wrap[layout='wrap-right'] {\n float: right;\n }\n\n .mediaSingleView-content-wrap[layout='wrap-right']\n + .mediaSingleView-content-wrap[layout='wrap-left'] {\n clear: both;\n }\n\n /* Larger margins for resize handlers when at depth 0 of the document */\n & > .mediaSingleView-content-wrap {\n .richMedia-resize-handle-right {\n margin-right: -", "px;\n }\n .richMedia-resize-handle-left {\n margin-left: -", "px;\n }\n }\n }\n\n .richMedia-resize-handle-right,\n .richMedia-resize-handle-left {\n display: flex;\n flex-direction: column;\n\n /* vertical align */\n justify-content: center;\n }\n\n .richMedia-resize-handle-right {\n align-items: flex-end;\n padding-right: ", ";\n margin-right: -", "px;\n }\n\n .richMedia-resize-handle-left {\n align-items: flex-start;\n padding-left: ", ";\n margin-left: -", "px;\n }\n\n .richMedia-resize-handle-right::after,\n .richMedia-resize-handle-left::after {\n content: ' ';\n display: flex;\n width: 3px;\n height: 64px;\n\n border-radius: 6px;\n }\n\n .", ":hover .richMedia-resize-handle-left::after,\n .", ":hover .richMedia-resize-handle-right::after {\n background: ", ";\n }\n\n .", " .richMedia-resize-handle-right::after,\n .", " .richMedia-resize-handle-left::after,\n .", " .richMedia-resize-handle-right:hover::after,\n .", " .richMedia-resize-handle-left:hover::after,\n .", ".is-resizing .richMedia-resize-handle-right::after,\n .", ".is-resizing .richMedia-resize-handle-left::after {\n background: ", ";\n }\n\n .__resizable_base__ {\n left: unset !important;\n width: auto !important;\n height: auto !important;\n }\n\n /* Danger when top level node for smart cards / inline links */\n .danger > div > div > .media-card-frame,\n .danger > span > a {\n background-color: ", ";\n box-shadow: 0px 0px 0px ", "px\n ", ";\n transition: background-color 0s, box-shadow 0s;\n }\n /* Danger when nested node or common */\n .danger {\n /* Media single */\n .", " .", "::after {\n border: 1px solid ", ";\n }\n /* Media single video player */\n .", " .", "::after {\n border: 1px solid ", ";\n }\n /* New file experience */\n .", " .", " {\n box-shadow: 0 0 0 1px\n ", " !important;\n }\n /* Media resize handlers */\n .richMedia-resize-handle-right::after,\n .richMedia-resize-handle-left::after {\n background: ", ";\n }\n\n /* Smart cards */\n div div .media-card-frame,\n .inlineCardView-content-wrap > span > a {\n background-color: ", "; /* R75 with 50% opactiy */\n transition: background-color 0s;\n }\n\n div div .media-card-frame::after {\n box-shadow: none;\n }\n }\n"])), _styles.mediaSingleSharedStyle, _styles.richMediaClassName, _styles.richMediaClassName, _styles.richMediaClassName, _editorSharedStyles.akEditorMediaResizeHandlerPaddingWide, _editorSharedStyles.akEditorMediaResizeHandlerPaddingWide, "var(--ds-space-150, 12px)", _editorSharedStyles.akEditorMediaResizeHandlerPadding, "var(--ds-space-150, 12px)", _editorSharedStyles.akEditorMediaResizeHandlerPadding, _styles.richMediaClassName, _styles.richMediaClassName, "var(--ds-border, ".concat(_colors.N60, ")"), _editorSharedStyles.akEditorSelectedNodeClassName, _editorSharedStyles.akEditorSelectedNodeClassName, _styles.richMediaClassName, _styles.richMediaClassName, _styles.richMediaClassName, _styles.richMediaClassName, "var(--ds-border-focused, ".concat(_colors.B200, ")"), "var(--ds-background-danger, ".concat(_editorSharedStyles.akEditorDeleteBackground, ")"), _editorSharedStyles.akEditorSelectedBorderBoldSize, "var(--ds-border-danger, ".concat(_editorSharedStyles.akEditorDeleteBorder, ")"), _styles.richMediaClassName, _mediaCard.fileCardImageViewSelector, "var(--ds-border-danger, ".concat(_editorSharedStyles.akEditorDeleteIconColor, ")"), _styles.richMediaClassName, _mediaCard.inlinePlayerClassName, "var(--ds-border-danger, ".concat(_editorSharedStyles.akEditorDeleteIconColor, ")"), _styles.richMediaClassName, _mediaCard.newFileExperienceClassName, "var(--ds-border-danger, ".concat(_editorSharedStyles.akEditorDeleteIconColor, ")"), "var(--ds-icon-danger, ".concat(_editorSharedStyles.akEditorDeleteIconColor, ")"), "var(--ds-blanket-danger, rgb(255, 189, 173, 0.5))");
15
+ var mediaStyles = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .ProseMirror {\n ", " & [layout='full-width'] .", ",\n & [layout='wide'] .", " {\n margin-left: 50%;\n transform: translateX(-50%);\n }\n\n .media-extended-resize-experience[layout^='wrap-'] {\n // override 'overflow: auto' when viewport <= 410 set by mediaSingleSharedStyle\n // to prevent scroll bar\n overflow: visible !important;\n }\n\n & [layout^='wrap-'] + [layout^='wrap-'] {\n clear: none;\n & + p,\n & + div[class^='fabric-editor-align'],\n & + ul,\n & + ol,\n & + h1,\n & + h2,\n & + h3,\n & + h4,\n & + h5,\n & + h6 {\n clear: both !important;\n }\n & .", " {\n margin-left: 0;\n margin-right: 0;\n }\n }\n\n .mediaSingleView-content-wrap[layout^='wrap-'] {\n max-width: 100%;\n // overwrite default Prosemirror setting making it clear: both\n clear: inherit;\n }\n\n .mediaSingleView-content-wrap[layout='wrap-left'] {\n float: left;\n }\n\n .mediaSingleView-content-wrap[layout='wrap-right'] {\n float: right;\n }\n\n .mediaSingleView-content-wrap[layout='wrap-right']\n + .mediaSingleView-content-wrap[layout='wrap-left'] {\n clear: both;\n }\n\n /* Larger margins for resize handlers when at depth 0 of the document */\n & > .mediaSingleView-content-wrap {\n .richMedia-resize-handle-right {\n margin-right: -", "px;\n }\n .richMedia-resize-handle-left {\n margin-left: -", "px;\n }\n }\n }\n\n .richMedia-resize-handle-right,\n .richMedia-resize-handle-left {\n display: flex;\n flex-direction: column;\n\n /* vertical align */\n justify-content: center;\n }\n\n .richMedia-resize-handle-right {\n align-items: flex-end;\n padding-right: ", ";\n margin-right: -", "px;\n }\n\n .richMedia-resize-handle-left {\n align-items: flex-start;\n padding-left: ", ";\n margin-left: -", "px;\n }\n\n .richMedia-resize-handle-right::after,\n .richMedia-resize-handle-left::after {\n content: ' ';\n display: flex;\n width: 3px;\n height: 64px;\n\n border-radius: 6px;\n }\n\n .", ":hover .richMedia-resize-handle-left::after,\n .", ":hover .richMedia-resize-handle-right::after {\n background: ", ";\n }\n\n .", " .richMedia-resize-handle-right::after,\n .", " .richMedia-resize-handle-left::after,\n .", " .richMedia-resize-handle-right:hover::after,\n .", " .richMedia-resize-handle-left:hover::after,\n .", ".is-resizing .richMedia-resize-handle-right::after,\n .", ".is-resizing .richMedia-resize-handle-left::after {\n background: ", ";\n }\n\n .__resizable_base__ {\n left: unset !important;\n width: auto !important;\n height: auto !important;\n }\n\n /* Danger when top level node for smart cards / inline links */\n .danger > div > div > .media-card-frame,\n .danger > span > a {\n background-color: ", ";\n box-shadow: 0px 0px 0px ", "px\n ", ";\n transition: background-color 0s, box-shadow 0s;\n }\n /* Danger when nested node or common */\n .danger {\n /* Media single */\n .", " .", "::after {\n border: 1px solid ", ";\n }\n /* Media single video player */\n .", " .", "::after {\n border: 1px solid ", ";\n }\n /* New file experience */\n .", " .", " {\n box-shadow: 0 0 0 1px\n ", " !important;\n }\n /* Media resize handlers */\n .richMedia-resize-handle-right::after,\n .richMedia-resize-handle-left::after {\n background: ", ";\n }\n\n /* Smart cards */\n div div .media-card-frame,\n .inlineCardView-content-wrap > span > a {\n background-color: ", "; /* R75 with 50% opactiy */\n transition: background-color 0s;\n }\n\n div div .media-card-frame::after {\n box-shadow: none;\n }\n }\n\n .warning {\n /* Media single */\n .", " .", "::after {\n border: 1px solid ", ";\n }\n\n .", " .", "::after {\n border: 1px solid ", ";\n }\n\n .", " .", " {\n box-shadow: 0 0 0 1px ", " !important;\n }\n\n .resizer-handle-left::after,\n .resizer-handle-right::after {\n background: ", " !important;\n }\n }\n"])), _styles.mediaSingleSharedStyle, _styles.richMediaClassName, _styles.richMediaClassName, _styles.richMediaClassName, _editorSharedStyles.akEditorMediaResizeHandlerPaddingWide, _editorSharedStyles.akEditorMediaResizeHandlerPaddingWide, "var(--ds-space-150, 12px)", _editorSharedStyles.akEditorMediaResizeHandlerPadding, "var(--ds-space-150, 12px)", _editorSharedStyles.akEditorMediaResizeHandlerPadding, _styles.richMediaClassName, _styles.richMediaClassName, "var(--ds-border, ".concat(_colors.N60, ")"), _editorSharedStyles.akEditorSelectedNodeClassName, _editorSharedStyles.akEditorSelectedNodeClassName, _styles.richMediaClassName, _styles.richMediaClassName, _styles.richMediaClassName, _styles.richMediaClassName, "var(--ds-border-focused, ".concat(_colors.B200, ")"), "var(--ds-background-danger, ".concat(_editorSharedStyles.akEditorDeleteBackground, ")"), _editorSharedStyles.akEditorSelectedBorderBoldSize, "var(--ds-border-danger, ".concat(_editorSharedStyles.akEditorDeleteBorder, ")"), _styles.richMediaClassName, _mediaCard.fileCardImageViewSelector, "var(--ds-border-danger, ".concat(_editorSharedStyles.akEditorDeleteIconColor, ")"), _styles.richMediaClassName, _mediaCard.inlinePlayerClassName, "var(--ds-border-danger, ".concat(_editorSharedStyles.akEditorDeleteIconColor, ")"), _styles.richMediaClassName, _mediaCard.newFileExperienceClassName, "var(--ds-border-danger, ".concat(_editorSharedStyles.akEditorDeleteIconColor, ")"), "var(--ds-icon-danger, ".concat(_editorSharedStyles.akEditorDeleteIconColor, ")"), "var(--ds-blanket-danger, rgb(255, 189, 173, 0.5))", _styles.richMediaClassName, _mediaCard.fileCardImageViewSelector, "var(--ds-border-warning, ".concat(_colors.Y500, ")"), _styles.richMediaClassName, _mediaCard.inlinePlayerClassName, "var(--ds-border-warning, ".concat(_colors.Y500, ")"), _styles.richMediaClassName, _mediaCard.newFileExperienceClassName, "var(--ds-border-warning, ".concat(_colors.Y500, ")"), "var(--ds-icon-warning, ".concat(_colors.Y500, ")"));
16
16
 
17
17
  /* `left: unset` above is to work around Chrome bug where rendering a div with
18
18
  * that style applied inside a container that has a scroll, causes any svgs on
@@ -28,13 +28,14 @@ var _messages2 = require("@atlaskit/editor-common/messages");
28
28
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
29
29
  var _filePreviewItem = require("./filePreviewItem");
30
30
  var _utils2 = require("./utils");
31
+ var _mediaSingle = require("../utils/media-single");
31
32
  var _commands = require("./commands");
32
33
  var _styles = require("../nodeviews/styles");
33
34
  var _ImageBorder = _interopRequireDefault(require("../ui/ImageBorder"));
34
35
  var _currentMediaNode = require("../utils/current-media-node");
35
36
  var _imageBorder = require("./imageBorder");
36
37
  var _PixelEntry = require("../ui/PixelEntry");
37
- var _mediaSingle = require("@atlaskit/editor-common/media-single");
38
+ var _mediaSingle2 = require("@atlaskit/editor-common/media-single");
38
39
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
39
40
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
40
41
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -198,7 +199,7 @@ var generateMediaInlineFloatingToolbar = function generateMediaInlineFloatingToo
198
199
  return items;
199
200
  };
200
201
  var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToolbar(state, intl, options, pluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags) {
201
- var _pluginInjectionApi$d8;
202
+ var _pluginInjectionApi$d;
202
203
  var mediaSingle = state.schema.nodes.mediaSingle;
203
204
  var allowResizing = options.allowResizing,
204
205
  allowLinking = options.allowLinking,
@@ -206,6 +207,8 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
206
207
  allowResizingInTables = options.allowResizingInTables,
207
208
  allowAltTextOnImages = options.allowAltTextOnImages;
208
209
  var toolbarButtons = [];
210
+ var _ref = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
211
+ hoverDecoration = _ref.hoverDecoration;
209
212
  if ((0, _imageBorder.shouldShowImageBorder)(state)) {
210
213
  toolbarButtons.push({
211
214
  type: 'custom',
@@ -219,12 +222,12 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
219
222
  var borderMark = (0, _currentMediaNode.currentMediaNodeBorderMark)(state);
220
223
  return /*#__PURE__*/_react.default.createElement(_ImageBorder.default, {
221
224
  toggleBorder: function toggleBorder() {
222
- var _pluginInjectionApi$d, _pluginInjectionApi$d2;
223
- (0, _commands.toggleBorderMark)(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions)(state, dispatch);
225
+ var _pluginInjectionApi$d2, _pluginInjectionApi$d3;
226
+ (0, _commands.toggleBorderMark)(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d2 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : (_pluginInjectionApi$d3 = _pluginInjectionApi$d2.analytics) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : _pluginInjectionApi$d3.actions)(state, dispatch);
224
227
  },
225
228
  setBorder: function setBorder(attrs) {
226
- var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
227
- (0, _commands.setBorderMark)(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d3 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : (_pluginInjectionApi$d4 = _pluginInjectionApi$d3.analytics) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.actions)(attrs)(state, dispatch);
229
+ var _pluginInjectionApi$d4, _pluginInjectionApi$d5;
230
+ (0, _commands.setBorderMark)(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d4 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : (_pluginInjectionApi$d5 = _pluginInjectionApi$d4.analytics) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : _pluginInjectionApi$d5.actions)(attrs)(state, dispatch);
228
231
  },
229
232
  showSomewhatSemanticTooltips: getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags().useSomewhatSemanticTextColorNames,
230
233
  borderMark: borderMark,
@@ -237,7 +240,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
237
240
  });
238
241
  }
239
242
  if (allowAdvancedToolBarOptions) {
240
- var _pluginInjectionApi$d5;
243
+ var _pluginInjectionApi$d6;
241
244
  var widthPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.width;
242
245
  var isChangingLayoutDisabled = false;
243
246
  if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.extended-resize-experience')) {
@@ -251,7 +254,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
251
254
  }
252
255
  }
253
256
  }
254
- var layoutButtons = (0, _card.buildLayoutButtons)(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d5 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : _pluginInjectionApi$d5.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled);
257
+ var layoutButtons = (0, _card.buildLayoutButtons)(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d6 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d6 === void 0 ? void 0 : _pluginInjectionApi$d6.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled);
255
258
  toolbarButtons = [].concat((0, _toConsumableArray2.default)(toolbarButtons), (0, _toConsumableArray2.default)(layoutButtons));
256
259
  if (layoutButtons.length) {
257
260
  toolbarButtons.push({
@@ -272,11 +275,11 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
272
275
  var state = editorView.state,
273
276
  dispatch = editorView.dispatch;
274
277
  var selectedMediaSingleNode = (0, _utils2.getSelectedMediaSingle)(state);
275
- var contentWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.lineLength) || _editorSharedStyles.akEditorDefaultLayoutWidth;
276
- var containerWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt3 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt3 === void 0 ? void 0 : _widthPlugin$sharedSt3.width) || _editorSharedStyles.akEditorFullWidthLayoutWidth;
277
278
  if (!selectedMediaSingleNode) {
278
279
  return null;
279
280
  }
281
+ var contentWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.lineLength) || _editorSharedStyles.akEditorDefaultLayoutWidth;
282
+ var containerWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt3 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt3 === void 0 ? void 0 : _widthPlugin$sharedSt3.width) || _editorSharedStyles.akEditorFullWidthLayoutWidth;
280
283
  var selectedMediaNode = selectedMediaSingleNode.node.content.firstChild;
281
284
  if (!selectedMediaNode) {
282
285
  return null;
@@ -288,30 +291,44 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
288
291
  var _selectedMediaNode$at = selectedMediaNode.attrs,
289
292
  mediaWidth = _selectedMediaNode$at.width,
290
293
  mediaHeight = _selectedMediaNode$at.height;
294
+ var maxWidthForNestedNode = (0, _mediaSingle2.getMaxWidthForNestedNodeNext)(editorView, selectedMediaSingleNode.pos);
295
+ var maxWidth = maxWidthForNestedNode || _editorSharedStyles.akEditorFullWidthLayoutWidth;
296
+ var isVideoFile = (0, _mediaSingle.isVideo)(selectedMediaNode.attrs.__fileMimeType);
297
+ var minWidth = (0, _mediaSingle2.calcMinWidth)(isVideoFile, maxWidthForNestedNode || contentWidth);
291
298
  var isLegacy = widthType !== 'pixel';
292
- var pixelWidth = (0, _mediaSingle.calcMediaSinglePixelWidth)({
299
+ var pixelWidth = (0, _mediaSingle2.calcMediaSinglePixelWidth)({
293
300
  width: singleMediaWidth,
294
301
  widthType: widthType,
295
- origWidth: mediaWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH,
302
+ origWidth: mediaWidth || _mediaSingle2.DEFAULT_IMAGE_WIDTH,
296
303
  layout: layout,
297
- contentWidth: (0, _mediaSingle.getMaxWidthForNestedNode)(editorView, selectedMediaSingleNode.pos) || contentWidth,
304
+ contentWidth: (0, _mediaSingle2.getMaxWidthForNestedNode)(editorView, selectedMediaSingleNode.pos) || contentWidth,
298
305
  containerWidth: containerWidth,
299
- gutterOffset: _mediaSingle.MEDIA_SINGLE_GUTTER_SIZE
306
+ gutterOffset: _mediaSingle2.MEDIA_SINGLE_GUTTER_SIZE
300
307
  });
301
308
  return /*#__PURE__*/_react.default.createElement(_PixelEntry.PixelEntry, {
302
309
  intl: intl,
303
310
  width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
304
311
  showMigration: !pluginState.isResizing && isLegacy,
305
- mediaWidth: mediaWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH,
306
- mediaHeight: mediaHeight || _mediaSingle.DEFAULT_IMAGE_HEIGHT,
312
+ mediaWidth: mediaWidth || _mediaSingle2.DEFAULT_IMAGE_WIDTH,
313
+ mediaHeight: mediaHeight || _mediaSingle2.DEFAULT_IMAGE_HEIGHT,
314
+ minWidth: minWidth,
315
+ maxWidth: maxWidth,
307
316
  validate: function validate(value) {
308
- if (value !== '' && !isNaN(value) && value >= _mediaSingle.MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH && value <= _editorSharedStyles.akEditorFullWidthLayoutWidth) {
309
- return true;
317
+ if (value && (value < minWidth || value > maxWidth)) {
318
+ hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true, 'warning')(editorView.state, dispatch, editorView);
319
+ } else {
320
+ // remove decoration when:
321
+ // input is within min-max range or
322
+ // input is empty
323
+ hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false)(editorView.state, dispatch, editorView);
324
+ }
325
+ if (value === '') {
326
+ return false;
310
327
  }
311
- return false;
328
+ return true;
312
329
  },
313
- onSubmit: function onSubmit(_ref) {
314
- var width = _ref.width;
330
+ onSubmit: function onSubmit(_ref2) {
331
+ var width = _ref2.width;
315
332
  var tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, _objectSpread(_objectSpread({}, selectedMediaSingleNode.node.attrs), {}, {
316
333
  width: width,
317
334
  widthType: 'pixel'
@@ -356,10 +373,10 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
356
373
  };
357
374
  var openLink = function openLink() {
358
375
  if (editorView) {
359
- var _pluginInjectionApi$d6;
376
+ var _pluginInjectionApi$d7;
360
377
  var tr = editorView.state.tr,
361
378
  dispatch = editorView.dispatch;
362
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d6 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d6 === void 0 ? void 0 : _pluginInjectionApi$d6.actions.attachAnalyticsEvent({
379
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d7 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d7 === void 0 ? void 0 : _pluginInjectionApi$d7.actions.attachAnalyticsEvent({
363
380
  eventType: _analytics.EVENT_TYPE.TRACK,
364
381
  action: _analytics.ACTION.VISITED,
365
382
  actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
@@ -385,13 +402,11 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
385
402
  }
386
403
  }
387
404
  if (allowAltTextOnImages) {
388
- var _pluginInjectionApi$d7;
389
- toolbarButtons.push((0, _altText2.altTextButton)(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d7 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d7 === void 0 ? void 0 : _pluginInjectionApi$d7.actions), {
405
+ var _pluginInjectionApi$d8;
406
+ toolbarButtons.push((0, _altText2.altTextButton)(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d8 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d8 === void 0 ? void 0 : _pluginInjectionApi$d8.actions), {
390
407
  type: 'separator'
391
408
  });
392
409
  }
393
- var _ref2 = (_pluginInjectionApi$d8 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d8 !== void 0 ? _pluginInjectionApi$d8 : {},
394
- hoverDecoration = _ref2.hoverDecoration;
395
410
  var removeButton = {
396
411
  id: 'editor.media.delete',
397
412
  type: 'button',
@@ -27,6 +27,8 @@ var PixelEntry = function PixelEntry(_ref) {
27
27
  mediaHeight = _ref.mediaHeight,
28
28
  onSubmit = _ref.onSubmit,
29
29
  validate = _ref.validate,
30
+ minWidth = _ref.minWidth,
31
+ maxWidth = _ref.maxWidth,
30
32
  formatMessage = _ref.intl.formatMessage,
31
33
  showMigration = _ref.showMigration,
32
34
  onMigrate = _ref.onMigrate;
@@ -54,18 +56,33 @@ var PixelEntry = function PixelEntry(_ref) {
54
56
  // Handle submit when user presses enter in form
55
57
  var handleOnSubmit = function handleOnSubmit(data) {
56
58
  if (onSubmit) {
57
- if (data.inputWidth === '') {
58
- return;
59
+ var widthToBeSumitted = data.inputWidth;
60
+ var isInvalidInput = false;
61
+ if (data.inputWidth < minWidth) {
62
+ widthToBeSumitted = minWidth;
63
+ isInvalidInput = true;
64
+ }
65
+ if (data.inputWidth > maxWidth) {
66
+ widthToBeSumitted = maxWidth;
67
+ isInvalidInput = true;
68
+ }
69
+
70
+ // If user keeps submitting an invalid input, node width attribute will be updated with the same value
71
+ // and won't upadte the state in useEffect (since width is the same)
72
+ // Thus, we set the state here to always display the correct dimension
73
+ if (isInvalidInput) {
74
+ setComputedWidth(widthToBeSumitted);
75
+ setComputedHeight(Math.round(ratioWidth * widthToBeSumitted));
59
76
  }
60
77
  onSubmit({
61
- width: data.inputWidth
78
+ width: widthToBeSumitted
62
79
  });
63
80
  }
64
81
  };
65
82
 
66
83
  // Syncronous validation returning undefined for valid and string for invalid
67
84
  var handleValidateWidth = (0, _react2.useCallback)(function (value) {
68
- if (!value || !validate) {
85
+ if (!validate || value === undefined) {
69
86
  return;
70
87
  }
71
88
  if (validate) {
@@ -83,16 +100,20 @@ var PixelEntry = function PixelEntry(_ref) {
83
100
  case 'inputWidth':
84
101
  {
85
102
  setComputedWidth(newInputValue);
86
- if (!isNaN(value)) {
103
+ if (newInputValue) {
87
104
  setComputedHeight(Math.round(ratioWidth * value));
105
+ } else {
106
+ setComputedHeight('');
88
107
  }
89
108
  break;
90
109
  }
91
110
  case 'inputHeight':
92
111
  {
93
112
  setComputedHeight(newInputValue);
94
- if (!isNaN(value)) {
113
+ if (newInputValue) {
95
114
  setComputedWidth(Math.round(ratioHeight * value));
115
+ } else {
116
+ setComputedWidth('');
96
117
  }
97
118
  break;
98
119
  }
@@ -126,7 +147,9 @@ var PixelEntry = function PixelEntry(_ref) {
126
147
  var fieldProps = _ref3.fieldProps;
127
148
  return (0, _react.jsx)(_tooltip.default, {
128
149
  hideTooltipOnMouseDown: true,
129
- content: formatMessage(_messages.messages.inputWidthTooltip),
150
+ content: formatMessage(_messages.messages.inputWidthTooltip, {
151
+ maxWidth: maxWidth
152
+ }),
130
153
  position: "top"
131
154
  }, (0, _react.jsx)(_textfield.default, (0, _extends2.default)({}, fieldProps, {
132
155
  css: [_styles.pixelSizingWidthInput, _styles.pixelSizingInput],
@@ -134,7 +157,9 @@ var PixelEntry = function PixelEntry(_ref) {
134
157
  isCompact: true,
135
158
  onChange: handleOnChange('inputWidth'),
136
159
  pattern: "\\d*",
137
- "aria-label": formatMessage(_messages.messages.inputWidthAriaLabel)
160
+ "aria-label": formatMessage(_messages.messages.inputWidthAriaLabel, {
161
+ maxWidth: maxWidth
162
+ })
138
163
  })));
139
164
  }), (0, _react.jsx)("span", {
140
165
  css: _styles.pixelSizingLabel
@@ -13,12 +13,12 @@ var messages = (0, _reactIntlNext.defineMessages)({
13
13
  },
14
14
  inputWidthTooltip: {
15
15
  id: 'fabric.editor.media.pixelEntry.inputWidthTooltip',
16
- defaultMessage: 'Width',
16
+ defaultMessage: 'Max width {maxWidth}px',
17
17
  description: 'The tooltip displayed ontop of the width input'
18
18
  },
19
19
  inputWidthAriaLabel: {
20
20
  id: 'fabric.editor.media.pixelEntry.inputWidthAriaLabel',
21
- defaultMessage: 'width input',
21
+ defaultMessage: 'Max width {maxWidth}px',
22
22
  description: 'The width input aria label'
23
23
  },
24
24
  inputHeightTooltip: {
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.insertMediaSingleNode = exports.insertMediaAsMediaSingle = exports.getParentWidthForNestedMediaSingleNode = exports.createMediaSingleNode = void 0;
7
+ exports.insertMediaSingleNode = exports.insertMediaAsMediaSingle = exports.createMediaSingleNode = void 0;
8
8
  exports.isCaptionNode = isCaptionNode;
9
9
  exports.isVideo = exports.isMediaSingle = void 0;
10
10
  exports.transformSliceForMedia = transformSliceForMedia;
@@ -225,23 +225,4 @@ function isCaptionNode(editorView) {
225
225
  var isVideo = function isVideo(fileType) {
226
226
  return !!fileType && fileType.includes('video');
227
227
  };
228
- exports.isVideo = isVideo;
229
- var getParentWidthForNestedMediaSingleNode = function getParentWidthForNestedMediaSingleNode(resolvedPos, view) {
230
- var domNode = view.nodeDOM(resolvedPos.pos);
231
- if (resolvedPos.nodeAfter && _utils3.floatingLayouts.includes(resolvedPos.nodeAfter.attrs.layout) && domNode && domNode.parentElement) {
232
- var _view$state$schema$no = view.state.schema.nodes,
233
- tableCell = _view$state$schema$no.tableCell,
234
- tableHeader = _view$state$schema$no.tableHeader;
235
- if ([tableCell, tableHeader].includes(resolvedPos.parent.type)) {
236
- // since table has constant padding, use hardcoded constant instead of query the dom
237
- var tablePadding = 8;
238
- return domNode.parentElement.offsetWidth - tablePadding * 2;
239
- }
240
- return domNode.parentElement.offsetWidth;
241
- }
242
- if (domNode instanceof HTMLElement) {
243
- return domNode.offsetWidth;
244
- }
245
- return null;
246
- };
247
- exports.getParentWidthForNestedMediaSingleNode = getParentWidthForNestedMediaSingleNode;
228
+ exports.isVideo = isVideo;
@@ -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.30.4";
9
+ var version = "187.30.5";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,7 +1,7 @@
1
1
  import { css } from '@emotion/react';
2
2
  import { mediaSingleSharedStyle, richMediaClassName } from '@atlaskit/editor-common/styles';
3
3
  import { akEditorDeleteBorder, akEditorDeleteBackground, akEditorSelectedBorderBoldSize, akEditorMediaResizeHandlerPaddingWide, akEditorMediaResizeHandlerPadding, akEditorSelectedNodeClassName, akEditorDeleteIconColor } from '@atlaskit/editor-shared-styles';
4
- import { N60, B200 } from '@atlaskit/theme/colors';
4
+ import { N60, B200, Y500 } from '@atlaskit/theme/colors';
5
5
  import { fileCardImageViewSelector, inlinePlayerClassName, newFileExperienceClassName } from '@atlaskit/media-card';
6
6
  export const mediaStyles = css`
7
7
  .ProseMirror {
@@ -158,6 +158,26 @@ export const mediaStyles = css`
158
158
  box-shadow: none;
159
159
  }
160
160
  }
161
+
162
+ .warning {
163
+ /* Media single */
164
+ .${richMediaClassName} .${fileCardImageViewSelector}::after {
165
+ border: 1px solid ${`var(--ds-border-warning, ${Y500})`};
166
+ }
167
+
168
+ .${richMediaClassName} .${inlinePlayerClassName}::after {
169
+ border: 1px solid ${`var(--ds-border-warning, ${Y500})`};
170
+ }
171
+
172
+ .${richMediaClassName} .${newFileExperienceClassName} {
173
+ box-shadow: 0 0 0 1px ${`var(--ds-border-warning, ${Y500})`} !important;
174
+ }
175
+
176
+ .resizer-handle-left::after,
177
+ .resizer-handle-right::after {
178
+ background: ${`var(--ds-icon-warning, ${Y500})`} !important;
179
+ }
180
+ }
161
181
  `;
162
182
 
163
183
  /* `left: unset` above is to work around Chrome bug where rendering a div with
@@ -19,13 +19,14 @@ import { cardMessages } from '@atlaskit/editor-common/messages';
19
19
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
20
20
  import { FilePreviewItem } from './filePreviewItem';
21
21
  import { downloadMedia, getSelectedMediaSingle, removeMediaGroupNode } from './utils';
22
+ import { isVideo } from '../utils/media-single';
22
23
  import { changeInlineToMediaCard, changeMediaCardToInline, removeInlineCard, setBorderMark, toggleBorderMark } from './commands';
23
24
  import { MediaInlineNodeSelector, MediaSingleNodeSelector } from '../nodeviews/styles';
24
25
  import ImageBorderItem from '../ui/ImageBorder';
25
26
  import { currentMediaNodeBorderMark } from '../utils/current-media-node';
26
27
  import { shouldShowImageBorder } from './imageBorder';
27
28
  import { PixelEntry } from '../ui/PixelEntry';
28
- import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_GUTTER_SIZE, calcMediaSinglePixelWidth, getMaxWidthForNestedNode } from '@atlaskit/editor-common/media-single';
29
+ import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_GUTTER_SIZE, calcMediaSinglePixelWidth, calcMinWidth, getMaxWidthForNestedNode, getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
29
30
  import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
30
31
  const remove = (state, dispatch) => {
31
32
  if (dispatch) {
@@ -191,7 +192,7 @@ const generateMediaInlineFloatingToolbar = (state, intl, mediaPluginState, hover
191
192
  return items;
192
193
  };
193
194
  const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags) => {
194
- var _pluginInjectionApi$d8;
195
+ var _pluginInjectionApi$d;
195
196
  const {
196
197
  mediaSingle
197
198
  } = state.schema.nodes;
@@ -203,6 +204,9 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
203
204
  allowAltTextOnImages
204
205
  } = options;
205
206
  let toolbarButtons = [];
207
+ const {
208
+ hoverDecoration
209
+ } = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {};
206
210
  if (shouldShowImageBorder(state)) {
207
211
  toolbarButtons.push({
208
212
  type: 'custom',
@@ -218,12 +222,12 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
218
222
  const borderMark = currentMediaNodeBorderMark(state);
219
223
  return /*#__PURE__*/React.createElement(ImageBorderItem, {
220
224
  toggleBorder: () => {
221
- var _pluginInjectionApi$d, _pluginInjectionApi$d2;
222
- toggleBorderMark(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions)(state, dispatch);
225
+ var _pluginInjectionApi$d2, _pluginInjectionApi$d3;
226
+ toggleBorderMark(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d2 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : (_pluginInjectionApi$d3 = _pluginInjectionApi$d2.analytics) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : _pluginInjectionApi$d3.actions)(state, dispatch);
223
227
  },
224
228
  setBorder: attrs => {
225
- var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
226
- setBorderMark(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d3 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : (_pluginInjectionApi$d4 = _pluginInjectionApi$d3.analytics) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.actions)(attrs)(state, dispatch);
229
+ var _pluginInjectionApi$d4, _pluginInjectionApi$d5;
230
+ setBorderMark(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d4 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : (_pluginInjectionApi$d5 = _pluginInjectionApi$d4.analytics) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : _pluginInjectionApi$d5.actions)(attrs)(state, dispatch);
227
231
  },
228
232
  showSomewhatSemanticTooltips: getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags().useSomewhatSemanticTextColorNames,
229
233
  borderMark: borderMark,
@@ -236,7 +240,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
236
240
  });
237
241
  }
238
242
  if (allowAdvancedToolBarOptions) {
239
- var _pluginInjectionApi$d5;
243
+ var _pluginInjectionApi$d6;
240
244
  const widthPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.width;
241
245
  let isChangingLayoutDisabled = false;
242
246
  if (getBooleanFF('platform.editor.media.extended-resize-experience')) {
@@ -252,7 +256,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
252
256
  }
253
257
  }
254
258
  }
255
- const layoutButtons = buildLayoutButtons(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d5 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : _pluginInjectionApi$d5.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled);
259
+ const layoutButtons = buildLayoutButtons(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d6 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d6 === void 0 ? void 0 : _pluginInjectionApi$d6.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled);
256
260
  toolbarButtons = [...toolbarButtons, ...layoutButtons];
257
261
  if (layoutButtons.length) {
258
262
  toolbarButtons.push({
@@ -275,11 +279,11 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
275
279
  dispatch
276
280
  } = editorView;
277
281
  const selectedMediaSingleNode = getSelectedMediaSingle(state);
278
- const contentWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.lineLength) || akEditorDefaultLayoutWidth;
279
- const containerWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt3 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt3 === void 0 ? void 0 : _widthPlugin$sharedSt3.width) || akEditorFullWidthLayoutWidth;
280
282
  if (!selectedMediaSingleNode) {
281
283
  return null;
282
284
  }
285
+ const contentWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.lineLength) || akEditorDefaultLayoutWidth;
286
+ const containerWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt3 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt3 === void 0 ? void 0 : _widthPlugin$sharedSt3.width) || akEditorFullWidthLayoutWidth;
283
287
  const selectedMediaNode = selectedMediaSingleNode.node.content.firstChild;
284
288
  if (!selectedMediaNode) {
285
289
  return null;
@@ -293,6 +297,10 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
293
297
  width: mediaWidth,
294
298
  height: mediaHeight
295
299
  } = selectedMediaNode.attrs;
300
+ const maxWidthForNestedNode = getMaxWidthForNestedNodeNext(editorView, selectedMediaSingleNode.pos);
301
+ const maxWidth = maxWidthForNestedNode || akEditorFullWidthLayoutWidth;
302
+ const isVideoFile = isVideo(selectedMediaNode.attrs.__fileMimeType);
303
+ const minWidth = calcMinWidth(isVideoFile, maxWidthForNestedNode || contentWidth);
296
304
  const isLegacy = widthType !== 'pixel';
297
305
  const pixelWidth = calcMediaSinglePixelWidth({
298
306
  width: singleMediaWidth,
@@ -309,11 +317,21 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
309
317
  showMigration: !pluginState.isResizing && isLegacy,
310
318
  mediaWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
311
319
  mediaHeight: mediaHeight || DEFAULT_IMAGE_HEIGHT,
320
+ minWidth: minWidth,
321
+ maxWidth: maxWidth,
312
322
  validate: value => {
313
- if (value !== '' && !isNaN(value) && value >= MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH && value <= akEditorFullWidthLayoutWidth) {
314
- return true;
323
+ if (value && (value < minWidth || value > maxWidth)) {
324
+ hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true, 'warning')(editorView.state, dispatch, editorView);
325
+ } else {
326
+ // remove decoration when:
327
+ // input is within min-max range or
328
+ // input is empty
329
+ hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false)(editorView.state, dispatch, editorView);
330
+ }
331
+ if (value === '') {
332
+ return false;
315
333
  }
316
- return false;
334
+ return true;
317
335
  },
318
336
  onSubmit: ({
319
337
  width
@@ -366,14 +384,14 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
366
384
  };
367
385
  const openLink = () => {
368
386
  if (editorView) {
369
- var _pluginInjectionApi$d6;
387
+ var _pluginInjectionApi$d7;
370
388
  const {
371
389
  state: {
372
390
  tr
373
391
  },
374
392
  dispatch
375
393
  } = editorView;
376
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d6 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d6 === void 0 ? void 0 : _pluginInjectionApi$d6.actions.attachAnalyticsEvent({
394
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d7 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d7 === void 0 ? void 0 : _pluginInjectionApi$d7.actions.attachAnalyticsEvent({
377
395
  eventType: EVENT_TYPE.TRACK,
378
396
  action: ACTION.VISITED,
379
397
  actionSubject: ACTION_SUBJECT.MEDIA,
@@ -399,14 +417,11 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
399
417
  }
400
418
  }
401
419
  if (allowAltTextOnImages) {
402
- var _pluginInjectionApi$d7;
403
- toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d7 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d7 === void 0 ? void 0 : _pluginInjectionApi$d7.actions), {
420
+ var _pluginInjectionApi$d8;
421
+ toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d8 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d8 === void 0 ? void 0 : _pluginInjectionApi$d8.actions), {
404
422
  type: 'separator'
405
423
  });
406
424
  }
407
- const {
408
- hoverDecoration
409
- } = (_pluginInjectionApi$d8 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d8 !== void 0 ? _pluginInjectionApi$d8 : {};
410
425
  const removeButton = {
411
426
  id: 'editor.media.delete',
412
427
  type: 'button',
@@ -15,6 +15,8 @@ export const PixelEntry = ({
15
15
  mediaHeight,
16
16
  onSubmit,
17
17
  validate,
18
+ minWidth,
19
+ maxWidth,
18
20
  intl: {
19
21
  formatMessage
20
22
  },
@@ -39,18 +41,33 @@ export const PixelEntry = ({
39
41
  // Handle submit when user presses enter in form
40
42
  const handleOnSubmit = data => {
41
43
  if (onSubmit) {
42
- if (data.inputWidth === '') {
43
- return;
44
+ let widthToBeSumitted = data.inputWidth;
45
+ let isInvalidInput = false;
46
+ if (data.inputWidth < minWidth) {
47
+ widthToBeSumitted = minWidth;
48
+ isInvalidInput = true;
49
+ }
50
+ if (data.inputWidth > maxWidth) {
51
+ widthToBeSumitted = maxWidth;
52
+ isInvalidInput = true;
53
+ }
54
+
55
+ // If user keeps submitting an invalid input, node width attribute will be updated with the same value
56
+ // and won't upadte the state in useEffect (since width is the same)
57
+ // Thus, we set the state here to always display the correct dimension
58
+ if (isInvalidInput) {
59
+ setComputedWidth(widthToBeSumitted);
60
+ setComputedHeight(Math.round(ratioWidth * widthToBeSumitted));
44
61
  }
45
62
  onSubmit({
46
- width: data.inputWidth
63
+ width: widthToBeSumitted
47
64
  });
48
65
  }
49
66
  };
50
67
 
51
68
  // Syncronous validation returning undefined for valid and string for invalid
52
69
  const handleValidateWidth = useCallback(value => {
53
- if (!value || !validate) {
70
+ if (!validate || value === undefined) {
54
71
  return;
55
72
  }
56
73
  if (validate) {
@@ -67,16 +84,20 @@ export const PixelEntry = ({
67
84
  case 'inputWidth':
68
85
  {
69
86
  setComputedWidth(newInputValue);
70
- if (!isNaN(value)) {
87
+ if (newInputValue) {
71
88
  setComputedHeight(Math.round(ratioWidth * value));
89
+ } else {
90
+ setComputedHeight('');
72
91
  }
73
92
  break;
74
93
  }
75
94
  case 'inputHeight':
76
95
  {
77
96
  setComputedHeight(newInputValue);
78
- if (!isNaN(value)) {
97
+ if (newInputValue) {
79
98
  setComputedWidth(Math.round(ratioHeight * value));
99
+ } else {
100
+ setComputedWidth('');
80
101
  }
81
102
  break;
82
103
  }
@@ -110,7 +131,9 @@ export const PixelEntry = ({
110
131
  fieldProps
111
132
  }) => jsx(Tooltip, {
112
133
  hideTooltipOnMouseDown: true,
113
- content: formatMessage(messages.inputWidthTooltip),
134
+ content: formatMessage(messages.inputWidthTooltip, {
135
+ maxWidth
136
+ }),
114
137
  position: "top"
115
138
  }, jsx(Textfield, _extends({}, fieldProps, {
116
139
  css: [pixelSizingWidthInput, pixelSizingInput],
@@ -118,7 +141,9 @@ export const PixelEntry = ({
118
141
  isCompact: true,
119
142
  onChange: handleOnChange('inputWidth'),
120
143
  pattern: "\\d*",
121
- "aria-label": formatMessage(messages.inputWidthAriaLabel)
144
+ "aria-label": formatMessage(messages.inputWidthAriaLabel, {
145
+ maxWidth
146
+ })
122
147
  })))), jsx("span", {
123
148
  css: pixelSizingLabel
124
149
  }, "x"), jsx(Field, {
@@ -7,12 +7,12 @@ export const messages = defineMessages({
7
7
  },
8
8
  inputWidthTooltip: {
9
9
  id: 'fabric.editor.media.pixelEntry.inputWidthTooltip',
10
- defaultMessage: 'Width',
10
+ defaultMessage: 'Max width {maxWidth}px',
11
11
  description: 'The tooltip displayed ontop of the width input'
12
12
  },
13
13
  inputWidthAriaLabel: {
14
14
  id: 'fabric.editor.media.pixelEntry.inputWidthAriaLabel',
15
- defaultMessage: 'width input',
15
+ defaultMessage: 'Max width {maxWidth}px',
16
16
  description: 'The width input aria label'
17
17
  },
18
18
  inputHeightTooltip: {
@@ -2,7 +2,7 @@ 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
4
  import { getMediaSingleInitialWidth, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
5
- import { isEmptyParagraph, floatingLayouts } from '@atlaskit/editor-common/utils';
5
+ import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
6
6
  import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
7
7
  import { mapSlice } from '../../../utils/slice';
8
8
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
@@ -217,23 +217,4 @@ export function isCaptionNode(editorView) {
217
217
  }
218
218
  return false;
219
219
  }
220
- export const isVideo = fileType => !!fileType && fileType.includes('video');
221
- export const getParentWidthForNestedMediaSingleNode = (resolvedPos, view) => {
222
- const domNode = view.nodeDOM(resolvedPos.pos);
223
- if (resolvedPos.nodeAfter && floatingLayouts.includes(resolvedPos.nodeAfter.attrs.layout) && domNode && domNode.parentElement) {
224
- const {
225
- tableCell,
226
- tableHeader
227
- } = view.state.schema.nodes;
228
- if ([tableCell, tableHeader].includes(resolvedPos.parent.type)) {
229
- // since table has constant padding, use hardcoded constant instead of query the dom
230
- const tablePadding = 8;
231
- return domNode.parentElement.offsetWidth - tablePadding * 2;
232
- }
233
- return domNode.parentElement.offsetWidth;
234
- }
235
- if (domNode instanceof HTMLElement) {
236
- return domNode.offsetWidth;
237
- }
238
- return null;
239
- };
220
+ export const isVideo = fileType => !!fileType && fileType.includes('video');
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.30.4";
2
+ export const version = "187.30.5";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -3,9 +3,9 @@ var _templateObject;
3
3
  import { css } from '@emotion/react';
4
4
  import { mediaSingleSharedStyle, richMediaClassName } from '@atlaskit/editor-common/styles';
5
5
  import { akEditorDeleteBorder, akEditorDeleteBackground, akEditorSelectedBorderBoldSize, akEditorMediaResizeHandlerPaddingWide, akEditorMediaResizeHandlerPadding, akEditorSelectedNodeClassName, akEditorDeleteIconColor } from '@atlaskit/editor-shared-styles';
6
- import { N60, B200 } from '@atlaskit/theme/colors';
6
+ import { N60, B200, Y500 } from '@atlaskit/theme/colors';
7
7
  import { fileCardImageViewSelector, inlinePlayerClassName, newFileExperienceClassName } from '@atlaskit/media-card';
8
- export var mediaStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror {\n ", " & [layout='full-width'] .", ",\n & [layout='wide'] .", " {\n margin-left: 50%;\n transform: translateX(-50%);\n }\n\n .media-extended-resize-experience[layout^='wrap-'] {\n // override 'overflow: auto' when viewport <= 410 set by mediaSingleSharedStyle\n // to prevent scroll bar\n overflow: visible !important;\n }\n\n & [layout^='wrap-'] + [layout^='wrap-'] {\n clear: none;\n & + p,\n & + div[class^='fabric-editor-align'],\n & + ul,\n & + ol,\n & + h1,\n & + h2,\n & + h3,\n & + h4,\n & + h5,\n & + h6 {\n clear: both !important;\n }\n & .", " {\n margin-left: 0;\n margin-right: 0;\n }\n }\n\n .mediaSingleView-content-wrap[layout^='wrap-'] {\n max-width: 100%;\n // overwrite default Prosemirror setting making it clear: both\n clear: inherit;\n }\n\n .mediaSingleView-content-wrap[layout='wrap-left'] {\n float: left;\n }\n\n .mediaSingleView-content-wrap[layout='wrap-right'] {\n float: right;\n }\n\n .mediaSingleView-content-wrap[layout='wrap-right']\n + .mediaSingleView-content-wrap[layout='wrap-left'] {\n clear: both;\n }\n\n /* Larger margins for resize handlers when at depth 0 of the document */\n & > .mediaSingleView-content-wrap {\n .richMedia-resize-handle-right {\n margin-right: -", "px;\n }\n .richMedia-resize-handle-left {\n margin-left: -", "px;\n }\n }\n }\n\n .richMedia-resize-handle-right,\n .richMedia-resize-handle-left {\n display: flex;\n flex-direction: column;\n\n /* vertical align */\n justify-content: center;\n }\n\n .richMedia-resize-handle-right {\n align-items: flex-end;\n padding-right: ", ";\n margin-right: -", "px;\n }\n\n .richMedia-resize-handle-left {\n align-items: flex-start;\n padding-left: ", ";\n margin-left: -", "px;\n }\n\n .richMedia-resize-handle-right::after,\n .richMedia-resize-handle-left::after {\n content: ' ';\n display: flex;\n width: 3px;\n height: 64px;\n\n border-radius: 6px;\n }\n\n .", ":hover .richMedia-resize-handle-left::after,\n .", ":hover .richMedia-resize-handle-right::after {\n background: ", ";\n }\n\n .", " .richMedia-resize-handle-right::after,\n .", " .richMedia-resize-handle-left::after,\n .", " .richMedia-resize-handle-right:hover::after,\n .", " .richMedia-resize-handle-left:hover::after,\n .", ".is-resizing .richMedia-resize-handle-right::after,\n .", ".is-resizing .richMedia-resize-handle-left::after {\n background: ", ";\n }\n\n .__resizable_base__ {\n left: unset !important;\n width: auto !important;\n height: auto !important;\n }\n\n /* Danger when top level node for smart cards / inline links */\n .danger > div > div > .media-card-frame,\n .danger > span > a {\n background-color: ", ";\n box-shadow: 0px 0px 0px ", "px\n ", ";\n transition: background-color 0s, box-shadow 0s;\n }\n /* Danger when nested node or common */\n .danger {\n /* Media single */\n .", " .", "::after {\n border: 1px solid ", ";\n }\n /* Media single video player */\n .", " .", "::after {\n border: 1px solid ", ";\n }\n /* New file experience */\n .", " .", " {\n box-shadow: 0 0 0 1px\n ", " !important;\n }\n /* Media resize handlers */\n .richMedia-resize-handle-right::after,\n .richMedia-resize-handle-left::after {\n background: ", ";\n }\n\n /* Smart cards */\n div div .media-card-frame,\n .inlineCardView-content-wrap > span > a {\n background-color: ", "; /* R75 with 50% opactiy */\n transition: background-color 0s;\n }\n\n div div .media-card-frame::after {\n box-shadow: none;\n }\n }\n"])), mediaSingleSharedStyle, richMediaClassName, richMediaClassName, richMediaClassName, akEditorMediaResizeHandlerPaddingWide, akEditorMediaResizeHandlerPaddingWide, "var(--ds-space-150, 12px)", akEditorMediaResizeHandlerPadding, "var(--ds-space-150, 12px)", akEditorMediaResizeHandlerPadding, richMediaClassName, richMediaClassName, "var(--ds-border, ".concat(N60, ")"), akEditorSelectedNodeClassName, akEditorSelectedNodeClassName, richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, "var(--ds-border-focused, ".concat(B200, ")"), "var(--ds-background-danger, ".concat(akEditorDeleteBackground, ")"), akEditorSelectedBorderBoldSize, "var(--ds-border-danger, ".concat(akEditorDeleteBorder, ")"), richMediaClassName, fileCardImageViewSelector, "var(--ds-border-danger, ".concat(akEditorDeleteIconColor, ")"), richMediaClassName, inlinePlayerClassName, "var(--ds-border-danger, ".concat(akEditorDeleteIconColor, ")"), richMediaClassName, newFileExperienceClassName, "var(--ds-border-danger, ".concat(akEditorDeleteIconColor, ")"), "var(--ds-icon-danger, ".concat(akEditorDeleteIconColor, ")"), "var(--ds-blanket-danger, rgb(255, 189, 173, 0.5))");
8
+ export var mediaStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror {\n ", " & [layout='full-width'] .", ",\n & [layout='wide'] .", " {\n margin-left: 50%;\n transform: translateX(-50%);\n }\n\n .media-extended-resize-experience[layout^='wrap-'] {\n // override 'overflow: auto' when viewport <= 410 set by mediaSingleSharedStyle\n // to prevent scroll bar\n overflow: visible !important;\n }\n\n & [layout^='wrap-'] + [layout^='wrap-'] {\n clear: none;\n & + p,\n & + div[class^='fabric-editor-align'],\n & + ul,\n & + ol,\n & + h1,\n & + h2,\n & + h3,\n & + h4,\n & + h5,\n & + h6 {\n clear: both !important;\n }\n & .", " {\n margin-left: 0;\n margin-right: 0;\n }\n }\n\n .mediaSingleView-content-wrap[layout^='wrap-'] {\n max-width: 100%;\n // overwrite default Prosemirror setting making it clear: both\n clear: inherit;\n }\n\n .mediaSingleView-content-wrap[layout='wrap-left'] {\n float: left;\n }\n\n .mediaSingleView-content-wrap[layout='wrap-right'] {\n float: right;\n }\n\n .mediaSingleView-content-wrap[layout='wrap-right']\n + .mediaSingleView-content-wrap[layout='wrap-left'] {\n clear: both;\n }\n\n /* Larger margins for resize handlers when at depth 0 of the document */\n & > .mediaSingleView-content-wrap {\n .richMedia-resize-handle-right {\n margin-right: -", "px;\n }\n .richMedia-resize-handle-left {\n margin-left: -", "px;\n }\n }\n }\n\n .richMedia-resize-handle-right,\n .richMedia-resize-handle-left {\n display: flex;\n flex-direction: column;\n\n /* vertical align */\n justify-content: center;\n }\n\n .richMedia-resize-handle-right {\n align-items: flex-end;\n padding-right: ", ";\n margin-right: -", "px;\n }\n\n .richMedia-resize-handle-left {\n align-items: flex-start;\n padding-left: ", ";\n margin-left: -", "px;\n }\n\n .richMedia-resize-handle-right::after,\n .richMedia-resize-handle-left::after {\n content: ' ';\n display: flex;\n width: 3px;\n height: 64px;\n\n border-radius: 6px;\n }\n\n .", ":hover .richMedia-resize-handle-left::after,\n .", ":hover .richMedia-resize-handle-right::after {\n background: ", ";\n }\n\n .", " .richMedia-resize-handle-right::after,\n .", " .richMedia-resize-handle-left::after,\n .", " .richMedia-resize-handle-right:hover::after,\n .", " .richMedia-resize-handle-left:hover::after,\n .", ".is-resizing .richMedia-resize-handle-right::after,\n .", ".is-resizing .richMedia-resize-handle-left::after {\n background: ", ";\n }\n\n .__resizable_base__ {\n left: unset !important;\n width: auto !important;\n height: auto !important;\n }\n\n /* Danger when top level node for smart cards / inline links */\n .danger > div > div > .media-card-frame,\n .danger > span > a {\n background-color: ", ";\n box-shadow: 0px 0px 0px ", "px\n ", ";\n transition: background-color 0s, box-shadow 0s;\n }\n /* Danger when nested node or common */\n .danger {\n /* Media single */\n .", " .", "::after {\n border: 1px solid ", ";\n }\n /* Media single video player */\n .", " .", "::after {\n border: 1px solid ", ";\n }\n /* New file experience */\n .", " .", " {\n box-shadow: 0 0 0 1px\n ", " !important;\n }\n /* Media resize handlers */\n .richMedia-resize-handle-right::after,\n .richMedia-resize-handle-left::after {\n background: ", ";\n }\n\n /* Smart cards */\n div div .media-card-frame,\n .inlineCardView-content-wrap > span > a {\n background-color: ", "; /* R75 with 50% opactiy */\n transition: background-color 0s;\n }\n\n div div .media-card-frame::after {\n box-shadow: none;\n }\n }\n\n .warning {\n /* Media single */\n .", " .", "::after {\n border: 1px solid ", ";\n }\n\n .", " .", "::after {\n border: 1px solid ", ";\n }\n\n .", " .", " {\n box-shadow: 0 0 0 1px ", " !important;\n }\n\n .resizer-handle-left::after,\n .resizer-handle-right::after {\n background: ", " !important;\n }\n }\n"])), mediaSingleSharedStyle, richMediaClassName, richMediaClassName, richMediaClassName, akEditorMediaResizeHandlerPaddingWide, akEditorMediaResizeHandlerPaddingWide, "var(--ds-space-150, 12px)", akEditorMediaResizeHandlerPadding, "var(--ds-space-150, 12px)", akEditorMediaResizeHandlerPadding, richMediaClassName, richMediaClassName, "var(--ds-border, ".concat(N60, ")"), akEditorSelectedNodeClassName, akEditorSelectedNodeClassName, richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, "var(--ds-border-focused, ".concat(B200, ")"), "var(--ds-background-danger, ".concat(akEditorDeleteBackground, ")"), akEditorSelectedBorderBoldSize, "var(--ds-border-danger, ".concat(akEditorDeleteBorder, ")"), richMediaClassName, fileCardImageViewSelector, "var(--ds-border-danger, ".concat(akEditorDeleteIconColor, ")"), richMediaClassName, inlinePlayerClassName, "var(--ds-border-danger, ".concat(akEditorDeleteIconColor, ")"), richMediaClassName, newFileExperienceClassName, "var(--ds-border-danger, ".concat(akEditorDeleteIconColor, ")"), "var(--ds-icon-danger, ".concat(akEditorDeleteIconColor, ")"), "var(--ds-blanket-danger, rgb(255, 189, 173, 0.5))", richMediaClassName, fileCardImageViewSelector, "var(--ds-border-warning, ".concat(Y500, ")"), richMediaClassName, inlinePlayerClassName, "var(--ds-border-warning, ".concat(Y500, ")"), richMediaClassName, newFileExperienceClassName, "var(--ds-border-warning, ".concat(Y500, ")"), "var(--ds-icon-warning, ".concat(Y500, ")"));
9
9
 
10
10
  /* `left: unset` above is to work around Chrome bug where rendering a div with
11
11
  * that style applied inside a container that has a scroll, causes any svgs on
@@ -23,13 +23,14 @@ import { cardMessages } from '@atlaskit/editor-common/messages';
23
23
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
24
24
  import { FilePreviewItem } from './filePreviewItem';
25
25
  import { downloadMedia, getSelectedMediaSingle, removeMediaGroupNode } from './utils';
26
+ import { isVideo } from '../utils/media-single';
26
27
  import { changeInlineToMediaCard, changeMediaCardToInline, removeInlineCard, setBorderMark, toggleBorderMark } from './commands';
27
28
  import { MediaInlineNodeSelector, MediaSingleNodeSelector } from '../nodeviews/styles';
28
29
  import ImageBorderItem from '../ui/ImageBorder';
29
30
  import { currentMediaNodeBorderMark } from '../utils/current-media-node';
30
31
  import { shouldShowImageBorder } from './imageBorder';
31
32
  import { PixelEntry } from '../ui/PixelEntry';
32
- import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_GUTTER_SIZE, calcMediaSinglePixelWidth, getMaxWidthForNestedNode } from '@atlaskit/editor-common/media-single';
33
+ import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_GUTTER_SIZE, calcMediaSinglePixelWidth, calcMinWidth, getMaxWidthForNestedNode, getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
33
34
  import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
34
35
  var remove = function remove(state, dispatch) {
35
36
  if (dispatch) {
@@ -191,7 +192,7 @@ var generateMediaInlineFloatingToolbar = function generateMediaInlineFloatingToo
191
192
  return items;
192
193
  };
193
194
  var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToolbar(state, intl, options, pluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags) {
194
- var _pluginInjectionApi$d8;
195
+ var _pluginInjectionApi$d;
195
196
  var mediaSingle = state.schema.nodes.mediaSingle;
196
197
  var allowResizing = options.allowResizing,
197
198
  allowLinking = options.allowLinking,
@@ -199,6 +200,8 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
199
200
  allowResizingInTables = options.allowResizingInTables,
200
201
  allowAltTextOnImages = options.allowAltTextOnImages;
201
202
  var toolbarButtons = [];
203
+ var _ref = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
204
+ hoverDecoration = _ref.hoverDecoration;
202
205
  if (shouldShowImageBorder(state)) {
203
206
  toolbarButtons.push({
204
207
  type: 'custom',
@@ -212,12 +215,12 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
212
215
  var borderMark = currentMediaNodeBorderMark(state);
213
216
  return /*#__PURE__*/React.createElement(ImageBorderItem, {
214
217
  toggleBorder: function toggleBorder() {
215
- var _pluginInjectionApi$d, _pluginInjectionApi$d2;
216
- toggleBorderMark(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions)(state, dispatch);
218
+ var _pluginInjectionApi$d2, _pluginInjectionApi$d3;
219
+ toggleBorderMark(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d2 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : (_pluginInjectionApi$d3 = _pluginInjectionApi$d2.analytics) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : _pluginInjectionApi$d3.actions)(state, dispatch);
217
220
  },
218
221
  setBorder: function setBorder(attrs) {
219
- var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
220
- setBorderMark(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d3 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : (_pluginInjectionApi$d4 = _pluginInjectionApi$d3.analytics) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.actions)(attrs)(state, dispatch);
222
+ var _pluginInjectionApi$d4, _pluginInjectionApi$d5;
223
+ setBorderMark(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d4 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : (_pluginInjectionApi$d5 = _pluginInjectionApi$d4.analytics) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : _pluginInjectionApi$d5.actions)(attrs)(state, dispatch);
221
224
  },
222
225
  showSomewhatSemanticTooltips: getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags().useSomewhatSemanticTextColorNames,
223
226
  borderMark: borderMark,
@@ -230,7 +233,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
230
233
  });
231
234
  }
232
235
  if (allowAdvancedToolBarOptions) {
233
- var _pluginInjectionApi$d5;
236
+ var _pluginInjectionApi$d6;
234
237
  var widthPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.width;
235
238
  var isChangingLayoutDisabled = false;
236
239
  if (getBooleanFF('platform.editor.media.extended-resize-experience')) {
@@ -244,7 +247,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
244
247
  }
245
248
  }
246
249
  }
247
- var layoutButtons = buildLayoutButtons(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d5 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : _pluginInjectionApi$d5.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled);
250
+ var layoutButtons = buildLayoutButtons(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d6 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d6 === void 0 ? void 0 : _pluginInjectionApi$d6.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled);
248
251
  toolbarButtons = [].concat(_toConsumableArray(toolbarButtons), _toConsumableArray(layoutButtons));
249
252
  if (layoutButtons.length) {
250
253
  toolbarButtons.push({
@@ -265,11 +268,11 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
265
268
  var state = editorView.state,
266
269
  dispatch = editorView.dispatch;
267
270
  var selectedMediaSingleNode = getSelectedMediaSingle(state);
268
- var contentWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.lineLength) || akEditorDefaultLayoutWidth;
269
- var containerWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt3 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt3 === void 0 ? void 0 : _widthPlugin$sharedSt3.width) || akEditorFullWidthLayoutWidth;
270
271
  if (!selectedMediaSingleNode) {
271
272
  return null;
272
273
  }
274
+ var contentWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.lineLength) || akEditorDefaultLayoutWidth;
275
+ var containerWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt3 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt3 === void 0 ? void 0 : _widthPlugin$sharedSt3.width) || akEditorFullWidthLayoutWidth;
273
276
  var selectedMediaNode = selectedMediaSingleNode.node.content.firstChild;
274
277
  if (!selectedMediaNode) {
275
278
  return null;
@@ -281,6 +284,10 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
281
284
  var _selectedMediaNode$at = selectedMediaNode.attrs,
282
285
  mediaWidth = _selectedMediaNode$at.width,
283
286
  mediaHeight = _selectedMediaNode$at.height;
287
+ var maxWidthForNestedNode = getMaxWidthForNestedNodeNext(editorView, selectedMediaSingleNode.pos);
288
+ var maxWidth = maxWidthForNestedNode || akEditorFullWidthLayoutWidth;
289
+ var isVideoFile = isVideo(selectedMediaNode.attrs.__fileMimeType);
290
+ var minWidth = calcMinWidth(isVideoFile, maxWidthForNestedNode || contentWidth);
284
291
  var isLegacy = widthType !== 'pixel';
285
292
  var pixelWidth = calcMediaSinglePixelWidth({
286
293
  width: singleMediaWidth,
@@ -297,14 +304,24 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
297
304
  showMigration: !pluginState.isResizing && isLegacy,
298
305
  mediaWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
299
306
  mediaHeight: mediaHeight || DEFAULT_IMAGE_HEIGHT,
307
+ minWidth: minWidth,
308
+ maxWidth: maxWidth,
300
309
  validate: function validate(value) {
301
- if (value !== '' && !isNaN(value) && value >= MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH && value <= akEditorFullWidthLayoutWidth) {
302
- return true;
310
+ if (value && (value < minWidth || value > maxWidth)) {
311
+ hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true, 'warning')(editorView.state, dispatch, editorView);
312
+ } else {
313
+ // remove decoration when:
314
+ // input is within min-max range or
315
+ // input is empty
316
+ hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false)(editorView.state, dispatch, editorView);
317
+ }
318
+ if (value === '') {
319
+ return false;
303
320
  }
304
- return false;
321
+ return true;
305
322
  },
306
- onSubmit: function onSubmit(_ref) {
307
- var width = _ref.width;
323
+ onSubmit: function onSubmit(_ref2) {
324
+ var width = _ref2.width;
308
325
  var tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, _objectSpread(_objectSpread({}, selectedMediaSingleNode.node.attrs), {}, {
309
326
  width: width,
310
327
  widthType: 'pixel'
@@ -349,10 +366,10 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
349
366
  };
350
367
  var openLink = function openLink() {
351
368
  if (editorView) {
352
- var _pluginInjectionApi$d6;
369
+ var _pluginInjectionApi$d7;
353
370
  var tr = editorView.state.tr,
354
371
  dispatch = editorView.dispatch;
355
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d6 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d6 === void 0 ? void 0 : _pluginInjectionApi$d6.actions.attachAnalyticsEvent({
372
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d7 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d7 === void 0 ? void 0 : _pluginInjectionApi$d7.actions.attachAnalyticsEvent({
356
373
  eventType: EVENT_TYPE.TRACK,
357
374
  action: ACTION.VISITED,
358
375
  actionSubject: ACTION_SUBJECT.MEDIA,
@@ -378,13 +395,11 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
378
395
  }
379
396
  }
380
397
  if (allowAltTextOnImages) {
381
- var _pluginInjectionApi$d7;
382
- toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d7 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d7 === void 0 ? void 0 : _pluginInjectionApi$d7.actions), {
398
+ var _pluginInjectionApi$d8;
399
+ toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d8 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d8 === void 0 ? void 0 : _pluginInjectionApi$d8.actions), {
383
400
  type: 'separator'
384
401
  });
385
402
  }
386
- var _ref2 = (_pluginInjectionApi$d8 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d8 !== void 0 ? _pluginInjectionApi$d8 : {},
387
- hoverDecoration = _ref2.hoverDecoration;
388
403
  var removeButton = {
389
404
  id: 'editor.media.delete',
390
405
  type: 'button',
@@ -16,6 +16,8 @@ export var PixelEntry = function PixelEntry(_ref) {
16
16
  mediaHeight = _ref.mediaHeight,
17
17
  onSubmit = _ref.onSubmit,
18
18
  validate = _ref.validate,
19
+ minWidth = _ref.minWidth,
20
+ maxWidth = _ref.maxWidth,
19
21
  formatMessage = _ref.intl.formatMessage,
20
22
  showMigration = _ref.showMigration,
21
23
  onMigrate = _ref.onMigrate;
@@ -43,18 +45,33 @@ export var PixelEntry = function PixelEntry(_ref) {
43
45
  // Handle submit when user presses enter in form
44
46
  var handleOnSubmit = function handleOnSubmit(data) {
45
47
  if (onSubmit) {
46
- if (data.inputWidth === '') {
47
- return;
48
+ var widthToBeSumitted = data.inputWidth;
49
+ var isInvalidInput = false;
50
+ if (data.inputWidth < minWidth) {
51
+ widthToBeSumitted = minWidth;
52
+ isInvalidInput = true;
53
+ }
54
+ if (data.inputWidth > maxWidth) {
55
+ widthToBeSumitted = maxWidth;
56
+ isInvalidInput = true;
57
+ }
58
+
59
+ // If user keeps submitting an invalid input, node width attribute will be updated with the same value
60
+ // and won't upadte the state in useEffect (since width is the same)
61
+ // Thus, we set the state here to always display the correct dimension
62
+ if (isInvalidInput) {
63
+ setComputedWidth(widthToBeSumitted);
64
+ setComputedHeight(Math.round(ratioWidth * widthToBeSumitted));
48
65
  }
49
66
  onSubmit({
50
- width: data.inputWidth
67
+ width: widthToBeSumitted
51
68
  });
52
69
  }
53
70
  };
54
71
 
55
72
  // Syncronous validation returning undefined for valid and string for invalid
56
73
  var handleValidateWidth = useCallback(function (value) {
57
- if (!value || !validate) {
74
+ if (!validate || value === undefined) {
58
75
  return;
59
76
  }
60
77
  if (validate) {
@@ -72,16 +89,20 @@ export var PixelEntry = function PixelEntry(_ref) {
72
89
  case 'inputWidth':
73
90
  {
74
91
  setComputedWidth(newInputValue);
75
- if (!isNaN(value)) {
92
+ if (newInputValue) {
76
93
  setComputedHeight(Math.round(ratioWidth * value));
94
+ } else {
95
+ setComputedHeight('');
77
96
  }
78
97
  break;
79
98
  }
80
99
  case 'inputHeight':
81
100
  {
82
101
  setComputedHeight(newInputValue);
83
- if (!isNaN(value)) {
102
+ if (newInputValue) {
84
103
  setComputedWidth(Math.round(ratioHeight * value));
104
+ } else {
105
+ setComputedWidth('');
85
106
  }
86
107
  break;
87
108
  }
@@ -115,7 +136,9 @@ export var PixelEntry = function PixelEntry(_ref) {
115
136
  var fieldProps = _ref3.fieldProps;
116
137
  return jsx(Tooltip, {
117
138
  hideTooltipOnMouseDown: true,
118
- content: formatMessage(messages.inputWidthTooltip),
139
+ content: formatMessage(messages.inputWidthTooltip, {
140
+ maxWidth: maxWidth
141
+ }),
119
142
  position: "top"
120
143
  }, jsx(Textfield, _extends({}, fieldProps, {
121
144
  css: [pixelSizingWidthInput, pixelSizingInput],
@@ -123,7 +146,9 @@ export var PixelEntry = function PixelEntry(_ref) {
123
146
  isCompact: true,
124
147
  onChange: handleOnChange('inputWidth'),
125
148
  pattern: "\\d*",
126
- "aria-label": formatMessage(messages.inputWidthAriaLabel)
149
+ "aria-label": formatMessage(messages.inputWidthAriaLabel, {
150
+ maxWidth: maxWidth
151
+ })
127
152
  })));
128
153
  }), jsx("span", {
129
154
  css: pixelSizingLabel
@@ -7,12 +7,12 @@ export var messages = defineMessages({
7
7
  },
8
8
  inputWidthTooltip: {
9
9
  id: 'fabric.editor.media.pixelEntry.inputWidthTooltip',
10
- defaultMessage: 'Width',
10
+ defaultMessage: 'Max width {maxWidth}px',
11
11
  description: 'The tooltip displayed ontop of the width input'
12
12
  },
13
13
  inputWidthAriaLabel: {
14
14
  id: 'fabric.editor.media.pixelEntry.inputWidthAriaLabel',
15
- defaultMessage: 'width input',
15
+ defaultMessage: 'Max width {maxWidth}px',
16
16
  description: 'The width input aria label'
17
17
  },
18
18
  inputHeightTooltip: {
@@ -5,7 +5,7 @@ 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
7
  import { getMediaSingleInitialWidth, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
8
- import { isEmptyParagraph, floatingLayouts } from '@atlaskit/editor-common/utils';
8
+ import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
9
9
  import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
10
10
  import { mapSlice } from '../../../utils/slice';
11
11
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
@@ -210,22 +210,4 @@ export function isCaptionNode(editorView) {
210
210
  }
211
211
  export var isVideo = function isVideo(fileType) {
212
212
  return !!fileType && fileType.includes('video');
213
- };
214
- export var getParentWidthForNestedMediaSingleNode = function getParentWidthForNestedMediaSingleNode(resolvedPos, view) {
215
- var domNode = view.nodeDOM(resolvedPos.pos);
216
- if (resolvedPos.nodeAfter && floatingLayouts.includes(resolvedPos.nodeAfter.attrs.layout) && domNode && domNode.parentElement) {
217
- var _view$state$schema$no = view.state.schema.nodes,
218
- tableCell = _view$state$schema$no.tableCell,
219
- tableHeader = _view$state$schema$no.tableHeader;
220
- if ([tableCell, tableHeader].includes(resolvedPos.parent.type)) {
221
- // since table has constant padding, use hardcoded constant instead of query the dom
222
- var tablePadding = 8;
223
- return domNode.parentElement.offsetWidth - tablePadding * 2;
224
- }
225
- return domNode.parentElement.offsetWidth;
226
- }
227
- if (domNode instanceof HTMLElement) {
228
- return domNode.offsetWidth;
229
- }
230
- return null;
231
213
  };
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "187.30.4";
2
+ export var version = "187.30.5";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,4 +1,4 @@
1
1
  /** @jsx jsx */
2
2
  import { jsx } from '@emotion/react';
3
3
  import type { PixelEntryProps } from './types';
4
- export declare const PixelEntry: ({ width, mediaWidth, mediaHeight, onSubmit, validate, intl: { formatMessage }, showMigration, onMigrate, }: PixelEntryProps) => jsx.JSX.Element;
4
+ export declare const PixelEntry: ({ width, mediaWidth, mediaHeight, onSubmit, validate, minWidth, maxWidth, intl: { formatMessage }, showMigration, onMigrate, }: PixelEntryProps) => jsx.JSX.Element;
@@ -16,6 +16,14 @@ export type PixelEntryProps = {
16
16
  * The original media height used to calculate the width
17
17
  */
18
18
  mediaHeight: number;
19
+ /**
20
+ * The minimum acceptable width input
21
+ */
22
+ minWidth: number;
23
+ /**
24
+ * The maximum acceptable width input
25
+ */
26
+ maxWidth: number;
19
27
  /**
20
28
  * show migration button to convert to pixels for legacy image resize experience
21
29
  */
@@ -35,8 +43,8 @@ export type PixelEntryProps = {
35
43
  onMigrate?: () => void;
36
44
  };
37
45
  export type PixelEntryFormValues = {
38
- inputWidth: number | '';
39
- inputHeight: number | '';
46
+ inputWidth: number;
47
+ inputHeight: number;
40
48
  };
41
49
  export type PixelEntryFormData = {
42
50
  width: number;
@@ -1,4 +1,4 @@
1
- import type { Node as PMNode, ResolvedPos, Schema } from '@atlaskit/editor-prosemirror/model';
1
+ import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
2
2
  import { Slice } from '@atlaskit/editor-prosemirror/model';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
@@ -20,4 +20,3 @@ export declare const createMediaSingleNode: (schema: Schema, collection: string,
20
20
  export declare function transformSliceForMedia(slice: Slice, schema: Schema): (selection: Selection) => Slice;
21
21
  export declare function isCaptionNode(editorView: EditorView): boolean;
22
22
  export declare const isVideo: (fileType?: string) => boolean;
23
- export declare const getParentWidthForNestedMediaSingleNode: (resolvedPos: ResolvedPos, view: EditorView) => number | null;
@@ -1,4 +1,4 @@
1
1
  /** @jsx jsx */
2
2
  import { jsx } from '@emotion/react';
3
3
  import type { PixelEntryProps } from './types';
4
- export declare const PixelEntry: ({ width, mediaWidth, mediaHeight, onSubmit, validate, intl: { formatMessage }, showMigration, onMigrate, }: PixelEntryProps) => jsx.JSX.Element;
4
+ export declare const PixelEntry: ({ width, mediaWidth, mediaHeight, onSubmit, validate, minWidth, maxWidth, intl: { formatMessage }, showMigration, onMigrate, }: PixelEntryProps) => jsx.JSX.Element;
@@ -16,6 +16,14 @@ export type PixelEntryProps = {
16
16
  * The original media height used to calculate the width
17
17
  */
18
18
  mediaHeight: number;
19
+ /**
20
+ * The minimum acceptable width input
21
+ */
22
+ minWidth: number;
23
+ /**
24
+ * The maximum acceptable width input
25
+ */
26
+ maxWidth: number;
19
27
  /**
20
28
  * show migration button to convert to pixels for legacy image resize experience
21
29
  */
@@ -35,8 +43,8 @@ export type PixelEntryProps = {
35
43
  onMigrate?: () => void;
36
44
  };
37
45
  export type PixelEntryFormValues = {
38
- inputWidth: number | '';
39
- inputHeight: number | '';
46
+ inputWidth: number;
47
+ inputHeight: number;
40
48
  };
41
49
  export type PixelEntryFormData = {
42
50
  width: number;
@@ -1,4 +1,4 @@
1
- import type { Node as PMNode, ResolvedPos, Schema } from '@atlaskit/editor-prosemirror/model';
1
+ import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
2
2
  import { Slice } from '@atlaskit/editor-prosemirror/model';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
@@ -20,4 +20,3 @@ export declare const createMediaSingleNode: (schema: Schema, collection: string,
20
20
  export declare function transformSliceForMedia(slice: Slice, schema: Schema): (selection: Selection) => Slice;
21
21
  export declare function isCaptionNode(editorView: EditorView): boolean;
22
22
  export declare const isVideo: (fileType?: string) => boolean;
23
- export declare const getParentWidthForNestedMediaSingleNode: (resolvedPos: ResolvedPos, view: EditorView) => number | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.30.4",
3
+ "version": "187.30.5",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"