From 24a3f814ed4f558539ef895c5341fa152e9eb3f0 Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 25 Aug 2019 21:55:36 +0200 Subject: [PATCH] fix ctrl+enter in sql console --- src/public/javascripts/dialogs/sql_console.js | 6 +----- src/public/javascripts/services/utils.js | 3 ++- src/services/script.js | 4 ++++ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/public/javascripts/dialogs/sql_console.js b/src/public/javascripts/dialogs/sql_console.js index 83c706124..c7a6b6a07 100644 --- a/src/public/javascripts/dialogs/sql_console.js +++ b/src/public/javascripts/dialogs/sql_console.js @@ -50,11 +50,7 @@ async function initEditor() { codeEditor.focus(); } -async function execute(e) { - // stop from propagating upwards (dangerous especially with ctrl+enter executable javascript notes) - e.preventDefault(); - e.stopPropagation(); - +async function execute() { // execute the selected text or the whole content if there's no selection let sqlQuery = codeEditor.getSelection(); diff --git a/src/public/javascripts/services/utils.js b/src/public/javascripts/services/utils.js index 81c150fc4..0a1217156 100644 --- a/src/public/javascripts/services/utils.js +++ b/src/public/javascripts/services/utils.js @@ -141,9 +141,10 @@ function bindElShortcut($el, keyboardShortcut, handler) { } $el.bind('keydown', keyboardShortcut, e => { - handler(); + handler(e); e.preventDefault(); + e.stopPropagation(); }); } } diff --git a/src/services/script.js b/src/services/script.js index 85c02aef5..8fbfd8828 100644 --- a/src/services/script.js +++ b/src/services/script.js @@ -92,6 +92,10 @@ function getParams(params) { async function getScriptBundleForFrontend(note) { const bundle = await getScriptBundle(note); + if (!bundle) { + return; + } + // for frontend we return just noteIds because frontend needs to use its own entity instances bundle.noteId = bundle.note.noteId; delete bundle.note;