mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-10-30 01:26:43 +08:00
fix (pdf): js based pdfviewer as fallback
This commit is contained in:
@ -2,7 +2,7 @@ import React, { useState } from "react";
|
|||||||
import { Document, Page, pdfjs } from "react-pdf";
|
import { Document, Page, pdfjs } from "react-pdf";
|
||||||
|
|
||||||
import "react-pdf/dist/esm/Page/AnnotationLayer.css";
|
import "react-pdf/dist/esm/Page/AnnotationLayer.css";
|
||||||
pdfjs.GlobalWorkerOptions.workerSrc = "/assets/vendor/pdfjs/2.6.347/build/pdf.worker.js";
|
pdfjs.GlobalWorkerOptions.workerSrc = "/assets/vendor/node_modules/pdfjs-dist/build/pdf.worker.js";
|
||||||
|
|
||||||
export function PDFJSViewer({ src }) {
|
export function PDFJSViewer({ src }) {
|
||||||
const [numPages, setNumPages] = useState(0);
|
const [numPages, setNumPages] = useState(0);
|
||||||
@ -12,7 +12,7 @@ export function PDFJSViewer({ src }) {
|
|||||||
file={src}
|
file={src}
|
||||||
onLoadSuccess={(d) => setNumPages(d["numPages"])}
|
onLoadSuccess={(d) => setNumPages(d["numPages"])}
|
||||||
options={{
|
options={{
|
||||||
cMapUrl: "/assets/vendor/pdfjs/cmaps/",
|
cMapUrl: "/assets/vendor/node_modules/pdfjs-dist/cmaps/",
|
||||||
cMapPacked: true,
|
cMapPacked: true,
|
||||||
}}>
|
}}>
|
||||||
{
|
{
|
||||||
|
|||||||
@ -73,8 +73,8 @@ const config = {
|
|||||||
{ from: "assets/fonts/*" },
|
{ from: "assets/fonts/*" },
|
||||||
], { context: path.join(__dirname, "client") }),
|
], { context: path.join(__dirname, "client") }),
|
||||||
new CopyWebpackPlugin([
|
new CopyWebpackPlugin([
|
||||||
{ from: "node_modules/pdfjs-dist/build/*.js", to: "assets/vendor/pdfjs/2.6.347/build/" },
|
{ from: "node_modules/pdfjs-dist/build/*.js", to: "assets/vendor/" },
|
||||||
{ from: "node_modules/pdfjs-dist/cmaps/", to: "assets/vendor/pdfjs/2.6.347/cmaps/" },
|
{ from: "node_modules/pdfjs-dist/cmaps/*", to: "assets/vendor/" },
|
||||||
]),
|
]),
|
||||||
// new BundleAnalyzerPlugin()
|
// new BundleAnalyzerPlugin()
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user