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(
() => {
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();
}
});
},