diff --git a/ts/editor/BUILD.bazel b/ts/editor/BUILD.bazel index cd5951967..158d2b1ce 100644 --- a/ts/editor/BUILD.bazel +++ b/ts/editor/BUILD.bazel @@ -132,6 +132,7 @@ copy_mdi_icons( # tag editor "tag-outline.svg", + "tag-plus.svg", ], visibility = ["//visibility:public"], ) diff --git a/ts/editor/Tag.svelte b/ts/editor/Tag.svelte index f05ae70a4..e057db70b 100644 --- a/ts/editor/Tag.svelte +++ b/ts/editor/Tag.svelte @@ -14,6 +14,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html let active = false; + function checkForActivation(): void { + const selection = window.getSelection()!; + if (selection.isCollapsed) { + active = true; + } + } + function tagDelete(event: Event): void { dispatch("tagdelete", { name }); event.stopPropagation(); @@ -25,10 +32,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html {:else} (active = true)} + on:click|stopPropagation={checkForActivation} > {name} - {@html deleteIcon} diff --git a/ts/editor/TagEditor.svelte b/ts/editor/TagEditor.svelte index e4a926cbe..b2a1427f2 100644 --- a/ts/editor/TagEditor.svelte +++ b/ts/editor/TagEditor.svelte @@ -7,14 +7,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import Badge from "components/Badge.svelte"; import Tag from "./Tag.svelte"; import TagInputNew from "./TagInputNew.svelte"; - import { tagIcon } from "./icons"; + import { addTagIcon } from "./icons"; export let tags = ["en::foobar", "zh::あっちこっち"]; let tagInputNew: HTMLInputElement; let inputNew = false; - function focusTagInputNew(): void { + function focusInputNew(): void { inputNew = true; tagInputNew.focus(); } @@ -26,26 +26,33 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -
- {@html tagIcon} +
+ {@html addTagIcon} {#each tags as tag} {/each} - {#if inputNew} +
(inputNew = false)} /> - {/if} +
diff --git a/ts/editor/TagInput.svelte b/ts/editor/TagInput.svelte index 61ccf0463..4b09f2578 100644 --- a/ts/editor/TagInput.svelte +++ b/ts/editor/TagInput.svelte @@ -63,7 +63,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html on:nameChosen={setTagname} on:accept={onAccept} > -