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 #18471 from calixteman/bug1909097

Add a pref containing the url for the sumo page about alt text (bug 1909097)
This commit is contained in:
calixteman 2024-07-21 17:07:29 +02:00 committed by GitHub
commit d0b580e79f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 18 additions and 1 deletions

View file

@ -55,6 +55,10 @@
"type": "boolean",
"default": false
},
"altTextLearnMoreUrl": {
"type": "string",
"default": ""
},
"enableUpdatedAddImage": {
"type": "boolean",
"default": false

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) {