From: Aleksander Ɓukasz Date: Wed, 7 Aug 2013 13:53:02 +0000 (+0200) Subject: Fix: After breaking node element into two non empty ones via enter move caret to... X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/b2ed6c0477904d9bcbf8494043f231a5197f6b78 Fix: After breaking node element into two non empty ones via enter move caret to the second one --- diff --git a/modules/documentCanvas/canvas/canvas.js b/modules/documentCanvas/canvas/canvas.js index 873b39e..9282d20 100644 --- a/modules/documentCanvas/canvas/canvas.js +++ b/modules/documentCanvas/canvas/canvas.js @@ -284,16 +284,23 @@ $.extend(Canvas.prototype, { 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(newEmpty) { goto = newEmpty.append(documentElement.DocumentTextElement.create({text: ''}, this)); - canvas.setCurrentElement(goto); + gotoOptions = {}; + } else { + goto = elements.second; + gotoOptions = {caretTo: 'start'}; } + + canvas.setCurrentElement(goto, gotoOptions); } } }