better behavior of link title auto setting

This commit is contained in:
azivner 2017-08-28 21:59:47 -04:00
parent 570dd7cb4e
commit 27dc43b688

View file

@ -97,6 +97,9 @@ $(document).on('click', 'div.popover-content a', function(e) {
let linkInfo; let linkInfo;
$(document).bind('keydown', 'alt+l', function() { $(document).bind('keydown', 'alt+l', function() {
$("#noteAutocomplete").val('');
$("#linkTitle").val('');
const noteDetail = $('#noteDetail'); const noteDetail = $('#noteDetail');
noteDetail.summernote('editor.saveRange'); noteDetail.summernote('editor.saveRange');
@ -115,16 +118,18 @@ $(document).bind('keydown', 'alt+l', function() {
$("#noteAutocomplete").autocomplete({ $("#noteAutocomplete").autocomplete({
source: autocompleteItems, source: autocompleteItems,
change: function(event, ui) { minLength: 0,
change: function() {
let val = $("#noteAutocomplete").val(); let val = $("#noteAutocomplete").val();
val = val.replace(/ \([A-Za-z0-9]{22}\)/, ""); val = val.replace(/ \([A-Za-z0-9]{22}\)/, "");
$("#linkTitle").val(val); $("#linkTitle").val(val);
},
focus: function(event, ui) {
$("#linkTitle").val(ui.item.label);
} }
}); });
//linkInfo = noteDetail.summernote('invoke', 'editor.getLinkInfo');
}); });
$("#addLinkButton").click(function() { $("#addLinkButton").click(function() {
@ -146,7 +151,6 @@ $("#addLinkButton").click(function() {
text: globalNoteNames[noteId], text: globalNoteNames[noteId],
url: 'app#' + noteId, url: 'app#' + noteId,
isNewWindow: true isNewWindow: true
// range: linkInfo.range
}); });
} }
}); });