@atlaskit/editor-core 187.29.3 → 187.30.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 (48) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +9 -46
  3. package/dist/cjs/plugins/media/toolbar/index.js +14 -1
  4. package/dist/cjs/plugins/media/ui/PixelEntry/constants.js +8 -0
  5. package/dist/cjs/plugins/media/ui/PixelEntry/index.js +14 -1
  6. package/dist/cjs/plugins/media/ui/PixelEntry/messages.js +10 -0
  7. package/dist/cjs/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +26 -5
  8. package/dist/cjs/plugins/type-ahead/index.js +1 -0
  9. package/dist/cjs/version-wrapper.js +1 -1
  10. package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +4 -41
  11. package/dist/es2019/plugins/media/toolbar/index.js +16 -2
  12. package/dist/es2019/plugins/media/ui/PixelEntry/constants.js +1 -0
  13. package/dist/es2019/plugins/media/ui/PixelEntry/index.js +14 -1
  14. package/dist/es2019/plugins/media/ui/PixelEntry/messages.js +10 -0
  15. package/dist/es2019/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +27 -5
  16. package/dist/es2019/plugins/type-ahead/index.js +1 -0
  17. package/dist/es2019/version-wrapper.js +1 -1
  18. package/dist/esm/plugins/media/nodeviews/mediaSingle.js +4 -41
  19. package/dist/esm/plugins/media/toolbar/index.js +15 -2
  20. package/dist/esm/plugins/media/ui/PixelEntry/constants.js +1 -0
  21. package/dist/esm/plugins/media/ui/PixelEntry/index.js +14 -1
  22. package/dist/esm/plugins/media/ui/PixelEntry/messages.js +10 -0
  23. package/dist/esm/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +26 -5
  24. package/dist/esm/plugins/type-ahead/index.js +1 -0
  25. package/dist/esm/version-wrapper.js +1 -1
  26. package/dist/types/labs/next/presets/default.d.ts +8 -8
  27. package/dist/types/plugins/emoji/index.d.ts +1 -1
  28. package/dist/types/plugins/media/nodeviews/mediaSingle.d.ts +0 -12
  29. package/dist/types/plugins/media/ui/PixelEntry/constants.d.ts +1 -0
  30. package/dist/types/plugins/media/ui/PixelEntry/index.d.ts +1 -1
  31. package/dist/types/plugins/media/ui/PixelEntry/messages.d.ts +10 -0
  32. package/dist/types/plugins/media/ui/PixelEntry/types.d.ts +8 -0
  33. package/dist/types/plugins/type-ahead/api.d.ts +2 -1
  34. package/dist/types/plugins/type-ahead/index.d.ts +2 -13
  35. package/dist/types/plugins/type-ahead/types.d.ts +2 -3
  36. package/dist/types-ts4.5/labs/next/presets/default.d.ts +8 -8
  37. package/dist/types-ts4.5/plugins/emoji/index.d.ts +1 -1
  38. package/dist/types-ts4.5/plugins/media/nodeviews/mediaSingle.d.ts +0 -12
  39. package/dist/types-ts4.5/plugins/media/ui/PixelEntry/constants.d.ts +1 -0
  40. package/dist/types-ts4.5/plugins/media/ui/PixelEntry/index.d.ts +1 -1
  41. package/dist/types-ts4.5/plugins/media/ui/PixelEntry/messages.d.ts +10 -0
  42. package/dist/types-ts4.5/plugins/media/ui/PixelEntry/types.d.ts +8 -0
  43. package/dist/types-ts4.5/plugins/type-ahead/api.d.ts +2 -1
  44. package/dist/types-ts4.5/plugins/type-ahead/index.d.ts +2 -13
  45. package/dist/types-ts4.5/plugins/type-ahead/types.d.ts +2 -3
  46. package/package.json +4 -3
  47. package/report.api.md +2 -14
  48. package/tmp/api-report-tmp.d.ts +2 -10
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 187.30.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`7f45581d141`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7f45581d141) - ED-19630 fixed guideline alignment issue.
8
+
9
+ ### Patch Changes
10
+
11
+ - [`1e4b853a636`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1e4b853a636) - ED-19411 added guideline test, fixed invalid cursor location issue.
12
+ - Updated dependencies
13
+
14
+ ## 187.29.4
15
+
16
+ ### Patch Changes
17
+
18
+ - [`8595f0ddc4b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8595f0ddc4b) - Always show resizer handles when mediaSingle node is selected
19
+ - [`1af653a9630`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1af653a9630) - ED-19433 Initial scaffold for editor-plugin-type-ahead
20
+ - [`2f7d7be2983`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2f7d7be2983) - [ux] ED-19438 Added dark mode icons for headings 1 to 6
21
+ - [`1b917526a9f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1b917526a9f) - [ux] add convert to pixels cta in pixel entry for legacy experience
22
+ - Updated dependencies
23
+
3
24
  ## 187.29.3
