Merge pull request #20259 from calixteman/no_throw_when_switching_editing_mode

[Editor] Don't throw when switching to editing mode before an annotation editor layer is rendered
This commit is contained in:
Tim van der Meij 2025-09-11 22:04:47 +02:00 committed by GitHub
commit e8cc25c0ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1072,6 +1072,20 @@ class PDFViewer {
this._updateSpreadMode(); this._updateSpreadMode();
} }
eventBus._on(
"annotationeditorlayerrendered",
evt => {
if (this.#annotationEditorUIManager) {
// Ensure that the Editor buttons, in the toolbar, are updated.
eventBus.dispatch("annotationeditormodechanged", {
source: this,
mode: this.#annotationEditorMode,
});
}
},
{ once: true, signal }
);
// Fetch all the pages since the viewport is needed before printing // Fetch all the pages since the viewport is needed before printing
// starts to create the correct size canvas. Wait until one page is // starts to create the correct size canvas. Wait until one page is
// rendered so we don't tie up too many resources early on. // rendered so we don't tie up too many resources early on.
@ -1090,14 +1104,6 @@ class PDFViewer {
); );
} }
if (this.#annotationEditorUIManager) {
// Ensure that the Editor buttons, in the toolbar, are updated.
eventBus.dispatch("annotationeditormodechanged", {
source: this,
mode: this.#annotationEditorMode,
});
}
// In addition to 'disableAutoFetch' being set, also attempt to reduce // In addition to 'disableAutoFetch' being set, also attempt to reduce
// resource usage when loading *very* long/large documents. // resource usage when loading *very* long/large documents.
if ( if (