1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Add the possibility to change some pdfjs preferences from the viewer (bug 1908483)

This commit is contained in:
Calixte Denizet 2024-07-17 19:51:53 +02:00
parent 86eb5ba700
commit 6cc32b699f
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)
);
}
/**