Move the disableCreateObjectURL option from the global PDFJS object and into getDocument instead

This commit is contained in:
Jonas Jenwald 2018-02-17 22:51:03 +01:00
parent 05c05bdef5
commit 1d03ad0060
11 changed files with 54 additions and 36 deletions

View file

@ -14,7 +14,7 @@
*/
import {
createObjectURL, createPromiseCapability, getFilenameFromUrl, PDFJS,
createObjectURL, createPromiseCapability, getFilenameFromUrl,
removeNullCharacters
} from 'pdfjs-lib';
@ -74,9 +74,9 @@ class PDFAttachmentViewer {
* @private
*/
_bindPdfLink(button, content, filename) {
if (PDFJS.disableCreateObjectURL) {
throw new Error('bindPdfLink: ' +
'Unsupported "PDFJS.disableCreateObjectURL" value.');
if (this.downloadManager.disableCreateObjectURL) {
throw new Error(
'bindPdfLink: Unsupported "disableCreateObjectURL" value.');
}
let blobUrl;
button.onclick = function() {
@ -141,7 +141,8 @@ class PDFAttachmentViewer {
div.className = 'attachmentsItem';
let button = document.createElement('button');
button.textContent = filename;
if (/\.pdf$/i.test(filename) && !PDFJS.disableCreateObjectURL) {
if (/\.pdf$/i.test(filename) &&
!this.downloadManager.disableCreateObjectURL) {
this._bindPdfLink(button, item.content, filename);
} else {
this._bindLink(button, item.content, filename);