Replace delim char with colons on copying tags

This commit is contained in:
Henrik Giesel 2021-07-09 02:17:21 +02:00
parent 46e607a777
commit 85691fada2
2 changed files with 11 additions and 2 deletions

View file

@ -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();

View file

@ -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}
/>