editor: canvas fix - fix selecting node without direct text node child
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 4 Jun 2014 12:03:31 +0000 (14:03 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 4 Jun 2014 12:03:31 +0000 (14:03 +0200)
Without this fix, clicking element without direct text child element but
with children containing text nodes resulted in selecting this
child text element (while visual indication for the user was that the
requested element was selected).

src/editor/modules/documentCanvas/canvas/canvas.js
src/editor/modules/documentCanvas/canvas/genericElement.js

index 05c109c..b234dd8 100644 (file)
@@ -349,7 +349,7 @@ $.extend(Canvas.prototype, Backbone.Events, {
             if(byBrowser && byBrowser.parent().sameNode(nodeToLand)) {
                 return byBrowser;
             }
-            return e.getVerticallyFirstTextElement();
+            return e.getVerticallyFirstTextElement({considerChildren: false});
         }.bind(this);
         var _markAsCurrent = function(element) {
             if(element instanceof documentElement.DocumentTextElement) {
index 878e140..4dfbe59 100644 (file)
@@ -80,13 +80,18 @@ $.extend(generic, {
         return toret;
     },
 
-    getVerticallyFirstTextElement: function() {
+    getVerticallyFirstTextElement: function(params) {
         var toret;
+        
+        params = _.extend({
+            considerChildren: true
+        }, params);
+        
         this.children().some(function(child) {
             if(child instanceof documentElement.DocumentTextElement) {
                 toret = child;
                 return true; // break
-            } else {
+            } else if(params.considerChildren) {
                 toret = child.getVerticallyFirstTextElement();
                 if(toret) {
                     return true; // break