diff --git a/server/__tests__/fileUpload.test.ts b/server/__tests__/fileUpload.test.ts index f4cc3070f..af1135cc2 100644 --- a/server/__tests__/fileUpload.test.ts +++ b/server/__tests__/fileUpload.test.ts @@ -13,6 +13,27 @@ beforeAll(() => { }); beforeEach(() => {}); afterAll(() => { + const pathToFiles = 'server/fileUpload/images/1/'; + fs.readdir(pathToFiles, (err, files) => { + if (err) { + console.error(err); + } + if (files) { + for (const file of files) { + fs.unlink(path.join(pathToFiles, file), (err) => { + if (err) { + console.error(err); + } + }); + } + } + fs.rmdir(pathToFiles, (err) => { + if (err) { + console.error(err); + } + }); + }); + return appDataSource.destroy(); }); diff --git a/src/components/activities/content/editors/DocumentEditor/PdfDisplay.tsx b/src/components/activities/content/editors/DocumentEditor/PdfDisplay.tsx index a361fdfd1..cfb52c59c 100644 --- a/src/components/activities/content/editors/DocumentEditor/PdfDisplay.tsx +++ b/src/components/activities/content/editors/DocumentEditor/PdfDisplay.tsx @@ -1,12 +1,34 @@ -import React from 'react'; +import React, { useState } from 'react'; import { Document, Page, pdfjs } from 'react-pdf'; -pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`; +import 'react-pdf/dist/esm/Page/TextLayer.css'; +import 'react-pdf/dist/esm/Page/AnnotationLayer.css'; + +pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.js`; + +const options = { + cMapUrl: `https://unpkg.com/pdfjs-dist@${pdfjs.version}/cmaps/`, +}; export default function PdfDisplay({ url }: { url: string }) { + const [numPages, setNumPages] = useState(1); + function onDocumentLoadSuccess({ numPages }: { numPages: number }): void { + setNumPages(numPages); + } + return ( - - + + {Array.from(Array(numPages).keys()).map((v) => ( +
+ +
+ ))}
); } diff --git a/src/styles/base.scss b/src/styles/base.scss index 0f3c2e35a..8ae442190 100644 --- a/src/styles/base.scss +++ b/src/styles/base.scss @@ -217,3 +217,7 @@ main { left: 10vw; } } + +.linkAnnotation { + opacity: 0; +}