Fix: After breaking node element into two non empty ones via enter move caret to...
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 7 Aug 2013 13:53:02 +0000 (15:53 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 7 Aug 2013 21:31:12 +0000 (23:31 +0200)
modules/documentCanvas/canvas/canvas.js

index 873b39e..9282d20 100644 (file)
@@ -284,16 +284,23 @@ $.extend(Canvas.prototype, {
 
                             var elements = position.element.split({offset: position.offset}),
                                 newEmpty,
 
                             var elements = position.element.split({offset: position.offset}),
                                 newEmpty,
-                                goto;
+                                goto,
+                                gotoOptions;
 
                             if(position.offsetAtBeginning)
                                 newEmpty = elements.first;
                             else if(position.offsetAtEnd)
                                 newEmpty = elements.second;
 
                             if(position.offsetAtBeginning)
                                 newEmpty = elements.first;
                             else if(position.offsetAtEnd)
                                 newEmpty = elements.second;
+                            
                             if(newEmpty) {
                                 goto = newEmpty.append(documentElement.DocumentTextElement.create({text: ''}, this));
                             if(newEmpty) {
                                 goto = newEmpty.append(documentElement.DocumentTextElement.create({text: ''}, this));
-                                canvas.setCurrentElement(goto);
+                                gotoOptions = {};
+                            } else {
+                                goto = elements.second;
+                                gotoOptions = {caretTo: 'start'};
                             }
                             }
+
+                            canvas.setCurrentElement(goto, gotoOptions);
                         }
                     }
                 }
                         }
                     }
                 }