@atlaskit/media-card 70.9.0 → 72.0.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 +69 -0
- package/dist/cjs/errors.js +109 -6
- package/dist/cjs/files/cardImageView/index.js +58 -89
- package/dist/cjs/files/index.js +0 -6
- package/dist/cjs/index.js +16 -6
- package/dist/cjs/root/card/cardAnalytics.js +33 -19
- package/dist/cjs/root/card/cardConstants.js +8 -0
- package/dist/cjs/root/card/cardSSRView.js +114 -0
- package/dist/cjs/root/card/cardState.js +50 -0
- package/dist/cjs/root/card/getCardPreview/cache.js +49 -0
- package/dist/cjs/root/card/getCardPreview/filePreviewStatus.js +50 -0
- package/dist/cjs/root/card/getCardPreview/helpers.js +215 -0
- package/dist/cjs/root/card/getCardPreview/index.js +225 -0
- package/dist/cjs/root/card/getCardStatus.js +16 -21
- package/dist/cjs/root/card/index.js +339 -398
- package/dist/cjs/root/cardView.js +108 -56
- package/dist/cjs/root/index.js +9 -1
- package/dist/cjs/root/inline/loader.js +22 -21
- package/dist/cjs/root/inline/{inlineMediaCard.js → mediaInlineCard.js} +66 -24
- package/dist/cjs/root/inlinePlayer.js +5 -15
- package/dist/cjs/root/ui/Breakpoint.js +13 -0
- package/dist/cjs/root/ui/common.js +5 -11
- package/dist/cjs/root/ui/iconMessage/index.js +17 -9
- package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +32 -115
- package/dist/cjs/root/ui/loadingRateLimited/loadingRateLimited.js +2 -2
- package/dist/cjs/root/ui/progressBar/progressBar.js +2 -2
- package/dist/cjs/root/ui/progressBar/styled.js +3 -1
- package/dist/cjs/root/ui/styled.js +17 -80
- package/dist/cjs/root/ui/styledSSR.js +108 -0
- package/dist/cjs/root/ui/titleBox/failedTitleBox.js +7 -3
- package/dist/cjs/root/ui/titleBox/styled.js +3 -1
- package/dist/cjs/utils/analytics.js +26 -43
- package/dist/cjs/utils/dimensionComparer.js +1 -1
- package/dist/cjs/utils/document.js +12 -0
- package/dist/cjs/utils/getDataURIDimension.js +13 -2
- package/dist/cjs/utils/metadata.js +11 -3
- package/dist/cjs/utils/objectURLCache.js +6 -0
- package/dist/cjs/utils/resizeModeToMediaImageProps.js +13 -0
- package/dist/cjs/utils/shouldDisplayImageThumbnail.js +1 -1
- package/dist/cjs/utils/videoSnapshot.js +45 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/errors.js +52 -2
- package/dist/es2019/files/cardImageView/index.js +12 -46
- package/dist/es2019/files/index.js +1 -1
- package/dist/es2019/index.js +3 -3
- package/dist/es2019/root/card/cardAnalytics.js +23 -17
- package/dist/es2019/root/card/cardConstants.js +1 -0
- package/dist/es2019/root/card/cardSSRView.js +93 -0
- package/dist/es2019/root/card/cardState.js +26 -0
- package/dist/es2019/root/card/getCardPreview/cache.js +29 -0
- package/dist/es2019/root/card/getCardPreview/filePreviewStatus.js +35 -0
- package/dist/es2019/root/card/getCardPreview/helpers.js +83 -0
- package/dist/es2019/root/card/getCardPreview/index.js +129 -0
- package/dist/es2019/root/card/getCardStatus.js +11 -15
- package/dist/es2019/root/card/index.js +292 -276
- package/dist/es2019/root/cardView.js +107 -53
- package/dist/es2019/root/index.js +2 -1
- package/dist/es2019/root/inline/loader.js +16 -15
- package/dist/es2019/root/inline/mediaInlineCard.js +127 -0
- package/dist/es2019/root/inlinePlayer.js +5 -13
- package/dist/es2019/root/ui/Breakpoint.js +6 -0
- package/dist/es2019/root/ui/common.js +1 -7
- package/dist/es2019/root/ui/iconMessage/index.js +10 -6
- package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +22 -74
- package/dist/es2019/root/ui/loadingRateLimited/loadingRateLimited.js +1 -1
- package/dist/es2019/root/ui/progressBar/progressBar.js +1 -1
- package/dist/es2019/root/ui/progressBar/styled.js +2 -1
- package/dist/es2019/root/ui/styled.js +4 -64
- package/dist/es2019/root/ui/styledSSR.js +93 -0
- package/dist/es2019/root/ui/titleBox/failedTitleBox.js +5 -3
- package/dist/es2019/root/ui/titleBox/styled.js +2 -1
- package/dist/es2019/utils/analytics.js +29 -40
- package/dist/es2019/utils/dimensionComparer.js +1 -1
- package/dist/es2019/utils/document.js +1 -0
- package/dist/es2019/utils/getDataURIDimension.js +8 -0
- package/dist/es2019/utils/metadata.js +12 -4
- package/dist/es2019/utils/objectURLCache.js +5 -0
- package/dist/es2019/utils/resizeModeToMediaImageProps.js +6 -0
- package/dist/es2019/utils/shouldDisplayImageThumbnail.js +1 -1
- package/dist/es2019/utils/videoSnapshot.js +7 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/errors.js +85 -2
- package/dist/esm/files/cardImageView/index.js +55 -87
- package/dist/esm/files/index.js +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/root/card/cardAnalytics.js +23 -18
- package/dist/esm/root/card/cardConstants.js +1 -0
- package/dist/esm/root/card/cardSSRView.js +92 -0
- package/dist/esm/root/card/cardState.js +32 -0
- package/dist/esm/root/card/getCardPreview/cache.js +33 -0
- package/dist/esm/root/card/getCardPreview/filePreviewStatus.js +35 -0
- package/dist/esm/root/card/getCardPreview/helpers.js +194 -0
- package/dist/esm/root/card/getCardPreview/index.js +174 -0
- package/dist/esm/root/card/getCardStatus.js +13 -17
- package/dist/esm/root/card/index.js +349 -401
- package/dist/esm/root/cardView.js +105 -52
- package/dist/esm/root/index.js +2 -1
- package/dist/esm/root/inline/loader.js +23 -22
- package/dist/esm/root/inline/{inlineMediaCard.js → mediaInlineCard.js} +62 -22
- package/dist/esm/root/inlinePlayer.js +5 -13
- package/dist/esm/root/ui/Breakpoint.js +6 -0
- package/dist/esm/root/ui/common.js +1 -7
- package/dist/esm/root/ui/iconMessage/index.js +12 -7
- package/dist/esm/root/ui/imageRenderer/imageRenderer.js +24 -106
- package/dist/esm/root/ui/loadingRateLimited/loadingRateLimited.js +1 -1
- package/dist/esm/root/ui/progressBar/progressBar.js +1 -1
- package/dist/esm/root/ui/progressBar/styled.js +2 -1
- package/dist/esm/root/ui/styled.js +13 -61
- package/dist/esm/root/ui/styledSSR.js +76 -0
- package/dist/esm/root/ui/titleBox/failedTitleBox.js +6 -3
- package/dist/esm/root/ui/titleBox/styled.js +2 -1
- package/dist/esm/utils/analytics.js +22 -35
- package/dist/esm/utils/dimensionComparer.js +1 -1
- package/dist/esm/utils/document.js +3 -0
- package/dist/esm/utils/getDataURIDimension.js +8 -0
- package/dist/esm/utils/metadata.js +12 -4
- package/dist/esm/utils/objectURLCache.js +6 -0
- package/dist/esm/utils/resizeModeToMediaImageProps.js +6 -0
- package/dist/esm/utils/shouldDisplayImageThumbnail.js +1 -1
- package/dist/esm/utils/videoSnapshot.js +31 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/__tests_external__/page-objects/MediaCard.d.ts +4 -3
- package/dist/types/errors.d.ts +24 -2
- package/dist/types/files/cardImageView/index.d.ts +5 -12
- package/dist/types/files/cardImageView/styled.d.ts +1 -1
- package/dist/types/files/index.d.ts +1 -1
- package/dist/types/index.d.ts +9 -12
- package/dist/types/root/card/cardAnalytics.d.ts +5 -7
- package/dist/types/root/card/cardConstants.d.ts +1 -0
- package/dist/types/root/card/cardSSRView.d.ts +13 -0
- package/dist/types/root/card/cardState.d.ts +5 -0
- package/dist/types/root/card/getCardPreview/cache.d.ts +18 -0
- package/dist/types/root/card/getCardPreview/filePreviewStatus.d.ts +5 -0
- package/dist/types/root/card/getCardPreview/helpers.d.ts +9 -0
- package/dist/types/root/card/getCardPreview/index.d.ts +44 -0
- package/dist/types/root/card/getCardStatus.d.ts +4 -14
- package/dist/types/root/card/index.d.ts +17 -21
- package/dist/types/root/cardView.d.ts +12 -8
- package/dist/types/root/index.d.ts +1 -0
- package/dist/types/root/inline/loader.d.ts +8 -8
- package/dist/types/root/inline/{inlineMediaCard.d.ts → mediaInlineCard.d.ts} +4 -4
- package/dist/types/root/inlinePlayer.d.ts +1 -1
- package/dist/types/root/ui/Breakpoint.d.ts +4 -0
- package/dist/types/root/ui/common.d.ts +1 -4
- package/dist/types/root/ui/iconMessage/index.d.ts +7 -2
- package/dist/types/root/ui/iconWrapper/styled.d.ts +1 -1
- package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +2 -16
- package/dist/types/root/ui/loadingRateLimited/loadingRateLimited.d.ts +1 -1
- package/dist/types/root/ui/loadingRateLimited/styled.d.ts +1 -1
- package/dist/types/root/ui/progressBar/progressBar.d.ts +1 -1
- package/dist/types/root/ui/progressBar/styled.d.ts +1 -1
- package/dist/types/root/ui/styled.d.ts +3 -10
- package/dist/types/root/ui/styledSSR.d.ts +16 -0
- package/dist/types/root/ui/titleBox/failedTitleBox.d.ts +3 -1
- package/dist/types/root/ui/titleBox/styled.d.ts +1 -1
- package/dist/types/root/ui/titleBox/titleBox.d.ts +1 -1
- package/dist/types/types.d.ts +15 -1
- package/dist/types/utils/analytics.d.ts +20 -21
- package/dist/types/utils/cardDimensions.d.ts +5 -1
- package/dist/types/utils/dimensionComparer.d.ts +1 -1
- package/dist/types/utils/document.d.ts +2 -0
- package/dist/types/utils/getDataURIDimension.d.ts +3 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/lazyContent/styled.d.ts +1 -1
- package/dist/types/utils/lightCards/types.d.ts +1 -1
- package/dist/types/utils/metadata.d.ts +2 -2
- package/dist/types/utils/objectURLCache.d.ts +2 -1
- package/dist/types/utils/resizeModeToMediaImageProps.d.ts +5 -0
- package/dist/types/utils/shouldDisplayImageThumbnail.d.ts +1 -1
- package/dist/types/utils/videoSnapshot.d.ts +1 -0
- package/example-helpers/index.tsx +21 -0
- package/package.json +19 -17
- package/dist/cjs/root/card/getCardPreview.js +0 -173
- package/dist/cjs/utils/fileAttributesContext.js +0 -40
- package/dist/es2019/root/card/getCardPreview.js +0 -86
- package/dist/es2019/root/inline/inlineMediaCard.js +0 -92
- package/dist/es2019/utils/fileAttributesContext.js +0 -19
- package/dist/esm/root/card/getCardPreview.js +0 -153
- package/dist/esm/utils/fileAttributesContext.js +0 -18
- package/dist/types/root/card/getCardPreview.d.ts +0 -8
- package/dist/types/utils/fileAttributesContext.d.ts +0 -10
|
@@ -1,80 +1,28 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import
|
|
3
|
-
import React from 'react';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
4
3
|
import { MediaImage } from '@atlaskit/media-ui';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const {
|
|
18
|
-
createAnalyticsEvent,
|
|
19
|
-
fileAttributes
|
|
20
|
-
} = this.props;
|
|
21
|
-
|
|
22
|
-
if (fileAttributes && this.shouldFireEvent(RenderEventAction.SUCCEEDED)) {
|
|
23
|
-
fireMediaCardEvent(getRenderSucceededEventPayload(fileAttributes), createAnalyticsEvent);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
_defineProperty(this, "onImageError", () => {
|
|
28
|
-
const {
|
|
29
|
-
onImageError,
|
|
30
|
-
fileAttributes
|
|
31
|
-
} = this.props;
|
|
32
|
-
onImageError && onImageError();
|
|
33
|
-
|
|
34
|
-
if (fileAttributes && this.shouldFireEvent(RenderEventAction.FAILED)) {
|
|
35
|
-
const {
|
|
36
|
-
createAnalyticsEvent,
|
|
37
|
-
mediaItemType
|
|
38
|
-
} = this.props;
|
|
39
|
-
|
|
40
|
-
if (mediaItemType === 'file') {
|
|
41
|
-
fireMediaCardEvent(getRenderFailedFileUriPayload(fileAttributes), createAnalyticsEvent);
|
|
42
|
-
} else if (mediaItemType === 'external-image') {
|
|
43
|
-
fireMediaCardEvent(getRenderFailedExternalUriPayload(fileAttributes), createAnalyticsEvent);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
_defineProperty(this, "shouldFireEvent", action => !this.lastAnalyticsAction || this.lastAnalyticsAction !== action);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
componentDidMount() {
|
|
4
|
+
import { resizeModeToMediaImageProps } from '../../../utils/resizeModeToMediaImageProps';
|
|
5
|
+
export const ImageRenderer = ({
|
|
6
|
+
dataURI,
|
|
7
|
+
previewOrientation,
|
|
8
|
+
alt,
|
|
9
|
+
resizeMode,
|
|
10
|
+
onImageLoad,
|
|
11
|
+
onImageError,
|
|
12
|
+
onDisplayImage,
|
|
13
|
+
mediaType
|
|
14
|
+
}) => {
|
|
15
|
+
useEffect(() => {
|
|
52
16
|
// TODO: trigger accordingly with the succeeded event. This could be a breaking change
|
|
53
|
-
const {
|
|
54
|
-
onDisplayImage,
|
|
55
|
-
mediaType
|
|
56
|
-
} = this.props;
|
|
57
|
-
|
|
58
17
|
if (mediaType === 'image' && onDisplayImage) {
|
|
59
18
|
onDisplayImage();
|
|
60
19
|
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return /*#__PURE__*/React.createElement(MediaImage, _extends({
|
|
71
|
-
dataURI: dataURI,
|
|
72
|
-
alt: alt,
|
|
73
|
-
previewOrientation: previewOrientation,
|
|
74
|
-
onImageLoad: this.onImageLoad,
|
|
75
|
-
onImageError: this.onImageError
|
|
76
|
-
}, resizeModeToMediaImageProps(resizeMode)));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
export const ImageRenderer = withAnalyticsEvents()(withFileAttributes(ImageRendererBase));
|
|
20
|
+
}, [mediaType, onDisplayImage]);
|
|
21
|
+
return /*#__PURE__*/React.createElement(MediaImage, _extends({
|
|
22
|
+
dataURI: dataURI,
|
|
23
|
+
alt: alt,
|
|
24
|
+
previewOrientation: previewOrientation,
|
|
25
|
+
onImageLoad: onImageLoad,
|
|
26
|
+
onImageError: onImageError
|
|
27
|
+
}, resizeModeToMediaImageProps(resizeMode)));
|
|
28
|
+
};
|
|
@@ -3,7 +3,7 @@ import { errorIcon } from '@atlaskit/media-ui/errorIcon';
|
|
|
3
3
|
import { WarningIconWrapper, LoadingRateLimitedContainer, CouldntLoadWrapper, ErrorWrapper, LoadingRateLimitedTextWrapper } from './styled';
|
|
4
4
|
import { messages } from '@atlaskit/media-ui';
|
|
5
5
|
import { FormattedMessage } from 'react-intl';
|
|
6
|
-
import { Breakpoint } from '../
|
|
6
|
+
import { Breakpoint } from '../Breakpoint';
|
|
7
7
|
export const LoadingRateLimited = ({
|
|
8
8
|
breakpoint = Breakpoint.SMALL,
|
|
9
9
|
positionBottom = true
|
|
@@ -2,7 +2,8 @@ import styled from 'styled-components';
|
|
|
2
2
|
import { borderRadius } from '@atlaskit/media-ui';
|
|
3
3
|
import { rgba } from '../../../styles/mixins';
|
|
4
4
|
import { N0, N400 } from '@atlaskit/theme/colors';
|
|
5
|
-
import {
|
|
5
|
+
import { getTitleBoxHeight, responsiveSettings } from '../common';
|
|
6
|
+
import { Breakpoint } from '../Breakpoint';
|
|
6
7
|
const height = 3;
|
|
7
8
|
const padding = 1;
|
|
8
9
|
const width = 95; // %
|
|
@@ -1,30 +1,11 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
import { getCSSUnitValue } from '../../utils/getCSSUnitValue';
|
|
3
3
|
import { getDefaultCardDimensions } from '../../utils/cardDimensions';
|
|
4
|
-
import { fontFamily } from '@atlaskit/theme/constants';
|
|
5
|
-
import { borderRadius } from '@atlaskit/media-ui';
|
|
6
|
-
import { N20, N60A } from '@atlaskit/theme/colors';
|
|
7
|
-
import { akEditorSelectedBoxShadow } from '@atlaskit/editor-shared-styles/consts';
|
|
8
4
|
import { hideNativeBrowserTextSelectionStyles } from '@atlaskit/editor-shared-styles/selection';
|
|
9
|
-
import { transition } from '../../styles';
|
|
10
5
|
import { tickBoxClassName, tickboxFixedStyles } from './tickBox/styled';
|
|
11
|
-
import { fixedBlanketStyles, blanketClassName } from './blanket/styled';
|
|
12
6
|
import { fixedActionBarStyles, actionsBarClassName } from './actionsBar/styled';
|
|
13
7
|
import { fixedPlayButtonStyles, playButtonClassName } from './playButton/styled';
|
|
14
|
-
import {
|
|
15
|
-
const breakpointSizes = [[Breakpoint.SMALL, 599], [Breakpoint.LARGE, Infinity]];
|
|
16
|
-
export const calcBreakpointSize = (wrapperWidth = 0) => {
|
|
17
|
-
const [breakpoint] = breakpointSizes.find(([_breakpoint, limit]) => wrapperWidth <= limit) || [Breakpoint.SMALL];
|
|
18
|
-
return breakpoint;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const generateResponsiveStyles = (breakpoint = Breakpoint.SMALL) => {
|
|
22
|
-
const setting = responsiveSettings[breakpoint];
|
|
23
|
-
return `
|
|
24
|
-
font-size: ${setting.fontSize}px;
|
|
25
|
-
line-height: ${setting.lineHeight}px;
|
|
26
|
-
`;
|
|
27
|
-
};
|
|
8
|
+
import { SSRFileExperienceWrapper } from './styledSSR';
|
|
28
9
|
|
|
29
10
|
const getWrapperDimensions = (dimensions, appearance) => {
|
|
30
11
|
const {
|
|
@@ -41,19 +22,8 @@ const getWrapperDimensions = (dimensions, appearance) => {
|
|
|
41
22
|
height: ${getCSSUnitValue(height || defaultHeight)};
|
|
42
23
|
max-height: 100%;
|
|
43
24
|
`;
|
|
44
|
-
}; // This is a trick to simulate the blue border without affecting the dimensions.
|
|
45
|
-
// CSS outline has no 'radius', therefore we can't achieve the same effect with it
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const getWrapperShadow = (disableOverlay, selected) => {
|
|
49
|
-
const withOverlayShadow = !disableOverlay ? `0 1px 1px ${N60A}, 0 0 1px 0 ${N60A}` : '';
|
|
50
|
-
const selectedShadow = selected ? akEditorSelectedBoxShadow : '';
|
|
51
|
-
const shadow = [selectedShadow, withOverlayShadow].filter(Boolean).join(', ');
|
|
52
|
-
return shadow ? `box-shadow: ${shadow};` : '';
|
|
53
25
|
};
|
|
54
26
|
|
|
55
|
-
const getCursorStyle = shouldUsePointerCursor => `cursor: ${shouldUsePointerCursor ? 'pointer' : 'default'};`;
|
|
56
|
-
|
|
57
27
|
const getClickablePlayButtonStyles = isPlayButtonClickable => {
|
|
58
28
|
if (!isPlayButtonClickable) {
|
|
59
29
|
return '';
|
|
@@ -78,40 +48,20 @@ const getSelectableTickBoxStyles = isTickBoxSelectable => {
|
|
|
78
48
|
`;
|
|
79
49
|
};
|
|
80
50
|
|
|
81
|
-
export const NewFileExperienceWrapper = styled
|
|
51
|
+
export const NewFileExperienceWrapper = styled(SSRFileExperienceWrapper)`
|
|
82
52
|
${({
|
|
83
|
-
breakpoint,
|
|
84
53
|
dimensions,
|
|
85
54
|
appearance,
|
|
86
|
-
shouldUsePointerCursor,
|
|
87
|
-
disableOverlay,
|
|
88
|
-
displayBackground,
|
|
89
|
-
selected,
|
|
90
55
|
isPlayButtonClickable,
|
|
91
56
|
isTickBoxSelectable,
|
|
92
57
|
shouldDisplayTooltip
|
|
93
58
|
}) => `
|
|
94
|
-
${transition()}
|
|
95
|
-
box-sizing: border-box;
|
|
96
|
-
* {
|
|
97
|
-
box-sizing: border-box;
|
|
98
|
-
}
|
|
99
|
-
position: relative;
|
|
100
|
-
font-family: ${fontFamily()};
|
|
101
|
-
${getWrapperDimensions(dimensions, appearance)}
|
|
102
|
-
${displayBackground ? `background-color: ${N20};` : ''}
|
|
103
|
-
${borderRadius}
|
|
104
|
-
${getCursorStyle(shouldUsePointerCursor)}
|
|
105
|
-
${getWrapperShadow(disableOverlay, selected)}
|
|
106
|
-
${generateResponsiveStyles(breakpoint)}
|
|
107
59
|
${hideNativeBrowserTextSelectionStyles}
|
|
108
60
|
|
|
109
61
|
/* We use classnames from here exceptionally to be able to handle styles when the Card is on hover */
|
|
110
62
|
${getClickablePlayButtonStyles(isPlayButtonClickable)}
|
|
111
63
|
${getSelectableTickBoxStyles(isTickBoxSelectable)}
|
|
112
|
-
|
|
113
|
-
${fixedBlanketStyles}
|
|
114
|
-
}
|
|
64
|
+
|
|
115
65
|
&:hover .${actionsBarClassName} {
|
|
116
66
|
${fixedActionBarStyles}
|
|
117
67
|
}
|
|
@@ -120,14 +70,4 @@ export const NewFileExperienceWrapper = styled.div`
|
|
|
120
70
|
${shouldDisplayTooltip ? `> div { ${getWrapperDimensions(dimensions, appearance)} }` : ''}
|
|
121
71
|
`}
|
|
122
72
|
`;
|
|
123
|
-
NewFileExperienceWrapper.displayName = 'NewFileExperienceWrapper';
|
|
124
|
-
export const CardImageContainer = styled.div`
|
|
125
|
-
display: flex;
|
|
126
|
-
position: relative;
|
|
127
|
-
max-width: 100%;
|
|
128
|
-
width: 100%;
|
|
129
|
-
height: 100%;
|
|
130
|
-
max-height: 100%;
|
|
131
|
-
overflow: hidden;
|
|
132
|
-
${borderRadius}
|
|
133
|
-
`;
|
|
73
|
+
NewFileExperienceWrapper.displayName = 'NewFileExperienceWrapper';
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { akEditorSelectedBoxShadow } from '@atlaskit/editor-shared-styles/consts';
|
|
3
|
+
import { N20, N60A } from '@atlaskit/theme/colors';
|
|
4
|
+
import { fontFamily } from '@atlaskit/theme/constants';
|
|
5
|
+
import { hideNativeBrowserTextSelectionStyles } from '@atlaskit/editor-shared-styles/selection';
|
|
6
|
+
import { borderRadius } from '@atlaskit/media-ui';
|
|
7
|
+
import { transition } from '../../styles';
|
|
8
|
+
import { getDefaultCardDimensions } from '../../utils/cardDimensions';
|
|
9
|
+
import { getCSSUnitValue } from '../../utils/getCSSUnitValue';
|
|
10
|
+
import { fixedBlanketStyles, blanketClassName } from './blanket/styled';
|
|
11
|
+
import { responsiveSettings } from './common';
|
|
12
|
+
import { Breakpoint } from './Breakpoint';
|
|
13
|
+
export const SSRFileExperienceWrapper = styled.div`
|
|
14
|
+
${({
|
|
15
|
+
breakpoint,
|
|
16
|
+
dimensions,
|
|
17
|
+
appearance,
|
|
18
|
+
shouldUsePointerCursor,
|
|
19
|
+
displayBackground,
|
|
20
|
+
disableOverlay,
|
|
21
|
+
selected
|
|
22
|
+
}) => `
|
|
23
|
+
${transition()}
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
* {
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
}
|
|
28
|
+
position: relative;
|
|
29
|
+
font-family: ${fontFamily()};
|
|
30
|
+
${getWrapperDimensions(dimensions, appearance)}
|
|
31
|
+
${displayBackground ? `background-color: ${N20};` : ''}
|
|
32
|
+
${borderRadius}
|
|
33
|
+
${getCursorStyle(shouldUsePointerCursor)}
|
|
34
|
+
${generateResponsiveStyles(breakpoint)}
|
|
35
|
+
${hideNativeBrowserTextSelectionStyles}
|
|
36
|
+
${getWrapperShadow(disableOverlay, selected)}
|
|
37
|
+
`}
|
|
38
|
+
&:hover .${blanketClassName} {
|
|
39
|
+
${fixedBlanketStyles}
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
SSRFileExperienceWrapper.displayName = 'SSRFileExperienceWrapper';
|
|
43
|
+
export const getWrapperDimensions = (dimensions, appearance) => {
|
|
44
|
+
const {
|
|
45
|
+
width,
|
|
46
|
+
height
|
|
47
|
+
} = dimensions || {};
|
|
48
|
+
const {
|
|
49
|
+
width: defaultWidth,
|
|
50
|
+
height: defaultHeight
|
|
51
|
+
} = getDefaultCardDimensions(appearance);
|
|
52
|
+
return `
|
|
53
|
+
width: ${getCSSUnitValue(width || defaultWidth)};
|
|
54
|
+
max-width: 100%;
|
|
55
|
+
height: ${getCSSUnitValue(height || defaultHeight)};
|
|
56
|
+
max-height: 100%;
|
|
57
|
+
`;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const generateResponsiveStyles = (breakpoint = Breakpoint.SMALL) => {
|
|
61
|
+
const setting = responsiveSettings[breakpoint];
|
|
62
|
+
return `
|
|
63
|
+
font-size: ${setting.fontSize}px;
|
|
64
|
+
line-height: ${setting.lineHeight}px;
|
|
65
|
+
`;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const getCursorStyle = shouldUsePointerCursor => `cursor: ${shouldUsePointerCursor ? 'pointer' : 'default'};`; // This is a trick to simulate the blue border without affecting the dimensions.
|
|
69
|
+
// CSS outline has no 'radius', therefore we can't achieve the same effect with it
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
const getWrapperShadow = (disableOverlay, selected) => {
|
|
73
|
+
const withOverlayShadow = !disableOverlay ? `0 1px 1px ${N60A}, 0 0 1px 0 ${N60A}` : '';
|
|
74
|
+
const selectedShadow = selected ? akEditorSelectedBoxShadow : '';
|
|
75
|
+
const shadow = [selectedShadow, withOverlayShadow].filter(Boolean).join(', ');
|
|
76
|
+
return shadow ? `box-shadow: ${shadow};` : '';
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const CardImageContainer = styled.div`
|
|
80
|
+
display: flex;
|
|
81
|
+
position: relative;
|
|
82
|
+
max-width: 100%;
|
|
83
|
+
width: 100%;
|
|
84
|
+
height: 100%;
|
|
85
|
+
max-height: 100%;
|
|
86
|
+
overflow: hidden;
|
|
87
|
+
${borderRadius}
|
|
88
|
+
`;
|
|
89
|
+
const breakpointSizes = [[Breakpoint.SMALL, 599], [Breakpoint.LARGE, Infinity]];
|
|
90
|
+
export const calcBreakpointSize = (wrapperWidth = 0) => {
|
|
91
|
+
const [breakpoint] = breakpointSizes.find(([_breakpoint, limit]) => wrapperWidth <= limit) || [Breakpoint.SMALL];
|
|
92
|
+
return breakpoint;
|
|
93
|
+
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TitleBoxWrapper, ErrorMessageWrapper } from './styled';
|
|
3
3
|
import EditorWarningIcon from '@atlaskit/icon/glyph/editor/warning';
|
|
4
|
+
import { messages } from '@atlaskit/media-ui';
|
|
4
5
|
import { R300 } from '@atlaskit/theme/colors';
|
|
5
|
-
import {
|
|
6
|
+
import { FormattedMessage } from 'react-intl';
|
|
6
7
|
export const FailedTitleBox = ({
|
|
7
|
-
breakpoint
|
|
8
|
+
breakpoint,
|
|
9
|
+
customMessage = messages.failed_to_load
|
|
8
10
|
}) => {
|
|
9
11
|
return /*#__PURE__*/React.createElement(TitleBoxWrapper, {
|
|
10
12
|
breakpoint: breakpoint
|
|
@@ -12,5 +14,5 @@ export const FailedTitleBox = ({
|
|
|
12
14
|
label: 'Warning',
|
|
13
15
|
size: 'small',
|
|
14
16
|
primaryColor: R300
|
|
15
|
-
}),
|
|
17
|
+
}), /*#__PURE__*/React.createElement(FormattedMessage, customMessage)));
|
|
16
18
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
-
import { responsiveSettings, getTitleBoxHeight
|
|
2
|
+
import { responsiveSettings, getTitleBoxHeight } from '../common';
|
|
3
|
+
import { Breakpoint } from '../Breakpoint';
|
|
3
4
|
import { N0 } from '@atlaskit/theme/colors';
|
|
4
5
|
import { rgba } from '../../../styles/mixins';
|
|
5
6
|
|
|
@@ -2,14 +2,6 @@ import { getMediaClientErrorReason, isRequestError } from '@atlaskit/media-clien
|
|
|
2
2
|
import { ANALYTICS_MEDIA_CHANNEL } from '@atlaskit/media-common';
|
|
3
3
|
import { createAndFireEvent } from '@atlaskit/analytics-next';
|
|
4
4
|
import { isMediaCardError } from '../errors';
|
|
5
|
-
export let RenderEventAction;
|
|
6
|
-
|
|
7
|
-
(function (RenderEventAction) {
|
|
8
|
-
RenderEventAction["COMMENCED"] = "commenced";
|
|
9
|
-
RenderEventAction["SUCCEEDED"] = "succeeded";
|
|
10
|
-
RenderEventAction["FAILED"] = "failed";
|
|
11
|
-
})(RenderEventAction || (RenderEventAction = {}));
|
|
12
|
-
|
|
13
5
|
export const getFileAttributes = (metadata, fileStatus) => ({
|
|
14
6
|
fileMediatype: metadata.mediaType,
|
|
15
7
|
fileMimetype: metadata.mimeType,
|
|
@@ -17,49 +9,44 @@ export const getFileAttributes = (metadata, fileStatus) => ({
|
|
|
17
9
|
fileSize: metadata.size,
|
|
18
10
|
fileStatus
|
|
19
11
|
});
|
|
20
|
-
export const
|
|
21
|
-
eventType: '
|
|
22
|
-
action:
|
|
23
|
-
actionSubject: '
|
|
12
|
+
export const getRenderPreviewableCardPayload = fileAttributes => ({
|
|
13
|
+
eventType: 'screen',
|
|
14
|
+
action: 'viewed',
|
|
15
|
+
actionSubject: 'mediaCardRenderScreen',
|
|
16
|
+
name: 'mediaCardRenderScreen',
|
|
24
17
|
attributes: {
|
|
18
|
+
type: fileAttributes.fileMediatype,
|
|
25
19
|
fileAttributes
|
|
26
20
|
}
|
|
27
21
|
});
|
|
28
|
-
export const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (!fileStatus) {
|
|
39
|
-
// This fail reason will come from a bug, most likely.
|
|
40
|
-
return `unknown-uri`;
|
|
41
|
-
} else if (fileStatus === 'uploading') {
|
|
42
|
-
return 'local-uri';
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return 'remote-uri';
|
|
22
|
+
export const getRenderCommencedEventPayload = (fileAttributes, performanceAttributes) => {
|
|
23
|
+
return {
|
|
24
|
+
eventType: 'operational',
|
|
25
|
+
action: 'commenced',
|
|
26
|
+
actionSubject: 'mediaCardRender',
|
|
27
|
+
attributes: {
|
|
28
|
+
fileAttributes,
|
|
29
|
+
performanceAttributes
|
|
30
|
+
}
|
|
31
|
+
};
|
|
46
32
|
};
|
|
47
|
-
export const
|
|
33
|
+
export const getRenderSucceededEventPayload = (fileAttributes, performanceAttributes) => ({
|
|
48
34
|
eventType: 'operational',
|
|
49
|
-
action:
|
|
35
|
+
action: 'succeeded',
|
|
50
36
|
actionSubject: 'mediaCardRender',
|
|
51
37
|
attributes: {
|
|
52
38
|
fileAttributes,
|
|
53
|
-
|
|
54
|
-
|
|
39
|
+
performanceAttributes,
|
|
40
|
+
status: 'success'
|
|
55
41
|
}
|
|
56
42
|
});
|
|
57
|
-
export const getRenderFailedExternalUriPayload = fileAttributes => ({
|
|
43
|
+
export const getRenderFailedExternalUriPayload = (fileAttributes, performanceAttributes) => ({
|
|
58
44
|
eventType: 'operational',
|
|
59
|
-
action:
|
|
45
|
+
action: 'failed',
|
|
60
46
|
actionSubject: 'mediaCardRender',
|
|
61
47
|
attributes: {
|
|
62
48
|
fileAttributes,
|
|
49
|
+
performanceAttributes,
|
|
63
50
|
status: 'fail',
|
|
64
51
|
failReason: 'external-uri'
|
|
65
52
|
}
|
|
@@ -94,12 +81,13 @@ export const getRenderErrorRequestMetadata = error => {
|
|
|
94
81
|
return error.secondaryError.metadata;
|
|
95
82
|
}
|
|
96
83
|
};
|
|
97
|
-
export const getRenderErrorEventPayload = (fileAttributes, error) => ({
|
|
84
|
+
export const getRenderErrorEventPayload = (fileAttributes, performanceAttributes, error) => ({
|
|
98
85
|
eventType: 'operational',
|
|
99
|
-
action:
|
|
86
|
+
action: 'failed',
|
|
100
87
|
actionSubject: 'mediaCardRender',
|
|
101
88
|
attributes: {
|
|
102
89
|
fileAttributes,
|
|
90
|
+
performanceAttributes,
|
|
103
91
|
status: 'fail',
|
|
104
92
|
failReason: getRenderErrorFailReason(error),
|
|
105
93
|
error: getRenderErrorErrorReason(error),
|
|
@@ -107,12 +95,13 @@ export const getRenderErrorEventPayload = (fileAttributes, error) => ({
|
|
|
107
95
|
request: getRenderErrorRequestMetadata(error)
|
|
108
96
|
}
|
|
109
97
|
});
|
|
110
|
-
export const getRenderFailedFileStatusPayload = fileAttributes => ({
|
|
98
|
+
export const getRenderFailedFileStatusPayload = (fileAttributes, performanceAttributes) => ({
|
|
111
99
|
eventType: 'operational',
|
|
112
|
-
action:
|
|
100
|
+
action: 'failed',
|
|
113
101
|
actionSubject: 'mediaCardRender',
|
|
114
102
|
attributes: {
|
|
115
103
|
fileAttributes,
|
|
104
|
+
performanceAttributes,
|
|
116
105
|
status: 'fail',
|
|
117
106
|
failReason: 'failed-processing'
|
|
118
107
|
}
|
|
@@ -20,7 +20,7 @@ export const canCompareDimension = (current, next) => {
|
|
|
20
20
|
return false;
|
|
21
21
|
};
|
|
22
22
|
export const isBigger = (current, next) => {
|
|
23
|
-
if (canCompareDimension(current.width, next.width) && canCompareDimension(current.height, next.height)) {
|
|
23
|
+
if (!!current && !!next && canCompareDimension(current.width, next.width) && canCompareDimension(current.height, next.height)) {
|
|
24
24
|
const nextIsHigher = parseInt(`${current.width}`, 10) < parseInt(`${next.width}`, 10);
|
|
25
25
|
const nextIsWider = parseInt(`${current.height}`, 10) < parseInt(`${next.height}`, 10);
|
|
26
26
|
return nextIsHigher || nextIsWider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default (() => document);
|
|
@@ -20,4 +20,12 @@ export const getDataURIDimension = (dimension, options) => {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
return defaultImageCardDimensions[dimension] * retinaFactor;
|
|
23
|
+
};
|
|
24
|
+
export const getRequestedDimensions = options => {
|
|
25
|
+
const width = getDataURIDimension('width', options);
|
|
26
|
+
const height = getDataURIDimension('height', options);
|
|
27
|
+
return {
|
|
28
|
+
width,
|
|
29
|
+
height
|
|
30
|
+
};
|
|
23
31
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isErrorFileState } from '@atlaskit/media-client';
|
|
1
|
+
import { isErrorFileState, isFileIdentifier } from '@atlaskit/media-client';
|
|
2
2
|
|
|
3
3
|
const getProcessingStatusFromFileState = status => {
|
|
4
4
|
switch (status) {
|
|
@@ -13,7 +13,7 @@ const getProcessingStatusFromFileState = status => {
|
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const getFileDetailsFromFileState = state => ({
|
|
17
17
|
id: state.id,
|
|
18
18
|
name: state.name,
|
|
19
19
|
size: state.size,
|
|
@@ -21,6 +21,14 @@ export const getFileDetails = state => !isErrorFileState(state) ? {
|
|
|
21
21
|
createdAt: state.createdAt,
|
|
22
22
|
mediaType: state.mediaType,
|
|
23
23
|
processingStatus: getProcessingStatusFromFileState(state.status)
|
|
24
|
-
}
|
|
25
|
-
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const getFileDetails = (identifier, fileState) => {
|
|
27
|
+
return isFileIdentifier(identifier) ? fileState && !isErrorFileState(fileState) ? getFileDetailsFromFileState(fileState) : {
|
|
28
|
+
id: identifier.id
|
|
29
|
+
} : {
|
|
30
|
+
id: identifier.mediaItemType,
|
|
31
|
+
name: identifier.name || identifier.dataURI,
|
|
32
|
+
mediaType: 'image'
|
|
33
|
+
};
|
|
26
34
|
};
|
|
@@ -42,5 +42,10 @@ export class ObjectURLCache {
|
|
|
42
42
|
this.cache.set(key, value);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
remove(key) {
|
|
46
|
+
const removed = this.cache.remove(key);
|
|
47
|
+
removed && URL.revokeObjectURL(removed.dataURI);
|
|
48
|
+
}
|
|
49
|
+
|
|
45
50
|
}
|
|
46
51
|
export const createObjectURLCache = () => new ObjectURLCache(PREVIEW_CACHE_LRU_SIZE);
|
|
@@ -5,7 +5,7 @@ export const shouldDisplayImageThumbnail = (cardStatus, mediaItemType, dataURI,
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
if (dataURI) {
|
|
8
|
-
return mediaItemType === 'external-image' || mimeType && isMimeTypeSupportedByBrowser(mimeType) || cardStatus === 'complete';
|
|
8
|
+
return mediaItemType === 'external-image' || mimeType && isMimeTypeSupportedByBrowser(mimeType) || cardStatus === 'complete' || cardStatus === 'loading-preview';
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
return false;
|
package/dist/es2019/version.json
CHANGED