@atlaskit/editor-plugin-media 2.6.7 → 2.7.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 +8 -0
- package/dist/cjs/nodeviews/mediaNodeUpdater.js +24 -18
- package/dist/cjs/nodeviews/mediaSingle.js +1 -1
- package/dist/es2019/nodeviews/mediaNodeUpdater.js +5 -1
- package/dist/es2019/nodeviews/mediaSingle.js +1 -1
- package/dist/esm/nodeviews/mediaNodeUpdater.js +24 -18
- package/dist/esm/nodeviews/mediaSingle.js +1 -1
- package/dist/types/types/index.d.ts +17 -0
- package/dist/types-ts4.5/types/index.d.ts +17 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 2.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#143009](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/143009)
|
|
8
|
+
[`6711c20c022e4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6711c20c022e4) -
|
|
9
|
+
[UX-3339] Adds a configuration for media insert to only allow for external links.
|
|
10
|
+
|
|
3
11
|
## 2.6.7
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -254,41 +254,47 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
254
254
|
})));
|
|
255
255
|
(0, _defineProperty2.default)(this, "uploadExternalMedia", /*#__PURE__*/function () {
|
|
256
256
|
var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(getPos) {
|
|
257
|
-
var node, mediaProvider, uploadMediaClientConfig, mediaClient, collection, uploader, uploadableFileUpfrontIds, dimensions, pos;
|
|
257
|
+
var _this$props, node, mediaOptions, mediaProvider, uploadMediaClientConfig, mediaClient, collection, uploader, uploadableFileUpfrontIds, dimensions, pos;
|
|
258
258
|
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
259
259
|
while (1) switch (_context7.prev = _context7.next) {
|
|
260
260
|
case 0:
|
|
261
|
-
node = _this.props.
|
|
262
|
-
|
|
263
|
-
|
|
261
|
+
_this$props = _this.props, node = _this$props.node, mediaOptions = _this$props.mediaOptions;
|
|
262
|
+
if (!(mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.isExternalMediaUploadDisabled)) {
|
|
263
|
+
_context7.next = 3;
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
return _context7.abrupt("return");
|
|
264
267
|
case 3:
|
|
268
|
+
_context7.next = 5;
|
|
269
|
+
return _this.props.mediaProvider;
|
|
270
|
+
case 5:
|
|
265
271
|
mediaProvider = _context7.sent;
|
|
266
272
|
if (!(node && mediaProvider)) {
|
|
267
|
-
_context7.next =
|
|
273
|
+
_context7.next = 26;
|
|
268
274
|
break;
|
|
269
275
|
}
|
|
270
276
|
uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
|
|
271
277
|
if (!(!uploadMediaClientConfig || !node.attrs.url)) {
|
|
272
|
-
_context7.next =
|
|
278
|
+
_context7.next = 10;
|
|
273
279
|
break;
|
|
274
280
|
}
|
|
275
281
|
return _context7.abrupt("return");
|
|
276
|
-
case
|
|
282
|
+
case 10:
|
|
277
283
|
mediaClient = (0, _mediaClientReact.getMediaClient)(uploadMediaClientConfig);
|
|
278
284
|
collection = mediaProvider.uploadParams && mediaProvider.uploadParams.collection;
|
|
279
|
-
_context7.prev =
|
|
280
|
-
_context7.next =
|
|
285
|
+
_context7.prev = 12;
|
|
286
|
+
_context7.next = 15;
|
|
281
287
|
return mediaClient.file.uploadExternal(node.attrs.url, collection);
|
|
282
|
-
case
|
|
288
|
+
case 15:
|
|
283
289
|
uploader = _context7.sent;
|
|
284
290
|
uploadableFileUpfrontIds = uploader.uploadableFileUpfrontIds, dimensions = uploader.dimensions;
|
|
285
291
|
pos = getPos();
|
|
286
292
|
if (!(typeof pos !== 'number')) {
|
|
287
|
-
_context7.next =
|
|
293
|
+
_context7.next = 20;
|
|
288
294
|
break;
|
|
289
295
|
}
|
|
290
296
|
return _context7.abrupt("return");
|
|
291
|
-
case
|
|
297
|
+
case 20:
|
|
292
298
|
(0, _helpers.replaceExternalMedia)(pos + 1, {
|
|
293
299
|
id: uploadableFileUpfrontIds.id,
|
|
294
300
|
collection: collection,
|
|
@@ -296,11 +302,11 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
296
302
|
width: dimensions.width,
|
|
297
303
|
occurrenceKey: uploadableFileUpfrontIds.occurrenceKey
|
|
298
304
|
})(_this.props.view.state, _this.props.view.dispatch);
|
|
299
|
-
_context7.next =
|
|
305
|
+
_context7.next = 26;
|
|
300
306
|
break;
|
|
301
|
-
case
|
|
302
|
-
_context7.prev =
|
|
303
|
-
_context7.t0 = _context7["catch"](
|
|
307
|
+
case 23:
|
|
308
|
+
_context7.prev = 23;
|
|
309
|
+
_context7.t0 = _context7["catch"](12);
|
|
304
310
|
//keep it as external media
|
|
305
311
|
if (_this.props.dispatchAnalyticsEvent) {
|
|
306
312
|
_this.props.dispatchAnalyticsEvent({
|
|
@@ -309,11 +315,11 @@ var MediaNodeUpdater = exports.MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
309
315
|
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
310
316
|
});
|
|
311
317
|
}
|
|
312
|
-
case
|
|
318
|
+
case 26:
|
|
313
319
|
case "end":
|
|
314
320
|
return _context7.stop();
|
|
315
321
|
}
|
|
316
|
-
}, _callee7, null, [[
|
|
322
|
+
}, _callee7, null, [[12, 23]]);
|
|
317
323
|
}));
|
|
318
324
|
return function (_x3) {
|
|
319
325
|
return _ref8.apply(this, arguments);
|
|
@@ -568,7 +568,7 @@ var MediaSingleNodeWrapper = function MediaSingleNodeWrapper(_ref6) {
|
|
|
568
568
|
return mediaState !== null && mediaState !== void 0 && mediaState.mediaProvider ? Promise.resolve(mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider) : undefined;
|
|
569
569
|
}, [mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider]);
|
|
570
570
|
var isSelectedAndInteracted = (0, _react.useCallback)(function () {
|
|
571
|
-
return Boolean(selected() && hasHadInteraction);
|
|
571
|
+
return Boolean(selected() && hasHadInteraction !== false);
|
|
572
572
|
}, [hasHadInteraction, selected]);
|
|
573
573
|
if ((0, _platformFeatureFlags.fg)('platform_editor_react18_phase2__media_single') || (0, _platformFeatureFlags.fg)('platform_editor_react18_phase2__media_single_jira')) {
|
|
574
574
|
return (0, _react2.jsx)(_mediaSingleNext.MediaSingleNodeNext, {
|
|
@@ -136,8 +136,12 @@ export class MediaNodeUpdater {
|
|
|
136
136
|
});
|
|
137
137
|
_defineProperty(this, "uploadExternalMedia", async getPos => {
|
|
138
138
|
const {
|
|
139
|
-
node
|
|
139
|
+
node,
|
|
140
|
+
mediaOptions
|
|
140
141
|
} = this.props;
|
|
142
|
+
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.isExternalMediaUploadDisabled) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
141
145
|
const mediaProvider = await this.props.mediaProvider;
|
|
142
146
|
if (node && mediaProvider) {
|
|
143
147
|
const uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
|
|
@@ -482,7 +482,7 @@ const MediaSingleNodeWrapper = ({
|
|
|
482
482
|
} = useSharedPluginState(pluginInjectionApi, ['width', 'media', 'annotation', 'editorDisabled', 'editorViewMode']);
|
|
483
483
|
const hasHadInteraction = useSharedPluginStateSelector(pluginInjectionApi, 'interaction.hasHadInteraction');
|
|
484
484
|
const mediaProvider = useMemo(() => mediaState !== null && mediaState !== void 0 && mediaState.mediaProvider ? Promise.resolve(mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider) : undefined, [mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider]);
|
|
485
|
-
const isSelectedAndInteracted = useCallback(() => Boolean(selected() && hasHadInteraction), [hasHadInteraction, selected]);
|
|
485
|
+
const isSelectedAndInteracted = useCallback(() => Boolean(selected() && hasHadInteraction !== false), [hasHadInteraction, selected]);
|
|
486
486
|
if (fg('platform_editor_react18_phase2__media_single') || fg('platform_editor_react18_phase2__media_single_jira')) {
|
|
487
487
|
return jsx(MediaSingleNodeNext, {
|
|
488
488
|
width: (widthState === null || widthState === void 0 ? void 0 : widthState.width) || 0,
|
|
@@ -247,41 +247,47 @@ export var MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
247
247
|
})));
|
|
248
248
|
_defineProperty(this, "uploadExternalMedia", /*#__PURE__*/function () {
|
|
249
249
|
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(getPos) {
|
|
250
|
-
var node, mediaProvider, uploadMediaClientConfig, mediaClient, collection, uploader, uploadableFileUpfrontIds, dimensions, pos;
|
|
250
|
+
var _this$props, node, mediaOptions, mediaProvider, uploadMediaClientConfig, mediaClient, collection, uploader, uploadableFileUpfrontIds, dimensions, pos;
|
|
251
251
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
252
252
|
while (1) switch (_context7.prev = _context7.next) {
|
|
253
253
|
case 0:
|
|
254
|
-
node = _this.props.
|
|
255
|
-
|
|
256
|
-
|
|
254
|
+
_this$props = _this.props, node = _this$props.node, mediaOptions = _this$props.mediaOptions;
|
|
255
|
+
if (!(mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.isExternalMediaUploadDisabled)) {
|
|
256
|
+
_context7.next = 3;
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
return _context7.abrupt("return");
|
|
257
260
|
case 3:
|
|
261
|
+
_context7.next = 5;
|
|
262
|
+
return _this.props.mediaProvider;
|
|
263
|
+
case 5:
|
|
258
264
|
mediaProvider = _context7.sent;
|
|
259
265
|
if (!(node && mediaProvider)) {
|
|
260
|
-
_context7.next =
|
|
266
|
+
_context7.next = 26;
|
|
261
267
|
break;
|
|
262
268
|
}
|
|
263
269
|
uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
|
|
264
270
|
if (!(!uploadMediaClientConfig || !node.attrs.url)) {
|
|
265
|
-
_context7.next =
|
|
271
|
+
_context7.next = 10;
|
|
266
272
|
break;
|
|
267
273
|
}
|
|
268
274
|
return _context7.abrupt("return");
|
|
269
|
-
case
|
|
275
|
+
case 10:
|
|
270
276
|
mediaClient = getMediaClient(uploadMediaClientConfig);
|
|
271
277
|
collection = mediaProvider.uploadParams && mediaProvider.uploadParams.collection;
|
|
272
|
-
_context7.prev =
|
|
273
|
-
_context7.next =
|
|
278
|
+
_context7.prev = 12;
|
|
279
|
+
_context7.next = 15;
|
|
274
280
|
return mediaClient.file.uploadExternal(node.attrs.url, collection);
|
|
275
|
-
case
|
|
281
|
+
case 15:
|
|
276
282
|
uploader = _context7.sent;
|
|
277
283
|
uploadableFileUpfrontIds = uploader.uploadableFileUpfrontIds, dimensions = uploader.dimensions;
|
|
278
284
|
pos = getPos();
|
|
279
285
|
if (!(typeof pos !== 'number')) {
|
|
280
|
-
_context7.next =
|
|
286
|
+
_context7.next = 20;
|
|
281
287
|
break;
|
|
282
288
|
}
|
|
283
289
|
return _context7.abrupt("return");
|
|
284
|
-
case
|
|
290
|
+
case 20:
|
|
285
291
|
replaceExternalMedia(pos + 1, {
|
|
286
292
|
id: uploadableFileUpfrontIds.id,
|
|
287
293
|
collection: collection,
|
|
@@ -289,11 +295,11 @@ export var MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
289
295
|
width: dimensions.width,
|
|
290
296
|
occurrenceKey: uploadableFileUpfrontIds.occurrenceKey
|
|
291
297
|
})(_this.props.view.state, _this.props.view.dispatch);
|
|
292
|
-
_context7.next =
|
|
298
|
+
_context7.next = 26;
|
|
293
299
|
break;
|
|
294
|
-
case
|
|
295
|
-
_context7.prev =
|
|
296
|
-
_context7.t0 = _context7["catch"](
|
|
300
|
+
case 23:
|
|
301
|
+
_context7.prev = 23;
|
|
302
|
+
_context7.t0 = _context7["catch"](12);
|
|
297
303
|
//keep it as external media
|
|
298
304
|
if (_this.props.dispatchAnalyticsEvent) {
|
|
299
305
|
_this.props.dispatchAnalyticsEvent({
|
|
@@ -302,11 +308,11 @@ export var MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
302
308
|
eventType: EVENT_TYPE.OPERATIONAL
|
|
303
309
|
});
|
|
304
310
|
}
|
|
305
|
-
case
|
|
311
|
+
case 26:
|
|
306
312
|
case "end":
|
|
307
313
|
return _context7.stop();
|
|
308
314
|
}
|
|
309
|
-
}, _callee7, null, [[
|
|
315
|
+
}, _callee7, null, [[12, 23]]);
|
|
310
316
|
}));
|
|
311
317
|
return function (_x3) {
|
|
312
318
|
return _ref8.apply(this, arguments);
|
|
@@ -563,7 +563,7 @@ var MediaSingleNodeWrapper = function MediaSingleNodeWrapper(_ref6) {
|
|
|
563
563
|
return mediaState !== null && mediaState !== void 0 && mediaState.mediaProvider ? Promise.resolve(mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider) : undefined;
|
|
564
564
|
}, [mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider]);
|
|
565
565
|
var isSelectedAndInteracted = useCallback(function () {
|
|
566
|
-
return Boolean(selected() && hasHadInteraction);
|
|
566
|
+
return Boolean(selected() && hasHadInteraction !== false);
|
|
567
567
|
}, [hasHadInteraction, selected]);
|
|
568
568
|
if (fg('platform_editor_react18_phase2__media_single') || fg('platform_editor_react18_phase2__media_single_jira')) {
|
|
569
569
|
return jsx(MediaSingleNodeNext, {
|
|
@@ -57,6 +57,23 @@ export interface MediaPluginOptions {
|
|
|
57
57
|
forceHandlePositioning?: HandlePositioning;
|
|
58
58
|
mediaShallowCopyScope?: MediaCopyScope;
|
|
59
59
|
allowPixelResizing?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Enabling this will prevent this plugin from automatically trying to upload external images to the Media service.
|
|
62
|
+
* This can be used in conjunction with the `isOnlyExternalLinks` config for `media-insert-plugin` to limit images
|
|
63
|
+
* to external URLs in the UI as well.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* createDefaultPreset({ featureFlags: {}, paste: {} })
|
|
68
|
+
* .add(listPlugin)
|
|
69
|
+
* .add(gridPlugin)
|
|
70
|
+
* .add([mediaPlugin, { provider, allowMediaSingle: true, isExternalMediaUploadDisabled: true }])
|
|
71
|
+
* .add(insertBlockPlugin)
|
|
72
|
+
* .add(contentInsertionPlugin)
|
|
73
|
+
* .add([mediaInsertPlugin, { isOnlyExternalLinks: true }])
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
isExternalMediaUploadDisabled?: boolean;
|
|
60
77
|
}
|
|
61
78
|
/**
|
|
62
79
|
* @private
|
|
@@ -57,6 +57,23 @@ export interface MediaPluginOptions {
|
|
|
57
57
|
forceHandlePositioning?: HandlePositioning;
|
|
58
58
|
mediaShallowCopyScope?: MediaCopyScope;
|
|
59
59
|
allowPixelResizing?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Enabling this will prevent this plugin from automatically trying to upload external images to the Media service.
|
|
62
|
+
* This can be used in conjunction with the `isOnlyExternalLinks` config for `media-insert-plugin` to limit images
|
|
63
|
+
* to external URLs in the UI as well.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* createDefaultPreset({ featureFlags: {}, paste: {} })
|
|
68
|
+
* .add(listPlugin)
|
|
69
|
+
* .add(gridPlugin)
|
|
70
|
+
* .add([mediaPlugin, { provider, allowMediaSingle: true, isExternalMediaUploadDisabled: true }])
|
|
71
|
+
* .add(insertBlockPlugin)
|
|
72
|
+
* .add(contentInsertionPlugin)
|
|
73
|
+
* .add([mediaInsertPlugin, { isOnlyExternalLinks: true }])
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
isExternalMediaUploadDisabled?: boolean;
|
|
60
77
|
}
|
|
61
78
|
/**
|
|
62
79
|
* @private
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@atlaskit/analytics-namespaced-context": "^7.0.0",
|
|
39
39
|
"@atlaskit/analytics-next": "^11.0.0",
|
|
40
40
|
"@atlaskit/button": "^23.0.0",
|
|
41
|
-
"@atlaskit/editor-common": "^103.
|
|
41
|
+
"@atlaskit/editor-common": "^103.19.0",
|
|
42
42
|
"@atlaskit/editor-palette": "^2.1.0",
|
|
43
43
|
"@atlaskit/editor-plugin-analytics": "^2.2.0",
|
|
44
44
|
"@atlaskit/editor-plugin-annotation": "^2.7.0",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@atlaskit/primitives": "^14.4.0",
|
|
71
71
|
"@atlaskit/textfield": "^8.0.0",
|
|
72
72
|
"@atlaskit/theme": "^18.0.0",
|
|
73
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
73
|
+
"@atlaskit/tmp-editor-statsig": "^4.15.0",
|
|
74
74
|
"@atlaskit/tokens": "^4.8.0",
|
|
75
75
|
"@atlaskit/tooltip": "^20.0.0",
|
|
76
76
|
"@babel/runtime": "^7.0.0",
|