mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18: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
|
@ -430,7 +430,8 @@ class StampEditor extends AnnotationEditor {
|
|||
return;
|
||||
}
|
||||
this.#hasMLBeenQueried = true;
|
||||
if (!this._uiManager.isMLEnabledFor("altText") || this.hasAltText()) {
|
||||
const isMLEnabled = await this._uiManager.isMLEnabledFor("altText");
|
||||
if (!isMLEnabled || this.hasAltText()) {
|
||||
return;
|
||||
}
|
||||
const offscreen = new OffscreenCanvas(width, height);
|
||||
|
@ -447,7 +448,7 @@ class StampEditor extends AnnotationEditor {
|
|||
height
|
||||
);
|
||||
const response = await this._uiManager.mlGuess({
|
||||
service: "image-to-text",
|
||||
service: "moz-image-to-text",
|
||||
request: {
|
||||
data: ctx.getImageData(0, 0, width, height).data,
|
||||
width,
|
||||
|
|
|
@ -855,8 +855,8 @@ class AnnotationEditorUIManager {
|
|||
return this.#mlManager?.guess(data) || null;
|
||||
}
|
||||
|
||||
isMLEnabledFor(name) {
|
||||
return !!this.#mlManager?.isEnabledFor(name);
|
||||
async isMLEnabledFor(name) {
|
||||
return !!(await this.#mlManager?.isEnabledFor(name));
|
||||
}
|
||||
|
||||
get useNewAltTextFlow() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue