From fde8d11b5f59de5dac41ad3584678cee0414b90d Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 15 Aug 2017 21:32:53 +0200 Subject: [PATCH] Improved error handling. --- .../app/lib/base/jquery.contenteditable.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/app/lib/base/jquery.contenteditable.js b/app/assets/javascripts/app/lib/base/jquery.contenteditable.js index a9fd43626..a82a036dc 100644 --- a/app/assets/javascripts/app/lib/base/jquery.contenteditable.js +++ b/app/assets/javascripts/app/lib/base/jquery.contenteditable.js @@ -104,12 +104,14 @@ // break
after enter on empty line sel = window.getSelection() - node = $(sel.anchorNode) - if (node.parent().is('blockquote')) { - e.preventDefault() - document.execCommand('Insertparagraph') - document.execCommand('Outdent') - return + if (sel) { + node = $(sel.anchorNode) + if (node && node.parent() && node.parent().is('blockquote')) { + e.preventDefault() + document.execCommand('Insertparagraph') + document.execCommand('Outdent') + return + } } // behavior to enter new line on alt+enter @@ -246,7 +248,7 @@ // limit check if ( !_this.allowKey(e) ) { - if ( !_this.maxLengthOk( 1 ) ) { + if ( !_this.maxLengthOk(1) ) { e.preventDefault() return }