From fe35573308239218de64ab8742f987d7dccc9fbc Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Sat, 26 Jun 2021 01:00:41 +0200 Subject: [PATCH] Reimplement tagjoin with tick() --- ts/editor/TagEditor.svelte | 28 ++++++---------------------- ts/editor/TagInput.svelte | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/ts/editor/TagEditor.svelte b/ts/editor/TagEditor.svelte index b4425cb6d..f980a5d3b 100644 --- a/ts/editor/TagEditor.svelte +++ b/ts/editor/TagEditor.svelte @@ -56,36 +56,24 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html tags = tags; } - function joinWithPreviousTag( - index: number, - setPosition: (position: number) => void - ): void { + function joinWithPreviousTag(index: number): void { if (index === 0) { return; } const spliced = tags.splice(index - 1, 1)[0]; - const length = spliced.name.length; tags[index - 1].name = spliced.name + tags[index - 1].name; tags = tags; - - setPosition(length); } - function joinWithNextTag( - index: number, - setPosition: (position: number) => void - ): void { + function joinWithNextTag(index: number): void { if (index === tags.length - 1) { return; } const spliced = tags.splice(index + 1, 1)[0]; - const length = tags[index].name.length; tags[index].name = tags[index].name + spliced.name; tags = tags; - - setPosition(length); } function moveToPreviousTag(index: number): void { @@ -115,13 +103,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html newName = ""; } - function joinWithLastTag(setPosition: (position: number) => void): void { + function joinWithLastTag(): void { const popped = tags.pop(); tags = tags; if (popped) { newName = popped.name + newName; - setPosition(popped.name.length); } } @@ -149,10 +136,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html on:tagupdate={() => checkForDuplicateAt(index)} on:tagadd={() => insertTagAt(index)} on:tagdelete={() => deleteTagAt(index)} - on:tagjoinprevious={({ detail }) => - joinWithPreviousTag(index, detail.setPosition)} - on:tagjoinnext={({ detail }) => - joinWithNextTag(index, detail.setPosition)} + on:tagjoinprevious={() => joinWithPreviousTag(index)} + on:tagjoinnext={() => joinWithNextTag(index)} on:tagmoveprevious={() => moveToPreviousTag(index)} on:tagmovenext={() => moveToNextTag(index)} /> @@ -165,8 +150,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html on:blur={destroyAutocomplete} on:tagupdate={appendTag} on:tagadd={appendTag} - on:tagjoinprevious={({ detail }) => - joinWithLastTag(detail.setPosition)} + on:tagjoinprevious={joinWithLastTag} on:tagmoveprevious={moveToLastTag} /> diff --git a/ts/editor/TagInput.svelte b/ts/editor/TagInput.svelte index 00df08c7e..276fe35dd 100644 --- a/ts/editor/TagInput.svelte +++ b/ts/editor/TagInput.svelte @@ -3,7 +3,7 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -->