1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 17:48:07 +02:00

[Annotations] Add some aria-owns in the text layer to link to annotations (bug 1780375)

This patch doesn't structurally change the text layer: it just adds some aria-owns
attributes to some spans.
The aria-owns attribute expect to have an element id, hence it's why it adds back an
id on the element rendering an annotation, but this id is built in using crypto.randomUUID
to avoid any potential issues with the hash in the url.
The elements in the annotation layer are moved into the DOM in order to have them in the
same "order" as they visually are.
The overall goal is to help screen readers to present to the user the annotations as
they visually are and as they come in the text flow.
It is clearly not perfect, but it should improve readability for some people with visual
disabilities.
This commit is contained in:
Calixte Denizet 2022-07-28 17:59:03 +02:00
parent cef2ac99e5
commit f316300113
23 changed files with 436 additions and 246 deletions

View file

@ -73,19 +73,17 @@ function getComputedStyleSelector(id) {
return `getComputedStyle(${getQuerySelector(id)})`;
}
exports.getComputedStyleSelector = getComputedStyleSelector;
const editorPrefix = "#pdfjs_internal_editor_";
exports.editorPrefix = editorPrefix;
exports.getEditorSelector = n => `#pdfjs_internal_editor_${n}`;
function getSelectedEditors(page) {
return page.evaluate(prefix => {
return page.evaluate(() => {
const elements = document.querySelectorAll(".selectedEditor");
const results = [];
for (const { id } of elements) {
results.push(parseInt(id.slice(prefix.length)));
results.push(parseInt(id.split("_").at(-1)));
}
results.sort();
return results;
}, editorPrefix.slice(1));
});
}
exports.getSelectedEditors = getSelectedEditors;