@atlaskit/editor-plugin-media 12.8.3 → 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.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/nodeviews/mediaGroupNext.js +12 -12
- package/dist/cjs/nodeviews/mediaInline.js +25 -25
- package/dist/cjs/nodeviews/mediaNodeUpdater.js +199 -198
- package/dist/cjs/nodeviews/mediaNodeView/media.js +29 -17
- package/dist/cjs/nodeviews/mediaSingleNext.js +24 -24
- package/dist/cjs/pm-plugins/ai-generating-decoration.js +59 -12
- package/dist/cjs/pm-plugins/commands.js +2 -2
- package/dist/cjs/pm-plugins/main.js +55 -46
- package/dist/cjs/pm-plugins/mediaTaskManager.js +6 -6
- package/dist/cjs/pm-plugins/picker-facade.js +4 -4
- package/dist/cjs/pm-plugins/utils/check-media-type.js +17 -17
- package/dist/cjs/ui/MediaPicker/PickerFacadeProvider.js +21 -21
- package/dist/cjs/ui/ResizableMediaSingle/index.js +18 -18
- package/dist/cjs/ui/toolbar/utils.js +11 -11
- package/dist/es2019/nodeviews/mediaNodeView/media.js +12 -0
- package/dist/es2019/pm-plugins/ai-generating-decoration.js +53 -12
- package/dist/es2019/pm-plugins/commands.js +2 -2
- package/dist/es2019/pm-plugins/main.js +11 -1
- package/dist/esm/nodeviews/mediaGroupNext.js +12 -12
- package/dist/esm/nodeviews/mediaInline.js +25 -25
- package/dist/esm/nodeviews/mediaNodeUpdater.js +199 -198
- package/dist/esm/nodeviews/mediaNodeView/media.js +28 -16
- package/dist/esm/nodeviews/mediaSingleNext.js +23 -23
- package/dist/esm/pm-plugins/ai-generating-decoration.js +59 -12
- package/dist/esm/pm-plugins/commands.js +2 -2
- package/dist/esm/pm-plugins/main.js +54 -45
- package/dist/esm/pm-plugins/mediaTaskManager.js +6 -6
- package/dist/esm/pm-plugins/picker-facade.js +4 -4
- package/dist/esm/pm-plugins/utils/check-media-type.js +17 -17
- package/dist/esm/ui/MediaPicker/PickerFacadeProvider.js +21 -21
- package/dist/esm/ui/ResizableMediaSingle/index.js +18 -18
- package/dist/esm/ui/toolbar/utils.js +11 -11
- package/dist/types/mediaPluginType.d.ts +2 -1
- package/dist/types/nodeviews/mediaNodeView/media.d.ts +1 -0
- package/dist/types/pm-plugins/ai-generating-decoration.d.ts +3 -1
- package/dist/types/pm-plugins/commands.d.ts +2 -1
- package/dist/types/pm-plugins/main.d.ts +1 -0
- package/dist/types/pm-plugins/types.d.ts +1 -0
- package/dist/types-ts4.5/mediaPluginType.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/mediaNodeView/media.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/ai-generating-decoration.d.ts +3 -1
- package/dist/types-ts4.5/pm-plugins/commands.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/types.d.ts +1 -0
- package/package.json +8 -5
|
@@ -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
|
|
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 =
|
|
18
|
+
_context.next = 1;
|
|
19
19
|
break;
|
|
20
20
|
}
|
|
21
21
|
return _context.abrupt("return", 'external');
|
|
22
|
-
case
|
|
22
|
+
case 1:
|
|
23
23
|
if (mediaNode.attrs.id) {
|
|
24
|
-
_context.next =
|
|
24
|
+
_context.next = 2;
|
|
25
25
|
break;
|
|
26
26
|
}
|
|
27
27
|
return _context.abrupt("return");
|
|
28
|
-
case
|
|
29
|
-
_context.prev =
|
|
30
|
-
_context.next =
|
|
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
|
|
34
|
+
case 3:
|
|
35
35
|
fileState = _context.sent;
|
|
36
36
|
if (!(fileState && fileState.status !== 'error')) {
|
|
37
|
-
_context.next =
|
|
37
|
+
_context.next = 4;
|
|
38
38
|
break;
|
|
39
39
|
}
|
|
40
40
|
return _context.abrupt("return", fileState.mediaType);
|
|
41
|
-
case
|
|
42
|
-
_context.next =
|
|
41
|
+
case 4:
|
|
42
|
+
_context.next = 6;
|
|
43
43
|
break;
|
|
44
|
-
case
|
|
45
|
-
_context.prev =
|
|
46
|
-
|
|
47
|
-
case
|
|
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, [[
|
|
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
|
|
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 =
|
|
55
|
+
_context.next = 1;
|
|
56
56
|
return provider;
|
|
57
|
-
case
|
|
57
|
+
case 1:
|
|
58
58
|
mediaProvider = _context.sent;
|
|
59
59
|
if (!(!mediaProvider || !mediaProvider.uploadParams || !insertFile)) {
|
|
60
|
-
_context.next =
|
|
60
|
+
_context.next = 2;
|
|
61
61
|
break;
|
|
62
62
|
}
|
|
63
63
|
return _context.abrupt("return");
|
|
64
|
-
case
|
|
65
|
-
_context.next =
|
|
64
|
+
case 2:
|
|
65
|
+
_context.next = 3;
|
|
66
66
|
return mediaProvider.uploadMediaClientConfig;
|
|
67
|
-
case
|
|
68
|
-
|
|
69
|
-
if (
|
|
70
|
-
_context.next =
|
|
67
|
+
case 3:
|
|
68
|
+
_t = _context.sent;
|
|
69
|
+
if (_t) {
|
|
70
|
+
_context.next = 5;
|
|
71
71
|
break;
|
|
72
72
|
}
|
|
73
|
-
_context.next =
|
|
73
|
+
_context.next = 4;
|
|
74
74
|
return mediaProvider.viewMediaClientConfig;
|
|
75
|
-
case
|
|
76
|
-
|
|
77
|
-
case
|
|
78
|
-
resolvedMediaClientConfig =
|
|
75
|
+
case 4:
|
|
76
|
+
_t = _context.sent;
|
|
77
|
+
case 5:
|
|
78
|
+
resolvedMediaClientConfig = _t;
|
|
79
79
|
if (resolvedMediaClientConfig) {
|
|
80
|
-
_context.next =
|
|
80
|
+
_context.next = 6;
|
|
81
81
|
break;
|
|
82
82
|
}
|
|
83
83
|
return _context.abrupt("return");
|
|
84
|
-
case
|
|
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 =
|
|
90
|
+
_context.next = 7;
|
|
91
91
|
return new _pickerFacade.default('customMediaPicker', pickerFacadeConfig, dummyMediaPickerObject, analyticsName).init();
|
|
92
|
-
case
|
|
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
|
|
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
|
|
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 =
|
|
214
|
+
_context.next = 1;
|
|
215
215
|
break;
|
|
216
216
|
}
|
|
217
|
-
_context.next =
|
|
217
|
+
_context.next = 1;
|
|
218
218
|
return this.checkVideoFile(viewMediaClientConfig);
|
|
219
|
-
case
|
|
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
|
|
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 =
|
|
250
|
+
_context2.next = 1;
|
|
251
251
|
break;
|
|
252
252
|
}
|
|
253
253
|
return _context2.abrupt("return");
|
|
254
|
-
case
|
|
254
|
+
case 1:
|
|
255
255
|
mediaNode = this.props.view.state.doc.nodeAt($pos.pos + 1);
|
|
256
256
|
if (!mediaNode) {
|
|
257
|
-
_context2.next =
|
|
257
|
+
_context2.next = 3;
|
|
258
258
|
break;
|
|
259
259
|
}
|
|
260
|
-
_context2.next =
|
|
260
|
+
_context2.next = 2;
|
|
261
261
|
return (0, _checkMediaType.checkMediaType)(mediaNode, viewMediaClientConfig);
|
|
262
|
-
case
|
|
263
|
-
|
|
264
|
-
_context2.next =
|
|
262
|
+
case 2:
|
|
263
|
+
_t = _context2.sent;
|
|
264
|
+
_context2.next = 4;
|
|
265
265
|
break;
|
|
266
|
-
case
|
|
267
|
-
|
|
268
|
-
case
|
|
269
|
-
mediaType =
|
|
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
|
|
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
|
|
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 =
|
|
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 =
|
|
71
|
+
_context.next = 1;
|
|
72
72
|
return mediaClient.file.getCurrentState(id, {
|
|
73
73
|
collectionName: collection
|
|
74
74
|
});
|
|
75
|
-
case
|
|
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
|
|
79
|
+
case 2:
|
|
80
80
|
return _context.abrupt("return", true);
|
|
81
|
-
case
|
|
82
|
-
_context.prev =
|
|
83
|
-
|
|
81
|
+
case 3:
|
|
82
|
+
_context.prev = 3;
|
|
83
|
+
_t = _context["catch"](0);
|
|
84
84
|
return _context.abrupt("return", false);
|
|
85
|
-
case
|
|
85
|
+
case 4:
|
|
86
86
|
case "end":
|
|
87
87
|
return _context.stop();
|
|
88
88
|
}
|
|
89
|
-
}, _callee, null, [[0,
|
|
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
|
|
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
|
|
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
|
-
|
|
118
|
-
ids
|
|
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:
|
|
132
|
+
decorationSet: newDecoSet
|
|
122
133
|
};
|
|
123
134
|
}
|
|
124
135
|
case 'CLEAR_GENERATING':
|
|
125
136
|
{
|
|
126
|
-
const ids = new
|
|
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:
|
|
150
|
+
decorationSet: newDecoSet
|
|
131
151
|
};
|
|
132
152
|
}
|
|
133
153
|
case 'CLEAR_ALL':
|
|
134
154
|
return {
|
|
135
|
-
generatingMediaIds: new
|
|
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
|
|
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
|
|
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 =
|
|
129
|
+
_context.next = 1;
|
|
130
130
|
break;
|
|
131
131
|
}
|
|
132
|
-
_context.next =
|
|
132
|
+
_context.next = 1;
|
|
133
133
|
return mediaNodeUpdater.updateNodeAttrs(getPos);
|
|
134
|
-
case
|
|
134
|
+
case 1:
|
|
135
135
|
contextId = mediaNodeUpdater.getNodeContextId();
|
|
136
136
|
if (contextId) {
|
|
137
|
-
_context.next =
|
|
137
|
+
_context.next = 2;
|
|
138
138
|
break;
|
|
139
139
|
}
|
|
140
|
-
_context.next =
|
|
140
|
+
_context.next = 2;
|
|
141
141
|
return mediaNodeUpdater.updateNodeContextId(getPos);
|
|
142
|
-
case
|
|
143
|
-
_context.next =
|
|
142
|
+
case 2:
|
|
143
|
+
_context.next = 3;
|
|
144
144
|
return mediaNodeUpdater.shouldNodeBeDeepCopied();
|
|
145
|
-
case
|
|
145
|
+
case 3:
|
|
146
146
|
shouldNodeBeDeepCopied = _context.sent;
|
|
147
147
|
if (!shouldNodeBeDeepCopied) {
|
|
148
|
-
_context.next =
|
|
148
|
+
_context.next = 4;
|
|
149
149
|
break;
|
|
150
150
|
}
|
|
151
|
-
_context.next =
|
|
151
|
+
_context.next = 4;
|
|
152
152
|
return mediaNodeUpdater.copyNodeFromPos(getPos, {
|
|
153
153
|
traceId: node.attrs.__mediaTraceId
|
|
154
154
|
});
|
|
155
|
-
case
|
|
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
|
|
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 =
|
|
60
|
+
_context.next = 1;
|
|
61
61
|
break;
|
|
62
62
|
}
|
|
63
63
|
return _context.abrupt("return");
|
|
64
|
-
case
|
|
64
|
+
case 1:
|
|
65
65
|
contextId = mediaNodeUpdater.getNodeContextId();
|
|
66
66
|
if (contextId) {
|
|
67
|
-
_context.next =
|
|
67
|
+
_context.next = 2;
|
|
68
68
|
break;
|
|
69
69
|
}
|
|
70
|
-
_context.next =
|
|
70
|
+
_context.next = 2;
|
|
71
71
|
return mediaNodeUpdater.updateContextId();
|
|
72
|
-
case
|
|
73
|
-
_context.next =
|
|
72
|
+
case 2:
|
|
73
|
+
_context.next = 3;
|
|
74
74
|
return mediaNodeUpdater.shouldNodeBeDeepCopied();
|
|
75
|
-
case
|
|
75
|
+
case 3:
|
|
76
76
|
shouldNodeBeDeepCopied = _context.sent;
|
|
77
77
|
if (!shouldNodeBeDeepCopied) {
|
|
78
|
-
_context.next =
|
|
78
|
+
_context.next = 7;
|
|
79
79
|
break;
|
|
80
80
|
}
|
|
81
|
-
_context.prev =
|
|
81
|
+
_context.prev = 4;
|
|
82
82
|
copyNode = mediaNodeUpdater.copyNode({
|
|
83
83
|
traceId: node.attrs.__mediaTraceId
|
|
84
84
|
});
|
|
85
85
|
addPendingTask(copyNode);
|
|
86
|
-
_context.next =
|
|
86
|
+
_context.next = 5;
|
|
87
87
|
return copyNode;
|
|
88
|
-
case
|
|
89
|
-
_context.next =
|
|
88
|
+
case 5:
|
|
89
|
+
_context.next = 7;
|
|
90
90
|
break;
|
|
91
|
-
case
|
|
92
|
-
_context.prev =
|
|
93
|
-
|
|
91
|
+
case 6:
|
|
92
|
+
_context.prev = 6;
|
|
93
|
+
_t = _context["catch"](4);
|
|
94
94
|
return _context.abrupt("return");
|
|
95
|
-
case
|
|
96
|
-
_context.next =
|
|
95
|
+
case 7:
|
|
96
|
+
_context.next = 8;
|
|
97
97
|
return mediaNodeUpdater.updateMediaSingleFileAttrs();
|
|
98
|
-
case
|
|
98
|
+
case 8:
|
|
99
99
|
case "end":
|
|
100
100
|
return _context.stop();
|
|
101
101
|
}
|
|
102
|
-
}, _callee, null, [[
|
|
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
|
|
140
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
141
141
|
while (1) switch (_context2.prev = _context2.next) {
|
|
142
142
|
case 0:
|
|
143
|
-
_context2.next =
|
|
143
|
+
_context2.next = 1;
|
|
144
144
|
return props.mediaProvider;
|
|
145
|
-
case
|
|
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
|
|
151
|
+
case 2:
|
|
152
152
|
case "end":
|
|
153
153
|
return _context2.stop();
|
|
154
154
|
}
|