mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Fix TagBadge and TagSpacer
This commit is contained in:
parent
96325a4910
commit
36f455c0ee
1 changed files with 10 additions and 19 deletions
|
@ -50,22 +50,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
activeAfterBlur = null;
|
activeAfterBlur = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addEmptyTag(): Promise<void> {
|
|
||||||
const lastTag = tags[tags.length - 1];
|
|
||||||
|
|
||||||
if (lastTag.name.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const index = tags.push(attachId("")) - 1;
|
|
||||||
tags = tags;
|
|
||||||
active = index;
|
|
||||||
}
|
|
||||||
|
|
||||||
function insertEmptyTagAt(index: number): void {
|
function insertEmptyTagAt(index: number): void {
|
||||||
|
/* used by tag badge and tag spacer */
|
||||||
tags.splice(index, 0, attachId(""));
|
tags.splice(index, 0, attachId(""));
|
||||||
tags = tags;
|
tags = tags;
|
||||||
setActiveAfterBlur(index);
|
active = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendEmptyTagAt(index: number): void {
|
function appendEmptyTagAt(index: number): void {
|
||||||
|
@ -87,7 +76,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function enterTag(tag: TagType, index: number): void {
|
function enterTag(_tag: TagType, index: number): void {
|
||||||
appendEmptyTagAt(index);
|
appendEmptyTagAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +147,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
async function moveToNextTag(tag: TagType, index: number): Promise<void> {
|
async function moveToNextTag(tag: TagType, index: number): Promise<void> {
|
||||||
if (isLast(index)) {
|
if (isLast(index)) {
|
||||||
addEmptyTag();
|
if (tag.name.length !== 0) {
|
||||||
|
appendEmptyTagAt(index);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log("movenext", index);
|
console.log("movenext", index);
|
||||||
|
@ -166,8 +157,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
active = null;
|
active = null;
|
||||||
activeAfterBlur = index + 1;
|
activeAfterBlur = index + 1;
|
||||||
|
|
||||||
/* await tick(); */
|
await tick();
|
||||||
/* input.setSelectionRange(0, 0); */
|
input.setSelectionRange(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function activate(index: number): Promise<void> {
|
async function activate(index: number): Promise<void> {
|
||||||
|
@ -185,7 +176,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
<StickyBottom>
|
<StickyBottom>
|
||||||
<div class="row-gap">
|
<div class="row-gap">
|
||||||
<ButtonToolbar class="dropup d-flex flex-wrap align-items-center" {size}>
|
<ButtonToolbar class="dropup d-flex flex-wrap align-items-center" {size}>
|
||||||
<AddTagBadge on:click={addEmptyTag} />
|
<AddTagBadge on:click={() => insertEmptyTagAt(tags.length)} />
|
||||||
|
|
||||||
<TagAutocomplete
|
<TagAutocomplete
|
||||||
class="d-flex flex-column-reverse"
|
class="d-flex flex-column-reverse"
|
||||||
|
@ -228,7 +219,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="tag-spacer flex-grow-1 align-self-stretch"
|
class="tag-spacer flex-grow-1 align-self-stretch"
|
||||||
on:click={addEmptyTag}
|
on:click={() => insertEmptyTagAt(tags.length)}
|
||||||
/>
|
/>
|
||||||
</TagAutocomplete>
|
</TagAutocomplete>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue