mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 01:35:43 +02:00
Add the possibility to change some pdfjs preferences from the viewer (bug 1908483)
This commit is contained in:
parent
86eb5ba700
commit
6cc32b699f
2 changed files with 9 additions and 5 deletions
|
@ -150,6 +150,10 @@ class Preferences extends BasePreferences {
|
||||||
async _readFromStorage(prefObj) {
|
async _readFromStorage(prefObj) {
|
||||||
return FirefoxCom.requestAsync("getPreferences", prefObj);
|
return FirefoxCom.requestAsync("getPreferences", prefObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _writeToStorage(prefObj) {
|
||||||
|
return FirefoxCom.requestAsync("setPreferences", prefObj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(function listenFindEvents() {
|
(function listenFindEvents() {
|
||||||
|
|
|
@ -108,14 +108,14 @@ class BasePreferences {
|
||||||
* provided that the preference exists and the types match.
|
* provided that the preference exists and the types match.
|
||||||
*/
|
*/
|
||||||
async set(name, value) {
|
async set(name, value) {
|
||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
|
||||||
throw new Error("Please use `about:config` to change preferences.");
|
|
||||||
}
|
|
||||||
await this.#initializedPromise;
|
await this.#initializedPromise;
|
||||||
AppOptions.setAll({ [name]: value }, /* prefs = */ true);
|
AppOptions.setAll({ [name]: value }, /* prefs = */ true);
|
||||||
|
|
||||||
const prefs = AppOptions.getAll(OptionKind.PREFERENCE);
|
await this._writeToStorage(
|
||||||
await this._writeToStorage(prefs);
|
typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")
|
||||||
|
? { [name]: AppOptions.get(name) }
|
||||||
|
: AppOptions.getAll(OptionKind.PREFERENCE)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue