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.
This commit is contained in:
Jonas Jenwald 2022-12-07 17:27:02 +01:00
parent ded02941f2
commit 8fa8310ec9

View File

@ -853,24 +853,23 @@ class PDFPageView {
const resultPromise = paintTask.promise.then( const resultPromise = paintTask.promise.then(
() => { () => {
return finishPaintTask(null).then(() => { return finishPaintTask(null).then(async () => {
this.#renderTextLayer(); this.#renderTextLayer();
if (this.annotationLayer) { if (this.annotationLayer) {
this.#renderAnnotationLayer().then(() => { await this.#renderAnnotationLayer();
if (this.annotationEditorLayerFactory) { }
this.annotationEditorLayer ||= if (this.annotationEditorLayerFactory) {
this.annotationEditorLayerFactory.createAnnotationEditorLayerBuilder( this.annotationEditorLayer ||=
{ this.annotationEditorLayerFactory.createAnnotationEditorLayerBuilder(
pageDiv: div, {
pdfPage, pageDiv: div,
l10n: this.l10n, pdfPage,
accessibilityManager: this._accessibilityManager, l10n: this.l10n,
} accessibilityManager: this._accessibilityManager,
); }
this.#renderAnnotationEditorLayer(); );
} this.#renderAnnotationEditorLayer();
});
} }
}); });
}, },