mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Merge pull request #18546 from calixteman/load_model_switch_stamp
[Editor] Load the model when the user switch to the stamp editing mode
This commit is contained in:
commit
c8ba7b02b0
3 changed files with 14 additions and 4 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue