From 2eff823a5d1d585428e78860b365a996ac8deb88 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Wed, 9 Nov 2022 09:35:26 +0100 Subject: [PATCH] Fixes #111 --- web/smart_quotes.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/web/smart_quotes.ts b/web/smart_quotes.ts index 028b2733..90c26ff6 100644 --- a/web/smart_quotes.ts +++ b/web/smart_quotes.ts @@ -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: {