Implement tag auto-completion
This commit is contained in:
parent
70b66122c8
commit
e341d666af
|
@ -22,14 +22,16 @@
|
|||
|
||||
function handleInput(e) {
|
||||
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();
|
||||
return;
|
||||
}
|
||||
|
||||
open(word);
|
||||
}
|
||||
|
||||
function handleKeyDown(e) {
|
||||
|
@ -52,9 +54,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
function open(word) {
|
||||
function open() {
|
||||
isOpen = true;
|
||||
updateSuggestions(word);
|
||||
selectedIndex = 0;
|
||||
}
|
||||
|
||||
|
@ -93,10 +94,6 @@
|
|||
return input.value.substring(bounds.start, bounds.end);
|
||||
}
|
||||
|
||||
function updateSuggestions(word) {
|
||||
suggestions = tags.filter(tag => tag.indexOf(word) === 0);
|
||||
}
|
||||
|
||||
function updateSelection(dir) {
|
||||
|
||||
const length = suggestions.length;
|
||||
|
|
Loading…
Reference in New Issue