Fixing left/right arrow support in empty text element
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Fri, 9 Aug 2013 11:04:19 +0000 (13:04 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Fri, 9 Aug 2013 11:54:46 +0000 (13:54 +0200)
modules/documentCanvas/canvas/canvas.js

index 1b39183..8ba871b 100644 (file)
@@ -188,8 +188,8 @@ $.extend(Canvas.prototype, {
                                 direction = 'below';
                                 caretTo = 'start';
                             }
                                 direction = 'below';
                                 caretTo = 'start';
                             }
-                            var el = canvas.getDocumentElement(utils.nearestInDocumentOrder('[document-text-element]', direction, window.getSelection().focusNode))
-                            canvas.setCurrentElement(element, {caretTo: caretTo});
+                            var el = canvas.getDocumentElement(utils.nearestInDocumentOrder('[document-text-element]', direction, element.dom()[0]));
+                            canvas.setCurrentElement(el, {caretTo: caretTo});
                         } else {
                             var txt = element.dom().contents()[0].data;
                             if(e.which === KEYS.ARROW_LEFT && position.offset > 1 && txt.charAt(position.offset-2) === utils.unicode.ZWS) {
                         } else {
                             var txt = element.dom().contents()[0].data;
                             if(e.which === KEYS.ARROW_LEFT && position.offset > 1 && txt.charAt(position.offset-2) === utils.unicode.ZWS) {