Fix "repeat cloze" shortcut regression

Closes #1748 again.
This commit is contained in:
Damien Elmes 2022-03-30 14:52:16 +10:00
parent 39c3a8e104
commit f0dc6e103f

View file

@ -8,6 +8,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import IconButton from "../../components/IconButton.svelte";
import Shortcut from "../../components/Shortcut.svelte";
import * as tr from "../../lib/ftl";
import { isApplePlatform } from "../../lib/platform";
import { getPlatformString } from "../../lib/shortcuts";
import { wrapInternal } from "../../lib/wrap";
import { context as noteEditorContext } from "../NoteEditor.svelte";
@ -17,6 +18,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
const { focusedInput, fields } = noteEditorContext.get();
// Workaround for Cmd+Option+Shift+C not working on macOS. The keyup approach works
// on Linux as well, but fails on Windows.
const event = isApplePlatform() ? "keyup" : "keydown";
const clozePattern = /\{\{c(\d+)::/gu;
function getCurrentHighestCloze(increment: boolean): number {
let highest = 0;
@ -65,6 +70,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<Shortcut
{keyCombination}
event="keyup"
{event}
on:action={(event) => onCloze(event.detail.originalEvent)}
/>