mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
fix Ctrl+right/left handling in RTL fields
This commit is contained in:
parent
d079307536
commit
46573df890
1 changed files with 23 additions and 0 deletions
|
@ -59,6 +59,29 @@ function onKey(evt: KeyboardEvent) {
|
||||||
focusPrevious();
|
focusPrevious();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fix Ctrl+right/left handling in RTL fields
|
||||||
|
if (currentField.dir === "rtl") {
|
||||||
|
const selection = window.getSelection();
|
||||||
|
let granularity = "character";
|
||||||
|
let alter = "move";
|
||||||
|
if (evt.ctrlKey) {
|
||||||
|
granularity = "word";
|
||||||
|
}
|
||||||
|
if (evt.shiftKey) {
|
||||||
|
alter = "extend";
|
||||||
|
}
|
||||||
|
if (evt.which === 39) {
|
||||||
|
selection.modify(alter, "right", granularity);
|
||||||
|
evt.preventDefault();
|
||||||
|
return;
|
||||||
|
} else if (evt.which === 37) {
|
||||||
|
selection.modify(alter, "left", granularity);
|
||||||
|
evt.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
triggerKeyTimer();
|
triggerKeyTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue