Skip to content

Commit

Permalink
Fix/pdf preview in build (#11621)
Browse files Browse the repository at this point in the history
  • Loading branch information
zxhlyh authored Dec 13, 2024
1 parent fa3dcbb commit 3d803c2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
17 changes: 17 additions & 0 deletions web/app/components/base/file-uploader/dynamic-pdf-preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use client'

import dynamic from 'next/dynamic'

type DynamicPdfPreviewProps = {
url: string
onCancel: () => void
}
const DynamicPdfPreview = dynamic<DynamicPdfPreviewProps>(
(() => {
if (typeof window !== 'undefined')
return import('./pdf-preview')
}) as any,
{ ssr: false }, // This will prevent the module from being loaded on the server-side
)

export default DynamicPdfPreview
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import ProgressCircle from '@/app/components/base/progress-bar/progress-circle'
import { ReplayLine } from '@/app/components/base/icons/src/vender/other'
import ActionButton from '@/app/components/base/action-button'
import Button from '@/app/components/base/button'
import PdfPreview from '@/app/components/base/file-uploader/pdf-preview'
import PdfPreview from '@/app/components/base/file-uploader/dynamic-pdf-preview'
import AudioPreview from '@/app/components/base/file-uploader/audio-preview'
import VideoPreview from '@/app/components/base/file-uploader/video-preview'

Expand Down
1 change: 1 addition & 0 deletions web/app/components/base/file-uploader/pdf-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const PdfPreview: FC<PdfPreviewProps> = ({
style={{ transform: `scale(${scale})`, transformOrigin: 'center', scrollbarWidth: 'none', msOverflowStyle: 'none' }}
>
<PdfLoader
workerSrc='/pdf.worker.min.mjs'
url={url}
beforeLoad={<div className='flex justify-center items-center h-64'><Loading type='app' /></div>}
>
Expand Down
21 changes: 21 additions & 0 deletions web/public/pdf.worker.min.mjs

Large diffs are not rendered by default.

0 comments on commit 3d803c2

Please sign in to comment.