From 570dd7cb4e1963bca4dc85bd93f9c996af452b8f Mon Sep 17 00:00:00 2001 From: azivner Date: Mon, 28 Aug 2017 21:50:20 -0400 Subject: [PATCH] link is inserted at correct position in the editor --- static/js/init.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/static/js/init.js b/static/js/init.js index 404b4a4c9..ed1741b9b 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() { + const noteDetail = $('#noteDetail'); + noteDetail.summernote('editor.saveRange'); + $("#insertLinkDialog").dialog({ modal: true }); @@ -121,10 +124,7 @@ $(document).bind('keydown', 'alt+l', function() { } }); - //const noteDetail = $('#noteDetail'); - //linkInfo = noteDetail.summernote('invoke', 'editor.getLinkInfo'); - //noteDetail.summernote('invoke', 'editor.saveRange'); }); $("#addLinkButton").click(function() { @@ -138,15 +138,15 @@ $("#addLinkButton").click(function() { const noteDetail = $('#noteDetail'); + $("#insertLinkDialog").dialog("close"); + + noteDetail.summernote('editor.restoreRange'); + noteDetail.summernote('createLink', { text: globalNoteNames[noteId], url: 'app#' + noteId, isNewWindow: true // range: linkInfo.range }); - - //noteDetail.summernote('invoke', 'editor.restoreRange'); - - $("#insertLinkDialog").dialog("close"); } }); \ No newline at end of file