1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Merge pull request #18449 from calixteman/bug1908483

Add the possibility to change some pdfjs preferences from the viewer (bug 1908483)
This commit is contained in:
calixteman 2024-07-18 10:19:50 +02:00 committed by GitHub
commit e1f64a5b3e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View file

@ -150,6 +150,10 @@ class Preferences extends BasePreferences {
async _readFromStorage(prefObj) {
return FirefoxCom.requestAsync("getPreferences", prefObj);
}
async _writeToStorage(prefObj) {
return FirefoxCom.requestAsync("setPreferences", prefObj);
}
}
(function listenFindEvents() {

View file

@ -108,14 +108,14 @@ class BasePreferences {
* provided that the preference exists and the types match.
*/
async set(name, value) {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
throw new Error("Please use `about:config` to change preferences.");
}
await this.#initializedPromise;
AppOptions.setAll({ [name]: value }, /* prefs = */ true);
const prefs = AppOptions.getAll(OptionKind.PREFERENCE);
await this._writeToStorage(prefs);
await this._writeToStorage(
typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")
? { [name]: AppOptions.get(name) }
: AppOptions.getAll(OptionKind.PREFERENCE)
);
}
/**