mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Replace delim char with colons on copying tags
This commit is contained in:
parent
46e607a777
commit
85691fada2
2 changed files with 11 additions and 2 deletions
|
@ -350,7 +350,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
function copySelectedTags() {
|
||||
const content = tags
|
||||
.filter((tag) => tag.selected)
|
||||
.map((tag) => tag.name)
|
||||
.map((tag) => replaceWithColon(tag.name))
|
||||
.join("\n");
|
||||
copyToClipboard(content);
|
||||
deselect();
|
||||
|
|
|
@ -4,7 +4,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
-->
|
||||
<script lang="typescript">
|
||||
import { onMount, createEventDispatcher, tick } from "svelte";
|
||||
import { normalizeTagname, delimChar } from "./tags";
|
||||
import { normalizeTagname, delimChar, replaceWithColon } from "./tags";
|
||||
|
||||
export let id: string | undefined = undefined;
|
||||
let className: string = "";
|
||||
|
@ -178,6 +178,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
}
|
||||
}
|
||||
|
||||
function onCopy(event: ClipboardEvent): void {
|
||||
const selection = document.getSelection();
|
||||
event.clipboardData!.setData(
|
||||
"text/plain",
|
||||
replaceWithColon(selection!.toString())
|
||||
);
|
||||
}
|
||||
|
||||
function onPaste(event: ClipboardEvent): void {
|
||||
if (!event.clipboardData) {
|
||||
return;
|
||||
|
@ -220,6 +228,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
on:keydown
|
||||
on:keyup
|
||||
on:input
|
||||
on:copy|preventDefault={onCopy}
|
||||
on:paste|preventDefault={onPaste}
|
||||
/>
|
||||
|
||||
|
|
Loading…
Reference in a new issue