@atlaskit/media-viewer 54.11.21 → 54.11.23
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 +31 -0
- package/dist/cjs/DownloadButton.js +14 -5
- package/dist/cjs/DownloadItem.js +3 -1
- package/dist/cjs/ErrorViewDownloadButton.js +3 -0
- package/dist/cjs/ItemViewerBase.js +8 -7
- package/dist/cjs/ToolbarDownloadButton.js +5 -2
- package/dist/cjs/analytics/ufoExperiences.js +1 -1
- package/dist/cjs/errorMessage.compiled.css +1 -0
- package/dist/cjs/errorMessage.js +11 -7
- package/dist/cjs/errorMessageWithAnalytics.js +2 -1
- package/dist/cjs/header.js +2 -1
- package/dist/cjs/insetViewerContext.js +15 -15
- package/dist/cjs/loading.js +7 -2
- package/dist/cjs/navigation.js +7 -5
- package/dist/cjs/styleWrappers.compiled.css +5 -1
- package/dist/cjs/styleWrappers.js +53 -18
- package/dist/cjs/viewers/archiveSidebar/archive-viewer-base.js +3 -3
- package/dist/cjs/viewers/audio.js +68 -27
- package/dist/cjs/viewers/codeViewer/CodeRendererAdvanced/CodeRendererAdvanced.compiled.css +6 -1
- package/dist/cjs/viewers/codeViewer/CodeRendererAdvanced/CodeRendererAdvanced.js +37 -9
- package/dist/cjs/viewers/codeViewer/CodeRendererAdvanced/theme.js +68 -53
- package/dist/cjs/viewers/codeViewer/CodeViewRenderer-2.js +15 -1
- package/dist/cjs/viewers/codeViewer/CodeViewerFooter.compiled.css +10 -0
- package/dist/cjs/viewers/codeViewer/CodeViewerFooter.js +41 -0
- package/dist/cjs/viewers/codeViewer/CodeViewerHeaderBar.js +6 -0
- package/dist/cjs/viewers/codeViewer/codeViewerRenderer-compiled.compiled.css +3 -1
- package/dist/cjs/viewers/codeViewer/codeViewerRenderer-compiled.js +8 -1
- package/dist/cjs/viewers/doc/DocViewer.js +7 -2
- package/dist/cjs/viewers/doc/passwordInput.compiled.css +3 -1
- package/dist/cjs/viewers/doc/passwordInput.js +27 -13
- package/dist/cjs/viewers/video.js +6 -6
- package/dist/es2019/DownloadButton.js +12 -4
- package/dist/es2019/DownloadItem.js +3 -1
- package/dist/es2019/ErrorViewDownloadButton.js +3 -0
- package/dist/es2019/ItemViewerBase.js +3 -2
- package/dist/es2019/ToolbarDownloadButton.js +4 -1
- package/dist/es2019/analytics/ufoExperiences.js +1 -1
- package/dist/es2019/errorMessage.compiled.css +1 -0
- package/dist/es2019/errorMessage.js +9 -5
- package/dist/es2019/errorMessageWithAnalytics.js +2 -1
- package/dist/es2019/header.js +2 -1
- package/dist/es2019/insetViewerContext.js +11 -11
- package/dist/es2019/loading.js +7 -2
- package/dist/es2019/navigation.js +3 -1
- package/dist/es2019/styleWrappers.compiled.css +4 -0
- package/dist/es2019/styleWrappers.js +62 -27
- package/dist/es2019/viewers/archiveSidebar/archive-viewer-base.js +3 -3
- package/dist/es2019/viewers/audio.js +52 -17
- package/dist/es2019/viewers/codeViewer/CodeRendererAdvanced/CodeRendererAdvanced.compiled.css +6 -1
- package/dist/es2019/viewers/codeViewer/CodeRendererAdvanced/CodeRendererAdvanced.js +29 -9
- package/dist/es2019/viewers/codeViewer/CodeRendererAdvanced/theme.js +21 -5
- package/dist/es2019/viewers/codeViewer/CodeViewRenderer-2.js +15 -1
- package/dist/es2019/viewers/codeViewer/CodeViewerFooter.compiled.css +10 -0
- package/dist/es2019/viewers/codeViewer/CodeViewerFooter.js +33 -0
- package/dist/es2019/viewers/codeViewer/CodeViewerHeaderBar.js +6 -0
- package/dist/es2019/viewers/codeViewer/codeViewerRenderer-compiled.compiled.css +3 -1
- package/dist/es2019/viewers/codeViewer/codeViewerRenderer-compiled.js +5 -1
- package/dist/es2019/viewers/doc/DocViewer.js +7 -2
- package/dist/es2019/viewers/doc/passwordInput.compiled.css +3 -1
- package/dist/es2019/viewers/doc/passwordInput.js +19 -5
- package/dist/es2019/viewers/video.js +7 -7
- package/dist/esm/DownloadButton.js +14 -5
- package/dist/esm/DownloadItem.js +3 -1
- package/dist/esm/ErrorViewDownloadButton.js +3 -0
- package/dist/esm/ItemViewerBase.js +3 -2
- package/dist/esm/ToolbarDownloadButton.js +4 -1
- package/dist/esm/analytics/ufoExperiences.js +1 -1
- package/dist/esm/errorMessage.compiled.css +1 -0
- package/dist/esm/errorMessage.js +11 -7
- package/dist/esm/errorMessageWithAnalytics.js +2 -1
- package/dist/esm/header.js +2 -1
- package/dist/esm/insetViewerContext.js +14 -14
- package/dist/esm/loading.js +7 -2
- package/dist/esm/navigation.js +3 -1
- package/dist/esm/styleWrappers.compiled.css +5 -1
- package/dist/esm/styleWrappers.js +51 -16
- package/dist/esm/viewers/archiveSidebar/archive-viewer-base.js +3 -3
- package/dist/esm/viewers/audio.js +69 -28
- package/dist/esm/viewers/codeViewer/CodeRendererAdvanced/CodeRendererAdvanced.compiled.css +6 -1
- package/dist/esm/viewers/codeViewer/CodeRendererAdvanced/CodeRendererAdvanced.js +38 -11
- package/dist/esm/viewers/codeViewer/CodeRendererAdvanced/theme.js +67 -52
- package/dist/esm/viewers/codeViewer/CodeViewRenderer-2.js +15 -1
- package/dist/esm/viewers/codeViewer/CodeViewerFooter.compiled.css +10 -0
- package/dist/esm/viewers/codeViewer/CodeViewerFooter.js +32 -0
- package/dist/esm/viewers/codeViewer/CodeViewerHeaderBar.js +6 -0
- package/dist/esm/viewers/codeViewer/codeViewerRenderer-compiled.compiled.css +3 -1
- package/dist/esm/viewers/codeViewer/codeViewerRenderer-compiled.js +8 -1
- package/dist/esm/viewers/doc/DocViewer.js +7 -2
- package/dist/esm/viewers/doc/passwordInput.compiled.css +3 -1
- package/dist/esm/viewers/doc/passwordInput.js +19 -5
- package/dist/esm/viewers/video.js +7 -7
- package/dist/types/DownloadButton.d.ts +1 -1
- package/dist/types/DownloadButtonProps.d.ts +1 -0
- package/dist/types/DownloadItem.d.ts +1 -1
- package/dist/types/DownloadItemProps.d.ts +1 -0
- package/dist/types/errorMessage.d.ts +6 -1
- package/dist/types/insetViewerContext.d.ts +3 -3
- package/dist/types/styleWrappers.d.ts +2 -2
- package/dist/types/viewers/audio.d.ts +2 -16
- package/dist/types/viewers/codeViewer/CodeRendererAdvanced/theme.d.ts +1 -0
- package/dist/types/viewers/codeViewer/CodeViewerFooter.d.ts +7 -0
- package/dist/types/viewers/codeViewer/CodeViewerHeaderBar.d.ts +1 -1
- package/example-helpers/NativeMediaPreview.tsx +3 -1
- package/package.json +8 -8
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
/* errorMessage.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import "./errorMessage.compiled.css";
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
2
5
|
import React from 'react';
|
|
3
6
|
import { FormattedMessage } from 'react-intl';
|
|
4
7
|
import { messages as i18nMessages } from '@atlaskit/media-ui/messages';
|
|
@@ -12,6 +15,9 @@ import { errorLoadingFile } from './error-images';
|
|
|
12
15
|
import { getErrorMessageFromError } from './getErrorMessageFromError';
|
|
13
16
|
import { getPrimaryErrorReason } from './getPrimaryErrorReason';
|
|
14
17
|
import { ErrorMessageWrapper, ErrorImage } from './styleWrappers';
|
|
18
|
+
const styles = {
|
|
19
|
+
insetViewerLine: "_syazazsu"
|
|
20
|
+
};
|
|
15
21
|
const errorLoadingFileImage = formatMessage => /*#__PURE__*/React.createElement(ErrorImage, {
|
|
16
22
|
src: errorLoadingFile,
|
|
17
23
|
alt: formatMessage(i18nMessages.error_loading_file)
|
|
@@ -115,11 +121,9 @@ export class ErrorMessage extends React.Component {
|
|
|
115
121
|
const errorInfo = this.getErrorInfo();
|
|
116
122
|
return /*#__PURE__*/React.createElement(ErrorMessageWrapper, {
|
|
117
123
|
"data-testid": "media-viewer-error"
|
|
118
|
-
}, /*#__PURE__*/React.createElement("div", null, errorInfo.icon, errorInfo.messages.map((formatMessage, i) =>
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
React.createElement("p", {
|
|
122
|
-
key: `p${i}`
|
|
124
|
+
}, /*#__PURE__*/React.createElement("div", null, errorInfo.icon, errorInfo.messages.map((formatMessage, i) => /*#__PURE__*/React.createElement("p", {
|
|
125
|
+
key: `p${i}`,
|
|
126
|
+
className: ax([this.props.isInsetViewer && styles.insetViewerLine])
|
|
123
127
|
}, /*#__PURE__*/React.createElement(FormattedMessage, formatMessage)))), this.props.children);
|
|
124
128
|
}
|
|
125
129
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { injectIntl } from 'react-intl';
|
|
2
2
|
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
3
3
|
import { ErrorMessage } from './errorMessage';
|
|
4
|
+
import { withInsetViewer } from './insetViewerContext';
|
|
4
5
|
|
|
5
6
|
// @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
|
|
6
|
-
const ErroMsg = withAnalyticsEvents()(injectIntl(ErrorMessage));
|
|
7
|
+
const ErroMsg = withAnalyticsEvents()(withInsetViewer(injectIntl(ErrorMessage)));
|
|
7
8
|
export default ErroMsg;
|
package/dist/es2019/header.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { FormattedMessage } from 'react-intl';
|
|
3
3
|
import CrossIcon from '@atlaskit/icon/core/cross';
|
|
4
|
-
import {
|
|
4
|
+
import { isErrorFileState, toCommonMediaClientError } from '@atlaskit/media-client';
|
|
5
5
|
import { useFileState } from '@atlaskit/media-client-react/use-file-state';
|
|
6
6
|
import { useMediaClient } from '@atlaskit/media-client-react/use-media-client';
|
|
7
|
+
import { isExternalImageIdentifier } from '@atlaskit/media-client/is-external-image-identifier';
|
|
7
8
|
import { isZipMimeType } from '@atlaskit/media-common/isZipMimeType';
|
|
8
9
|
import { hideControlsClassName } from '@atlaskit/media-ui/classNames';
|
|
9
10
|
import { getExtension } from '@atlaskit/media-ui/getExtension';
|
|
@@ -7,31 +7,31 @@ const MediaFooterControlsContext = /*#__PURE__*/createContext(null);
|
|
|
7
7
|
const SetMediaFooterControlsContext = /*#__PURE__*/createContext(() => {});
|
|
8
8
|
|
|
9
9
|
// Whether a viewer has registered video controls in the footer, which gives the footer extra room.
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const HasMediaFooterPlayerControlsContext = /*#__PURE__*/createContext(false);
|
|
11
|
+
const SetHasMediaFooterPlayerControlsContext = /*#__PURE__*/createContext(() => {});
|
|
12
12
|
export const InsetViewerProvider = ({
|
|
13
13
|
isInsetViewer = false,
|
|
14
14
|
children
|
|
15
15
|
}) => {
|
|
16
16
|
const [mediaFooterControls, setMediaFooterControls] = useState(null);
|
|
17
|
-
const [
|
|
17
|
+
const [hasPlayerControls, setHasPlayerControls] = useState(false);
|
|
18
18
|
return /*#__PURE__*/React.createElement(InsetViewerContext.Provider, {
|
|
19
19
|
value: isInsetViewer
|
|
20
20
|
}, /*#__PURE__*/React.createElement(SetMediaFooterControlsContext.Provider, {
|
|
21
21
|
value: setMediaFooterControls
|
|
22
22
|
}, /*#__PURE__*/React.createElement(MediaFooterControlsContext.Provider, {
|
|
23
23
|
value: mediaFooterControls
|
|
24
|
-
}, /*#__PURE__*/React.createElement(
|
|
25
|
-
value:
|
|
26
|
-
}, /*#__PURE__*/React.createElement(
|
|
27
|
-
value:
|
|
24
|
+
}, /*#__PURE__*/React.createElement(SetHasMediaFooterPlayerControlsContext.Provider, {
|
|
25
|
+
value: setHasPlayerControls
|
|
26
|
+
}, /*#__PURE__*/React.createElement(HasMediaFooterPlayerControlsContext.Provider, {
|
|
27
|
+
value: hasPlayerControls
|
|
28
28
|
}, children)))));
|
|
29
29
|
};
|
|
30
30
|
export const useIsInsetViewer = () => useContext(InsetViewerContext);
|
|
31
31
|
export const useMediaFooterControls = () => useContext(MediaFooterControlsContext);
|
|
32
32
|
export const useSetMediaFooterControls = () => useContext(SetMediaFooterControlsContext);
|
|
33
|
-
export const
|
|
34
|
-
export const
|
|
33
|
+
export const useHasMediaFooterPlayerControls = () => useContext(HasMediaFooterPlayerControlsContext);
|
|
34
|
+
export const useSetHasMediaFooterPlayerControls = () => useContext(SetHasMediaFooterPlayerControlsContext);
|
|
35
35
|
export const withInsetViewer = WrappedComponent => {
|
|
36
36
|
const WithInsetViewer = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
37
37
|
const isInsetViewer = useIsInsetViewer();
|
|
@@ -47,12 +47,12 @@ export const withInsetViewerFooter = WrappedComponent => {
|
|
|
47
47
|
const WithInsetViewerFooter = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
48
48
|
const isInsetViewer = useIsInsetViewer();
|
|
49
49
|
const mediaFooterControls = useMediaFooterControls();
|
|
50
|
-
const
|
|
50
|
+
const setHasPlayerControls = useSetHasMediaFooterPlayerControls();
|
|
51
51
|
return /*#__PURE__*/React.createElement(WrappedComponent, _extends({}, props, {
|
|
52
52
|
ref: ref,
|
|
53
53
|
isInsetViewer: isInsetViewer,
|
|
54
54
|
mediaFooterControls: mediaFooterControls,
|
|
55
|
-
|
|
55
|
+
setHasPlayerControls: setHasPlayerControls
|
|
56
56
|
}));
|
|
57
57
|
});
|
|
58
58
|
WithInsetViewerFooter.displayName = `WithInsetViewerFooter(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;
|
package/dist/es2019/loading.js
CHANGED
|
@@ -2,11 +2,16 @@ import React from 'react';
|
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
3
|
import { messages } from '@atlaskit/media-ui/messages';
|
|
4
4
|
import AkSpinner from '@atlaskit/spinner/spinner';
|
|
5
|
+
import { useIsInsetViewer } from './insetViewerContext';
|
|
5
6
|
export const Spinner = ({}) => {
|
|
6
7
|
const intl = useIntl();
|
|
8
|
+
const isInsetViewer = useIsInsetViewer();
|
|
7
9
|
return /*#__PURE__*/React.createElement(AkSpinner, {
|
|
8
|
-
label: intl.formatMessage(messages.loading_file)
|
|
9
|
-
|
|
10
|
+
label: intl.formatMessage(messages.loading_file)
|
|
11
|
+
// The overlay viewer is always dark, so it inverts the spinner. The inset viewer follows the
|
|
12
|
+
// theme, so it uses the spinner's own subtle icon colour.
|
|
13
|
+
,
|
|
14
|
+
appearance: isInsetViewer ? 'inherit' : 'invert',
|
|
10
15
|
size: "large"
|
|
11
16
|
});
|
|
12
17
|
};
|
|
@@ -12,7 +12,9 @@ import { hideControlsClassName } from '@atlaskit/media-ui/classNames';
|
|
|
12
12
|
import { Shortcut } from '@atlaskit/media-ui/shortcut';
|
|
13
13
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
14
14
|
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
|
|
15
|
-
import { Pressable
|
|
15
|
+
import { Pressable } from '@atlaskit/primitives/pressable';
|
|
16
|
+
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
|
|
17
|
+
import { xcss } from '@atlaskit/primitives/xcss/xcss';
|
|
16
18
|
import { createNavigatedEvent } from './analytics/events/ui/createNavigatedEvent';
|
|
17
19
|
import { fireAnalytics } from './analytics/fireAnalytics';
|
|
18
20
|
import { withInsetViewer } from './insetViewerContext';
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
._154i1ejb{top:var(--ds-space-300,24px)}
|
|
14
14
|
._154i1ssb{top:50%}
|
|
15
15
|
._154i1wug{top:auto}
|
|
16
|
+
._154i69le{top:calc(50% + var(--ds-space-800, 4pc)/2 + var(--ds-space-050, 4px)/2)}
|
|
16
17
|
._154iidpf{top:0}
|
|
18
|
+
._154inuvu{top:calc(50% + var(--ds-space-800, 4pc)/2)}
|
|
17
19
|
._16jlidpf{flex-grow:0}
|
|
18
20
|
._16jlkb7n{flex-grow:1}
|
|
19
21
|
._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
@@ -40,6 +42,7 @@
|
|
|
40
42
|
._1bsb1osq{width:100%}
|
|
41
43
|
._1bsb1tcg{width:24px}
|
|
42
44
|
._1bsbauwl{width:100vw}
|
|
45
|
+
._1bsbt4lq{width:calc(100% - 3pc)}
|
|
43
46
|
._1bsbyazj{width:calc(100% - 26pc)}
|
|
44
47
|
._1bsbze3t{width:var(--ds-space-0,0)}
|
|
45
48
|
._1bto1l2s{text-overflow:ellipsis}
|
|
@@ -117,6 +120,7 @@
|
|
|
117
120
|
._bfhk1i5c{background-color:var(--ds-blanket,#050c1f75)}
|
|
118
121
|
._bfhk1j28{background-color:transparent}
|
|
119
122
|
._bfhk1tzm{background-color:#22272b}
|
|
123
|
+
._bfhki8nm{background-color:var(--ds-background-neutral,#0515240f)}
|
|
120
124
|
._bfhkr3uz{background-color:#000}
|
|
121
125
|
._bfhkvuon{background-color:var(--ds-surface,#fff)}
|
|
122
126
|
._c71l1osq{max-height:100%}
|
|
@@ -12,14 +12,18 @@ import Heading from '@atlaskit/heading/heading';
|
|
|
12
12
|
import ExitingPersistence from '@atlaskit/motion/exiting-persistence';
|
|
13
13
|
import SlideIn from '@atlaskit/motion/slide-in';
|
|
14
14
|
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
|
|
15
|
-
import { Box
|
|
16
|
-
|
|
15
|
+
import { Box } from '@atlaskit/primitives/box';
|
|
16
|
+
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
|
|
17
|
+
import { xcss } from '@atlaskit/primitives/xcss/xcss';
|
|
18
|
+
import { useHasMediaFooterPlayerControls, useIsInsetViewer, useSetMediaFooterControls } from './insetViewerContext';
|
|
17
19
|
const INSET_HEADER_HEIGHT = "var(--ds-space-800, 64px)";
|
|
18
20
|
// The horizontal gutter of the inset header, footer and fitted media, shared so they can't drift.
|
|
19
21
|
// It is `space.300` at the default root font size, hard-coded because the fit maths needs a number
|
|
20
22
|
// and resolving the token would mean reading the DOM on every resize.
|
|
21
23
|
export const INSET_VIEWER_GUTTER_PX = 24;
|
|
22
24
|
const INSET_SIDEBAR_WIDTH = '400px';
|
|
25
|
+
// The media footer is the header's height, and taller when it holds player controls.
|
|
26
|
+
const INSET_PLAYER_FOOTER_HEIGHT = `calc(${INSET_HEADER_HEIGHT} + ${"var(--ds-space-050, 4px)"})`;
|
|
23
27
|
const insetSidebarWidthTransitionStyles = null;
|
|
24
28
|
const insetSidebarSlotStyles = null;
|
|
25
29
|
const insetSidebarSlotOpenStyles = null;
|
|
@@ -42,7 +46,7 @@ const insetViewerSidebarHeaderContentStyles = null;
|
|
|
42
46
|
const insetViewerSidebarHeaderTitleStyles = null;
|
|
43
47
|
const insetViewerMediaStageStyles = null;
|
|
44
48
|
const insetViewerMediaFooterBarStyles = null;
|
|
45
|
-
const
|
|
49
|
+
const insetViewerPlayerMediaFooterBarStyles = null;
|
|
46
50
|
const listWrapperStyles = null;
|
|
47
51
|
const insetViewerListWrapperStyles = null;
|
|
48
52
|
const itemStageStyles = null;
|
|
@@ -67,7 +71,11 @@ const pdfWrapperStyles = null;
|
|
|
67
71
|
const arrowStyles = null;
|
|
68
72
|
const arrowWrapperStyles = null;
|
|
69
73
|
const insetViewerArrowStyles = null;
|
|
74
|
+
|
|
75
|
+
// The arrows' container is the stage above the footer, so half the footer is added to centre them on
|
|
76
|
+
// the whole media column, wherever the footer's height changes.
|
|
70
77
|
const insetViewerArrowWrapperStyles = null;
|
|
78
|
+
const insetViewerPlayerArrowWrapperStyles = null;
|
|
71
79
|
const insetViewerLeftWrapperStyles = null;
|
|
72
80
|
const insetViewerRightWrapperStyles = null;
|
|
73
81
|
const arrowsWrapperStyles = null;
|
|
@@ -100,13 +108,23 @@ const metadataIconWrapperStyles = xcss({
|
|
|
100
108
|
const rightHeaderStyles = null;
|
|
101
109
|
const insetViewerRightHeaderStyles = null;
|
|
102
110
|
const customAudioPlayerWrapperStyles = null;
|
|
111
|
+
|
|
112
|
+
// The controls are in the footer, so the player's play/pause blanket covers the whole stage.
|
|
113
|
+
const insetViewerCustomAudioPlayerWrapperStyles = null;
|
|
103
114
|
const audioPlayerStyles = null;
|
|
115
|
+
const insetViewerAudioPlayerStyles = null;
|
|
116
|
+
const insetViewerAudioCoverStyles = null;
|
|
104
117
|
const audioStyles = null;
|
|
105
118
|
const audioCoverStyles = null;
|
|
106
119
|
const defaultCoverWrapperStyles = null;
|
|
120
|
+
const defaultCoverScaleStyles = null;
|
|
107
121
|
const downloadButtonWrapperStyles = null;
|
|
122
|
+
|
|
123
|
+
// The media button's text is fixed dark on its light blue, so it stays dark on hover. The inset
|
|
124
|
+
// viewer's themed button sets its own hover colors.
|
|
125
|
+
const downloadButtonWrapperHoverStyles = null;
|
|
108
126
|
const customVideoPlayerWrapperStyles = null;
|
|
109
|
-
const
|
|
127
|
+
const insetViewerCustomMediaPlayerWrapperStyles = null;
|
|
110
128
|
const insetViewerFittedVideoFrameStyles = null;
|
|
111
129
|
const sidebarWrapperStyles = null;
|
|
112
130
|
const insetViewerSidebarWrapperStyles = null;
|
|
@@ -202,11 +220,11 @@ export const MediaStage = ({
|
|
|
202
220
|
}, children);
|
|
203
221
|
export const MediaFooterBar = () => {
|
|
204
222
|
const setMediaFooterControls = useSetMediaFooterControls();
|
|
205
|
-
const
|
|
223
|
+
const hasPlayerControls = useHasMediaFooterPlayerControls();
|
|
206
224
|
return /*#__PURE__*/React.createElement("div", {
|
|
207
225
|
ref: setMediaFooterControls,
|
|
208
226
|
"data-testid": "media-viewer-media-footer",
|
|
209
|
-
className: ax(["_1reoewfl _18m9ewfl _1o9zidpf _4t3ixncg _vchhusvi _1bsb1osq _1e0c1txw _4cvr1h6o _1bah1h6o _ca0qpxbi _u5f31tcg _n3tdpxbi _19bv1tcg _kqswh2mm _lcxv1rj4",
|
|
227
|
+
className: ax(["_1reoewfl _18m9ewfl _1o9zidpf _4t3ixncg _vchhusvi _1bsb1osq _1e0c1txw _4cvr1h6o _1bah1h6o _ca0qpxbi _u5f31tcg _n3tdpxbi _19bv1tcg _kqswh2mm _lcxv1rj4", hasPlayerControls && "_4t3iz5ib _ca0qv47k"])
|
|
210
228
|
});
|
|
211
229
|
};
|
|
212
230
|
export const ListWrapper = ({
|
|
@@ -344,16 +362,18 @@ export const LeftWrapper = ({
|
|
|
344
362
|
isArchiveSideBarVisible
|
|
345
363
|
}) => {
|
|
346
364
|
const isInsetViewer = useIsInsetViewer();
|
|
365
|
+
const hasPlayerControls = useHasMediaFooterPlayerControls();
|
|
347
366
|
return /*#__PURE__*/React.createElement("div", {
|
|
348
|
-
className: ax(["_kqswstnw _154i1ssb _t9ec1i34 _ca0qv47k _n3tdv47k _19bvv47k _u5f3v47k", "_y3gn1e5h _1ltvidpf", isArchiveSideBarVisible && "_1ltv1mjv", isInsetViewer && "_ca0qze3t _n3tdze3t _19bvze3t _u5f3ze3t", isInsetViewer && "_1ltv1ejb"])
|
|
367
|
+
className: ax(["_kqswstnw _154i1ssb _t9ec1i34 _ca0qv47k _n3tdv47k _19bvv47k _u5f3v47k", "_y3gn1e5h _1ltvidpf", isArchiveSideBarVisible && "_1ltv1mjv", isInsetViewer && "_154inuvu _ca0qze3t _n3tdze3t _19bvze3t _u5f3ze3t", isInsetViewer && hasPlayerControls && "_154i69le", isInsetViewer && "_1ltv1ejb"])
|
|
349
368
|
}, children);
|
|
350
369
|
};
|
|
351
370
|
export const RightWrapper = ({
|
|
352
371
|
children
|
|
353
372
|
}) => {
|
|
354
373
|
const isInsetViewer = useIsInsetViewer();
|
|
374
|
+
const hasPlayerControls = useHasMediaFooterPlayerControls();
|
|
355
375
|
return /*#__PURE__*/React.createElement("div", {
|
|
356
|
-
className: ax(["_kqswstnw _154i1ssb _t9ec1i34 _ca0qv47k _n3tdv47k _19bvv47k _u5f3v47k", "_y3gnusic _1xi2idpf", isInsetViewer && "_ca0qze3t _n3tdze3t _19bvze3t _u5f3ze3t", isInsetViewer && "_1xi21ejb"])
|
|
376
|
+
className: ax(["_kqswstnw _154i1ssb _t9ec1i34 _ca0qv47k _n3tdv47k _19bvv47k _u5f3v47k", "_y3gnusic _1xi2idpf", isInsetViewer && "_154inuvu _ca0qze3t _n3tdze3t _19bvze3t _u5f3ze3t", isInsetViewer && hasPlayerControls && "_154i69le", isInsetViewer && "_1xi21ejb"])
|
|
357
377
|
}, children);
|
|
358
378
|
};
|
|
359
379
|
|
|
@@ -486,16 +506,22 @@ export const RightHeader = ({
|
|
|
486
506
|
};
|
|
487
507
|
export const CustomAudioPlayerWrapper = ({
|
|
488
508
|
children
|
|
489
|
-
}) =>
|
|
490
|
-
|
|
491
|
-
|
|
509
|
+
}) => {
|
|
510
|
+
const isInsetViewer = useIsInsetViewer();
|
|
511
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
512
|
+
className: ax(["_kqswstnw _94n5idpf _1ltvidpf _1bsb1osq", isInsetViewer && "_154iidpf _4t3i1osq"])
|
|
513
|
+
}, children);
|
|
514
|
+
};
|
|
492
515
|
export const AudioPlayer = ({
|
|
493
516
|
'data-testid': datatestId,
|
|
494
517
|
children
|
|
495
|
-
}) =>
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
518
|
+
}) => {
|
|
519
|
+
const isInsetViewer = useIsInsetViewer();
|
|
520
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
521
|
+
"data-testid": datatestId,
|
|
522
|
+
className: ax(["_2rkofajl _1reo15vq _18m915vq _bfhk1tzm _4cvr1h6o _1bah1h6o _1bsb1kdj _4t3i1kdj _1e0c1txw _2lx21bp4 _kqswh2mm", isInsetViewer && "_2rko1mok _bfhki8nm _1bsbt4lq _4t3i1osq"])
|
|
523
|
+
}, children);
|
|
524
|
+
};
|
|
499
525
|
AudioPlayer.displayName = 'AudioPlayer';
|
|
500
526
|
export const Audio = /*#__PURE__*/forwardRef(({
|
|
501
527
|
autoPlay,
|
|
@@ -513,22 +539,31 @@ export const Audio = /*#__PURE__*/forwardRef(({
|
|
|
513
539
|
export const AudioCover = ({
|
|
514
540
|
src,
|
|
515
541
|
alt
|
|
516
|
-
}) =>
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
542
|
+
}) => {
|
|
543
|
+
const isInsetViewer = useIsInsetViewer();
|
|
544
|
+
return /*#__PURE__*/React.createElement("img", {
|
|
545
|
+
alt: alt,
|
|
546
|
+
src: src,
|
|
547
|
+
className: ax(["_1bsb1osq _4t3i1osq _5ralzm06 _bfhkr3uz", isInsetViewer && "_bfhki8nm"])
|
|
548
|
+
});
|
|
549
|
+
};
|
|
521
550
|
export const DefaultCoverWrapper = ({
|
|
522
551
|
children
|
|
523
|
-
}) =>
|
|
524
|
-
|
|
525
|
-
|
|
552
|
+
}) => {
|
|
553
|
+
const isInsetViewer = useIsInsetViewer();
|
|
554
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
555
|
+
className: ax(["_1bsb1osq _4t3i1osq _1e0c1txw _4cvr1h6o _1bah1h6o _syazi7uo", !isInsetViewer && "_umc418ws"])
|
|
556
|
+
}, children);
|
|
557
|
+
};
|
|
526
558
|
export const DownloadButtonWrapper = ({
|
|
527
559
|
children
|
|
528
|
-
}) =>
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
560
|
+
}) => {
|
|
561
|
+
const isInsetViewer = useIsInsetViewer();
|
|
562
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
563
|
+
className: ax(["_19pk1ejb _y3gn1h6o", !isInsetViewer && "_1sfy1fjg _4pkp1fjg"])
|
|
564
|
+
}, children);
|
|
565
|
+
};
|
|
566
|
+
export const CustomMediaPlayerWrapper = /*#__PURE__*/forwardRef(({
|
|
532
567
|
'data-testid': datatestId,
|
|
533
568
|
children
|
|
534
569
|
}, ref) => {
|
|
@@ -9,7 +9,7 @@ import { getLanguageType } from '@atlaskit/media-ui/getLanguageType';
|
|
|
9
9
|
import { isCodeViewerItem } from '@atlaskit/media-ui/isCodeViewerItem';
|
|
10
10
|
import { messages } from '@atlaskit/media-ui/messages';
|
|
11
11
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
12
|
-
import { Text } from '@atlaskit/primitives/compiled';
|
|
12
|
+
import { Text } from '@atlaskit/primitives/compiled/text';
|
|
13
13
|
import { createPreviewUnsupportedEvent } from '../../analytics/events/operational/previewUnsupported';
|
|
14
14
|
import { createZipEntryLoadFailedEvent } from '../../analytics/events/operational/zipEntryLoadFailed';
|
|
15
15
|
import { createZipEntryLoadSucceededEvent } from '../../analytics/events/operational/zipEntryLoadSucceeded';
|
|
@@ -21,7 +21,7 @@ import ErrorMessage from '../../errorMessageWithAnalytics';
|
|
|
21
21
|
import { isMediaViewerError } from '../../isMediaViewerError';
|
|
22
22
|
import { MAX_FILE_SIZE_SUPPORTED_BY_CODEVIEWER } from '../../item-viewer';
|
|
23
23
|
import { Spinner } from '../../loading';
|
|
24
|
-
import {
|
|
24
|
+
import { CustomMediaPlayerWrapper, AudioPlayer, CustomAudioPlayerWrapper, DefaultCoverWrapper, ListWrapper } from '../../styleWrappers';
|
|
25
25
|
import { getMediaTypeFromFilename } from '../../utils/getMediaTypeFromFilename';
|
|
26
26
|
import { getMimeTypeFromFilename } from '../../utils/getMimeTypeFromFilename';
|
|
27
27
|
import { rejectAfter } from '../../utils/rejectAfter';
|
|
@@ -248,7 +248,7 @@ export class ArchiveViewerBase extends BaseViewer {
|
|
|
248
248
|
onError: this.onViewerError('archiveviewer-imageviewer-onerror', selectedArchiveEntry)
|
|
249
249
|
}));
|
|
250
250
|
case 'video':
|
|
251
|
-
return /*#__PURE__*/React.createElement(ArchiveItemViewerWrapper, null, /*#__PURE__*/React.createElement(
|
|
251
|
+
return /*#__PURE__*/React.createElement(ArchiveItemViewerWrapper, null, /*#__PURE__*/React.createElement(CustomMediaPlayerWrapper, {
|
|
252
252
|
"data-testid": "media-viewer-video-content"
|
|
253
253
|
}, /*#__PURE__*/React.createElement(CustomMediaPlayer, {
|
|
254
254
|
type: "video",
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import AudioIcon from '@atlaskit/icon/core/audio';
|
|
4
|
+
import IconTile from '@atlaskit/icon/icon-tile';
|
|
4
5
|
import { globalMediaEventEmitter } from '@atlaskit/media-client/global-media-event-emitter';
|
|
5
6
|
import { CustomMediaPlayer } from '@atlaskit/media-ui/customMediaPlayer';
|
|
7
|
+
import { InsetViewerProvider } from '@atlaskit/media-ui/insetViewerProvider';
|
|
6
8
|
import { Outcome } from '../domain/outcome';
|
|
9
|
+
import { withInsetViewerFooter } from '../insetViewerContext';
|
|
7
10
|
import { MediaViewerError } from '../MediaViewerError';
|
|
8
|
-
import { AudioPlayer, AudioCover, Audio, DefaultCoverWrapper, CustomAudioPlayerWrapper } from '../styleWrappers';
|
|
11
|
+
import { AudioPlayer, AudioCover, Audio, DefaultCoverWrapper, CustomAudioPlayerWrapper, CustomMediaPlayerWrapper } from '../styleWrappers';
|
|
9
12
|
import { getObjectUrlFromFileState } from '../utils/getObjectUrlFromFileState';
|
|
10
13
|
import { isIE } from '../utils/isIE';
|
|
11
14
|
import { BaseViewer } from './base-viewer';
|
|
@@ -16,7 +19,7 @@ const defaultCover = /*#__PURE__*/React.createElement(DefaultCoverWrapper, null,
|
|
|
16
19
|
const getCoverUrl = (item, mediaClient, collectionName) => mediaClient.getImageUrl(item.id, {
|
|
17
20
|
collection: collectionName
|
|
18
21
|
});
|
|
19
|
-
|
|
22
|
+
class _AudioViewer extends BaseViewer {
|
|
20
23
|
constructor(...args) {
|
|
21
24
|
super(...args);
|
|
22
25
|
_defineProperty(this, "renderCover", () => {
|
|
@@ -31,6 +34,13 @@ export class AudioViewer extends BaseViewer {
|
|
|
31
34
|
src: coverUrl,
|
|
32
35
|
alt: item.name
|
|
33
36
|
});
|
|
37
|
+
} else if (this.props.isInsetViewer) {
|
|
38
|
+
return /*#__PURE__*/React.createElement(DefaultCoverWrapper, null, /*#__PURE__*/React.createElement(IconTile, {
|
|
39
|
+
icon: AudioIcon,
|
|
40
|
+
label: "cover",
|
|
41
|
+
appearance: "gray",
|
|
42
|
+
size: "xlarge"
|
|
43
|
+
}));
|
|
34
44
|
} else {
|
|
35
45
|
return defaultCover;
|
|
36
46
|
}
|
|
@@ -82,6 +92,20 @@ export class AudioViewer extends BaseViewer {
|
|
|
82
92
|
} catch (e) {}
|
|
83
93
|
});
|
|
84
94
|
}
|
|
95
|
+
componentDidMount() {
|
|
96
|
+
super.componentDidMount();
|
|
97
|
+
if (this.props.isInsetViewer) {
|
|
98
|
+
var _this$props$setHasPla, _this$props;
|
|
99
|
+
(_this$props$setHasPla = (_this$props = this.props).setHasPlayerControls) === null || _this$props$setHasPla === void 0 ? void 0 : _this$props$setHasPla.call(_this$props, true);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
componentWillUnmount() {
|
|
103
|
+
if (this.props.isInsetViewer) {
|
|
104
|
+
var _this$props$setHasPla2, _this$props2;
|
|
105
|
+
(_this$props$setHasPla2 = (_this$props2 = this.props).setHasPlayerControls) === null || _this$props$setHasPla2 === void 0 ? void 0 : _this$props$setHasPla2.call(_this$props2, false);
|
|
106
|
+
}
|
|
107
|
+
super.componentWillUnmount();
|
|
108
|
+
}
|
|
85
109
|
get initialState() {
|
|
86
110
|
return {
|
|
87
111
|
content: Outcome.pending()
|
|
@@ -92,23 +116,33 @@ export class AudioViewer extends BaseViewer {
|
|
|
92
116
|
item,
|
|
93
117
|
showControls,
|
|
94
118
|
previewCount,
|
|
95
|
-
onCanPlay
|
|
119
|
+
onCanPlay,
|
|
120
|
+
isInsetViewer,
|
|
121
|
+
mediaFooterControls
|
|
96
122
|
} = this.props;
|
|
97
123
|
const useCustomAudioPlayer = !isIE();
|
|
98
124
|
const isAutoPlay = previewCount === 0;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
125
|
+
if (useCustomAudioPlayer) {
|
|
126
|
+
const player = /*#__PURE__*/React.createElement(AudioPlayer, {
|
|
127
|
+
"data-testid": "media-viewer-audio-content"
|
|
128
|
+
}, this.renderCover(), /*#__PURE__*/React.createElement(CustomAudioPlayerWrapper, null, /*#__PURE__*/React.createElement(InsetViewerProvider, {
|
|
129
|
+
isInsetViewer: isInsetViewer
|
|
130
|
+
}, /*#__PURE__*/React.createElement(CustomMediaPlayer, {
|
|
131
|
+
type: "audio",
|
|
132
|
+
isAutoPlay: isAutoPlay,
|
|
133
|
+
src: src,
|
|
134
|
+
fileId: item.id,
|
|
135
|
+
isShortcutEnabled: true,
|
|
136
|
+
showControls: showControls,
|
|
137
|
+
onCanPlay: onCanPlay,
|
|
138
|
+
onFirstPlay: this.onFirstPlay,
|
|
139
|
+
onError: this.onError,
|
|
140
|
+
controlsPortalElement: mediaFooterControls
|
|
141
|
+
}))));
|
|
142
|
+
// Same stage wrapper as the video, so audio fills the stage the same way.
|
|
143
|
+
return isInsetViewer ? /*#__PURE__*/React.createElement(CustomMediaPlayerWrapper, null, player) : player;
|
|
144
|
+
}
|
|
145
|
+
return /*#__PURE__*/React.createElement(AudioPlayer, null, this.renderCover(), /*#__PURE__*/React.createElement(CustomAudioPlayerWrapper, null, /*#__PURE__*/React.createElement(Audio, {
|
|
112
146
|
autoPlay: isAutoPlay,
|
|
113
147
|
controls: true,
|
|
114
148
|
ref: this.saveAudioElement,
|
|
@@ -157,4 +191,5 @@ export class AudioViewer extends BaseViewer {
|
|
|
157
191
|
}
|
|
158
192
|
URL.revokeObjectURL(content.data);
|
|
159
193
|
}
|
|
160
|
-
}
|
|
194
|
+
}
|
|
195
|
+
export const AudioViewer = withInsetViewerFooter(_AudioViewer);
|
package/dist/es2019/viewers/codeViewer/CodeRendererAdvanced/CodeRendererAdvanced.compiled.css
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
._154iidpf{top:0}
|
|
1
|
+
._2rko1mok{border-radius:var(--ds-radius-large,8px)}._154iidpf{top:0}
|
|
2
|
+
._18m915vq{overflow-y:hidden}
|
|
2
3
|
._18m91wug{overflow-y:auto}
|
|
4
|
+
._1ltv1tcg{left:24px}
|
|
3
5
|
._1ltvidpf{left:0}
|
|
6
|
+
._1reo15vq{overflow-x:hidden}
|
|
4
7
|
._1reo1wug{overflow-x:auto}
|
|
8
|
+
._1xi21tcg{right:24px}
|
|
5
9
|
._1xi2idpf{right:0}
|
|
10
|
+
._4t3i1osq{height:100%}
|
|
6
11
|
._4t3i8ved{height:75px}
|
|
7
12
|
._94n5idpf{bottom:0}
|
|
8
13
|
._bfhk1nox{background-color:#1d2125}
|
|
@@ -1,29 +1,44 @@
|
|
|
1
1
|
/* CodeRendererAdvanced.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
2
|
import "./CodeRendererAdvanced.compiled.css";
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
|
-
import React, { useRef } from 'react';
|
|
4
|
+
import React, { useRef, useState } from 'react';
|
|
5
5
|
import { syntaxHighlighting } from '@codemirror/language';
|
|
6
6
|
import { languages } from '@codemirror/language-data';
|
|
7
7
|
import { Compartment, EditorState } from '@codemirror/state';
|
|
8
8
|
import { EditorView, lineNumbers, gutters } from '@codemirror/view';
|
|
9
|
-
import {
|
|
9
|
+
import { useIsInsetViewer, useMediaFooterControls } from '../../../insetViewerContext';
|
|
10
|
+
import { INSET_VIEWER_GUTTER_PX } from '../../../styleWrappers';
|
|
11
|
+
import { CodeViewerFooter } from '../CodeViewerFooter';
|
|
12
|
+
import { cmTheme, highlightStyle, insetViewerCmTheme } from './theme';
|
|
10
13
|
const codeViewWrapperStyles = null;
|
|
14
|
+
const insetViewerCodeViewWrapperStyles = null;
|
|
15
|
+
|
|
16
|
+
// Gives the editor a definite height to fill, so its own scroller scrolls.
|
|
17
|
+
const insetViewerEditorHostStyles = null;
|
|
11
18
|
const codeViewerHeaderBarStyles = null;
|
|
12
19
|
export const CodeRendererAdvanced = props => {
|
|
20
|
+
var _props$item$name$spli;
|
|
21
|
+
const isInsetViewer = useIsInsetViewer();
|
|
22
|
+
const footerElement = useMediaFooterControls();
|
|
23
|
+
// CodeMirror already splits the document into lines, so the footer gets the count for free.
|
|
24
|
+
const [lineCount, setLineCount] = useState();
|
|
25
|
+
const extension = (_props$item$name$spli = props.item.name.split('.').pop()) !== null && _props$item$name$spli !== void 0 ? _props$item$name$spli : '';
|
|
26
|
+
const language = languages.find(lang => lang.extensions.includes(extension));
|
|
13
27
|
const nodeRef = useRef(elem => {
|
|
14
|
-
var _props$
|
|
28
|
+
var _props$onSuccess;
|
|
15
29
|
if (!elem) {
|
|
16
30
|
return;
|
|
17
31
|
}
|
|
18
|
-
const extension = (_props$item$name$spli = props.item.name.split('.').pop()) !== null && _props$item$name$spli !== void 0 ? _props$item$name$spli : '';
|
|
19
32
|
const languageCompartment = new Compartment();
|
|
20
33
|
const view = new EditorView({
|
|
21
34
|
doc: props.src,
|
|
22
35
|
parent: elem,
|
|
23
|
-
extensions: [lineNumbers(), gutters(), EditorState.readOnly.of(true), EditorView.editable.of(false), EditorView.lineWrapping, cmTheme, syntaxHighlighting(highlightStyle), languageCompartment.of([])]
|
|
36
|
+
extensions: [lineNumbers(), gutters(), EditorState.readOnly.of(true), EditorView.editable.of(false), EditorView.lineWrapping, isInsetViewer ? insetViewerCmTheme : cmTheme, syntaxHighlighting(highlightStyle), languageCompartment.of([])]
|
|
24
37
|
});
|
|
38
|
+
if (isInsetViewer) {
|
|
39
|
+
setLineCount(view.state.doc.lines);
|
|
40
|
+
}
|
|
25
41
|
(_props$onSuccess = props.onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(props);
|
|
26
|
-
const language = languages.find(lang => lang.extensions.includes(extension));
|
|
27
42
|
language === null || language === void 0 ? void 0 : language.load().then(val => {
|
|
28
43
|
view.dispatch({
|
|
29
44
|
effects: languageCompartment.reconfigure(val)
|
|
@@ -35,10 +50,15 @@ export const CodeRendererAdvanced = props => {
|
|
|
35
50
|
});
|
|
36
51
|
return /*#__PURE__*/React.createElement("div", {
|
|
37
52
|
"data-testid": props.testId,
|
|
38
|
-
className: ax(["_1reo1wug _18m91wug _kqswstnw _1ltvidpf _154iidpf _1xi2idpf _94n5idpf _bfhkvuon"])
|
|
39
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: ax(["_1reo1wug _18m91wug _kqswstnw _1ltvidpf _154iidpf _1xi2idpf _94n5idpf _bfhkvuon", isInsetViewer && "_2rko1mok _1reo15vq _18m915vq _1ltv1tcg _1xi21tcg"])
|
|
54
|
+
}, !isInsetViewer && /*#__PURE__*/React.createElement("div", {
|
|
40
55
|
className: ax(["_4t3i8ved _bfhk1nox"])
|
|
41
56
|
}), /*#__PURE__*/React.createElement("div", {
|
|
42
|
-
ref: nodeRef.current
|
|
57
|
+
ref: nodeRef.current,
|
|
58
|
+
className: ax([isInsetViewer && "_4t3i1osq"])
|
|
59
|
+
}), isInsetViewer && /*#__PURE__*/React.createElement(CodeViewerFooter, {
|
|
60
|
+
lineCount: lineCount,
|
|
61
|
+
languageName: language === null || language === void 0 ? void 0 : language.name,
|
|
62
|
+
footerElement: footerElement
|
|
43
63
|
}));
|
|
44
64
|
};
|
|
@@ -7,15 +7,21 @@ import { tags } from '@lezer/highlight';
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
const LINE_HEIGHT = '1.5rem';
|
|
10
|
-
|
|
10
|
+
const createCmTheme = isInsetViewer => CodeMirror.theme({
|
|
11
11
|
'&': {
|
|
12
12
|
backgroundColor: "var(--ds-background-neutral, #0515240F)",
|
|
13
13
|
padding: '0',
|
|
14
|
-
marginTop: "var(--ds-space-100, 8px)",
|
|
15
|
-
marginBottom: "var(--ds-space-100, 8px)",
|
|
14
|
+
marginTop: isInsetViewer ? "var(--ds-space-0, 0px)" : "var(--ds-space-100, 8px)",
|
|
15
|
+
marginBottom: isInsetViewer ? "var(--ds-space-0, 0px)" : "var(--ds-space-100, 8px)",
|
|
16
16
|
['fontSize']: '0.875rem',
|
|
17
17
|
// Custom syntax styling to match existing styling
|
|
18
|
-
['lineHeight']: LINE_HEIGHT
|
|
18
|
+
['lineHeight']: LINE_HEIGHT,
|
|
19
|
+
// The editor scrolls and is rounded itself, so its scrollbar sits inside the rounded corners.
|
|
20
|
+
...(isInsetViewer ? {
|
|
21
|
+
height: '100%',
|
|
22
|
+
overflow: 'hidden',
|
|
23
|
+
borderRadius: "var(--ds-radius-large, 8px)"
|
|
24
|
+
} : {})
|
|
19
25
|
},
|
|
20
26
|
'&.cm-focused': {
|
|
21
27
|
outline: 'none'
|
|
@@ -53,7 +59,13 @@ export const cmTheme = CodeMirror.theme({
|
|
|
53
59
|
backgroundColor: "var(--ds-background-neutral, #0515240F)",
|
|
54
60
|
border: 'none',
|
|
55
61
|
padding: "var(--ds-space-100, 8px)",
|
|
56
|
-
color: "var(--ds-text-subtlest, #6B6E76)"
|
|
62
|
+
color: "var(--ds-text-subtlest, #6B6E76)",
|
|
63
|
+
// CodeMirror sizes the gutter to the visible height, so once the editor scrolls it
|
|
64
|
+
// would stop short of the bottom. Let it grow with the content instead.
|
|
65
|
+
...(isInsetViewer ? {
|
|
66
|
+
height: 'auto',
|
|
67
|
+
minHeight: '100%'
|
|
68
|
+
} : {})
|
|
57
69
|
},
|
|
58
70
|
'.cm-lineNumbers .cm-gutterElement': {
|
|
59
71
|
paddingLeft: "var(--ds-space-0, 0px)",
|
|
@@ -68,6 +80,10 @@ export const cmTheme = CodeMirror.theme({
|
|
|
68
80
|
minHeight: LINE_HEIGHT
|
|
69
81
|
}
|
|
70
82
|
});
|
|
83
|
+
export const cmTheme = createCmTheme(false);
|
|
84
|
+
|
|
85
|
+
// The inset viewer's wrapper already frames the editor, so it has no margin, and the editor does the scrolling.
|
|
86
|
+
export const insetViewerCmTheme = createCmTheme(true);
|
|
71
87
|
function overflowShadow({
|
|
72
88
|
leftCoverWidth,
|
|
73
89
|
rightCoverWidth
|