mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-18 06:11:33 -05:00
3c01402bbd
PDF Detach v2 GitOrigin-RevId: 3deb76474185f9176cde23ab32ef51b90df6e8e9
25 lines
573 B
JavaScript
25 lines
573 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, 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)
|