mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
select all tags with Ctrl+A (#1847)
This commit is contained in:
parent
1b48d3e3d1
commit
68482d37a1
2 changed files with 17 additions and 1 deletions
|
@ -112,6 +112,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
|
||||
function appendEmptyTag(): void {
|
||||
// used by tag badge and tag spacer
|
||||
deselect();
|
||||
const lastTag = tagTypes[tagTypes.length - 1];
|
||||
|
||||
if (!lastTag || lastTag.name.length > 0) {
|
||||
|
@ -448,6 +449,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
splitTag(index, detail.start, detail.end)}
|
||||
on:tagadd={() => insertTagKeepFocus(index)}
|
||||
on:tagdelete={() => deleteTagAt(index)}
|
||||
on:tagselectall={selectAllTags}
|
||||
on:tagjoinprevious={() => joinWithPreviousTag(index)}
|
||||
on:tagjoinnext={() => joinWithNextTag(index)}
|
||||
on:tagmoveprevious={() => moveToPreviousTag(index)}
|
||||
|
|
|
@ -5,6 +5,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
<script lang="ts">
|
||||
import { createEventDispatcher, onMount, tick } from "svelte";
|
||||
|
||||
import { registerShortcut } from "../../lib/shortcuts";
|
||||
import {
|
||||
delimChar,
|
||||
normalizeTagname,
|
||||
|
@ -230,7 +231,20 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
name = last;
|
||||
}
|
||||
|
||||
onMount(() => input.focus());
|
||||
async function onSelectAll(event: KeyboardEvent) {
|
||||
if (name.length === 0) {
|
||||
input.blur();
|
||||
await tick(); // ensure blur events are processed before tagselectall
|
||||
dispatch("tagselectall");
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
registerShortcut(onSelectAll, "Control+A", { target: input });
|
||||
input.focus();
|
||||
});
|
||||
</script>
|
||||
|
||||
<input
|
||||
|
|
Loading…
Reference in a new issue