2021-10-21 06:31:51 -04:00
|
|
|
import { lazy, memo } from 'react'
|
2021-10-15 05:39:56 -04:00
|
|
|
import { useCompileContext } from '../../../shared/context/compile-context'
|
2021-09-30 07:29:25 -04:00
|
|
|
|
|
|
|
const PdfJsViewer = lazy(() =>
|
|
|
|
import(/* webpackChunkName: "pdf-js-viewer" */ './pdf-js-viewer')
|
|
|
|
)
|
|
|
|
|
|
|
|
function PdfViewer() {
|
2021-10-21 06:31:51 -04:00
|
|
|
const { pdfUrl, pdfViewer } = useCompileContext()
|
2021-09-30 07:29:25 -04:00
|
|
|
|
|
|
|
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)
|