mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
[Editor] Make the text layer focusable before the editors (bug 1881746)
Keep the different layers in a constant order to avoid the use of a z-index and a tab-index.
This commit is contained in:
parent
0022310b9c
commit
1b00511301
14 changed files with 187 additions and 36 deletions
|
@ -237,6 +237,7 @@ class AnnotationEditorLayer {
|
|||
* editor creation.
|
||||
*/
|
||||
enable() {
|
||||
this.div.tabIndex = 0;
|
||||
this.togglePointerEvents(true);
|
||||
const annotationElementIds = new Set();
|
||||
for (const editor of this.#editors.values()) {
|
||||
|
@ -274,6 +275,7 @@ class AnnotationEditorLayer {
|
|||
*/
|
||||
disable() {
|
||||
this.#isDisabling = true;
|
||||
this.div.tabIndex = -1;
|
||||
this.togglePointerEvents(false);
|
||||
const hiddenAnnotationIds = new Set();
|
||||
for (const editor of this.#editors.values()) {
|
||||
|
@ -333,6 +335,7 @@ class AnnotationEditorLayer {
|
|||
}
|
||||
|
||||
enableTextSelection() {
|
||||
this.div.tabIndex = -1;
|
||||
if (this.#textLayer?.div && !this.#boundTextLayerPointerDown) {
|
||||
this.#boundTextLayerPointerDown = this.#textLayerPointerDown.bind(this);
|
||||
this.#textLayer.div.addEventListener(
|
||||
|
@ -344,6 +347,7 @@ class AnnotationEditorLayer {
|
|||
}
|
||||
|
||||
disableTextSelection() {
|
||||
this.div.tabIndex = 0;
|
||||
if (this.#textLayer?.div && this.#boundTextLayerPointerDown) {
|
||||
this.#textLayer.div.removeEventListener(
|
||||
"pointerdown",
|
||||
|
|
|
@ -44,6 +44,8 @@ class AnnotationEditor {
|
|||
|
||||
#altText = null;
|
||||
|
||||
#disabled = false;
|
||||
|
||||
#keepAspectRatio = false;
|
||||
|
||||
#resizersDiv = null;
|
||||
|
@ -1002,7 +1004,7 @@ class AnnotationEditor {
|
|||
this.div.setAttribute("data-editor-rotation", (360 - this.rotation) % 360);
|
||||
this.div.className = this.name;
|
||||
this.div.setAttribute("id", this.id);
|
||||
this.div.setAttribute("tabIndex", 0);
|
||||
this.div.tabIndex = this.#disabled ? -1 : 0;
|
||||
if (!this._isVisible) {
|
||||
this.div.classList.add("hidden");
|
||||
}
|
||||
|
@ -1680,6 +1682,20 @@ class AnnotationEditor {
|
|||
this.div.classList.toggle("hidden", !visible);
|
||||
this._isVisible = visible;
|
||||
}
|
||||
|
||||
enable() {
|
||||
if (this.div) {
|
||||
this.div.tabIndex = 0;
|
||||
}
|
||||
this.#disabled = false;
|
||||
}
|
||||
|
||||
disable() {
|
||||
if (this.div) {
|
||||
this.div.tabIndex = -1;
|
||||
}
|
||||
this.#disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
// This class is used to fake an editor which has been deleted.
|
||||
|
|
|
@ -1596,6 +1596,9 @@ class AnnotationEditorUIManager {
|
|||
for (const layer of this.#allLayers.values()) {
|
||||
layer.enable();
|
||||
}
|
||||
for (const editor of this.#allEditors.values()) {
|
||||
editor.enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1609,6 +1612,9 @@ class AnnotationEditorUIManager {
|
|||
for (const layer of this.#allLayers.values()) {
|
||||
layer.disable();
|
||||
}
|
||||
for (const editor of this.#allEditors.values()) {
|
||||
editor.disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue