mirror of
https://github.com/ankitects/anki.git
synced 2025-11-11 07:07:13 -05:00
Add selector shortcuts
This commit is contained in:
parent
0137ca6c27
commit
4444942b46
4 changed files with 10 additions and 1 deletions
|
|
@ -31,4 +31,5 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
{onChange}
|
{onChange}
|
||||||
items={decks}
|
items={decks}
|
||||||
icon={mdiBookOutline}
|
icon={mdiBookOutline}
|
||||||
|
keyCombination="Control+D"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -10,16 +10,18 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
import Modal from "./Modal.svelte";
|
import Modal from "./Modal.svelte";
|
||||||
import type { IconData } from "./types";
|
import type { IconData } from "./types";
|
||||||
import * as tr from "@generated/ftl";
|
import * as tr from "@generated/ftl";
|
||||||
|
import Shortcut from "./Shortcut.svelte";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
title: string;
|
title: string;
|
||||||
selectedItem?: Item | null;
|
selectedItem?: Item | null;
|
||||||
items: Item[];
|
items: Item[];
|
||||||
icon: IconData;
|
icon: IconData;
|
||||||
|
keyCombination: string;
|
||||||
onChange?: (item: Item) => void;
|
onChange?: (item: Item) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { title, onChange, icon, items, selectedItem = $bindable(null) }: Props = $props();
|
let { title, onChange, icon, items, selectedItem = $bindable(null), keyCombination }: Props = $props();
|
||||||
let modal: Modal | null = $state(null);
|
let modal: Modal | null = $state(null);
|
||||||
let searchQuery = $state("");
|
let searchQuery = $state("");
|
||||||
|
|
||||||
|
|
@ -54,6 +56,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
{selectedItem?.name ?? "…"}
|
{selectedItem?.name ?? "…"}
|
||||||
</LabelButton>
|
</LabelButton>
|
||||||
|
|
||||||
|
<Shortcut keyCombination={keyCombination} on:action={() => modal?.toggle()} />
|
||||||
<Modal bind:this={modal} dialogClass="modal-lg">
|
<Modal bind:this={modal} dialogClass="modal-lg">
|
||||||
<div slot="header" class="modal-header">
|
<div slot="header" class="modal-header">
|
||||||
<IconConstrain iconSize={90}>
|
<IconConstrain iconSize={90}>
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
modal.hide();
|
modal.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function toggle(): void {
|
||||||
|
modal.toggle();
|
||||||
|
}
|
||||||
|
|
||||||
export { onOkClicked_ as acceptHandler, onCancelClicked_ as cancelHandler };
|
export { onOkClicked_ as acceptHandler, onCancelClicked_ as cancelHandler };
|
||||||
|
|
||||||
const { set: setModalOpen, remove: removeModalClosingHandler } =
|
const { set: setModalOpen, remove: removeModalClosingHandler } =
|
||||||
|
|
|
||||||
|
|
@ -30,4 +30,5 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
{onChange}
|
{onChange}
|
||||||
items={notetypes}
|
items={notetypes}
|
||||||
icon={mdiNewspaper}
|
icon={mdiNewspaper}
|
||||||
|
keyCombination="Control+N"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue