From 8fa8310ec91297a4a0c6b4894473a9e15010ec9a Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 7 Dec 2022 17:27:02 +0100 Subject: [PATCH] Decouple the `annotationLayer` and `annotationEditorLayer` in the viewer Currently we'll only initialize and render the `annotationEditorLayer` once the regular `annotationLayer` has been rendered. While it obviously makes sense to render the `annotationEditorLayer` *last*, the way that the code is currently written means that if a third-party user disables the `annotationLayer` then the editing-functionality indirectly becomes disabled as well. Given that this seems like a somewhat arbitrary limitation, this patch simply decouples these two layers while still keeping the rendering order consistent. --- web/pdf_page_view.js | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js index b962c3894..49826c438 100644 --- a/web/pdf_page_view.js +++ b/web/pdf_page_view.js @@ -853,24 +853,23 @@ class PDFPageView { const resultPromise = paintTask.promise.then( () => { - return finishPaintTask(null).then(() => { + return finishPaintTask(null).then(async () => { this.#renderTextLayer(); if (this.annotationLayer) { - this.#renderAnnotationLayer().then(() => { - if (this.annotationEditorLayerFactory) { - this.annotationEditorLayer ||= - this.annotationEditorLayerFactory.createAnnotationEditorLayerBuilder( - { - pageDiv: div, - pdfPage, - l10n: this.l10n, - accessibilityManager: this._accessibilityManager, - } - ); - this.#renderAnnotationEditorLayer(); - } - }); + await this.#renderAnnotationLayer(); + } + if (this.annotationEditorLayerFactory) { + this.annotationEditorLayer ||= + this.annotationEditorLayerFactory.createAnnotationEditorLayerBuilder( + { + pageDiv: div, + pdfPage, + l10n: this.l10n, + accessibilityManager: this._accessibilityManager, + } + ); + this.#renderAnnotationEditorLayer(); } }); },