@atlaskit/editor-core 187.27.0 → 187.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 187.27.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`719a3a60441`](https://bitbucket.org/atlassian/atlassian-frontend/commits/719a3a60441) - ED-19411 minor refactor of ResizableMediaSingleNext
8
+
3
9
  ## 187.27.0
4
10
 
5
11
  ### Minor Changes
@@ -111,10 +111,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
111
111
  // so that we have image aligned with text
112
112
  return 'full-width';
113
113
  });
114
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "calcColumnLeftOffset", function () {
115
- var offsetLeft = _this.state.offsetLeft;
116
- return _this.insideInlineLike ? (0, _ui.calcColumnsFromPx)(offsetLeft, _this.props.lineLength, _this.props.gridSize) : 0;
117
- });
118
114
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "calcPxHeight", function (newWidth) {
119
115
  var _this$props3 = _this.props,
120
116
  _this$props3$width = _this$props3.width,
@@ -126,9 +122,8 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
126
122
  return _this.wrapper = wrapper;
127
123
  });
128
124
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "displayGuideline", function (guidelines) {
129
- var _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$d3;
130
- var pluginInjectionApi = _this.props.pluginInjectionApi;
131
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.guideline) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : (_pluginInjectionApi$d3 = _pluginInjectionApi$d2.actions) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : _pluginInjectionApi$d3.displayGuideline(_this.props.view)({
125
+ var _this$props$pluginInj, _this$props$pluginInj2, _this$props$pluginInj3, _this$props$pluginInj4;
126
+ return (_this$props$pluginInj = _this.props.pluginInjectionApi) === null || _this$props$pluginInj === void 0 ? void 0 : (_this$props$pluginInj2 = _this$props$pluginInj.dependencies) === null || _this$props$pluginInj2 === void 0 ? void 0 : (_this$props$pluginInj3 = _this$props$pluginInj2.guideline) === null || _this$props$pluginInj3 === void 0 ? void 0 : (_this$props$pluginInj4 = _this$props$pluginInj3.actions) === null || _this$props$pluginInj4 === void 0 ? void 0 : _this$props$pluginInj4.displayGuideline(_this.props.view)({
132
127
  guidelines: guidelines
133
128
  });
134
129
  });
@@ -155,9 +150,10 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
155
150
  return (0, _mediaSingle.calcMediaSingleMaxWidth)(containerWidth);
156
151
  }));
157
152
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getRelativeGuides", function () {
158
- var relativeGuides = _this.$pos && _this.$pos.nodeAfter && _this.state.size.width ? (0, _guideline.getRelativeGuidelines)(_this.state.relativeGuides, {
159
- node: _this.$pos.nodeAfter,
160
- pos: _this.$pos.pos
153
+ var $pos = _this.$pos;
154
+ var relativeGuides = $pos && $pos.nodeAfter && _this.state.size.width ? (0, _guideline.getRelativeGuidelines)(_this.state.relativeGuides, {
155
+ node: $pos.nodeAfter,
156
+ pos: $pos.pos
161
157
  }, _this.props.view, _this.props.lineLength, _this.state.size) : [];
162
158
  return relativeGuides;
163
159
  });
@@ -174,57 +170,20 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
174
170
  _this.displayGuideline([].concat((0, _toConsumableArray2.default)((0, _guideline.getGuidelinesWithHighlights)(gap, _mediaSingle.MEDIA_SINGLE_SNAP_GAP, activeGuidelineKeys, guidelines)), (0, _toConsumableArray2.default)(relativeGuidelines)));
175
171
  }
176
172
  });
177
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "roundPixelValue", function (value) {
178
- return Math.round(value);
179
- });
180
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getHeightFromNewWidth", function (originalWidth, originalHeight, newWidth) {
181
- return _this.roundPixelValue(originalHeight / originalWidth * newWidth);
182
- });
183
173
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "calculateSizeState", function (size, delta) {
184
- var originalWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
185
- var originalHeight = arguments.length > 3 ? arguments[3] : undefined;
186
- var onResizeStop = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
187
- var calculatedWidth = _this.roundPixelValue(size.width + delta.width);
174
+ var onResizeStop = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
175
+ var calculatedWidth = Math.round(size.width + delta.width);
188
176
  var calculatedWidthWithLayout = _this.calcNewSize(calculatedWidth, onResizeStop);
189
- var calculatedHeightWithLayout = _this.getHeightFromNewWidth(originalWidth, originalHeight, calculatedWidth);
190
177
  return {
191
178
  width: calculatedWidth,
192
- height: calculatedHeightWithLayout,
179
+ height: calculatedWidth / _this.aspectRatio,
193
180
  calculatedWidthWithLayout: calculatedWidthWithLayout
194
181
  };
195
182
  });
196
183
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "selectCurrentMediaNode", function () {
197
184
  // TODO: if adding !this.props.selected, it doesn't work if media single node is at top postion
198
- if (typeof _this.props.getPos === 'function') {
199
- var propPos = _this.props.getPos();
200
- if (propPos !== undefined) {
201
- (0, _utils2.setNodeSelection)(_this.props.view, propPos);
202
- }
203
- }
204
- });
205
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getParentNodeTypeNameFromCurrentPositionNode", function () {
206
- var $pos = _this.$pos;
207
- if (!$pos) {
208
- return undefined;
209
- }
210
-
211
- // Supported Parent Nodes
212
- var _this$props$view$stat = _this.props.view.state.schema.nodes,
213
- listItem = _this$props$view$stat.listItem,
214
- expand = _this$props$view$stat.expand,
215
- tableCell = _this$props$view$stat.tableCell,
216
- tableHeader = _this$props$view$stat.tableHeader,
217
- layoutSection = _this$props$view$stat.layoutSection,
218
- nestedExpand = _this$props$view$stat.nestedExpand;
219
- var parentNode = (0, _utils.findParentNodeOfTypeClosestToPos)($pos, [listItem, expand, tableCell, tableHeader, layoutSection, nestedExpand]);
220
-
221
- // Return matched parent node name
222
- if (parentNode) {
223
- return parentNode.node.type.name;
224
- }
225
-
226
- // Return undefined if parent node cannot be found
227
- return undefined;
185
+ var pos = _this.pos;
186
+ pos && (0, _utils2.setNodeSelection)(_this.props.view, pos);
228
187
  });
229
188
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleResizeStart", function () {
230
189
  _this.setState({
@@ -233,17 +192,15 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
233
192
  _this.selectCurrentMediaNode();
234
193
  _this.setIsResizing(true);
235
194
  _this.updateSizeInPluginState(_this.state.size.width);
236
- // re-calucate guidelines
195
+ // re-calculate guidelines
237
196
  _this.updateGuidelines();
238
197
  });
239
198
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleResize", function (size, delta) {
240
199
  var _this$props4 = _this.props,
241
- originalWidth = _this$props4.width,
242
- originalHeight = _this$props4.height,
243
200
  layout = _this$props4.layout,
244
201
  updateSize = _this$props4.updateSize,
245
202
  lineLength = _this$props4.lineLength;
246
- var _this$calculateSizeSt = _this.calculateSizeState(size, delta, originalWidth, originalHeight),
203
+ var _this$calculateSizeSt = _this.calculateSizeState(size, delta),
247
204
  width = _this$calculateSizeSt.width,
248
205
  height = _this$calculateSizeSt.height,
249
206
  calculatedWidthWithLayout = _this$calculateSizeSt.calculatedWidthWithLayout;
@@ -266,22 +223,21 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
266
223
  });
267
224
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleResizeStop", function (size, delta) {
268
225
  var _this$props5 = _this.props,
269
- originalWidth = _this$props5.width,
270
- originalHeight = _this$props5.height,
271
226
  updateSize = _this$props5.updateSize,
272
227
  dispatchAnalyticsEvent = _this$props5.dispatchAnalyticsEvent,
273
228
  nodeType = _this$props5.nodeType;
274
- var _this$calculateSizeSt2 = _this.calculateSizeState(size, delta, originalWidth, originalHeight, true),
229
+ var _this$calculateSizeSt2 = _this.calculateSizeState(size, delta, true),
275
230
  width = _this$calculateSizeSt2.width,
276
231
  height = _this$calculateSizeSt2.height,
277
232
  calculatedWidthWithLayout = _this$calculateSizeSt2.calculatedWidthWithLayout;
278
233
  if (dispatchAnalyticsEvent) {
234
+ var $pos = _this.$pos;
279
235
  var event = (0, _analytics.getMediaResizeAnalyticsEvent)(nodeType || 'mediaSingle', {
280
236
  width: width,
281
237
  layout: calculatedWidthWithLayout.layout,
282
238
  widthType: 'pixel',
283
239
  snapType: (0, _guideline.getGuidelineTypeFromKey)(_this.lastSnappedGuidelineKeys, _this.state.guidelines),
284
- parentNode: _this.getParentNodeTypeNameFromCurrentPositionNode()
240
+ parentNode: $pos ? $pos.parent.type.name : undefined
285
241
  });
286
242
  if (event) {
287
243
  dispatchAnalyticsEvent(event);
@@ -315,23 +271,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
315
271
  };
316
272
  return _this;
317
273
  }
318
-
319
- /**
320
- * Calculate media single node initial width if props.mediaSingleWidth is undefined
321
- * (Mainly when switching from lagacy experience to new experience).
322
- *
323
- * @returns initial width in pixel
324
- */
325
274
  (0, _createClass2.default)(ResizableMediaSingleNext, [{
326
- key: "calcInitialWidth",
327
- value: function calcInitialWidth() {
328
- var _this$props6 = this.props,
329
- origWidth = _this$props6.width,
330
- contentWidth = _this$props6.lineLength,
331
- containerWidth = _this$props6.containerWidth;
332
- return Math.max(Math.min(origWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH, contentWidth || containerWidth || _editorSharedStyles.akEditorDefaultLayoutWidth), _mediaSingle.MEDIA_SINGLE_MIN_PIXEL_WIDTH);
333
- }
334
- }, {
335
275
  key: "componentDidUpdate",
336
276
  value: function componentDidUpdate(prevProps) {
337
277
  var _this2 = this;
@@ -374,29 +314,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
374
314
  }
375
315
  return true;
376
316
  }
377
-
378
- // check if is inside of layout, table, expand, nestedExpand and list item
379
- }, {
380
- key: "isNestedNode",
381
- value: function isNestedNode() {
382
- return !!(this.$pos && this.$pos.parent.type.name !== 'doc');
383
- }
384
- }, {
385
- key: "getDefaultGuidelines",
386
- value: function getDefaultGuidelines() {
387
- var _this$props7 = this.props,
388
- lineLength = _this$props7.lineLength,
389
- containerWidth = _this$props7.containerWidth,
390
- fullWidthMode = _this$props7.fullWidthMode;
391
-
392
- // disable guidelines for nested media single node
393
- return this.isNestedNode() ? [] : (0, _guideline.generateDefaultGuidelines)(lineLength, containerWidth, fullWidthMode);
394
- }
395
- }, {
396
- key: "wrappedLayout",
397
- get: function get() {
398
- return _ui.wrappedLayouts.indexOf(this.props.layout) > -1;
399
- }
400
317
  }, {
401
318
  key: "componentDidMount",
402
319
  value: function () {
@@ -430,18 +347,82 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
430
347
  this.checkVideoFile(nextProps.viewMediaClientConfig);
431
348
  }
432
349
  }
350
+ }, {
351
+ key: "wrappedLayout",
352
+ get: function get() {
353
+ return _ui.wrappedLayouts.indexOf(this.props.layout) > -1;
354
+ }
355
+ }, {
356
+ key: "pos",
357
+ get: function get() {
358
+ if (typeof this.props.getPos !== 'function') {
359
+ return null;
360
+ }
361
+ var pos = this.props.getPos();
362
+ if (Number.isNaN(pos) || typeof pos !== 'number') {
363
+ return null;
364
+ }
365
+ return pos;
366
+ }
367
+ }, {
368
+ key: "$pos",
369
+ get: function get() {
370
+ var pos = this.pos;
371
+ // need to pass view because we may not get updated props in time
372
+ return pos && this.props.view.state.doc.resolve(pos);
373
+ }
433
374
  }, {
434
375
  key: "aspectRatio",
435
376
  get: function get() {
436
- var _this$props8 = this.props,
437
- width = _this$props8.width,
438
- height = _this$props8.height;
377
+ var _this$props6 = this.props,
378
+ width = _this$props6.width,
379
+ height = _this$props6.height;
439
380
  if (width) {
440
381
  return width / height;
441
382
  }
383
+
442
384
  // TODO handle this case
443
385
  return 1;
444
386
  }
387
+ }, {
388
+ key: "insideInlineLike",
389
+ get: function get() {
390
+ var $pos = this.$pos;
391
+ if (!$pos) {
392
+ return false;
393
+ }
394
+ var listItem = this.props.view.state.schema.nodes.listItem;
395
+ return !!(0, _utils.findParentNodeOfTypeClosestToPos)($pos, [listItem]);
396
+ }
397
+ }, {
398
+ key: "insideLayout",
399
+ get: function get() {
400
+ var $pos = this.$pos;
401
+ if (!$pos) {
402
+ return false;
403
+ }
404
+ var layoutColumn = this.props.view.state.schema.nodes.layoutColumn;
405
+ return !!(0, _utils.findParentNodeOfTypeClosestToPos)($pos, [layoutColumn]);
406
+ }
407
+
408
+ // check if is inside of layout, table, expand, nestedExpand and list item
409
+ }, {
410
+ key: "isNestedNode",
411
+ value: function isNestedNode() {
412
+ var $pos = this.$pos;
413
+ return !!($pos && $pos.parent.type !== $pos.parent.type.schema.nodes.doc);
414
+ }
415
+ }, {
416
+ key: "getDefaultGuidelines",
417
+ value: function getDefaultGuidelines() {
418
+ var _this$props7 = this.props,
419
+ lineLength = _this$props7.lineLength,
420
+ containerWidth = _this$props7.containerWidth,
421
+ fullWidthMode = _this$props7.fullWidthMode;
422
+
423
+ // disable guidelines for nested media single node
424
+ return this.isNestedNode() ? [] : (0, _guideline.generateDefaultGuidelines)(lineLength, containerWidth, fullWidthMode);
425
+ }
445
426
  }, {
446
427
  key: "checkVideoFile",
447
428
  value: function () {
@@ -496,63 +477,19 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
496
477
  }
497
478
  return checkVideoFile;
498
479
  }()
499
- }, {
500
- key: "$pos",
501
- get: function get() {
502
- if (typeof this.props.getPos !== 'function') {
503
- return null;
504
- }
505
- var pos = this.props.getPos();
506
- if (Number.isNaN(pos) || typeof pos !== 'number') {
507
- return null;
508
- }
509
-
510
- // need to pass view because we may not get updated props in time
511
- return this.props.view.state.doc.resolve(pos);
512
- }
513
-
514
- /**
515
- * The maxmimum number of grid columns this node can resize to.
516
- */
517
- }, {
518
- key: "gridWidth",
519
- get: function get() {
520
- var gridSize = this.props.gridSize;
521
- return !(this.wrappedLayout || this.insideInlineLike) ? gridSize / 2 : gridSize;
522
- }
523
- }, {
524
- key: "insideInlineLike",
525
- get: function get() {
526
- var $pos = this.$pos;
527
- if (!$pos) {
528
- return false;
529
- }
530
- var listItem = this.props.view.state.schema.nodes.listItem;
531
- return !!(0, _utils.findParentNodeOfTypeClosestToPos)($pos, [listItem]);
532
- }
533
- }, {
534
- key: "insideLayout",
535
- get: function get() {
536
- var $pos = this.$pos;
537
- if (!$pos) {
538
- return false;
539
- }
540
- var layoutColumn = this.props.view.state.schema.nodes.layoutColumn;
541
- return !!(0, _utils.findParentNodeOfTypeClosestToPos)($pos, [layoutColumn]);
542
- }
543
480
  }, {
544
481
  key: "render",
545
482
  value: function render() {
546
483
  var _this3 = this;
547
- var _this$props9 = this.props,
548
- origWidth = _this$props9.width,
549
- layout = _this$props9.layout,
550
- pctWidth = _this$props9.pctWidth,
551
- containerWidth = _this$props9.containerWidth,
552
- fullWidthMode = _this$props9.fullWidthMode,
553
- selected = _this$props9.selected,
554
- children = _this$props9.children,
555
- lineLength = _this$props9.lineLength;
484
+ var _this$props8 = this.props,
485
+ origWidth = _this$props8.width,
486
+ layout = _this$props8.layout,
487
+ pctWidth = _this$props8.pctWidth,
488
+ containerWidth = _this$props8.containerWidth,
489
+ fullWidthMode = _this$props8.fullWidthMode,
490
+ selected = _this$props8.selected,
491
+ children = _this$props8.children,
492
+ lineLength = _this$props8.lineLength;
556
493
  var _this$state = this.state,
557
494
  isResizing = _this$state.isResizing,
558
495
  size = _this$state.size;
@@ -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.27.0";
9
+ var version = "187.27.1";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -4,9 +4,9 @@ import React from 'react';
4
4
  import { jsx } from '@emotion/react';
5
5
  import { findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
6
6
  import { getMediaClient } from '@atlaskit/media-client';
7
- import { calcPctFromPx, wrappedLayouts, handleSides, imageAlignmentMap, calcColumnsFromPx } from '@atlaskit/editor-common/ui';
7
+ import { calcPctFromPx, wrappedLayouts, handleSides, imageAlignmentMap } from '@atlaskit/editor-common/ui';
8
8
  import { nonWrappedLayouts, setNodeSelection } from '@atlaskit/editor-common/utils';
9
- import { akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
9
+ import { akEditorFullWidthLayoutWidth, akEditorGutterPadding } from '@atlaskit/editor-shared-styles';
10
10
  import { wrapperStyle } from './styled';
11
11
  import { ResizerNext } from '@atlaskit/editor-common/resizer';
12
12
  import classnames from 'classnames';
@@ -94,12 +94,6 @@ class ResizableMediaSingleNext extends React.Component {
94
94
  // so that we have image aligned with text
95
95
  return 'full-width';
96
96
  });
97
- _defineProperty(this, "calcColumnLeftOffset", () => {
98
- const {
99
- offsetLeft
100
- } = this.state;
101
- return this.insideInlineLike ? calcColumnsFromPx(offsetLeft, this.props.lineLength, this.props.gridSize) : 0;
102
- });
103
97
  _defineProperty(this, "calcPxHeight", newWidth => {
104
98
  const {
105
99
  width = newWidth,
@@ -109,11 +103,8 @@ class ResizableMediaSingleNext extends React.Component {
109
103
  });
110
104
  _defineProperty(this, "saveWrapper", wrapper => this.wrapper = wrapper);
111
105
  _defineProperty(this, "displayGuideline", guidelines => {
112
- var _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$d3;
113
- const {
114
- pluginInjectionApi
115
- } = this.props;
116
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.guideline) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : (_pluginInjectionApi$d3 = _pluginInjectionApi$d2.actions) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : _pluginInjectionApi$d3.displayGuideline(this.props.view)({
106
+ var _this$props$pluginInj, _this$props$pluginInj2, _this$props$pluginInj3, _this$props$pluginInj4;
107
+ return (_this$props$pluginInj = this.props.pluginInjectionApi) === null || _this$props$pluginInj === void 0 ? void 0 : (_this$props$pluginInj2 = _this$props$pluginInj.dependencies) === null || _this$props$pluginInj2 === void 0 ? void 0 : (_this$props$pluginInj3 = _this$props$pluginInj2.guideline) === null || _this$props$pluginInj3 === void 0 ? void 0 : (_this$props$pluginInj4 = _this$props$pluginInj3.actions) === null || _this$props$pluginInj4 === void 0 ? void 0 : _this$props$pluginInj4.displayGuideline(this.props.view)({
117
108
  guidelines
118
109
  });
119
110
  });
@@ -142,9 +133,10 @@ class ResizableMediaSingleNext extends React.Component {
142
133
  return calcMediaSingleMaxWidth(containerWidth);
143
134
  }));
144
135
  _defineProperty(this, "getRelativeGuides", () => {
145
- const relativeGuides = this.$pos && this.$pos.nodeAfter && this.state.size.width ? getRelativeGuidelines(this.state.relativeGuides, {
146
- node: this.$pos.nodeAfter,
147
- pos: this.$pos.pos
136
+ const $pos = this.$pos;
137
+ const relativeGuides = $pos && $pos.nodeAfter && this.state.size.width ? getRelativeGuidelines(this.state.relativeGuides, {
138
+ node: $pos.nodeAfter,
139
+ pos: $pos.pos
148
140
  }, this.props.view, this.props.lineLength, this.state.size) : [];
149
141
  return relativeGuides;
150
142
  });
@@ -159,51 +151,19 @@ class ResizableMediaSingleNext extends React.Component {
159
151
  this.displayGuideline([...getGuidelinesWithHighlights(gap, MEDIA_SINGLE_SNAP_GAP, activeGuidelineKeys, guidelines), ...relativeGuidelines]);
160
152
  }
161
153
  });
162
- _defineProperty(this, "roundPixelValue", value => Math.round(value));
163
- _defineProperty(this, "getHeightFromNewWidth", (originalWidth, originalHeight, newWidth) => this.roundPixelValue(originalHeight / originalWidth * newWidth));
164
- _defineProperty(this, "calculateSizeState", (size, delta, originalWidth = 0, originalHeight, onResizeStop = false) => {
165
- const calculatedWidth = this.roundPixelValue(size.width + delta.width);
154
+ _defineProperty(this, "calculateSizeState", (size, delta, onResizeStop = false) => {
155
+ const calculatedWidth = Math.round(size.width + delta.width);
166
156
  const calculatedWidthWithLayout = this.calcNewSize(calculatedWidth, onResizeStop);
167
- const calculatedHeightWithLayout = this.getHeightFromNewWidth(originalWidth, originalHeight, calculatedWidth);
168
157
  return {
169
158
  width: calculatedWidth,
170
- height: calculatedHeightWithLayout,
159
+ height: calculatedWidth / this.aspectRatio,
171
160
  calculatedWidthWithLayout
172
161
  };
173
162
  });
174
163
  _defineProperty(this, "selectCurrentMediaNode", () => {
175
164
  // TODO: if adding !this.props.selected, it doesn't work if media single node is at top postion
176
- if (typeof this.props.getPos === 'function') {
177
- const propPos = this.props.getPos();
178
- if (propPos !== undefined) {
179
- setNodeSelection(this.props.view, propPos);
180
- }
181
- }
182
- });
183
- _defineProperty(this, "getParentNodeTypeNameFromCurrentPositionNode", () => {
184
- const $pos = this.$pos;
185
- if (!$pos) {
186
- return undefined;
187
- }
188
-
189
- // Supported Parent Nodes
190
- const {
191
- listItem,
192
- expand,
193
- tableCell,
194
- tableHeader,
195
- layoutSection,
196
- nestedExpand
197
- } = this.props.view.state.schema.nodes;
198
- const parentNode = findParentNodeOfTypeClosestToPos($pos, [listItem, expand, tableCell, tableHeader, layoutSection, nestedExpand]);
199
-
200
- // Return matched parent node name
201
- if (parentNode) {
202
- return parentNode.node.type.name;
203
- }
204
-
205
- // Return undefined if parent node cannot be found
206
- return undefined;
165
+ const pos = this.pos;
166
+ pos && setNodeSelection(this.props.view, pos);
207
167
  });
208
168
  _defineProperty(this, "handleResizeStart", () => {
209
169
  this.setState({
@@ -212,13 +172,11 @@ class ResizableMediaSingleNext extends React.Component {
212
172
  this.selectCurrentMediaNode();
213
173
  this.setIsResizing(true);
214
174
  this.updateSizeInPluginState(this.state.size.width);
215
- // re-calucate guidelines
175
+ // re-calculate guidelines
216
176
  this.updateGuidelines();
217
177
  });
218
178
  _defineProperty(this, "handleResize", (size, delta) => {
219
179
  const {
220
- width: originalWidth,
221
- height: originalHeight,
222
180
  layout,
223
181
  updateSize,
224
182
  lineLength
@@ -227,7 +185,7 @@ class ResizableMediaSingleNext extends React.Component {
227
185
  width,
228
186
  height,
229
187
  calculatedWidthWithLayout
230
- } = this.calculateSizeState(size, delta, originalWidth, originalHeight);
188
+ } = this.calculateSizeState(size, delta);
231
189
  const guidelineSnaps = getGuidelineSnaps(this.state.guidelines, lineLength, layout);
232
190
  this.updateActiveGuidelines(width, this.state.guidelines, guidelineSnaps);
233
191
  const relativeSnaps = getRelativeGuideSnaps(this.state.relativeGuides, this.aspectRatio);
@@ -247,8 +205,6 @@ class ResizableMediaSingleNext extends React.Component {
247
205
  });
248
206
  _defineProperty(this, "handleResizeStop", (size, delta) => {
249
207
  const {
250
- width: originalWidth,
251
- height: originalHeight,
252
208
  updateSize,
253
209
  dispatchAnalyticsEvent,
254
210
  nodeType
@@ -257,14 +213,15 @@ class ResizableMediaSingleNext extends React.Component {
257
213
  width,
258
214
  height,
259
215
  calculatedWidthWithLayout
260
- } = this.calculateSizeState(size, delta, originalWidth, originalHeight, true);
216
+ } = this.calculateSizeState(size, delta, true);
261
217
  if (dispatchAnalyticsEvent) {
218
+ const $pos = this.$pos;
262
219
  const event = getMediaResizeAnalyticsEvent(nodeType || 'mediaSingle', {
263
220
  width,
264
221
  layout: calculatedWidthWithLayout.layout,
265
222
  widthType: 'pixel',
266
223
  snapType: getGuidelineTypeFromKey(this.lastSnappedGuidelineKeys, this.state.guidelines),
267
- parentNode: this.getParentNodeTypeNameFromCurrentPositionNode()
224
+ parentNode: $pos ? $pos.parent.type.name : undefined
268
225
  });
269
226
  if (event) {
270
227
  dispatchAnalyticsEvent(event);
@@ -297,21 +254,6 @@ class ResizableMediaSingleNext extends React.Component {
297
254
  guidelines: []
298
255
  };
299
256
  }
300
-
301
- /**
302
- * Calculate media single node initial width if props.mediaSingleWidth is undefined
303
- * (Mainly when switching from lagacy experience to new experience).
304
- *
305
- * @returns initial width in pixel
306
- */
307
- calcInitialWidth() {
308
- const {
309
- width: origWidth,
310
- lineLength: contentWidth,
311
- containerWidth
312
- } = this.props;
313
- return Math.max(Math.min(origWidth || DEFAULT_IMAGE_WIDTH, contentWidth || containerWidth || akEditorDefaultLayoutWidth), MEDIA_SINGLE_MIN_PIXEL_WIDTH);
314
- }
315
257
  componentDidUpdate(prevProps) {
316
258
  const offsetLeft = calculateOffsetLeft(this.insideInlineLike, this.insideLayout, this.props.view.dom, this.wrapper);
317
259
  if (offsetLeft !== this.state.offsetLeft && offsetLeft >= 0) {
@@ -352,24 +294,6 @@ class ResizableMediaSingleNext extends React.Component {
352
294
  }
353
295
  return true;
354
296
  }
355
-
356
- // check if is inside of layout, table, expand, nestedExpand and list item
357
- isNestedNode() {
358
- return !!(this.$pos && this.$pos.parent.type.name !== 'doc');
359
- }
360
- getDefaultGuidelines() {
361
- const {
362
- lineLength,
363
- containerWidth,
364
- fullWidthMode
365
- } = this.props;
366
-
367
- // disable guidelines for nested media single node
368
- return this.isNestedNode() ? [] : generateDefaultGuidelines(lineLength, containerWidth, fullWidthMode);
369
- }
370
- get wrappedLayout() {
371
- return wrappedLayouts.indexOf(this.props.layout) > -1;
372
- }
373
297
  async componentDidMount() {
374
298
  const {
375
299
  viewMediaClientConfig
@@ -383,6 +307,24 @@ class ResizableMediaSingleNext extends React.Component {
383
307
  this.checkVideoFile(nextProps.viewMediaClientConfig);
384
308
  }
385
309
  }
310
+ get wrappedLayout() {
311
+ return wrappedLayouts.indexOf(this.props.layout) > -1;
312
+ }
313
+ get pos() {
314
+ if (typeof this.props.getPos !== 'function') {
315
+ return null;
316
+ }
317
+ const pos = this.props.getPos();
318
+ if (Number.isNaN(pos) || typeof pos !== 'number') {
319
+ return null;
320
+ }
321
+ return pos;
322
+ }
323
+ get $pos() {
324
+ const pos = this.pos;
325
+ // need to pass view because we may not get updated props in time
326
+ return pos && this.props.view.state.doc.resolve(pos);
327
+ }
386
328
  get aspectRatio() {
387
329
  const {
388
330
  width,
@@ -391,9 +333,46 @@ class ResizableMediaSingleNext extends React.Component {
391
333
  if (width) {
392
334
  return width / height;
393
335
  }
336
+
394
337
  // TODO handle this case
395
338
  return 1;
396
339
  }
340
+ get insideInlineLike() {
341
+ const $pos = this.$pos;
342
+ if (!$pos) {
343
+ return false;
344
+ }
345
+ const {
346
+ listItem
347
+ } = this.props.view.state.schema.nodes;
348
+ return !!findParentNodeOfTypeClosestToPos($pos, [listItem]);
349
+ }
350
+ get insideLayout() {
351
+ const $pos = this.$pos;
352
+ if (!$pos) {
353
+ return false;
354
+ }
355
+ const {
356
+ layoutColumn
357
+ } = this.props.view.state.schema.nodes;
358
+ return !!findParentNodeOfTypeClosestToPos($pos, [layoutColumn]);
359
+ }
360
+
361
+ // check if is inside of layout, table, expand, nestedExpand and list item
362
+ isNestedNode() {
363
+ const $pos = this.$pos;
364
+ return !!($pos && $pos.parent.type !== $pos.parent.type.schema.nodes.doc);
365
+ }
366
+ getDefaultGuidelines() {
367
+ const {
368
+ lineLength,
369
+ containerWidth,
370
+ fullWidthMode
371
+ } = this.props;
372
+
373
+ // disable guidelines for nested media single node
374
+ return this.isNestedNode() ? [] : generateDefaultGuidelines(lineLength, containerWidth, fullWidthMode);
375
+ }
397
376
  async checkVideoFile(viewMediaClientConfig) {
398
377
  const $pos = this.$pos;
399
378
  if (!$pos || !viewMediaClientConfig) {
@@ -419,48 +398,6 @@ class ResizableMediaSingleNext extends React.Component {
419
398
  });
420
399
  }
421
400
  }
422
- get $pos() {
423
- if (typeof this.props.getPos !== 'function') {
424
- return null;
425
- }
426
- const pos = this.props.getPos();
427
- if (Number.isNaN(pos) || typeof pos !== 'number') {
428
- return null;
429
- }
430
-
431
- // need to pass view because we may not get updated props in time
432
- return this.props.view.state.doc.resolve(pos);
433
- }
434
-
435
- /**
436
- * The maxmimum number of grid columns this node can resize to.
437
- */
438
- get gridWidth() {
439
- const {
440
- gridSize
441
- } = this.props;
442
- return !(this.wrappedLayout || this.insideInlineLike) ? gridSize / 2 : gridSize;
443
- }
444
- get insideInlineLike() {
445
- const $pos = this.$pos;
446
- if (!$pos) {
447
- return false;
448
- }
449
- const {
450
- listItem
451
- } = this.props.view.state.schema.nodes;
452
- return !!findParentNodeOfTypeClosestToPos($pos, [listItem]);
453
- }
454
- get insideLayout() {
455
- const $pos = this.$pos;
456
- if (!$pos) {
457
- return false;
458
- }
459
- const {
460
- layoutColumn
461
- } = this.props.view.state.schema.nodes;
462
- return !!findParentNodeOfTypeClosestToPos($pos, [layoutColumn]);
463
- }
464
401
  render() {
465
402
  const {
466
403
  width: origWidth,
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.27.0";
2
+ export const version = "187.27.1";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -15,9 +15,9 @@ import React from 'react';
15
15
  import { jsx } from '@emotion/react';
16
16
  import { findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
17
17
  import { getMediaClient } from '@atlaskit/media-client';
18
- import { calcPctFromPx, wrappedLayouts, handleSides, imageAlignmentMap, calcColumnsFromPx } from '@atlaskit/editor-common/ui';
18
+ import { calcPctFromPx, wrappedLayouts, handleSides, imageAlignmentMap } from '@atlaskit/editor-common/ui';
19
19
  import { nonWrappedLayouts, setNodeSelection } from '@atlaskit/editor-common/utils';
20
- import { akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
20
+ import { akEditorFullWidthLayoutWidth, akEditorGutterPadding } from '@atlaskit/editor-shared-styles';
21
21
  import { wrapperStyle } from './styled';
22
22
  import { ResizerNext } from '@atlaskit/editor-common/resizer';
23
23
  import classnames from 'classnames';
@@ -104,10 +104,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
104
104
  // so that we have image aligned with text
105
105
  return 'full-width';
106
106
  });
107
- _defineProperty(_assertThisInitialized(_this), "calcColumnLeftOffset", function () {
108
- var offsetLeft = _this.state.offsetLeft;
109
- return _this.insideInlineLike ? calcColumnsFromPx(offsetLeft, _this.props.lineLength, _this.props.gridSize) : 0;
110
- });
111
107
  _defineProperty(_assertThisInitialized(_this), "calcPxHeight", function (newWidth) {
112
108
  var _this$props3 = _this.props,
113
109
  _this$props3$width = _this$props3.width,
@@ -119,9 +115,8 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
119
115
  return _this.wrapper = wrapper;
120
116
  });
121
117
  _defineProperty(_assertThisInitialized(_this), "displayGuideline", function (guidelines) {
122
- var _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$d3;
123
- var pluginInjectionApi = _this.props.pluginInjectionApi;
124
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.guideline) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : (_pluginInjectionApi$d3 = _pluginInjectionApi$d2.actions) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : _pluginInjectionApi$d3.displayGuideline(_this.props.view)({
118
+ var _this$props$pluginInj, _this$props$pluginInj2, _this$props$pluginInj3, _this$props$pluginInj4;
119
+ return (_this$props$pluginInj = _this.props.pluginInjectionApi) === null || _this$props$pluginInj === void 0 ? void 0 : (_this$props$pluginInj2 = _this$props$pluginInj.dependencies) === null || _this$props$pluginInj2 === void 0 ? void 0 : (_this$props$pluginInj3 = _this$props$pluginInj2.guideline) === null || _this$props$pluginInj3 === void 0 ? void 0 : (_this$props$pluginInj4 = _this$props$pluginInj3.actions) === null || _this$props$pluginInj4 === void 0 ? void 0 : _this$props$pluginInj4.displayGuideline(_this.props.view)({
125
120
  guidelines: guidelines
126
121
  });
127
122
  });
@@ -148,9 +143,10 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
148
143
  return calcMediaSingleMaxWidth(containerWidth);
149
144
  }));
150
145
  _defineProperty(_assertThisInitialized(_this), "getRelativeGuides", function () {
151
- var relativeGuides = _this.$pos && _this.$pos.nodeAfter && _this.state.size.width ? getRelativeGuidelines(_this.state.relativeGuides, {
152
- node: _this.$pos.nodeAfter,
153
- pos: _this.$pos.pos
146
+ var $pos = _this.$pos;
147
+ var relativeGuides = $pos && $pos.nodeAfter && _this.state.size.width ? getRelativeGuidelines(_this.state.relativeGuides, {
148
+ node: $pos.nodeAfter,
149
+ pos: $pos.pos
154
150
  }, _this.props.view, _this.props.lineLength, _this.state.size) : [];
155
151
  return relativeGuides;
156
152
  });
@@ -167,57 +163,20 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
167
163
  _this.displayGuideline([].concat(_toConsumableArray(getGuidelinesWithHighlights(gap, MEDIA_SINGLE_SNAP_GAP, activeGuidelineKeys, guidelines)), _toConsumableArray(relativeGuidelines)));
168
164
  }
169
165
  });
170
- _defineProperty(_assertThisInitialized(_this), "roundPixelValue", function (value) {
171
- return Math.round(value);
172
- });
173
- _defineProperty(_assertThisInitialized(_this), "getHeightFromNewWidth", function (originalWidth, originalHeight, newWidth) {
174
- return _this.roundPixelValue(originalHeight / originalWidth * newWidth);
175
- });
176
166
  _defineProperty(_assertThisInitialized(_this), "calculateSizeState", function (size, delta) {
177
- var originalWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
178
- var originalHeight = arguments.length > 3 ? arguments[3] : undefined;
179
- var onResizeStop = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
180
- var calculatedWidth = _this.roundPixelValue(size.width + delta.width);
167
+ var onResizeStop = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
168
+ var calculatedWidth = Math.round(size.width + delta.width);
181
169
  var calculatedWidthWithLayout = _this.calcNewSize(calculatedWidth, onResizeStop);
182
- var calculatedHeightWithLayout = _this.getHeightFromNewWidth(originalWidth, originalHeight, calculatedWidth);
183
170
  return {
184
171
  width: calculatedWidth,
185
- height: calculatedHeightWithLayout,
172
+ height: calculatedWidth / _this.aspectRatio,
186
173
  calculatedWidthWithLayout: calculatedWidthWithLayout
187
174
  };
188
175
  });
189
176
  _defineProperty(_assertThisInitialized(_this), "selectCurrentMediaNode", function () {
190
177
  // TODO: if adding !this.props.selected, it doesn't work if media single node is at top postion
191
- if (typeof _this.props.getPos === 'function') {
192
- var propPos = _this.props.getPos();
193
- if (propPos !== undefined) {
194
- setNodeSelection(_this.props.view, propPos);
195
- }
196
- }
197
- });
198
- _defineProperty(_assertThisInitialized(_this), "getParentNodeTypeNameFromCurrentPositionNode", function () {
199
- var $pos = _this.$pos;
200
- if (!$pos) {
201
- return undefined;
202
- }
203
-
204
- // Supported Parent Nodes
205
- var _this$props$view$stat = _this.props.view.state.schema.nodes,
206
- listItem = _this$props$view$stat.listItem,
207
- expand = _this$props$view$stat.expand,
208
- tableCell = _this$props$view$stat.tableCell,
209
- tableHeader = _this$props$view$stat.tableHeader,
210
- layoutSection = _this$props$view$stat.layoutSection,
211
- nestedExpand = _this$props$view$stat.nestedExpand;
212
- var parentNode = findParentNodeOfTypeClosestToPos($pos, [listItem, expand, tableCell, tableHeader, layoutSection, nestedExpand]);
213
-
214
- // Return matched parent node name
215
- if (parentNode) {
216
- return parentNode.node.type.name;
217
- }
218
-
219
- // Return undefined if parent node cannot be found
220
- return undefined;
178
+ var pos = _this.pos;
179
+ pos && setNodeSelection(_this.props.view, pos);
221
180
  });
222
181
  _defineProperty(_assertThisInitialized(_this), "handleResizeStart", function () {
223
182
  _this.setState({
@@ -226,17 +185,15 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
226
185
  _this.selectCurrentMediaNode();
227
186
  _this.setIsResizing(true);
228
187
  _this.updateSizeInPluginState(_this.state.size.width);
229
- // re-calucate guidelines
188
+ // re-calculate guidelines
230
189
  _this.updateGuidelines();
231
190
  });
232
191
  _defineProperty(_assertThisInitialized(_this), "handleResize", function (size, delta) {
233
192
  var _this$props4 = _this.props,
234
- originalWidth = _this$props4.width,
235
- originalHeight = _this$props4.height,
236
193
  layout = _this$props4.layout,
237
194
  updateSize = _this$props4.updateSize,
238
195
  lineLength = _this$props4.lineLength;
239
- var _this$calculateSizeSt = _this.calculateSizeState(size, delta, originalWidth, originalHeight),
196
+ var _this$calculateSizeSt = _this.calculateSizeState(size, delta),
240
197
  width = _this$calculateSizeSt.width,
241
198
  height = _this$calculateSizeSt.height,
242
199
  calculatedWidthWithLayout = _this$calculateSizeSt.calculatedWidthWithLayout;
@@ -259,22 +216,21 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
259
216
  });
260
217
  _defineProperty(_assertThisInitialized(_this), "handleResizeStop", function (size, delta) {
261
218
  var _this$props5 = _this.props,
262
- originalWidth = _this$props5.width,
263
- originalHeight = _this$props5.height,
264
219
  updateSize = _this$props5.updateSize,
265
220
  dispatchAnalyticsEvent = _this$props5.dispatchAnalyticsEvent,
266
221
  nodeType = _this$props5.nodeType;
267
- var _this$calculateSizeSt2 = _this.calculateSizeState(size, delta, originalWidth, originalHeight, true),
222
+ var _this$calculateSizeSt2 = _this.calculateSizeState(size, delta, true),
268
223
  width = _this$calculateSizeSt2.width,
269
224
  height = _this$calculateSizeSt2.height,
270
225
  calculatedWidthWithLayout = _this$calculateSizeSt2.calculatedWidthWithLayout;
271
226
  if (dispatchAnalyticsEvent) {
227
+ var $pos = _this.$pos;
272
228
  var event = getMediaResizeAnalyticsEvent(nodeType || 'mediaSingle', {
273
229
  width: width,
274
230
  layout: calculatedWidthWithLayout.layout,
275
231
  widthType: 'pixel',
276
232
  snapType: getGuidelineTypeFromKey(_this.lastSnappedGuidelineKeys, _this.state.guidelines),
277
- parentNode: _this.getParentNodeTypeNameFromCurrentPositionNode()
233
+ parentNode: $pos ? $pos.parent.type.name : undefined
278
234
  });
279
235
  if (event) {
280
236
  dispatchAnalyticsEvent(event);
@@ -308,23 +264,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
308
264
  };
309
265
  return _this;
310
266
  }
311
-
312
- /**
313
- * Calculate media single node initial width if props.mediaSingleWidth is undefined
314
- * (Mainly when switching from lagacy experience to new experience).
315
- *
316
- * @returns initial width in pixel
317
- */
318
267
  _createClass(ResizableMediaSingleNext, [{
319
- key: "calcInitialWidth",
320
- value: function calcInitialWidth() {
321
- var _this$props6 = this.props,
322
- origWidth = _this$props6.width,
323
- contentWidth = _this$props6.lineLength,
324
- containerWidth = _this$props6.containerWidth;
325
- return Math.max(Math.min(origWidth || DEFAULT_IMAGE_WIDTH, contentWidth || containerWidth || akEditorDefaultLayoutWidth), MEDIA_SINGLE_MIN_PIXEL_WIDTH);
326
- }
327
- }, {
328
268
  key: "componentDidUpdate",
329
269
  value: function componentDidUpdate(prevProps) {
330
270
  var _this2 = this;
@@ -367,29 +307,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
367
307
  }
368
308
  return true;
369
309
  }
370
-
371
- // check if is inside of layout, table, expand, nestedExpand and list item
372
- }, {
373
- key: "isNestedNode",
374
- value: function isNestedNode() {
375
- return !!(this.$pos && this.$pos.parent.type.name !== 'doc');
376
- }
377
- }, {
378
- key: "getDefaultGuidelines",
379
- value: function getDefaultGuidelines() {
380
- var _this$props7 = this.props,
381
- lineLength = _this$props7.lineLength,
382
- containerWidth = _this$props7.containerWidth,
383
- fullWidthMode = _this$props7.fullWidthMode;
384
-
385
- // disable guidelines for nested media single node
386
- return this.isNestedNode() ? [] : generateDefaultGuidelines(lineLength, containerWidth, fullWidthMode);
387
- }
388
- }, {
389
- key: "wrappedLayout",
390
- get: function get() {
391
- return wrappedLayouts.indexOf(this.props.layout) > -1;
392
- }
393
310
  }, {
394
311
  key: "componentDidMount",
395
312
  value: function () {
@@ -423,18 +340,82 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
423
340
  this.checkVideoFile(nextProps.viewMediaClientConfig);
424
341
  }
425
342
  }
343
+ }, {
344
+ key: "wrappedLayout",
345
+ get: function get() {
346
+ return wrappedLayouts.indexOf(this.props.layout) > -1;
347
+ }
348
+ }, {
349
+ key: "pos",
350
+ get: function get() {
351
+ if (typeof this.props.getPos !== 'function') {
352
+ return null;
353
+ }
354
+ var pos = this.props.getPos();
355
+ if (Number.isNaN(pos) || typeof pos !== 'number') {
356
+ return null;
357
+ }
358
+ return pos;
359
+ }
360
+ }, {
361
+ key: "$pos",
362
+ get: function get() {
363
+ var pos = this.pos;
364
+ // need to pass view because we may not get updated props in time
365
+ return pos && this.props.view.state.doc.resolve(pos);
366
+ }
426
367
  }, {
427
368
  key: "aspectRatio",
428
369
  get: function get() {
429
- var _this$props8 = this.props,
430
- width = _this$props8.width,
431
- height = _this$props8.height;
370
+ var _this$props6 = this.props,
371
+ width = _this$props6.width,
372
+ height = _this$props6.height;
432
373
  if (width) {
433
374
  return width / height;
434
375
  }
376
+
435
377
  // TODO handle this case
436
378
  return 1;
437
379
  }
380
+ }, {
381
+ key: "insideInlineLike",
382
+ get: function get() {
383
+ var $pos = this.$pos;
384
+ if (!$pos) {
385
+ return false;
386
+ }
387
+ var listItem = this.props.view.state.schema.nodes.listItem;
388
+ return !!findParentNodeOfTypeClosestToPos($pos, [listItem]);
389
+ }
390
+ }, {
391
+ key: "insideLayout",
392
+ get: function get() {
393
+ var $pos = this.$pos;
394
+ if (!$pos) {
395
+ return false;
396
+ }
397
+ var layoutColumn = this.props.view.state.schema.nodes.layoutColumn;
398
+ return !!findParentNodeOfTypeClosestToPos($pos, [layoutColumn]);
399
+ }
400
+
401
+ // check if is inside of layout, table, expand, nestedExpand and list item
402
+ }, {
403
+ key: "isNestedNode",
404
+ value: function isNestedNode() {
405
+ var $pos = this.$pos;
406
+ return !!($pos && $pos.parent.type !== $pos.parent.type.schema.nodes.doc);
407
+ }
408
+ }, {
409
+ key: "getDefaultGuidelines",
410
+ value: function getDefaultGuidelines() {
411
+ var _this$props7 = this.props,
412
+ lineLength = _this$props7.lineLength,
413
+ containerWidth = _this$props7.containerWidth,
414
+ fullWidthMode = _this$props7.fullWidthMode;
415
+
416
+ // disable guidelines for nested media single node
417
+ return this.isNestedNode() ? [] : generateDefaultGuidelines(lineLength, containerWidth, fullWidthMode);
418
+ }
438
419
  }, {
439
420
  key: "checkVideoFile",
440
421
  value: function () {
@@ -489,63 +470,19 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
489
470
  }
490
471
  return checkVideoFile;
491
472
  }()
492
- }, {
493
- key: "$pos",
494
- get: function get() {
495
- if (typeof this.props.getPos !== 'function') {
496
- return null;
497
- }
498
- var pos = this.props.getPos();
499
- if (Number.isNaN(pos) || typeof pos !== 'number') {
500
- return null;
501
- }
502
-
503
- // need to pass view because we may not get updated props in time
504
- return this.props.view.state.doc.resolve(pos);
505
- }
506
-
507
- /**
508
- * The maxmimum number of grid columns this node can resize to.
509
- */
510
- }, {
511
- key: "gridWidth",
512
- get: function get() {
513
- var gridSize = this.props.gridSize;
514
- return !(this.wrappedLayout || this.insideInlineLike) ? gridSize / 2 : gridSize;
515
- }
516
- }, {
517
- key: "insideInlineLike",
518
- get: function get() {
519
- var $pos = this.$pos;
520
- if (!$pos) {
521
- return false;
522
- }
523
- var listItem = this.props.view.state.schema.nodes.listItem;
524
- return !!findParentNodeOfTypeClosestToPos($pos, [listItem]);
525
- }
526
- }, {
527
- key: "insideLayout",
528
- get: function get() {
529
- var $pos = this.$pos;
530
- if (!$pos) {
531
- return false;
532
- }
533
- var layoutColumn = this.props.view.state.schema.nodes.layoutColumn;
534
- return !!findParentNodeOfTypeClosestToPos($pos, [layoutColumn]);
535
- }
536
473
  }, {
537
474
  key: "render",
538
475
  value: function render() {
539
476
  var _this3 = this;
540
- var _this$props9 = this.props,
541
- origWidth = _this$props9.width,
542
- layout = _this$props9.layout,
543
- pctWidth = _this$props9.pctWidth,
544
- containerWidth = _this$props9.containerWidth,
545
- fullWidthMode = _this$props9.fullWidthMode,
546
- selected = _this$props9.selected,
547
- children = _this$props9.children,
548
- lineLength = _this$props9.lineLength;
477
+ var _this$props8 = this.props,
478
+ origWidth = _this$props8.width,
479
+ layout = _this$props8.layout,
480
+ pctWidth = _this$props8.pctWidth,
481
+ containerWidth = _this$props8.containerWidth,
482
+ fullWidthMode = _this$props8.fullWidthMode,
483
+ selected = _this$props8.selected,
484
+ children = _this$props8.children,
485
+ lineLength = _this$props8.lineLength;
549
486
  var _this$state = this.state,
550
487
  isResizing = _this$state.isResizing,
551
488
  size = _this$state.size;
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "187.27.0";
2
+ export var version = "187.27.1";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -20,38 +20,27 @@ export declare const resizerNextTestId = "mediaSingle.resizerNext.testid";
20
20
  type ResizableMediaSingleNextProps = Props;
21
21
  declare class ResizableMediaSingleNext extends React.Component<ResizableMediaSingleNextProps, State> {
22
22
  private lastSnappedGuidelineKeys;
23
+ private wrapper?;
23
24
  constructor(props: ResizableMediaSingleNextProps);
24
- /**
25
- * Calculate media single node initial width if props.mediaSingleWidth is undefined
26
- * (Mainly when switching from lagacy experience to new experience).
27
- *
28
- * @returns initial width in pixel
29
- */
30
- calcInitialWidth(): number;
31
25
  componentDidUpdate(prevProps: Props): boolean;
32
- isNestedNode(): boolean;
33
- private getDefaultGuidelines;
34
- private updateGuidelines;
35
- get wrappedLayout(): boolean;
36
26
  componentDidMount(): Promise<void>;
37
27
  UNSAFE_componentWillReceiveProps(nextProps: Props): void;
28
+ get wrappedLayout(): boolean;
29
+ get pos(): number | null;
30
+ get $pos(): 0 | import("prosemirror-model").ResolvedPos | null;
38
31
  get aspectRatio(): number;
32
+ get insideInlineLike(): boolean;
33
+ get insideLayout(): boolean;
34
+ isNestedNode(): boolean;
35
+ private getDefaultGuidelines;
36
+ private updateGuidelines;
39
37
  checkVideoFile(viewMediaClientConfig?: MediaClientConfig): Promise<void>;
40
38
  calcNewSize: (newWidth: number, stop: boolean) => {
41
39
  width: number | null;
42
40
  layout: MediaSingleLayout;
43
41
  };
44
42
  calcUnwrappedLayout: (width: number, containerWidth: number, contentWidth: number, fullWidthMode?: boolean) => 'center' | 'wide' | 'full-width';
45
- get $pos(): import("prosemirror-model").ResolvedPos | null;
46
- /**
47
- * The maxmimum number of grid columns this node can resize to.
48
- */
49
- get gridWidth(): number;
50
- calcColumnLeftOffset: () => number;
51
- wrapper?: HTMLElement;
52
43
  calcPxHeight: (newWidth: number) => number;
53
- get insideInlineLike(): boolean;
54
- get insideLayout(): boolean;
55
44
  private saveWrapper;
56
45
  private displayGuideline;
57
46
  private setIsResizing;
@@ -59,9 +48,7 @@ declare class ResizableMediaSingleNext extends React.Component<ResizableMediaSin
59
48
  private calcMaxWidth;
60
49
  private getRelativeGuides;
61
50
  updateActiveGuidelines: (width: number | undefined, guidelines: GuidelineConfig[], guidelineSnapsReference: GuidelineSnapsReference) => void;
62
- roundPixelValue: (value: number) => number;
63
- getHeightFromNewWidth: (originalWidth: number, originalHeight: number, newWidth: number) => number;
64
- calculateSizeState: (size: Position & Dimensions, delta: Dimensions, originalWidth: number | undefined, originalHeight: number, onResizeStop?: boolean) => {
51
+ calculateSizeState: (size: Position & Dimensions, delta: Dimensions, onResizeStop?: boolean) => {
65
52
  width: number;
66
53
  height: number;
67
54
  calculatedWidthWithLayout: {
@@ -70,7 +57,6 @@ declare class ResizableMediaSingleNext extends React.Component<ResizableMediaSin
70
57
  };
71
58
  };
72
59
  selectCurrentMediaNode: () => void;
73
- getParentNodeTypeNameFromCurrentPositionNode: () => string | undefined;
74
60
  handleResizeStart: HandleResizeStart;
75
61
  handleResize: HandleResize;
76
62
  handleResizeStop: HandleResize;
@@ -20,38 +20,27 @@ export declare const resizerNextTestId = "mediaSingle.resizerNext.testid";
20
20
  type ResizableMediaSingleNextProps = Props;
21
21
  declare class ResizableMediaSingleNext extends React.Component<ResizableMediaSingleNextProps, State> {
22
22
  private lastSnappedGuidelineKeys;
23
+ private wrapper?;
23
24
  constructor(props: ResizableMediaSingleNextProps);
24
- /**
25
- * Calculate media single node initial width if props.mediaSingleWidth is undefined
26
- * (Mainly when switching from lagacy experience to new experience).
27
- *
28
- * @returns initial width in pixel
29
- */
30
- calcInitialWidth(): number;
31
25
  componentDidUpdate(prevProps: Props): boolean;
32
- isNestedNode(): boolean;
33
- private getDefaultGuidelines;
34
- private updateGuidelines;
35
- get wrappedLayout(): boolean;
36
26
  componentDidMount(): Promise<void>;
37
27
  UNSAFE_componentWillReceiveProps(nextProps: Props): void;
28
+ get wrappedLayout(): boolean;
29
+ get pos(): number | null;
30
+ get $pos(): 0 | import("prosemirror-model").ResolvedPos | null;
38
31
  get aspectRatio(): number;
32
+ get insideInlineLike(): boolean;
33
+ get insideLayout(): boolean;
34
+ isNestedNode(): boolean;
35
+ private getDefaultGuidelines;
36
+ private updateGuidelines;
39
37
  checkVideoFile(viewMediaClientConfig?: MediaClientConfig): Promise<void>;
40
38
  calcNewSize: (newWidth: number, stop: boolean) => {
41
39
  width: number | null;
42
40
  layout: MediaSingleLayout;
43
41
  };
44
42
  calcUnwrappedLayout: (width: number, containerWidth: number, contentWidth: number, fullWidthMode?: boolean) => 'center' | 'wide' | 'full-width';
45
- get $pos(): import("prosemirror-model").ResolvedPos | null;
46
- /**
47
- * The maxmimum number of grid columns this node can resize to.
48
- */
49
- get gridWidth(): number;
50
- calcColumnLeftOffset: () => number;
51
- wrapper?: HTMLElement;
52
43
  calcPxHeight: (newWidth: number) => number;
53
- get insideInlineLike(): boolean;
54
- get insideLayout(): boolean;
55
44
  private saveWrapper;
56
45
  private displayGuideline;
57
46
  private setIsResizing;
@@ -59,9 +48,7 @@ declare class ResizableMediaSingleNext extends React.Component<ResizableMediaSin
59
48
  private calcMaxWidth;
60
49
  private getRelativeGuides;
61
50
  updateActiveGuidelines: (width: number | undefined, guidelines: GuidelineConfig[], guidelineSnapsReference: GuidelineSnapsReference) => void;
62
- roundPixelValue: (value: number) => number;
63
- getHeightFromNewWidth: (originalWidth: number, originalHeight: number, newWidth: number) => number;
64
- calculateSizeState: (size: Position & Dimensions, delta: Dimensions, originalWidth: number | undefined, originalHeight: number, onResizeStop?: boolean) => {
51
+ calculateSizeState: (size: Position & Dimensions, delta: Dimensions, onResizeStop?: boolean) => {
65
52
  width: number;
66
53
  height: number;
67
54
  calculatedWidthWithLayout: {
@@ -70,7 +57,6 @@ declare class ResizableMediaSingleNext extends React.Component<ResizableMediaSin
70
57
  };
71
58
  };
72
59
  selectCurrentMediaNode: () => void;
73
- getParentNodeTypeNameFromCurrentPositionNode: () => string | undefined;
74
60
  handleResizeStart: HandleResizeStart;
75
61
  handleResize: HandleResize;
76
62
  handleResizeStop: HandleResize;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.27.0",
3
+ "version": "187.27.1",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"