[Editor] Improve a11y for newly added element (#15109)

- In the annotationEditorLayer, reorder the editors in the DOM according
  the position of the elements on the screen;
- add an aria-owns attribute on the "nearest" element in the text layer
  which points to the added editor.
This commit is contained in:
Calixte Denizet 2022-06-28 18:21:32 +02:00
parent ad15532235
commit 624b26e1de
15 changed files with 467 additions and 96 deletions

View file

@ -77,6 +77,7 @@ class AnnotationEditorLayerBuilder {
this.div = document.createElement("div");
this.div.className = "annotationEditorLayer";
this.div.tabIndex = 0;
this.pageDiv.append(this.div);
this.annotationEditorLayer = new AnnotationEditorLayer({
uiManager: this.#uiManager,
@ -84,6 +85,7 @@ class AnnotationEditorLayerBuilder {
annotationStorage: this.annotationStorage,
pageIndex: this.pdfPage._pageIndex,
l10n: this.l10n,
viewport: clonedViewport,
});
const parameters = {
@ -94,12 +96,11 @@ class AnnotationEditorLayerBuilder {
};
this.annotationEditorLayer.render(parameters);
this.pageDiv.append(this.div);
}
cancel() {
this._cancelled = true;
this.destroy();
}
hide() {
@ -121,8 +122,8 @@ class AnnotationEditorLayerBuilder {
return;
}
this.pageDiv = null;
this.div.remove();
this.annotationEditorLayer.destroy();
this.div.remove();
}
}