@atlaskit/editor-plugin-media 1.4.0 → 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 +16 -0
- package/dist/cjs/nodeviews/mediaSingle.js +4 -1
- package/dist/cjs/nodeviews/styles.js +30 -12
- 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/nodeviews/mediaSingle.js +6 -3
- package/dist/es2019/nodeviews/styles.js +24 -16
- 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/nodeviews/mediaSingle.js +6 -3
- package/dist/esm/nodeviews/styles.js +29 -10
- 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/nodeviews/styles.d.ts +3 -2
- package/dist/types/toolbar/utils.d.ts +1 -0
- package/dist/types/types.d.ts +3 -0
- package/dist/types-ts4.5/nodeviews/styles.d.ts +3 -2
- package/dist/types-ts4.5/toolbar/utils.d.ts +1 -0
- package/dist/types-ts4.5/types.d.ts +3 -0
- package/package.json +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
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
|
+
|
|
13
|
+
## 1.4.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#77601](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/77601) [`ee98d2aa7c8a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ee98d2aa7c8a) - [ED-22199] Update media card wrapper so that it applies comments styles according to comment status
|
|
18
|
+
|
|
3
19
|
## 1.4.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -45,6 +45,9 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
45
45
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
46
46
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
47
47
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
|
|
48
|
+
var figureWrapperStyles = (0, _react2.css)({
|
|
49
|
+
margin: 0
|
|
50
|
+
});
|
|
48
51
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
49
52
|
var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
|
|
50
53
|
(0, _inherits2.default)(MediaSingleNode, _Component);
|
|
@@ -421,7 +424,7 @@ var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
421
424
|
var shouldShowPlaceholder = mediaOptions.allowCaptions && node.childCount !== 2 && isSelected && state.selection instanceof _state.NodeSelection;
|
|
422
425
|
var MediaChildren = (0, _react2.jsx)("figure", {
|
|
423
426
|
ref: this.mediaSingleWrapperRef,
|
|
424
|
-
css:
|
|
427
|
+
css: figureWrapperStyles,
|
|
425
428
|
className: _styles.MediaSingleNodeSelector,
|
|
426
429
|
onClick: this.onMediaSingleClicked
|
|
427
430
|
}, (0, _react2.jsx)("div", {
|
|
@@ -4,36 +4,54 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
8
|
-
var
|
|
7
|
+
exports.MediaSingleNodeSelector = exports.MediaInlineNodeSelector = exports.MediaCardWrapper = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _react2 = require("@emotion/react");
|
|
11
11
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
12
|
-
var
|
|
13
|
-
|
|
12
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
13
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /** @jsx jsx */
|
|
14
15
|
var MediaInlineNodeSelector = exports.MediaInlineNodeSelector = 'media-inline-node';
|
|
15
16
|
var MediaSingleNodeSelector = exports.MediaSingleNodeSelector = 'media-single-node';
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
var absoluteDivStyles = (0, _react2.css)({
|
|
18
|
+
position: 'absolute',
|
|
19
|
+
width: '100%',
|
|
20
|
+
height: '100%'
|
|
21
|
+
});
|
|
22
|
+
var forcedDimensionsStyles = (0, _react2.css)({
|
|
23
|
+
width: '100%',
|
|
24
|
+
position: 'relative'
|
|
25
|
+
});
|
|
26
|
+
var boxShadowColorByStatus = {
|
|
27
|
+
draft: "var(--ds-background-accent-yellow-subtle, ".concat(_colors.Y300, ")"),
|
|
28
|
+
focus: "var(--ds-background-accent-yellow-subtle, ".concat(_colors.Y300, ")"),
|
|
29
|
+
blur: "var(--ds-background-accent-yellow-subtler, ".concat(_colors.Y200, ")")
|
|
30
|
+
};
|
|
31
|
+
var commentStatusStyleMap = function commentStatusStyleMap(status) {
|
|
32
|
+
return "3px 3px 0px 0px ".concat(boxShadowColorByStatus[status]);
|
|
33
|
+
};
|
|
19
34
|
var MediaCardWrapper = exports.MediaCardWrapper = function MediaCardWrapper(_ref) {
|
|
20
35
|
var dimensions = _ref.dimensions,
|
|
21
36
|
children = _ref.children,
|
|
22
37
|
selected = _ref.selected,
|
|
23
38
|
_ref$borderWidth = _ref.borderWidth,
|
|
24
39
|
borderWidth = _ref$borderWidth === void 0 ? 0 : _ref$borderWidth,
|
|
25
|
-
onContextMenu = _ref.onContextMenu
|
|
40
|
+
onContextMenu = _ref.onContextMenu,
|
|
41
|
+
commentStatus = _ref.commentStatus;
|
|
26
42
|
var calculatedBorderWidth = selected && borderWidth > 0 ? borderWidth + 1 : borderWidth;
|
|
27
43
|
return (0, _react2.jsx)("div", {
|
|
28
44
|
"data-testid": "media-card-wrapper",
|
|
29
|
-
style: {
|
|
45
|
+
style: _objectSpread({
|
|
30
46
|
borderColor: "var(--custom-palette-color)",
|
|
31
47
|
borderWidth: "".concat(calculatedBorderWidth, "px"),
|
|
32
48
|
borderStyle: 'solid',
|
|
33
49
|
borderRadius: "".concat(calculatedBorderWidth * 2, "px")
|
|
34
|
-
}
|
|
50
|
+
}, commentStatus && {
|
|
51
|
+
boxShadow: "".concat(commentStatusStyleMap(commentStatus))
|
|
52
|
+
})
|
|
35
53
|
}, (0, _react2.jsx)("div", {
|
|
36
|
-
css:
|
|
54
|
+
css: forcedDimensionsStyles,
|
|
37
55
|
style: {
|
|
38
56
|
paddingBottom: "".concat(dimensions.height / dimensions.width * 100, "%")
|
|
39
57
|
},
|
|
@@ -41,6 +59,6 @@ var MediaCardWrapper = exports.MediaCardWrapper = function MediaCardWrapper(_ref
|
|
|
41
59
|
}, borderWidth > 0 && (0, _react2.jsx)(_ui.MediaBorderGapFiller, {
|
|
42
60
|
borderColor: "var(--custom-palette-color)"
|
|
43
61
|
}), (0, _react2.jsx)("div", {
|
|
44
|
-
css:
|
|
62
|
+
css: absoluteDivStyles
|
|
45
63
|
}, children)));
|
|
46
64
|
};
|
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;
|
|
@@ -3,7 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
|
|
5
5
|
import React, { Component } from 'react';
|
|
6
|
-
import { jsx } from '@emotion/react';
|
|
6
|
+
import { css, jsx } from '@emotion/react';
|
|
7
7
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
8
8
|
import { calcMediaSinglePixelWidth, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH, getMaxWidthForNestedNode, MEDIA_SINGLE_GUTTER_SIZE } from '@atlaskit/editor-common/media-single';
|
|
9
9
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
@@ -23,7 +23,10 @@ import ResizableMediaSingleNext from '../ui/ResizableMediaSingle/ResizableMediaS
|
|
|
23
23
|
import { isMediaBlobUrlFromAttrs } from '../utils/media-common';
|
|
24
24
|
import { hasPrivateAttrsChanged } from './helpers';
|
|
25
25
|
import { MediaNodeUpdater } from './mediaNodeUpdater';
|
|
26
|
-
import {
|
|
26
|
+
import { MediaSingleNodeSelector } from './styles';
|
|
27
|
+
const figureWrapperStyles = css({
|
|
28
|
+
margin: 0
|
|
29
|
+
});
|
|
27
30
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
28
31
|
export default class MediaSingleNode extends Component {
|
|
29
32
|
constructor(...args) {
|
|
@@ -334,7 +337,7 @@ export default class MediaSingleNode extends Component {
|
|
|
334
337
|
const shouldShowPlaceholder = mediaOptions.allowCaptions && node.childCount !== 2 && isSelected && state.selection instanceof NodeSelection;
|
|
335
338
|
const MediaChildren = jsx("figure", {
|
|
336
339
|
ref: this.mediaSingleWrapperRef,
|
|
337
|
-
css:
|
|
340
|
+
css: figureWrapperStyles,
|
|
338
341
|
className: MediaSingleNodeSelector,
|
|
339
342
|
onClick: this.onMediaSingleClicked
|
|
340
343
|
}, jsx("div", {
|
|
@@ -2,26 +2,31 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
4
|
import { MediaBorderGapFiller } from '@atlaskit/editor-common/ui';
|
|
5
|
+
import { Y200, Y300 } from '@atlaskit/theme/colors';
|
|
5
6
|
export const MediaInlineNodeSelector = 'media-inline-node';
|
|
6
7
|
export const MediaSingleNodeSelector = 'media-single-node';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
const absoluteDivStyles = css({
|
|
9
|
+
position: 'absolute',
|
|
10
|
+
width: '100%',
|
|
11
|
+
height: '100%'
|
|
12
|
+
});
|
|
13
|
+
const forcedDimensionsStyles = css({
|
|
14
|
+
width: '100%',
|
|
15
|
+
position: 'relative'
|
|
16
|
+
});
|
|
17
|
+
const boxShadowColorByStatus = {
|
|
18
|
+
draft: `var(--ds-background-accent-yellow-subtle, ${Y300})`,
|
|
19
|
+
focus: `var(--ds-background-accent-yellow-subtle, ${Y300})`,
|
|
20
|
+
blur: `var(--ds-background-accent-yellow-subtler, ${Y200})`
|
|
21
|
+
};
|
|
22
|
+
const commentStatusStyleMap = status => `3px 3px 0px 0px ${boxShadowColorByStatus[status]}`;
|
|
19
23
|
export const MediaCardWrapper = ({
|
|
20
24
|
dimensions,
|
|
21
25
|
children,
|
|
22
26
|
selected,
|
|
23
27
|
borderWidth = 0,
|
|
24
|
-
onContextMenu
|
|
28
|
+
onContextMenu,
|
|
29
|
+
commentStatus
|
|
25
30
|
}) => {
|
|
26
31
|
const calculatedBorderWidth = selected && borderWidth > 0 ? borderWidth + 1 : borderWidth;
|
|
27
32
|
return jsx("div", {
|
|
@@ -30,10 +35,13 @@ export const MediaCardWrapper = ({
|
|
|
30
35
|
borderColor: `var(--custom-palette-color)`,
|
|
31
36
|
borderWidth: `${calculatedBorderWidth}px`,
|
|
32
37
|
borderStyle: 'solid',
|
|
33
|
-
borderRadius: `${calculatedBorderWidth * 2}px
|
|
38
|
+
borderRadius: `${calculatedBorderWidth * 2}px`,
|
|
39
|
+
...(commentStatus && {
|
|
40
|
+
boxShadow: `${commentStatusStyleMap(commentStatus)}`
|
|
41
|
+
})
|
|
34
42
|
}
|
|
35
43
|
}, jsx("div", {
|
|
36
|
-
css:
|
|
44
|
+
css: forcedDimensionsStyles,
|
|
37
45
|
style: {
|
|
38
46
|
paddingBottom: `${dimensions.height / dimensions.width * 100}%`
|
|
39
47
|
},
|
|
@@ -41,6 +49,6 @@ export const MediaCardWrapper = ({
|
|
|
41
49
|
}, borderWidth > 0 && jsx(MediaBorderGapFiller, {
|
|
42
50
|
borderColor: `var(--custom-palette-color)`
|
|
43
51
|
}), jsx("div", {
|
|
44
|
-
css:
|
|
52
|
+
css: absoluteDivStyles
|
|
45
53
|
}, children)));
|
|
46
54
|
};
|
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);
|
|
@@ -16,7 +16,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
16
16
|
/** @jsx jsx */
|
|
17
17
|
|
|
18
18
|
import React, { Component } from 'react';
|
|
19
|
-
import { jsx } from '@emotion/react';
|
|
19
|
+
import { css, jsx } from '@emotion/react';
|
|
20
20
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
21
21
|
import { calcMediaSinglePixelWidth, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH, getMaxWidthForNestedNode, MEDIA_SINGLE_GUTTER_SIZE } from '@atlaskit/editor-common/media-single';
|
|
22
22
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
@@ -36,7 +36,10 @@ import ResizableMediaSingleNext from '../ui/ResizableMediaSingle/ResizableMediaS
|
|
|
36
36
|
import { isMediaBlobUrlFromAttrs } from '../utils/media-common';
|
|
37
37
|
import { hasPrivateAttrsChanged } from './helpers';
|
|
38
38
|
import { MediaNodeUpdater } from './mediaNodeUpdater';
|
|
39
|
-
import {
|
|
39
|
+
import { MediaSingleNodeSelector } from './styles';
|
|
40
|
+
var figureWrapperStyles = css({
|
|
41
|
+
margin: 0
|
|
42
|
+
});
|
|
40
43
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
41
44
|
var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
42
45
|
_inherits(MediaSingleNode, _Component);
|
|
@@ -413,7 +416,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
413
416
|
var shouldShowPlaceholder = mediaOptions.allowCaptions && node.childCount !== 2 && isSelected && state.selection instanceof NodeSelection;
|
|
414
417
|
var MediaChildren = jsx("figure", {
|
|
415
418
|
ref: this.mediaSingleWrapperRef,
|
|
416
|
-
css:
|
|
419
|
+
css: figureWrapperStyles,
|
|
417
420
|
className: MediaSingleNodeSelector,
|
|
418
421
|
onClick: this.onMediaSingleClicked
|
|
419
422
|
}, jsx("div", {
|
|
@@ -1,32 +1,51 @@
|
|
|
1
|
-
import
|
|
2
|
-
var
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
4
|
/** @jsx jsx */
|
|
4
5
|
import React from 'react';
|
|
5
6
|
import { css, jsx } from '@emotion/react';
|
|
6
7
|
import { MediaBorderGapFiller } from '@atlaskit/editor-common/ui';
|
|
8
|
+
import { Y200, Y300 } from '@atlaskit/theme/colors';
|
|
7
9
|
export var MediaInlineNodeSelector = 'media-inline-node';
|
|
8
10
|
export var MediaSingleNodeSelector = 'media-single-node';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
var absoluteDivStyles = css({
|
|
12
|
+
position: 'absolute',
|
|
13
|
+
width: '100%',
|
|
14
|
+
height: '100%'
|
|
15
|
+
});
|
|
16
|
+
var forcedDimensionsStyles = css({
|
|
17
|
+
width: '100%',
|
|
18
|
+
position: 'relative'
|
|
19
|
+
});
|
|
20
|
+
var boxShadowColorByStatus = {
|
|
21
|
+
draft: "var(--ds-background-accent-yellow-subtle, ".concat(Y300, ")"),
|
|
22
|
+
focus: "var(--ds-background-accent-yellow-subtle, ".concat(Y300, ")"),
|
|
23
|
+
blur: "var(--ds-background-accent-yellow-subtler, ".concat(Y200, ")")
|
|
24
|
+
};
|
|
25
|
+
var commentStatusStyleMap = function commentStatusStyleMap(status) {
|
|
26
|
+
return "3px 3px 0px 0px ".concat(boxShadowColorByStatus[status]);
|
|
27
|
+
};
|
|
12
28
|
export var MediaCardWrapper = function MediaCardWrapper(_ref) {
|
|
13
29
|
var dimensions = _ref.dimensions,
|
|
14
30
|
children = _ref.children,
|
|
15
31
|
selected = _ref.selected,
|
|
16
32
|
_ref$borderWidth = _ref.borderWidth,
|
|
17
33
|
borderWidth = _ref$borderWidth === void 0 ? 0 : _ref$borderWidth,
|
|
18
|
-
onContextMenu = _ref.onContextMenu
|
|
34
|
+
onContextMenu = _ref.onContextMenu,
|
|
35
|
+
commentStatus = _ref.commentStatus;
|
|
19
36
|
var calculatedBorderWidth = selected && borderWidth > 0 ? borderWidth + 1 : borderWidth;
|
|
20
37
|
return jsx("div", {
|
|
21
38
|
"data-testid": "media-card-wrapper",
|
|
22
|
-
style: {
|
|
39
|
+
style: _objectSpread({
|
|
23
40
|
borderColor: "var(--custom-palette-color)",
|
|
24
41
|
borderWidth: "".concat(calculatedBorderWidth, "px"),
|
|
25
42
|
borderStyle: 'solid',
|
|
26
43
|
borderRadius: "".concat(calculatedBorderWidth * 2, "px")
|
|
27
|
-
}
|
|
44
|
+
}, commentStatus && {
|
|
45
|
+
boxShadow: "".concat(commentStatusStyleMap(commentStatus))
|
|
46
|
+
})
|
|
28
47
|
}, jsx("div", {
|
|
29
|
-
css:
|
|
48
|
+
css: forcedDimensionsStyles,
|
|
30
49
|
style: {
|
|
31
50
|
paddingBottom: "".concat(dimensions.height / dimensions.width * 100, "%")
|
|
32
51
|
},
|
|
@@ -34,6 +53,6 @@ export var MediaCardWrapper = function MediaCardWrapper(_ref) {
|
|
|
34
53
|
}, borderWidth > 0 && jsx(MediaBorderGapFiller, {
|
|
35
54
|
borderColor: "var(--custom-palette-color)"
|
|
36
55
|
}), jsx("div", {
|
|
37
|
-
css:
|
|
56
|
+
css: absoluteDivStyles
|
|
38
57
|
}, children)));
|
|
39
58
|
};
|
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;
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
4
|
import type { NumericalCardDimensions } from '@atlaskit/media-card';
|
|
5
|
+
import type { CommentStatus } from '../types';
|
|
5
6
|
export declare const MediaInlineNodeSelector = "media-inline-node";
|
|
6
7
|
export declare const MediaSingleNodeSelector = "media-single-node";
|
|
7
|
-
export declare const figureWrapper: import("@emotion/react").SerializedStyles;
|
|
8
8
|
type MediaCardWrapperProps = {
|
|
9
9
|
dimensions: NumericalCardDimensions;
|
|
10
10
|
children: React.ReactNode;
|
|
11
11
|
selected?: boolean;
|
|
12
12
|
borderWidth?: number;
|
|
13
13
|
onContextMenu?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
14
|
+
commentStatus?: CommentStatus;
|
|
14
15
|
};
|
|
15
|
-
export declare const MediaCardWrapper: ({ dimensions, children, selected, borderWidth, onContextMenu, }: MediaCardWrapperProps) => jsx.JSX.Element;
|
|
16
|
+
export declare const MediaCardWrapper: ({ dimensions, children, selected, borderWidth, onContextMenu, commentStatus, }: MediaCardWrapperProps) => jsx.JSX.Element;
|
|
16
17
|
export {};
|
|
@@ -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
|
@@ -12,6 +12,7 @@ interface PlaceholderTextOptions {
|
|
|
12
12
|
allowInserting?: boolean;
|
|
13
13
|
}
|
|
14
14
|
export type MediaStateStatus = 'unknown' | 'ready' | 'cancelled' | 'preview' | 'error' | 'mobile-upload-end';
|
|
15
|
+
export type CommentStatus = 'draft' | 'focus' | 'blur';
|
|
15
16
|
export type MediaSingleWithType = 'pixel' | 'percentage';
|
|
16
17
|
export interface MediaOptions {
|
|
17
18
|
provider?: Providers['mediaProvider'];
|
|
@@ -34,6 +35,7 @@ export interface MediaOptions {
|
|
|
34
35
|
allowRemoteDimensionsFetch?: boolean;
|
|
35
36
|
allowDropzoneDropLine?: boolean;
|
|
36
37
|
allowMarkingUploadsAsIncomplete?: boolean;
|
|
38
|
+
allowImagePreview?: boolean;
|
|
37
39
|
fullWidthEnabled?: boolean;
|
|
38
40
|
uploadErrorHandler?: (state: MediaState) => void;
|
|
39
41
|
waitForMediaUpload?: boolean;
|
|
@@ -107,6 +109,7 @@ export type MediaFloatingToolbarOptions = {
|
|
|
107
109
|
allowAdvancedToolBarOptions?: boolean;
|
|
108
110
|
allowResizingInTables?: boolean;
|
|
109
111
|
allowAltTextOnImages?: boolean;
|
|
112
|
+
allowImagePreview?: boolean;
|
|
110
113
|
altTextValidator?: (value: string) => string[];
|
|
111
114
|
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
112
115
|
fullWidthEnabled?: boolean;
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
4
|
import type { NumericalCardDimensions } from '@atlaskit/media-card';
|
|
5
|
+
import type { CommentStatus } from '../types';
|
|
5
6
|
export declare const MediaInlineNodeSelector = "media-inline-node";
|
|
6
7
|
export declare const MediaSingleNodeSelector = "media-single-node";
|
|
7
|
-
export declare const figureWrapper: import("@emotion/react").SerializedStyles;
|
|
8
8
|
type MediaCardWrapperProps = {
|
|
9
9
|
dimensions: NumericalCardDimensions;
|
|
10
10
|
children: React.ReactNode;
|
|
11
11
|
selected?: boolean;
|
|
12
12
|
borderWidth?: number;
|
|
13
13
|
onContextMenu?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
14
|
+
commentStatus?: CommentStatus;
|
|
14
15
|
};
|
|
15
|
-
export declare const MediaCardWrapper: ({ dimensions, children, selected, borderWidth, onContextMenu, }: MediaCardWrapperProps) => jsx.JSX.Element;
|
|
16
|
+
export declare const MediaCardWrapper: ({ dimensions, children, selected, borderWidth, onContextMenu, commentStatus, }: MediaCardWrapperProps) => jsx.JSX.Element;
|
|
16
17
|
export {};
|
|
@@ -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;
|
|
@@ -12,6 +12,7 @@ interface PlaceholderTextOptions {
|
|
|
12
12
|
allowInserting?: boolean;
|
|
13
13
|
}
|
|
14
14
|
export type MediaStateStatus = 'unknown' | 'ready' | 'cancelled' | 'preview' | 'error' | 'mobile-upload-end';
|
|
15
|
+
export type CommentStatus = 'draft' | 'focus' | 'blur';
|
|
15
16
|
export type MediaSingleWithType = 'pixel' | 'percentage';
|
|
16
17
|
export interface MediaOptions {
|
|
17
18
|
provider?: Providers['mediaProvider'];
|
|
@@ -34,6 +35,7 @@ export interface MediaOptions {
|
|
|
34
35
|
allowRemoteDimensionsFetch?: boolean;
|
|
35
36
|
allowDropzoneDropLine?: boolean;
|
|
36
37
|
allowMarkingUploadsAsIncomplete?: boolean;
|
|
38
|
+
allowImagePreview?: boolean;
|
|
37
39
|
fullWidthEnabled?: boolean;
|
|
38
40
|
uploadErrorHandler?: (state: MediaState) => void;
|
|
39
41
|
waitForMediaUpload?: boolean;
|
|
@@ -107,6 +109,7 @@ export type MediaFloatingToolbarOptions = {
|
|
|
107
109
|
allowAdvancedToolBarOptions?: boolean;
|
|
108
110
|
allowResizingInTables?: boolean;
|
|
109
111
|
allowAltTextOnImages?: boolean;
|
|
112
|
+
allowImagePreview?: boolean;
|
|
110
113
|
altTextValidator?: (value: string) => string[];
|
|
111
114
|
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
112
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",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@atlaskit/analytics-namespaced-context": "^6.9.0",
|
|
38
38
|
"@atlaskit/analytics-next": "^9.2.0",
|
|
39
39
|
"@atlaskit/button": "^17.6.0",
|
|
40
|
-
"@atlaskit/editor-common": "^78.
|
|
40
|
+
"@atlaskit/editor-common": "^78.9.0",
|
|
41
41
|
"@atlaskit/editor-palette": "1.5.2",
|
|
42
42
|
"@atlaskit/editor-plugin-analytics": "^1.0.0",
|
|
43
43
|
"@atlaskit/editor-plugin-decorations": "^1.0.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",
|