mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 02:05:37 +02:00
Merge pull request #18484 from calixteman/bug1909310
Add a pref to know if the alt-text must be automatically generated (bug 1909310)
This commit is contained in:
commit
33493301b3
4 changed files with 21 additions and 12 deletions
|
@ -55,6 +55,10 @@
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
|
"enableGuessAltText": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": true
|
||||||
|
},
|
||||||
"altTextLearnMoreUrl": {
|
"altTextLearnMoreUrl": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": ""
|
"default": ""
|
||||||
|
|
20
web/app.js
20
web/app.js
|
@ -205,10 +205,10 @@ const PDFViewerApplication = {
|
||||||
if (mode) {
|
if (mode) {
|
||||||
document.documentElement.classList.add(mode);
|
document.documentElement.classList.add(mode);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (AppOptions.get("enableAltText")) {
|
||||||
// We want to load the image-to-text AI engine as soon as possible.
|
// We want to load the image-to-text AI engine as soon as possible.
|
||||||
this.mlManager = new MLManager({
|
this.mlManager = new MLManager({
|
||||||
enableAltText: AppOptions.get("enableAltText"),
|
enableGuessAltText: AppOptions.get("enableGuessAltText"),
|
||||||
altTextLearnMoreUrl: AppOptions.get("altTextLearnMoreUrl"),
|
altTextLearnMoreUrl: AppOptions.get("altTextLearnMoreUrl"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -376,14 +376,14 @@ const PDFViewerApplication = {
|
||||||
|
|
||||||
let eventBus;
|
let eventBus;
|
||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||||
eventBus =
|
eventBus = AppOptions.eventBus = new FirefoxEventBus(
|
||||||
AppOptions.eventBus =
|
AppOptions.get("allowedGlobalEvents"),
|
||||||
this.mlManager.eventBus =
|
externalServices,
|
||||||
new FirefoxEventBus(
|
AppOptions.get("isInAutomation")
|
||||||
AppOptions.get("allowedGlobalEvents"),
|
);
|
||||||
externalServices,
|
if (this.mlManager) {
|
||||||
AppOptions.get("isInAutomation")
|
this.mlManager.eventBus = eventBus;
|
||||||
);
|
}
|
||||||
} else {
|
} else {
|
||||||
eventBus = new EventBus();
|
eventBus = new EventBus();
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,6 +187,11 @@ const defaultOptions = {
|
||||||
value: false,
|
value: false,
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
||||||
},
|
},
|
||||||
|
enableGuessAltText: {
|
||||||
|
/** @type {boolean} */
|
||||||
|
value: true,
|
||||||
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
||||||
|
},
|
||||||
enableHighlightEditor: {
|
enableHighlightEditor: {
|
||||||
// We'll probably want to make some experiments before enabling this
|
// We'll probably want to make some experiments before enabling this
|
||||||
// in Firefox release, but it has to be temporary.
|
// in Firefox release, but it has to be temporary.
|
||||||
|
|
|
@ -328,8 +328,8 @@ class MLManager {
|
||||||
return FirefoxCom.requestAsync("mlGuess", data);
|
return FirefoxCom.requestAsync("mlGuess", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
enable({ altTextLearnMoreUrl, enableAltText, listenToProgress }) {
|
enable({ altTextLearnMoreUrl, enableGuessAltText, listenToProgress }) {
|
||||||
if (enableAltText) {
|
if (enableGuessAltText) {
|
||||||
this.#loadAltTextEngine(listenToProgress);
|
this.#loadAltTextEngine(listenToProgress);
|
||||||
}
|
}
|
||||||
// The `altTextLearnMoreUrl` is used to provide a link to the user to learn
|
// The `altTextLearnMoreUrl` is used to provide a link to the user to learn
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue