@atlaskit/editor-plugin-media 1.43.13 → 1.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/nodeviews/mediaGroup.js +4 -4
  3. package/dist/cjs/nodeviews/mediaGroupNext.js +4 -4
  4. package/dist/cjs/nodeviews/mediaInline.js +8 -8
  5. package/dist/cjs/nodeviews/mediaNodeUpdater.js +254 -177
  6. package/dist/cjs/nodeviews/mediaSingle.js +4 -4
  7. package/dist/cjs/nodeviews/mediaSingleNext.js +4 -4
  8. package/dist/cjs/pm-plugins/alt-text/ui/AltTextEdit.js +4 -0
  9. package/dist/cjs/pm-plugins/main.js +41 -13
  10. package/dist/cjs/pm-plugins/utils/media-single.js +43 -25
  11. package/dist/cjs/ui/MediaLinkingToolbar.js +1 -0
  12. package/dist/cjs/ui/toolbar/mediaInline.js +3 -3
  13. package/dist/es2019/nodeviews/mediaGroup.js +2 -2
  14. package/dist/es2019/nodeviews/mediaGroupNext.js +2 -2
  15. package/dist/es2019/nodeviews/mediaInline.js +5 -5
  16. package/dist/es2019/nodeviews/mediaNodeUpdater.js +78 -27
  17. package/dist/es2019/nodeviews/mediaSingle.js +2 -2
  18. package/dist/es2019/nodeviews/mediaSingleNext.js +2 -2
  19. package/dist/es2019/pm-plugins/alt-text/ui/AltTextEdit.js +4 -0
  20. package/dist/es2019/pm-plugins/main.js +42 -12
  21. package/dist/es2019/pm-plugins/utils/media-single.js +40 -18
  22. package/dist/es2019/ui/MediaLinkingToolbar.js +1 -0
  23. package/dist/es2019/ui/toolbar/mediaInline.js +3 -3
  24. package/dist/esm/nodeviews/mediaGroup.js +4 -4
  25. package/dist/esm/nodeviews/mediaGroupNext.js +4 -4
  26. package/dist/esm/nodeviews/mediaInline.js +8 -8
  27. package/dist/esm/nodeviews/mediaNodeUpdater.js +254 -177
  28. package/dist/esm/nodeviews/mediaSingle.js +4 -4
  29. package/dist/esm/nodeviews/mediaSingleNext.js +4 -4
  30. package/dist/esm/pm-plugins/alt-text/ui/AltTextEdit.js +4 -0
  31. package/dist/esm/pm-plugins/main.js +42 -14
  32. package/dist/esm/pm-plugins/utils/media-single.js +43 -25
  33. package/dist/esm/ui/MediaLinkingToolbar.js +1 -0
  34. package/dist/esm/ui/toolbar/mediaInline.js +3 -3
  35. package/dist/types/nodeviews/__mocks__/mediaNodeUpdater.d.ts +1 -0
  36. package/dist/types/nodeviews/mediaNodeUpdater.d.ts +4 -1
  37. package/dist/types/pm-plugins/main.d.ts +4 -1
  38. package/dist/types/pm-plugins/types.d.ts +2 -0
  39. package/dist/types/types/index.d.ts +2 -0
  40. package/dist/types-ts4.5/nodeviews/__mocks__/mediaNodeUpdater.d.ts +1 -0
  41. package/dist/types-ts4.5/nodeviews/mediaNodeUpdater.d.ts +4 -1
  42. package/dist/types-ts4.5/pm-plugins/main.d.ts +4 -1
  43. package/dist/types-ts4.5/pm-plugins/types.d.ts +2 -0
  44. package/dist/types-ts4.5/types/index.d.ts +2 -0
  45. package/package.json +13 -7
@@ -1,7 +1,10 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
1
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
3
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
4
  import _createClass from "@babel/runtime/helpers/createClass";
4
5
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
+ var _excluded = ["authProvider"],
7
+ _excluded2 = ["authProvider"];
5
8
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
9
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
10
  import _regeneratorRuntime from "@babel/runtime/regenerator";
