anki/ts/components/Shortcut.svelte
Henrik Giesel f534dbb8e5
Separate input components into their own directories / Remove WithShortcut (#1613)
* Put PlainTextInput into its own directory

* Create a directory for RichTextInput

* Create editor-toolbar directory

* Move PreviewButton into editor-toolbar

* The time to refactor this is not quite yet here

* Create tag-editor directory

* Remove some of the uses of WithShortcut

* Remove all uses of WithShortcut from editor package

* Remove last uses of WithShortcut

* Fix typo
2022-01-24 11:43:09 +10:00

21 lines
618 B
Svelte

<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import { createEventDispatcher, onMount } from "svelte";
import { registerShortcut } from "../lib/shortcuts";
import { preventDefault } from "../lib/events";
export let keyCombination: string;
const dispatch = createEventDispatcher();
onMount(() =>
registerShortcut((event: KeyboardEvent) => {
preventDefault(event);
dispatch("action", { originalEvent: event });
}, keyCombination),
);
</script>