4
25
 
5
26
  ### Patch Changes
@@ -24,7 +24,6 @@ var _ui = require("@atlaskit/editor-common/ui");
24
24
  var _utils = require("@atlaskit/editor-common/utils");
25
25
  var _nodes = require("../../../utils/nodes");
26
26
  var _utils2 = require("../../../utils");
27
- var _mediaSingle = require("../utils/media-single");
28
27
  var _ResizableMediaSingleNext = _interopRequireDefault(require("../ui/ResizableMediaSingle/ResizableMediaSingleNext"));
29
28
  var _ResizableMediaSingle = _interopRequireDefault(require("../ui/ResizableMediaSingle"));
30
29
  var _main = require("../pm-plugins/main");
@@ -40,7 +39,7 @@ var _CaptionPlaceholder = _interopRequireDefault(require("../ui/CaptionPlacehold
40
39
  var _state = require("@atlaskit/editor-prosemirror/state");
41
40
  var _captions = require("../commands/captions");
42
41
  var _hooks = require("@atlaskit/editor-common/hooks");
43
- var _mediaSingle2 = require("@atlaskit/editor-common/media-single");
42
+ var _mediaSingle = require("@atlaskit/editor-common/media-single");
44
43
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
45
44
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
46
45
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -251,42 +250,6 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
251
250
  }
252
251
  (0, _captions.insertAndSelectCaptionFromMediaSinglePos)(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)(getPos(), node)(view.state, view.dispatch);
253
252
  });
254
- /**
255
- * Get parent width for a nested media single node
256
- * @param view Editor view
257
- * @param pos node position
258
- */
259
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getLineLength", function (view, pos, includeMoreParentNodeTypes) {
260
- if (typeof pos !== 'number') {
261
- return null;
262
- }
263
- if ((0, _utils.isRichMediaInsideOfBlockNode)(view, pos)) {
264
- var $pos = view.state.doc.resolve(pos);
265
- var domNode = view.nodeDOM($pos.pos);
266
- if ($pos.nodeAfter && _utils.floatingLayouts.indexOf($pos.nodeAfter.attrs.layout) > -1 && domNode && domNode.parentElement) {
267
- return domNode.parentElement.offsetWidth;
268
- }
269
- if (domNode instanceof HTMLElement) {
270
- return domNode.offsetWidth;
271
- }
272
- }
273
- return null;
274
- });
275
- /**
276
- * Get parent width for a nested media single node for new experience
277
- * @param view Editor view
278
- * @param pos node position
279
- */
280
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getLineLengthNext", function (view, pos) {
281
- if (typeof pos !== 'number') {
282
- return null;
283
- }
284
- var $pos = view.state.doc.resolve(pos);
285
- if ($pos && $pos.parent.type.name !== 'doc') {
286
- return (0, _mediaSingle.getParentWidthForNestedMediaSingleNode)($pos, view);
287
- }
288
- return null;
289
- });
290
253
  return _this;
291
254
  }
292
255
  (0, _createClass2.default)(MediaSingleNode, [{
@@ -376,19 +339,19 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
376
339
  stateWidth = _this$state.width,
377
340
  stateHeight = _this$state.height;
378
341
  if (width === null) {
379
- width = stateWidth || _mediaSingle2.DEFAULT_IMAGE_WIDTH;
342
+ width = stateWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH;
380
343
  }
381
344
  if (height === null) {
382
- height = stateHeight || _mediaSingle2.DEFAULT_IMAGE_HEIGHT;
345
+ height = stateHeight || _mediaSingle.DEFAULT_IMAGE_HEIGHT;
383
346
  }
384
347
  }
385
348
  if (!width || !height) {
386
- width = _mediaSingle2.DEFAULT_IMAGE_WIDTH;
387
- height = _mediaSingle2.DEFAULT_IMAGE_HEIGHT;
349
+ width = _mediaSingle.DEFAULT_IMAGE_WIDTH;
350
+ height = _mediaSingle.DEFAULT_IMAGE_HEIGHT;
388
351
  }
389
352
  var isSelected = selected();
390
- var contentWidthForLegacyExperience = this.getLineLength(view, getPos()) || lineLength;
391
- var contentWidth = this.getLineLengthNext(view, getPos()) || lineLength;
353
+ var contentWidthForLegacyExperience = (0, _mediaSingle.getMaxWidthForNestedNode)(view, getPos()) || lineLength;
354
+ var contentWidth = (0, _mediaSingle.getMaxWidthForNestedNodeNext)(view, getPos()) || lineLength;
392
355
  var mediaSingleProps = {
393
356
  layout: layout,
394
357
  width: width,
@@ -398,7 +361,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
398
361
  pctWidth: mediaSingleWidthAttribute,
399
362
  fullWidthMode: fullWidthMode,
400
363
  hasFallbackContainer: false,
401
- mediaSingleWidth: (0, _mediaSingle2.calcMediaSinglePixelWidth)({
364
+ mediaSingleWidth: (0, _mediaSingle.calcMediaSinglePixelWidth)({
402
365
  width: mediaSingleWidthAttribute,
403
366
  widthType: widthType,
404
367
  origWidth: width,
@@ -407,7 +370,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
407
370
  // thus we use the legecy value (exclude table as container node)
408
371
  contentWidth: contentWidthForLegacyExperience,
409
372
  containerWidth: containerWidth,
410
- gutterOffset: _mediaSingle2.MEDIA_SINGLE_GUTTER_SIZE
373
+ gutterOffset: _mediaSingle.MEDIA_SINGLE_GUTTER_SIZE
411
374
  })
412
375
  };
413
376
  var resizableMediaSingleProps = _objectSpread({
@@ -288,18 +288,20 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
288
288
  var _selectedMediaNode$at = selectedMediaNode.attrs,
289
289
  mediaWidth = _selectedMediaNode$at.width,
290
290
  mediaHeight = _selectedMediaNode$at.height;
291
+ var isLegacy = widthType !== 'pixel';
291
292
  var pixelWidth = (0, _mediaSingle.calcMediaSinglePixelWidth)({
292
293
  width: singleMediaWidth,
293
294
  widthType: widthType,
294
295
  origWidth: mediaWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH,
295
296
  layout: layout,
296
- contentWidth: contentWidth,
297
+ contentWidth: (0, _mediaSingle.getMaxWidthForNestedNode)(editorView, selectedMediaSingleNode.pos) || contentWidth,
297
298
  containerWidth: containerWidth,
298
299
  gutterOffset: _mediaSingle.MEDIA_SINGLE_GUTTER_SIZE
299
300
  });
300
301
  return /*#__PURE__*/_react.default.createElement(_PixelEntry.PixelEntry, {
301
302
  intl: intl,
302
303
  width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
304
+ showMigration: !pluginState.isResizing && isLegacy,
303
305
  mediaWidth: mediaWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH,
304
306
  mediaHeight: mediaHeight || _mediaSingle.DEFAULT_IMAGE_HEIGHT,
305
307
  validate: function validate(value) {
@@ -314,6 +316,17 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
314
316
  width: width,
315
317
  widthType: 'pixel'
316
318
  }));
319
+ tr.setMeta('scrollIntoView', false);
320
+ tr.setSelection(_state2.NodeSelection.create(tr.doc, selectedMediaSingleNode.pos));
321
+ dispatch(tr);
322
+ },
323
+ onMigrate: function onMigrate() {
324
+ var tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, _objectSpread(_objectSpread({}, selectedMediaSingleNode.node.attrs), {}, {
325
+ width: pixelWidth,
326
+ widthType: 'pixel'
327
+ }));
328
+ tr.setMeta('scrollIntoView', false);
329
+ tr.setSelection(_state2.NodeSelection.create(tr.doc, selectedMediaSingleNode.pos));
317
330
  dispatch(tr);
318
331
  }
319
332
  });
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PIXELENTRY_MIGRATION_BUTTON_TESTID = void 0;
7
+ var PIXELENTRY_MIGRATION_BUTTON_TESTID = 'pixel-entry-convert-pixels-btn';
8
+ exports.PIXELENTRY_MIGRATION_BUTTON_TESTID = PIXELENTRY_MIGRATION_BUTTON_TESTID;
@@ -16,6 +16,7 @@ var _button = _interopRequireDefault(require("@atlaskit/button"));
16
16
  var _form = _interopRequireWildcard(require("@atlaskit/form"));
17
17
  var _styles = require("./styles");
18
18
  var _messages = require("./messages");
19
+ var _constants = require("./constants");
19
20
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
20
21
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
22
  /** @jsx jsx */
@@ -26,7 +27,9 @@ var PixelEntry = function PixelEntry(_ref) {
26
27
  mediaHeight = _ref.mediaHeight,
27
28
  onSubmit = _ref.onSubmit,
28
29
  validate = _ref.validate,
29
- formatMessage = _ref.intl.formatMessage;
30
+ formatMessage = _ref.intl.formatMessage,
31
+ showMigration = _ref.showMigration,
32
+ onMigrate = _ref.onMigrate;
30
33
  var ratioWidth = (0, _react2.useMemo)(function () {
31
34
  return mediaHeight / mediaWidth;
32
35
  }, [mediaHeight, mediaWidth]);
@@ -96,6 +99,16 @@ var PixelEntry = function PixelEntry(_ref) {
96
99
  }
97
100
  };
98
101
  }, [ratioHeight, ratioWidth]);
102
+ if (showMigration) {
103
+ return (0, _react.jsx)(_tooltip.default, {
104
+ content: formatMessage(_messages.messages.migrationButtonTooltip)
105
+ }, (0, _react.jsx)(_button.default, {
106
+ appearance: "warning",
107
+ spacing: "compact",
108
+ onClick: onMigrate,
109
+ testId: _constants.PIXELENTRY_MIGRATION_BUTTON_TESTID
110
+ }, formatMessage(_messages.messages.migrationButtonText)));
111
+ }
99
112
  return (0, _react.jsx)("div", {
100
113
  css: _styles.pixelEntryForm
101
114
  }, (0, _react.jsx)(_form.default, {
@@ -35,6 +35,16 @@ var messages = (0, _reactIntlNext.defineMessages)({
35
35
  id: 'fabric.editor.media.pixelEntry.submitButtonText',
36
36
  defaultMessage: 'Submit',
37
37
  description: 'The text give to the hidden submit button'
38
+ },
39
+ migrationButtonText: {
40
+ id: 'fabric.editor.media.pixelEntry.migrationButtonText',
41
+ defaultMessage: 'Convert to pixels',
42
+ description: 'The text give to the button used to covert to pixels for legacy experience'
43
+ },
44
+ migrationButtonTooltip: {
45
+ id: 'fabric.editor.media.pixelEntry.migrationButtonTooltip',
46
+ defaultMessage: 'Migrate from percentage to fixed pixel sizing',
47
+ description: 'The tooltip displayed on the migration button'
38
48
  }
39
49
  });
40
50
  exports.messages = messages;
@@ -36,6 +36,16 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
36
36
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
37
37
  var resizerNextTestId = 'mediaSingle.resizerNext.testid';
38
38
  exports.resizerNextTestId = resizerNextTestId;
39
+ var handleComponent = {
40
+ left: (0, _react2.jsx)("div", {
41
+ "data-testid": "richMedia-resize-handle-left-elem",
42
+ contentEditable: false
43
+ }),
44
+ right: (0, _react2.jsx)("div", {
45
+ "data-testid": "richMedia-resize-handle-right-elem",
46
+ contentEditable: false
47
+ })
48
+ };
39
49
  var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
40
50
  (0, _inherits2.default)(ResizableMediaSingleNext, _React$Component);
41
51
  var _super = _createSuper(ResizableMediaSingleNext);
@@ -153,11 +163,18 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
153
163
  return Math.min(contentWidth || _editorSharedStyles.akEditorDefaultLayoutWidth, isVideoFile ? _mediaSingle.MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH : _mediaSingle.MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH);
154
164
  }));
155
165
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getRelativeGuides", function () {
166
+ var _this$props$pluginInj5, _this$props$pluginInj6, _this$props$pluginInj7, _this$props$pluginInj8;
167
+ var guidelinePluginState = (_this$props$pluginInj5 = _this.props.pluginInjectionApi) === null || _this$props$pluginInj5 === void 0 ? void 0 : (_this$props$pluginInj6 = _this$props$pluginInj5.dependencies) === null || _this$props$pluginInj6 === void 0 ? void 0 : (_this$props$pluginInj7 = _this$props$pluginInj6.guideline) === null || _this$props$pluginInj7 === void 0 ? void 0 : (_this$props$pluginInj8 = _this$props$pluginInj7.sharedState) === null || _this$props$pluginInj8 === void 0 ? void 0 : _this$props$pluginInj8.currentState();
168
+ var _ref = (guidelinePluginState === null || guidelinePluginState === void 0 ? void 0 : guidelinePluginState.rect) || {
169
+ top: 0,
170
+ left: 0
171
+ },
172
+ topOffset = _ref.top;
156
173
  var $pos = _this.$pos;
157
174
  var relativeGuides = $pos && $pos.nodeAfter && _this.state.size.width ? (0, _guideline.getRelativeGuidelines)(_this.state.relativeGuides, {
158
175
  node: $pos.nodeAfter,
159
176
  pos: $pos.pos
160
- }, _this.props.view, _this.props.lineLength, _this.state.size) : [];
177
+ }, _this.props.view, _this.props.lineLength, topOffset, _this.state.size) : [];
161
178
  return relativeGuides;
162
179
  });
163
180
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateActiveGuidelines", function () {
@@ -185,8 +202,10 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
185
202
  });
186
203
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "selectCurrentMediaNode", function () {
187
204
  // TODO: if adding !this.props.selected, it doesn't work if media single node is at top postion
188
- var pos = _this.pos;
189
- pos && (0, _utils2.setNodeSelection)(_this.props.view, pos);
205
+ if (_this.pos === null) {
206
+ return;
207
+ }
208
+ (0, _utils2.setNodeSelection)(_this.props.view, _this.pos);
190
209
  });
191
210
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleResizeStart", function () {
192
211
  _this.setState({
@@ -413,7 +432,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
413
432
  key: "isNestedNode",
414
433
  value: function isNestedNode() {
415
434
  var $pos = this.$pos;
416
- return !!($pos && $pos.parent.type !== $pos.parent.type.schema.nodes.doc);
435
+ return !!($pos && $pos.depth !== 0);
417
436
  }
418
437
  }, {
419
438
  key: "getDefaultGuidelines",
@@ -537,7 +556,9 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
537
556
  handleResizeStop: this.handleResizeStop,
538
557
  snap: this.state.snaps,
539
558
  resizeRatio: _utils2.nonWrappedLayouts.includes(layout) ? 2 : 1,
540
- "data-testid": resizerNextTestId
559
+ handleComponent: handleComponent,
560
+ "data-testid": resizerNextTestId,
561
+ isHandleVisible: selected
541
562
  }, children));
542
563
  }
543
564
  }]);
@@ -118,6 +118,7 @@ var TypeAheadMenu = /*#__PURE__*/_react.default.memo(function (_ref) {
118
118
  cancel: cancel
119
119
  });
120
120
  });
121
+
121
122
  /**
122
123
  *
123
124
  * Revamped typeahead using decorations instead of the `typeAheadQuery` mark
@@ -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.29.3";
9
+ var version = "187.30.0";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -5,10 +5,9 @@ import { jsx } from '@emotion/react';
5
5
  import React, { Component } from 'react';
6
6
  import { WithProviders } from '@atlaskit/editor-common/provider-factory';
7
7
  import { MediaSingle } from '@atlaskit/editor-common/ui';
8
- import { browser, floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-common/utils';
8
+ import { browser } from '@atlaskit/editor-common/utils';
9
9
  import { isNodeSelectedOrInRange } from '../../../utils/nodes';
10
10
  import { setNodeSelection, setTextSelection } from '../../../utils';
11
- import { getParentWidthForNestedMediaSingleNode } from '../utils/media-single';
12
11
  import ResizableMediaSingleNext from '../ui/ResizableMediaSingle/ResizableMediaSingleNext';
13
12
  import ResizableMediaSingle from '../ui/ResizableMediaSingle';
14
13
  import { MEDIA_CONTENT_WRAP_CLASS_NAME } from '../pm-plugins/main';
@@ -24,7 +23,7 @@ import CaptionPlaceholder from '../ui/CaptionPlaceholder';
24
23
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
25
24
  import { insertAndSelectCaptionFromMediaSinglePos } from '../commands/captions';
26
25
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
27
- import { calcMediaSinglePixelWidth, MEDIA_SINGLE_GUTTER_SIZE, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
26
+ import { calcMediaSinglePixelWidth, MEDIA_SINGLE_GUTTER_SIZE, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH, getMaxWidthForNestedNode, getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
28
27
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
29
28
  export default class MediaSingleNode extends Component {
30
29
  constructor(...args) {
@@ -177,42 +176,6 @@ export default class MediaSingleNode extends Component {
177
176
  }
178
177
  insertAndSelectCaptionFromMediaSinglePos(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)(getPos(), node)(view.state, view.dispatch);
179
178
  });
180
- /**
181
- * Get parent width for a nested media single node
182
- * @param view Editor view
183
- * @param pos node position
184
- */
185
- _defineProperty(this, "getLineLength", (view, pos, includeMoreParentNodeTypes) => {
186
- if (typeof pos !== 'number') {
187
- return null;
188
- }
189
- if (isRichMediaInsideOfBlockNode(view, pos)) {
190
- const $pos = view.state.doc.resolve(pos);
191
- const domNode = view.nodeDOM($pos.pos);
192
- if ($pos.nodeAfter && floatingLayouts.indexOf($pos.nodeAfter.attrs.layout) > -1 && domNode && domNode.parentElement) {
193
- return domNode.parentElement.offsetWidth;
194
- }
195
- if (domNode instanceof HTMLElement) {
196
- return domNode.offsetWidth;
197
- }
198
- }
199
- return null;
200
- });
201
- /**
202
- * Get parent width for a nested media single node for new experience
203
- * @param view Editor view
204
- * @param pos node position
205
- */
206
- _defineProperty(this, "getLineLengthNext", (view, pos) => {
207
- if (typeof pos !== 'number') {
208
- return null;
209
- }
210
- const $pos = view.state.doc.resolve(pos);
211
- if ($pos && $pos.parent.type.name !== 'doc') {
212
- return getParentWidthForNestedMediaSingleNode($pos, view);
213
- }
214
- return null;
215
- });
216
179
  }
217
180
  UNSAFE_componentWillReceiveProps(nextProps) {
218
181
  if (nextProps.mediaProvider !== this.props.mediaProvider) {
@@ -294,8 +257,8 @@ export default class MediaSingleNode extends Component {
294
257
  height = DEFAULT_IMAGE_HEIGHT;
295
258
  }
296
259
  const isSelected = selected();
297
- const contentWidthForLegacyExperience = this.getLineLength(view, getPos()) || lineLength;
298
- const contentWidth = this.getLineLengthNext(view, getPos()) || lineLength;
260
+ const contentWidthForLegacyExperience = getMaxWidthForNestedNode(view, getPos()) || lineLength;
261
+ const contentWidth = getMaxWidthForNestedNodeNext(view, getPos()) || lineLength;
299
262
  const mediaSingleProps = {
300
263
  layout,
301
264
  width,
@@ -25,7 +25,7 @@ import ImageBorderItem from '../ui/ImageBorder';
25
25
  import { currentMediaNodeBorderMark } from '../utils/current-media-node';
26
26
  import { shouldShowImageBorder } from './imageBorder';
27
27
  import { PixelEntry } from '../ui/PixelEntry';
28
- import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_GUTTER_SIZE, calcMediaSinglePixelWidth } from '@atlaskit/editor-common/media-single';
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
29
  import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
30
30
  const remove = (state, dispatch) => {
31
31
  if (dispatch) {
@@ -293,18 +293,20 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
293
293
  width: mediaWidth,
294
294
  height: mediaHeight
295
295
  } = selectedMediaNode.attrs;
296
+ const isLegacy = widthType !== 'pixel';
296
297
  const pixelWidth = calcMediaSinglePixelWidth({
297
298
  width: singleMediaWidth,
298
299
  widthType,
299
300
  origWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
300
301
  layout,
301
- contentWidth,
302
+ contentWidth: getMaxWidthForNestedNode(editorView, selectedMediaSingleNode.pos) || contentWidth,
302
303
  containerWidth,
303
304
  gutterOffset: MEDIA_SINGLE_GUTTER_SIZE
304
305
  });
305
306
  return /*#__PURE__*/React.createElement(PixelEntry, {
306
307
  intl: intl,
307
308
  width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
309
+ showMigration: !pluginState.isResizing && isLegacy,
308
310
  mediaWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
309
311
  mediaHeight: mediaHeight || DEFAULT_IMAGE_HEIGHT,
310
312
  validate: value => {
@@ -321,6 +323,18 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
321
323
  width,
322
324
  widthType: 'pixel'
323
325
  });
326
+ tr.setMeta('scrollIntoView', false);
327
+ tr.setSelection(NodeSelection.create(tr.doc, selectedMediaSingleNode.pos));
328
+ dispatch(tr);
329
+ },
330
+ onMigrate: () => {
331
+ const tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, {
332
+ ...selectedMediaSingleNode.node.attrs,
333
+ width: pixelWidth,
334
+ widthType: 'pixel'
335
+ });
336
+ tr.setMeta('scrollIntoView', false);
337
+ tr.setSelection(NodeSelection.create(tr.doc, selectedMediaSingleNode.pos));
324
338
  dispatch(tr);
325
339
  }
326
340
  });
