diff --git a/src/component/main/InnerNMRiumContents.tsx b/src/component/main/InnerNMRiumContents.tsx index be0d5b7a3d..33dd6cfd34 100644 --- a/src/component/main/InnerNMRiumContents.tsx +++ b/src/component/main/InnerNMRiumContents.tsx @@ -1,20 +1,17 @@ /** @jsxImportSource @emotion/react */ import { Global, css } from '@emotion/react'; -import { MouseEvent, RefObject, useCallback } from 'react'; +import { MouseEvent, RefObject, useCallback, useEffect, useState } from 'react'; import { useFullscreen } from 'react-science/ui'; import checkModifierKeyActivated from '../../data/utilities/checkModifierKeyActivated'; -import Viewer1D from '../1d/Viewer1D'; -import FloatMoleculeStructures from '../1d-2d/components/FloatMoleculeStructures'; -import Viewer2D from '../2d/Viewer2D'; import KeysListenerTracker from '../EventsTrackers/KeysListenerTracker'; -import { useChartData } from '../context/ChartContext'; import Header from '../header/Header'; import DropZone from '../loader/DropZone'; import Panels from '../panels/Panels'; import ToolBar from '../toolbar/ToolBar'; +import { NMRiumViewer } from './NMRiumViewer'; import { SplitPaneWrapper } from './SplitPaneWrapper'; import { StateError } from './StateError'; @@ -67,6 +64,12 @@ const containerStyles = css` padding: 5px; box-shadow: none; } + + @page { + size: a4 landscape; + margin: 0; + padding: 0; + } `; interface InnerNMRiumContentsProps { @@ -81,7 +84,6 @@ export function InnerNMRiumContents(props: InnerNMRiumContentsProps) { const { emptyText, mainDivRef, elementsWrapperRef, rootRef, viewerRef } = props; - const { displayerMode } = useChartData(); const { isFullScreen } = useFullscreen(); const preventContextMenuHandler = useCallback( @@ -93,6 +95,25 @@ export function InnerNMRiumContents(props: InnerNMRiumContentsProps) { [], ); + const [printFlag, setPrintFlag] = useState(false); + + useEffect(() => { + function handleBeforePrint() { + setPrintFlag(true); + } + function handleAfterPrint() { + setPrintFlag(false); + } + + window.addEventListener('beforeprint', handleBeforePrint); + window.addEventListener('afterprint', handleAfterPrint); + + return () => { + window.removeEventListener('beforeprint', handleBeforePrint); + window.removeEventListener('afterprint', handleAfterPrint); + }; + }, []); + return ( <> @@ -112,66 +133,63 @@ export function InnerNMRiumContents(props: InnerNMRiumContentsProps) { onContextMenu={preventContextMenuHandler} style={{ height: '100%', width: '100%' }} > - -
-
- + {!printFlag && ( +
- - -
- -
- - {displayerMode === '1D' ? ( - - ) : ( - - )} -
-
- -
+
+ > + + +
+ + + +
+ +
+ +
+
-
-
+ + )} + {printFlag && ( + + )}
); diff --git a/src/component/main/NMRiumViewer.tsx b/src/component/main/NMRiumViewer.tsx new file mode 100644 index 0000000000..e82af10b2f --- /dev/null +++ b/src/component/main/NMRiumViewer.tsx @@ -0,0 +1,40 @@ +import { CSSProperties, RefObject } from 'react'; + +import Viewer1D from '../1d/Viewer1D'; +import FloatMoleculeStructures from '../1d-2d/components/FloatMoleculeStructures'; +import Viewer2D from '../2d/Viewer2D'; +import { useChartData } from '../context/ChartContext'; + +import { NMRiumProps } from './NMRium'; + +interface NMRiumViewerProps { + emptyText: NMRiumProps['emptyText']; + viewerRef: RefObject; + style?: CSSProperties; +} + +export function NMRiumViewer(props: NMRiumViewerProps) { + const { emptyText, viewerRef, style = {} } = props; + const { displayerMode } = useChartData(); + + return ( +
+ + {displayerMode === '1D' ? ( + + ) : ( + + )} +
+ ); +} diff --git a/src/demo/Sidebar.tsx b/src/demo/Sidebar.tsx index c8abf61e95..ca20e16d2e 100644 --- a/src/demo/Sidebar.tsx +++ b/src/demo/Sidebar.tsx @@ -102,6 +102,7 @@ function Sidebar(props) { return (
div { + width: 100% !important; + margin: 0 !important; + padding: 0 !important; + } + + .demo-side-bar, + .demo-main-container > div > div:first-child { + display: none !important; + } +} + .rc-menu { border: none !important; box-shadow: none !important; diff --git a/src/demo/layouts/Admin.tsx b/src/demo/layouts/Admin.tsx index d3bd4f7168..1d6bfb6fa4 100644 --- a/src/demo/layouts/Admin.tsx +++ b/src/demo/layouts/Admin.tsx @@ -71,6 +71,7 @@ export function Dashboard(props: DashboardProps) { onMenuToggle={toggleMenu} />