@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.
- package/CHANGELOG.md +17 -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 +254 -177
- package/dist/cjs/nodeviews/mediaSingle.js +4 -4
- package/dist/cjs/nodeviews/mediaSingleNext.js +4 -4
- package/dist/cjs/pm-plugins/alt-text/ui/AltTextEdit.js +4 -0
- package/dist/cjs/pm-plugins/main.js +41 -13
- package/dist/cjs/pm-plugins/utils/media-single.js +43 -25
- package/dist/cjs/ui/MediaLinkingToolbar.js +1 -0
- package/dist/cjs/ui/toolbar/mediaInline.js +3 -3
- 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 +78 -27
- package/dist/es2019/nodeviews/mediaSingle.js +2 -2
- package/dist/es2019/nodeviews/mediaSingleNext.js +2 -2
- package/dist/es2019/pm-plugins/alt-text/ui/AltTextEdit.js +4 -0
- package/dist/es2019/pm-plugins/main.js +42 -12
- package/dist/es2019/pm-plugins/utils/media-single.js +40 -18
- package/dist/es2019/ui/MediaLinkingToolbar.js +1 -0
- package/dist/es2019/ui/toolbar/mediaInline.js +3 -3
- 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 +254 -177
- package/dist/esm/nodeviews/mediaSingle.js +4 -4
- package/dist/esm/nodeviews/mediaSingleNext.js +4 -4
- package/dist/esm/pm-plugins/alt-text/ui/AltTextEdit.js +4 -0
- package/dist/esm/pm-plugins/main.js +42 -14
- package/dist/esm/pm-plugins/utils/media-single.js +43 -25
- package/dist/esm/ui/MediaLinkingToolbar.js +1 -0
- package/dist/esm/ui/toolbar/mediaInline.js +3 -3
- package/dist/types/nodeviews/__mocks__/mediaNodeUpdater.d.ts +1 -0
- package/dist/types/nodeviews/mediaNodeUpdater.d.ts +4 -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 +4 -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 +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, "
|
|
334
|
-
var
|
|
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
|
-
|
|
379
|
+
_context9.next = 3;
|
|
340
380
|
return _this.getObjectId();
|
|
341
381
|
case 3:
|
|
342
|
-
currentContextId =
|
|
382
|
+
currentContextId = _context9.sent;
|
|
343
383
|
if (!(nodeContextId && currentContextId && nodeContextId !== currentContextId)) {
|
|
344
|
-
|
|
384
|
+
_context9.next = 6;
|
|
345
385
|
break;
|
|
346
386
|
}
|
|
347
|
-
return
|
|
387
|
+
return _context9.abrupt("return", true);
|
|
348
388
|
case 6:
|
|
349
|
-
return
|
|
389
|
+
return _context9.abrupt("return", false);
|
|
350
390
|
case 7:
|
|
351
391
|
case "end":
|
|
352
|
-
return
|
|
392
|
+
return _context9.stop();
|
|
353
393
|
}
|
|
354
|
-
},
|
|
394
|
+
}, _callee9);
|
|
355
395
|
})));
|
|
356
|
-
_defineProperty(this, "isNodeFromDifferentCollection", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
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
|
|
359
|
-
while (1) switch (
|
|
398
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
399
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
360
400
|
case 0:
|
|
361
|
-
|
|
401
|
+
_context10.next = 2;
|
|
362
402
|
return _this.props.mediaProvider;
|
|
363
403
|
case 2:
|
|
364
|
-
mediaProvider =
|
|
404
|
+
mediaProvider = _context10.sent;
|
|
365
405
|
if (!(!mediaProvider || !mediaProvider.uploadParams)) {
|
|
366
|
-
|
|
406
|
+
_context10.next = 5;
|
|
367
407
|
break;
|
|
368
408
|
}
|
|
369
|
-
return
|
|
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
|
-
|
|
414
|
+
_context10.next = 9;
|
|
375
415
|
break;
|
|
376
416
|
}
|
|
377
|
-
return
|
|
417
|
+
return _context10.abrupt("return", false);
|
|
378
418
|
case 9:
|
|
379
419
|
nodeCollection = attrs.collection, __contextId = attrs.__contextId;
|
|
380
|
-
|
|
381
|
-
if (
|
|
382
|
-
|
|
420
|
+
_context10.t0 = __contextId;
|
|
421
|
+
if (_context10.t0) {
|
|
422
|
+
_context10.next = 15;
|
|
383
423
|
break;
|
|
384
424
|
}
|
|
385
|
-
|
|
425
|
+
_context10.next = 14;
|
|
386
426
|
return _this.getObjectId();
|
|
387
427
|
case 14:
|
|
388
|
-
|
|
428
|
+
_context10.t0 = _context10.sent;
|
|
389
429
|
case 15:
|
|
390
|
-
contextId =
|
|
430
|
+
contextId = _context10.t0;
|
|
391
431
|
if (!(contextId && currentCollectionName !== nodeCollection)) {
|
|
392
|
-
|
|
432
|
+
_context10.next = 18;
|
|
393
433
|
break;
|
|
394
434
|
}
|
|
395
|
-
return
|
|
435
|
+
return _context10.abrupt("return", true);
|
|
396
436
|
case 18:
|
|
397
|
-
return
|
|
437
|
+
return _context10.abrupt("return", false);
|
|
398
438
|
case 19:
|
|
399
439
|
case "end":
|
|
400
|
-
return
|
|
440
|
+
return _context10.stop();
|
|
401
441
|
}
|
|
402
|
-
},
|
|
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
|
|
406
|
-
var attrs, url, mediaAttrs, mediaProvider, currentCollectionName, contextId, id, collection, height, width, mimeType, name, size, uploadMediaClientConfig, mediaClient,
|
|
407
|
-
return _regeneratorRuntime.wrap(function
|
|
408
|
-
while (1) switch (
|
|
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
|
-
|
|
489
|
+
_context12.next = 3;
|
|
413
490
|
break;
|
|
414
491
|
}
|
|
415
|
-
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
|
-
|
|
497
|
+
_context12.next = 7;
|
|
421
498
|
break;
|
|
422
499
|
}
|
|
423
|
-
return
|
|
500
|
+
return _context12.abrupt("return");
|
|
424
501
|
case 7:
|
|
425
|
-
|
|
502
|
+
_context12.next = 9;
|
|
426
503
|
return _this.props.mediaProvider;
|
|
427
504
|
case 9:
|
|
428
|
-
mediaProvider =
|
|
505
|
+
mediaProvider = _context12.sent;
|
|
429
506
|
if (!(!mediaProvider || !mediaProvider.uploadParams)) {
|
|
430
|
-
|
|
507
|
+
_context12.next = 12;
|
|
431
508
|
break;
|
|
432
509
|
}
|
|
433
|
-
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
|
-
|
|
516
|
+
_context12.next = 17;
|
|
440
517
|
break;
|
|
441
518
|
}
|
|
442
|
-
return
|
|
519
|
+
return _context12.abrupt("return");
|
|
443
520
|
case 17:
|
|
444
521
|
mediaClient = getMediaClient(uploadMediaClientConfig);
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
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
|
-
|
|
457
|
-
|
|
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
|
-
|
|
543
|
+
_context12.next = 25;
|
|
468
544
|
break;
|
|
469
545
|
}
|
|
470
|
-
return
|
|
471
|
-
case
|
|
546
|
+
return _context12.abrupt("return");
|
|
547
|
+
case 25:
|
|
472
548
|
replaceExternalMedia(pos + 1, {
|
|
473
|
-
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
|
|
557
|
+
case 26:
|
|
482
558
|
case "end":
|
|
483
|
-
return
|
|
559
|
+
return _context12.stop();
|
|
484
560
|
}
|
|
485
|
-
},
|
|
561
|
+
}, _callee12);
|
|
486
562
|
}));
|
|
487
|
-
return function (
|
|
488
|
-
return
|
|
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
|
|
569
|
+
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(getPos, traceContext) {
|
|
494
570
|
var attrs, copiedAttrs;
|
|
495
|
-
return _regeneratorRuntime.wrap(function
|
|
496
|
-
while (1) switch (
|
|
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
|
-
|
|
576
|
+
_context13.next = 3;
|
|
501
577
|
break;
|
|
502
578
|
}
|
|
503
|
-
return
|
|
579
|
+
return _context13.abrupt("return");
|
|
504
580
|
case 3:
|
|
505
|
-
|
|
581
|
+
_context13.next = 5;
|
|
506
582
|
return _this.copyFile(attrs.id, attrs.collection, traceContext);
|
|
507
583
|
case 5:
|
|
508
|
-
copiedAttrs =
|
|
584
|
+
copiedAttrs = _context13.sent;
|
|
509
585
|
if (copiedAttrs) {
|
|
510
|
-
|
|
586
|
+
_context13.next = 8;
|
|
511
587
|
break;
|
|
512
588
|
}
|
|
513
|
-
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
|
|
597
|
+
return _context13.stop();
|
|
522
598
|
}
|
|
523
|
-
},
|
|
599
|
+
}, _callee13);
|
|
524
600
|
}));
|
|
525
|
-
return function (
|
|
526
|
-
return
|
|
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
|
|
607
|
+
var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(traceContext) {
|
|
532
608
|
var attrs, view, copiedAttrs;
|
|
533
|
-
return _regeneratorRuntime.wrap(function
|
|
534
|
-
while (1) switch (
|
|
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
|
-
|
|
615
|
+
_context14.next = 4;
|
|
540
616
|
break;
|
|
541
617
|
}
|
|
542
|
-
return
|
|
618
|
+
return _context14.abrupt("return");
|
|
543
619
|
case 4:
|
|
544
|
-
|
|
620
|
+
_context14.next = 6;
|
|
545
621
|
return _this.copyFile(attrs.id, attrs.collection, traceContext);
|
|
546
622
|
case 6:
|
|
547
|
-
copiedAttrs =
|
|
623
|
+
copiedAttrs = _context14.sent;
|
|
548
624
|
if (copiedAttrs) {
|
|
549
|
-
|
|
625
|
+
_context14.next = 9;
|
|
550
626
|
break;
|
|
551
627
|
}
|
|
552
|
-
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
|
|
633
|
+
return _context14.stop();
|
|
558
634
|
}
|
|
559
|
-
},
|
|
635
|
+
}, _callee14);
|
|
560
636
|
}));
|
|
561
|
-
return function (
|
|
562
|
-
return
|
|
637
|
+
return function (_x8) {
|
|
638
|
+
return _ref16.apply(this, arguments);
|
|
563
639
|
};
|
|
564
640
|
}());
|
|
565
641
|
_defineProperty(this, "copyFile", /*#__PURE__*/function () {
|
|
566
|
-
var
|
|
567
|
-
var mediaProvider, nodeContextId, uploadMediaClientConfig, mediaClient,
|
|
568
|
-
return _regeneratorRuntime.wrap(function
|
|
569
|
-
while (1) switch (
|
|
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
|
-
|
|
647
|
+
_context15.next = 2;
|
|
572
648
|
return _this.props.mediaProvider;
|
|
573
649
|
case 2:
|
|
574
|
-
mediaProvider =
|
|
650
|
+
mediaProvider = _context15.sent;
|
|
575
651
|
if (mediaProvider !== null && mediaProvider !== void 0 && mediaProvider.uploadParams) {
|
|
576
|
-
|
|
652
|
+
_context15.next = 5;
|
|
577
653
|
break;
|
|
578
654
|
}
|
|
579
|
-
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
|
-
|
|
660
|
+
_context15.next = 9;
|
|
585
661
|
break;
|
|
586
662
|
}
|
|
587
|
-
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
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
return
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
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
|
|
696
|
+
case 19:
|
|
621
697
|
case "end":
|
|
622
|
-
return
|
|
698
|
+
return _context15.stop();
|
|
623
699
|
}
|
|
624
|
-
},
|
|
700
|
+
}, _callee15);
|
|
625
701
|
}));
|
|
626
|
-
return function (
|
|
627
|
-
return
|
|
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
|
|
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
|
|
649
|
-
while (1) switch (
|
|
725
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
726
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
650
727
|
case 0:
|
|
651
|
-
|
|
728
|
+
_context16.next = 2;
|
|
652
729
|
return this.props.mediaProvider;
|
|
653
730
|
case 2:
|
|
654
|
-
mediaProvider =
|
|
731
|
+
mediaProvider = _context16.sent;
|
|
655
732
|
mediaOptions = this.props.mediaOptions;
|
|
656
733
|
attrs = this.getAttrs();
|
|
657
734
|
if (!(!mediaProvider || !attrs)) {
|
|
658
|
-
|
|
735
|
+
_context16.next = 7;
|
|
659
736
|
break;
|
|
660
737
|
}
|
|
661
|
-
return
|
|
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
|
-
|
|
742
|
+
_context16.next = 10;
|
|
666
743
|
break;
|
|
667
744
|
}
|
|
668
|
-
return
|
|
745
|
+
return _context16.abrupt("return", false);
|
|
669
746
|
case 10:
|
|
670
747
|
id = attrs.id, collection = attrs.collection;
|
|
671
748
|
if (!(height && width)) {
|
|
672
|
-
|
|
749
|
+
_context16.next = 13;
|
|
673
750
|
break;
|
|
674
751
|
}
|
|
675
|
-
return
|
|
752
|
+
return _context16.abrupt("return", false);
|
|
676
753
|
case 13:
|
|
677
754
|
if (!(mediaOptions && !mediaOptions.allowRemoteDimensionsFetch)) {
|
|
678
|
-
|
|
755
|
+
_context16.next = 15;
|
|
679
756
|
break;
|
|
680
757
|
}
|
|
681
|
-
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
|
-
|
|
766
|
+
_context16.next = 19;
|
|
690
767
|
return mediaClient.file.getCurrentState(id, {
|
|
691
768
|
collectionName: collection
|
|
692
769
|
});
|
|
693
770
|
case 19:
|
|
694
|
-
currentState =
|
|
771
|
+
currentState = _context16.sent;
|
|
695
772
|
if (isImageRepresentationReady(currentState)) {
|
|
696
|
-
|
|
773
|
+
_context16.next = 22;
|
|
697
774
|
break;
|
|
698
775
|
}
|
|
699
|
-
return
|
|
776
|
+
return _context16.abrupt("return", false);
|
|
700
777
|
case 22:
|
|
701
|
-
|
|
778
|
+
_context16.next = 24;
|
|
702
779
|
return mediaClient.getImageMetadata(id, {
|
|
703
780
|
collection: collection
|
|
704
781
|
});
|
|
705
782
|
case 24:
|
|
706
|
-
imageMetadata =
|
|
783
|
+
imageMetadata = _context16.sent;
|
|
707
784
|
if (!(!imageMetadata || !imageMetadata.original)) {
|
|
708
|
-
|
|
785
|
+
_context16.next = 27;
|
|
709
786
|
break;
|
|
710
787
|
}
|
|
711
|
-
return
|
|
788
|
+
return _context16.abrupt("return", false);
|
|
712
789
|
case 27:
|
|
713
|
-
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
|
|
797
|
+
return _context16.stop();
|
|
721
798
|
}
|
|
722
|
-
},
|
|
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
|
|
733
|
-
return _regeneratorRuntime.wrap(function
|
|
734
|
-
while (1) switch (
|
|
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
|
-
|
|
814
|
+
_context17.next = 12;
|
|
738
815
|
break;
|
|
739
816
|
}
|
|
740
|
-
|
|
741
|
-
|
|
817
|
+
_context17.prev = 1;
|
|
818
|
+
_context17.next = 4;
|
|
742
819
|
return this.copyNodeFromBlobUrl(getPos);
|
|
743
820
|
case 4:
|
|
744
|
-
|
|
821
|
+
_context17.next = 10;
|
|
745
822
|
break;
|
|
746
823
|
case 6:
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
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
|
-
|
|
829
|
+
_context17.next = 14;
|
|
753
830
|
break;
|
|
754
831
|
case 12:
|
|
755
|
-
|
|
832
|
+
_context17.next = 14;
|
|
756
833
|
return this.uploadExternalMedia(getPos);
|
|
757
834
|
case 14:
|
|
758
835
|
case "end":
|
|
759
|
-
return
|
|
836
|
+
return _context17.stop();
|
|
760
837
|
}
|
|
761
|
-
},
|
|
838
|
+
}, _callee17, this, [[1, 6]]);
|
|
762
839
|
}));
|
|
763
|
-
function handleExternalMedia(
|
|
840
|
+
function handleExternalMedia(_x12) {
|
|
764
841
|
return _handleExternalMedia.apply(this, arguments);
|
|
765
842
|
}
|
|
766
843
|
return handleExternalMedia;
|