Skip to content

Commit 933b7c8

Browse files
committed
[Editor] Load the model when the user switch to the stamp editing mode
1 parent 464d534 commit 933b7c8

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

web/firefoxcom.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,6 @@ class MLManager {
329329
this.altTextLearnMoreUrl = altTextLearnMoreUrl;
330330
this.enableAltTextModelDownload = enableAltTextModelDownload;
331331
this.enableGuessAltText = enableGuessAltText;
332-
333-
if (enableAltTextModelDownload) {
334-
this.#loadAltTextEngine(false);
335-
}
336332
}
337333

338334
async isEnabledFor(name) {
@@ -356,6 +352,12 @@ class MLManager {
356352
]);
357353
}
358354

355+
async loadModel(name) {
356+
if (name === "altText" && this.enableAltTextModelDownload) {
357+
await this.#loadAltTextEngine(false);
358+
}
359+
}
360+
359361
async downloadModel(name) {
360362
if (name !== "altText") {
361363
return null;

web/genericcom.js

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ class FakeMLManager {
8888
return null;
8989
}
9090

91+
async loadModel(_name) {}
92+
9193
async downloadModel(_name) {
9294
// Simulate downloading the model but with progress.
9395
// The progress can be seen in the new alt-text dialog.

web/pdf_viewer.js

+3
Original file line numberDiff line numberDiff line change
@@ -2299,6 +2299,9 @@ class PDFViewer {
22992299
* @param {AnnotationEditorModeOptions} options
23002300
*/
23012301
set annotationEditorMode({ mode, editId = null, isFromKeyboard = false }) {
2302+
if (mode === AnnotationEditorType.STAMP) {
2303+
this.#mlManager?.loadModel("altText");
2304+
}
23022305
if (!this.#annotationEditorUIManager) {
23032306
throw new Error(`The AnnotationEditor is not enabled.`);
23042307
}

0 commit comments

Comments
 (0)