Skip to content

Commit

Permalink
[Editing] Disable buttons until the first page is rendered
Browse files Browse the repository at this point in the history
  • Loading branch information
calixteman committed Aug 9, 2022
1 parent 589f72e commit ae3742a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
14 changes: 8 additions & 6 deletions web/base_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -727,12 +727,6 @@ class BaseViewer {
if (isPureXfa) {
console.warn("Warning: XFA-editing is not implemented.");
} else if (isValidAnnotationEditorMode(mode)) {
// Ensure that the Editor buttons, in the toolbar, are updated.
this.eventBus.dispatch("annotationeditormodechanged", {
source: this,
mode,
});

this.#annotationEditorUIManager = new AnnotationEditorUIManager(
this.container,
this.eventBus
Expand Down Expand Up @@ -817,6 +811,14 @@ class BaseViewer {
this._scriptingManager.setDocument(pdfDocument); // Enable scripting.
}

if (this.#annotationEditorUIManager) {
// Ensure that the Editor buttons, in the toolbar, are updated.
this.eventBus.dispatch("annotationeditormodechanged", {
source: this,
mode: this.#annotationEditorMode,
});
}

// In addition to 'disableAutoFetch' being set, also attempt to reduce
// resource usage when loading *very* long/large documents.
if (
Expand Down
8 changes: 5 additions & 3 deletions web/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,17 @@ class Toolbar {
}
};
this.eventBus._on("annotationeditormodechanged", editorModeChanged);

this.eventBus._on("toolbarreset", evt => {
const reset = evt => {
if (evt.source === this) {
editorModeChanged(
{ mode: AnnotationEditorType.NONE },
/* disableButtons = */ true
);
}
});
};

this.eventBus._on("toolbarreset", reset);
reset({ source: this });
}

_updateUIState(resetNumPages = false) {
Expand Down

0 comments on commit ae3742a

Please sign in to comment.