Fix PDF Viewer worker URL and restore default streaming behavior
All checks were successful
Automated Container Build / build-and-push (push) Successful in 28s
All checks were successful
Automated Container Build / build-and-push (push) Successful in 28s
This commit is contained in:
parent
3c47584bb2
commit
6ee6ef376c
1 changed files with 4 additions and 7 deletions
|
|
@ -7,9 +7,10 @@ import { useInView } from 'react-intersection-observer';
|
||||||
import 'react-pdf/dist/Page/AnnotationLayer.css';
|
import 'react-pdf/dist/Page/AnnotationLayer.css';
|
||||||
import 'react-pdf/dist/Page/TextLayer.css';
|
import 'react-pdf/dist/Page/TextLayer.css';
|
||||||
|
|
||||||
if (typeof window !== 'undefined') {
|
pdfjs.GlobalWorkerOptions.workerSrc = new URL(
|
||||||
pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.mjs`;
|
'pdfjs-dist/build/pdf.worker.min.mjs',
|
||||||
}
|
import.meta.url,
|
||||||
|
).toString();
|
||||||
|
|
||||||
function LazyPage({ pageNumber, scale, containerWidth }: { pageNumber: number; scale: number; containerWidth: number }) {
|
function LazyPage({ pageNumber, scale, containerWidth }: { pageNumber: number; scale: number; containerWidth: number }) {
|
||||||
const { ref, inView } = useInView({
|
const { ref, inView } = useInView({
|
||||||
|
|
@ -132,10 +133,6 @@ export default function PdfViewer({ url }: { url: string }) {
|
||||||
console.error('Failed to load PDF:', error);
|
console.error('Failed to load PDF:', error);
|
||||||
setLoadError('Failed to load PDF file.');
|
setLoadError('Failed to load PDF file.');
|
||||||
}}
|
}}
|
||||||
options={{
|
|
||||||
disableAutoFetch: true,
|
|
||||||
disableStream: true,
|
|
||||||
}}
|
|
||||||
loading={
|
loading={
|
||||||
<div className="flex flex-col items-center justify-center h-full mt-20 gap-3">
|
<div className="flex flex-col items-center justify-center h-full mt-20 gap-3">
|
||||||
<Loader2 className="w-8 h-8 animate-spin" style={{ color: 'var(--color-accent)' }} />
|
<Loader2 className="w-8 h-8 animate-spin" style={{ color: 'var(--color-accent)' }} />
|
||||||
|
|
|
||||||
Reference in a new issue