@atlaskit/editor-core 187.44.2 → 187.44.3

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.44.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`bb3d72ef732`](https://bitbucket.org/atlassian/atlassian-frontend/commits/bb3d72ef732) - ED-20041 added check for external media
8
+
3
9
  ## 187.44.2
4
10
 
5
11
  ### Patch Changes
@@ -18,7 +18,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
18
18
  var _react = _interopRequireDefault(require("react"));
19
19
  var _react2 = require("@emotion/react");
20
20
  var _utils = require("@atlaskit/editor-prosemirror/utils");
21
- var _mediaClient = require("@atlaskit/media-client");
22
21
  var _ui = require("@atlaskit/editor-common/ui");
23
22
  var _utils2 = require("@atlaskit/editor-common/utils");
24
23
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
@@ -33,6 +32,7 @@ var _analytics = require("../../utils/analytics");
33
32
  var _throttle = _interopRequireDefault(require("lodash/throttle"));
34
33
  var _main = require("../../pm-plugins/main");
35
34
  var _ResizableMediaMigrationNotification = require("./ResizableMediaMigrationNotification");
35
+ var _checkMediaType = require("../../utils/check-media-type");
36
36
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
37
37
  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 */
38
38
  var resizerNextTestId = 'mediaSingle.resizerNext.testid';
@@ -425,7 +425,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
425
425
  key: "checkVideoFile",
426
426
  value: function () {
427
427
  var _checkVideoFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(viewMediaClientConfig) {
428
- var mediaNode, mediaClient, state;
428
+ var mediaNode, mediaType, isVideoFile;
429
429
  return _regenerator.default.wrap(function _callee2$(_context2) {
430
430
  while (1) switch (_context2.prev = _context2.next) {
431
431
  case 0:
@@ -436,38 +436,31 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
436
436
  return _context2.abrupt("return");
437
437
  case 2:
438
438
  mediaNode = this.props.view.state.doc.nodeAt(this.pos + 1);
439
- if (!(!mediaNode || !mediaNode.attrs.id)) {
440
- _context2.next = 5;
439
+ if (!mediaNode) {
440
+ _context2.next = 9;
441
441
  break;
442
442
  }
443
- return _context2.abrupt("return");
444
- case 5:
445
- mediaClient = (0, _mediaClient.getMediaClient)(viewMediaClientConfig);
446
- _context2.prev = 6;
447
- _context2.next = 9;
448
- return mediaClient.file.getCurrentState(mediaNode.attrs.id, {
449
- collectionName: mediaNode.attrs.collection
450
- });
443
+ _context2.next = 6;
444
+ return (0, _checkMediaType.checkMediaType)(mediaNode, viewMediaClientConfig);
445
+ case 6:
446
+ _context2.t0 = _context2.sent;
447
+ _context2.next = 10;
448
+ break;
451
449
  case 9:
452
- state = _context2.sent;
453
- if (state && state.status !== 'error' && state.mediaType === 'image') {
450
+ _context2.t0 = undefined;
451
+ case 10:
452
+ mediaType = _context2.t0;
453
+ isVideoFile = mediaType !== 'external' && mediaType !== 'image';
454
+ if (this.state.isVideoFile !== isVideoFile) {
454
455
  this.setState({
455
- isVideoFile: false
456
+ isVideoFile: isVideoFile
456
457
  });
457
458
  }
458
- _context2.next = 16;
459
- break;
460
459
  case 13:
461
- _context2.prev = 13;
462
- _context2.t0 = _context2["catch"](6);
463
- this.setState({
464
- isVideoFile: false
465
- });
466
- case 16:
467
460
  case "end":
468
461
  return _context2.stop();
469
462
  }
470
- }, _callee2, this, [[6, 13]]);
463
+ }, _callee2, this);
471
464
  }));
