From: Aleksander Ɓukasz Date: Wed, 24 Apr 2013 09:20:00 +0000 (+0200) Subject: Visual editor - handling double enter X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/cb0381b9670fd26c43e808bd2f35aac8d50c9288?ds=sidebyside Visual editor - handling double enter If enter is hit in empty node, the node gets deleted and clone of it's parent is created and inserted after the original. --- diff --git a/modules/visualEditor.js b/modules/visualEditor.js index 77ed078..83bf329 100644 --- a/modules/visualEditor.js +++ b/modules/visualEditor.js @@ -37,6 +37,11 @@ rng.modules.visualEditor = function(sandbox) { var anchor = $(window.getSelection().anchorNode); if(anchor[0].nodeType === Node.TEXT_NODE) anchor = anchor.parent(); + if(anchor.text() === '') { + var todel = anchor; + anchor = anchor.parent(); + todel.remove(); + } var newNode = anchor.clone().empty(); newNode.attr('id', ''); anchor.after(newNode);