@@ -12,7 +15,9 @@ import { getAttrsFromUrl, isImageRepresentationReady, isMediaBlobUrl as _isMedia
12
15
  import { getMediaClient } from '@atlaskit/media-client-react';
13
16
  import { fg } from '@atlaskit/platform-feature-flags';
14
17
  import { replaceExternalMedia, updateAllMediaNodesAttrs, updateCurrentMediaNodeAttrs, updateMediaNodeAttrs } from '../pm-plugins/commands/helpers';
18
+ import { stateKey as mediaStateKey } from '../pm-plugins/plugin-key';
15
19
  import { batchMediaNodeAttrsUpdate } from '../pm-plugins/utils/batchMediaNodeAttrs';
20
+ import { getIdentifier } from '../pm-plugins/utils/media-common';
16
21
  var isMediaTypeSupported = function isMediaTypeSupported(type) {
17
22
  if (type) {
18
23
  return ['image', 'file'].includes(type);
@@ -330,147 +335,218 @@ export var MediaNodeUpdater = /*#__PURE__*/function () {
330
335
  })(_this.props.view.state, _this.props.view.dispatch);
331
336
  }
332
337
  });
333
- _defineProperty(this, "hasDifferentContextId", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
334
- var nodeContextId, currentContextId;
338
+ _defineProperty(this, "shouldNodeBeDeepCopied", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
339
+ var _ref10, _this$props$mediaOpti, _this$props$mediaOpti2, _this$mediaPluginStat;
340
+ var scope, attrs, id, isIdentifierOutsideEditorScope;
335
341
  return _regeneratorRuntime.wrap(function _callee8$(_context8) {
336
342
  while (1) switch (_context8.prev = _context8.next) {
343
+ case 0:
344
+ scope = (_ref10 = (_this$props$mediaOpti = (_this$props$mediaOpti2 = _this.props.mediaOptions) === null || _this$props$mediaOpti2 === void 0 ? void 0 : _this$props$mediaOpti2.mediaShallowCopyScope) !== null && _this$props$mediaOpti !== void 0 ? _this$props$mediaOpti : (_this$mediaPluginStat = _this.mediaPluginState) === null || _this$mediaPluginStat === void 0 || (_this$mediaPluginStat = _this$mediaPluginStat.mediaOptions) === null || _this$mediaPluginStat === void 0 ? void 0 : _this$mediaPluginStat.mediaShallowCopyScope) !== null && _ref10 !== void 0 ? _ref10 : 'context';
345
+ if (!(scope === 'context')) {
346
+ _context8.next = 7;
347
+ break;
348
+ }
349
+ _context8.next = 4;
350
+ return _this.hasDifferentContextId();
351
+ case 4:
352
+ return _context8.abrupt("return", _context8.sent);
353
+ case 7:
354
+ attrs = _this.getAttrs();
355
+ if (!(!attrs || !_this.mediaPluginState)) {
356
+ _context8.next = 10;
357
+ break;
358
+ }
359
+ return _context8.abrupt("return", false);
360
+ case 10:
361
+ id = getIdentifier(attrs);
362
+ _context8.next = 13;
363
+ return _this.mediaPluginState.isIdentifierInEditorScope(id);
364
+ case 13:
365
+ isIdentifierOutsideEditorScope = !_context8.sent;
366
+ return _context8.abrupt("return", isIdentifierOutsideEditorScope);
367
+ case 15:
368
+ case "end":
369
+ return _context8.stop();
370
+ }
371
+ }, _callee8);
372
+ })));
373
+ _defineProperty(this, "hasDifferentContextId", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
374
+ var nodeContextId, currentContextId;
375
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
376
+ while (1) switch (_context9.prev = _context9.next) {
337
377
  case 0:
338
378
  nodeContextId = _this.getNodeContextId();
339
- _context8.next = 3;
379
+ _context9.next = 3;
340
380
  return _this.getObjectId();
341
381
  case 3:
342
- currentContextId = _context8.sent;
382
+ currentContextId = _context9.sent;
343
383
  if (!(nodeContextId && currentContextId && nodeContextId !== currentContextId)) {
344
- _context8.next = 6;
384
+ _context9.next = 6;
345
385
  break;
346
386
  }
347
- return _context8.abrupt("return", true);
387
+ return _context9.abrupt("return", true);
348
388
  case 6:
349
- return _context8.abrupt("return", false);
389
+ return _context9.abrupt("return", false);
350
390
  case 7:
351
391
  case "end":
352
- return _context8.stop();
392
+ return _context9.stop();
353
393
  }
354
- }, _callee8);
394
+ }, _callee9);
355
395
  })));
