Merge pull request #3343 from thelounge/xpaw/fix-formatting
Fix formatting hotkeys on non english locales
This commit is contained in:
commit
b8948856f3
@ -49,13 +49,13 @@ const Mousetrap = require("mousetrap");
|
|||||||
const {wrapCursor} = require("undate");
|
const {wrapCursor} = require("undate");
|
||||||
|
|
||||||
const formattingHotkeys = {
|
const formattingHotkeys = {
|
||||||
k: "\x03",
|
"mod+k": "\x03",
|
||||||
b: "\x02",
|
"mod+b": "\x02",
|
||||||
u: "\x1F",
|
"mod+u": "\x1F",
|
||||||
i: "\x1D",
|
"mod+i": "\x1D",
|
||||||
o: "\x0F",
|
"mod+o": "\x0F",
|
||||||
s: "\x1e",
|
"mod+s": "\x1e",
|
||||||
m: "\x11",
|
"mod+m": "\x11",
|
||||||
};
|
};
|
||||||
|
|
||||||
// Autocomplete bracket and quote characters like in a modern IDE
|
// Autocomplete bracket and quote characters like in a modern IDE
|
||||||
@ -91,10 +91,8 @@ export default {
|
|||||||
|
|
||||||
const inputTrap = Mousetrap(this.$refs.input);
|
const inputTrap = Mousetrap(this.$refs.input);
|
||||||
|
|
||||||
for (const hotkey in formattingHotkeys) {
|
inputTrap.bind(Object.keys(formattingHotkeys), function(e, key) {
|
||||||
inputTrap.bind("mod+" + hotkey, function(e) {
|
const modifier = formattingHotkeys[key];
|
||||||
// Key is lowercased because keybinds also get processed if caps lock is on
|
|
||||||
const modifier = formattingHotkeys[e.key.toLowerCase()];
|
|
||||||
|
|
||||||
wrapCursor(
|
wrapCursor(
|
||||||
e.target,
|
e.target,
|
||||||
@ -104,11 +102,10 @@ export default {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
inputTrap.bind(Object.keys(bracketWraps), function(e) {
|
inputTrap.bind(Object.keys(bracketWraps), function(e, key) {
|
||||||
if (e.target.selectionStart !== e.target.selectionEnd) {
|
if (e.target.selectionStart !== e.target.selectionEnd) {
|
||||||
wrapCursor(e.target, e.key, bracketWraps[e.key]);
|
wrapCursor(e.target, key, bracketWraps[key]);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user