Improve link-complete dropdown menu
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
2a0a582d7b
commit
3bdc30465e
|
@ -108,18 +108,12 @@ function showSearchResultsExtended(element, template, searchTool, query, input,
|
|||
return searchTool(query).then(results => {
|
||||
let opt = options || {};
|
||||
if (opt.showOnlyResults && (query.length === 0 || !results.length)) {
|
||||
$lc.fadeOut()
|
||||
$lc.hide()
|
||||
return
|
||||
}
|
||||
$lc.data('result-type', resultType)
|
||||
|
||||
if (opt.belowCursor) {
|
||||
let pos = getCaretCoordinates(input, value.selectionEnd, {})
|
||||
let off = $(input).offset()
|
||||
pos.top += off.top + pos.height
|
||||
pos.left += off.left
|
||||
$lc.offset(pos)
|
||||
}
|
||||
const visible = $(':visible', $lc).length
|
||||
|
||||
let selectedPos = 0;
|
||||
let selected = $lc.find('li.selected');
|
||||
|
@ -148,7 +142,14 @@ function showSearchResultsExtended(element, template, searchTool, query, input,
|
|||
})
|
||||
)
|
||||
|
||||
$lc.html($ul).fadeIn()
|
||||
$lc.show()
|
||||
.html($ul)
|
||||
|
||||
if (opt.belowCursor) {
|
||||
let pos = getCaretCoordinates(input, value.selectionEnd, {})
|
||||
let off = $(input).offset()
|
||||
$lc.offset({top: off.top + pos.top + pos.height, left: off.left + pos.left})
|
||||
}
|
||||
|
||||
return results
|
||||
})
|
||||
|
@ -514,13 +515,13 @@ function Editor(holder, input) {
|
|||
const isVisible = $('#link-complete:visible').length > 0;
|
||||
|
||||
if (event.key === 'Escape' && isVisible) {
|
||||
$lc.fadeOut()
|
||||
$lc.hide()
|
||||
return false
|
||||
} else if (event.key === 'Enter' && isVisible) {
|
||||
const element = $lc.find('li.selected')
|
||||
const linkName = element.text()
|
||||
$lc.trigger('popup:selected', [linkName, $lc.data('result-type'), element])
|
||||
$lc.fadeOut()
|
||||
$lc.hide()
|
||||
return false
|
||||
} else if (event.key === 'ArrowUp' && isVisible) {
|
||||
const selected = $lc.find('li.selected')
|
||||
|
@ -580,7 +581,7 @@ function Editor(holder, input) {
|
|||
if (event.key === '/') {
|
||||
searchEnabled = true
|
||||
}
|
||||
if (searchEnabled && event.key === 'Escape') {
|
||||
if (searchEnabled && (event.key === 'Escape' || event.key === 'Space')) {
|
||||
searchEnabled = false
|
||||
return false;
|
||||
}
|
||||
|
@ -608,7 +609,7 @@ function Editor(holder, input) {
|
|||
if (insideSearch) {
|
||||
let query = value.substring(start + 1, end);
|
||||
showSearchResults(commandSearch, query, input, value, 'command').then(results => {
|
||||
if (query.length > 0 && results.length === 0) {
|
||||
if (query.length > 0 && (!results || results.length === 0)) {
|
||||
searchEnabled = false
|
||||
}
|
||||
})
|
||||
|
@ -618,7 +619,7 @@ function Editor(holder, input) {
|
|||
showSearchResults(titleSearch, query, input, value, 'link');
|
||||
return true
|
||||
} else {
|
||||
$('#link-complete').fadeOut();
|
||||
$('#link-complete').hide();
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue
Block a user