Implement tag auto-completion
This commit is contained in:
parent
70b66122c8
commit
e341d666af
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue