editor: fix - block removing root node via insert/delete
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 27 Jan 2014 11:03:04 +0000 (12:03 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 27 Jan 2014 11:03:04 +0000 (12:03 +0100)
src/editor/modules/documentCanvas/canvas/keyboard.js

index 6b55909..c815489 100644 (file)
@@ -249,6 +249,9 @@ handlers.push({keys: [KEYS.BACKSPACE, KEYS.DELETE],
                 event.preventDefault();
                 var parent = element.parent(),
                     grandParent = parent ? parent.parent() : null;
+                if(!grandParent && parent.children().length === 1) {
+                    return;
+                }
                 if(parent.children().length === 1 && parent.children()[0].sameNode(element)) {
                     if(grandParent && grandParent.children().length === 1) {
                         goto = grandParent.data('wlxmlNode').append({text: ''});