mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Add select all shortcut
+ Remove addEventListener for Ctrl+C/V/A It seems like they're really not necessary
This commit is contained in:
parent
d40e0df11b
commit
6d21c16250
2 changed files with 19 additions and 1 deletions
|
@ -16,6 +16,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
import { dotsIcon } from "./icons";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
const allLabel = "Select all tags";
|
||||
const copyLabel = "Copy tags";
|
||||
const removeLabel = "Remove tags";
|
||||
</script>
|
||||
|
@ -25,7 +27,17 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
<Badge class="me-1" on:mount={withSpan(createDropdown)}>{@html dotsIcon}</Badge>
|
||||
|
||||
<DropdownMenu>
|
||||
<WithShortcut shortcut="C" let:createShortcut let:shortcutLabel>
|
||||
<WithShortcut shortcut="Control+A" let:createShortcut let:shortcutLabel>
|
||||
<DropdownItem
|
||||
on:click={(event) => {
|
||||
dispatch("tagselectall");
|
||||
event.stopImmediatePropagation();
|
||||
}}
|
||||
on:mount={withButton(createShortcut)}
|
||||
>{appendInParentheses(allLabel, shortcutLabel)}</DropdownItem
|
||||
>
|
||||
</WithShortcut>
|
||||
<WithShortcut shortcut="Control+C" let:createShortcut let:shortcutLabel>
|
||||
<DropdownItem
|
||||
on:click={() => dispatch("tagcopy")}
|
||||
on:mount={withButton(createShortcut)}
|
||||
|
|
|
@ -339,6 +339,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
document.body.removeChild(textarea);
|
||||
}
|
||||
|
||||
function selectAllTags() {
|
||||
tags.forEach((tag) => (tag.selected = true));
|
||||
tags = tags;
|
||||
}
|
||||
|
||||
function copySelectedTags() {
|
||||
const content = tags
|
||||
.filter((tag) => tag.selected)
|
||||
|
@ -368,6 +373,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
{#if tags.some((tag) => tag.selected)}
|
||||
<SelectedTagBadge
|
||||
--badge-align="-webkit-baseline-middle"
|
||||
on:tagselectall={selectAllTags}
|
||||
on:tagcopy={copySelectedTags}
|
||||
on:tagdelete={deleteSelectedTags}
|
||||
/>
|
||||
|
|
Loading…
Reference in a new issue