From f0dc6e103f6a6493ff96219b10906ff5018bf20d Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 30 Mar 2022 14:52:16 +1000 Subject: [PATCH] Fix "repeat cloze" shortcut regression Closes #1748 again. --- ts/editor/editor-toolbar/ClozeButton.svelte | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ts/editor/editor-toolbar/ClozeButton.svelte b/ts/editor/editor-toolbar/ClozeButton.svelte index eb6fa8579..2041b60d2 100644 --- a/ts/editor/editor-toolbar/ClozeButton.svelte +++ b/ts/editor/editor-toolbar/ClozeButton.svelte @@ -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 onCloze(event.detail.originalEvent)} />