Quick fix: Fixing node element selection
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 15 Jul 2013 15:06:28 +0000 (17:06 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 15 Jul 2013 15:06:28 +0000 (17:06 +0200)
Cursor now lands in a text element chosen to be selected by
canvas algorithm.

modules/documentCanvas/canvas/canvas.js

index 7a1d930..76eddb1 100644 (file)
@@ -208,11 +208,12 @@ $.extend(Canvas.prototype, {
         if(currentTextElement && !(currentTextElement.sameNode(textElementToLand)))
             this.wrapper.find('.current-text-element').removeClass('current-text-element');
 
         if(currentTextElement && !(currentTextElement.sameNode(textElementToLand)))
             this.wrapper.find('.current-text-element').removeClass('current-text-element');
 
-        if(textElementToLand && !(textElementToLand.sameNode(currentTextElement))) {
+        if(textElementToLand) {
             _markAsCurrent(textElementToLand);
             _markAsCurrent(textElementToLand);
-            if(params.caretTo)
+            if(params.caretTo || !textElementToLand.sameNode(this.getCursor().getPosition().element))
                 this._moveCaretToTextElement(textElementToLand, params.caretTo); // as method on element?
                 this._moveCaretToTextElement(textElementToLand, params.caretTo); // as method on element?
-            this.publisher('currentTextElementSet', element);
+            if(!(textElementToLand.sameNode(currentTextElement)))
+                this.publisher('currentTextElementSet', element);
         }
 
         if(!(currentNodeElement && currentNodeElement.sameNode(nodeElementToLand))) {
         }
 
         if(!(currentNodeElement && currentNodeElement.sameNode(nodeElementToLand))) {