356
- _defineProperty(this, "isNodeFromDifferentCollection", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
396
+ _defineProperty(this, "isNodeFromDifferentCollection", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
357
397
  var mediaProvider, currentCollectionName, attrs, nodeCollection, __contextId, contextId;
358
- return _regeneratorRuntime.wrap(function _callee9$(_context9) {
359
- while (1) switch (_context9.prev = _context9.next) {
398
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
399
+ while (1) switch (_context10.prev = _context10.next) {
360
400
  case 0:
361
- _context9.next = 2;
401
+ _context10.next = 2;
362
402
  return _this.props.mediaProvider;
363
403
  case 2:
364
- mediaProvider = _context9.sent;
404
+ mediaProvider = _context10.sent;
365
405
  if (!(!mediaProvider || !mediaProvider.uploadParams)) {
366
- _context9.next = 5;
406
+ _context10.next = 5;
367
407
  break;
368
408
  }
369
- return _context9.abrupt("return", false);
409
+ return _context10.abrupt("return", false);
370
410
  case 5:
371
411
  currentCollectionName = mediaProvider.uploadParams.collection;
372
412
  attrs = _this.getAttrs();
373
413
  if (!(!attrs || attrs && !isMediaTypeSupported(attrs.type))) {
374
- _context9.next = 9;
414
+ _context10.next = 9;
375
415
  break;
376
416
  }
377
- return _context9.abrupt("return", false);
417
+ return _context10.abrupt("return", false);
378
418
  case 9:
379
419
  nodeCollection = attrs.collection, __contextId = attrs.__contextId;
380
- _context9.t0 = __contextId;
381
- if (_context9.t0) {
382
- _context9.next = 15;
420
+ _context10.t0 = __contextId;
421
+ if (_context10.t0) {
422
+ _context10.next = 15;
383
423
  break;
384
424
  }
385
- _context9.next = 14;
425
+ _context10.next = 14;
386
426
  return _this.getObjectId();
387
427
  case 14:
388
- _context9.t0 = _context9.sent;
428
+ _context10.t0 = _context10.sent;
389
429
  case 15:
390
- contextId = _context9.t0;
430
+ contextId = _context10.t0;
391
431
  if (!(contextId && currentCollectionName !== nodeCollection)) {
392
- _context9.next = 18;
432
+ _context10.next = 18;
393
433
  break;
394
434
  }
395
- return _context9.abrupt("return", true);
435
+ return _context10.abrupt("return", true);
396
436
  case 18:
397
- return _context9.abrupt("return", false);
437
+ return _context10.abrupt("return", false);
398
438
  case 19:
399
439
  case "end":
400
- return _context9.stop();
440
+ return _context10.stop();
401
441
  }
402
- }, _callee9);
442
+ }, _callee10);
403
443
  })));
444
+ _defineProperty(this, "handleCopyFileSwitcher", /*#__PURE__*/function () {
445
+ var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(attrs) {
446
+ var mediaClient, source, destination, traceContext, _sourceAP, copyV2Source, _destAP, copyV2Destination, _yield$mediaClient$fi, id, _yield$mediaClient$fi2, _id;
447
+ return _regeneratorRuntime.wrap(function _callee11$(_context11) {
448
+ while (1) switch (_context11.prev = _context11.next) {
449
+ case 0:
450
+ mediaClient = attrs.mediaClient, source = attrs.source, destination = attrs.destination, traceContext = attrs.traceContext;
451
+ if (!fg('platform_media_copy_and_paste_v2')) {
452
+ _context11.next = 11;
453
+ break;
454
+ }
455
+ // don't need authProviders for v2 copy
456
+ _sourceAP = source.authProvider, copyV2Source = _objectWithoutProperties(source, _excluded);
457
+ _destAP = destination.authProvider, copyV2Destination = _objectWithoutProperties(destination, _excluded2);
458
+ _context11.next = 6;
459
+ return mediaClient.file.copyFile(copyV2Source, copyV2Destination, undefined, traceContext);
460
+ case 6:
461
+ _yield$mediaClient$fi = _context11.sent;
462
+ id = _yield$mediaClient$fi.id;
463
+ return _context11.abrupt("return", id);
464
+ case 11:
465
+ _context11.next = 13;
466
+ return mediaClient.file.copyFile(source, destination, undefined, traceContext);
467
+ case 13:
468
+ _yield$mediaClient$fi2 = _context11.sent;
469
+ _id = _yield$mediaClient$fi2.id;
470
+ return _context11.abrupt("return", _id);
471
+ case 16:
472
+ case "end":
473
+ return _context11.stop();
474
+ }
475
+ }, _callee11);
476
+ }));
477
+ return function (_x4) {
478
+ return _ref13.apply(this, arguments);
479
+ };
480
+ }());
404
481
  _defineProperty(this, "copyNodeFromBlobUrl", /*#__PURE__*/function () {
405
- var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(getPos) {
406
- var attrs, url, mediaAttrs, mediaProvider, currentCollectionName, contextId, id, collection, height, width, mimeType, name, size, uploadMediaClientConfig, mediaClient, auth, source, destination, mediaFile, pos;
407
- return _regeneratorRuntime.wrap(function _callee10$(_context10) {
408
- while (1) switch (_context10.prev = _context10.next) {
482
+ var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(getPos) {
483
+ var attrs, url, mediaAttrs, mediaProvider, currentCollectionName, contextId, id, collection, height, width, mimeType, name, size, uploadMediaClientConfig, mediaClient, getAuthFromContext, mediaFileId, pos;
484
+ return _regeneratorRuntime.wrap(function _callee12$(_context12) {
485
+ while (1) switch (_context12.prev = _context12.next) {
409
486
  case 0:
410
487
  attrs = _this.getAttrs();
411
488
  if (!(!attrs || attrs.type !== 'external')) {
412
- _context10.next = 3;
489
+ _context12.next = 3;
413
490
  break;
414
491
  }
415
- return _context10.abrupt("return");
492
+ return _context12.abrupt("return");
416
493
  case 3:
417
494
  url = attrs.url;
418
495
  mediaAttrs = getAttrsFromUrl(url);
419
496
  if (mediaAttrs) {
420
- _context10.next = 7;
497
+ _context12.next = 7;
421
498
  break;
422
499
  }
423
- return _context10.abrupt("return");
500
+ return _context12.abrupt("return");
424
501
  case 7:
425
- _context10.next = 9;
502
+ _context12.next = 9;
426
503
  return _this.props.mediaProvider;
427
504
  case 9:
428
- mediaProvider = _context10.sent;
505
+ mediaProvider = _context12.sent;
429
506
  if (!(!mediaProvider || !mediaProvider.uploadParams)) {
430
- _context10.next = 12;
507
+ _context12.next = 12;
431
508
  break;
432
509
  }
433
- return _context10.abrupt("return");
510
+ return _context12.abrupt("return");
434
511
  case 12:
435
512
  currentCollectionName = mediaProvider.uploadParams.collection;
436
513
  contextId = mediaAttrs.contextId, id = mediaAttrs.id, collection = mediaAttrs.collection, height = mediaAttrs.height, width = mediaAttrs.width, mimeType = mediaAttrs.mimeType, name = mediaAttrs.name, size = mediaAttrs.size;
437
514
  uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
438
515
  if (!(!uploadMediaClientConfig || !uploadMediaClientConfig.getAuthFromContext)) {
439
- _context10.next = 17;
516
+ _context12.next = 17;
440
517
  break;
441
518
  }
442
- return _context10.abrupt("return");
519
+ return _context12.abrupt("return");
443
520
  case 17:
444
521
  mediaClient = getMediaClient(uploadMediaClientConfig);
445
- _context10.next = 20;
446
- return uploadMediaClientConfig.getAuthFromContext(contextId);
447
- case 20:
448
- auth = _context10.sent;
449
- source = {
450
- id: id,
451
- collection: collection,
452
- authProvider: function authProvider() {
453
- return Promise.resolve(auth);
522
+ getAuthFromContext = uploadMediaClientConfig.getAuthFromContext;
523
+ _context12.next = 21;
524
+ return _this.handleCopyFileSwitcher({
525
+ mediaClient: mediaClient,
526
+ source: {
527
+ id: id,
528
+ collection: collection,
529
+ authProvider: function authProvider() {
530
+ return getAuthFromContext(contextId);
531
+ }
532
+ },
533
+ destination: {
534
+ collection: currentCollectionName,
535
+ authProvider: uploadMediaClientConfig.authProvider,
536
+ occurrenceKey: uuidV4()
454
537
  }
455
- };
456
- destination = {
457
- collection: currentCollectionName,
458
- authProvider: uploadMediaClientConfig.authProvider,
459
- occurrenceKey: uuidV4()
460
- };
461
- _context10.next = 25;
462
- return mediaClient.file.copyFile(source, destination);
463
- case 25:
464
- mediaFile = _context10.sent;
538
+ });
539
+ case 21:
540
+ mediaFileId = _context12.sent;
465
541
  pos = getPos();
466
542
  if (!(typeof pos !== 'number')) {
467
- _context10.next = 29;
543
+ _context12.next = 25;
468
544
  break;
469
545
  }
470
- return _context10.abrupt("return");
471
- case 29:
546
+ return _context12.abrupt("return");
547
+ case 25:
472
548
  replaceExternalMedia(pos + 1, {
473
- id: mediaFile.id,
549
+ id: mediaFileId,
474
550
  collection: currentCollectionName,
475
551
  height: height,
476
552
  width: width,
@@ -478,39 +554,39 @@ export var MediaNodeUpdater = /*#__PURE__*/function () {
478
554
  __fileMimeType: mimeType,
479
555
  __fileSize: size
480
556
  })(_this.props.view.state, _this.props.view.dispatch);
481
- case 30:
557
+ case 26:
482
558
  case "end":
483
- return _context10.stop();
559
+ return _context12.stop();
484
560
  }
485
- }, _callee10);
561
+ }, _callee12);
486
562
  }));
487
- return function (_x4) {
488
- return _ref11.apply(this, arguments);
563
+ return function (_x5) {
564
+ return _ref14.apply(this, arguments);
489
565
  };
490
566
  }());
491
567
  // Copies the pasted node into the current collection using a getPos handler
492
568
  _defineProperty(this, "copyNodeFromPos", /*#__PURE__*/function () {
493
- var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(getPos, traceContext) {
569
+ var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(getPos, traceContext) {
494
570
  var attrs, copiedAttrs;
495
- return _regeneratorRuntime.wrap(function _callee11$(_context11) {
496
- while (1) switch (_context11.prev = _context11.next) {
571
+ return _regeneratorRuntime.wrap(function _callee13$(_context13) {
572
+ while (1) switch (_context13.prev = _context13.next) {
497
573
  case 0:
498
574
  attrs = _this.getAttrs();
499
575
  if (!(!attrs || attrs && !isMediaTypeSupported(attrs.type))) {
500
- _context11.next = 3;
576
+ _context13.next = 3;
501
577
  break;
502
578
  }
503
- return _context11.abrupt("return");
579
+ return _context13.abrupt("return");
504
580
  case 3:
505
- _context11.next = 5;
581
+ _context13.next = 5;
506
582
  return _this.copyFile(attrs.id, attrs.collection, traceContext);
507
583
  case 5:
508
- copiedAttrs = _context11.sent;
584
+ copiedAttrs = _context13.sent;
509
585
  if (copiedAttrs) {
510
- _context11.next = 8;
586
+ _context13.next = 8;
511
587
  break;
512
588
  }
513
- return _context11.abrupt("return");
589
+ return _context13.abrupt("return");
514
590
  case 8:
515
591
  updateCurrentMediaNodeAttrs(copiedAttrs, {
516
592
  node: _this.props.node,
@@ -518,116 +594,117 @@ export var MediaNodeUpdater = /*#__PURE__*/function () {
518
594
  })(_this.props.view.state, _this.props.view.dispatch);
519
595
  case 9:
520
596
  case "end":
521
- return _context11.stop();
597
+ return _context13.stop();
522
598
  }
523
- }, _callee11);
599
+ }, _callee13);
524
600
  }));
525
- return function (_x5, _x6) {
526
- return _ref12.apply(this, arguments);
601
+ return function (_x6, _x7) {
602
+ return _ref15.apply(this, arguments);
527
603
  };
528
604
  }());
529
605
  // Copies the pasted node into the current collection
530
606
  _defineProperty(this, "copyNode", /*#__PURE__*/function () {
531
- var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(traceContext) {
607
+ var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(traceContext) {
532
608
  var attrs, view, copiedAttrs;
533
- return _regeneratorRuntime.wrap(function _callee12$(_context12) {
534
- while (1) switch (_context12.prev = _context12.next) {
609
+ return _regeneratorRuntime.wrap(function _callee14$(_context14) {
610
+ while (1) switch (_context14.prev = _context14.next) {
535
611
  case 0:
536
612
  attrs = _this.getAttrs();
537
613
  view = _this.props.view;
538
614
  if (!(!attrs || attrs && !isMediaTypeSupported(attrs.type))) {
539
- _context12.next = 4;
615
+ _context14.next = 4;
540
616
  break;
541
617
  }
542
- return _context12.abrupt("return");
618
+ return _context14.abrupt("return");
543
619
  case 4:
544
- _context12.next = 6;
620
+ _context14.next = 6;
545
621
  return _this.copyFile(attrs.id, attrs.collection, traceContext);
546
622
  case 6:
547
- copiedAttrs = _context12.sent;
623
+ copiedAttrs = _context14.sent;
548
624
  if (copiedAttrs) {
549
- _context12.next = 9;
625
+ _context14.next = 9;
550
626
  break;
551
627
  }
552
- return _context12.abrupt("return");
628
+ return _context14.abrupt("return");
553
629
  case 9:
554
630
  updateMediaNodeAttrs(attrs.id, copiedAttrs)(view.state, view.dispatch);
555
631
  case 10:
556
632
  case "end":
557
- return _context12.stop();
633
+ return _context14.stop();
558
634
  }
559
- }, _callee12);
635
+ }, _callee14);
560
636
  }));
561
- return function (_x7) {
562
- return _ref13.apply(this, arguments);
637
+ return function (_x8) {
638
+ return _ref16.apply(this, arguments);
563
639
  };
564
640
  }());
565
641
  _defineProperty(this, "copyFile", /*#__PURE__*/function () {
566
- var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(id, collection, traceContext) {
567
- var mediaProvider, nodeContextId, uploadMediaClientConfig, mediaClient, auth, objectId, source, currentCollectionName, destination, mediaFile;
568
- return _regeneratorRuntime.wrap(function _callee13$(_context13) {
569
- while (1) switch (_context13.prev = _context13.next) {
642
+ var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(id, collection, traceContext) {
643
+ var mediaProvider, nodeContextId, uploadMediaClientConfig, mediaClient, currentCollectionName, objectId, getAuthFromContext, mediaFileId;
644
+ return _regeneratorRuntime.wrap(function _callee15$(_context15) {
645
+ while (1) switch (_context15.prev = _context15.next) {
570
646
  case 0:
571
- _context13.next = 2;
647
+ _context15.next = 2;
572
648
  return _this.props.mediaProvider;
573
649
  case 2:
574
- mediaProvider = _context13.sent;
650
+ mediaProvider = _context15.sent;
575
651
  if (mediaProvider !== null && mediaProvider !== void 0 && mediaProvider.uploadParams) {
576
- _context13.next = 5;
652
+ _context15.next = 5;
577
653
  break;
578
654
  }
579
- return _context13.abrupt("return");
655
+ return _context15.abrupt("return");
580
656
  case 5:
581
657
  nodeContextId = _this.getNodeContextId();
582
658
  uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
583
659
  if (!(!(uploadMediaClientConfig !== null && uploadMediaClientConfig !== void 0 && uploadMediaClientConfig.getAuthFromContext) || !nodeContextId)) {
584
- _context13.next = 9;
660
+ _context15.next = 9;
585
661
  break;
586
662
  }
587
- return _context13.abrupt("return");
663
+ return _context15.abrupt("return");
588
664
  case 9:
589
665
  mediaClient = getMediaClient(uploadMediaClientConfig);
590
- _context13.next = 12;
591
- return uploadMediaClientConfig.getAuthFromContext(nodeContextId);
592
- case 12:
593
- auth = _context13.sent;
594
- _context13.next = 15;
595
- return _this.getObjectId();
596
- case 15:
597
- objectId = _context13.sent;
598
- source = {
599
- id: id,
600
- collection: collection,
601
- authProvider: function authProvider() {
602
- return Promise.resolve(auth);
603
- }
604
- };
605
666
  currentCollectionName = mediaProvider.uploadParams.collection;
606
- destination = {
607
- collection: currentCollectionName,
608
- authProvider: uploadMediaClientConfig.authProvider,
609
- occurrenceKey: uuidV4()
610
- };
611
- _context13.next = 21;
612
- return mediaClient.file.copyFile(source, destination, undefined, traceContext);
613
- case 21:
614
- mediaFile = _context13.sent;
615
- return _context13.abrupt("return", {
616
- id: mediaFile.id,
667
+ _context15.next = 13;
668
+ return _this.getObjectId();
669
+ case 13:
670
+ objectId = _context15.sent;
671
+ getAuthFromContext = uploadMediaClientConfig.getAuthFromContext;
672
+ _context15.next = 17;
673
+ return _this.handleCopyFileSwitcher({
674
+ mediaClient: mediaClient,
675
+ source: {
676
+ id: id,
677
+ collection: collection,
678
+ authProvider: function authProvider() {
679
+ return getAuthFromContext(nodeContextId);
680
+ }
681
+ },
682
+ destination: {
683
+ collection: currentCollectionName,
684
+ authProvider: uploadMediaClientConfig.authProvider,
685
+ occurrenceKey: uuidV4()
686
+ },
687
+ traceContext: traceContext
688
+ });
689
+ case 17:
690
+ mediaFileId = _context15.sent;
691
+ return _context15.abrupt("return", {
692
+ id: mediaFileId,
617
693
  collection: currentCollectionName,
618
694
  __contextId: objectId
619
695
  });
620
- case 23:
696
+ case 19:
621
697
  case "end":
622
- return _context13.stop();
698
+ return _context15.stop();
623
699
  }
624
- }, _callee13);
700
+ }, _callee15);
625
701
  }));
626
- return function (_x8, _x9, _x10) {
627
- return _ref14.apply(this, arguments);
702
+ return function (_x9, _x10, _x11) {
703
+ return _ref17.apply(this, arguments);
628
704
  };
629
705
  }());
630
706
  this.props = props;
707
+ this.mediaPluginState = mediaStateKey.getState(props.view.state);
631
708
  }
632
709
  return _createClass(MediaNodeUpdater, [{
633
710
  key: "setProps",
@@ -643,42 +720,42 @@ export var MediaNodeUpdater = /*#__PURE__*/function () {
643
720
  }, {
644
721
  key: "getRemoteDimensions",
645
722
  value: function () {
646
- var _getRemoteDimensions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
723
+ var _getRemoteDimensions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
647
724
  var mediaProvider, mediaOptions, attrs, height, width, id, collection, viewMediaClientConfig, mediaClient, currentState, imageMetadata;
648
- return _regeneratorRuntime.wrap(function _callee14$(_context14) {
649
- while (1) switch (_context14.prev = _context14.next) {
725
+ return _regeneratorRuntime.wrap(function _callee16$(_context16) {
726
+ while (1) switch (_context16.prev = _context16.next) {
650
727
  case 0:
651
- _context14.next = 2;
728
+ _context16.next = 2;
652
729
  return this.props.mediaProvider;
653
730
  case 2:
654
- mediaProvider = _context14.sent;
731
+ mediaProvider = _context16.sent;
655
732
  mediaOptions = this.props.mediaOptions;
656
733
  attrs = this.getAttrs();
657
734
  if (!(!mediaProvider || !attrs)) {
658
- _context14.next = 7;
735
+ _context16.next = 7;
659
736
  break;
660
737
  }
661
- return _context14.abrupt("return", false);
738
+ return _context16.abrupt("return", false);
662
739
  case 7:
663
740
  height = attrs.height, width = attrs.width;
664
741
  if (!(attrs.type === 'external' || !attrs.id)) {
665
- _context14.next = 10;
742
+ _context16.next = 10;
666
743
  break;
667
744
  }
668
- return _context14.abrupt("return", false);
745
+ return _context16.abrupt("return", false);
669
746
  case 10:
670
747
  id = attrs.id, collection = attrs.collection;
671
748
  if (!(height && width)) {
672
- _context14.next = 13;
749
+ _context16.next = 13;
673
750
  break;
674
751
  }
675
- return _context14.abrupt("return", false);
752
+ return _context16.abrupt("return", false);
676
753
  case 13:
677
754
  if (!(mediaOptions && !mediaOptions.allowRemoteDimensionsFetch)) {
678
- _context14.next = 15;
755
+ _context16.next = 15;
679
756
  break;
680
757
  }
681
- return _context14.abrupt("return", {
758
+ return _context16.abrupt("return", {
682
759
  id: id,
683
760
  height: DEFAULT_IMAGE_HEIGHT,
684
761
  width: DEFAULT_IMAGE_WIDTH
@@ -686,40 +763,40 @@ export var MediaNodeUpdater = /*#__PURE__*/function () {
686
763
  case 15:
687
764
  viewMediaClientConfig = mediaProvider.viewMediaClientConfig;
688
765
  mediaClient = getMediaClient(viewMediaClientConfig);
689
- _context14.next = 19;
766
+ _context16.next = 19;
690
767
  return mediaClient.file.getCurrentState(id, {
691
768
  collectionName: collection
692
769
  });
693
770
  case 19:
694
- currentState = _context14.sent;
771
+ currentState = _context16.sent;
695
772
  if (isImageRepresentationReady(currentState)) {
696
- _context14.next = 22;
773
+ _context16.next = 22;
697
774
  break;
698
775
  }
699
- return _context14.abrupt("return", false);
776
+ return _context16.abrupt("return", false);
700
777
  case 22:
701
- _context14.next = 24;
778
+ _context16.next = 24;
702
779
  return mediaClient.getImageMetadata(id, {
703
780
  collection: collection
704
781
  });
705
782
  case 24:
706
- imageMetadata = _context14.sent;
783
+ imageMetadata = _context16.sent;
707
784
  if (!(!imageMetadata || !imageMetadata.original)) {
708
- _context14.next = 27;
785
+ _context16.next = 27;
709
786
  break;
710
787
  }
711
- return _context14.abrupt("return", false);
788
+ return _context16.abrupt("return", false);
712
789
  case 27:
713
- return _context14.abrupt("return", {
790
+ return _context16.abrupt("return", {
714
791
  id: id,
715
792
  height: imageMetadata.original.height || DEFAULT_IMAGE_HEIGHT,
716
793
  width: imageMetadata.original.width || DEFAULT_IMAGE_WIDTH
717
794
  });
718
795
  case 28:
719
796
  case "end":
720
- return _context14.stop();
797
+ return _context16.stop();
721
798
  }
722
- }, _callee14, this);
799
+ }, _callee16, this);
723
800
  }));
724
801
  function getRemoteDimensions() {
725
802
  return _getRemoteDimensions.apply(this, arguments);
@@ -729,38 +806,38 @@ export var MediaNodeUpdater = /*#__PURE__*/function () {
729
806
  }, {
730
807
  key: "handleExternalMedia",
731
808
  value: function () {
732
- var _handleExternalMedia = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(getPos) {
733
- return _regeneratorRuntime.wrap(function _callee15$(_context15) {
734
- while (1) switch (_context15.prev = _context15.next) {
809
+ var _handleExternalMedia = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(getPos) {
810
+ return _regeneratorRuntime.wrap(function _callee17$(_context17) {
811
+ while (1) switch (_context17.prev = _context17.next) {
735
812
  case 0:
736
813
  if (!this.isMediaBlobUrl()) {
737
- _context15.next = 12;
814
+ _context17.next = 12;
738
815
  break;
739
816
  }
740
- _context15.prev = 1;
741
- _context15.next = 4;
817
+ _context17.prev = 1;
818
+ _context17.next = 4;
742
819
  return this.copyNodeFromBlobUrl(getPos);
743
820
  case 4:
744
- _context15.next = 10;
821
+ _context17.next = 10;
745
822
  break;
746
823
  case 6:
747
- _context15.prev = 6;
748
- _context15.t0 = _context15["catch"](1);
749
- _context15.next = 10;
824
+ _context17.prev = 6;
825
+ _context17.t0 = _context17["catch"](1);
826
+ _context17.next = 10;
750
827
  return this.uploadExternalMedia(getPos);
751
828
  case 10:
752
- _context15.next = 14;
829
+ _context17.next = 14;
753
830
  break;
754
831
  case 12:
755
- _context15.next = 14;
832
+ _context17.next = 14;
756
833
  return this.uploadExternalMedia(getPos);
757
834
  case 14:
758
835
  case "end":
759
- return _context15.stop();
836
+ return _context17.stop();
760
837
  }
761
- }, _callee15, this, [[1, 6]]);
838
+ }, _callee17, this, [[1, 6]]);
762
839
  }));
763
- function handleExternalMedia(_x11) {
840
+ function handleExternalMedia(_x12) {
764
841
  return _handleExternalMedia.apply(this, arguments);
765
842
  }
766
843
  return handleExternalMedia;