integration wip: ctrl + enter
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 20 Nov 2013 12:35:14 +0000 (13:35 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 2 Dec 2013 13:50:53 +0000 (14:50 +0100)
src/editor/modules/documentCanvas/canvas/keyboard.js

index 57a245e..ee36332 100644 (file)
@@ -56,9 +56,14 @@ handlers.push({key: KEYS.ENTER,
 
         if(!cursor.isSelecting()) {
             if(event.ctrlKey) {
 
         if(!cursor.isSelecting()) {
             if(event.ctrlKey) {
-                var added = element.after({tag: element.getWlxmlTag() || 'div', klass: element.getWlxmlClass() || 'p'});
-                added.append({text:''});
-                canvas.setCurrentElement(added, {caretTo: 'start'});
+                if(element instanceof documentElement.DocumentTextElement) {
+                    element = element.parent();
+                }
+                var added = element.data('wlxmlNode').after(
+                    {tagName: element.getWlxmlTag() || 'div', attrs: {'class': element.getWlxmlClass() || 'p'}}
+                );
+                added.append({text: ''});
+                canvas.setCurrentElement(utils.findCanvasElement(added), {caretTo: 'start'});
 
             } else {
 
 
             } else {