@atlaskit/editor-core 187.27.0 → 187.28.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 187.28.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`9ebabeaa630`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9ebabeaa630) - added ExtractPublicEditorAPI type helper
8
+
9
+ ### Patch Changes
10
+
11
+ - [`fd6bb9c9184`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fd6bb9c9184) - Delete version.json
12
+ - Updated dependencies
13
+
14
+ ## 187.27.1
15
+
16
+ ### Patch Changes
17
+
18
+ - [`719a3a60441`](https://bitbucket.org/atlassian/atlassian-frontend/commits/719a3a60441) - ED-19411 minor refactor of ResizableMediaSingleNext
19
+
3
20
  ## 187.27.0
4
21
 
5
22
  ### Minor Changes
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -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.28.0";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -0,0 +1 @@
1
+ export {};