mirror of
https://github.com/ankitects/anki.git
synced 2026-01-07 02:53:54 -05:00
Use pre-existing shortcut methods
This commit is contained in:
parent
f5cdf0f22f
commit
acc672afcd
4 changed files with 38 additions and 9 deletions
|
|
@ -34,7 +34,10 @@ const keyCodeLookup = {
|
|||
".": 190,
|
||||
"/": 191,
|
||||
"`": 192,
|
||||
};
|
||||
"!": 49,
|
||||
"*": 56,
|
||||
"@": 50,
|
||||
} as const;
|
||||
|
||||
function isRequiredModifier(modifier: string): boolean {
|
||||
return !modifier.endsWith("?");
|
||||
|
|
@ -113,6 +116,7 @@ function keyCombinationToCheck(
|
|||
keyCombination.slice(0, -1),
|
||||
);
|
||||
|
||||
console.log({ keyCode, required, optional });
|
||||
return check(keyCode, required, optional);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
import { setFlag } from "@generated/backend";
|
||||
import type { ReviewerState } from "../reviewer";
|
||||
import type { MoreMenuItemInfo } from "./types";
|
||||
import Shortcut from "$lib/components/Shortcut.svelte";
|
||||
|
||||
let showFloating = false;
|
||||
let showFlags = false;
|
||||
|
|
@ -114,8 +115,30 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
setFlag({ cardIds: [card!.id], flag: index });
|
||||
$cardData!.queue!.cards[0].card!.flags = index;
|
||||
}
|
||||
|
||||
function prepKeycodeForShortcut(keycode: string) {
|
||||
return keycode.replace("Ctrl", "Control");
|
||||
}
|
||||
</script>
|
||||
|
||||
{#each shortcuts as shortcut}
|
||||
{#if shortcut !== "hr"}
|
||||
<Shortcut
|
||||
keyCombination={prepKeycodeForShortcut(shortcut.shortcut)}
|
||||
event="keydown"
|
||||
on:action={shortcut.onClick}
|
||||
/>
|
||||
{/if}
|
||||
{/each}
|
||||
|
||||
{#each flags as flag, i}
|
||||
<Shortcut
|
||||
keyCombination={prepKeycodeForShortcut(flag.shortcut)}
|
||||
event="keydown"
|
||||
on:action={() => changeFlag(i + 1)}
|
||||
/>
|
||||
{/each}
|
||||
|
||||
<MoreSubmenu bind:showFloating>
|
||||
<button
|
||||
slot="button"
|
||||
|
|
@ -165,7 +188,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
? "RGBA(255,0,0,0.25)"
|
||||
: ""}
|
||||
>
|
||||
<MoreItem shortcut={shortcut.shortcut} on:click={shortcut.onClick}>
|
||||
<MoreItem
|
||||
shortcut={shortcut.shortcut}
|
||||
on:click={shortcut.onClick}
|
||||
on:keydown={shortcut.onClick}
|
||||
on:action={console.log}
|
||||
>
|
||||
{shortcut.name}
|
||||
</MoreItem>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
</script>
|
||||
|
||||
<div class="row" on:click on:keydown role="button" tabindex="0">
|
||||
<!--<Shortcut keyCombination={shortcut}></Shortcut>-->
|
||||
<slot />
|
||||
<span>{shortcut}</span>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -259,12 +259,10 @@ export class ReviewerState {
|
|||
break;
|
||||
}
|
||||
case "e": {
|
||||
this.displayEditMenu();
|
||||
break;
|
||||
}
|
||||
case "-": {
|
||||
this.buryOrSuspendCurrentCard(false);
|
||||
break;
|
||||
if (!ctrl) {
|
||||
this.displayEditMenu();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue