mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-23 08:38:06 +02:00
[Editor] Don't steal the keyboard events when editing mode is enabled
This commit is contained in:
parent
1ab0f8a0ec
commit
77475ac610
2 changed files with 90 additions and 6 deletions
|
@ -611,6 +611,14 @@ class AnnotationEditorUIManager {
|
|||
);
|
||||
};
|
||||
|
||||
const textInputChecker = (_self, { target: el }) => {
|
||||
if (el instanceof HTMLInputElement) {
|
||||
const { type } = el;
|
||||
return type !== "text" && type !== "number";
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
const small = this.TRANSLATE_SMALL;
|
||||
const big = this.TRANSLATE_BIG;
|
||||
|
||||
|
@ -618,8 +626,12 @@ class AnnotationEditorUIManager {
|
|||
this,
|
||||
"_keyboardManager",
|
||||
new KeyboardManager([
|
||||
[["ctrl+a", "mac+meta+a"], proto.selectAll],
|
||||
[["ctrl+z", "mac+meta+z"], proto.undo],
|
||||
[
|
||||
["ctrl+a", "mac+meta+a"],
|
||||
proto.selectAll,
|
||||
{ checker: textInputChecker },
|
||||
],
|
||||
[["ctrl+z", "mac+meta+z"], proto.undo, { checker: textInputChecker }],
|
||||
[
|
||||
// On mac, depending of the OS version, the event.key is either "z" or
|
||||
// "Z" when the user presses "meta+shift+z".
|
||||
|
@ -631,6 +643,7 @@ class AnnotationEditorUIManager {
|
|||
"mac+meta+shift+Z",
|
||||
],
|
||||
proto.redo,
|
||||
{ checker: textInputChecker },
|
||||
],
|
||||
[
|
||||
[
|
||||
|
@ -647,6 +660,7 @@ class AnnotationEditorUIManager {
|
|||
"mac+Delete",
|
||||
],
|
||||
proto.delete,
|
||||
{ checker: textInputChecker },
|
||||
],
|
||||
[
|
||||
["Enter", "mac+Enter"],
|
||||
|
@ -906,13 +920,11 @@ class AnnotationEditorUIManager {
|
|||
#addKeyboardManager() {
|
||||
// The keyboard events are caught at the container level in order to be able
|
||||
// to execute some callbacks even if the current page doesn't have focus.
|
||||
window.addEventListener("keydown", this.#boundKeydown, { capture: true });
|
||||
window.addEventListener("keydown", this.#boundKeydown);
|
||||
}
|
||||
|
||||
#removeKeyboardManager() {
|
||||
window.removeEventListener("keydown", this.#boundKeydown, {
|
||||
capture: true,
|
||||
});
|
||||
window.removeEventListener("keydown", this.#boundKeydown);
|
||||
}
|
||||
|
||||
#addCopyPasteListeners() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue