[Editor] Load the model when the user switch to the stamp editing mode
This commit is contained in:
parent
464d534961
commit
a81b071d2d
@ -329,10 +329,6 @@ class MLManager {
|
||||
this.altTextLearnMoreUrl = altTextLearnMoreUrl;
|
||||
this.enableAltTextModelDownload = enableAltTextModelDownload;
|
||||
this.enableGuessAltText = enableGuessAltText;
|
||||
|
||||
if (enableAltTextModelDownload) {
|
||||
this.#loadAltTextEngine(false);
|
||||
}
|
||||
}
|
||||
|
||||
async isEnabledFor(name) {
|
||||
@ -356,6 +352,12 @@ class MLManager {
|
||||
]);
|
||||
}
|
||||
|
||||
async loadModel(name) {
|
||||
if (name === "altText" && this.enableAltTextModelDownload) {
|
||||
await this.#loadAltTextEngine(false);
|
||||
}
|
||||
}
|
||||
|
||||
async downloadModel(name) {
|
||||
if (name !== "altText") {
|
||||
return null;
|
||||
|
||||
@ -88,6 +88,8 @@ class FakeMLManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
async loadModel(_name) {}
|
||||
|
||||
async downloadModel(_name) {
|
||||
// Simulate downloading the model but with progress.
|
||||
// The progress can be seen in the new alt-text dialog.
|
||||
|
||||
@ -906,6 +906,9 @@ class PDFViewer {
|
||||
uiManager: this.#annotationEditorUIManager,
|
||||
});
|
||||
if (mode !== AnnotationEditorType.NONE) {
|
||||
if (mode === AnnotationEditorType.STAMP) {
|
||||
this.#mlManager?.loadModel("altText");
|
||||
}
|
||||
this.#annotationEditorUIManager.updateMode(mode);
|
||||
}
|
||||
} else {
|
||||
@ -2311,6 +2314,9 @@ class PDFViewer {
|
||||
if (!this.pdfDocument) {
|
||||
return;
|
||||
}
|
||||
if (mode === AnnotationEditorType.STAMP) {
|
||||
this.#mlManager?.loadModel("altText");
|
||||
}
|
||||
|
||||
const { eventBus } = this;
|
||||
const updater = () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user