mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
df6147bb4d
GitOrigin-RevId: 840bc48816d78497131b927522b4f6f7940bb0c4
25 lines
601 B
TypeScript
25 lines
601 B
TypeScript
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)
|