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

Add a pref containing the url for the sumo page about alt text (bug 1909097)

This commit is contained in:
Calixte Denizet 2024-07-21 14:48:39 +02:00
parent ebb3d27125
commit 5860c7bcc9
4 changed files with 18 additions and 1 deletions

View file

@ -209,6 +209,7 @@ const PDFViewerApplication = {
// We want to load the image-to-text AI engine as soon as possible.
this.mlManager = new MLManager({
enableAltText: AppOptions.get("enableAltText"),
altTextLearnMoreUrl: AppOptions.get("altTextLearnMoreUrl"),
});
}

View file

@ -117,6 +117,14 @@ const defaultOptions = {
kind: OptionKind.BROWSER + OptionKind.EVENT_DISPATCH,
},
altTextLearnMoreUrl: {
/** @type {string} */
value:
typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")
? "https://support.mozilla.org/1/firefox/%VERSION%/%OS%/%LOCALE%/pdf-alt-text"
: "",
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
},
annotationEditorMode: {
/** @type {number} */
value: 0,

View file

@ -324,10 +324,14 @@ class MLManager {
return FirefoxCom.requestAsync("mlGuess", data);
}
enable({ enableAltText, listenToProgress }) {
enable({ altTextLearnMoreUrl, enableAltText, listenToProgress }) {
if (enableAltText) {
this.#loadAltTextEngine(listenToProgress);
}
// The `altTextLearnMoreUrl` is used to provide a link to the user to learn
// more about the "alt text" feature.
// The link is used in the Alt Text dialog or in the Image Settings.
this.altTextLearnMoreUrl = altTextLearnMoreUrl;
}
async #loadAltTextEngine(listenToProgress) {