mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-08 11:18:28 +02:00
Implement tag auto-completion
This commit is contained in:
@@ -22,14 +22,16 @@
|
|||||||
|
|
||||||
function handleInput(e) {
|
function handleInput(e) {
|
||||||
input = e.target;
|
input = e.target;
|
||||||
const word = getCurrentWord(e.target);
|
|
||||||
|
|
||||||
if (!word) {
|
const word = getCurrentWord();
|
||||||
|
|
||||||
|
suggestions = word ? tags.filter(tag => tag.indexOf(word) === 0) : [];
|
||||||
|
|
||||||
|
if (word && suggestions.length > 0) {
|
||||||
|
open();
|
||||||
|
} else {
|
||||||
close();
|
close();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open(word);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleKeyDown(e) {
|
function handleKeyDown(e) {
|
||||||
@@ -52,9 +54,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function open(word) {
|
function open() {
|
||||||
isOpen = true;
|
isOpen = true;
|
||||||
updateSuggestions(word);
|
|
||||||
selectedIndex = 0;
|
selectedIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,10 +94,6 @@
|
|||||||
return input.value.substring(bounds.start, bounds.end);
|
return input.value.substring(bounds.start, bounds.end);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSuggestions(word) {
|
|
||||||
suggestions = tags.filter(tag => tag.indexOf(word) === 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateSelection(dir) {
|
function updateSelection(dir) {
|
||||||
|
|
||||||
const length = suggestions.length;
|
const length = suggestions.length;
|
||||||
|
Reference in New Issue
Block a user