472
465
  function checkVideoFile(_x) {
473
466
  return _checkVideoFile.apply(this, arguments);
@@ -18,12 +18,12 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
18
18
  var _react = _interopRequireDefault(require("react"));
19
19
  var _react2 = require("@emotion/react");
20
20
  var _utils = require("@atlaskit/editor-prosemirror/utils");
21
- var _mediaClient = require("@atlaskit/media-client");
22
21
  var _ui = require("@atlaskit/editor-common/ui");
23
22
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
24
23
  var _styled = require("./styled");
25
24
  var _mediaSingle = require("@atlaskit/editor-common/media-single");
26
25
  var _utils2 = require("@atlaskit/editor-common/utils");
26
+ var _checkMediaType = require("../../utils/check-media-type");
27
27
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
28
28
  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 */
29
29
  var ResizableMediaSingle = /*#__PURE__*/function (_React$Component) {
@@ -229,7 +229,7 @@ var ResizableMediaSingle = /*#__PURE__*/function (_React$Component) {
229
229
  key: "checkVideoFile",
230
230
  value: function () {
231
231
  var _checkVideoFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(viewMediaClientConfig) {
232
- var $pos, mediaNode, mediaClient, state;
232
+ var $pos, mediaNode, mediaType, isVideoFile;
233
233
  return _regenerator.default.wrap(function _callee2$(_context2) {
234
234
  while (1) switch (_context2.prev = _context2.next) {
235
235
  case 0:
@@ -241,38 +241,31 @@ var ResizableMediaSingle = /*#__PURE__*/function (_React$Component) {
241
241
  return _context2.abrupt("return");
242
242
  case 3:
243
243
  mediaNode = this.props.view.state.doc.nodeAt($pos.pos + 1);
244
- if (!(!mediaNode || !mediaNode.attrs.id)) {
245
- _context2.next = 6;
244
+ if (!mediaNode) {
245
+ _context2.next = 10;
246
246
  break;
247
247
  }
248
- return _context2.abrupt("return");
249
- case 6:
250
- mediaClient = (0, _mediaClient.getMediaClient)(viewMediaClientConfig);
251
- _context2.prev = 7;
252
- _context2.next = 10;
253
- return mediaClient.file.getCurrentState(mediaNode.attrs.id, {
254
- collectionName: mediaNode.attrs.collection
255
- });
248
+ _context2.next = 7;
249
+ return (0, _checkMediaType.checkMediaType)(mediaNode, viewMediaClientConfig);
250
+ case 7:
251
+ _context2.t0 = _context2.sent;
252
+ _context2.next = 11;
253
+ break;
256
254
  case 10:
257
- state = _context2.sent;
258
- if (state && state.status !== 'error' && state.mediaType === 'image') {
255
+ _context2.t0 = undefined;
256
+ case 11:
257
+ mediaType = _context2.t0;
258
+ isVideoFile = mediaType !== 'external' && mediaType !== 'image';
259
+ if (this.state.isVideoFile !== isVideoFile) {
259
260
  this.setState({
260
- isVideoFile: false
261
+ isVideoFile: isVideoFile
261
262
  });
262
263
  }
263
- _context2.next = 17;
264
- break;
265
264
  case 14:
266
- _context2.prev = 14;
267
- _context2.t0 = _context2["catch"](7);
268
- this.setState({
269
- isVideoFile: false
270
- });
271
- case 17:
272
265
  case "end":
273
266
  return _context2.stop();
274
267
  }
275
- }, _callee2, this, [[7, 14]]);
268
+ }, _callee2, this);
276
269
  }));
277
270
  function checkVideoFile(_x) {
278
271
  return _checkVideoFile.apply(this, arguments);
@@ -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.44.2";
9
+ var version = "187.44.3";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -3,7 +3,6 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import React from 'react';
4
4
  import { jsx } from '@emotion/react';
5
5
  import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
6
- import { getMediaClient } from '@atlaskit/media-client';
7
6
  import { calcPctFromPx, wrappedLayouts, handleSides, imageAlignmentMap } from '@atlaskit/editor-common/ui';
8
7
  import { nonWrappedLayouts, setNodeSelection } from '@atlaskit/editor-common/utils';
9
8
  import { akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
@@ -18,6 +17,7 @@ import { getMediaResizeAnalyticsEvent } from '../../utils/analytics';
18
17
  import throttle from 'lodash/throttle';
19
18
  import { MEDIA_PLUGIN_IS_RESIZING_KEY, MEDIA_PLUGIN_RESIZING_WIDTH_KEY } from '../../pm-plugins/main';
20
19
  import { ResizableMediaMigrationNotification } from './ResizableMediaMigrationNotification';
20
+ import { checkMediaType } from '../../utils/check-media-type';
21
21
  export const resizerNextTestId = 'mediaSingle.resizerNext.testid';
22
22
  class ResizableMediaSingleNext extends React.Component {
23
23
  constructor(props) {
@@ -374,22 +374,11 @@ class ResizableMediaSingleNext extends React.Component {
374
374
  return;
375
375
  }
376
376
  const mediaNode = this.props.view.state.doc.nodeAt(this.pos + 1);
377
- if (!mediaNode || !mediaNode.attrs.id) {
378
- return;
379
- }
380
- const mediaClient = getMediaClient(viewMediaClientConfig);
381
- try {
382
- const state = await mediaClient.file.getCurrentState(mediaNode.attrs.id, {
383
- collectionName: mediaNode.attrs.collection
384
- });
385
- if (state && state.status !== 'error' && state.mediaType === 'image') {
386
- this.setState({
387
- isVideoFile: false
388
- });
389
- }
390
- } catch (err) {
377
+ const mediaType = mediaNode ? await checkMediaType(mediaNode, viewMediaClientConfig) : undefined;
378
+ const isVideoFile = mediaType !== 'external' && mediaType !== 'image';
379
+ if (this.state.isVideoFile !== isVideoFile) {
391
380
  this.setState({
392
- isVideoFile: false
381
+ isVideoFile
393
382
  });
394
383
  }
395
384
  }
@@ -4,12 +4,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  import React from 'react';
5
5
  import { jsx } from '@emotion/react';
6
6
  import { findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
7
- import { getMediaClient } from '@atlaskit/media-client';
8
7
  import { calcPctFromPx, calcColumnsFromPx, wrappedLayouts, Resizer, calcMediaPxWidth, snapTo, handleSides, imageAlignmentMap } from '@atlaskit/editor-common/ui';
9
8
  import { akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
10
9
  import { wrapperStyle } from './styled';
11
10
  import { calculateOffsetLeft } from '@atlaskit/editor-common/media-single';
12
11
  import { calculateSnapPoints } from '@atlaskit/editor-common/utils';
12
+ import { checkMediaType } from '../../utils/check-media-type';
13
13
  export default class ResizableMediaSingle extends React.Component {
14
14
  constructor(...args) {
15
15
  super(...args);
@@ -193,22 +193,11 @@ export default class ResizableMediaSingle extends React.Component {
193
193
  return;
194
194
  }
195
195
  const mediaNode = this.props.view.state.doc.nodeAt($pos.pos + 1);
196
- if (!mediaNode || !mediaNode.attrs.id) {
197
- return;
198
- }
199
- const mediaClient = getMediaClient(viewMediaClientConfig);
200
- try {
201
- const state = await mediaClient.file.getCurrentState(mediaNode.attrs.id, {
202
- collectionName: mediaNode.attrs.collection
203
- });
204
- if (state && state.status !== 'error' && state.mediaType === 'image') {
205
- this.setState({
206
- isVideoFile: false
207
- });
208
- }
209
- } catch (err) {
196
+ const mediaType = mediaNode ? await checkMediaType(mediaNode, viewMediaClientConfig) : undefined;
197
+ const isVideoFile = mediaType !== 'external' && mediaType !== 'image';
198
+ if (this.state.isVideoFile !== isVideoFile) {
210
199
  this.setState({
211
- isVideoFile: false
200
+ isVideoFile
212
201
  });
213
202
  }
214
203
  }
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.44.2";
2
+ export const version = "187.44.3";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -14,7 +14,6 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
14
14
  import React from 'react';
15
15
  import { jsx } from '@emotion/react';
16
16
  import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
17
- import { getMediaClient } from '@atlaskit/media-client';
18
17
  import { calcPctFromPx, wrappedLayouts, handleSides, imageAlignmentMap } from '@atlaskit/editor-common/ui';
19
18
  import { nonWrappedLayouts, setNodeSelection } from '@atlaskit/editor-common/utils';
20
19
  import { akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
@@ -29,6 +28,7 @@ import { getMediaResizeAnalyticsEvent } from '../../utils/analytics';
29
28
  import throttle from 'lodash/throttle';
30
29
  import { MEDIA_PLUGIN_IS_RESIZING_KEY, MEDIA_PLUGIN_RESIZING_WIDTH_KEY } from '../../pm-plugins/main';
31
30
  import { ResizableMediaMigrationNotification } from './ResizableMediaMigrationNotification';
31
+ import { checkMediaType } from '../../utils/check-media-type';
32
32
  export var resizerNextTestId = 'mediaSingle.resizerNext.testid';
33
33
  var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
34
34
  _inherits(ResizableMediaSingleNext, _React$Component);
@@ -418,7 +418,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
418
418
  key: "checkVideoFile",
419
419
  value: function () {
420
420
  var _checkVideoFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(viewMediaClientConfig) {
421
- var mediaNode, mediaClient, state;
421
+ var mediaNode, mediaType, isVideoFile;
422
422
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
423
423
  while (1) switch (_context2.prev = _context2.next) {
424
424
  case 0:
@@ -429,38 +429,31 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
429
429
  return _context2.abrupt("return");
430
430
  case 2:
431
431
  mediaNode = this.props.view.state.doc.nodeAt(this.pos + 1);
432
- if (!(!mediaNode || !mediaNode.attrs.id)) {
433
- _context2.next = 5;
432
+ if (!mediaNode) {
433
+ _context2.next = 9;
434
434
  break;
435
435
  }
436
- return _context2.abrupt("return");
437
- case 5:
438
- mediaClient = getMediaClient(viewMediaClientConfig);
439
- _context2.prev = 6;
440
- _context2.next = 9;
441
- return mediaClient.file.getCurrentState(mediaNode.attrs.id, {
442
- collectionName: mediaNode.attrs.collection
443
- });
436
+ _context2.next = 6;
437
+ return checkMediaType(mediaNode, viewMediaClientConfig);
438
+ case 6:
439
+ _context2.t0 = _context2.sent;
440
+ _context2.next = 10;
441
+ break;
444
442
  case 9:
445
- state = _context2.sent;
446
- if (state && state.status !== 'error' && state.mediaType === 'image') {
443
+ _context2.t0 = undefined;
444
+ case 10:
445
+ mediaType = _context2.t0;
446
+ isVideoFile = mediaType !== 'external' && mediaType !== 'image';
447
+ if (this.state.isVideoFile !== isVideoFile) {
447
448
  this.setState({
448
- isVideoFile: false
449
+ isVideoFile: isVideoFile
449
450
  });
450
451
  }
451
- _context2.next = 16;
452
- break;
453
452
  case 13:
454
- _context2.prev = 13;
455
- _context2.t0 = _context2["catch"](6);
456
- this.setState({
457
- isVideoFile: false
458
- });
459
- case 16:
460
453
  case "end":
461
454
  return _context2.stop();
462
455
  }
463
- }, _callee2, this, [[6, 13]]);
456
+ }, _callee2, this);
464
457
  }));
465
458
  function checkVideoFile(_x) {
466
459
  return _checkVideoFile.apply(this, arguments);
@@ -14,12 +14,12 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
14
14
  import React from 'react';
15
15
  import { jsx } from '@emotion/react';
16
16
  import { findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
17
- import { getMediaClient } from '@atlaskit/media-client';
18
17
  import { calcPctFromPx, calcColumnsFromPx, wrappedLayouts, Resizer, calcMediaPxWidth, snapTo, handleSides, imageAlignmentMap } from '@atlaskit/editor-common/ui';
19
18
  import { akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
20
19
  import { wrapperStyle } from './styled';
21
20
  import { calculateOffsetLeft } from '@atlaskit/editor-common/media-single';
22
21
  import { calculateSnapPoints } from '@atlaskit/editor-common/utils';
22
+ import { checkMediaType } from '../../utils/check-media-type';
23
23
  var ResizableMediaSingle = /*#__PURE__*/function (_React$Component) {
24
24
  _inherits(ResizableMediaSingle, _React$Component);
25
25
  var _super = _createSuper(ResizableMediaSingle);
@@ -223,7 +223,7 @@ var ResizableMediaSingle = /*#__PURE__*/function (_React$Component) {
223
223
  key: "checkVideoFile",
224
224
  value: function () {
225
225
  var _checkVideoFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(viewMediaClientConfig) {
226
- var $pos, mediaNode, mediaClient, state;
226
+ var $pos, mediaNode, mediaType, isVideoFile;
227
227
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
228
228
  while (1) switch (_context2.prev = _context2.next) {
229
229
  case 0:
@@ -235,38 +235,31 @@ var ResizableMediaSingle = /*#__PURE__*/function (_React$Component) {
235
235
  return _context2.abrupt("return");
236
236
  case 3:
237
237
  mediaNode = this.props.view.state.doc.nodeAt($pos.pos + 1);
238
- if (!(!mediaNode || !mediaNode.attrs.id)) {
239
- _context2.next = 6;
238
+ if (!mediaNode) {
239
+ _context2.next = 10;
240
240
  break;
241
241
  }
242
- return _context2.abrupt("return");
243
- case 6:
244
- mediaClient = getMediaClient(viewMediaClientConfig);
245
- _context2.prev = 7;
246
- _context2.next = 10;
247
- return mediaClient.file.getCurrentState(mediaNode.attrs.id, {
248
- collectionName: mediaNode.attrs.collection
249
- });
242
+ _context2.next = 7;
243
+ return checkMediaType(mediaNode, viewMediaClientConfig);
244
+ case 7:
245
+ _context2.t0 = _context2.sent;
246
+ _context2.next = 11;
247
+ break;
250
248
  case 10:
251
- state = _context2.sent;
252
- if (state && state.status !== 'error' && state.mediaType === 'image') {
249
+ _context2.t0 = undefined;
250
+ case 11:
251
+ mediaType = _context2.t0;
252
+ isVideoFile = mediaType !== 'external' && mediaType !== 'image';
253
+ if (this.state.isVideoFile !== isVideoFile) {
253
254
  this.setState({
254
- isVideoFile: false
255
+ isVideoFile: isVideoFile
255
256
  });
256
257
  }
257
- _context2.next = 17;
258
- break;
259
258
  case 14:
260
- _context2.prev = 14;
261
- _context2.t0 = _context2["catch"](7);
262
- this.setState({
263
- isVideoFile: false
264
- });
265
- case 17:
266
259
  case "end":
267
260
  return _context2.stop();
268
261
  }
269
- }, _callee2, this, [[7, 14]]);
262
+ }, _callee2, this);
270
263
  }));
271
264
  function checkVideoFile(_x) {
272
265
  return _checkVideoFile.apply(this, arguments);
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "187.44.2";
2
+ export var version = "187.44.3";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.44.2",
3
+ "version": "187.44.3",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"