document-viewer-ts
Advanced tools
Comparing version 0.3.1-legacy to 0.3.2-legacy
@@ -26,5 +26,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
const handleError = (containerDiv) => (err) => { | ||
const errorDiv = document.createElement('div'); | ||
errorDiv.textContent = `There was an error fetching your document. Please try again later. Error: ${err}`; | ||
containerDiv.append(errorDiv); | ||
renderErrorMessage(containerDiv)(`There was an error fetching your document. Please try again later. Error: ${err}`); | ||
}; | ||
@@ -198,2 +196,8 @@ const pdfScale = 10; | ||
}; | ||
const renderErrorMessage = (containerDiv) => (errorMessage) => { | ||
const errorDiv = document.createElement('div'); | ||
errorDiv.className = 'error-message'; | ||
errorDiv.textContent = errorMessage; | ||
containerDiv.appendChild(errorDiv); | ||
}; | ||
export const renderDocument = (containerDiv) => { | ||
@@ -210,3 +214,10 @@ var _a; | ||
case 'pdf': | ||
renderPDF(containerDiv, documentUrl); | ||
try { | ||
(() => globalThis)(); | ||
new File([], 'test.txt'); | ||
renderPDF(containerDiv, documentUrl); | ||
} | ||
catch (err) { | ||
renderErrorMessage(containerDiv)('Your browser does not support showing PDF previews. Click the download button to view this document.'); | ||
} | ||
return; | ||
@@ -213,0 +224,0 @@ case 'doc': |
@@ -29,5 +29,3 @@ "use strict"; | ||
const handleError = (containerDiv) => (err) => { | ||
const errorDiv = document.createElement('div'); | ||
errorDiv.textContent = `There was an error fetching your document. Please try again later. Error: ${err}`; | ||
containerDiv.append(errorDiv); | ||
renderErrorMessage(containerDiv)(`There was an error fetching your document. Please try again later. Error: ${err}`); | ||
}; | ||
@@ -202,2 +200,8 @@ const pdfScale = 10; | ||
}; | ||
const renderErrorMessage = (containerDiv) => (errorMessage) => { | ||
const errorDiv = document.createElement('div'); | ||
errorDiv.className = 'error-message'; | ||
errorDiv.textContent = errorMessage; | ||
containerDiv.appendChild(errorDiv); | ||
}; | ||
const renderDocument = (containerDiv) => { | ||
@@ -214,3 +218,10 @@ var _a; | ||
case 'pdf': | ||
(0, exports.renderPDF)(containerDiv, documentUrl); | ||
try { | ||
(() => globalThis)(); | ||
new File([], 'test.txt'); | ||
(0, exports.renderPDF)(containerDiv, documentUrl); | ||
} | ||
catch (err) { | ||
renderErrorMessage(containerDiv)('Your browser does not support showing PDF previews. Click the download button to view this document.'); | ||
} | ||
return; | ||
@@ -217,0 +228,0 @@ case 'doc': |
{ | ||
"name": "document-viewer-ts", | ||
"version": "0.3.1-legacy", | ||
"version": "0.3.2-legacy", | ||
"description": "PDF and MS Doc viewer written in TypeScript for React and vanilla JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57556
744