@atlaskit/editor-plugin-media 12.8.2 → 12.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +19 -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 +18 -18
  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/esm/nodeviews/mediaGroupNext.js +12 -12
  21. package/dist/esm/nodeviews/mediaInline.js +25 -25
  22. package/dist/esm/nodeviews/mediaNodeUpdater.js +199 -198
  23. package/dist/esm/nodeviews/mediaNodeView/media.js +28 -16
  24. package/dist/esm/nodeviews/mediaSingleNext.js +23 -23
  25. package/dist/esm/pm-plugins/ai-generating-decoration.js +59 -12
  26. package/dist/esm/pm-plugins/commands.js +2 -2
  27. package/dist/esm/pm-plugins/main.js +54 -45
  28. package/dist/esm/pm-plugins/mediaTaskManager.js +6 -6
  29. package/dist/esm/pm-plugins/picker-facade.js +4 -4
  30. package/dist/esm/pm-plugins/utils/check-media-type.js +17 -17
  31. package/dist/esm/ui/MediaPicker/PickerFacadeProvider.js +21 -21
  32. package/dist/esm/ui/ResizableMediaSingle/index.js +18 -18
  33. package/dist/esm/ui/toolbar/utils.js +11 -11
  34. package/dist/types/mediaPluginType.d.ts +2 -1
  35. package/dist/types/nodeviews/mediaNodeView/media.d.ts +1 -0
  36. package/dist/types/pm-plugins/ai-generating-decoration.d.ts +3 -1
  37. package/dist/types/pm-plugins/commands.d.ts +2 -1
  38. package/dist/types/pm-plugins/main.d.ts +1 -0
  39. package/dist/types/pm-plugins/types.d.ts +1 -0
  40. package/dist/types-ts4.5/mediaPluginType.d.ts +2 -1
  41. package/dist/types-ts4.5/nodeviews/mediaNodeView/media.d.ts +1 -0
  42. package/dist/types-ts4.5/pm-plugins/ai-generating-decoration.d.ts +3 -1
  43. package/dist/types-ts4.5/pm-plugins/commands.d.ts +2 -1
  44. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -0
  45. package/dist/types-ts4.5/pm-plugins/types.d.ts +1 -0
  46. package/package.json +10 -7
@@ -10,45 +10,45 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
10
10
  var _mediaClientReact = require("@atlaskit/media-client-react");
11
11
  var checkMediaType = exports.checkMediaType = /*#__PURE__*/function () {
12
12
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(mediaNode, mediaClientConfig) {
13
- var fileState;
14
- return _regenerator.default.wrap(function _callee$(_context) {
13
+ var fileState, _t;
14
+ return _regenerator.default.wrap(function (_context) {
15
15
  while (1) switch (_context.prev = _context.next) {
16
16
  case 0:
17
17
  if (!(mediaNode.attrs.type === 'external')) {
18
- _context.next = 2;
18
+ _context.next = 1;
19
19
  break;
20
20
  }
21
21
  return _context.abrupt("return", 'external');
22
- case 2:
22
+ case 1:
23
23
  if (mediaNode.attrs.id) {
24
- _context.next = 4;
24
+ _context.next = 2;
25
25
  break;
26
26
  }
27
27
  return _context.abrupt("return");
28
- case 4:
29
- _context.prev = 4;
30
- _context.next = 7;
28
+ case 2:
29
+ _context.prev = 2;
30
+ _context.next = 3;
31
31
  return (0, _mediaClientReact.getMediaClient)(mediaClientConfig).file.getCurrentState(mediaNode.attrs.id, {
32
32
  collectionName: mediaNode.attrs.collection
33
33
  });
34
- case 7:
34
+ case 3:
35
35
  fileState = _context.sent;
36
36
  if (!(fileState && fileState.status !== 'error')) {
37
- _context.next = 10;
37
+ _context.next = 4;
38
38
  break;
39
39
  }
40
40
  return _context.abrupt("return", fileState.mediaType);
41
- case 10:
42
- _context.next = 14;
41
+ case 4:
42
+ _context.next = 6;
43
43
  break;
44
- case 12:
45
- _context.prev = 12;
46
- _context.t0 = _context["catch"](4);
47
- case 14:
44
+ case 5:
45
+ _context.prev = 5;
46
+ _t = _context["catch"](2);
47
+ case 6:
48
48
  case "end":
49
49
  return _context.stop();
50
50
  }
51
- }, _callee, null, [[4, 12]]);
51
+ }, _callee, null, [[2, 5]]);
52
52
  }));
53
53
  return function checkMediaType(_x, _x2) {
54
54
  return _ref.apply(this, arguments);
@@ -48,48 +48,48 @@ function PickerFacadeProvider(_ref) {
48
48
  options = _useSharedPluginState.options;
49
49
  var handleMediaProvider = (0, _react.useCallback)( /*#__PURE__*/function () {
50
50
  var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_name, provider) {
51
- var mediaProvider, resolvedMediaClientConfig, pickerFacadeConfig, pickerFacadeInstance, config;
52
- return _regenerator.default.wrap(function _callee$(_context) {
51
+ var mediaProvider, resolvedMediaClientConfig, pickerFacadeConfig, pickerFacadeInstance, config, _t;
52
+ return _regenerator.default.wrap(function (_context) {
53
53
  while (1) switch (_context.prev = _context.next) {
54
54
  case 0:
55
- _context.next = 2;
55
+ _context.next = 1;
56
56
  return provider;
57
- case 2:
57
+ case 1:
58
58
  mediaProvider = _context.sent;
59
59
  if (!(!mediaProvider || !mediaProvider.uploadParams || !insertFile)) {
60
- _context.next = 5;
60
+ _context.next = 2;
61
61
  break;
62
62
  }
63
63
  return _context.abrupt("return");
64
- case 5:
65
- _context.next = 7;
64
+ case 2:
65
+ _context.next = 3;
66
66
  return mediaProvider.uploadMediaClientConfig;
67
- case 7:
68
- _context.t0 = _context.sent;
69
- if (_context.t0) {
70
- _context.next = 12;
67
+ case 3:
68
+ _t = _context.sent;
69
+ if (_t) {
70
+ _context.next = 5;
71
71
  break;
72
72
  }
73
- _context.next = 11;
73
+ _context.next = 4;
74
74
  return mediaProvider.viewMediaClientConfig;
75
- case 11:
76
- _context.t0 = _context.sent;
77
- case 12:
78
- resolvedMediaClientConfig = _context.t0;
75
+ case 4:
76
+ _t = _context.sent;
77
+ case 5:
78
+ resolvedMediaClientConfig = _t;
79
79
  if (resolvedMediaClientConfig) {
80
- _context.next = 15;
80
+ _context.next = 6;
81
81
  break;
82
82
  }
83
83
  return _context.abrupt("return");
84
- case 15:
84
+ case 6:
85
85
  pickerFacadeConfig = {
86
86
  mediaClientConfig: resolvedMediaClientConfig,
87
87
  errorReporter: (options === null || options === void 0 ? void 0 : options.errorReporter) || new _utils.ErrorReporter(),
88
88
  featureFlags: mediaOptions && mediaOptions.featureFlags
89
89
  };
90
- _context.next = 18;
90
+ _context.next = 7;
91
91
  return new _pickerFacade.default('customMediaPicker', pickerFacadeConfig, dummyMediaPickerObject, analyticsName).init();
92
- case 18:
92
+ case 7:
93
93
  pickerFacadeInstance = _context.sent;
94
94
  pickerFacadeInstance.onNewMedia(insertFile);
95
95
  pickerFacadeInstance.setUploadParams(mediaProvider.uploadParams);
@@ -103,7 +103,7 @@ function PickerFacadeProvider(_ref) {
103
103
  mediaClientConfig: resolvedMediaClientConfig
104
104
  });
105
105
  });
106
- case 23:
106
+ case 8:
107
107
  case "end":
108
108
  return _context.stop();
109
109
  }
@@ -206,17 +206,17 @@ var ResizableMediaSingle = exports.default = /*#__PURE__*/function (_React$Compo
206
206
  value: function () {
207
207
  var _componentDidMount = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
208
208
  var viewMediaClientConfig;
209
- return _regenerator.default.wrap(function _callee$(_context) {
209
+ return _regenerator.default.wrap(function (_context) {
210
210
  while (1) switch (_context.prev = _context.next) {
211
211
  case 0:
212
212
  viewMediaClientConfig = this.props.viewMediaClientConfig;
213
213
  if (!viewMediaClientConfig) {
214
- _context.next = 4;
214
+ _context.next = 1;
215
215
  break;
216
216
  }
217
- _context.next = 4;
217
+ _context.next = 1;
218
218
  return this.checkVideoFile(viewMediaClientConfig);
219
- case 4:
219
+ case 1:
220
220
  case "end":
221
221
  return _context.stop();
222
222
  }
@@ -241,39 +241,39 @@ var ResizableMediaSingle = exports.default = /*#__PURE__*/function (_React$Compo
241
241
  key: "checkVideoFile",
242
242
  value: function () {
243
243
  var _checkVideoFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(viewMediaClientConfig) {
244
- var $pos, mediaNode, mediaType, isVideoFile;
245
- return _regenerator.default.wrap(function _callee2$(_context2) {
244
+ var $pos, mediaNode, mediaType, isVideoFile, _t;
245
+ return _regenerator.default.wrap(function (_context2) {
246
246
  while (1) switch (_context2.prev = _context2.next) {
247
247
  case 0:
248
248
  $pos = this.$pos;
249
249
  if (!(!$pos || !viewMediaClientConfig)) {
250
- _context2.next = 3;
250
+ _context2.next = 1;
251
251
  break;
252
252
  }
253
253
  return _context2.abrupt("return");
254
- case 3:
254
+ case 1:
255
255
  mediaNode = this.props.view.state.doc.nodeAt($pos.pos + 1);
256
256
  if (!mediaNode) {
257
- _context2.next = 10;
257
+ _context2.next = 3;
258
258
  break;
259
259
  }
260
- _context2.next = 7;
260
+ _context2.next = 2;
261
261
  return (0, _checkMediaType.checkMediaType)(mediaNode, viewMediaClientConfig);
262
- case 7:
263
- _context2.t0 = _context2.sent;
264
- _context2.next = 11;
262
+ case 2:
263
+ _t = _context2.sent;
264
+ _context2.next = 4;
265
265
  break;
266
- case 10:
267
- _context2.t0 = undefined;
268
- case 11:
269
- mediaType = _context2.t0;
266
+ case 3:
267
+ _t = undefined;
268
+ case 4:
269
+ mediaType = _t;
270
270
  isVideoFile = mediaType !== 'external' && mediaType !== 'image';
271
271
  if (this.state.isVideoFile !== isVideoFile) {
272
272
  this.setState({
273
273
  isVideoFile: isVideoFile
274
274
  });
275
275
  }
276
- case 14:
276
+ case 5:
277
277
  case "end":
278
278
  return _context2.stop();
279
279
  }
@@ -56,37 +56,37 @@ var getIsDownloadDisabledByDataSecurityPolicy = exports.getIsDownloadDisabledByD
56
56
  };
57
57
  var downloadMedia = exports.downloadMedia = /*#__PURE__*/function () {
58
58
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(mediaPluginState, isViewMode) {
59
- var selectedNodeAttrs, id, _selectedNodeAttrs$co, collection, mediaClient, fileState, fileName;
60
- return _regenerator.default.wrap(function _callee$(_context) {
59
+ var selectedNodeAttrs, id, _selectedNodeAttrs$co, collection, mediaClient, fileState, fileName, _t;
60
+ return _regenerator.default.wrap(function (_context) {
61
61
  while (1) switch (_context.prev = _context.next) {
62
62
  case 0:
63
63
  _context.prev = 0;
64
64
  selectedNodeAttrs = isViewMode ? getSelectedNearestMediaContainerNodeAttrs(mediaPluginState) : getSelectedMediaContainerNodeAttrs(mediaPluginState);
65
65
  if (!(selectedNodeAttrs && mediaPluginState.mediaClientConfig && !isExternalMedia(selectedNodeAttrs))) {
66
- _context.next = 10;
66
+ _context.next = 2;
67
67
  break;
68
68
  }
69
69
  id = selectedNodeAttrs.id, _selectedNodeAttrs$co = selectedNodeAttrs.collection, collection = _selectedNodeAttrs$co === void 0 ? '' : _selectedNodeAttrs$co;
70
70
  mediaClient = (0, _mediaClientReact.getMediaClient)(mediaPluginState.mediaClientConfig);
71
- _context.next = 7;
71
+ _context.next = 1;
72
72
  return mediaClient.file.getCurrentState(id, {
73
73
  collectionName: collection
74
74
  });
75
- case 7:
75
+ case 1:
76
76
  fileState = _context.sent;
77
77
  fileName = fileState.status === 'error' ? undefined : fileState.name;
78
78
  mediaClient.file.downloadBinary(id, fileName, collection);
79
- case 10:
79
+ case 2:
80
80
  return _context.abrupt("return", true);
81
- case 13:
82
- _context.prev = 13;
83
- _context.t0 = _context["catch"](0);
81
+ case 3:
82
+ _context.prev = 3;
83
+ _t = _context["catch"](0);
84
84
  return _context.abrupt("return", false);
85
- case 16:
85
+ case 4:
86
86
  case "end":
87
87
  return _context.stop();
88
88
  }
89
- }, _callee, null, [[0, 13]]);
89
+ }, _callee, null, [[0, 3]]);
90
90
  }));
91
91
  return function downloadMedia(_x, _x2) {
92
92
  return _ref.apply(this, arguments);
@@ -84,6 +84,17 @@ export class MediaNode extends Component {
84
84
  _defineProperty(this, "getMediaSettings", memoizeOne(viewAndUploadMediaClientConfig => ({
85
85
  canUpdateVideoCaptions: fg('platform_media_video_captions') ? !!viewAndUploadMediaClientConfig : false
86
86
  })));
87
+ _defineProperty(this, "onPreviewRender", fileId => {
88
+ if (fg('aifc_page_create_with_rovo_include_infographics')) {
89
+ var _this$props$pluginInj2, _this$props$pluginInj3;
90
+ (_this$props$pluginInj2 = this.props.pluginInjectionApi) === null || _this$props$pluginInj2 === void 0 ? void 0 : (_this$props$pluginInj3 = _this$props$pluginInj2.core) === null || _this$props$pluginInj3 === void 0 ? void 0 : _this$props$pluginInj3.actions.execute(({
91
+ tr
92
+ }) => tr.setMeta(mediaStateKey, {
93
+ type: 'PREVIEW_RENDERED',
94
+ fileId
95
+ }));
96
+ }
97
+ });
87
98
  _defineProperty(this, "onError", reason => {
88
99
  var _this$props$api;
89
100
  const nestedUnder = this.getNestedUnder();
@@ -319,6 +330,7 @@ export class MediaNode extends Component {
319
330
  ssr: ssr,
320
331
  mediaSettings: this.getMediaSettings(viewAndUploadMediaClientConfig),
321
332
  isAIGenerating: !!this.props.isAIGenerating,
333
+ onPreviewRender: this.onPreviewRender,
322
334
  onError: expValEquals('platform_editor_media_error_analytics', 'isEnabled', true) ? this.onError : undefined
323
335
  })));
324
336
  }
@@ -67,10 +67,11 @@ export function hasAIGeneratingDecoration(decorations) {
67
67
  * );
68
68
  * ```
69
69
  */
70
- export function setAIGeneratingMeta(tr, mediaId) {
70
+ export function setAIGeneratingMeta(tr, mediaId, source) {
71
71
  return tr.setMeta(aiGeneratingDecorationPluginKey, {
72
72
  type: 'SET_GENERATING',
73
- mediaId
73
+ mediaId,
74
+ source
74
75
  }).setMeta('addToHistory', false);
75
76
  }
76
77
 
@@ -94,7 +95,7 @@ export function createAIGeneratingDecorationPlugin() {
94
95
  state: {
95
96
  init() {
96
97
  return {
97
- generatingMediaIds: new Set(),
98
+ generatingMediaIds: new Map(),
98
99
  decorationSet: DecorationSet.empty
99
100
  };
100
101
  },
@@ -103,7 +104,7 @@ export function createAIGeneratingDecorationPlugin() {
103
104
  if (!fg('cc-maui-phase-2') || !expValEquals('cc-maui-experiment', 'isEnabled', true)) {
104
105
  if (pluginState.generatingMediaIds.size > 0) {
105
106
  return {
106
- generatingMediaIds: new Set(),
107
+ generatingMediaIds: new Map(),
107
108
  decorationSet: DecorationSet.empty
108
109
  };
109
110
  }
@@ -114,30 +115,71 @@ export function createAIGeneratingDecorationPlugin() {
114
115
  switch (meta.type) {
115
116
  case 'SET_GENERATING':
116
117
  {
117
- const ids = new Set(pluginState.generatingMediaIds);
118
- ids.add(meta.mediaId);
118
+ var _meta$source;
119
+ const ids = new Map(pluginState.generatingMediaIds);
120
+ ids.set(meta.mediaId, (_meta$source = meta.source) !== null && _meta$source !== void 0 ? _meta$source : 'maui');
121
+ const hasCwrIds = fg('aifc_page_create_with_rovo_include_infographics') && [...ids.values()].some(s => s === 'cwr');
122
+ const newDecoSet = buildDecorationSet(newState.doc, ids);
123
+ if (hasCwrIds && newDecoSet.find().length === 0 && ids.size > 0) {
124
+ // CWR fallback — keep existing decorations during transient doc absence
125
+ return {
126
+ generatingMediaIds: ids,
127
+ decorationSet: pluginState.decorationSet
128
+ };
129
+ }
119
130
  return {
120
131
  generatingMediaIds: ids,
121
- decorationSet: buildDecorationSet(newState.doc, ids)
132
+ decorationSet: newDecoSet
122
133
  };
123
134
  }
124
135
  case 'CLEAR_GENERATING':
125
136
  {
126
- const ids = new Set(pluginState.generatingMediaIds);
137
+ const ids = new Map(pluginState.generatingMediaIds);
127
138
  ids.delete(meta.mediaId);
139
+ const hasCwrIds = fg('aifc_page_create_with_rovo_include_infographics') && [...ids.values()].some(s => s === 'cwr');
140
+ const newDecoSet = buildDecorationSet(newState.doc, ids);
141
+ if (hasCwrIds && newDecoSet.find().length === 0) {
142
+ // CWR fallback — keep existing decorations during transient doc absence
143
+ return {
144
+ generatingMediaIds: ids,
145
+ decorationSet: pluginState.decorationSet
146
+ };
147
+ }
128
148
  return {
129
149
  generatingMediaIds: ids,
130
- decorationSet: buildDecorationSet(newState.doc, ids)
150
+ decorationSet: newDecoSet
131
151
  };
132
152
  }
133
153
  case 'CLEAR_ALL':
134
154
  return {
135
- generatingMediaIds: new Set(),
155
+ generatingMediaIds: new Map(),
136
156
  decorationSet: DecorationSet.empty
137
157
  };
138
158
  }
139
159
  }
140
160
 
161
+ // CWR path
162
+ // Rebuild decorations from scratch because CWR streaming replaces the
163
+ // entire document on every chunk and map() drops decorations whose
164
+ // positions can't be mapped.
165
+ const hasCwrIds = fg('aifc_page_create_with_rovo_include_infographics') && [...pluginState.generatingMediaIds.values()].some(s => s === 'cwr');
166
+ if (tr.docChanged && hasCwrIds) {
167
+ const rebuilt = buildDecorationSet(newState.doc, pluginState.generatingMediaIds);
168
+ const prevCount = pluginState.decorationSet.find().length;
169
+ const newCount = rebuilt.find().length;
170
+
171
+ // Prevents flickering that results from updating during transient
172
+ // doc replacements (when nodes are briefly absent)
173
+ if (newCount !== prevCount && newCount >= pluginState.generatingMediaIds.size) {
174
+ return {
175
+ ...pluginState,
176
+ decorationSet: rebuilt
177
+ };
178
+ }
179
+ return pluginState;
180
+ }
181
+
182
+ // Remix path
141
183
  // Map decorations through document changes so positions stay in sync
142
184
  if (tr.docChanged && pluginState.decorationSet !== DecorationSet.empty) {
143
185
  try {
@@ -146,9 +188,8 @@ export function createAIGeneratingDecorationPlugin() {
146
188
  decorationSet: pluginState.decorationSet.map(tr.mapping, newState.doc)
147
189
  };
148
190
  } catch {
149
- // Collaborative editing edge case — reset
150
191
  return {
151
- generatingMediaIds: new Set(),
192
+ generatingMediaIds: new Map(),
152
193
  decorationSet: DecorationSet.empty
153
194
  };
154
195
  }
@@ -41,9 +41,9 @@ export const trackMediaPaste = attrs => ({
41
41
  * Decorations live in the view layer only and never affect the document model
42
42
  * or undo/redo history.
43
43
  */
44
- export const setAIGenerating = mediaId => ({
44
+ export const setAIGenerating = (mediaId, source) => ({
45
45
  tr
46
- }) => setAIGeneratingMeta(tr, mediaId);
46
+ }) => setAIGeneratingMeta(tr, mediaId, source);
47
47
 
48
48
  /**
49
49
  * Clears the AI-generating decoration for a specific media node identified by
@@ -60,6 +60,7 @@ export class MediaPluginStateImplementation {
60
60
  _defineProperty(this, "ignoreLinks", false);
61
61
  _defineProperty(this, "waitForMediaUpload", true);
62
62
  _defineProperty(this, "allUploadsFinished", true);
63
+ _defineProperty(this, "previewRenderedMediaIds", new Set());
63
64
  _defineProperty(this, "showDropzone", false);
64
65
  _defineProperty(this, "isFullscreen", false);
65
66
  _defineProperty(this, "layout", 'center');
@@ -945,7 +946,7 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, node
945
946
  nextPluginState = nextPluginState.clone();
946
947
  }
947
948
  const meta = tr.getMeta(stateKey);
948
- if (meta) {
949
+ if (meta && meta.type !== 'PREVIEW_RENDERED') {
949
950
  const {
950
951
  allowsUploads
951
952
  } = meta;
@@ -955,6 +956,15 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, node
955
956
  nextPluginState = nextPluginState.clone();
956
957
  }
957
958
 
959
+ // Handle preview render notifications — add the file ID to the
960
+ // previewRenderedMediaIds Set so sharedState subscribers can react.
961
+ if ((meta === null || meta === void 0 ? void 0 : meta.type) === 'PREVIEW_RENDERED' && typeof meta.fileId === 'string') {
962
+ const newSet = new Set(pluginState.previewRenderedMediaIds);
963
+ newSet.add(meta.fileId);
964
+ pluginState.previewRenderedMediaIds = newSet;
965
+ nextPluginState = nextPluginState.clone();
966
+ }
967
+
958
968
  // ACTIONS
959
969
  switch (meta === null || meta === void 0 ? void 0 : meta.type) {
960
970
  case ACTIONS.SHOW_MEDIA_VIEWER:
@@ -121,38 +121,38 @@ var useLatestMediaGroupNode = function useLatestMediaGroupNode(nextMediaNode) {
121
121
  var runMediaNodeUpdate = /*#__PURE__*/function () {
122
122
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2) {
123
123
  var mediaNodeUpdater, getPos, node, updateAttrs, contextId, shouldNodeBeDeepCopied;
124
- return _regeneratorRuntime.wrap(function _callee$(_context) {
124
+ return _regeneratorRuntime.wrap(function (_context) {
125
125
  while (1) switch (_context.prev = _context.next) {
126
126
  case 0:
127
127
  mediaNodeUpdater = _ref2.mediaNodeUpdater, getPos = _ref2.getPos, node = _ref2.node, updateAttrs = _ref2.updateAttrs;
128
128
  if (!updateAttrs) {
129
- _context.next = 4;
129
+ _context.next = 1;
130
130
  break;
131
131
  }
132
- _context.next = 4;
132
+ _context.next = 1;
133
133
  return mediaNodeUpdater.updateNodeAttrs(getPos);
134
- case 4:
134
+ case 1:
135
135
  contextId = mediaNodeUpdater.getNodeContextId();
136
136
  if (contextId) {
137
- _context.next = 8;
137
+ _context.next = 2;
138
138
  break;
139
139
  }
140
- _context.next = 8;
140
+ _context.next = 2;
141
141
  return mediaNodeUpdater.updateNodeContextId(getPos);
142
- case 8:
143
- _context.next = 10;
142
+ case 2:
143
+ _context.next = 3;
144
144
  return mediaNodeUpdater.shouldNodeBeDeepCopied();
145
- case 10:
145
+ case 3:
146
146
  shouldNodeBeDeepCopied = _context.sent;
147
147
  if (!shouldNodeBeDeepCopied) {
148
- _context.next = 14;
148
+ _context.next = 4;
149
149
  break;
150
150
  }
151
- _context.next = 14;
151
+ _context.next = 4;
152
152
  return mediaNodeUpdater.copyNodeFromPos(getPos, {
153
153
  traceId: node.attrs.__mediaTraceId
154
154
  });
155
- case 14:
155
+ case 4:
156
156
  case "end":
157
157
  return _context.stop();
158
158
  }
@@ -50,56 +50,56 @@ var createMediaNodeUpdater = function createMediaNodeUpdater(props) {
50
50
  */
51
51
  var updateMediaNodeAttributes = /*#__PURE__*/function () {
52
52
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(props, mediaNodeUpdater) {
53
- var addPendingTask, node, contextId, shouldNodeBeDeepCopied, copyNode;
54
- return _regeneratorRuntime.wrap(function _callee$(_context) {
53
+ var addPendingTask, node, contextId, shouldNodeBeDeepCopied, copyNode, _t;
54
+ return _regeneratorRuntime.wrap(function (_context) {
55
55
  while (1) switch (_context.prev = _context.next) {
56
56
  case 0:
57
57
  addPendingTask = props.addPendingTask;
58
58
  node = props.node;
59
59
  if (node) {
60
- _context.next = 4;
60
+ _context.next = 1;
61
61
  break;
62
62
  }
63
63
  return _context.abrupt("return");
64
- case 4:
64
+ case 1:
65
65
  contextId = mediaNodeUpdater.getNodeContextId();
66
66
  if (contextId) {
67
- _context.next = 8;
67
+ _context.next = 2;
68
68
  break;
69
69
  }
70
- _context.next = 8;
70
+ _context.next = 2;
71
71
  return mediaNodeUpdater.updateContextId();
72
- case 8:
73
- _context.next = 10;
72
+ case 2:
73
+ _context.next = 3;
74
74
  return mediaNodeUpdater.shouldNodeBeDeepCopied();
75
- case 10:
75
+ case 3:
76
76
  shouldNodeBeDeepCopied = _context.sent;
77
77
  if (!shouldNodeBeDeepCopied) {
78
- _context.next = 22;
78
+ _context.next = 7;
79
79
  break;
80
80
  }
81
- _context.prev = 12;
81
+ _context.prev = 4;
82
82
  copyNode = mediaNodeUpdater.copyNode({
83
83
  traceId: node.attrs.__mediaTraceId
84
84
  });
85
85
  addPendingTask(copyNode);
86
- _context.next = 17;
86
+ _context.next = 5;
87
87
  return copyNode;
88
- case 17:
89
- _context.next = 22;
88
+ case 5:
89
+ _context.next = 7;
90
90
  break;
91
- case 19:
92
- _context.prev = 19;
93
- _context.t0 = _context["catch"](12);
91
+ case 6:
92
+ _context.prev = 6;
93
+ _t = _context["catch"](4);
94
94
  return _context.abrupt("return");
95
- case 22:
96
- _context.next = 24;
95
+ case 7:
96
+ _context.next = 8;
97
97
  return mediaNodeUpdater.updateMediaSingleFileAttrs();
98
- case 24:
98
+ case 8:
99
99
  case "end":
100
100
  return _context.stop();
101
101
  }
102
- }, _callee, null, [[12, 19]]);
102
+ }, _callee, null, [[4, 6]]);
103
103
  }));
104
104
  return function updateMediaNodeAttributes(_x, _x2) {
105
105
  return _ref.apply(this, arguments);
@@ -137,18 +137,18 @@ export var MediaInline = function MediaInline(props) {
137
137
  var updateViewMediaClientConfig = /*#__PURE__*/function () {
138
138
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(props) {
139
139
  var mediaProvider, _viewMediaClientConfig;
140
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
140
+ return _regeneratorRuntime.wrap(function (_context2) {
141
141
  while (1) switch (_context2.prev = _context2.next) {
142
142
  case 0:
143
- _context2.next = 2;
143
+ _context2.next = 1;
144
144
  return props.mediaProvider;
145
- case 2:
145
+ case 1:
146
146
  mediaProvider = _context2.sent;
147
147
  if (mediaProvider) {
148
148
  _viewMediaClientConfig = mediaProvider.viewMediaClientConfig;
149
149
  setViewMediaClientConfig(_viewMediaClientConfig);
150
150
  }
151
- case 4:
151
+ case 2:
152
152
  case "end":
153
153
  return _context2.stop();
154
154
  }