Add the docBaseUrl
API parameter to AppOptions
in the viewer
This unfortunately required a bit of special handling, to correctly deal with the various extension builds.
This commit is contained in:
parent
0cc0789af3
commit
ba2c042a75
18
web/app.js
18
web/app.js
@ -642,16 +642,20 @@ let PDFViewerApplication = {
|
|||||||
this.setTitleUsingUrl(file.originalUrl);
|
this.setTitleUsingUrl(file.originalUrl);
|
||||||
parameters.url = file.url;
|
parameters.url = file.url;
|
||||||
}
|
}
|
||||||
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) {
|
|
||||||
parameters.docBaseUrl = document.URL.split('#')[0];
|
|
||||||
} else if (typeof PDFJSDev !== 'undefined' &&
|
|
||||||
PDFJSDev.test('FIREFOX || MOZCENTRAL || CHROME')) {
|
|
||||||
parameters.docBaseUrl = this.baseUrl;
|
|
||||||
}
|
|
||||||
// Set the necessary API parameters, using the available options.
|
// Set the necessary API parameters, using the available options.
|
||||||
const apiParameters = AppOptions.getAll(OptionKind.API);
|
const apiParameters = AppOptions.getAll(OptionKind.API);
|
||||||
for (let key in apiParameters) {
|
for (let key in apiParameters) {
|
||||||
parameters[key] = apiParameters[key];
|
let value = apiParameters[key];
|
||||||
|
|
||||||
|
if (key === 'docBaseUrl' && !value) {
|
||||||
|
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) {
|
||||||
|
value = document.URL.split('#')[0];
|
||||||
|
} else if (typeof PDFJSDev !== 'undefined' &&
|
||||||
|
PDFJSDev.test('FIREFOX || MOZCENTRAL || CHROME')) {
|
||||||
|
value = this.baseUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parameters[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args) {
|
if (args) {
|
||||||
|
@ -105,6 +105,9 @@ const defaultOptions = {
|
|||||||
value: false,
|
value: false,
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* The `printResolution` is, conditionally, defined below.
|
||||||
|
*/
|
||||||
renderer: {
|
renderer: {
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
value: 'canvas',
|
value: 'canvas',
|
||||||
@ -183,6 +186,11 @@ const defaultOptions = {
|
|||||||
value: false,
|
value: false,
|
||||||
kind: OptionKind.API + OptionKind.PREFERENCE,
|
kind: OptionKind.API + OptionKind.PREFERENCE,
|
||||||
},
|
},
|
||||||
|
docBaseUrl: {
|
||||||
|
/** @type {string} */
|
||||||
|
value: '',
|
||||||
|
kind: OptionKind.API,
|
||||||
|
},
|
||||||
isEvalSupported: {
|
isEvalSupported: {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
value: true,
|
value: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user