Compare commits
51 Commits
Author | SHA1 | Date |
---|---|---|
![]() |
2079bdc8b4 | |
![]() |
c01f8c6a06 | |
![]() |
aa454b058d | |
![]() |
14ba80fed5 | |
![]() |
bd833cd530 | |
![]() |
3a444d289b | |
![]() |
89b674c513 | |
![]() |
57d7ba6ce3 | |
![]() |
d69a91111c | |
![]() |
b6588b7079 | |
![]() |
e129617119 | |
![]() |
40427e399c | |
![]() |
1079e67338 | |
![]() |
4e430a7e55 | |
![]() |
b12e8226c5 | |
![]() |
30c429c7b4 | |
![]() |
e5b8bbec96 | |
![]() |
9ff6eb4638 | |
![]() |
5c82aea1c9 | |
![]() |
68e249b2ce | |
![]() |
cc063d54f5 | |
![]() |
6993785de9 | |
![]() |
6e90fd2b28 | |
![]() |
549e413bf8 | |
![]() |
b4ae196052 | |
![]() |
c2affa08a1 | |
![]() |
ed48fa8621 | |
![]() |
78807984ca | |
![]() |
7f26585016 | |
![]() |
70997a27b8 | |
![]() |
a7a8932a58 | |
![]() |
f54d05855f | |
![]() |
8fca398a0a | |
![]() |
8fbeb8b502 | |
![]() |
d2e7d5c81f | |
![]() |
68c8cf8880 | |
![]() |
a983f90c35 | |
![]() |
556a0956c4 | |
![]() |
76f7fe7c63 | |
![]() |
399d6c35fa | |
![]() |
0cf3a6cb5a | |
![]() |
fc604da9fb | |
![]() |
3659fc4177 | |
![]() |
fa5d7b49ea | |
![]() |
30755e57ec | |
![]() |
745f7f333e | |
![]() |
efd81faa83 | |
![]() |
bcb5e1223a | |
![]() |
eedeac1e0d | |
![]() |
4d84be8a7c | |
![]() |
dcc5e57a90 |
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"scanSettings": {
|
||||||
|
"configMode": "AUTO",
|
||||||
|
"configExternalURL": "",
|
||||||
|
"projectToken": "",
|
||||||
|
"baseBranches": [],
|
||||||
|
"enableLicenseViolations": "true"
|
||||||
|
},
|
||||||
|
"checkRunSettings": {
|
||||||
|
"vulnerableCheckRunConclusionLevel": "failure",
|
||||||
|
"displayMode": "diff"
|
||||||
|
},
|
||||||
|
"issueSettings": {
|
||||||
|
"minSeverityLevel": "LOW",
|
||||||
|
"issueType": "DEPENDENCY"
|
||||||
|
},
|
||||||
|
"remediateSettings": {
|
||||||
|
"workflowRules": {
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
"extends": ["github>whitesource/merge-confidence:beta"],
|
||||||
|
"transitiveRemediation": true
|
||||||
|
}
|
||||||
|
}
|
59
CHANGELOG.md
59
CHANGELOG.md
|
@ -1,3 +1,62 @@
|
||||||
|
#### 0.1.15 (2024-07-31)
|
||||||
|
|
||||||
|
#### 0.1.14 (2024-07-31)
|
||||||
|
|
||||||
|
##### Bug Fixes
|
||||||
|
|
||||||
|
* readded missing library ([bd833cd5](https://github.com/Alcumus/react-doc-viewer/commit/bd833cd53083a634f3aa685608b733119cb87f92))
|
||||||
|
* possible fix for cjs support ([d69a9111](https://github.com/Alcumus/react-doc-viewer/commit/d69a91111cd65abf8865a9beabeda1b292e3fc0c))
|
||||||
|
|
||||||
|
##### Other Changes
|
||||||
|
|
||||||
|
* possible fix for cjs support" ([89b674c5](https://github.com/Alcumus/react-doc-viewer/commit/89b674c513a8733d2fe30adf893b2879dfa26a23))
|
||||||
|
|
||||||
|
#### 0.1.13 (2024-06-21)
|
||||||
|
|
||||||
|
#### 0.1.12 (2024-06-21)
|
||||||
|
|
||||||
|
#### 0.1.11 (2024-05-14)
|
||||||
|
|
||||||
|
#### 0.1.10 (2024-05-14)
|
||||||
|
|
||||||
|
#### 0.1.9 (2024-05-14)
|
||||||
|
|
||||||
|
#### 0.1.8 (2024-05-14)
|
||||||
|
|
||||||
|
##### Chores
|
||||||
|
|
||||||
|
* **deps:** update dependency react-pdf to v8 ([f54d0585](https://github.com/Alcumus/react-doc-viewer/commit/f54d05855f764ca1c522157116e832ee8ca7caf0))
|
||||||
|
|
||||||
|
#### 0.1.7 (2024-05-13)
|
||||||
|
|
||||||
|
##### Chores
|
||||||
|
|
||||||
|
* **deps:** update dependency pdfjs-dist to v4 ([556a0956](https://github.com/Alcumus/react-doc-viewer/commit/556a0956c4447bdf95a8bf17ea5595cf97c54fdd))
|
||||||
|
|
||||||
|
#### 0.1.6 (2024-05-13)
|
||||||
|
|
||||||
|
#### 0.1.5 (2020-10-29)
|
||||||
|
|
||||||
|
##### Bug Fixes
|
||||||
|
|
||||||
|
* **TIFFRenderer file Corrupt:** Don't crash if parseTIFF fails because of corrupted file. ([30755e57](https://github.com/Alcumus/react-doc-viewer/commit/30755e57ec0bef8a665ce1c6f9e8f93c4ada55dc))
|
||||||
|
|
||||||
|
#### 0.1.4 (2020-10-29)
|
||||||
|
|
||||||
|
##### Bug Fixes
|
||||||
|
|
||||||
|
* **TIFFRenderer crash:** If parseTiff is supplied with an undefined tiffArrayBuffer. Return out. ([eedeac1e](https://github.com/Alcumus/react-doc-viewer/commit/eedeac1e0deada4126e77058d5c52b1ed92f200f))
|
||||||
|
|
||||||
|
#### 0.1.3 (2020-10-29)
|
||||||
|
|
||||||
|
##### New Features
|
||||||
|
|
||||||
|
* **TIF:** Added .tif as an option to render within TIFFRenderer. ([a32f9b0f](https://github.com/Alcumus/react-doc-viewer/commit/a32f9b0ffff1a0a37d14a6dd948e1d0f52ffe6c6))
|
||||||
|
|
||||||
|
##### Other Changes
|
||||||
|
|
||||||
|
* fix/pptx ([60c27812](https://github.com/Alcumus/react-doc-viewer/commit/60c27812f658d4edf4a7cc1673c26a95b838eca1))
|
||||||
|
|
||||||
#### 0.1.2 (2020-10-26)
|
#### 0.1.2 (2020-10-26)
|
||||||
|
|
||||||
##### Bug Fixes
|
##### Bug Fixes
|
||||||
|
|
18
package.json
18
package.json
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "react-doc-viewer",
|
"name": "react-doc-viewer",
|
||||||
"version": "0.1.2",
|
"version": "0.1.14",
|
||||||
"description": "Document viewer for react. Renders online/local documents.",
|
"description": "Document viewer for react. Renders online/local documents.",
|
||||||
"author": "Matthew Mogford",
|
"author": "Matthew Mogford",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
@ -10,27 +10,27 @@
|
||||||
"main": "build/index.js",
|
"main": "build/index.js",
|
||||||
"types": "build/index.d.ts",
|
"types": "build/index.d.ts",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pdfjs-dist": "2.4.456",
|
"pdfjs-dist": "^4.5.136",
|
||||||
"react-pdf": "5.0.0",
|
"react-pdf": "9.0.0",
|
||||||
"styled-components": "^5.1.1",
|
"styled-components": "^5.3.11",
|
||||||
"wl-msg-reader": "^0.2.0"
|
"wl-msg-reader": "^0.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@testing-library/jest-dom": "^4.2.4",
|
"@testing-library/jest-dom": "^4.2.4",
|
||||||
"@testing-library/react": "^9.3.2",
|
"@testing-library/react": "^9.3.2",
|
||||||
"@testing-library/user-event": "^7.1.2",
|
"@testing-library/user-event": "^7.1.2",
|
||||||
|
"@types/babel__core": "7.1.19",
|
||||||
|
"@types/babel__traverse": "7.17.1",
|
||||||
"@types/jest": "^24.0.0",
|
"@types/jest": "^24.0.0",
|
||||||
"@types/node": "^12.0.0",
|
"@types/node": "^12.0.0",
|
||||||
"@types/pdfjs-dist": "2.1.5",
|
|
||||||
"@types/react": "^16.9.46",
|
"@types/react": "^16.9.46",
|
||||||
"@types/react-dom": "^16.9.8",
|
"@types/react-dom": "^16.9.8",
|
||||||
"@types/react-pdf": "4.0.5",
|
"@types/styled-components": "^5.1.34",
|
||||||
"@types/styled-components": "^5.1.2",
|
|
||||||
"generate-changelog": "^1.8.0",
|
"generate-changelog": "^1.8.0",
|
||||||
"react": "^16.13.1",
|
"react": "^16.13.1",
|
||||||
"react-dom": "^16.13.1",
|
"react-dom": "^16.13.1",
|
||||||
"react-scripts": "3.4.3",
|
"react-scripts": "4.0.3",
|
||||||
"typescript": "^3.9.7"
|
"typescript": "^4.0.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
|
"extends": [
|
||||||
|
"config:base"
|
||||||
|
]
|
||||||
|
}
|
|
@ -1,14 +1,16 @@
|
||||||
// @ts-ignore
|
|
||||||
import * as pdfjsWorker from "pdfjs-dist/build/pdf.worker.entry";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { pdfjs } from "react-pdf";
|
import { pdfjs } from "react-pdf";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import { DocRenderer, IStyledProps } from "../../types";
|
import { DocRenderer, IStyledProps } from "../../types";
|
||||||
import PDFPages from "./components/pages/PDFPages";
|
import { getMetaURL } from "../../utils/importMeta";
|
||||||
import PDFControls from "./components/PDFControls";
|
import PDFControls from "./components/PDFControls";
|
||||||
|
import PDFPages from "./components/pages/PDFPages";
|
||||||
import { PDFProvider } from "./state";
|
import { PDFProvider } from "./state";
|
||||||
|
|
||||||
pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
|
pdfjs.GlobalWorkerOptions.workerSrc = new URL(
|
||||||
|
"pdfjs-dist/build/pdf.worker.min.mjs",
|
||||||
|
getMetaURL()
|
||||||
|
).toString();
|
||||||
|
|
||||||
const PDFRenderer: DocRenderer = ({ mainState }) => {
|
const PDFRenderer: DocRenderer = ({ mainState }) => {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -11,15 +11,28 @@ const TIFFRenderer: DocRenderer = (props) => {
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const [loadedCanvas, setLoadedCanvas] = useState(false);
|
const [loadedCanvas, setLoadedCanvas] = useState(false);
|
||||||
|
const [corruptedFile, setCorruptedFile] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!currentDocument || loadedCanvas) return;
|
if (!currentDocument || loadedCanvas) return;
|
||||||
|
|
||||||
var canvas = document.getElementById("tiff-img");
|
var canvas = document.getElementById("tiff-img");
|
||||||
canvas && parseTIFF(currentDocument.fileData as ArrayBuffer, canvas);
|
try {
|
||||||
setLoadedCanvas(true);
|
canvas && parseTIFF(currentDocument.fileData as ArrayBuffer, canvas);
|
||||||
|
setLoadedCanvas(true);
|
||||||
|
} catch (error) {
|
||||||
|
setCorruptedFile(true);
|
||||||
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
if (corruptedFile) {
|
||||||
|
return (
|
||||||
|
<ImageProxyRenderer {...props}>
|
||||||
|
<div>Your file is corrupted. Please check it on your machine.</div>
|
||||||
|
</ImageProxyRenderer>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ImageProxyRenderer {...props}>
|
<ImageProxyRenderer {...props}>
|
||||||
<Canvas id="tiff-img" />
|
<Canvas id="tiff-img" />
|
||||||
|
|
|
@ -347,14 +347,14 @@ const parseFileDirectory = (byteOffset) => {
|
||||||
export const parseTIFF = (tiffArrayBuffer, _canvas) => {
|
export const parseTIFF = (tiffArrayBuffer, _canvas) => {
|
||||||
let canvas = _canvas || document.createElement("canvas");
|
let canvas = _canvas || document.createElement("canvas");
|
||||||
|
|
||||||
|
if (!tiffArrayBuffer) return;
|
||||||
|
|
||||||
tiffDataView = new DataView(tiffArrayBuffer);
|
tiffDataView = new DataView(tiffArrayBuffer);
|
||||||
// canvas = _canvas;
|
// canvas = _canvas;
|
||||||
|
|
||||||
littleEndian = isLittleEndian(tiffDataView);
|
littleEndian = isLittleEndian(tiffDataView);
|
||||||
|
|
||||||
if (!hasTowel(tiffDataView, littleEndian)) {
|
if (!hasTowel(tiffDataView, littleEndian)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var firstIFDByteOffset = getBytes(4, 4);
|
var firstIFDByteOffset = getBytes(4, 4);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
export const getMetaURL = () => import.meta.url;
|
|
@ -2,7 +2,7 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./build",
|
"outDir": "./build",
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"module": "commonjs",
|
"module": "esnext",
|
||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
"lib": ["dom", "dom.iterable", "esnext"],
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
|
|
Loading…
Reference in New Issue