@atlaskit/editor-plugin-media 1.43.14 → 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.
- package/CHANGELOG.md +9 -0
- package/dist/cjs/nodeviews/mediaGroup.js +4 -4
- package/dist/cjs/nodeviews/mediaGroupNext.js +4 -4
- package/dist/cjs/nodeviews/mediaInline.js +8 -8
- package/dist/cjs/nodeviews/mediaNodeUpdater.js +179 -141
- package/dist/cjs/nodeviews/mediaSingle.js +4 -4
- package/dist/cjs/nodeviews/mediaSingleNext.js +4 -4
- package/dist/cjs/pm-plugins/main.js +41 -13
- package/dist/es2019/nodeviews/mediaGroup.js +2 -2
- package/dist/es2019/nodeviews/mediaGroupNext.js +2 -2
- package/dist/es2019/nodeviews/mediaInline.js +5 -5
- package/dist/es2019/nodeviews/mediaNodeUpdater.js +18 -0
- package/dist/es2019/nodeviews/mediaSingle.js +2 -2
- package/dist/es2019/nodeviews/mediaSingleNext.js +2 -2
- package/dist/es2019/pm-plugins/main.js +42 -12
- package/dist/esm/nodeviews/mediaGroup.js +4 -4
- package/dist/esm/nodeviews/mediaGroupNext.js +4 -4
- package/dist/esm/nodeviews/mediaInline.js +8 -8
- package/dist/esm/nodeviews/mediaNodeUpdater.js +179 -141
- package/dist/esm/nodeviews/mediaSingle.js +4 -4
- package/dist/esm/nodeviews/mediaSingleNext.js +4 -4
- package/dist/esm/pm-plugins/main.js +42 -14
- package/dist/types/nodeviews/__mocks__/mediaNodeUpdater.d.ts +1 -0
- package/dist/types/nodeviews/mediaNodeUpdater.d.ts +3 -1
- package/dist/types/pm-plugins/main.d.ts +4 -1
- package/dist/types/pm-plugins/types.d.ts +2 -0
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types-ts4.5/nodeviews/__mocks__/mediaNodeUpdater.d.ts +1 -0
- package/dist/types-ts4.5/nodeviews/mediaNodeUpdater.d.ts +3 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +4 -1
- package/dist/types-ts4.5/pm-plugins/types.d.ts +2 -0
- package/dist/types-ts4.5/types/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -18,7 +18,9 @@ var _mediaClient = require("@atlaskit/media-client");
|
|
|
18
18
|
var _mediaClientReact = require("@atlaskit/media-client-react");
|
|
19
19
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
20
|
var _helpers = require("../pm-plugins/commands/helpers");
|
|
21
|
+
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
21
22
|
var _batchMediaNodeAttrs = require("../pm-plugins/utils/batchMediaNodeAttrs");
|
|
23
|
+
var _mediaCommon = require("../pm-plugins/utils/media-common");
|
|
22
24
|
var _excluded = ["authProvider"],
|
|
23
25
|
_excluded2 = ["authProvider"];
|
|
24
26
|
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; }
|
|
@@ -340,157 +342,192 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
340
342
|
})(_this.props.view.state, _this.props.view.dispatch);
|
|
341
343
|
}
|
|
342
344
|
});
|
|
343
|
-
(0, _defineProperty2.default)(this, "
|
|
344
|
-
var
|
|
345
|
+
(0, _defineProperty2.default)(this, "shouldNodeBeDeepCopied", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
|
346
|
+
var _ref10, _this$props$mediaOpti, _this$props$mediaOpti2, _this$mediaPluginStat;
|
|
347
|
+
var scope, attrs, id, isIdentifierOutsideEditorScope;
|
|
345
348
|
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
346
349
|
while (1) switch (_context8.prev = _context8.next) {
|
|
350
|
+
case 0:
|
|
351
|
+
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';
|
|
352
|
+
if (!(scope === 'context')) {
|
|
353
|
+
_context8.next = 7;
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
_context8.next = 4;
|
|
357
|
+
return _this.hasDifferentContextId();
|
|
358
|
+
case 4:
|
|
359
|
+
return _context8.abrupt("return", _context8.sent);
|
|
360
|
+
case 7:
|
|
361
|
+
attrs = _this.getAttrs();
|
|
362
|
+
if (!(!attrs || !_this.mediaPluginState)) {
|
|
363
|
+
_context8.next = 10;
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
return _context8.abrupt("return", false);
|
|
367
|
+
case 10:
|
|
368
|
+
id = (0, _mediaCommon.getIdentifier)(attrs);
|
|
369
|
+
_context8.next = 13;
|
|
370
|
+
return _this.mediaPluginState.isIdentifierInEditorScope(id);
|
|
371
|
+
case 13:
|
|
372
|
+
isIdentifierOutsideEditorScope = !_context8.sent;
|
|
373
|
+
return _context8.abrupt("return", isIdentifierOutsideEditorScope);
|
|
374
|
+
case 15:
|
|
375
|
+
case "end":
|
|
376
|
+
return _context8.stop();
|
|
377
|
+
}
|
|
378
|
+
}, _callee8);
|
|
379
|
+
})));
|
|
380
|
+
(0, _defineProperty2.default)(this, "hasDifferentContextId", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
|
|
381
|
+
var nodeContextId, currentContextId;
|
|
382
|
+
return _regenerator.default.wrap(function _callee9$(_context9) {
|
|
383
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
347
384
|
case 0:
|
|
348
385
|
nodeContextId = _this.getNodeContextId();
|
|
349
|
-
|
|
386
|
+
_context9.next = 3;
|
|
350
387
|
return _this.getObjectId();
|
|
351
388
|
case 3:
|
|
352
|
-
currentContextId =
|
|
389
|
+
currentContextId = _context9.sent;
|
|
353
390
|
if (!(nodeContextId && currentContextId && nodeContextId !== currentContextId)) {
|
|
354
|
-
|
|
391
|
+
_context9.next = 6;
|
|
355
392
|
break;
|
|
356
393
|
}
|
|
357
|
-
return
|
|
394
|
+
return _context9.abrupt("return", true);
|
|
358
395
|
case 6:
|
|
359
|
-
return
|
|
396
|
+
return _context9.abrupt("return", false);
|
|
360
397
|
case 7:
|
|
361
398
|
case "end":
|
|
362
|
-
return
|
|
399
|
+
return _context9.stop();
|
|
363
400
|
}
|
|
364
|
-
},
|
|
401
|
+
}, _callee9);
|
|
365
402
|
})));
|
|
366
|
-
(0, _defineProperty2.default)(this, "isNodeFromDifferentCollection", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
403
|
+
(0, _defineProperty2.default)(this, "isNodeFromDifferentCollection", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
|
|
367
404
|
var mediaProvider, currentCollectionName, attrs, nodeCollection, __contextId, contextId;
|
|
368
|
-
return _regenerator.default.wrap(function
|
|
369
|
-
while (1) switch (
|
|
405
|
+
return _regenerator.default.wrap(function _callee10$(_context10) {
|
|
406
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
370
407
|
case 0:
|
|
371
|
-
|
|
408
|
+
_context10.next = 2;
|
|
372
409
|
return _this.props.mediaProvider;
|
|
373
410
|
case 2:
|
|
374
|
-
mediaProvider =
|
|
411
|
+
mediaProvider = _context10.sent;
|
|
375
412
|
if (!(!mediaProvider || !mediaProvider.uploadParams)) {
|
|
376
|
-
|
|
413
|
+
_context10.next = 5;
|
|
377
414
|
break;
|
|
378
415
|
}
|
|
379
|
-
return
|
|
416
|
+
return _context10.abrupt("return", false);
|
|
380
417
|
case 5:
|
|
381
418
|
currentCollectionName = mediaProvider.uploadParams.collection;
|
|
382
419
|
attrs = _this.getAttrs();
|
|
383
420
|
if (!(!attrs || attrs && !isMediaTypeSupported(attrs.type))) {
|
|
384
|
-
|
|
421
|
+
_context10.next = 9;
|
|
385
422
|
break;
|
|
386
423
|
}
|
|
387
|
-
return
|
|
424
|
+
return _context10.abrupt("return", false);
|
|
388
425
|
case 9:
|
|
389
426
|
nodeCollection = attrs.collection, __contextId = attrs.__contextId;
|
|
390
|
-
|
|
391
|
-
if (
|
|
392
|
-
|
|
427
|
+
_context10.t0 = __contextId;
|
|
428
|
+
if (_context10.t0) {
|
|
429
|
+
_context10.next = 15;
|
|
393
430
|
break;
|
|
394
431
|
}
|
|
395
|
-
|
|
432
|
+
_context10.next = 14;
|
|
396
433
|
return _this.getObjectId();
|
|
397
434
|
case 14:
|
|
398
|
-
|
|
435
|
+
_context10.t0 = _context10.sent;
|
|
399
436
|
case 15:
|
|
400
|
-
contextId =
|
|
437
|
+
contextId = _context10.t0;
|
|
401
438
|
if (!(contextId && currentCollectionName !== nodeCollection)) {
|
|
402
|
-
|
|
439
|
+
_context10.next = 18;
|
|
403
440
|
break;
|
|
404
441
|
}
|
|
405
|
-
return
|
|
442
|
+
return _context10.abrupt("return", true);
|
|
406
443
|
case 18:
|
|
407
|
-
return
|
|
444
|
+
return _context10.abrupt("return", false);
|
|
408
445
|
case 19:
|
|
409
446
|
case "end":
|
|
410
|
-
return
|
|
447
|
+
return _context10.stop();
|
|
411
448
|
}
|
|
412
|
-
},
|
|
449
|
+
}, _callee10);
|
|
413
450
|
})));
|
|
414
451
|
(0, _defineProperty2.default)(this, "handleCopyFileSwitcher", /*#__PURE__*/function () {
|
|
415
|
-
var
|
|
452
|
+
var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(attrs) {
|
|
416
453
|
var mediaClient, source, destination, traceContext, _sourceAP, copyV2Source, _destAP, copyV2Destination, _yield$mediaClient$fi, id, _yield$mediaClient$fi2, _id;
|
|
417
|
-
return _regenerator.default.wrap(function
|
|
418
|
-
while (1) switch (
|
|
454
|
+
return _regenerator.default.wrap(function _callee11$(_context11) {
|
|
455
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
419
456
|
case 0:
|
|
420
457
|
mediaClient = attrs.mediaClient, source = attrs.source, destination = attrs.destination, traceContext = attrs.traceContext;
|
|
421
458
|
if (!(0, _platformFeatureFlags.fg)('platform_media_copy_and_paste_v2')) {
|
|
422
|
-
|
|
459
|
+
_context11.next = 11;
|
|
423
460
|
break;
|
|
424
461
|
}
|
|
425
462
|
// don't need authProviders for v2 copy
|
|
426
463
|
_sourceAP = source.authProvider, copyV2Source = (0, _objectWithoutProperties2.default)(source, _excluded);
|
|
427
464
|
_destAP = destination.authProvider, copyV2Destination = (0, _objectWithoutProperties2.default)(destination, _excluded2);
|
|
428
|
-
|
|
465
|
+
_context11.next = 6;
|
|
429
466
|
return mediaClient.file.copyFile(copyV2Source, copyV2Destination, undefined, traceContext);
|
|
430
467
|
case 6:
|
|
431
|
-
_yield$mediaClient$fi =
|
|
468
|
+
_yield$mediaClient$fi = _context11.sent;
|
|
432
469
|
id = _yield$mediaClient$fi.id;
|
|
433
|
-
return
|
|
470
|
+
return _context11.abrupt("return", id);
|
|
434
471
|
case 11:
|
|
435
|
-
|
|
472
|
+
_context11.next = 13;
|
|
436
473
|
return mediaClient.file.copyFile(source, destination, undefined, traceContext);
|
|
437
474
|
case 13:
|
|
438
|
-
_yield$mediaClient$fi2 =
|
|
475
|
+
_yield$mediaClient$fi2 = _context11.sent;
|
|
439
476
|
_id = _yield$mediaClient$fi2.id;
|
|
440
|
-
return
|
|
477
|
+
return _context11.abrupt("return", _id);
|
|
441
478
|
case 16:
|
|
442
479
|
case "end":
|
|
443
|
-
return
|
|
480
|
+
return _context11.stop();
|
|
444
481
|
}
|
|
445
|
-
},
|
|
482
|
+
}, _callee11);
|
|
446
483
|
}));
|
|
447
484
|
return function (_x4) {
|
|
448
|
-
return
|
|
485
|
+
return _ref13.apply(this, arguments);
|
|
449
486
|
};
|
|
450
487
|
}());
|
|
451
488
|
(0, _defineProperty2.default)(this, "copyNodeFromBlobUrl", /*#__PURE__*/function () {
|
|
452
|
-
var
|
|
489
|
+
var _ref14 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(getPos) {
|
|
453
490
|
var attrs, url, mediaAttrs, mediaProvider, currentCollectionName, contextId, id, collection, height, width, mimeType, name, size, uploadMediaClientConfig, mediaClient, getAuthFromContext, mediaFileId, pos;
|
|
454
|
-
return _regenerator.default.wrap(function
|
|
455
|
-
while (1) switch (
|
|
491
|
+
return _regenerator.default.wrap(function _callee12$(_context12) {
|
|
492
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
456
493
|
case 0:
|
|
457
494
|
attrs = _this.getAttrs();
|
|
458
495
|
if (!(!attrs || attrs.type !== 'external')) {
|
|
459
|
-
|
|
496
|
+
_context12.next = 3;
|
|
460
497
|
break;
|
|
461
498
|
}
|
|
462
|
-
return
|
|
499
|
+
return _context12.abrupt("return");
|
|
463
500
|
case 3:
|
|
464
501
|
url = attrs.url;
|
|
465
502
|
mediaAttrs = (0, _mediaClient.getAttrsFromUrl)(url);
|
|
466
503
|
if (mediaAttrs) {
|
|
467
|
-
|
|
504
|
+
_context12.next = 7;
|
|
468
505
|
break;
|
|
469
506
|
}
|
|
470
|
-
return
|
|
507
|
+
return _context12.abrupt("return");
|
|
471
508
|
case 7:
|
|
472
|
-
|
|
509
|
+
_context12.next = 9;
|
|
473
510
|
return _this.props.mediaProvider;
|
|
474
511
|
case 9:
|
|
475
|
-
mediaProvider =
|
|
512
|
+
mediaProvider = _context12.sent;
|
|
476
513
|
if (!(!mediaProvider || !mediaProvider.uploadParams)) {
|
|
477
|
-
|
|
514
|
+
_context12.next = 12;
|
|
478
515
|
break;
|
|
479
516
|
}
|
|
480
|
-
return
|
|
517
|
+
return _context12.abrupt("return");
|
|
481
518
|
case 12:
|
|
482
519
|
currentCollectionName = mediaProvider.uploadParams.collection;
|
|
483
520
|
contextId = mediaAttrs.contextId, id = mediaAttrs.id, collection = mediaAttrs.collection, height = mediaAttrs.height, width = mediaAttrs.width, mimeType = mediaAttrs.mimeType, name = mediaAttrs.name, size = mediaAttrs.size;
|
|
484
521
|
uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
|
|
485
522
|
if (!(!uploadMediaClientConfig || !uploadMediaClientConfig.getAuthFromContext)) {
|
|
486
|
-
|
|
523
|
+
_context12.next = 17;
|
|
487
524
|
break;
|
|
488
525
|
}
|
|
489
|
-
return
|
|
526
|
+
return _context12.abrupt("return");
|
|
490
527
|
case 17:
|
|
491
528
|
mediaClient = (0, _mediaClientReact.getMediaClient)(uploadMediaClientConfig);
|
|
492
529
|
getAuthFromContext = uploadMediaClientConfig.getAuthFromContext;
|
|
493
|
-
|
|
530
|
+
_context12.next = 21;
|
|
494
531
|
return _this.handleCopyFileSwitcher({
|
|
495
532
|
mediaClient: mediaClient,
|
|
496
533
|
source: {
|
|
@@ -507,13 +544,13 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
507
544
|
}
|
|
508
545
|
});
|
|
509
546
|
case 21:
|
|
510
|
-
mediaFileId =
|
|
547
|
+
mediaFileId = _context12.sent;
|
|
511
548
|
pos = getPos();
|
|
512
549
|
if (!(typeof pos !== 'number')) {
|
|
513
|
-
|
|
550
|
+
_context12.next = 25;
|
|
514
551
|
break;
|
|
515
552
|
}
|
|
516
|
-
return
|
|
553
|
+
return _context12.abrupt("return");
|
|
517
554
|
case 25:
|
|
518
555
|
(0, _helpers.replaceExternalMedia)(pos + 1, {
|
|
519
556
|
id: mediaFileId,
|
|
@@ -526,37 +563,37 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
526
563
|
})(_this.props.view.state, _this.props.view.dispatch);
|
|
527
564
|
case 26:
|
|
528
565
|
case "end":
|
|
529
|
-
return
|
|
566
|
+
return _context12.stop();
|
|
530
567
|
}
|
|
531
|
-
},
|
|
568
|
+
}, _callee12);
|
|
532
569
|
}));
|
|
533
570
|
return function (_x5) {
|
|
534
|
-
return
|
|
571
|
+
return _ref14.apply(this, arguments);
|
|
535
572
|
};
|
|
536
573
|
}());
|
|
537
574
|
// Copies the pasted node into the current collection using a getPos handler
|
|
538
575
|
(0, _defineProperty2.default)(this, "copyNodeFromPos", /*#__PURE__*/function () {
|
|
539
|
-
var
|
|
576
|
+
var _ref15 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(getPos, traceContext) {
|
|
540
577
|
var attrs, copiedAttrs;
|
|
541
|
-
return _regenerator.default.wrap(function
|
|
542
|
-
while (1) switch (
|
|
578
|
+
return _regenerator.default.wrap(function _callee13$(_context13) {
|
|
579
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
543
580
|
case 0:
|
|
544
581
|
attrs = _this.getAttrs();
|
|
545
582
|
if (!(!attrs || attrs && !isMediaTypeSupported(attrs.type))) {
|
|
546
|
-
|
|
583
|
+
_context13.next = 3;
|
|
547
584
|
break;
|
|
548
585
|
}
|
|
549
|
-
return
|
|
586
|
+
return _context13.abrupt("return");
|
|
550
587
|
case 3:
|
|
551
|
-
|
|
588
|
+
_context13.next = 5;
|
|
552
589
|
return _this.copyFile(attrs.id, attrs.collection, traceContext);
|
|
553
590
|
case 5:
|
|
554
|
-
copiedAttrs =
|
|
591
|
+
copiedAttrs = _context13.sent;
|
|
555
592
|
if (copiedAttrs) {
|
|
556
|
-
|
|
593
|
+
_context13.next = 8;
|
|
557
594
|
break;
|
|
558
595
|
}
|
|
559
|
-
return
|
|
596
|
+
return _context13.abrupt("return");
|
|
560
597
|
case 8:
|
|
561
598
|
(0, _helpers.updateCurrentMediaNodeAttrs)(copiedAttrs, {
|
|
562
599
|
node: _this.props.node,
|
|
@@ -564,82 +601,82 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
564
601
|
})(_this.props.view.state, _this.props.view.dispatch);
|
|
565
602
|
case 9:
|
|
566
603
|
case "end":
|
|
567
|
-
return
|
|
604
|
+
return _context13.stop();
|
|
568
605
|
}
|
|
569
|
-
},
|
|
606
|
+
}, _callee13);
|
|
570
607
|
}));
|
|
571
608
|
return function (_x6, _x7) {
|
|
572
|
-
return
|
|
609
|
+
return _ref15.apply(this, arguments);
|
|
573
610
|
};
|
|
574
611
|
}());
|
|
575
612
|
// Copies the pasted node into the current collection
|
|
576
613
|
(0, _defineProperty2.default)(this, "copyNode", /*#__PURE__*/function () {
|
|
577
|
-
var
|
|
614
|
+
var _ref16 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(traceContext) {
|
|
578
615
|
var attrs, view, copiedAttrs;
|
|
579
|
-
return _regenerator.default.wrap(function
|
|
580
|
-
while (1) switch (
|
|
616
|
+
return _regenerator.default.wrap(function _callee14$(_context14) {
|
|
617
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
581
618
|
case 0:
|
|
582
619
|
attrs = _this.getAttrs();
|
|
583
620
|
view = _this.props.view;
|
|
584
621
|
if (!(!attrs || attrs && !isMediaTypeSupported(attrs.type))) {
|
|
585
|
-
|
|
622
|
+
_context14.next = 4;
|
|
586
623
|
break;
|
|
587
624
|
}
|
|
588
|
-
return
|
|
625
|
+
return _context14.abrupt("return");
|
|
589
626
|
case 4:
|
|
590
|
-
|
|
627
|
+
_context14.next = 6;
|
|
591
628
|
return _this.copyFile(attrs.id, attrs.collection, traceContext);
|
|
592
629
|
case 6:
|
|
593
|
-
copiedAttrs =
|
|
630
|
+
copiedAttrs = _context14.sent;
|
|
594
631
|
if (copiedAttrs) {
|
|
595
|
-
|
|
632
|
+
_context14.next = 9;
|
|
596
633
|
break;
|
|
597
634
|
}
|
|
598
|
-
return
|
|
635
|
+
return _context14.abrupt("return");
|
|
599
636
|
case 9:
|
|
600
637
|
(0, _helpers.updateMediaNodeAttrs)(attrs.id, copiedAttrs)(view.state, view.dispatch);
|
|
601
638
|
case 10:
|
|
602
639
|
case "end":
|
|
603
|
-
return
|
|
640
|
+
return _context14.stop();
|
|
604
641
|
}
|
|
605
|
-
},
|
|
642
|
+
}, _callee14);
|
|
606
643
|
}));
|
|
607
644
|
return function (_x8) {
|
|
608
|
-
return
|
|
645
|
+
return _ref16.apply(this, arguments);
|
|
609
646
|
};
|
|
610
647
|
}());
|
|
611
648
|
(0, _defineProperty2.default)(this, "copyFile", /*#__PURE__*/function () {
|
|
612
|
-
var
|
|
649
|
+
var _ref17 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(id, collection, traceContext) {
|
|
613
650
|
var mediaProvider, nodeContextId, uploadMediaClientConfig, mediaClient, currentCollectionName, objectId, getAuthFromContext, mediaFileId;
|
|
614
|
-
return _regenerator.default.wrap(function
|
|
615
|
-
while (1) switch (
|
|
651
|
+
return _regenerator.default.wrap(function _callee15$(_context15) {
|
|
652
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
616
653
|
case 0:
|
|
617
|
-
|
|
654
|
+
_context15.next = 2;
|
|
618
655
|
return _this.props.mediaProvider;
|
|
619
656
|
case 2:
|
|
620
|
-
mediaProvider =
|
|
657
|
+
mediaProvider = _context15.sent;
|
|
621
658
|
if (mediaProvider !== null && mediaProvider !== void 0 && mediaProvider.uploadParams) {
|
|
622
|
-
|
|
659
|
+
_context15.next = 5;
|
|
623
660
|
break;
|
|
624
661
|
}
|
|
625
|
-
return
|
|
662
|
+
return _context15.abrupt("return");
|
|
626
663
|
case 5:
|
|
627
664
|
nodeContextId = _this.getNodeContextId();
|
|
628
665
|
uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
|
|
629
666
|
if (!(!(uploadMediaClientConfig !== null && uploadMediaClientConfig !== void 0 && uploadMediaClientConfig.getAuthFromContext) || !nodeContextId)) {
|
|
630
|
-
|
|
667
|
+
_context15.next = 9;
|
|
631
668
|
break;
|
|
632
669
|
}
|
|
633
|
-
return
|
|
670
|
+
return _context15.abrupt("return");
|
|
634
671
|
case 9:
|
|
635
672
|
mediaClient = (0, _mediaClientReact.getMediaClient)(uploadMediaClientConfig);
|
|
636
673
|
currentCollectionName = mediaProvider.uploadParams.collection;
|
|
637
|
-
|
|
674
|
+
_context15.next = 13;
|
|
638
675
|
return _this.getObjectId();
|
|
639
676
|
case 13:
|
|
640
|
-
objectId =
|
|
677
|
+
objectId = _context15.sent;
|
|
641
678
|
getAuthFromContext = uploadMediaClientConfig.getAuthFromContext;
|
|
642
|
-
|
|
679
|
+
_context15.next = 17;
|
|
643
680
|
return _this.handleCopyFileSwitcher({
|
|
644
681
|
mediaClient: mediaClient,
|
|
645
682
|
source: {
|
|
@@ -657,23 +694,24 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
657
694
|
traceContext: traceContext
|
|
658
695
|
});
|
|
659
696
|
case 17:
|
|
660
|
-
mediaFileId =
|
|
661
|
-
return
|
|
697
|
+
mediaFileId = _context15.sent;
|
|
698
|
+
return _context15.abrupt("return", {
|
|
662
699
|
id: mediaFileId,
|
|
663
700
|
collection: currentCollectionName,
|
|
664
701
|
__contextId: objectId
|
|
665
702
|
});
|
|
666
703
|
case 19:
|
|
667
704
|
case "end":
|
|
668
|
-
return
|
|
705
|
+
return _context15.stop();
|
|
669
706
|
}
|
|
670
|
-
},
|
|
707
|
+
}, _callee15);
|
|
671
708
|
}));
|
|
672
709
|
return function (_x9, _x10, _x11) {
|
|
673
|
-
return
|
|
710
|
+
return _ref17.apply(this, arguments);
|
|
674
711
|
};
|
|
675
712
|
}());
|
|
676
713
|
this.props = props;
|
|
714
|
+
this.mediaPluginState = _pluginKey.stateKey.getState(props.view.state);
|
|
677
715
|
}
|
|
678
716
|
return (0, _createClass2.default)(MediaNodeUpdater, [{
|
|
679
717
|
key: "setProps",
|
|
@@ -689,42 +727,42 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
689
727
|
}, {
|
|
690
728
|
key: "getRemoteDimensions",
|
|
691
729
|
value: function () {
|
|
692
|
-
var _getRemoteDimensions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
730
|
+
var _getRemoteDimensions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
|
|
693
731
|
var mediaProvider, mediaOptions, attrs, height, width, id, collection, viewMediaClientConfig, mediaClient, currentState, imageMetadata;
|
|
694
|
-
return _regenerator.default.wrap(function
|
|
695
|
-
while (1) switch (
|
|
732
|
+
return _regenerator.default.wrap(function _callee16$(_context16) {
|
|
733
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
696
734
|
case 0:
|
|
697
|
-
|
|
735
|
+
_context16.next = 2;
|
|
698
736
|
return this.props.mediaProvider;
|
|
699
737
|
case 2:
|
|
700
|
-
mediaProvider =
|
|
738
|
+
mediaProvider = _context16.sent;
|
|
701
739
|
mediaOptions = this.props.mediaOptions;
|
|
702
740
|
attrs = this.getAttrs();
|
|
703
741
|
if (!(!mediaProvider || !attrs)) {
|
|
704
|
-
|
|
742
|
+
_context16.next = 7;
|
|
705
743
|
break;
|
|
706
744
|
}
|
|
707
|
-
return
|
|
745
|
+
return _context16.abrupt("return", false);
|
|
708
746
|
case 7:
|
|
709
747
|
height = attrs.height, width = attrs.width;
|
|
710
748
|
if (!(attrs.type === 'external' || !attrs.id)) {
|
|
711
|
-
|
|
749
|
+
_context16.next = 10;
|
|
712
750
|
break;
|
|
713
751
|
}
|
|
714
|
-
return
|
|
752
|
+
return _context16.abrupt("return", false);
|
|
715
753
|
case 10:
|
|
716
754
|
id = attrs.id, collection = attrs.collection;
|
|
717
755
|
if (!(height && width)) {
|
|
718
|
-
|
|
756
|
+
_context16.next = 13;
|
|
719
757
|
break;
|
|
720
758
|
}
|
|
721
|
-
return
|
|
759
|
+
return _context16.abrupt("return", false);
|
|
722
760
|
case 13:
|
|
723
761
|
if (!(mediaOptions && !mediaOptions.allowRemoteDimensionsFetch)) {
|
|
724
|
-
|
|
762
|
+
_context16.next = 15;
|
|
725
763
|
break;
|
|
726
764
|
}
|
|
727
|
-
return
|
|
765
|
+
return _context16.abrupt("return", {
|
|
728
766
|
id: id,
|
|
729
767
|
height: _mediaSingle.DEFAULT_IMAGE_HEIGHT,
|
|
730
768
|
width: _mediaSingle.DEFAULT_IMAGE_WIDTH
|
|
@@ -732,40 +770,40 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
732
770
|
case 15:
|
|
733
771
|
viewMediaClientConfig = mediaProvider.viewMediaClientConfig;
|
|
734
772
|
mediaClient = (0, _mediaClientReact.getMediaClient)(viewMediaClientConfig);
|
|
735
|
-
|
|
773
|
+
_context16.next = 19;
|
|
736
774
|
return mediaClient.file.getCurrentState(id, {
|
|
737
775
|
collectionName: collection
|
|
738
776
|
});
|
|
739
777
|
case 19:
|
|
740
|
-
currentState =
|
|
778
|
+
currentState = _context16.sent;
|
|
741
779
|
if ((0, _mediaClient.isImageRepresentationReady)(currentState)) {
|
|
742
|
-
|
|
780
|
+
_context16.next = 22;
|
|
743
781
|
break;
|
|
744
782
|
}
|
|
745
|
-
return
|
|
783
|
+
return _context16.abrupt("return", false);
|
|
746
784
|
case 22:
|
|
747
|
-
|
|
785
|
+
_context16.next = 24;
|
|
748
786
|
return mediaClient.getImageMetadata(id, {
|
|
749
787
|
collection: collection
|
|
750
788
|
});
|
|
751
789
|
case 24:
|
|
752
|
-
imageMetadata =
|
|
790
|
+
imageMetadata = _context16.sent;
|
|
753
791
|
if (!(!imageMetadata || !imageMetadata.original)) {
|
|
754
|
-
|
|
792
|
+
_context16.next = 27;
|
|
755
793
|
break;
|
|
756
794
|
}
|
|
757
|
-
return
|
|
795
|
+
return _context16.abrupt("return", false);
|
|
758
796
|
case 27:
|
|
759
|
-
return
|
|
797
|
+
return _context16.abrupt("return", {
|
|
760
798
|
id: id,
|
|
761
799
|
height: imageMetadata.original.height || _mediaSingle.DEFAULT_IMAGE_HEIGHT,
|
|
762
800
|
width: imageMetadata.original.width || _mediaSingle.DEFAULT_IMAGE_WIDTH
|
|
763
801
|
});
|
|
764
802
|
case 28:
|
|
765
803
|
case "end":
|
|
766
|
-
return
|
|
804
|
+
return _context16.stop();
|
|
767
805
|
}
|
|
768
|
-
},
|
|
806
|
+
}, _callee16, this);
|
|
769
807
|
}));
|
|
770
808
|
function getRemoteDimensions() {
|
|
771
809
|
return _getRemoteDimensions.apply(this, arguments);
|
|
@@ -775,36 +813,36 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
775
813
|
}, {
|
|
776
814
|
key: "handleExternalMedia",
|
|
777
815
|
value: function () {
|
|
778
|
-
var _handleExternalMedia = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
779
|
-
return _regenerator.default.wrap(function
|
|
780
|
-
while (1) switch (
|
|
816
|
+
var _handleExternalMedia = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(getPos) {
|
|
817
|
+
return _regenerator.default.wrap(function _callee17$(_context17) {
|
|
818
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
781
819
|
case 0:
|
|
782
820
|
if (!this.isMediaBlobUrl()) {
|
|
783
|
-
|
|
821
|
+
_context17.next = 12;
|
|
784
822
|
break;
|
|
785
823
|
}
|
|
786
|
-
|
|
787
|
-
|
|
824
|
+
_context17.prev = 1;
|
|
825
|
+
_context17.next = 4;
|
|
788
826
|
return this.copyNodeFromBlobUrl(getPos);
|
|
789
827
|
case 4:
|
|
790
|
-
|
|
828
|
+
_context17.next = 10;
|
|
791
829
|
break;
|
|
792
830
|
case 6:
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
831
|
+
_context17.prev = 6;
|
|
832
|
+
_context17.t0 = _context17["catch"](1);
|
|
833
|
+
_context17.next = 10;
|
|
796
834
|
return this.uploadExternalMedia(getPos);
|
|
797
835
|
case 10:
|
|
798
|
-
|
|
836
|
+
_context17.next = 14;
|
|
799
837
|
break;
|
|
800
838
|
case 12:
|
|
801
|
-
|
|
839
|
+
_context17.next = 14;
|
|
802
840
|
return this.uploadExternalMedia(getPos);
|
|
803
841
|
case 14:
|
|
804
842
|
case "end":
|
|
805
|
-
return
|
|
843
|
+
return _context17.stop();
|
|
806
844
|
}
|
|
807
|
-
},
|
|
845
|
+
}, _callee17, this, [[1, 6]]);
|
|
808
846
|
}));
|
|
809
847
|
function handleExternalMedia(_x12) {
|
|
810
848
|
return _handleExternalMedia.apply(this, arguments);
|
|
@@ -122,7 +122,7 @@ var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
122
122
|
(0, _defineProperty2.default)(_this, "updateMediaNodeAttributes", /*#__PURE__*/function () {
|
|
123
123
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(props) {
|
|
124
124
|
var _this$mediaNodeUpdate2, _this$props$node$firs, _this$mediaNodeUpdate4, _this$mediaNodeUpdate6;
|
|
125
|
-
var addPendingTask, node, updatedDimensions, currentAttrs, _this$mediaNodeUpdate3, updatingNode, contextId, _this$mediaNodeUpdate5,
|
|
125
|
+
var addPendingTask, node, updatedDimensions, currentAttrs, _this$mediaNodeUpdate3, updatingNode, contextId, _this$mediaNodeUpdate5, shouldNodeBeDeepCopied, copyNode;
|
|
126
126
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
127
127
|
while (1) switch (_context2.prev = _context2.next) {
|
|
128
128
|
case 0:
|
|
@@ -165,10 +165,10 @@ var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
165
165
|
return (_this$mediaNodeUpdate5 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate5 === void 0 ? void 0 : _this$mediaNodeUpdate5.updateContextId();
|
|
166
166
|
case 20:
|
|
167
167
|
_context2.next = 22;
|
|
168
|
-
return (_this$mediaNodeUpdate6 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate6 === void 0 ? void 0 : _this$mediaNodeUpdate6.
|
|
168
|
+
return (_this$mediaNodeUpdate6 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate6 === void 0 ? void 0 : _this$mediaNodeUpdate6.shouldNodeBeDeepCopied();
|
|
169
169
|
case 22:
|
|
170
|
-
|
|
171
|
-
if (!
|
|
170
|
+
shouldNodeBeDeepCopied = _context2.sent;
|
|
171
|
+
if (!shouldNodeBeDeepCopied) {
|
|
172
172
|
_context2.next = 35;
|
|
173
173
|
break;
|
|
174
174
|
}
|