@atlaskit/editor-core 187.8.11 → 187.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/plugins/floating-toolbar/index.js +1 -3
  3. package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +33 -23
  4. package/dist/cjs/plugins/media/toolbar/index.js +16 -2
  5. package/dist/cjs/plugins/media/toolbar/utils.js +7 -2
  6. package/dist/cjs/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +574 -0
  7. package/dist/cjs/plugins/media/ui/ResizableMediaSingle/guidelines.js +117 -0
  8. package/dist/cjs/plugins/media/ui/ResizableMediaSingle/resizable-media-single-messages.js +15 -0
  9. package/dist/cjs/ui/ElementBrowser/components/ElementSearch.js +5 -3
  10. package/dist/cjs/ui/ElementBrowser/components/StatelessElementBrowser.js +8 -6
  11. package/dist/cjs/ui/Resizer/ResizeLabel/index.js +20 -0
  12. package/dist/cjs/ui/Resizer/ResizeLabel/styles.js +17 -0
  13. package/dist/cjs/version-wrapper.js +1 -1
  14. package/dist/cjs/version.json +1 -1
  15. package/dist/es2019/plugins/floating-toolbar/index.js +1 -1
  16. package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +34 -23
  17. package/dist/es2019/plugins/media/toolbar/index.js +19 -3
  18. package/dist/es2019/plugins/media/toolbar/utils.js +7 -1
  19. package/dist/es2019/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +493 -0
  20. package/dist/es2019/plugins/media/ui/ResizableMediaSingle/guidelines.js +108 -0
  21. package/dist/es2019/plugins/media/ui/ResizableMediaSingle/resizable-media-single-messages.js +8 -0
  22. package/dist/es2019/ui/ElementBrowser/components/ElementSearch.js +5 -3
  23. package/dist/es2019/ui/ElementBrowser/components/StatelessElementBrowser.js +9 -6
  24. package/dist/es2019/ui/Resizer/ResizeLabel/index.js +12 -0
  25. package/dist/es2019/ui/Resizer/ResizeLabel/styles.js +25 -0
  26. package/dist/es2019/version-wrapper.js +1 -1
  27. package/dist/es2019/version.json +1 -1
  28. package/dist/esm/plugins/floating-toolbar/index.js +1 -3
  29. package/dist/esm/plugins/media/nodeviews/mediaSingle.js +33 -23
  30. package/dist/esm/plugins/media/toolbar/index.js +17 -3
  31. package/dist/esm/plugins/media/toolbar/utils.js +5 -1
  32. package/dist/esm/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +564 -0
  33. package/dist/esm/plugins/media/ui/ResizableMediaSingle/guidelines.js +108 -0
  34. package/dist/esm/plugins/media/ui/ResizableMediaSingle/resizable-media-single-messages.js +8 -0
  35. package/dist/esm/ui/ElementBrowser/components/ElementSearch.js +5 -3
  36. package/dist/esm/ui/ElementBrowser/components/StatelessElementBrowser.js +8 -6
  37. package/dist/esm/ui/Resizer/ResizeLabel/index.js +12 -0
  38. package/dist/esm/ui/Resizer/ResizeLabel/styles.js +7 -0
  39. package/dist/esm/version-wrapper.js +1 -1
  40. package/dist/esm/version.json +1 -1
  41. package/dist/types/labs/next/presets/universal.d.ts +1 -2
  42. package/dist/types/plugins/floating-toolbar/index.d.ts +3 -1
  43. package/dist/types/plugins/media/index.d.ts +2 -0
  44. package/dist/types/plugins/media/nodeviews/styles.d.ts +1 -1
  45. package/dist/types/plugins/media/pm-plugins/main.d.ts +1 -1
  46. package/dist/types/plugins/media/toolbar/utils.d.ts +1 -0
  47. package/dist/types/plugins/media/types.d.ts +1 -0
  48. package/dist/types/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +61 -0
  49. package/dist/types/plugins/media/ui/ResizableMediaSingle/guidelines.d.ts +4 -0
  50. package/dist/types/plugins/media/ui/ResizableMediaSingle/resizable-media-single-messages.d.ts +7 -0
  51. package/dist/types/plugins/media/ui/ResizableMediaSingle/types.d.ts +1 -0
  52. package/dist/types/ui/ElementBrowser/components/ElementSearch.d.ts +2 -1
  53. package/dist/types/ui/ElementBrowser/components/StatelessElementBrowser.d.ts +4 -4
  54. package/dist/types/ui/Resizer/ResizeLabel/index.d.ts +8 -0
  55. package/dist/types/ui/Resizer/ResizeLabel/styles.d.ts +3 -0
  56. package/dist/types-ts4.5/labs/next/presets/universal.d.ts +1 -2
  57. package/dist/types-ts4.5/plugins/floating-toolbar/index.d.ts +3 -1
  58. package/dist/types-ts4.5/plugins/media/index.d.ts +2 -0
  59. package/dist/types-ts4.5/plugins/media/nodeviews/styles.d.ts +1 -1
  60. package/dist/types-ts4.5/plugins/media/pm-plugins/main.d.ts +1 -1
  61. package/dist/types-ts4.5/plugins/media/toolbar/utils.d.ts +1 -0
  62. package/dist/types-ts4.5/plugins/media/types.d.ts +1 -0
  63. package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +61 -0
  64. package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/guidelines.d.ts +4 -0
  65. package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/resizable-media-single-messages.d.ts +7 -0
  66. package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/types.d.ts +1 -0
  67. package/dist/types-ts4.5/ui/ElementBrowser/components/ElementSearch.d.ts +2 -1
  68. package/dist/types-ts4.5/ui/ElementBrowser/components/StatelessElementBrowser.d.ts +4 -4
  69. package/dist/types-ts4.5/ui/Resizer/ResizeLabel/index.d.ts +8 -0
  70. package/dist/types-ts4.5/ui/Resizer/ResizeLabel/styles.d.ts +3 -0
  71. package/package.json +2 -2
  72. package/report.api.md +7 -4
  73. package/tmp/api-report-tmp.d.ts +5 -1
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.messages = void 0;
7
+ var _reactIntlNext = require("react-intl-next");
8
+ var messages = (0, _reactIntlNext.defineMessages)({
9
+ fullWidthImage: {
10
+ id: 'fabric.editor.image.fullWidthImage',
11
+ defaultMessage: 'Full width image',
12
+ description: 'The image has reached its full width'
13
+ }
14
+ });
15
+ exports.messages = messages;
@@ -29,6 +29,7 @@ function ElementSearch(_ref) {
29
29
  formatMessage = _ref.intl.formatMessage,
30
30
  focus = _ref.focus,
31
31
  onClick = _ref.onClick,
32
+ onKeyDown = _ref.onKeyDown,
32
33
  searchTerm = _ref.searchTerm;
33
34
  var ref = (0, _useFocus.default)(focus);
34
35
  var onChange = function onChange(_ref2) {
@@ -44,6 +45,7 @@ function ElementSearch(_ref) {
44
45
  onChange: onChange,
45
46
  onClick: onClick,
46
47
  onFocus: onFocus,
48
+ onKeyDown: onKeyDown,
47
49
  onBlur: onBlur,
48
50
  elemBeforeInput: (0, _react2.jsx)("div", {
49
51
  css: elementBeforeInput,
@@ -75,10 +77,10 @@ var placeHolderMessage = {
75
77
  description: 'Search field placeholder'
76
78
  };
77
79
  var styledShortcut = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n ", "\n padding: ", "px ", "px;\n width: ", "px;\n"])), _styles.shortcutStyle, _constants.GRID_SIZE / 2, _constants.GRID_SIZE, _constants.GRID_SIZE * 6);
78
- var wrapper = (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n & > [data-ds--text-field--container] {\n height: ", "px;\n border-radius: ", "px;\n flex: 1 1 100%;\n overflow: visible;\n & > [data-ds--text-field--input] {\n margin-bottom: 3px;\n font-size: ", ";\n padding: ", "px 6px ", "px 0;\n }\n }\n"])), _constants.GRID_SIZE * 6, _constants.GRID_SIZE, (0, _editorSharedStyles.relativeFontSizeToBase16)(14), _constants.GRID_SIZE, _constants.GRID_SIZE);
80
+ var wrapper = (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n & > [data-ds--text-field--container] {\n height: ", "px;\n border-radius: ", "px;\n flex: 1 1 100%;\n overflow: visible;\n & > [data-ds--text-field--input] {\n margin-bottom: 3px;\n font-size: ", ";\n padding: ", "px ", " ", "px 0;\n }\n }\n"])), _constants.GRID_SIZE * 6, _constants.GRID_SIZE, (0, _editorSharedStyles.relativeFontSizeToBase16)(14), _constants.GRID_SIZE, "var(--ds-space-075, 6px)", _constants.GRID_SIZE);
79
81
  var wrapperInline = (0, _react2.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n & > [data-ds--text-field--container] {\n height: ", "px;\n flex: none;\n overflow: revert;\n }\n"])), _constants.GRID_SIZE * 5);
80
- var elementBeforeInput = (0, _react2.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n margin: 1px 6px 0 8px;\n color: ", ";\n\n // Custom SearchIcon style\n span,\n svg {\n height: 20px;\n width: 20px;\n }\n"])), "var(--ds-icon, ".concat(_colors.N200, ")"));
81
- var elementAfterInput = (0, _react2.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n margin: 0 8px;\n height: ", ";\n text-align: center;\n"])), _constants.SEARCH_ITEM_HEIGHT_WIDTH);
82
+ var elementBeforeInput = (0, _react2.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n margin: 1px ", " 0 ", ";\n color: ", ";\n\n // Custom SearchIcon style\n span,\n svg {\n height: 20px;\n width: 20px;\n }\n"])), "var(--ds-space-075, 6px)", "var(--ds-space-100, 8px)", "var(--ds-icon, ".concat(_colors.N200, ")"));
83
+ var elementAfterInput = (0, _react2.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n margin: 0 ", ";\n height: ", ";\n text-align: center;\n"])), "var(--ds-space-100, 8px)", _constants.SEARCH_ITEM_HEIGHT_WIDTH);
82
84
  var MemoizedElementSearchWithAnalytics = /*#__PURE__*/(0, _react.memo)((0, _analyticsNext.withAnalyticsContext)({
83
85
  component: 'Searchbar'
84
86
  })((0, _reactIntlNext.injectIntl)(ElementSearch)));
@@ -30,7 +30,7 @@ var baseBrowserContainerStyles = (0, _react2.css)(_templateObject2 || (_template
30
30
  var mobileElementBrowserContainer = (0, _react2.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n ", ";\n flex-direction: column;\n"])), baseBrowserContainerStyles);
31
31
  var elementBrowserContainer = (0, _react2.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n ", ";\n flex-direction: row;\n"])), baseBrowserContainerStyles);
32
32
  var baseSidebarStyles = (0, _react2.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n\n overflow-x: auto;\n overflow-y: hidden;\n"])));
33
- var mobileSideBar = (0, _react2.css)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n ", ";\n flex: 0 0 ", ";\n padding: 12px 12px 0 12px;\n"])), baseSidebarStyles, _constants.INLINE_SIDEBAR_HEIGHT);
33
+ var mobileSideBar = (0, _react2.css)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n ", ";\n flex: 0 0 ", ";\n padding: ", " ", " 0\n ", ";\n"])), baseSidebarStyles, _constants.INLINE_SIDEBAR_HEIGHT, "var(--ds-space-150, 12px)", "var(--ds-space-150, 12px)", "var(--ds-space-150, 12px)");
34
34
  var mobileSideBarShowCategories = (0, _react2.css)(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n flex: 0 0 auto;\n"])));
35
35
  var sideBar = (0, _react2.css)(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["\n ", ";\n flex: 0 0 'auto';\n"])), baseSidebarStyles);
36
36
  var sideBarShowCategories = (0, _react2.css)(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["\n ", ";\n flex: 0 0 ", ";\n"])), baseSidebarStyles, _constants.SIDEBAR_WIDTH);
@@ -43,6 +43,7 @@ var categoryListWrapper = (0, _react2.css)(_templateObject15 || (_templateObject
43
43
  function StatelessElementBrowser(props) {
44
44
  var items = props.items,
45
45
  onSelectItem = props.onSelectItem,
46
+ onInsertItem = props.onInsertItem,
46
47
  viewMoreItem = props.viewMoreItem;
47
48
  var _useContainerWidth = (0, _useContainerWidth2.default)(),
48
49
  containerWidth = _useContainerWidth.containerWidth,
@@ -92,10 +93,11 @@ function StatelessElementBrowser(props) {
92
93
  if (e.key !== 'Enter') {
93
94
  return;
94
95
  }
95
- if (onSelectItem && selectedItem != null) {
96
- onSelectItem(selectedItem);
96
+ if (onInsertItem && selectedItem != null) {
97
+ onInsertItem(selectedItem);
97
98
  }
98
- }, [onSelectItem, selectedItem]);
99
+ e.preventDefault();
100
+ }, [onInsertItem, selectedItem]);
99
101
 
100
102
  /**
101
103
  * On arrow key selection and clicks the selectedItemIndex will change.
@@ -156,13 +158,13 @@ function MobileBrowser(_ref) {
156
158
  viewMoreItem = _ref.viewMoreItem;
157
159
  return (0, _react2.jsx)("div", {
158
160
  css: mobileElementBrowserContainer,
159
- onKeyPress: onKeyPress,
160
161
  onKeyDown: onKeyDown,
161
162
  "data-testid": "mobile__element-browser"
162
163
  }, (0, _react2.jsx)("div", {
163
164
  css: showCategories ? [mobileSideBar, mobileSideBarShowCategories] : mobileSideBar
164
165
  }, showSearch && (0, _react2.jsx)(_ElementSearch.default, {
165
166
  onSearch: onSearch,
167
+ onKeyDown: onKeyPress,
166
168
  mode: mode,
167
169
  focus: focusOnSearch,
168
170
  onClick: setFocusOnSearch,
@@ -235,13 +237,13 @@ function DesktopBrowser(_ref2) {
235
237
  createAnalyticsEvent: createAnalyticsEvent
236
238
  }))), (0, _react2.jsx)("div", {
237
239
  css: mainContent,
238
- onKeyPress: onKeyPress,
239
240
  onKeyDown: onKeyDown,
240
241
  "data-testid": "main-content"
241
242
  }, showSearch && (0, _react2.jsx)("div", {
242
243
  css: searchContainer
243
244
  }, (0, _react2.jsx)(_ElementSearch.default, {
244
245
  onSearch: onSearch,
246
+ onKeyDown: onKeyPress,
245
247
  mode: mode,
246
248
  focus: focusOnSearch,
247
249
  onClick: setFocusOnSearch,
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("@emotion/react");
8
+ var _styles = require("./styles");
9
+ /** @jsx jsx */
10
+
11
+ var ResizeLabelBreakoutWidth = 110;
12
+ var ResizeLabel = function ResizeLabel(props) {
13
+ return (0, _react.jsx)("div", {
14
+ css: _styles.wrapper
15
+ }, (0, _react.jsx)("span", {
16
+ css: [_styles.text, props.containerWidth < ResizeLabelBreakoutWidth && _styles.smallText]
17
+ }, props.label));
18
+ };
19
+ var _default = ResizeLabel;
20
+ exports.default = _default;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.wrapper = exports.text = exports.smallText = void 0;
8
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
+ var _react = require("@emotion/react");
10
+ var _colors = require("@atlaskit/theme/colors");
11
+ var _templateObject, _templateObject2, _templateObject3;
12
+ var wrapper = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n font-size: ", ";\n width: 100%;\n text-align: center;\n position: absolute;\n transform: translateY(-125%);\n top: 0;\n"])), "var(--ds-font-size-100, 14px)");
13
+ exports.wrapper = wrapper;
14
+ var text = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n display: inline-block;\n border-radius: 6px;\n min-width: 75px;\n background-color: ", ";\n color: ", ";\n padding: ", " ", ";\n letter-spacing: 0.5px;\n"])), "var(--ds-text-accent-blue, ".concat(_colors.B300, ")"), "var(--ds-text-inverse, white)", "var(--ds-space-050, 4px)", "var(--ds-space-200, 16px)");
15
+ exports.text = text;
16
+ var smallText = (0, _react.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n letter-spacing: -0.5px;\n font-size: ", ";\n min-width: 27px;\n padding: ", " ", ";\n"])), "var(--ds-font-size-050, 8px)", "var(--ds-space-0, 0px)", "var(--ds-space-025, 2px)");
17
+ exports.smallText = smallText;
@@ -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.8.11";
9
+ var version = "187.9.0";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.8.11",
3
+ "version": "187.9.0",
4
4
  "sideEffects": false
5
5
  }
@@ -315,7 +315,7 @@ function floatingToolbarPluginFactory(options) {
315
315
  };
316
316
  const apply = (tr, pluginState) => {
317
317
  const newPluginState = {
318
- getConfigWithNodeInfo
318
+ ...pluginState
319
319
  };
320
320
  dispatch(pluginKey, newPluginState);
321
321
  return newPluginState;
@@ -1,4 +1,3 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
2
  /** @jsx jsx */
4
3
  import { jsx } from '@emotion/react';
@@ -8,6 +7,7 @@ import { MediaSingle, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaski
8
7
  import { browser, floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-common/utils';
9
8
  import { isNodeSelectedOrInRange } from '../../../utils/nodes';
10
9
  import { setNodeSelection, setTextSelection } from '../../../utils';
10
+ import ResizableMediaSingleNext from '../ui/ResizableMediaSingle/ResizableMediaSingleNext';
11
11
  import ResizableMediaSingle from '../ui/ResizableMediaSingle';
12
12
  import { MEDIA_CONTENT_WRAP_CLASS_NAME } from '../pm-plugins/main';
13
13
  import { MediaNodeUpdater } from './mediaNodeUpdater';
@@ -22,6 +22,8 @@ import CaptionPlaceholder from '../ui/CaptionPlaceholder';
22
22
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
23
23
  import { insertAndSelectCaptionFromMediaSinglePos } from '../commands/captions';
24
24
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
25
+ import { getMediaSinglePixelWidth } from '@atlaskit/editor-common/media-single';
26
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
25
27
  export default class MediaSingleNode extends Component {
26
28
  constructor(...args) {
27
29
  super(...args);
@@ -133,7 +135,8 @@ export default class MediaSingleNode extends Component {
133
135
  const tr = state.tr.setNodeMarkup(pos, undefined, {
134
136
  ...this.props.node.attrs,
135
137
  layout,
136
- width
138
+ width,
139
+ widthType: 'pixel'
137
140
  });
138
141
  tr.setMeta('scrollIntoView', false);
139
142
  /**
@@ -220,14 +223,21 @@ export default class MediaSingleNode extends Component {
220
223
  view: {
221
224
  state
222
225
  },
223
- view
226
+ view,
227
+ pluginInjectionApi,
228
+ width: containerWidth,
229
+ lineLength,
230
+ dispatchAnalyticsEvent
224
231
  } = this.props;
225
232
  const {
226
233
  layout,
227
- width: mediaSingleWidth
234
+ widthType,
235
+ width: mediaSingleWidthAttribute
228
236
  } = node.attrs;
229
237
  const childNode = node.firstChild;
230
238
  const attrs = childNode.attrs;
239
+
240
+ // original width and height of child media node (scaled)
231
241
  let {
232
242
  width,
233
243
  height
@@ -259,15 +269,29 @@ export default class MediaSingleNode extends Component {
259
269
  width = DEFAULT_IMAGE_WIDTH;
260
270
  height = DEFAULT_IMAGE_HEIGHT;
261
271
  }
272
+ const isSelected = selected();
262
273
  const mediaSingleProps = {
263
274
  layout,
264
275
  width,
265
276
  height,
266
- containerWidth: this.props.width,
267
- lineLength: this.props.lineLength,
268
- pctWidth: mediaSingleWidth,
277
+ containerWidth: containerWidth,
278
+ lineLength: this.getLineLength(view, getPos()) || lineLength,
279
+ pctWidth: mediaSingleWidthAttribute,
269
280
  fullWidthMode,
270
- hasFallbackContainer: false
281
+ hasFallbackContainer: false,
282
+ mediaSingleWidth: mediaSingleWidthAttribute && getMediaSinglePixelWidth(mediaSingleWidthAttribute, lineLength, widthType)
283
+ };
284
+ const ResizableMediaSingleProps = {
285
+ view: view,
286
+ getPos: getPos,
287
+ updateSize: this.updateSize,
288
+ gridSize: 12,
289
+ viewMediaClientConfig: this.state.viewMediaClientConfig,
290
+ allowBreakoutSnapPoints: mediaOptions && mediaOptions.allowBreakoutSnapPoints,
291
+ selected: isSelected,
292
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
293
+ pluginInjectionApi: pluginInjectionApi,
294
+ ...mediaSingleProps
271
295
  };
272
296
  let canResize = !!this.props.mediaOptions.allowResizing;
273
297
  if (!this.props.mediaOptions.allowResizingInTables) {
@@ -282,12 +306,10 @@ export default class MediaSingleNode extends Component {
282
306
  canResize = canResize && !disabledNode;
283
307
  }
284
308
  }
285
- const lineLength = this.getLineLength(view, getPos()) || this.props.lineLength;
286
- const isSelected = selected();
287
309
  const shouldShowPlaceholder = getMediaFeatureFlag('captions', mediaOptions.featureFlags) && node.childCount !== 2 && isSelected && state.selection instanceof NodeSelection;
288
310
  const MediaChildren = jsx("figure", {
289
311
  ref: this.mediaSingleWrapperRef,
290
- css: figureWrapper,
312
+ css: [figureWrapper],
291
313
  className: MediaSingleNodeSelector,
292
314
  onClick: this.onMediaSingleClicked
293
315
  }, jsx("div", {
@@ -296,18 +318,7 @@ export default class MediaSingleNode extends Component {
296
318
  ref: this.captionPlaceHolderRef,
297
319
  onClick: this.clickPlaceholder
298
320
  }));
299
- return canResize ? jsx(ResizableMediaSingle, _extends({}, mediaSingleProps, {
300
- lineLength: lineLength,
301
- view: this.props.view,
302
- getPos: getPos,
303
- updateSize: this.updateSize,
304
- gridSize: 12,
305
- viewMediaClientConfig: this.state.viewMediaClientConfig,
306
- allowBreakoutSnapPoints: mediaOptions && mediaOptions.allowBreakoutSnapPoints,
307
- selected: isSelected,
308
- dispatchAnalyticsEvent: this.props.dispatchAnalyticsEvent,
309
- pluginInjectionApi: this.props.pluginInjectionApi
310
- }), MediaChildren) : jsx(MediaSingle, mediaSingleProps, MediaChildren);
321
+ return canResize ? getBooleanFF('platform.editor.media.extended-resize-experience') ? jsx(ResizableMediaSingleNext, ResizableMediaSingleProps, MediaChildren) : jsx(ResizableMediaSingle, ResizableMediaSingleProps, MediaChildren) : jsx(MediaSingle, mediaSingleProps, MediaChildren);
311
322
  }
312
323
  }
313
324
  _defineProperty(MediaSingleNode, "defaultProps", {
@@ -16,8 +16,9 @@ import { LinkToolbarAppearance } from './linking-toolbar-appearance';
16
16
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
17
17
  import { messages } from '@atlaskit/media-ui';
18
18
  import { cardMessages } from '@atlaskit/editor-common/messages';
19
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
19
20
  import { FilePreviewItem } from './filePreviewItem';
20
- import { downloadMedia, removeMediaGroupNode } from './utils';
21
+ import { downloadMedia, getSelectedMediaSingle, removeMediaGroupNode } from './utils';
21
22
  import { changeInlineToMediaCard, changeMediaCardToInline, removeInlineCard, setBorderMark, toggleBorderMark } from './commands';
22
23
  import { MediaInlineNodeSelector, MediaSingleNodeSelector } from '../nodeviews/styles';
23
24
  import ImageBorderItem from '../ui/ImageBorder';
@@ -231,7 +232,22 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
231
232
  }
232
233
  if (allowAdvancedToolBarOptions) {
233
234
  var _pluginInjectionApi$d;
234
- const layoutButtons = buildLayoutButtons(state, intl, state.schema.nodes.mediaSingle, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.width, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions, allowResizing, allowResizingInTables);
235
+ const widthPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.width;
236
+ let isChangingLayoutDisabled = false;
237
+ if (getBooleanFF('platform.editor.media.extended-resize-experience')) {
238
+ var _widthPlugin$sharedSt;
239
+ const contentWidth = widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt === void 0 ? void 0 : _widthPlugin$sharedSt.lineLength;
240
+ const selectedNode = getSelectedMediaSingle(state);
241
+ if (selectedNode && contentWidth) {
242
+ const {
243
+ width
244
+ } = selectedNode.node.attrs;
245
+ if (width >= contentWidth) {
246
+ isChangingLayoutDisabled = true;
247
+ }
248
+ }
249
+ }
250
+ const layoutButtons = buildLayoutButtons(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled);
235
251
  toolbarButtons = [...toolbarButtons, ...layoutButtons];
236
252
  if (layoutButtons.length) {
237
253
  toolbarButtons.push({
@@ -342,7 +358,7 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
342
358
  const {
343
359
  hoverDecoration
344
360
  } = (_pluginInjectionApi$d4 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d4 !== void 0 ? _pluginInjectionApi$d4 : {};
345
- if (!mediaPluginState) {
361
+ if (!mediaPluginState || mediaPluginState.isResizing) {
346
362
  return;
347
363
  }
348
364
  const nodeType = allowMediaInline ? [mediaInline, mediaSingle, media] : [mediaSingle];
@@ -1,5 +1,5 @@
1
1
  import { getMediaClient } from '@atlaskit/media-client';
2
- import { findParentNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
2
+ import { findParentNodeOfType, removeParentNodeOfType, removeSelectedNode, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
3
3
  export const getSelectedMediaContainerNodeAttrs = mediaPluginState => {
4
4
  const selectedNode = mediaPluginState.selectedMediaContainerNode();
5
5
  if (selectedNode && selectedNode.attrs) {
@@ -40,4 +40,10 @@ export const removeMediaGroupNode = state => {
40
40
  tr = removeSelectedNode(tr);
41
41
  }
42
42
  return tr;
43
+ };
44
+ export const getSelectedMediaSingle = state => {
45
+ const {
46
+ mediaSingle
47
+ } = state.schema.nodes;
48
+ return findSelectedNodeOfType(mediaSingle)(state.selection) || findParentNodeOfType(mediaSingle)(state.selection);
43
49
  };