Don't show popup at beginning of input and only when there are results
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Peter Stuifzand 2020-05-31 22:26:49 +02:00
parent 2bb0c01914
commit c0850e44c4

View File

@ -165,13 +165,21 @@ if (holder) {
let value = input.value
let end = input.selectionEnd
let start = value.lastIndexOf("[[", end)
if (start < 0) {
return true
}
let linkEnd = value.lastIndexOf("]]", end - 1)
if (start < linkEnd) {
return
return true
}
let query = value.substring(start+2, end);
let results = search.search(query)
if (results.length === 0) {
return true
}
let pos = getCaretCoordinates(input, value.selectionEnd, {})
let off = $(input).offset()
pos.top += off.top + pos.height
@ -183,6 +191,7 @@ if (holder) {
var template = document.getElementById('link-template').innerHTML;
var rendered = Mustache.render(template, {results: results}, {}, ['[[', ']]']);
$lc.html(rendered).fadeIn()
return true
})
})