pull/119/head
Zef Hemel 2022-11-09 09:35:26 +01:00
parent bb6bf289d9
commit 2eff823a5d
1 changed files with 9 additions and 5 deletions

View File

@ -15,8 +15,12 @@ function keyBindingForQuote(
right: string,
): KeyBinding {
return {
key: quote,
run: (target): boolean => {
any: (target, event): boolean => {
// Moving this check here rather than using the regular "key" property because
// for some reason the "ä" key is not recognized as a quote key by CodeMirror.
if (event.key !== quote) {
return false;
}
const cursorPos = target.state.selection.main.from;
const chBefore = target.state.sliceDoc(cursorPos - 1, cursorPos);
@ -34,13 +38,13 @@ function keyBindingForQuote(
}
// Ok, still here, let's use a smart quote
let quote = right;
let q = right;
if (/\W/.exec(chBefore) && !/[!\?,\.\-=“]/.exec(chBefore)) {
quote = left;
q = left;
}
target.dispatch({
changes: {
insert: quote,
insert: q,
from: cursorPos,
},
selection: {