@atlaskit/editor-plugin-media 1.32.1 → 1.33.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 +20 -0
- package/dist/cjs/toolbar/index.js +4 -5
- package/dist/cjs/toolbar/utils.js +5 -2
- package/dist/cjs/ui/MediaViewer/PortalWrapper.js +34 -3
- package/dist/es2019/toolbar/index.js +5 -6
- package/dist/es2019/toolbar/utils.js +4 -1
- package/dist/es2019/ui/MediaViewer/PortalWrapper.js +31 -0
- package/dist/esm/toolbar/index.js +5 -6
- package/dist/esm/toolbar/utils.js +4 -1
- package/dist/esm/ui/MediaViewer/PortalWrapper.js +34 -3
- package/dist/types/toolbar/utils.d.ts +3 -2
- package/dist/types/ui/MediaViewer/PortalWrapper.d.ts +2 -2
- package/dist/types-ts4.5/toolbar/utils.d.ts +3 -2
- package/dist/types-ts4.5/ui/MediaViewer/PortalWrapper.d.ts +2 -2
- package/package.json +6 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 1.33.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#145463](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/145463)
|
|
8
|
+
[`d63935e60e04b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d63935e60e04b) -
|
|
9
|
+
[ux] ED-24924 Fix media preview broken for external images
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 1.32.2
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#144324](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/144324)
|
|
20
|
+
[`28ccc12f4b59f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/28ccc12f4b59f) -
|
|
21
|
+
Cleanup LD FF for Add comment button in the media toolbar
|
|
22
|
+
|
|
3
23
|
## 1.32.1
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -203,7 +203,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
203
203
|
var widthPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width;
|
|
204
204
|
var isChangingLayoutDisabled = false;
|
|
205
205
|
var selectedNode = (0, _utils2.getSelectedMediaSingle)(state);
|
|
206
|
-
if ((0, _platformFeatureFlags.
|
|
206
|
+
if ((0, _platformFeatureFlags.fg)('platform.editor.media.extended-resize-experience')) {
|
|
207
207
|
var _widthPlugin$sharedSt;
|
|
208
208
|
var contentWidth = widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt === void 0 ? void 0 : _widthPlugin$sharedSt.lineLength;
|
|
209
209
|
var selectedNodeMaxWidth = pluginState.currentMaxWidth || contentWidth;
|
|
@@ -290,7 +290,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
290
290
|
// Pixel Entry Toolbar Support
|
|
291
291
|
var selection = state.selection;
|
|
292
292
|
var isWithinTable = (0, _utils.hasParentNodeOfType)([state.schema.nodes.table])(selection);
|
|
293
|
-
if ((0, _platformFeatureFlags.
|
|
293
|
+
if (allowResizing && (!isWithinTable || allowResizingInTables === true) && (0, _platformFeatureFlags.fg)('platform.editor.media.extended-resize-experience')) {
|
|
294
294
|
var selectedMediaSingleNode = (0, _utils2.getSelectedMediaSingle)(state);
|
|
295
295
|
var sizeInput = {
|
|
296
296
|
type: 'custom',
|
|
@@ -388,8 +388,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
388
388
|
type: 'separator'
|
|
389
389
|
});
|
|
390
390
|
}
|
|
391
|
-
if (editorFeatureFlags && editorFeatureFlags.commentsOnMedia && allowCommentsOnMedia
|
|
392
|
-
) {
|
|
391
|
+
if (editorFeatureFlags && editorFeatureFlags.commentsOnMedia && allowCommentsOnMedia) {
|
|
393
392
|
toolbarButtons.push((0, _comments.commentButton)(intl, state, pluginInjectionApi), {
|
|
394
393
|
type: 'separator',
|
|
395
394
|
supportsViewMode: true
|
|
@@ -601,7 +600,7 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
|
|
|
601
600
|
scrollable: true,
|
|
602
601
|
mediaAssistiveMessage: assistiveMessage
|
|
603
602
|
});
|
|
604
|
-
if ((0, _platformFeatureFlags.
|
|
603
|
+
if (allowResizing && (0, _platformFeatureFlags.fg)('platform.editor.media.extended-resize-experience')) {
|
|
605
604
|
return _objectSpread(_objectSpread({}, toolbarConfig), {}, {
|
|
606
605
|
width: mediaPluginState.isResizing ? undefined : (0, _utils2.getMaxToolbarWidth)()
|
|
607
606
|
});
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.removeMediaGroupNode = exports.getSelectedNearestMediaContainerNodeAttrs = exports.getSelectedMediaSingle = exports.getSelectedLayoutIcon = exports.getPixelWidthOfElement = exports.getMaxToolbarWidth = exports.downloadMedia = exports.canShowSwitchButtons = exports.calcNewLayout = void 0;
|
|
7
|
+
exports.removeMediaGroupNode = exports.isExternalMedia = exports.getSelectedNearestMediaContainerNodeAttrs = exports.getSelectedMediaSingle = exports.getSelectedLayoutIcon = exports.getPixelWidthOfElement = exports.getMaxToolbarWidth = exports.downloadMedia = exports.canShowSwitchButtons = exports.calcNewLayout = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
@@ -14,6 +14,9 @@ var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
|
14
14
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
15
15
|
var _mediaClientReact = require("@atlaskit/media-client-react");
|
|
16
16
|
var _mediaSingle2 = require("../utils/media-single");
|
|
17
|
+
var isExternalMedia = exports.isExternalMedia = function isExternalMedia(attrs) {
|
|
18
|
+
return attrs.type === 'external';
|
|
19
|
+
};
|
|
17
20
|
var getSelectedMediaContainerNodeAttrs = function getSelectedMediaContainerNodeAttrs(mediaPluginState) {
|
|
18
21
|
var _mediaPluginState$sel;
|
|
19
22
|
var selectedNode = (_mediaPluginState$sel = mediaPluginState.selectedMediaContainerNode) === null || _mediaPluginState$sel === void 0 ? void 0 : _mediaPluginState$sel.call(mediaPluginState);
|
|
@@ -46,7 +49,7 @@ var downloadMedia = exports.downloadMedia = /*#__PURE__*/function () {
|
|
|
46
49
|
case 0:
|
|
47
50
|
_context.prev = 0;
|
|
48
51
|
selectedNodeAttrs = isViewMode ? getSelectedNearestMediaContainerNodeAttrs(mediaPluginState) : getSelectedMediaContainerNodeAttrs(mediaPluginState);
|
|
49
|
-
if (!(selectedNodeAttrs && mediaPluginState.mediaClientConfig)) {
|
|
52
|
+
if (!(selectedNodeAttrs && mediaPluginState.mediaClientConfig && !isExternalMedia(selectedNodeAttrs))) {
|
|
50
53
|
_context.next = 10;
|
|
51
54
|
break;
|
|
52
55
|
}
|
|
@@ -8,13 +8,44 @@ exports.RenderMediaViewer = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
10
10
|
var _mediaViewer = require("@atlaskit/media-viewer");
|
|
11
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
|
+
var _utils = require("../../toolbar/utils");
|
|
13
|
+
var getIdentifier = function getIdentifier(attrs) {
|
|
14
|
+
if ((0, _utils.isExternalMedia)(attrs)) {
|
|
15
|
+
return {
|
|
16
|
+
mediaItemType: 'external-image',
|
|
17
|
+
dataURI: attrs.url
|
|
18
|
+
};
|
|
19
|
+
} else {
|
|
20
|
+
var id = attrs.id,
|
|
21
|
+
_attrs$collection = attrs.collection,
|
|
22
|
+
collection = _attrs$collection === void 0 ? '' : _attrs$collection;
|
|
23
|
+
return {
|
|
24
|
+
id: id,
|
|
25
|
+
mediaItemType: 'file',
|
|
26
|
+
collectionName: collection
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
};
|
|
11
30
|
var RenderMediaViewer = exports.RenderMediaViewer = function RenderMediaViewer(_ref) {
|
|
12
31
|
var mediaClientConfig = _ref.mediaClientConfig,
|
|
13
32
|
onClose = _ref.onClose,
|
|
14
33
|
selectedNodeAttrs = _ref.selectedNodeAttrs;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
34
|
+
if ((0, _experiments.editorExperiment)('add-media-from-url', true)) {
|
|
35
|
+
var _identifier = getIdentifier(selectedNodeAttrs);
|
|
36
|
+
var collectionName = (0, _utils.isExternalMedia)(selectedNodeAttrs) ? '' : selectedNodeAttrs.collection;
|
|
37
|
+
return /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/_react.default.createElement(_mediaViewer.MediaViewer, {
|
|
38
|
+
collectionName: collectionName,
|
|
39
|
+
items: [],
|
|
40
|
+
mediaClientConfig: mediaClientConfig,
|
|
41
|
+
selectedItem: _identifier,
|
|
42
|
+
onClose: onClose
|
|
43
|
+
}), document.body);
|
|
44
|
+
}
|
|
45
|
+
var _ref2 = selectedNodeAttrs,
|
|
46
|
+
id = _ref2.id,
|
|
47
|
+
_ref2$collection = _ref2.collection,
|
|
48
|
+
collection = _ref2$collection === void 0 ? '' : _ref2$collection;
|
|
18
49
|
var identifier = {
|
|
19
50
|
id: id,
|
|
20
51
|
mediaItemType: 'file',
|
|
@@ -12,7 +12,7 @@ import DownloadIcon from '@atlaskit/icon/glyph/download';
|
|
|
12
12
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
13
13
|
import { mediaFilmstripItemDOMSelector } from '@atlaskit/media-filmstrip';
|
|
14
14
|
import { messages } from '@atlaskit/media-ui';
|
|
15
|
-
import {
|
|
15
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
16
|
import { showLinkingToolbar } from '../commands/linking';
|
|
17
17
|
import { MediaSingleNodeSelector } from '../nodeviews/styles';
|
|
18
18
|
import { getPluginState as getMediaAltTextPluginState } from '../pm-plugins/alt-text';
|
|
@@ -196,7 +196,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
196
196
|
const widthPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width;
|
|
197
197
|
let isChangingLayoutDisabled = false;
|
|
198
198
|
const selectedNode = getSelectedMediaSingle(state);
|
|
199
|
-
if (
|
|
199
|
+
if (fg('platform.editor.media.extended-resize-experience')) {
|
|
200
200
|
var _widthPlugin$sharedSt;
|
|
201
201
|
const contentWidth = widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt === void 0 ? void 0 : _widthPlugin$sharedSt.lineLength;
|
|
202
202
|
const selectedNodeMaxWidth = pluginState.currentMaxWidth || contentWidth;
|
|
@@ -281,7 +281,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
281
281
|
selection
|
|
282
282
|
} = state;
|
|
283
283
|
const isWithinTable = hasParentNodeOfType([state.schema.nodes.table])(selection);
|
|
284
|
-
if (
|
|
284
|
+
if (allowResizing && (!isWithinTable || allowResizingInTables === true) && fg('platform.editor.media.extended-resize-experience')) {
|
|
285
285
|
const selectedMediaSingleNode = getSelectedMediaSingle(state);
|
|
286
286
|
const sizeInput = {
|
|
287
287
|
type: 'custom',
|
|
@@ -385,8 +385,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
385
385
|
type: 'separator'
|
|
386
386
|
});
|
|
387
387
|
}
|
|
388
|
-
if (editorFeatureFlags && editorFeatureFlags.commentsOnMedia && allowCommentsOnMedia
|
|
389
|
-
) {
|
|
388
|
+
if (editorFeatureFlags && editorFeatureFlags.commentsOnMedia && allowCommentsOnMedia) {
|
|
390
389
|
toolbarButtons.push(commentButton(intl, state, pluginInjectionApi), {
|
|
391
390
|
type: 'separator',
|
|
392
391
|
supportsViewMode: true
|
|
@@ -603,7 +602,7 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
603
602
|
scrollable: true,
|
|
604
603
|
mediaAssistiveMessage: assistiveMessage
|
|
605
604
|
};
|
|
606
|
-
if (
|
|
605
|
+
if (allowResizing && fg('platform.editor.media.extended-resize-experience')) {
|
|
607
606
|
return {
|
|
608
607
|
...toolbarConfig,
|
|
609
608
|
width: mediaPluginState.isResizing ? undefined : getMaxToolbarWidth()
|
|
@@ -5,6 +5,9 @@ import { findParentNodeOfType, findSelectedNodeOfType, removeParentNodeOfType, r
|
|
|
5
5
|
import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
6
6
|
import { getMediaClient } from '@atlaskit/media-client-react';
|
|
7
7
|
import { isVideo } from '../utils/media-single';
|
|
8
|
+
export const isExternalMedia = attrs => {
|
|
9
|
+
return attrs.type === 'external';
|
|
10
|
+
};
|
|
8
11
|
const getSelectedMediaContainerNodeAttrs = mediaPluginState => {
|
|
9
12
|
var _mediaPluginState$sel;
|
|
10
13
|
const selectedNode = (_mediaPluginState$sel = mediaPluginState.selectedMediaContainerNode) === null || _mediaPluginState$sel === void 0 ? void 0 : _mediaPluginState$sel.call(mediaPluginState);
|
|
@@ -32,7 +35,7 @@ export const getSelectedNearestMediaContainerNodeAttrs = mediaPluginState => {
|
|
|
32
35
|
export const downloadMedia = async (mediaPluginState, isViewMode) => {
|
|
33
36
|
try {
|
|
34
37
|
const selectedNodeAttrs = isViewMode ? getSelectedNearestMediaContainerNodeAttrs(mediaPluginState) : getSelectedMediaContainerNodeAttrs(mediaPluginState);
|
|
35
|
-
if (selectedNodeAttrs && mediaPluginState.mediaClientConfig) {
|
|
38
|
+
if (selectedNodeAttrs && mediaPluginState.mediaClientConfig && !isExternalMedia(selectedNodeAttrs)) {
|
|
36
39
|
const {
|
|
37
40
|
id,
|
|
38
41
|
collection = ''
|
|
@@ -1,11 +1,42 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
import { MediaViewer } from '@atlaskit/media-viewer';
|
|
4
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
|
+
import { isExternalMedia } from '../../toolbar/utils';
|
|
6
|
+
const getIdentifier = attrs => {
|
|
7
|
+
if (isExternalMedia(attrs)) {
|
|
8
|
+
return {
|
|
9
|
+
mediaItemType: 'external-image',
|
|
10
|
+
dataURI: attrs.url
|
|
11
|
+
};
|
|
12
|
+
} else {
|
|
13
|
+
const {
|
|
14
|
+
id,
|
|
15
|
+
collection = ''
|
|
16
|
+
} = attrs;
|
|
17
|
+
return {
|
|
18
|
+
id,
|
|
19
|
+
mediaItemType: 'file',
|
|
20
|
+
collectionName: collection
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
};
|
|
4
24
|
export const RenderMediaViewer = ({
|
|
5
25
|
mediaClientConfig,
|
|
6
26
|
onClose,
|
|
7
27
|
selectedNodeAttrs
|
|
8
28
|
}) => {
|
|
29
|
+
if (editorExperiment('add-media-from-url', true)) {
|
|
30
|
+
const identifier = getIdentifier(selectedNodeAttrs);
|
|
31
|
+
const collectionName = isExternalMedia(selectedNodeAttrs) ? '' : selectedNodeAttrs.collection;
|
|
32
|
+
return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(MediaViewer, {
|
|
33
|
+
collectionName: collectionName,
|
|
34
|
+
items: [],
|
|
35
|
+
mediaClientConfig: mediaClientConfig,
|
|
36
|
+
selectedItem: identifier,
|
|
37
|
+
onClose: onClose
|
|
38
|
+
}), document.body);
|
|
39
|
+
}
|
|
9
40
|
const {
|
|
10
41
|
id,
|
|
11
42
|
collection = ''
|
|
@@ -16,7 +16,7 @@ import DownloadIcon from '@atlaskit/icon/glyph/download';
|
|
|
16
16
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
17
17
|
import { mediaFilmstripItemDOMSelector } from '@atlaskit/media-filmstrip';
|
|
18
18
|
import { messages } from '@atlaskit/media-ui';
|
|
19
|
-
import {
|
|
19
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
20
20
|
import { showLinkingToolbar } from '../commands/linking';
|
|
21
21
|
import { MediaSingleNodeSelector } from '../nodeviews/styles';
|
|
22
22
|
import { getPluginState as getMediaAltTextPluginState } from '../pm-plugins/alt-text';
|
|
@@ -193,7 +193,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
193
193
|
var widthPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width;
|
|
194
194
|
var isChangingLayoutDisabled = false;
|
|
195
195
|
var selectedNode = getSelectedMediaSingle(state);
|
|
196
|
-
if (
|
|
196
|
+
if (fg('platform.editor.media.extended-resize-experience')) {
|
|
197
197
|
var _widthPlugin$sharedSt;
|
|
198
198
|
var contentWidth = widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt === void 0 ? void 0 : _widthPlugin$sharedSt.lineLength;
|
|
199
199
|
var selectedNodeMaxWidth = pluginState.currentMaxWidth || contentWidth;
|
|
@@ -280,7 +280,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
280
280
|
// Pixel Entry Toolbar Support
|
|
281
281
|
var selection = state.selection;
|
|
282
282
|
var isWithinTable = hasParentNodeOfType([state.schema.nodes.table])(selection);
|
|
283
|
-
if (
|
|
283
|
+
if (allowResizing && (!isWithinTable || allowResizingInTables === true) && fg('platform.editor.media.extended-resize-experience')) {
|
|
284
284
|
var selectedMediaSingleNode = getSelectedMediaSingle(state);
|
|
285
285
|
var sizeInput = {
|
|
286
286
|
type: 'custom',
|
|
@@ -378,8 +378,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
378
378
|
type: 'separator'
|
|
379
379
|
});
|
|
380
380
|
}
|
|
381
|
-
if (editorFeatureFlags && editorFeatureFlags.commentsOnMedia && allowCommentsOnMedia
|
|
382
|
-
) {
|
|
381
|
+
if (editorFeatureFlags && editorFeatureFlags.commentsOnMedia && allowCommentsOnMedia) {
|
|
383
382
|
toolbarButtons.push(commentButton(intl, state, pluginInjectionApi), {
|
|
384
383
|
type: 'separator',
|
|
385
384
|
supportsViewMode: true
|
|
@@ -591,7 +590,7 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
591
590
|
scrollable: true,
|
|
592
591
|
mediaAssistiveMessage: assistiveMessage
|
|
593
592
|
});
|
|
594
|
-
if (
|
|
593
|
+
if (allowResizing && fg('platform.editor.media.extended-resize-experience')) {
|
|
595
594
|
return _objectSpread(_objectSpread({}, toolbarConfig), {}, {
|
|
596
595
|
width: mediaPluginState.isResizing ? undefined : getMaxToolbarWidth()
|
|
597
596
|
});
|
|
@@ -7,6 +7,9 @@ import { findParentNodeOfType, findSelectedNodeOfType, removeParentNodeOfType, r
|
|
|
7
7
|
import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
8
8
|
import { getMediaClient } from '@atlaskit/media-client-react';
|
|
9
9
|
import { isVideo } from '../utils/media-single';
|
|
10
|
+
export var isExternalMedia = function isExternalMedia(attrs) {
|
|
11
|
+
return attrs.type === 'external';
|
|
12
|
+
};
|
|
10
13
|
var getSelectedMediaContainerNodeAttrs = function getSelectedMediaContainerNodeAttrs(mediaPluginState) {
|
|
11
14
|
var _mediaPluginState$sel;
|
|
12
15
|
var selectedNode = (_mediaPluginState$sel = mediaPluginState.selectedMediaContainerNode) === null || _mediaPluginState$sel === void 0 ? void 0 : _mediaPluginState$sel.call(mediaPluginState);
|
|
@@ -39,7 +42,7 @@ export var downloadMedia = /*#__PURE__*/function () {
|
|
|
39
42
|
case 0:
|
|
40
43
|
_context.prev = 0;
|
|
41
44
|
selectedNodeAttrs = isViewMode ? getSelectedNearestMediaContainerNodeAttrs(mediaPluginState) : getSelectedMediaContainerNodeAttrs(mediaPluginState);
|
|
42
|
-
if (!(selectedNodeAttrs && mediaPluginState.mediaClientConfig)) {
|
|
45
|
+
if (!(selectedNodeAttrs && mediaPluginState.mediaClientConfig && !isExternalMedia(selectedNodeAttrs))) {
|
|
43
46
|
_context.next = 10;
|
|
44
47
|
break;
|
|
45
48
|
}
|
|
@@ -1,13 +1,44 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
import { MediaViewer } from '@atlaskit/media-viewer';
|
|
4
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
|
+
import { isExternalMedia } from '../../toolbar/utils';
|
|
6
|
+
var getIdentifier = function getIdentifier(attrs) {
|
|
7
|
+
if (isExternalMedia(attrs)) {
|
|
8
|
+
return {
|
|
9
|
+
mediaItemType: 'external-image',
|
|
10
|
+
dataURI: attrs.url
|
|
11
|
+
};
|
|
12
|
+
} else {
|
|
13
|
+
var id = attrs.id,
|
|
14
|
+
_attrs$collection = attrs.collection,
|
|
15
|
+
collection = _attrs$collection === void 0 ? '' : _attrs$collection;
|
|
16
|
+
return {
|
|
17
|
+
id: id,
|
|
18
|
+
mediaItemType: 'file',
|
|
19
|
+
collectionName: collection
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
};
|
|
4
23
|
export var RenderMediaViewer = function RenderMediaViewer(_ref) {
|
|
5
24
|
var mediaClientConfig = _ref.mediaClientConfig,
|
|
6
25
|
onClose = _ref.onClose,
|
|
7
26
|
selectedNodeAttrs = _ref.selectedNodeAttrs;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
27
|
+
if (editorExperiment('add-media-from-url', true)) {
|
|
28
|
+
var _identifier = getIdentifier(selectedNodeAttrs);
|
|
29
|
+
var collectionName = isExternalMedia(selectedNodeAttrs) ? '' : selectedNodeAttrs.collection;
|
|
30
|
+
return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(MediaViewer, {
|
|
31
|
+
collectionName: collectionName,
|
|
32
|
+
items: [],
|
|
33
|
+
mediaClientConfig: mediaClientConfig,
|
|
34
|
+
selectedItem: _identifier,
|
|
35
|
+
onClose: onClose
|
|
36
|
+
}), document.body);
|
|
37
|
+
}
|
|
38
|
+
var _ref2 = selectedNodeAttrs,
|
|
39
|
+
id = _ref2.id,
|
|
40
|
+
_ref2$collection = _ref2.collection,
|
|
41
|
+
collection = _ref2$collection === void 0 ? '' : _ref2$collection;
|
|
11
42
|
var identifier = {
|
|
12
43
|
id: id,
|
|
13
44
|
mediaItemType: 'file',
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExternalMediaAttributes, MediaADFAttrs, RichMediaLayout } from '@atlaskit/adf-schema';
|
|
2
2
|
import type { LayoutIcon } from '@atlaskit/editor-common/card';
|
|
3
3
|
import type { Node as ProseMirrorNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
6
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
7
|
import type { MediaPluginState } from '../pm-plugins/types';
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const isExternalMedia: (attrs: MediaADFAttrs) => attrs is ExternalMediaAttributes;
|
|
9
|
+
export declare const getSelectedNearestMediaContainerNodeAttrs: (mediaPluginState: MediaPluginState) => MediaADFAttrs | null;
|
|
9
10
|
export declare const downloadMedia: (mediaPluginState: MediaPluginState, isViewMode?: boolean) => Promise<boolean>;
|
|
10
11
|
export declare const removeMediaGroupNode: (state: EditorState) => import("prosemirror-state").Transaction;
|
|
11
12
|
export declare const getSelectedMediaSingle: (state: EditorState) => ReturnType<ReturnType<typeof findSelectedNodeOfType>> | ReturnType<ReturnType<typeof findParentNodeOfType>>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { MediaADFAttrs } from '@atlaskit/adf-schema';
|
|
3
3
|
import type { MediaClientConfig } from '@atlaskit/media-client';
|
|
4
4
|
interface RenderMediaViewerProps {
|
|
5
5
|
mediaClientConfig: MediaClientConfig;
|
|
6
6
|
onClose: () => void;
|
|
7
|
-
selectedNodeAttrs:
|
|
7
|
+
selectedNodeAttrs: MediaADFAttrs;
|
|
8
8
|
}
|
|
9
9
|
export declare const RenderMediaViewer: ({ mediaClientConfig, onClose, selectedNodeAttrs, }: RenderMediaViewerProps) => React.ReactPortal;
|
|
10
10
|
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExternalMediaAttributes, MediaADFAttrs, RichMediaLayout } from '@atlaskit/adf-schema';
|
|
2
2
|
import type { LayoutIcon } from '@atlaskit/editor-common/card';
|
|
3
3
|
import type { Node as ProseMirrorNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
6
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
7
|
import type { MediaPluginState } from '../pm-plugins/types';
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const isExternalMedia: (attrs: MediaADFAttrs) => attrs is ExternalMediaAttributes;
|
|
9
|
+
export declare const getSelectedNearestMediaContainerNodeAttrs: (mediaPluginState: MediaPluginState) => MediaADFAttrs | null;
|
|
9
10
|
export declare const downloadMedia: (mediaPluginState: MediaPluginState, isViewMode?: boolean) => Promise<boolean>;
|
|
10
11
|
export declare const removeMediaGroupNode: (state: EditorState) => import("prosemirror-state").Transaction;
|
|
11
12
|
export declare const getSelectedMediaSingle: (state: EditorState) => ReturnType<ReturnType<typeof findSelectedNodeOfType>> | ReturnType<ReturnType<typeof findParentNodeOfType>>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { MediaADFAttrs } from '@atlaskit/adf-schema';
|
|
3
3
|
import type { MediaClientConfig } from '@atlaskit/media-client';
|
|
4
4
|
interface RenderMediaViewerProps {
|
|
5
5
|
mediaClientConfig: MediaClientConfig;
|
|
6
6
|
onClose: () => void;
|
|
7
|
-
selectedNodeAttrs:
|
|
7
|
+
selectedNodeAttrs: MediaADFAttrs;
|
|
8
8
|
}
|
|
9
9
|
export declare const RenderMediaViewer: ({ mediaClientConfig, onClose, selectedNodeAttrs, }: RenderMediaViewerProps) => React.ReactPortal;
|
|
10
10
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.33.0",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"@atlaskit/adf-schema": "^40.9.0",
|
|
36
36
|
"@atlaskit/analytics-namespaced-context": "^6.12.0",
|
|
37
37
|
"@atlaskit/analytics-next": "^10.1.0",
|
|
38
|
-
"@atlaskit/button": "^20.
|
|
39
|
-
"@atlaskit/editor-common": "^91.
|
|
38
|
+
"@atlaskit/button": "^20.2.0",
|
|
39
|
+
"@atlaskit/editor-common": "^91.1.0",
|
|
40
40
|
"@atlaskit/editor-palette": "1.6.0",
|
|
41
41
|
"@atlaskit/editor-plugin-analytics": "^1.8.0",
|
|
42
42
|
"@atlaskit/editor-plugin-annotation": "1.19.8",
|
|
@@ -50,15 +50,15 @@
|
|
|
50
50
|
"@atlaskit/editor-plugin-selection": "^1.4.0",
|
|
51
51
|
"@atlaskit/editor-plugin-width": "^1.3.0",
|
|
52
52
|
"@atlaskit/editor-prosemirror": "6.0.0",
|
|
53
|
-
"@atlaskit/editor-shared-styles": "^
|
|
53
|
+
"@atlaskit/editor-shared-styles": "^3.0.0",
|
|
54
54
|
"@atlaskit/editor-tables": "^2.8.0",
|
|
55
55
|
"@atlaskit/form": "^10.5.0",
|
|
56
56
|
"@atlaskit/icon": "^22.18.0",
|
|
57
57
|
"@atlaskit/media-card": "^78.5.0",
|
|
58
58
|
"@atlaskit/media-client": "^28.0.0",
|
|
59
59
|
"@atlaskit/media-client-react": "^2.2.0",
|
|
60
|
-
"@atlaskit/media-common": "^11.
|
|
61
|
-
"@atlaskit/media-filmstrip": "^47.
|
|
60
|
+
"@atlaskit/media-common": "^11.5.0",
|
|
61
|
+
"@atlaskit/media-filmstrip": "^47.4.0",
|
|
62
62
|
"@atlaskit/media-picker": "^66.7.0",
|
|
63
63
|
"@atlaskit/media-ui": "^25.15.0",
|
|
64
64
|
"@atlaskit/media-viewer": "^48.10.0",
|
|
@@ -132,9 +132,6 @@
|
|
|
132
132
|
"type": "boolean",
|
|
133
133
|
"referenceOnly": "true"
|
|
134
134
|
},
|
|
135
|
-
"platform.editor.live-view.comments-in-media-toolbar-button": {
|
|
136
|
-
"type": "boolean"
|
|
137
|
-
},
|
|
138
135
|
"platform.editor.live-view.disable-editing-in-view-mode_fi1rx": {
|
|
139
136
|
"type": "boolean"
|
|
140
137
|
},
|