@@ -0,0 +1 @@
1
+ export const PIXELENTRY_MIGRATION_BUTTON_TESTID = 'pixel-entry-convert-pixels-btn';
@@ -8,6 +8,7 @@ import Button from '@atlaskit/button';
8
8
  import Form, { Field } from '@atlaskit/form';
9
9
  import { pixelSizingInput, pixelSizingLabel, pixelSizingWidthInput, pixelSizingHeightInput, pixelSizingWrapper, pixelEntryForm, pixelEntryHiddenSubmit } from './styles';
10
10
  import { messages } from './messages';
11
+ import { PIXELENTRY_MIGRATION_BUTTON_TESTID } from './constants';
11
12
  export const PixelEntry = ({
12
13
  width,
13
14
  mediaWidth,
@@ -16,7 +17,9 @@ export const PixelEntry = ({
16
17
  validate,
17
18
  intl: {
18
19
  formatMessage
19
- }
20
+ },
21
+ showMigration,
22
+ onMigrate
20
23
  }) => {
21
24
  const ratioWidth = useMemo(() => {
22
25
  return mediaHeight / mediaWidth;
@@ -79,6 +82,16 @@ export const PixelEntry = ({
79
82
  }
80
83
  }
81
84
  }, [ratioHeight, ratioWidth]);
85
+ if (showMigration) {
86
+ return jsx(Tooltip, {
87
+ content: formatMessage(messages.migrationButtonTooltip)
88
+ }, jsx(Button, {
89
+ appearance: "warning",
90
+ spacing: "compact",
91
+ onClick: onMigrate,
92
+ testId: PIXELENTRY_MIGRATION_BUTTON_TESTID
93
+ }, formatMessage(messages.migrationButtonText)));
94
+ }
82
95
  return jsx("div", {
83
96
  css: pixelEntryForm
84
97
  }, jsx(Form, {
@@ -29,5 +29,15 @@ export const messages = defineMessages({
29
29
  id: 'fabric.editor.media.pixelEntry.submitButtonText',
30
30
  defaultMessage: 'Submit',
31
31
  description: 'The text give to the hidden submit button'
32
+ },
33
+ migrationButtonText: {
34
+ id: 'fabric.editor.media.pixelEntry.migrationButtonText',
35
+ defaultMessage: 'Convert to pixels',
36
+ description: 'The text give to the button used to covert to pixels for legacy experience'
37
+ },
38
+ migrationButtonTooltip: {
39
+ id: 'fabric.editor.media.pixelEntry.migrationButtonTooltip',
40
+ defaultMessage: 'Migrate from percentage to fixed pixel sizing',
41
+ description: 'The tooltip displayed on the migration button'
32
42
  }
33
43
  });
@@ -18,6 +18,16 @@ import { getMediaResizeAnalyticsEvent } from '../../utils/analytics';
18
18
  import throttle from 'lodash/throttle';
19
19
  import { MEDIA_PLUGIN_IS_RESIZING_KEY, MEDIA_PLUGIN_RESIZING_WIDTH_KEY } from '../../pm-plugins/main';
20
20
  export const resizerNextTestId = 'mediaSingle.resizerNext.testid';
21
+ const handleComponent = {
22
+ left: jsx("div", {
23
+ "data-testid": "richMedia-resize-handle-left-elem",
24
+ contentEditable: false
25
+ }),
26
+ right: jsx("div", {
27
+ "data-testid": "richMedia-resize-handle-right-elem",
28
+ contentEditable: false
29
+ })
30
+ };
21
31
  class ResizableMediaSingleNext extends React.Component {
22
32
  constructor(props) {
23
33
  super(props);
@@ -136,11 +146,19 @@ class ResizableMediaSingleNext extends React.Component {
136
146
  return Math.min(contentWidth || akEditorDefaultLayoutWidth, isVideoFile ? MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH : MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH);
137
147
  }));
138
148
  _defineProperty(this, "getRelativeGuides", () => {
149
+ var _this$props$pluginInj5, _this$props$pluginInj6, _this$props$pluginInj7, _this$props$pluginInj8;
150
+ const guidelinePluginState = (_this$props$pluginInj5 = this.props.pluginInjectionApi) === null || _this$props$pluginInj5 === void 0 ? void 0 : (_this$props$pluginInj6 = _this$props$pluginInj5.dependencies) === null || _this$props$pluginInj6 === void 0 ? void 0 : (_this$props$pluginInj7 = _this$props$pluginInj6.guideline) === null || _this$props$pluginInj7 === void 0 ? void 0 : (_this$props$pluginInj8 = _this$props$pluginInj7.sharedState) === null || _this$props$pluginInj8 === void 0 ? void 0 : _this$props$pluginInj8.currentState();
151
+ const {
152
+ top: topOffset
153
+ } = (guidelinePluginState === null || guidelinePluginState === void 0 ? void 0 : guidelinePluginState.rect) || {
154
+ top: 0,
155
+ left: 0
156
+ };
139
157
  const $pos = this.$pos;
140
158
  const relativeGuides = $pos && $pos.nodeAfter && this.state.size.width ? getRelativeGuidelines(this.state.relativeGuides, {
141
159
  node: $pos.nodeAfter,
142
160
  pos: $pos.pos
143
- }, this.props.view, this.props.lineLength, this.state.size) : [];
161
+ }, this.props.view, this.props.lineLength, topOffset, this.state.size) : [];
144
162
  return relativeGuides;
145
163
  });
146
164
  _defineProperty(this, "updateActiveGuidelines", (width = 0, guidelines, guidelineSnapsReference) => {
@@ -165,8 +183,10 @@ class ResizableMediaSingleNext extends React.Component {
165
183
  });
166
184
  _defineProperty(this, "selectCurrentMediaNode", () => {
167
185
  // TODO: if adding !this.props.selected, it doesn't work if media single node is at top postion
168
- const pos = this.pos;
169
- pos && setNodeSelection(this.props.view, pos);
186
+ if (this.pos === null) {
187
+ return;
188
+ }
189
+ setNodeSelection(this.props.view, this.pos);
170
190
  });
171
191
  _defineProperty(this, "handleResizeStart", () => {
172
192
  this.setState({
@@ -364,7 +384,7 @@ class ResizableMediaSingleNext extends React.Component {
364
384
  // check if is inside of layout, table, expand, nestedExpand and list item
365
385
  isNestedNode() {
366
386
  const $pos = this.$pos;
367
- return !!($pos && $pos.parent.type !== $pos.parent.type.schema.nodes.doc);
387
+ return !!($pos && $pos.depth !== 0);
368
388
  }
369
389
  getDefaultGuidelines() {
370
390
  const {
@@ -457,7 +477,9 @@ class ResizableMediaSingleNext extends React.Component {
457
477
  handleResizeStop: this.handleResizeStop,
458
478
  snap: this.state.snaps,
459
479
  resizeRatio: nonWrappedLayouts.includes(layout) ? 2 : 1,
460
- "data-testid": resizerNextTestId
480
+ handleComponent: handleComponent,
481
+ "data-testid": resizerNextTestId,
482
+ isHandleVisible: selected
461
483
  }, children));
462
484
  }
463
485
  }
@@ -102,6 +102,7 @@ const TypeAheadMenu = /*#__PURE__*/React.memo(({
102
102
  cancel: cancel
103
103
  });
104
104
  });
105
+
105
106
  /**
106
107
  *
107
108
  * Revamped typeahead using decorations instead of the `typeAheadQuery` mark
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.29.3";
2
+ export const version = "187.30.0";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };