mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-12 05:51:39 -05:00
9daa8f5d98
[web] rename all the JSX files to .jsx/.tsx GitOrigin-RevId: 82056ae47e017523722cf258dcc83c8a925a28f7
25 lines
600 B
JavaScript
25 lines
600 B
JavaScript
import { lazy, memo } from 'react'
|
|
import { useDetachCompileContext as useCompileContext } from '../../../shared/context/detach-compile-context'
|
|
|
|
const PdfJsViewer = lazy(() =>
|
|
import(/* webpackChunkName: "pdf-js-viewer" */ './pdf-js-viewer')
|
|
)
|
|
|
|
function PdfViewer() {
|
|
const { pdfUrl, pdfFile, pdfViewer } = useCompileContext()
|
|
|
|
if (!pdfUrl) {
|
|
return null
|
|
}
|
|
|
|
switch (pdfViewer) {
|
|
case 'native':
|
|
return <iframe title="PDF Preview" src={pdfUrl} />
|
|
|
|
case 'pdfjs':
|
|
default:
|
|
return <PdfJsViewer url={pdfUrl} pdfFile={pdfFile} />
|
|
}
|
|
}
|
|
|
|
export default memo(PdfViewer)
|