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