@atlaskit/editor-plugin-media 1.4.1 → 1.5.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 +10 -0
- package/dist/cjs/plugin.js +1 -0
- package/dist/cjs/toolbar/filePreviewItem.js +2 -2
- package/dist/cjs/toolbar/index.js +21 -6
- package/dist/cjs/toolbar/utils.js +16 -1
- package/dist/es2019/plugin.js +1 -0
- package/dist/es2019/toolbar/filePreviewItem.js +3 -3
- package/dist/es2019/toolbar/index.js +23 -8
- package/dist/es2019/toolbar/utils.js +15 -0
- package/dist/esm/plugin.js +1 -0
- package/dist/esm/toolbar/filePreviewItem.js +3 -3
- package/dist/esm/toolbar/index.js +21 -6
- package/dist/esm/toolbar/utils.js +15 -0
- package/dist/types/toolbar/utils.d.ts +1 -0
- package/dist/types/types.d.ts +2 -0
- package/dist/types-ts4.5/toolbar/utils.d.ts +1 -0
- package/dist/types-ts4.5/types.d.ts +2 -0
- package/package.json +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 1.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#76504](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/76504) [`35deb7a5d492`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/35deb7a5d492) - [ux] Add Media preview feature for full page Editor under FF
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
3
13
|
## 1.4.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -277,6 +277,7 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
277
277
|
allowLinking: options && options.allowLinking,
|
|
278
278
|
allowAdvancedToolBarOptions: options && options.allowAdvancedToolBarOptions,
|
|
279
279
|
allowAltTextOnImages: options && options.allowAltTextOnImages,
|
|
280
|
+
allowImagePreview: options && options.allowImagePreview,
|
|
280
281
|
altTextValidator: options && options.altTextValidator,
|
|
281
282
|
fullWidthEnabled: options && options.fullWidthEnabled,
|
|
282
283
|
allowMediaInlineImages: options && options.allowMediaInlineImages,
|
|
@@ -31,7 +31,7 @@ var FilePreviewItem = exports.FilePreviewItem = function FilePreviewItem(_ref) {
|
|
|
31
31
|
};
|
|
32
32
|
var renderMediaViewer = function renderMediaViewer() {
|
|
33
33
|
if (isMediaViewerVisible) {
|
|
34
|
-
var selectedNodeAttrs = (0, _utils.
|
|
34
|
+
var selectedNodeAttrs = (0, _utils.getSelectedNearestMediaContainerNodeAttrs)(mediaPluginState);
|
|
35
35
|
if (selectedNodeAttrs && mediaPluginState.mediaClientConfig) {
|
|
36
36
|
var id = selectedNodeAttrs.id,
|
|
37
37
|
_selectedNodeAttrs$co = selectedNodeAttrs.collection,
|
|
@@ -54,7 +54,7 @@ var FilePreviewItem = exports.FilePreviewItem = function FilePreviewItem(_ref) {
|
|
|
54
54
|
};
|
|
55
55
|
var mediaViewer = renderMediaViewer();
|
|
56
56
|
var tooltipContent = intl.formatMessage(_mediaUi.messages.preview);
|
|
57
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
57
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ui.FloatingToolbarButton, {
|
|
58
58
|
testId: "file-preview-toolbar-button",
|
|
59
59
|
key: "editor.media.card.preview",
|
|
60
60
|
onClick: openMediaViewer,
|
|
@@ -67,11 +67,8 @@ var handleRemoveMediaGroup = function handleRemoveMediaGroup(state, dispatch) {
|
|
|
67
67
|
}
|
|
68
68
|
return true;
|
|
69
69
|
};
|
|
70
|
-
var
|
|
71
|
-
|
|
72
|
-
var items = [{
|
|
73
|
-
type: 'separator'
|
|
74
|
-
}, {
|
|
70
|
+
var generateFilePreviewItem = function generateFilePreviewItem(mediaPluginState, intl, editorState) {
|
|
71
|
+
return {
|
|
75
72
|
type: 'custom',
|
|
76
73
|
fallback: [],
|
|
77
74
|
render: function render() {
|
|
@@ -81,7 +78,13 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
|
|
|
81
78
|
intl: intl
|
|
82
79
|
});
|
|
83
80
|
}
|
|
84
|
-
}
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI, forceFocusSelector) {
|
|
84
|
+
var mediaGroup = state.schema.nodes.mediaGroup;
|
|
85
|
+
var items = [{
|
|
86
|
+
type: 'separator'
|
|
87
|
+
}, generateFilePreviewItem(mediaPluginState, intl), {
|
|
85
88
|
type: 'separator'
|
|
86
89
|
}, {
|
|
87
90
|
id: 'editor.media.card.download',
|
|
@@ -177,6 +180,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
177
180
|
allowAltTextOnImages = options.allowAltTextOnImages,
|
|
178
181
|
allowMediaInline = options.allowMediaInline,
|
|
179
182
|
allowMediaInlineImages = options.allowMediaInlineImages,
|
|
183
|
+
allowImagePreview = options.allowImagePreview,
|
|
180
184
|
getEditorFeatureFlags = options.getEditorFeatureFlags;
|
|
181
185
|
var editorFeatureFlags = getEditorFeatureFlags ? getEditorFeatureFlags() : undefined;
|
|
182
186
|
var toolbarButtons = [];
|
|
@@ -449,6 +453,17 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
449
453
|
}
|
|
450
454
|
});
|
|
451
455
|
}
|
|
456
|
+
// Preview Support
|
|
457
|
+
if (allowImagePreview && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.preview-in-full-page')) {
|
|
458
|
+
var _mediaNode$attrs;
|
|
459
|
+
var _selectedMediaSingleNode = (0, _utils2.getSelectedMediaSingle)(state);
|
|
460
|
+
var mediaNode = _selectedMediaSingleNode === null || _selectedMediaSingleNode === void 0 ? void 0 : _selectedMediaSingleNode.node.content.firstChild;
|
|
461
|
+
if (!(0, _mediaSingle2.isVideo)(mediaNode === null || mediaNode === void 0 || (_mediaNode$attrs = mediaNode.attrs) === null || _mediaNode$attrs === void 0 ? void 0 : _mediaNode$attrs.__fileMimeType)) {
|
|
462
|
+
toolbarButtons.push(generateFilePreviewItem(pluginState, intl, state), {
|
|
463
|
+
type: 'separator'
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
}
|
|
452
467
|
}
|
|
453
468
|
if (allowAltTextOnImages) {
|
|
454
469
|
var _pluginInjectionApi$a8;
|
|
@@ -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.getSelectedMediaSingle = exports.getSelectedMediaContainerNodeAttrs = exports.getSelectedLayoutIcon = exports.getPixelWidthOfElement = exports.getMaxToolbarWidth = exports.downloadMedia = exports.canShowSwitchButtons = exports.calcNewLayout = void 0;
|
|
7
|
+
exports.removeMediaGroupNode = exports.getSelectedNearestMediaContainerNodeAttrs = exports.getSelectedMediaSingle = exports.getSelectedMediaContainerNodeAttrs = 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"));
|
|
@@ -21,6 +21,21 @@ var getSelectedMediaContainerNodeAttrs = exports.getSelectedMediaContainerNodeAt
|
|
|
21
21
|
}
|
|
22
22
|
return null;
|
|
23
23
|
};
|
|
24
|
+
var getSelectedNearestMediaContainerNodeAttrs = exports.getSelectedNearestMediaContainerNodeAttrs = function getSelectedNearestMediaContainerNodeAttrs(mediaPluginState) {
|
|
25
|
+
var selectedNode = mediaPluginState.selectedMediaContainerNode();
|
|
26
|
+
if (selectedNode) {
|
|
27
|
+
switch (selectedNode.type.name) {
|
|
28
|
+
case 'mediaSingle':
|
|
29
|
+
{
|
|
30
|
+
var childNode = selectedNode.firstChild;
|
|
31
|
+
return childNode === null || childNode === void 0 ? void 0 : childNode.attrs;
|
|
32
|
+
}
|
|
33
|
+
default:
|
|
34
|
+
return selectedNode.attrs;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
};
|
|
24
39
|
var downloadMedia = exports.downloadMedia = /*#__PURE__*/function () {
|
|
25
40
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(mediaPluginState) {
|
|
26
41
|
var selectedNodeAttrs, id, _selectedNodeAttrs$co, collection, mediaClient, fileState, fileName;
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -270,6 +270,7 @@ export const mediaPlugin = ({
|
|
|
270
270
|
allowLinking: options && options.allowLinking,
|
|
271
271
|
allowAdvancedToolBarOptions: options && options.allowAdvancedToolBarOptions,
|
|
272
272
|
allowAltTextOnImages: options && options.allowAltTextOnImages,
|
|
273
|
+
allowImagePreview: options && options.allowImagePreview,
|
|
273
274
|
altTextValidator: options && options.altTextValidator,
|
|
274
275
|
fullWidthEnabled: options && options.fullWidthEnabled,
|
|
275
276
|
allowMediaInlineImages: options && options.allowMediaInlineImages,
|
|
@@ -4,7 +4,7 @@ import { FloatingToolbarButton as ToolbarButton } from '@atlaskit/editor-common/
|
|
|
4
4
|
import FilePreviewIcon from '@atlaskit/icon/glyph/editor/file-preview';
|
|
5
5
|
import { messages } from '@atlaskit/media-ui';
|
|
6
6
|
import { MediaViewer } from '@atlaskit/media-viewer';
|
|
7
|
-
import {
|
|
7
|
+
import { getSelectedNearestMediaContainerNodeAttrs } from './utils';
|
|
8
8
|
export const FilePreviewItem = ({
|
|
9
9
|
mediaPluginState,
|
|
10
10
|
intl
|
|
@@ -18,7 +18,7 @@ export const FilePreviewItem = ({
|
|
|
18
18
|
};
|
|
19
19
|
const renderMediaViewer = () => {
|
|
20
20
|
if (isMediaViewerVisible) {
|
|
21
|
-
const selectedNodeAttrs =
|
|
21
|
+
const selectedNodeAttrs = getSelectedNearestMediaContainerNodeAttrs(mediaPluginState);
|
|
22
22
|
if (selectedNodeAttrs && mediaPluginState.mediaClientConfig) {
|
|
23
23
|
const {
|
|
24
24
|
id,
|
|
@@ -42,7 +42,7 @@ export const FilePreviewItem = ({
|
|
|
42
42
|
};
|
|
43
43
|
const mediaViewer = renderMediaViewer();
|
|
44
44
|
const tooltipContent = intl.formatMessage(messages.preview);
|
|
45
|
-
return /*#__PURE__*/React.createElement(
|
|
45
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ToolbarButton, {
|
|
46
46
|
testId: "file-preview-toolbar-button",
|
|
47
47
|
key: "editor.media.card.preview",
|
|
48
48
|
onClick: openMediaViewer,
|
|
@@ -53,13 +53,8 @@ const handleRemoveMediaGroup = (state, dispatch) => {
|
|
|
53
53
|
}
|
|
54
54
|
return true;
|
|
55
55
|
};
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
mediaGroup
|
|
59
|
-
} = state.schema.nodes;
|
|
60
|
-
const items = [{
|
|
61
|
-
type: 'separator'
|
|
62
|
-
}, {
|
|
56
|
+
const generateFilePreviewItem = (mediaPluginState, intl, editorState) => {
|
|
57
|
+
return {
|
|
63
58
|
type: 'custom',
|
|
64
59
|
fallback: [],
|
|
65
60
|
render: () => {
|
|
@@ -69,7 +64,15 @@ const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState, hoverDe
|
|
|
69
64
|
intl: intl
|
|
70
65
|
});
|
|
71
66
|
}
|
|
72
|
-
}
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI, forceFocusSelector) => {
|
|
70
|
+
const {
|
|
71
|
+
mediaGroup
|
|
72
|
+
} = state.schema.nodes;
|
|
73
|
+
const items = [{
|
|
74
|
+
type: 'separator'
|
|
75
|
+
}, generateFilePreviewItem(mediaPluginState, intl), {
|
|
73
76
|
type: 'separator'
|
|
74
77
|
}, {
|
|
75
78
|
id: 'editor.media.card.download',
|
|
@@ -166,6 +169,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
166
169
|
allowAltTextOnImages,
|
|
167
170
|
allowMediaInline,
|
|
168
171
|
allowMediaInlineImages,
|
|
172
|
+
allowImagePreview,
|
|
169
173
|
getEditorFeatureFlags
|
|
170
174
|
} = options;
|
|
171
175
|
const editorFeatureFlags = getEditorFeatureFlags ? getEditorFeatureFlags() : undefined;
|
|
@@ -452,6 +456,17 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
452
456
|
}
|
|
453
457
|
});
|
|
454
458
|
}
|
|
459
|
+
// Preview Support
|
|
460
|
+
if (allowImagePreview && getBooleanFF('platform.editor.media.preview-in-full-page')) {
|
|
461
|
+
var _mediaNode$attrs;
|
|
462
|
+
const selectedMediaSingleNode = getSelectedMediaSingle(state);
|
|
463
|
+
const mediaNode = selectedMediaSingleNode === null || selectedMediaSingleNode === void 0 ? void 0 : selectedMediaSingleNode.node.content.firstChild;
|
|
464
|
+
if (!isVideo(mediaNode === null || mediaNode === void 0 ? void 0 : (_mediaNode$attrs = mediaNode.attrs) === null || _mediaNode$attrs === void 0 ? void 0 : _mediaNode$attrs.__fileMimeType)) {
|
|
465
|
+
toolbarButtons.push(generateFilePreviewItem(pluginState, intl, state), {
|
|
466
|
+
type: 'separator'
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
}
|
|
455
470
|
}
|
|
456
471
|
if (allowAltTextOnImages) {
|
|
457
472
|
var _pluginInjectionApi$a8;
|
|
@@ -12,6 +12,21 @@ export const getSelectedMediaContainerNodeAttrs = mediaPluginState => {
|
|
|
12
12
|
}
|
|
13
13
|
return null;
|
|
14
14
|
};
|
|
15
|
+
export const getSelectedNearestMediaContainerNodeAttrs = mediaPluginState => {
|
|
16
|
+
const selectedNode = mediaPluginState.selectedMediaContainerNode();
|
|
17
|
+
if (selectedNode) {
|
|
18
|
+
switch (selectedNode.type.name) {
|
|
19
|
+
case 'mediaSingle':
|
|
20
|
+
{
|
|
21
|
+
const childNode = selectedNode.firstChild;
|
|
22
|
+
return childNode === null || childNode === void 0 ? void 0 : childNode.attrs;
|
|
23
|
+
}
|
|
24
|
+
default:
|
|
25
|
+
return selectedNode.attrs;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
15
30
|
export const downloadMedia = async mediaPluginState => {
|
|
16
31
|
try {
|
|
17
32
|
const selectedNodeAttrs = getSelectedMediaContainerNodeAttrs(mediaPluginState);
|
package/dist/esm/plugin.js
CHANGED
|
@@ -266,6 +266,7 @@ export var mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
266
266
|
allowLinking: options && options.allowLinking,
|
|
267
267
|
allowAdvancedToolBarOptions: options && options.allowAdvancedToolBarOptions,
|
|
268
268
|
allowAltTextOnImages: options && options.allowAltTextOnImages,
|
|
269
|
+
allowImagePreview: options && options.allowImagePreview,
|
|
269
270
|
altTextValidator: options && options.altTextValidator,
|
|
270
271
|
fullWidthEnabled: options && options.fullWidthEnabled,
|
|
271
272
|
allowMediaInlineImages: options && options.allowMediaInlineImages,
|
|
@@ -5,7 +5,7 @@ import { FloatingToolbarButton as ToolbarButton } from '@atlaskit/editor-common/
|
|
|
5
5
|
import FilePreviewIcon from '@atlaskit/icon/glyph/editor/file-preview';
|
|
6
6
|
import { messages } from '@atlaskit/media-ui';
|
|
7
7
|
import { MediaViewer } from '@atlaskit/media-viewer';
|
|
8
|
-
import {
|
|
8
|
+
import { getSelectedNearestMediaContainerNodeAttrs } from './utils';
|
|
9
9
|
export var FilePreviewItem = function FilePreviewItem(_ref) {
|
|
10
10
|
var mediaPluginState = _ref.mediaPluginState,
|
|
11
11
|
intl = _ref.intl;
|
|
@@ -21,7 +21,7 @@ export var FilePreviewItem = function FilePreviewItem(_ref) {
|
|
|
21
21
|
};
|
|
22
22
|
var renderMediaViewer = function renderMediaViewer() {
|
|
23
23
|
if (isMediaViewerVisible) {
|
|
24
|
-
var selectedNodeAttrs =
|
|
24
|
+
var selectedNodeAttrs = getSelectedNearestMediaContainerNodeAttrs(mediaPluginState);
|
|
25
25
|
if (selectedNodeAttrs && mediaPluginState.mediaClientConfig) {
|
|
26
26
|
var id = selectedNodeAttrs.id,
|
|
27
27
|
_selectedNodeAttrs$co = selectedNodeAttrs.collection,
|
|
@@ -44,7 +44,7 @@ export var FilePreviewItem = function FilePreviewItem(_ref) {
|
|
|
44
44
|
};
|
|
45
45
|
var mediaViewer = renderMediaViewer();
|
|
46
46
|
var tooltipContent = intl.formatMessage(messages.preview);
|
|
47
|
-
return /*#__PURE__*/React.createElement(
|
|
47
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ToolbarButton, {
|
|
48
48
|
testId: "file-preview-toolbar-button",
|
|
49
49
|
key: "editor.media.card.preview",
|
|
50
50
|
onClick: openMediaViewer,
|
|
@@ -57,11 +57,8 @@ var handleRemoveMediaGroup = function handleRemoveMediaGroup(state, dispatch) {
|
|
|
57
57
|
}
|
|
58
58
|
return true;
|
|
59
59
|
};
|
|
60
|
-
var
|
|
61
|
-
|
|
62
|
-
var items = [{
|
|
63
|
-
type: 'separator'
|
|
64
|
-
}, {
|
|
60
|
+
var generateFilePreviewItem = function generateFilePreviewItem(mediaPluginState, intl, editorState) {
|
|
61
|
+
return {
|
|
65
62
|
type: 'custom',
|
|
66
63
|
fallback: [],
|
|
67
64
|
render: function render() {
|
|
@@ -71,7 +68,13 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
|
|
|
71
68
|
intl: intl
|
|
72
69
|
});
|
|
73
70
|
}
|
|
74
|
-
}
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI, forceFocusSelector) {
|
|
74
|
+
var mediaGroup = state.schema.nodes.mediaGroup;
|
|
75
|
+
var items = [{
|
|
76
|
+
type: 'separator'
|
|
77
|
+
}, generateFilePreviewItem(mediaPluginState, intl), {
|
|
75
78
|
type: 'separator'
|
|
76
79
|
}, {
|
|
77
80
|
id: 'editor.media.card.download',
|
|
@@ -167,6 +170,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
167
170
|
allowAltTextOnImages = options.allowAltTextOnImages,
|
|
168
171
|
allowMediaInline = options.allowMediaInline,
|
|
169
172
|
allowMediaInlineImages = options.allowMediaInlineImages,
|
|
173
|
+
allowImagePreview = options.allowImagePreview,
|
|
170
174
|
getEditorFeatureFlags = options.getEditorFeatureFlags;
|
|
171
175
|
var editorFeatureFlags = getEditorFeatureFlags ? getEditorFeatureFlags() : undefined;
|
|
172
176
|
var toolbarButtons = [];
|
|
@@ -439,6 +443,17 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
439
443
|
}
|
|
440
444
|
});
|
|
441
445
|
}
|
|
446
|
+
// Preview Support
|
|
447
|
+
if (allowImagePreview && getBooleanFF('platform.editor.media.preview-in-full-page')) {
|
|
448
|
+
var _mediaNode$attrs;
|
|
449
|
+
var _selectedMediaSingleNode = getSelectedMediaSingle(state);
|
|
450
|
+
var mediaNode = _selectedMediaSingleNode === null || _selectedMediaSingleNode === void 0 ? void 0 : _selectedMediaSingleNode.node.content.firstChild;
|
|
451
|
+
if (!isVideo(mediaNode === null || mediaNode === void 0 || (_mediaNode$attrs = mediaNode.attrs) === null || _mediaNode$attrs === void 0 ? void 0 : _mediaNode$attrs.__fileMimeType)) {
|
|
452
|
+
toolbarButtons.push(generateFilePreviewItem(pluginState, intl, state), {
|
|
453
|
+
type: 'separator'
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
}
|
|
442
457
|
}
|
|
443
458
|
if (allowAltTextOnImages) {
|
|
444
459
|
var _pluginInjectionApi$a8;
|
|
@@ -14,6 +14,21 @@ export var getSelectedMediaContainerNodeAttrs = function getSelectedMediaContain
|
|
|
14
14
|
}
|
|
15
15
|
return null;
|
|
16
16
|
};
|
|
17
|
+
export var getSelectedNearestMediaContainerNodeAttrs = function getSelectedNearestMediaContainerNodeAttrs(mediaPluginState) {
|
|
18
|
+
var selectedNode = mediaPluginState.selectedMediaContainerNode();
|
|
19
|
+
if (selectedNode) {
|
|
20
|
+
switch (selectedNode.type.name) {
|
|
21
|
+
case 'mediaSingle':
|
|
22
|
+
{
|
|
23
|
+
var childNode = selectedNode.firstChild;
|
|
24
|
+
return childNode === null || childNode === void 0 ? void 0 : childNode.attrs;
|
|
25
|
+
}
|
|
26
|
+
default:
|
|
27
|
+
return selectedNode.attrs;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
};
|
|
17
32
|
export var downloadMedia = /*#__PURE__*/function () {
|
|
18
33
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(mediaPluginState) {
|
|
19
34
|
var selectedNodeAttrs, id, _selectedNodeAttrs$co, collection, mediaClient, fileState, fileName;
|
|
@@ -5,6 +5,7 @@ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
|
5
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import type { MediaPluginState } from '../pm-plugins/types';
|
|
7
7
|
export declare const getSelectedMediaContainerNodeAttrs: (mediaPluginState: MediaPluginState) => MediaBaseAttributes | null;
|
|
8
|
+
export declare const getSelectedNearestMediaContainerNodeAttrs: (mediaPluginState: MediaPluginState) => MediaBaseAttributes | null;
|
|
8
9
|
export declare const downloadMedia: (mediaPluginState: MediaPluginState) => Promise<boolean>;
|
|
9
10
|
export declare const removeMediaGroupNode: (state: EditorState) => import("prosemirror-state").Transaction;
|
|
10
11
|
export declare const getSelectedMediaSingle: (state: EditorState) => import("prosemirror-utils/dist/types").FindResult;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export interface MediaOptions {
|
|
|
35
35
|
allowRemoteDimensionsFetch?: boolean;
|
|
36
36
|
allowDropzoneDropLine?: boolean;
|
|
37
37
|
allowMarkingUploadsAsIncomplete?: boolean;
|
|
38
|
+
allowImagePreview?: boolean;
|
|
38
39
|
fullWidthEnabled?: boolean;
|
|
39
40
|
uploadErrorHandler?: (state: MediaState) => void;
|
|
40
41
|
waitForMediaUpload?: boolean;
|
|
@@ -108,6 +109,7 @@ export type MediaFloatingToolbarOptions = {
|
|
|
108
109
|
allowAdvancedToolBarOptions?: boolean;
|
|
109
110
|
allowResizingInTables?: boolean;
|
|
110
111
|
allowAltTextOnImages?: boolean;
|
|
112
|
+
allowImagePreview?: boolean;
|
|
111
113
|
altTextValidator?: (value: string) => string[];
|
|
112
114
|
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
113
115
|
fullWidthEnabled?: boolean;
|
|
@@ -5,6 +5,7 @@ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
|
5
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import type { MediaPluginState } from '../pm-plugins/types';
|
|
7
7
|
export declare const getSelectedMediaContainerNodeAttrs: (mediaPluginState: MediaPluginState) => MediaBaseAttributes | null;
|
|
8
|
+
export declare const getSelectedNearestMediaContainerNodeAttrs: (mediaPluginState: MediaPluginState) => MediaBaseAttributes | null;
|
|
8
9
|
export declare const downloadMedia: (mediaPluginState: MediaPluginState) => Promise<boolean>;
|
|
9
10
|
export declare const removeMediaGroupNode: (state: EditorState) => import("prosemirror-state").Transaction;
|
|
10
11
|
export declare const getSelectedMediaSingle: (state: EditorState) => import("prosemirror-utils/dist/types").FindResult;
|
|
@@ -35,6 +35,7 @@ export interface MediaOptions {
|
|
|
35
35
|
allowRemoteDimensionsFetch?: boolean;
|
|
36
36
|
allowDropzoneDropLine?: boolean;
|
|
37
37
|
allowMarkingUploadsAsIncomplete?: boolean;
|
|
38
|
+
allowImagePreview?: boolean;
|
|
38
39
|
fullWidthEnabled?: boolean;
|
|
39
40
|
uploadErrorHandler?: (state: MediaState) => void;
|
|
40
41
|
waitForMediaUpload?: boolean;
|
|
@@ -108,6 +109,7 @@ export type MediaFloatingToolbarOptions = {
|
|
|
108
109
|
allowAdvancedToolBarOptions?: boolean;
|
|
109
110
|
allowResizingInTables?: boolean;
|
|
110
111
|
allowAltTextOnImages?: boolean;
|
|
112
|
+
allowImagePreview?: boolean;
|
|
111
113
|
altTextValidator?: (value: string) => string[];
|
|
112
114
|
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
113
115
|
fullWidthEnabled?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -59,10 +59,10 @@
|
|
|
59
59
|
"@atlaskit/media-common": "^11.0.0",
|
|
60
60
|
"@atlaskit/media-filmstrip": "^47.0.0",
|
|
61
61
|
"@atlaskit/media-picker": "^66.3.0",
|
|
62
|
-
"@atlaskit/media-ui": "^25.
|
|
63
|
-
"@atlaskit/media-viewer": "^48.
|
|
62
|
+
"@atlaskit/media-ui": "^25.3.0",
|
|
63
|
+
"@atlaskit/media-viewer": "^48.3.0",
|
|
64
64
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
65
|
-
"@atlaskit/primitives": "^3.
|
|
65
|
+
"@atlaskit/primitives": "^3.2.0",
|
|
66
66
|
"@atlaskit/textfield": "^6.0.0",
|
|
67
67
|
"@atlaskit/theme": "^12.6.0",
|
|
68
68
|
"@atlaskit/tokens": "^1.38.0",
|
|
@@ -146,6 +146,9 @@
|
|
|
146
146
|
},
|
|
147
147
|
"platform.editor.media.autoselect-inserted-image_oumto": {
|
|
148
148
|
"type": "boolean"
|
|
149
|
+
},
|
|
150
|
+
"platform.editor.media.preview-in-full-page": {
|
|
151
|
+
"type": "boolean"
|
|
149
152
|
}
|
|
150
153
|
},
|
|
151
154
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0",
|