If browser returns selection outside of text element return cursor position as undefined
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 16 Jul 2013 09:31:24 +0000 (11:31 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 16 Jul 2013 09:31:24 +0000 (11:31 +0200)
This fixes entering caret out side of text element when clicking
on a node element with one empty text node

modules/documentCanvas/canvas/canvas.js

index 144417a..3f6599a 100644 (file)
@@ -419,6 +419,9 @@ $.extend(Cursor.prototype, {
             anchorElement = this.canvas.getDocumentElement(selection.anchorNode),
             focusElement = this.canvas.getDocumentElement(selection.focusNode);
         
+        if(anchorElement instanceof documentElement.DocumentNodeElement || focusElement instanceof documentElement.DocumentNodeElement)
+            return {};
+
         if(which === 'anchor') {
             return {
                 element: anchorElement,