mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Load the image-to-text model when opening the pdf viewer in Firefox (bug 1908938)
This commit is contained in:
parent
5b0e15ab18
commit
b71fa727e1
5 changed files with 62 additions and 24 deletions
28
web/app.js
28
web/app.js
|
@ -155,6 +155,7 @@ const PDFViewerApplication = {
|
|||
isViewerEmbedded: window.parent !== window,
|
||||
url: "",
|
||||
baseUrl: "",
|
||||
mlManager: null,
|
||||
_downloadUrl: "",
|
||||
_eventBusAbortController: null,
|
||||
_windowAbortController: null,
|
||||
|
@ -205,6 +206,11 @@ const PDFViewerApplication = {
|
|||
if (mode) {
|
||||
document.documentElement.classList.add(mode);
|
||||
}
|
||||
} else {
|
||||
// We want to load the image-to-text AI engine as soon as possible.
|
||||
this.mlManager = new MLManager({
|
||||
enableAltText: AppOptions.get("enableAltText"),
|
||||
});
|
||||
}
|
||||
|
||||
// Ensure that the `L10n`-instance has been initialized before creating
|
||||
|
@ -370,11 +376,14 @@ const PDFViewerApplication = {
|
|||
|
||||
let eventBus;
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||
eventBus = AppOptions.eventBus = new FirefoxEventBus(
|
||||
AppOptions.get("allowedGlobalEvents"),
|
||||
externalServices,
|
||||
AppOptions.get("isInAutomation")
|
||||
);
|
||||
eventBus =
|
||||
AppOptions.eventBus =
|
||||
this.mlManager.eventBus =
|
||||
new FirefoxEventBus(
|
||||
AppOptions.get("allowedGlobalEvents"),
|
||||
externalServices,
|
||||
AppOptions.get("isInAutomation")
|
||||
);
|
||||
} else {
|
||||
eventBus = new EventBus();
|
||||
}
|
||||
|
@ -731,15 +740,6 @@ const PDFViewerApplication = {
|
|||
return shadow(this, "externalServices", new ExternalServices());
|
||||
},
|
||||
|
||||
get mlManager() {
|
||||
const enableAltText = AppOptions.get("enableAltText");
|
||||
return shadow(
|
||||
this,
|
||||
"mlManager",
|
||||
enableAltText === true ? new MLManager({ enableAltText }) : null
|
||||
);
|
||||
},
|
||||
|
||||
get initialized() {
|
||||
return this._initializedCapability.settled;
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue