Roo/form/HtmlEditor.js
authorEdward <edward@roojs.com>
Mon, 8 Jun 2015 05:57:52 +0000 (13:57 +0800)
committerEdward <edward@roojs.com>
Mon, 8 Jun 2015 05:57:52 +0000 (13:57 +0800)
Roo/form/HtmlEditor.js

index aef6eb2..921cfe4 100644 (file)
@@ -274,12 +274,27 @@ Roo.extend(Roo.form.HtmlEditor, Roo.form.Field, {
             "end" : function(e){
                 e.preventDefault();
                 Roo.log('END');
-                Roo.log(this.el.dom.selectionStart);
-                Roo.log(this.getValue());
+                var curr = this.el.dom.selectionStart;
+                var lines = this.getValue().split("\n");
+                
+                if(!lines.length){
+                    return;
+                }
+                var pos = 0;
+                
+                for (var i = 0; i < lines.length;i++) {
+                    
+                    pos += lines[i].length;
+                    
+                    if(pos < curr){
+                        continue;
+                    }
+                    
+                    break;
+                }
                 
-                Roo.log(this.getValue().split("\n"));
                 
-                Roo.log(this.el.dom.setSelectionRange(this.getValue().length,this.getValue().length));
+                Roo.log(this.el.dom.setSelectionRange(pos, pos));
             },
 
             scope : this,