@atlaskit/editor-plugin-media 15.0.4 → 16.0.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 CHANGED
@@ -1,5 +1,29 @@
1
1
  # @atlaskit/editor-plugin-media
2
2
 
3
+ ## 16.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 15.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`8043a37357f34`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8043a37357f34) -
14
+ Added an `isCWR` prop to the media `Card`/`FileCard`. When set, the AI-generating loading state
15
+ renders an opaque `elevation.surface.sunken` overlay (instead of the translucent blanket) so the
16
+ generic media type icon isn't shown while a create-with-Rovo infographic streams in. Behaviour is
17
+ gated by the `aifc_page_create_with_rovo_include_infographics` experiment.
18
+
19
+ ```tsx
20
+ <FileCard identifier={identifier} isAIGenerating isCWR />
21
+ ```
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies
26
+
3
27
  ## 15.0.4
4
28
 
5
29
  ### Patch Changes
@@ -166,7 +166,8 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
166
166
  onExternalImageLoaded: _this.onExternalImageLoaded,
167
167
  isViewOnly: ((_this$reactComponentP = _this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.editorViewMode) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.sharedState.currentState()) === null || _this$reactComponentP === void 0 ? void 0 : _this$reactComponentP.mode) === 'view',
168
168
  pluginInjectionApi: _this.reactComponentProps.pluginInjectionApi,
169
- isAIGenerating: _this.isAIGenerating
169
+ isAIGenerating: _this.isAIGenerating,
170
+ isCwrAIGenerating: _this.aiGeneratingSource === 'cwr'
170
171
  });
171
172
  };
172
173
  });
@@ -254,9 +255,11 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
254
255
  this.isSelected = hasMediaNodeSelectedDecoration;
255
256
  return true;
256
257
  }
257
- var aiGenerating = (0, _aiGeneratingDecoration.hasAIGeneratingDecoration)(decorations);
258
- if (this.isAIGenerating !== aiGenerating) {
258
+ var aiGeneratingSource = (0, _aiGeneratingDecoration.getAIGeneratingDecorationSource)(decorations);
259
+ var aiGenerating = aiGeneratingSource !== undefined;
260
+ if (this.isAIGenerating !== aiGenerating || this.aiGeneratingSource !== aiGeneratingSource) {
259
261
  this.isAIGenerating = aiGenerating;
262
+ this.aiGeneratingSource = aiGeneratingSource;
260
263
  return true;
261
264
  }
262
265
  if (this.node.attrs !== nextNode.attrs) {
@@ -191,7 +191,7 @@ var MediaNode = exports.MediaNode = /*#__PURE__*/function (_Component) {
191
191
  value: function shouldComponentUpdate(nextProps, nextState) {
192
192
  var hasNewViewMediaClientConfig = !this.state.viewMediaClientConfig && nextState.viewMediaClientConfig;
193
193
  var hasNewViewAndUploadMediaClientConfig = !this.state.viewAndUploadMediaClientConfig && nextState.viewAndUploadMediaClientConfig;
194
- if (this.props.selected !== nextProps.selected || this.props.node.attrs.id !== nextProps.node.attrs.id || this.props.node.attrs.collection !== nextProps.node.attrs.collection || this.props.isAIGenerating !== nextProps.isAIGenerating || this.props.maxDimensions.height !== nextProps.maxDimensions.height || this.props.maxDimensions.width !== nextProps.maxDimensions.width || this.props.contextIdentifierProvider !== nextProps.contextIdentifierProvider || this.props.isLoading !== nextProps.isLoading || this.props.isViewOnly !== nextProps.isViewOnly || this.props.mediaProvider !== nextProps.mediaProvider || this.props.syncProvider !== nextProps.syncProvider || hasNewViewMediaClientConfig || hasNewViewAndUploadMediaClientConfig) {
194
+ if (this.props.selected !== nextProps.selected || this.props.node.attrs.id !== nextProps.node.attrs.id || this.props.node.attrs.collection !== nextProps.node.attrs.collection || this.props.isAIGenerating !== nextProps.isAIGenerating || this.props.isCwrAIGenerating !== nextProps.isCwrAIGenerating || this.props.maxDimensions.height !== nextProps.maxDimensions.height || this.props.maxDimensions.width !== nextProps.maxDimensions.width || this.props.contextIdentifierProvider !== nextProps.contextIdentifierProvider || this.props.isLoading !== nextProps.isLoading || this.props.isViewOnly !== nextProps.isViewOnly || this.props.mediaProvider !== nextProps.mediaProvider || this.props.syncProvider !== nextProps.syncProvider || hasNewViewMediaClientConfig || hasNewViewAndUploadMediaClientConfig) {
195
195
  return true;
196
196
  }
197
197
  return false;
@@ -382,6 +382,11 @@ var MediaNode = exports.MediaNode = /*#__PURE__*/function (_Component) {
382
382
  }
383
383
  };
384
384
  var ssr = process.env.REACT_SSR ? 'server' : 'client';
385
+
386
+ // CWR (create-with-Rovo) infographics get a distinct loading treatment so the
387
+ // generic media type icon isn't shown while the image streams in. Gated on the
388
+ // existing infographics experiment.
389
+ var isCWR = !!this.props.isCwrAIGenerating && (0, _expValEquals.expValEquals)('aifc_page_create_with_rovo_include_infographics', 'isEnabled', true);
385
390
  return /*#__PURE__*/_react.default.createElement(_styles.MediaCardWrapper, {
386
391
  dimensions: originalDimensions,
387
392
  onContextMenu: this.selectMediaSingle,
@@ -416,6 +421,7 @@ var MediaNode = exports.MediaNode = /*#__PURE__*/function (_Component) {
416
421
  ssr: ssr,
417
422
  mediaSettings: this.getMediaSettings(viewAndUploadMediaClientConfig, this.props.isViewOnly),
418
423
  isAIGenerating: !!this.props.isAIGenerating,
424
+ isCWR: isCWR,
419
425
  onPreviewRender: this.onPreviewRender,
420
426
  fallbackMediaNameFetcher: mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.fallbackMediaNameFetcher,
421
427
  onError: (0, _expValEquals.expValEquals)('platform_editor_media_error_analytics', 'isEnabled', true) ? this.onError : undefined
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.aiGeneratingDecorationPluginKey = void 0;
8
8
  exports.clearAIGeneratingMeta = clearAIGeneratingMeta;
9
9
  exports.createAIGeneratingDecorationPlugin = createAIGeneratingDecorationPlugin;
10
+ exports.getAIGeneratingDecorationSource = getAIGeneratingDecorationSource;
10
11
  exports.hasAIGeneratingDecoration = hasAIGeneratingDecoration;
11
12
  exports.setAIGeneratingMeta = setAIGeneratingMeta;
12
13
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
@@ -58,13 +59,14 @@ function buildDecorationSet(doc, targetIds) {
58
59
  return;
59
60
  }
60
61
  var wrapperLocalId = parent === null || parent === void 0 || (_parent$attrs = parent.attrs) === null || _parent$attrs === void 0 ? void 0 : _parent$attrs.localId;
61
- var matches = wrapperLocalId && targetIds.has(wrapperLocalId) || node.attrs.localId && targetIds.has(node.attrs.localId) || targetIds.has(node.attrs.id);
62
- if (matches) {
62
+ var source = wrapperLocalId && targetIds.get(wrapperLocalId) || node.attrs.localId && targetIds.get(node.attrs.localId) || targetIds.get(node.attrs.id);
63
+ if (source) {
63
64
  decorations.push(_view.Decoration.node(pos, pos + node.nodeSize, {},
64
65
  // no DOM attrs needed — the NodeView reads the decoration spec
65
66
  {
66
67
  type: AI_GENERATING_DECORATION_TYPE,
67
- mediaId: node.attrs.id
68
+ mediaId: node.attrs.id,
69
+ source: source
68
70
  }));
69
71
  }
70
72
  });
@@ -84,6 +86,18 @@ function hasAIGeneratingDecoration(decorations) {
84
86
  });
85
87
  }
86
88
 
89
+ /**
90
+ * Returns the `source` of the AI-generating decoration present on the given
91
+ * decorations array, or `undefined` if there is none. Lets a NodeView vary its
92
+ * rendering by which flow (e.g. `'cwr'`) triggered the generating state.
93
+ */
94
+ function getAIGeneratingDecorationSource(decorations) {
95
+ var _decorations$find;
96
+ return (_decorations$find = decorations.find(function (d) {
97
+ return d.spec.type === AI_GENERATING_DECORATION_TYPE;
98
+ })) === null || _decorations$find === void 0 ? void 0 : _decorations$find.spec.source;
99
+ }
100
+
87
101
  /**
88
102
  * Dispatch a transaction that sets the AI-generating decoration on a media
89
103
  * node identified by `mediaId`.
@@ -8,7 +8,7 @@ import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-
8
8
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
9
9
  import { akEditorFullWidthLayoutWidth, akEditorDefaultLayoutWidth, akEditorCalculatedWideLayoutWidth } from '@atlaskit/editor-shared-styles';
10
10
  import { getAttrsFromUrl } from '@atlaskit/media-client';
11
- import { hasAIGeneratingDecoration } from '../../pm-plugins/ai-generating-decoration';
11
+ import { getAIGeneratingDecorationSource } from '../../pm-plugins/ai-generating-decoration';
12
12
  import { updateCurrentMediaNodeAttrs } from '../../pm-plugins/commands/helpers';
13
13
  import { isMediaBlobUrlFromAttrs } from '../../pm-plugins/utils/media-common';
14
14
  import { MediaSSRReactContextsProvider } from '../../ui/MediaSSRReactContextsProvider';
@@ -155,7 +155,8 @@ class MediaNodeView extends SelectionBasedNodeView {
155
155
  onExternalImageLoaded: this.onExternalImageLoaded,
156
156
  isViewOnly: ((_this$reactComponentP = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP === void 0 ? void 0 : (_this$reactComponentP2 = _this$reactComponentP.editorViewMode) === null || _this$reactComponentP2 === void 0 ? void 0 : (_this$reactComponentP3 = _this$reactComponentP2.sharedState.currentState()) === null || _this$reactComponentP3 === void 0 ? void 0 : _this$reactComponentP3.mode) === 'view',
157
157
  pluginInjectionApi: this.reactComponentProps.pluginInjectionApi,
158
- isAIGenerating: this.isAIGenerating
158
+ isAIGenerating: this.isAIGenerating,
159
+ isCwrAIGenerating: this.aiGeneratingSource === 'cwr'
159
160
  });
160
161
  };
161
162
  });
@@ -234,9 +235,11 @@ class MediaNodeView extends SelectionBasedNodeView {
234
235
  this.isSelected = hasMediaNodeSelectedDecoration;
235
236
  return true;
236
237
  }
237
- const aiGenerating = hasAIGeneratingDecoration(decorations);
238
- if (this.isAIGenerating !== aiGenerating) {
238
+ const aiGeneratingSource = getAIGeneratingDecorationSource(decorations);
239
+ const aiGenerating = aiGeneratingSource !== undefined;
240
+ if (this.isAIGenerating !== aiGenerating || this.aiGeneratingSource !== aiGeneratingSource) {
239
241
  this.isAIGenerating = aiGenerating;
242
+ this.aiGeneratingSource = aiGeneratingSource;
240
243
  return true;
241
244
  }
242
245
  if (this.node.attrs !== nextNode.attrs) {
@@ -158,7 +158,7 @@ export class MediaNode extends Component {
158
158
  shouldComponentUpdate(nextProps, nextState) {
159
159
  const hasNewViewMediaClientConfig = !this.state.viewMediaClientConfig && nextState.viewMediaClientConfig;
160
160
  const hasNewViewAndUploadMediaClientConfig = !this.state.viewAndUploadMediaClientConfig && nextState.viewAndUploadMediaClientConfig;
161
- if (this.props.selected !== nextProps.selected || this.props.node.attrs.id !== nextProps.node.attrs.id || this.props.node.attrs.collection !== nextProps.node.attrs.collection || this.props.isAIGenerating !== nextProps.isAIGenerating || this.props.maxDimensions.height !== nextProps.maxDimensions.height || this.props.maxDimensions.width !== nextProps.maxDimensions.width || this.props.contextIdentifierProvider !== nextProps.contextIdentifierProvider || this.props.isLoading !== nextProps.isLoading || this.props.isViewOnly !== nextProps.isViewOnly || this.props.mediaProvider !== nextProps.mediaProvider || this.props.syncProvider !== nextProps.syncProvider || hasNewViewMediaClientConfig || hasNewViewAndUploadMediaClientConfig) {
161
+ if (this.props.selected !== nextProps.selected || this.props.node.attrs.id !== nextProps.node.attrs.id || this.props.node.attrs.collection !== nextProps.node.attrs.collection || this.props.isAIGenerating !== nextProps.isAIGenerating || this.props.isCwrAIGenerating !== nextProps.isCwrAIGenerating || this.props.maxDimensions.height !== nextProps.maxDimensions.height || this.props.maxDimensions.width !== nextProps.maxDimensions.width || this.props.contextIdentifierProvider !== nextProps.contextIdentifierProvider || this.props.isLoading !== nextProps.isLoading || this.props.isViewOnly !== nextProps.isViewOnly || this.props.mediaProvider !== nextProps.mediaProvider || this.props.syncProvider !== nextProps.syncProvider || hasNewViewMediaClientConfig || hasNewViewAndUploadMediaClientConfig) {
162
162
  return true;
163
163
  }
164
164
  return false;
@@ -324,6 +324,11 @@ export class MediaNode extends Component {
324
324
  authProvider: () => ({})
325
325
  };
326
326
  const ssr = process.env.REACT_SSR ? 'server' : 'client';
327
+
328
+ // CWR (create-with-Rovo) infographics get a distinct loading treatment so the
329
+ // generic media type icon isn't shown while the image streams in. Gated on the
330
+ // existing infographics experiment.
331
+ const isCWR = !!this.props.isCwrAIGenerating && expValEquals('aifc_page_create_with_rovo_include_infographics', 'isEnabled', true);
327
332
  return /*#__PURE__*/React.createElement(MediaCardWrapper, {
328
333
  dimensions: originalDimensions,
329
334
  onContextMenu: this.selectMediaSingle,
@@ -360,6 +365,7 @@ export class MediaNode extends Component {
360
365
  ssr: ssr,
361
366
  mediaSettings: this.getMediaSettings(viewAndUploadMediaClientConfig, this.props.isViewOnly),
362
367
  isAIGenerating: !!this.props.isAIGenerating,
368
+ isCWR: isCWR,
363
369
  onPreviewRender: this.onPreviewRender,
364
370
  fallbackMediaNameFetcher: mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.fallbackMediaNameFetcher,
365
371
  onError: expValEquals('platform_editor_media_error_analytics', 'isEnabled', true) ? this.onError : undefined
@@ -44,13 +44,14 @@ function buildDecorationSet(doc, targetIds) {
44
44
  return;
45
45
  }
46
46
  const wrapperLocalId = parent === null || parent === void 0 ? void 0 : (_parent$attrs = parent.attrs) === null || _parent$attrs === void 0 ? void 0 : _parent$attrs.localId;
47
- const matches = wrapperLocalId && targetIds.has(wrapperLocalId) || node.attrs.localId && targetIds.has(node.attrs.localId) || targetIds.has(node.attrs.id);
48
- if (matches) {
47
+ const source = wrapperLocalId && targetIds.get(wrapperLocalId) || node.attrs.localId && targetIds.get(node.attrs.localId) || targetIds.get(node.attrs.id);
48
+ if (source) {
49
49
  decorations.push(Decoration.node(pos, pos + node.nodeSize, {},
50
50
  // no DOM attrs needed — the NodeView reads the decoration spec
51
51
  {
52
52
  type: AI_GENERATING_DECORATION_TYPE,
53
- mediaId: node.attrs.id
53
+ mediaId: node.attrs.id,
54
+ source
54
55
  }));
55
56
  }
56
57
  });
@@ -68,6 +69,16 @@ export function hasAIGeneratingDecoration(decorations) {
68
69
  return decorations.some(d => d.spec.type === AI_GENERATING_DECORATION_TYPE);
69
70
  }
70
71
 
72
+ /**
73
+ * Returns the `source` of the AI-generating decoration present on the given
74
+ * decorations array, or `undefined` if there is none. Lets a NodeView vary its
75
+ * rendering by which flow (e.g. `'cwr'`) triggered the generating state.
76
+ */
77
+ export function getAIGeneratingDecorationSource(decorations) {
78
+ var _decorations$find;
79
+ return (_decorations$find = decorations.find(d => d.spec.type === AI_GENERATING_DECORATION_TYPE)) === null || _decorations$find === void 0 ? void 0 : _decorations$find.spec.source;
80
+ }
81
+
71
82
  /**
72
83
  * Dispatch a transaction that sets the AI-generating decoration on a media
73
84
  * node identified by `mediaId`.
@@ -21,7 +21,7 @@ import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-
21
21
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
22
22
  import { akEditorFullWidthLayoutWidth, akEditorDefaultLayoutWidth, akEditorCalculatedWideLayoutWidth } from '@atlaskit/editor-shared-styles';
23
23
  import { getAttrsFromUrl } from '@atlaskit/media-client';
24
- import { hasAIGeneratingDecoration } from '../../pm-plugins/ai-generating-decoration';
24
+ import { getAIGeneratingDecorationSource } from '../../pm-plugins/ai-generating-decoration';
25
25
  import { updateCurrentMediaNodeAttrs } from '../../pm-plugins/commands/helpers';
26
26
  import { isMediaBlobUrlFromAttrs } from '../../pm-plugins/utils/media-common';
27
27
  import { MediaSSRReactContextsProvider } from '../../ui/MediaSSRReactContextsProvider';
@@ -160,7 +160,8 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
160
160
  onExternalImageLoaded: _this.onExternalImageLoaded,
161
161
  isViewOnly: ((_this$reactComponentP = _this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.editorViewMode) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.sharedState.currentState()) === null || _this$reactComponentP === void 0 ? void 0 : _this$reactComponentP.mode) === 'view',
162
162
  pluginInjectionApi: _this.reactComponentProps.pluginInjectionApi,
163
- isAIGenerating: _this.isAIGenerating
163
+ isAIGenerating: _this.isAIGenerating,
164
+ isCwrAIGenerating: _this.aiGeneratingSource === 'cwr'
164
165
  });
165
166
  };
166
167
  });
@@ -248,9 +249,11 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
248
249
  this.isSelected = hasMediaNodeSelectedDecoration;
249
250
  return true;
250
251
  }
251
- var aiGenerating = hasAIGeneratingDecoration(decorations);
252
- if (this.isAIGenerating !== aiGenerating) {
252
+ var aiGeneratingSource = getAIGeneratingDecorationSource(decorations);
253
+ var aiGenerating = aiGeneratingSource !== undefined;
254
+ if (this.isAIGenerating !== aiGenerating || this.aiGeneratingSource !== aiGeneratingSource) {
253
255
  this.isAIGenerating = aiGenerating;
256
+ this.aiGeneratingSource = aiGeneratingSource;
254
257
  return true;
255
258
  }
256
259
  if (this.node.attrs !== nextNode.attrs) {
@@ -183,7 +183,7 @@ export var MediaNode = /*#__PURE__*/function (_Component) {
183
183
  value: function shouldComponentUpdate(nextProps, nextState) {
184
184
  var hasNewViewMediaClientConfig = !this.state.viewMediaClientConfig && nextState.viewMediaClientConfig;
185
185
  var hasNewViewAndUploadMediaClientConfig = !this.state.viewAndUploadMediaClientConfig && nextState.viewAndUploadMediaClientConfig;
186
- if (this.props.selected !== nextProps.selected || this.props.node.attrs.id !== nextProps.node.attrs.id || this.props.node.attrs.collection !== nextProps.node.attrs.collection || this.props.isAIGenerating !== nextProps.isAIGenerating || this.props.maxDimensions.height !== nextProps.maxDimensions.height || this.props.maxDimensions.width !== nextProps.maxDimensions.width || this.props.contextIdentifierProvider !== nextProps.contextIdentifierProvider || this.props.isLoading !== nextProps.isLoading || this.props.isViewOnly !== nextProps.isViewOnly || this.props.mediaProvider !== nextProps.mediaProvider || this.props.syncProvider !== nextProps.syncProvider || hasNewViewMediaClientConfig || hasNewViewAndUploadMediaClientConfig) {
186
+ if (this.props.selected !== nextProps.selected || this.props.node.attrs.id !== nextProps.node.attrs.id || this.props.node.attrs.collection !== nextProps.node.attrs.collection || this.props.isAIGenerating !== nextProps.isAIGenerating || this.props.isCwrAIGenerating !== nextProps.isCwrAIGenerating || this.props.maxDimensions.height !== nextProps.maxDimensions.height || this.props.maxDimensions.width !== nextProps.maxDimensions.width || this.props.contextIdentifierProvider !== nextProps.contextIdentifierProvider || this.props.isLoading !== nextProps.isLoading || this.props.isViewOnly !== nextProps.isViewOnly || this.props.mediaProvider !== nextProps.mediaProvider || this.props.syncProvider !== nextProps.syncProvider || hasNewViewMediaClientConfig || hasNewViewAndUploadMediaClientConfig) {
187
187
  return true;
188
188
  }
189
189
  return false;
@@ -374,6 +374,11 @@ export var MediaNode = /*#__PURE__*/function (_Component) {
374
374
  }
375
375
  };
376
376
  var ssr = process.env.REACT_SSR ? 'server' : 'client';
377
+
378
+ // CWR (create-with-Rovo) infographics get a distinct loading treatment so the
379
+ // generic media type icon isn't shown while the image streams in. Gated on the
380
+ // existing infographics experiment.
381
+ var isCWR = !!this.props.isCwrAIGenerating && expValEquals('aifc_page_create_with_rovo_include_infographics', 'isEnabled', true);
377
382
  return /*#__PURE__*/React.createElement(MediaCardWrapper, {
378
383
  dimensions: originalDimensions,
379
384
  onContextMenu: this.selectMediaSingle,
@@ -408,6 +413,7 @@ export var MediaNode = /*#__PURE__*/function (_Component) {
408
413
  ssr: ssr,
409
414
  mediaSettings: this.getMediaSettings(viewAndUploadMediaClientConfig, this.props.isViewOnly),
410
415
  isAIGenerating: !!this.props.isAIGenerating,
416
+ isCWR: isCWR,
411
417
  onPreviewRender: this.onPreviewRender,
412
418
  fallbackMediaNameFetcher: mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.fallbackMediaNameFetcher,
413
419
  onError: expValEquals('platform_editor_media_error_analytics', 'isEnabled', true) ? this.onError : undefined
@@ -48,13 +48,14 @@ function buildDecorationSet(doc, targetIds) {
48
48
  return;
49
49
  }
50
50
  var wrapperLocalId = parent === null || parent === void 0 || (_parent$attrs = parent.attrs) === null || _parent$attrs === void 0 ? void 0 : _parent$attrs.localId;
51
- var matches = wrapperLocalId && targetIds.has(wrapperLocalId) || node.attrs.localId && targetIds.has(node.attrs.localId) || targetIds.has(node.attrs.id);
52
- if (matches) {
51
+ var source = wrapperLocalId && targetIds.get(wrapperLocalId) || node.attrs.localId && targetIds.get(node.attrs.localId) || targetIds.get(node.attrs.id);
52
+ if (source) {
53
53
  decorations.push(Decoration.node(pos, pos + node.nodeSize, {},
54
54
  // no DOM attrs needed — the NodeView reads the decoration spec
55
55
  {
56
56
  type: AI_GENERATING_DECORATION_TYPE,
57
- mediaId: node.attrs.id
57
+ mediaId: node.attrs.id,
58
+ source: source
58
59
  }));
59
60
  }
60
61
  });
@@ -74,6 +75,18 @@ export function hasAIGeneratingDecoration(decorations) {
74
75
  });
75
76
  }
76
77
 
78
+ /**
79
+ * Returns the `source` of the AI-generating decoration present on the given
80
+ * decorations array, or `undefined` if there is none. Lets a NodeView vary its
81
+ * rendering by which flow (e.g. `'cwr'`) triggered the generating state.
82
+ */
83
+ export function getAIGeneratingDecorationSource(decorations) {
84
+ var _decorations$find;
85
+ return (_decorations$find = decorations.find(function (d) {
86
+ return d.spec.type === AI_GENERATING_DECORATION_TYPE;
87
+ })) === null || _decorations$find === void 0 ? void 0 : _decorations$find.spec.source;
88
+ }
89
+
77
90
  /**
78
91
  * Dispatch a transaction that sets the AI-generating decoration on a media
79
92
  * node identified by `mediaId`.
@@ -19,6 +19,7 @@ interface MediaNodeWithPluginStateComponentProps {
19
19
  declare class MediaNodeView extends SelectionBasedNodeView<MediaNodeViewProps> {
20
20
  private isSelected;
21
21
  private isAIGenerating;
22
+ private aiGeneratingSource;
22
23
  private hasBeenResized;
23
24
  private resizeListenerBinding?;
24
25
  getMediaSingleNode(getPos: getPosHandlerNode): PMNode | null;
@@ -16,6 +16,7 @@ export interface MediaNodeProps extends ReactNodeProps, ImageLoaderProps {
16
16
  contextIdentifierProvider?: Promise<ContextIdentifierProvider>;
17
17
  getPos: ProsemirrorGetPosHandler;
18
18
  isAIGenerating?: boolean;
19
+ isCwrAIGenerating?: boolean;
19
20
  isLoading?: boolean;
20
21
  isMediaSingle?: boolean;
21
22
  isViewOnly?: boolean;
@@ -28,6 +28,12 @@ export type AIGeneratingAction = {
28
28
  * to determine whether to render the AI border.
29
29
  */
30
30
  export declare function hasAIGeneratingDecoration(decorations: readonly Decoration[]): boolean;
31
+ /**
32
+ * Returns the `source` of the AI-generating decoration present on the given
33
+ * decorations array, or `undefined` if there is none. Lets a NodeView vary its
34
+ * rendering by which flow (e.g. `'cwr'`) triggered the generating state.
35
+ */
36
+ export declare function getAIGeneratingDecorationSource(decorations: readonly Decoration[]): AIGeneratingSource | undefined;
31
37
  /**
32
38
  * Dispatch a transaction that sets the AI-generating decoration on a media
33
39
  * node identified by `mediaId`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media",
3
- "version": "15.0.4",
3
+ "version": "16.0.0",
4
4
  "description": "Media plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -26,28 +26,28 @@
26
26
  "@atlaskit/analytics-next": "^12.3.0",
27
27
  "@atlaskit/button": "^25.0.0",
28
28
  "@atlaskit/editor-palette": "^3.4.0",
29
- "@atlaskit/editor-plugin-analytics": "^13.0.0",
30
- "@atlaskit/editor-plugin-annotation": "^13.0.0",
31
- "@atlaskit/editor-plugin-connectivity": "^13.0.0",
32
- "@atlaskit/editor-plugin-decorations": "^13.0.0",
33
- "@atlaskit/editor-plugin-editor-disabled": "^13.0.0",
34
- "@atlaskit/editor-plugin-editor-viewmode": "^15.0.0",
35
- "@atlaskit/editor-plugin-floating-toolbar": "^15.1.0",
36
- "@atlaskit/editor-plugin-focus": "^12.0.0",
37
- "@atlaskit/editor-plugin-grid": "^13.0.0",
38
- "@atlaskit/editor-plugin-guideline": "^13.0.0",
39
- "@atlaskit/editor-plugin-interaction": "^24.0.0",
40
- "@atlaskit/editor-plugin-media-editing": "^7.0.0",
41
- "@atlaskit/editor-plugin-selection": "^13.0.0",
42
- "@atlaskit/editor-plugin-toolbar": "^10.1.0",
43
- "@atlaskit/editor-plugin-width": "^14.0.0",
29
+ "@atlaskit/editor-plugin-analytics": "^14.0.0",
30
+ "@atlaskit/editor-plugin-annotation": "^14.0.0",
31
+ "@atlaskit/editor-plugin-connectivity": "^14.0.0",
32
+ "@atlaskit/editor-plugin-decorations": "^14.0.0",
33
+ "@atlaskit/editor-plugin-editor-disabled": "^14.0.0",
34
+ "@atlaskit/editor-plugin-editor-viewmode": "^16.0.0",
35
+ "@atlaskit/editor-plugin-floating-toolbar": "^16.0.0",
36
+ "@atlaskit/editor-plugin-focus": "^13.0.0",
37
+ "@atlaskit/editor-plugin-grid": "^14.0.0",
38
+ "@atlaskit/editor-plugin-guideline": "^14.0.0",
39
+ "@atlaskit/editor-plugin-interaction": "^25.0.0",
40
+ "@atlaskit/editor-plugin-media-editing": "^8.0.0",
41
+ "@atlaskit/editor-plugin-selection": "^14.0.0",
42
+ "@atlaskit/editor-plugin-toolbar": "^11.0.0",
43
+ "@atlaskit/editor-plugin-width": "^15.0.0",
44
44
  "@atlaskit/editor-prosemirror": "^8.0.0",
45
45
  "@atlaskit/editor-shared-styles": "^4.0.0",
46
46
  "@atlaskit/editor-tables": "^3.0.0",
47
47
  "@atlaskit/form": "^16.1.0",
48
48
  "@atlaskit/icon": "^37.3.0",
49
49
  "@atlaskit/icon-lab": "^7.5.0",
50
- "@atlaskit/media-card": "^81.5.0",
50
+ "@atlaskit/media-card": "^81.6.0",
51
51
  "@atlaskit/media-client": "^37.2.0",
52
52
  "@atlaskit/media-client-react": "^6.1.0",
53
53
  "@atlaskit/media-common": "^14.4.0",
@@ -70,7 +70,7 @@
70
70
  "uuid": "^3.1.0"
71
71
  },
72
72
  "peerDependencies": {
73
- "@atlaskit/editor-common": "^117.4.0",
73
+ "@atlaskit/editor-common": "^118.0.0",
74
74
  "@atlaskit/media-core": "^38.0.0",
75
75
  "react": "^18.2.0 || ^19.2.0",
76
76
  "react-dom": "^18.2.0 || ^19.2.0",