From 27dc43b688922cada7cc510346edcadf04f6623b Mon Sep 17 00:00:00 2001 From: azivner Date: Mon, 28 Aug 2017 21:59:47 -0400 Subject: [PATCH] better behavior of link title auto setting --- static/js/init.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/static/js/init.js b/static/js/init.js index ed1741b9b..210a28260 100644 --- a/static/js/init.js +++ b/static/js/init.js @@ -97,6 +97,9 @@ $(document).on('click', 'div.popover-content a', function(e) { let linkInfo; $(document).bind('keydown', 'alt+l', function() { + $("#noteAutocomplete").val(''); + $("#linkTitle").val(''); + const noteDetail = $('#noteDetail'); noteDetail.summernote('editor.saveRange'); @@ -115,16 +118,18 @@ $(document).bind('keydown', 'alt+l', function() { $("#noteAutocomplete").autocomplete({ source: autocompleteItems, - change: function(event, ui) { + minLength: 0, + change: function() { let val = $("#noteAutocomplete").val(); val = val.replace(/ \([A-Za-z0-9]{22}\)/, ""); $("#linkTitle").val(val); + }, + focus: function(event, ui) { + $("#linkTitle").val(ui.item.label); } }); - - //linkInfo = noteDetail.summernote('invoke', 'editor.getLinkInfo'); }); $("#addLinkButton").click(function() { @@ -146,7 +151,6 @@ $("#addLinkButton").click(function() { text: globalNoteNames[noteId], url: 'app#' + noteId, isNewWindow: true -// range: linkInfo.range }); } }); \ No newline at end of file