mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
Replace the OVERRIDES
list in PDFViewerApplication._readPreferences
with a disablePreferences
, in GENERIC
builds, `AppOption instead
Rather than having a (somewhat) randomly choosen list of Preferences which `AppOptions` are allowed to override, it makes much more sense to simply add an AppOption to allow custom implementations to ignore Preferences altogether (it's also inline with the AppOption that allows the `ViewHistory` to be bypassed on load).
This commit is contained in:
parent
1cb7cc9bf4
commit
d9743e462d
2 changed files with 14 additions and 13 deletions
19
web/app.js
19
web/app.js
|
@ -169,21 +169,14 @@ let PDFViewerApplication = {
|
|||
* @private
|
||||
*/
|
||||
async _readPreferences() {
|
||||
// A subset of the Preferences that `AppOptions`, for compatibility reasons,
|
||||
// is allowed to override if the `AppOptions` values matches the ones below.
|
||||
const OVERRIDES = {
|
||||
disableFontFace: true,
|
||||
disableRange: true,
|
||||
disableStream: true,
|
||||
textLayerMode: TextLayerMode.DISABLE,
|
||||
};
|
||||
|
||||
if (AppOptions.get('disablePreferences') === true) {
|
||||
// Give custom implementations of the default viewer a simpler way to
|
||||
// opt-out of having the `Preferences` override existing `AppOptions`.
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const prefs = await this.preferences.getAll();
|
||||
for (let name in prefs) {
|
||||
if ((name in OVERRIDES) && AppOptions.get(name) === OVERRIDES[name]) {
|
||||
continue;
|
||||
}
|
||||
for (const name in prefs) {
|
||||
AppOptions.set(name, prefs[name]);
|
||||
}
|
||||
} catch (reason) { }
|
||||
|
|
|
@ -58,6 +58,9 @@ const defaultOptions = {
|
|||
value: false,
|
||||
kind: OptionKind.VIEWER,
|
||||
},
|
||||
/**
|
||||
* The `disablePreferences` is, conditionally, defined below.
|
||||
*/
|
||||
enablePrintAutoRotate: {
|
||||
/** @type {boolean} */
|
||||
value: false,
|
||||
|
@ -218,6 +221,11 @@ const defaultOptions = {
|
|||
};
|
||||
if (typeof PDFJSDev === 'undefined' ||
|
||||
PDFJSDev.test('!PRODUCTION || GENERIC')) {
|
||||
defaultOptions.disablePreferences = {
|
||||
/** @type {boolean} */
|
||||
value: false,
|
||||
kind: OptionKind.VIEWER,
|
||||
};
|
||||
defaultOptions.locale = {
|
||||
/** @type {string} */
|
||||
value: (typeof navigator !== 'undefined' ? navigator.language : 'en-US'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue