mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 12:14:05 -05:00
913a62fbc8
GitOrigin-RevId: 80362a00ae6b73616a6fa9b3193b9b9974b5fd35
25 lines
539 B
JavaScript
25 lines
539 B
JavaScript
import { lazy, memo } from 'react'
|
|
import { useCompileContext } from '../../../shared/context/compile-context'
|
|
|
|
const PdfJsViewer = lazy(() =>
|
|
import(/* webpackChunkName: "pdf-js-viewer" */ './pdf-js-viewer')
|
|
)
|
|
|
|
function PdfViewer() {
|
|
const { pdfUrl, pdfViewer } = useCompileContext()
|
|
|
|
if (!pdfUrl) {
|
|
return null
|
|
}
|
|
|
|
switch (pdfViewer) {
|
|
case 'native':
|
|
return <iframe title="PDF Preview" src={pdfUrl} />
|
|
|
|
case 'pdfjs':
|
|
default:
|
|
return <PdfJsViewer url={pdfUrl} />
|
|
}
|
|
}
|
|
|
|
export default memo(PdfViewer)
|