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

[Editor] Change the enableML pref for enableAltText (bug 1905923)

We want to use this pref to make a Nimbus experiment in the next weeks.
This commit is contained in:
Calixte Denizet 2024-07-05 17:56:41 +02:00
parent e777ae2258
commit 0fba6e570e
8 changed files with 29 additions and 10 deletions

View file

@ -752,10 +752,11 @@ const PDFViewerApplication = {
},
get mlManager() {
const enableAltText = AppOptions.get("enableAltText");
return shadow(
this,
"mlManager",
AppOptions.get("enableML") === true ? new MLManager() : null
enableAltText === true ? new MLManager({ enableAltText }) : null
);
},

View file

@ -136,6 +136,11 @@ const defaultOptions = {
value: false,
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
},
enableAltText: {
/** @type {boolean} */
value: false,
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
},
enableHighlightEditor: {
// We'll probably want to make some experiments before enabling this
// in Firefox release, but it has to be temporary.
@ -152,11 +157,6 @@ const defaultOptions = {
value: typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING"),
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
},
enableML: {
/** @type {boolean} */
value: false,
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
},
enablePermissions: {
/** @type {boolean} */
value: false,

View file

@ -436,6 +436,10 @@ class ExternalServices extends BaseExternalServices {
}
class MLManager {
isEnabledFor(_name) {
return false;
}
async guess() {
return null;
}

View file

@ -303,6 +303,16 @@ class FirefoxScripting {
}
class MLManager {
#enabled = new Map();
constructor({ enableAltText }) {
this.#enabled.set("altText", enableAltText);
}
isEnabledFor(name) {
return this.#enabled.get(name);
}
guess(data) {
return FirefoxCom.requestAsync("mlGuess", data);
}

View file

@ -48,6 +48,10 @@ class ExternalServices extends BaseExternalServices {
}
class MLManager {
isEnabledFor(_name) {
return false;
}
async guess() {
return null;
}