@atlaskit/editor-plugin-media 12.8.3 → 12.9.1

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 (47) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/nodeviews/mediaGroupNext.js +12 -12
  3. package/dist/cjs/nodeviews/mediaInline.js +25 -25
  4. package/dist/cjs/nodeviews/mediaNodeUpdater.js +199 -198
  5. package/dist/cjs/nodeviews/mediaNodeView/media.js +29 -17
  6. package/dist/cjs/nodeviews/mediaSingleNext.js +24 -24
  7. package/dist/cjs/pm-plugins/ai-generating-decoration.js +59 -12
  8. package/dist/cjs/pm-plugins/commands.js +2 -2
  9. package/dist/cjs/pm-plugins/main.js +55 -46
  10. package/dist/cjs/pm-plugins/mediaTaskManager.js +6 -6
  11. package/dist/cjs/pm-plugins/picker-facade.js +4 -4
  12. package/dist/cjs/pm-plugins/utils/check-media-type.js +17 -17
  13. package/dist/cjs/ui/MediaPicker/PickerFacadeProvider.js +21 -21
  14. package/dist/cjs/ui/ResizableMediaSingle/index.js +23 -20
  15. package/dist/cjs/ui/toolbar/utils.js +11 -11
  16. package/dist/es2019/nodeviews/mediaNodeView/media.js +12 -0
  17. package/dist/es2019/pm-plugins/ai-generating-decoration.js +53 -12
  18. package/dist/es2019/pm-plugins/commands.js +2 -2
  19. package/dist/es2019/pm-plugins/main.js +11 -1
  20. package/dist/es2019/ui/ResizableMediaSingle/index.js +5 -2
  21. package/dist/esm/nodeviews/mediaGroupNext.js +12 -12
  22. package/dist/esm/nodeviews/mediaInline.js +25 -25
  23. package/dist/esm/nodeviews/mediaNodeUpdater.js +199 -198
  24. package/dist/esm/nodeviews/mediaNodeView/media.js +28 -16
  25. package/dist/esm/nodeviews/mediaSingleNext.js +23 -23
  26. package/dist/esm/pm-plugins/ai-generating-decoration.js +59 -12
  27. package/dist/esm/pm-plugins/commands.js +2 -2
  28. package/dist/esm/pm-plugins/main.js +54 -45
  29. package/dist/esm/pm-plugins/mediaTaskManager.js +6 -6
  30. package/dist/esm/pm-plugins/picker-facade.js +4 -4
  31. package/dist/esm/pm-plugins/utils/check-media-type.js +17 -17
  32. package/dist/esm/ui/MediaPicker/PickerFacadeProvider.js +21 -21
  33. package/dist/esm/ui/ResizableMediaSingle/index.js +23 -20
  34. package/dist/esm/ui/toolbar/utils.js +11 -11
  35. package/dist/types/mediaPluginType.d.ts +2 -1
  36. package/dist/types/nodeviews/mediaNodeView/media.d.ts +1 -0
  37. package/dist/types/pm-plugins/ai-generating-decoration.d.ts +3 -1
  38. package/dist/types/pm-plugins/commands.d.ts +2 -1
  39. package/dist/types/pm-plugins/main.d.ts +1 -0
  40. package/dist/types/pm-plugins/types.d.ts +1 -0
  41. package/dist/types-ts4.5/mediaPluginType.d.ts +2 -1
  42. package/dist/types-ts4.5/nodeviews/mediaNodeView/media.d.ts +1 -0
  43. package/dist/types-ts4.5/pm-plugins/ai-generating-decoration.d.ts +3 -1
  44. package/dist/types-ts4.5/pm-plugins/commands.d.ts +2 -1
  45. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -0
  46. package/dist/types-ts4.5/pm-plugins/types.d.ts +1 -0
  47. package/package.json +8 -5
@@ -42,20 +42,20 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
42
42
  // Updates the node with contextId if it doesn't have one already
43
43
  (0, _defineProperty2.default)(this, "updateContextId", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
44
44
  var attrs, id, objectId;
45
- return _regenerator.default.wrap(function _callee$(_context) {
45
+ return _regenerator.default.wrap(function (_context) {
46
46
  while (1) switch (_context.prev = _context.next) {
47
47
  case 0:
48
48
  attrs = _this.getAttrs();
49
49
  if (!(!attrs || attrs && !isMediaTypeSupported(attrs.type))) {
50
- _context.next = 3;
50
+ _context.next = 1;
51
51
  break;
52
52
  }
53
53
  return _context.abrupt("return");
54
- case 3:
54
+ case 1:
55
55
  id = attrs.id;
56
- _context.next = 6;
56
+ _context.next = 2;
57
57
  return _this.getObjectId();
58
- case 6:
58
+ case 2:
59
59
  objectId = _context.sent;
60
60
  (0, _batchMediaNodeAttrs.batchMediaNodeAttrsUpdate)(_this.props.view, {
61
61
  id: id,
@@ -63,7 +63,7 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
63
63
  __contextId: objectId
64
64
  }
65
65
  });
66
- case 8:
66
+ case 3:
67
67
  case "end":
68
68
  return _context.stop();
69
69
  }
@@ -72,19 +72,19 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
72
72
  (0, _defineProperty2.default)(this, "updateNodeContextId", /*#__PURE__*/function () {
73
73
  var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(getPos) {
74
74
  var attrs, objectId;
75
- return _regenerator.default.wrap(function _callee2$(_context2) {
75
+ return _regenerator.default.wrap(function (_context2) {
76
76
  while (1) switch (_context2.prev = _context2.next) {
77
77
  case 0:
78
78
  attrs = _this.getAttrs();
79
79
  if (!(!attrs || attrs && !isMediaTypeSupported(attrs.type))) {
80
- _context2.next = 3;
80
+ _context2.next = 1;
81
81
  break;
82
82
  }
83
83
  return _context2.abrupt("return");
84
- case 3:
85
- _context2.next = 5;
84
+ case 1:
85
+ _context2.next = 2;
86
86
  return _this.getObjectId();
87
- case 5:
87
+ case 2:
88
88
  objectId = _context2.sent;
89
89
  (0, _helpers.updateCurrentMediaNodeAttrs)({
90
90
  __contextId: objectId
@@ -92,7 +92,7 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
92
92
  node: _this.props.node,
93
93
  getPos: getPos
94
94
  })(_this.props.view.state, _this.props.view.dispatch);
95
- case 7:
95
+ case 3:
96
96
  case "end":
97
97
  return _context2.stop();
98
98
  }
@@ -106,55 +106,55 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
106
106
  return attrs && attrs.type === 'file' && attrs.__fileName && attrs.__fileMimeType && attrs.__fileSize && attrs.__contextId;
107
107
  });
108
108
  (0, _defineProperty2.default)(this, "getNewFileAttrsForNode", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
109
- var attrs, mediaProvider, mediaClientConfig, mediaClient, fileState, id, collectionName, contextId, _fileState, name, mimeType, size, newAttrs;
110
- return _regenerator.default.wrap(function _callee3$(_context3) {
109
+ var attrs, mediaProvider, mediaClientConfig, mediaClient, fileState, id, collectionName, contextId, _fileState, name, mimeType, size, newAttrs, _t, _t2;
110
+ return _regenerator.default.wrap(function (_context3) {
111
111
  while (1) switch (_context3.prev = _context3.next) {
112
112
  case 0:
113
113
  attrs = _this.getAttrs();
114
- _context3.next = 3;
114
+ _context3.next = 1;
115
115
  return _this.props.mediaProvider;
116
- case 3:
116
+ case 1:
117
117
  mediaProvider = _context3.sent;
118
118
  if (!(!mediaProvider || !mediaProvider.uploadParams || !attrs || !isMediaTypeSupported(attrs.type) || _this.hasFileAttributesDefined(attrs))) {
119
- _context3.next = 6;
119
+ _context3.next = 2;
120
120
  break;
121
121
  }
122
122
  return _context3.abrupt("return");
123
- case 6:
123
+ case 2:
124
124
  mediaClientConfig = mediaProvider.viewMediaClientConfig;
125
125
  mediaClient = (0, _mediaClientReact.getMediaClient)(mediaClientConfig);
126
126
  id = attrs.id, collectionName = attrs.collection;
127
- _context3.prev = 9;
128
- _context3.next = 12;
127
+ _context3.prev = 3;
128
+ _context3.next = 4;
129
129
  return mediaClient.file.getCurrentState(id, {
130
130
  collectionName: collectionName
131
131
  });
132
- case 12:
132
+ case 4:
133
133
  fileState = _context3.sent;
134
134
  if (!(fileState.status === 'error')) {
135
- _context3.next = 15;
135
+ _context3.next = 5;
136
136
  break;
137
137
  }
138
138
  return _context3.abrupt("return");
139
- case 15:
140
- _context3.next = 20;
139
+ case 5:
140
+ _context3.next = 7;
141
141
  break;
142
- case 17:
143
- _context3.prev = 17;
144
- _context3.t0 = _context3["catch"](9);
142
+ case 6:
143
+ _context3.prev = 6;
144
+ _t = _context3["catch"](3);
145
145
  return _context3.abrupt("return");
146
- case 20:
147
- _context3.t1 = _this.getNodeContextId();
148
- if (_context3.t1) {
149
- _context3.next = 25;
146
+ case 7:
147
+ _t2 = _this.getNodeContextId();
148
+ if (_t2) {
149
+ _context3.next = 9;
150
150
  break;
151
151
  }
152
- _context3.next = 24;
152
+ _context3.next = 8;
153
153
  return _this.getObjectId();
154
- case 24:
155
- _context3.t1 = _context3.sent;
156
- case 25:
157
- contextId = _context3.t1;
154
+ case 8:
155
+ _t2 = _context3.sent;
156
+ case 9:
157
+ contextId = _t2;
158
158
  _fileState = fileState, name = _fileState.name, mimeType = _fileState.mimeType, size = _fileState.size;
159
159
  newAttrs = {
160
160
  __fileName: name,
@@ -163,26 +163,26 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
163
163
  __contextId: contextId
164
164
  };
165
165
  if (hasPrivateAttrsChanged(attrs, newAttrs)) {
166
- _context3.next = 30;
166
+ _context3.next = 10;
167
167
  break;
168
168
  }
169
169
  return _context3.abrupt("return");
170
- case 30:
170
+ case 10:
171
171
  return _context3.abrupt("return", newAttrs);
172
- case 31:
172
+ case 11:
173
173
  case "end":
174
174
  return _context3.stop();
175
175
  }
176
- }, _callee3, null, [[9, 17]]);
176
+ }, _callee3, null, [[3, 6]]);
177
177
  })));
178
178
  (0, _defineProperty2.default)(this, "updateMediaSingleFileAttrs", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
179
179
  var newAttrs, _ref5, id;
180
- return _regenerator.default.wrap(function _callee4$(_context4) {
180
+ return _regenerator.default.wrap(function (_context4) {
181
181
  while (1) switch (_context4.prev = _context4.next) {
182
182
  case 0:
183
- _context4.next = 2;
183
+ _context4.next = 1;
184
184
  return _this.getNewFileAttrsForNode();
185
- case 2:
185
+ case 1:
186
186
  newAttrs = _context4.sent;
187
187
  _ref5 = _this.getAttrs(), id = _ref5.id;
188
188
  if (id && newAttrs) {
@@ -191,7 +191,7 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
191
191
  nextAttributes: newAttrs
192
192
  });
193
193
  }
194
- case 5:
194
+ case 2:
195
195
  case "end":
196
196
  return _context4.stop();
197
197
  }
@@ -200,12 +200,12 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
200
200
  (0, _defineProperty2.default)(this, "updateNodeAttrs", /*#__PURE__*/function () {
201
201
  var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(getPos) {
202
202
  var newAttrs;
203
- return _regenerator.default.wrap(function _callee5$(_context5) {
203
+ return _regenerator.default.wrap(function (_context5) {
204
204
  while (1) switch (_context5.prev = _context5.next) {
205
205
  case 0:
206
- _context5.next = 2;
206
+ _context5.next = 1;
207
207
  return _this.getNewFileAttrsForNode();
208
- case 2:
208
+ case 1:
209
209
  newAttrs = _context5.sent;
210
210
  if (newAttrs) {
211
211
  (0, _helpers.updateCurrentMediaNodeAttrs)(newAttrs, {
@@ -213,7 +213,7 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
213
213
  getPos: getPos
214
214
  })(_this.props.view.state, _this.props.view.dispatch);
215
215
  }
216
- case 4:
216
+ case 2:
217
217
  case "end":
218
218
  return _context5.stop();
219
219
  }
@@ -232,15 +232,15 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
232
232
  });
233
233
  (0, _defineProperty2.default)(this, "getObjectId", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
234
234
  var contextIdentifierProvider;
235
- return _regenerator.default.wrap(function _callee6$(_context6) {
235
+ return _regenerator.default.wrap(function (_context6) {
236
236
  while (1) switch (_context6.prev = _context6.next) {
237
237
  case 0:
238
- _context6.next = 2;
238
+ _context6.next = 1;
239
239
  return _this.props.contextIdentifierProvider;
240
- case 2:
240
+ case 1:
241
241
  contextIdentifierProvider = _context6.sent;
242
242
  return _context6.abrupt("return", (contextIdentifierProvider === null || contextIdentifierProvider === void 0 ? void 0 : contextIdentifierProvider.objectId) || null);
243
- case 4:
243
+ case 2:
244
244
  case "end":
245
245
  return _context6.stop();
246
246
  }
@@ -248,47 +248,47 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
248
248
  })));
249
249
  (0, _defineProperty2.default)(this, "uploadExternalMedia", /*#__PURE__*/function () {
250
250
  var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(getPos) {
251
- var _this$props, node, mediaOptions, mediaProvider, uploadMediaClientConfig, mediaClient, collection, uploader, uploadableFileUpfrontIds, dimensions, pos;
252
- return _regenerator.default.wrap(function _callee7$(_context7) {
251
+ var _this$props, node, mediaOptions, mediaProvider, uploadMediaClientConfig, mediaClient, collection, uploader, uploadableFileUpfrontIds, dimensions, pos, _t3;
252
+ return _regenerator.default.wrap(function (_context7) {
253
253
  while (1) switch (_context7.prev = _context7.next) {
254
254
  case 0:
255
255
  _this$props = _this.props, node = _this$props.node, mediaOptions = _this$props.mediaOptions;
256
256
  if (!(mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.isExternalMediaUploadDisabled)) {
257
- _context7.next = 3;
257
+ _context7.next = 1;
258
258
  break;
259
259
  }
260
260
  return _context7.abrupt("return");
261
- case 3:
262
- _context7.next = 5;
261
+ case 1:
262
+ _context7.next = 2;
263
263
  return _this.props.mediaProvider;
264
- case 5:
264
+ case 2:
265
265
  mediaProvider = _context7.sent;
266
266
  if (!(node && mediaProvider)) {
267
- _context7.next = 26;
267
+ _context7.next = 8;
268
268
  break;
269
269
  }
270
270
  uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
271
271
  if (!(!uploadMediaClientConfig || !node.attrs.url)) {
272
- _context7.next = 10;
272
+ _context7.next = 3;
273
273
  break;
274
274
  }
275
275
  return _context7.abrupt("return");
276
- case 10:
276
+ case 3:
277
277
  mediaClient = (0, _mediaClientReact.getMediaClient)(uploadMediaClientConfig);
278
278
  collection = mediaProvider.uploadParams && mediaProvider.uploadParams.collection;
279
- _context7.prev = 12;
280
- _context7.next = 15;
279
+ _context7.prev = 4;
280
+ _context7.next = 5;
281
281
  return mediaClient.file.uploadExternal(node.attrs.url, collection);
282
- case 15:
282
+ case 5:
283
283
  uploader = _context7.sent;
284
284
  uploadableFileUpfrontIds = uploader.uploadableFileUpfrontIds, dimensions = uploader.dimensions;
285
285
  pos = getPos();
286
286
  if (!(typeof pos !== 'number')) {
287
- _context7.next = 20;
287
+ _context7.next = 6;
288
288
  break;
289
289
  }
290
290
  return _context7.abrupt("return");
291
- case 20:
291
+ case 6:
292
292
  (0, _helpers.replaceExternalMedia)(pos + 1, {
293
293
  id: uploadableFileUpfrontIds.id,
294
294
  collection: collection,
@@ -296,11 +296,11 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
296
296
  width: dimensions.width,
297
297
  occurrenceKey: uploadableFileUpfrontIds.occurrenceKey
298
298
  })(_this.props.view.state, _this.props.view.dispatch);
299
- _context7.next = 26;
299
+ _context7.next = 8;
300
300
  break;
301
- case 23:
302
- _context7.prev = 23;
303
- _context7.t0 = _context7["catch"](12);
301
+ case 7:
302
+ _context7.prev = 7;
303
+ _t3 = _context7["catch"](4);
304
304
  //keep it as external media
305
305
  if (_this.props.dispatchAnalyticsEvent) {
306
306
  _this.props.dispatchAnalyticsEvent({
@@ -309,11 +309,11 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
309
309
  eventType: _analytics.EVENT_TYPE.OPERATIONAL
310
310
  });
311
311
  }
312
- case 26:
312
+ case 8:
313
313
  case "end":
314
314
  return _context7.stop();
315
315
  }
316
- }, _callee7, null, [[12, 23]]);
316
+ }, _callee7, null, [[4, 7]]);
317
317
  }));
318
318
  return function (_x3) {
319
319
  return _ref8.apply(this, arguments);
@@ -404,30 +404,30 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
404
404
  (0, _defineProperty2.default)(this, "shouldNodeBeDeepCopied", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
405
405
  var _ref0, _this$props$mediaOpti, _this$props$mediaOpti2, _this$mediaPluginStat;
406
406
  var scope, attrs, id, isIdentifierOutsideEditorScope;
407
- return _regenerator.default.wrap(function _callee8$(_context8) {
407
+ return _regenerator.default.wrap(function (_context8) {
408
408
  while (1) switch (_context8.prev = _context8.next) {
409
409
  case 0:
410
410
  scope = (_ref0 = (_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 && _ref0 !== void 0 ? _ref0 : 'context';
411
411
  if (!(scope === 'context')) {
412
- _context8.next = 7;
412
+ _context8.next = 2;
413
413
  break;
414
414
  }
415
- _context8.next = 4;
415
+ _context8.next = 1;
416
416
  return _this.hasDifferentContextId();
417
- case 4:
417
+ case 1:
418
418
  return _context8.abrupt("return", _context8.sent);
419
- case 7:
419
+ case 2:
420
420
  attrs = _this.getAttrs();
421
421
  if (!(!attrs || !_this.mediaPluginState)) {
422
- _context8.next = 10;
422
+ _context8.next = 3;
423
423
  break;
424
424
  }
425
425
  return _context8.abrupt("return", false);
426
- case 10:
426
+ case 3:
427
427
  id = (0, _mediaCommon2.getIdentifier)(attrs);
428
428
  isIdentifierOutsideEditorScope = !_this.mediaPluginState.isIdentifierInEditorScope(id);
429
429
  return _context8.abrupt("return", isIdentifierOutsideEditorScope);
430
- case 13:
430
+ case 4:
431
431
  case "end":
432
432
  return _context8.stop();
433
433
  }
@@ -435,70 +435,70 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
435
435
  })));
436
436
  (0, _defineProperty2.default)(this, "hasDifferentContextId", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
437
437
  var nodeContextId, currentContextId;
438
- return _regenerator.default.wrap(function _callee9$(_context9) {
438
+ return _regenerator.default.wrap(function (_context9) {
439
439
  while (1) switch (_context9.prev = _context9.next) {
440
440
  case 0:
441
441
  nodeContextId = _this.getNodeContextId();
442
- _context9.next = 3;
442
+ _context9.next = 1;
443
443
  return _this.getObjectId();
444
- case 3:
444
+ case 1:
445
445
  currentContextId = _context9.sent;
446
446
  if (!(nodeContextId && currentContextId && nodeContextId !== currentContextId)) {
447
- _context9.next = 6;
447
+ _context9.next = 2;
448
448
  break;
449
449
  }
450
450
  return _context9.abrupt("return", true);
451
- case 6:
451
+ case 2:
452
452
  return _context9.abrupt("return", false);
453
- case 7:
453
+ case 3:
454
454
  case "end":
455
455
  return _context9.stop();
456
456
  }
457
457
  }, _callee9);
458
458
  })));
459
459
  (0, _defineProperty2.default)(this, "isNodeFromDifferentCollection", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee0() {
460
- var mediaProvider, currentCollectionName, attrs, nodeCollection, __contextId, contextId;
461
- return _regenerator.default.wrap(function _callee0$(_context0) {
460
+ var mediaProvider, currentCollectionName, attrs, nodeCollection, __contextId, contextId, _t4;
461
+ return _regenerator.default.wrap(function (_context0) {
462
462
  while (1) switch (_context0.prev = _context0.next) {
463
463
  case 0:
464
- _context0.next = 2;
464
+ _context0.next = 1;
465
465
  return _this.props.mediaProvider;
466
- case 2:
466
+ case 1:
467
467
  mediaProvider = _context0.sent;
468
468
  if (!(!mediaProvider || !mediaProvider.uploadParams)) {
469
- _context0.next = 5;
469
+ _context0.next = 2;
470
470
  break;
471
471
  }
472
472
  return _context0.abrupt("return", false);
473
- case 5:
473
+ case 2:
474
474
  currentCollectionName = mediaProvider.uploadParams.collection;
475
475
  attrs = _this.getAttrs();
476
476
  if (!(!attrs || attrs && !isMediaTypeSupported(attrs.type))) {
477
- _context0.next = 9;
477
+ _context0.next = 3;
478
478
  break;
479
479
  }
480
480
  return _context0.abrupt("return", false);
481
- case 9:
481
+ case 3:
482
482
  nodeCollection = attrs.collection, __contextId = attrs.__contextId;
483
- _context0.t0 = __contextId;
484
- if (_context0.t0) {
485
- _context0.next = 15;
483
+ _t4 = __contextId;
484
+ if (_t4) {
485
+ _context0.next = 5;
486
486
  break;
487
487
  }
488
- _context0.next = 14;
488
+ _context0.next = 4;
489
489
  return _this.getObjectId();
490
- case 14:
491
- _context0.t0 = _context0.sent;
492
- case 15:
493
- contextId = _context0.t0;
490
+ case 4:
491
+ _t4 = _context0.sent;
492
+ case 5:
493
+ contextId = _t4;
494
494
  if (!(contextId && currentCollectionName !== nodeCollection)) {
495
- _context0.next = 18;
495
+ _context0.next = 6;
496
496
  break;
497
497
  }
498
498
  return _context0.abrupt("return", true);
499
- case 18:
499
+ case 6:
500
500
  return _context0.abrupt("return", false);
501
- case 19:
501
+ case 7:
502
502
  case "end":
503
503
  return _context0.stop();
504
504
  }
@@ -506,41 +506,41 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
506
506
  })));
507
507
  (0, _defineProperty2.default)(this, "handleCopyFileSwitcher", /*#__PURE__*/function () {
508
508
  var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee1(attrs) {
509
- var mediaClient, source, destination, traceContext, _yield$mediaClient$fi, id, _sourceAP, copyV2Source, _destAP, copyV2Destination, _yield$mediaClient$fi2, _id;
510
- return _regenerator.default.wrap(function _callee1$(_context1) {
509
+ var mediaClient, source, destination, traceContext, _yield$mediaClient$fi, id, _sourceAP, copyV2Source, _destAP, copyV2Destination, _yield$mediaClient$fi2, _id, _t5;
510
+ return _regenerator.default.wrap(function (_context1) {
511
511
  while (1) switch (_context1.prev = _context1.next) {
512
512
  case 0:
513
513
  mediaClient = attrs.mediaClient, source = attrs.source, destination = attrs.destination, traceContext = attrs.traceContext;
514
514
  _context1.prev = 1;
515
- _context1.next = 4;
515
+ _context1.next = 2;
516
516
  return mediaClient.file.copyFile(source, destination, undefined, traceContext);
517
- case 4:
517
+ case 2:
518
518
  _yield$mediaClient$fi = _context1.sent;
519
519
  id = _yield$mediaClient$fi.id;
520
520
  return _context1.abrupt("return", id);
521
- case 9:
522
- _context1.prev = 9;
523
- _context1.t0 = _context1["catch"](1);
521
+ case 3:
522
+ _context1.prev = 3;
523
+ _t5 = _context1["catch"](1);
524
524
  if (!(0, _platformFeatureFlags.fg)('platform_media_cross_client_copy')) {
525
- _context1.next = 21;
525
+ _context1.next = 5;
526
526
  break;
527
527
  }
528
528
  // calling /v2/file/copy by removing the auth tokens to make cross product copy and pastes
529
529
  _sourceAP = source.authProvider, copyV2Source = (0, _objectWithoutProperties2.default)(source, _excluded);
530
530
  _destAP = destination.authProvider, copyV2Destination = (0, _objectWithoutProperties2.default)(destination, _excluded2);
531
- _context1.next = 16;
531
+ _context1.next = 4;
532
532
  return mediaClient.file.copyFile(copyV2Source, copyV2Destination, undefined, traceContext);
533
- case 16:
533
+ case 4:
534
534
  _yield$mediaClient$fi2 = _context1.sent;
535
535
  _id = _yield$mediaClient$fi2.id;
536
536
  return _context1.abrupt("return", _id);
537
- case 21:
538
- throw _context1.t0;
539
- case 22:
537
+ case 5:
538
+ throw _t5;
539
+ case 6:
540
540
  case "end":
541
541
  return _context1.stop();
542
542
  }
543
- }, _callee1, null, [[1, 9]]);
543
+ }, _callee1, null, [[1, 3]]);
544
544
  }));
545
545
  return function (_x4) {
546
546
  return _ref11.apply(this, arguments);
@@ -549,46 +549,46 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
549
549
  (0, _defineProperty2.default)(this, "copyNodeFromBlobUrl", /*#__PURE__*/function () {
550
550
  var _ref12 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(getPos) {
551
551
  var attrs, url, mediaAttrs, mediaProvider, currentCollectionName, contextId, clientId, id, collection, height, width, mimeType, name, size, uploadMediaClientConfig, mediaClient, getAuthFromContext, mediaFileId, pos;
552
- return _regenerator.default.wrap(function _callee10$(_context10) {
552
+ return _regenerator.default.wrap(function (_context10) {
553
553
  while (1) switch (_context10.prev = _context10.next) {
554
554
  case 0:
555
555
  attrs = _this.getAttrs();
556
556
  if (!(!attrs || attrs.type !== 'external')) {
557
- _context10.next = 3;
557
+ _context10.next = 1;
558
558
  break;
559
559
  }
560
560
  return _context10.abrupt("return");
561
- case 3:
561
+ case 1:
562
562
  url = attrs.url;
563
563
  mediaAttrs = (0, _mediaClient.getAttrsFromUrl)(url);
564
564
  if (mediaAttrs) {
565
- _context10.next = 7;
565
+ _context10.next = 2;
566
566
  break;
567
567
  }
568
568
  return _context10.abrupt("return");
569
- case 7:
570
- _context10.next = 9;
569
+ case 2:
570
+ _context10.next = 3;
571
571
  return _this.props.mediaProvider;
572
- case 9:
572
+ case 3:
573
573
  mediaProvider = _context10.sent;
574
574
  if (!(!mediaProvider || !mediaProvider.uploadParams)) {
575
- _context10.next = 12;
575
+ _context10.next = 4;
576
576
  break;
577
577
  }
578
578
  return _context10.abrupt("return");
579
- case 12:
579
+ case 4:
580
580
  currentCollectionName = mediaProvider.uploadParams.collection;
581
581
  contextId = mediaAttrs.contextId, clientId = mediaAttrs.clientId, id = mediaAttrs.id, collection = mediaAttrs.collection, height = mediaAttrs.height, width = mediaAttrs.width, mimeType = mediaAttrs.mimeType, name = mediaAttrs.name, size = mediaAttrs.size;
582
582
  uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
583
583
  if (!(!uploadMediaClientConfig || !uploadMediaClientConfig.getAuthFromContext)) {
584
- _context10.next = 17;
584
+ _context10.next = 5;
585
585
  break;
586
586
  }
587
587
  return _context10.abrupt("return");
588
- case 17:
588
+ case 5:
589
589
  mediaClient = (0, _mediaClientReact.getMediaClient)(uploadMediaClientConfig);
590
590
  getAuthFromContext = uploadMediaClientConfig.getAuthFromContext;
591
- _context10.next = 21;
591
+ _context10.next = 6;
592
592
  return _this.handleCopyFileSwitcher({
593
593
  mediaClient: mediaClient,
594
594
  source: {
@@ -606,15 +606,15 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
606
606
  occurrenceKey: (0, _v.default)()
607
607
  }
608
608
  });
609
- case 21:
609
+ case 6:
610
610
  mediaFileId = _context10.sent;
611
611
  pos = getPos();
612
612
  if (!(typeof pos !== 'number')) {
613
- _context10.next = 25;
613
+ _context10.next = 7;
614
614
  break;
615
615
  }
616
616
  return _context10.abrupt("return");
617
- case 25:
617
+ case 7:
618
618
  (0, _helpers.replaceExternalMedia)(pos + 1, {
619
619
  id: mediaFileId,
620
620
  collection: currentCollectionName,
@@ -624,7 +624,7 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
624
624
  __fileMimeType: mimeType,
625
625
  __fileSize: size
626
626
  })(_this.props.view.state, _this.props.view.dispatch);
627
- case 26:
627
+ case 8:
628
628
  case "end":
629
629
  return _context10.stop();
630
630
  }
@@ -638,31 +638,31 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
638
638
  (0, _defineProperty2.default)(this, "copyNodeFromPos", /*#__PURE__*/function () {
639
639
  var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(getPos, traceContext) {
640
640
  var attrs, copiedAttrs;
641
- return _regenerator.default.wrap(function _callee11$(_context11) {
641
+ return _regenerator.default.wrap(function (_context11) {
642
642
  while (1) switch (_context11.prev = _context11.next) {
643
643
  case 0:
644
644
  attrs = _this.getAttrs();
645
645
  if (!(!attrs || attrs && !isMediaTypeSupported(attrs.type))) {
646
- _context11.next = 3;
646
+ _context11.next = 1;
647
647
  break;
648
648
  }
649
649
  return _context11.abrupt("return");
650
- case 3:
651
- _context11.next = 5;
650
+ case 1:
651
+ _context11.next = 2;
652
652
  return _this.copyFile(attrs.id, attrs.collection, traceContext);
653
- case 5:
653
+ case 2:
654
654
  copiedAttrs = _context11.sent;
655
655
  if (copiedAttrs) {
656
- _context11.next = 8;
656
+ _context11.next = 3;
657
657
  break;
658
658
  }
659
659
  return _context11.abrupt("return");
660
- case 8:
660
+ case 3:
661
661
  (0, _helpers.updateCurrentMediaNodeAttrs)(copiedAttrs, {
662
662
  node: _this.props.node,
663
663
  getPos: getPos
664
664
  })(_this.props.view.state, _this.props.view.dispatch);
665
- case 9:
665
+ case 4:
666
666
  case "end":
667
667
  return _context11.stop();
668
668
  }
@@ -676,29 +676,29 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
676
676
  (0, _defineProperty2.default)(this, "copyNode", /*#__PURE__*/function () {
677
677
  var _ref14 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(traceContext) {
678
678
  var attrs, view, copiedAttrs;
679
- return _regenerator.default.wrap(function _callee12$(_context12) {
679
+ return _regenerator.default.wrap(function (_context12) {
680
680
  while (1) switch (_context12.prev = _context12.next) {
681
681
  case 0:
682
682
  attrs = _this.getAttrs();
683
683
  view = _this.props.view;
684
684
  if (!(!attrs || attrs && !isMediaTypeSupported(attrs.type))) {
685
- _context12.next = 4;
685
+ _context12.next = 1;
686
686
  break;
687
687
  }
688
688
  return _context12.abrupt("return");
689
- case 4:
690
- _context12.next = 6;
689
+ case 1:
690
+ _context12.next = 2;
691
691
  return _this.copyFile(attrs.id, attrs.collection, traceContext);
692
- case 6:
692
+ case 2:
693
693
  copiedAttrs = _context12.sent;
694
694
  if (copiedAttrs) {
695
- _context12.next = 9;
695
+ _context12.next = 3;
696
696
  break;
697
697
  }
698
698
  return _context12.abrupt("return");
699
- case 9:
699
+ case 3:
700
700
  (0, _helpers.updateMediaNodeAttrs)(attrs.id, copiedAttrs)(view.state, view.dispatch);
701
- case 10:
701
+ case 4:
702
702
  case "end":
703
703
  return _context12.stop();
704
704
  }
@@ -711,36 +711,36 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
711
711
  (0, _defineProperty2.default)(this, "copyFile", /*#__PURE__*/function () {
712
712
  var _ref15 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(id, collection, traceContext) {
713
713
  var mediaProvider, nodeContextId, uploadMediaClientConfig, mediaClient, clientId, currentCollectionName, objectId, getAuthFromContext, mediaFileId;
714
- return _regenerator.default.wrap(function _callee13$(_context13) {
714
+ return _regenerator.default.wrap(function (_context13) {
715
715
  while (1) switch (_context13.prev = _context13.next) {
716
716
  case 0:
717
- _context13.next = 2;
717
+ _context13.next = 1;
718
718
  return _this.props.mediaProvider;
719
- case 2:
719
+ case 1:
720
720
  mediaProvider = _context13.sent;
721
721
  if (mediaProvider !== null && mediaProvider !== void 0 && mediaProvider.uploadParams) {
722
- _context13.next = 5;
722
+ _context13.next = 2;
723
723
  break;
724
724
  }
725
725
  return _context13.abrupt("return");
726
- case 5:
726
+ case 2:
727
727
  nodeContextId = _this.getNodeContextId();
728
728
  uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
729
729
  if (!(!(uploadMediaClientConfig !== null && uploadMediaClientConfig !== void 0 && uploadMediaClientConfig.getAuthFromContext) || !nodeContextId)) {
730
- _context13.next = 9;
730
+ _context13.next = 3;
731
731
  break;
732
732
  }
733
733
  return _context13.abrupt("return");
734
- case 9:
734
+ case 3:
735
735
  mediaClient = (0, _mediaClientReact.getMediaClient)(uploadMediaClientConfig);
736
736
  clientId = (0, _platformFeatureFlags.fg)('platform_media_cross_client_copy_with_auth') ? (0, _mediaCommon.getClientIdForFile)(id) : undefined;
737
737
  currentCollectionName = mediaProvider.uploadParams.collection;
738
- _context13.next = 14;
738
+ _context13.next = 4;
739
739
  return _this.getObjectId();
740
- case 14:
740
+ case 4:
741
741
  objectId = _context13.sent;
742
742
  getAuthFromContext = uploadMediaClientConfig.getAuthFromContext;
743
- _context13.next = 18;
743
+ _context13.next = 5;
744
744
  return _this.handleCopyFileSwitcher({
745
745
  mediaClient: mediaClient,
746
746
  source: {
@@ -759,14 +759,14 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
759
759
  },
760
760
  traceContext: traceContext
761
761
  });
762
- case 18:
762
+ case 5:
763
763
  mediaFileId = _context13.sent;
764
764
  return _context13.abrupt("return", {
765
765
  id: mediaFileId,
766
766
  collection: currentCollectionName,
767
767
  __contextId: objectId
768
768
  });
769
- case 20:
769
+ case 6:
770
770
  case "end":
771
771
  return _context13.stop();
772
772
  }
@@ -795,37 +795,37 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
795
795
  value: function () {
796
796
  var _getRemoteDimensions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
797
797
  var mediaProvider, mediaOptions, attrs, height, width, id, collection, viewMediaClientConfig, mediaClient, currentState, imageMetadata;
798
- return _regenerator.default.wrap(function _callee14$(_context14) {
798
+ return _regenerator.default.wrap(function (_context14) {
799
799
  while (1) switch (_context14.prev = _context14.next) {
800
800
  case 0:
801
- _context14.next = 2;
801
+ _context14.next = 1;
802
802
  return this.props.mediaProvider;
803
- case 2:
803
+ case 1:
804
804
  mediaProvider = _context14.sent;
805
805
  mediaOptions = this.props.mediaOptions;
806
806
  attrs = this.getAttrs();
807
807
  if (!(!mediaProvider || !attrs)) {
808
- _context14.next = 7;
808
+ _context14.next = 2;
809
809
  break;
810
810
  }
811
811
  return _context14.abrupt("return", false);
812
- case 7:
812
+ case 2:
813
813
  height = attrs.height, width = attrs.width;
814
814
  if (!(attrs.type === 'external' || !attrs.id)) {
815
- _context14.next = 10;
815
+ _context14.next = 3;
816
816
  break;
817
817
  }
818
818
  return _context14.abrupt("return", false);
819
- case 10:
819
+ case 3:
820
820
  id = attrs.id, collection = attrs.collection;
821
821
  if (!(height && width)) {
822
- _context14.next = 13;
822
+ _context14.next = 4;
823
823
  break;
824
824
  }
825
825
  return _context14.abrupt("return", false);
826
- case 13:
826
+ case 4:
827
827
  if (!(mediaOptions && !mediaOptions.allowRemoteDimensionsFetch)) {
828
- _context14.next = 15;
828
+ _context14.next = 5;
829
829
  break;
830
830
  }
831
831
  return _context14.abrupt("return", {
@@ -833,39 +833,39 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
833
833
  height: _mediaSingle.DEFAULT_IMAGE_HEIGHT,
834
834
  width: _mediaSingle.DEFAULT_IMAGE_WIDTH
835
835
  });
836
- case 15:
836
+ case 5:
837
837
  viewMediaClientConfig = mediaProvider.viewMediaClientConfig;
838
838
  mediaClient = (0, _mediaClientReact.getMediaClient)(viewMediaClientConfig);
839
- _context14.next = 19;
839
+ _context14.next = 6;
840
840
  return mediaClient.file.getCurrentState(id, {
841
841
  collectionName: collection
842
842
  });
843
- case 19:
843
+ case 6:
844
844
  currentState = _context14.sent;
845
845
  if ((0, _mediaClient.isImageRepresentationReady)(currentState)) {
846
- _context14.next = 22;
846
+ _context14.next = 7;
847
847
  break;
848
848
  }
849
849
  return _context14.abrupt("return", false);
850
- case 22:
851
- _context14.next = 24;
850
+ case 7:
851
+ _context14.next = 8;
852
852
  return mediaClient.getImageMetadata(id, {
853
853
  collection: collection
854
854
  });
855
- case 24:
855
+ case 8:
856
856
  imageMetadata = _context14.sent;
857
857
  if (!(!imageMetadata || !imageMetadata.original)) {
858
- _context14.next = 27;
858
+ _context14.next = 9;
859
859
  break;
860
860
  }
861
861
  return _context14.abrupt("return", false);
862
- case 27:
862
+ case 9:
863
863
  return _context14.abrupt("return", {
864
864
  id: id,
865
865
  height: imageMetadata.original.height || _mediaSingle.DEFAULT_IMAGE_HEIGHT,
866
866
  width: imageMetadata.original.width || _mediaSingle.DEFAULT_IMAGE_WIDTH
867
867
  });
868
- case 28:
868
+ case 10:
869
869
  case "end":
870
870
  return _context14.stop();
871
871
  }
@@ -880,35 +880,36 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
880
880
  key: "handleExternalMedia",
881
881
  value: function () {
882
882
  var _handleExternalMedia = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(getPos) {
883
- return _regenerator.default.wrap(function _callee15$(_context15) {
883
+ var _t6;
884
+ return _regenerator.default.wrap(function (_context15) {
884
885
  while (1) switch (_context15.prev = _context15.next) {
885
886
  case 0:
886
887
  if (!this.isMediaBlobUrl()) {
887
- _context15.next = 12;
888
+ _context15.next = 5;
888
889
  break;
889
890
  }
890
891
  _context15.prev = 1;
891
- _context15.next = 4;
892
+ _context15.next = 2;
892
893
  return this.copyNodeFromBlobUrl(getPos);
893
- case 4:
894
- _context15.next = 10;
894
+ case 2:
895
+ _context15.next = 4;
895
896
  break;
896
- case 6:
897
- _context15.prev = 6;
898
- _context15.t0 = _context15["catch"](1);
899
- _context15.next = 10;
897
+ case 3:
898
+ _context15.prev = 3;
899
+ _t6 = _context15["catch"](1);
900
+ _context15.next = 4;
900
901
  return this.uploadExternalMedia(getPos);
901
- case 10:
902
- _context15.next = 14;
902
+ case 4:
903
+ _context15.next = 6;
903
904
  break;
904
- case 12:
905
- _context15.next = 14;
905
+ case 5:
906
+ _context15.next = 6;
906
907
  return this.uploadExternalMedia(getPos);
907
- case 14:
908
+ case 6:
908
909
  case "end":
909
910
  return _context15.stop();
910
911
  }
911
- }, _callee15, this, [[1, 6]]);
912
+ }, _callee15, this, [[1, 3]]);
912
913
  }));
913
914
  function handleExternalMedia(_x10) {
914
915
  return _handleExternalMedia.apply(this, arguments);