diff --git a/ts/editor/TagEditor.svelte b/ts/editor/TagEditor.svelte index 0f447a6ad..5731fef94 100644 --- a/ts/editor/TagEditor.svelte +++ b/ts/editor/TagEditor.svelte @@ -132,9 +132,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html activeInput.setSelectionRange(0, 0); } - function insertTag(index: number): void { - if (!isActiveNameUniqueAt(index)) { + function insertTagKeepFocus(index: number): void { + if (isActiveNameUniqueAt(index)) { tags.splice(index, 0, attachId(activeName)); + active!++; tags = tags; } } @@ -418,7 +419,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html on:input={() => updateTagName(tag)} on:tagsplit={({ detail }) => enterBehavior(index, detail.start, detail.end)} - on:tagadd={() => insertTag(index)} + on:tagadd={() => insertTagKeepFocus(index)} on:tagdelete={() => deleteTagAt(index)} on:tagjoinprevious={() => joinWithPreviousTag(index)} on:tagjoinnext={() => joinWithNextTag(index)} diff --git a/ts/editor/TagInput.svelte b/ts/editor/TagInput.svelte index f3a3b3262..c21673c82 100644 --- a/ts/editor/TagInput.svelte +++ b/ts/editor/TagInput.svelte @@ -139,8 +139,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html } function onPaste(event: ClipboardEvent): void { - event.preventDefault(); - if (!event.clipboardData) { return; } @@ -153,21 +151,16 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html if (splitted.length === 0) { return; - } else if (splitted.length === 1) { - name = splitted.shift()!; - } else { - name = splitted.shift()!; - dispatch("tagadd"); - - const last = splitted.pop()!; - - for (const pastedName of splitted) { - name = pastedName; - dispatch("tagadd"); - } - - name = last; } + + const last = splitted.pop()!; + + for (const pastedName of splitted.reverse()) { + name = pastedName; + dispatch("tagadd"); + } + + name = last; } onMount(() => input.focus()); @@ -187,7 +180,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html on:keydown on:keyup on:input - on:paste={onPaste} + on:paste|preventDefault={onPaste} />