mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Convert PDF.js code to TypeScript
GitOrigin-RevId: 840bc48816d78497131b927522b4f6f7940bb0c4
This commit is contained in:
@@ -15,9 +15,9 @@ const FileViewPdf: FC<{
|
||||
const handleContainer = useCallback(
|
||||
async (element: HTMLDivElement | null) => {
|
||||
if (element) {
|
||||
const { PDFJS } = await import(
|
||||
'../../pdf-preview/util/pdf-js-versions'
|
||||
).then(m => m.default as any)
|
||||
const { loadPdfDocumentFromUrl } = await import(
|
||||
'@/features/pdf-preview/util/pdf-js'
|
||||
)
|
||||
|
||||
// bail out if loading PDF.js took too long
|
||||
if (!mountedRef.current) {
|
||||
@@ -33,10 +33,7 @@ const FileViewPdf: FC<{
|
||||
return
|
||||
}
|
||||
|
||||
const pdf = await PDFJS.getDocument({
|
||||
url: preview.url,
|
||||
isEvalSupported: false,
|
||||
}).promise
|
||||
const pdf = await loadPdfDocumentFromUrl(preview.url).promise
|
||||
|
||||
// bail out if loading the PDF took too long
|
||||
if (!mountedRef.current) {
|
||||
@@ -61,7 +58,7 @@ const FileViewPdf: FC<{
|
||||
|
||||
element.append(canvas)
|
||||
page.render({
|
||||
canvasContext: canvas.getContext('2d'),
|
||||
canvasContext: canvas.getContext('2d')!,
|
||||
viewport,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user