mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
[Editor] Disable annotation layer when highlighting (bug 1868759)
When highlighting, the annotation editor layer is disabled to get pointer events from the text layer, but the annotation layer must be then disabled either in order to avoid bad interactions.
This commit is contained in:
parent
70015ffe6b
commit
95f9bedc7c
5 changed files with 126 additions and 10 deletions
|
@ -151,8 +151,9 @@ class AnnotationEditorLayer {
|
|||
case AnnotationEditorType.NONE:
|
||||
this.disableTextSelection();
|
||||
this.togglePointerEvents(false);
|
||||
this.toggleAnnotationLayerPointerEvents(true);
|
||||
this.disableClick();
|
||||
break;
|
||||
return;
|
||||
case AnnotationEditorType.INK:
|
||||
// We always want to have an ink editor ready to draw in.
|
||||
this.addInkEditorIfNeeded(false);
|
||||
|
@ -172,16 +173,15 @@ class AnnotationEditorLayer {
|
|||
this.enableClick();
|
||||
}
|
||||
|
||||
if (mode !== AnnotationEditorType.NONE) {
|
||||
const { classList } = this.div;
|
||||
for (const editorType of AnnotationEditorLayer.#editorTypes.values()) {
|
||||
classList.toggle(
|
||||
`${editorType._type}Editing`,
|
||||
mode === editorType._editorType
|
||||
);
|
||||
}
|
||||
this.div.hidden = false;
|
||||
this.toggleAnnotationLayerPointerEvents(false);
|
||||
const { classList } = this.div;
|
||||
for (const editorType of AnnotationEditorLayer.#editorTypes.values()) {
|
||||
classList.toggle(
|
||||
`${editorType._type}Editing`,
|
||||
mode === editorType._editorType
|
||||
);
|
||||
}
|
||||
this.div.hidden = false;
|
||||
}
|
||||
|
||||
addInkEditorIfNeeded(isCommitting) {
|
||||
|
@ -228,6 +228,10 @@ class AnnotationEditorLayer {
|
|||
this.div.classList.toggle("disabled", !enabled);
|
||||
}
|
||||
|
||||
toggleAnnotationLayerPointerEvents(enabled = false) {
|
||||
this.#annotationLayer?.div.classList.toggle("disabled", !enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable pointer events on the main div in order to enable
|
||||
* editor creation.
|
||||
|
@ -306,6 +310,7 @@ class AnnotationEditorLayer {
|
|||
classList.remove(`${editorType._type}Editing`);
|
||||
}
|
||||
this.disableTextSelection();
|
||||
this.toggleAnnotationLayerPointerEvents(true);
|
||||
|
||||
this.#isDisabling = false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue