[Dojo-checkins] jaredj - r20752 - dijit/trunk/_editor

dojo-checkins-admin at dojotoolkit.org dojo-checkins-admin at dojotoolkit.org
Mon Nov 9 12:22:05 EST 2009


Author: jaredj
Date: Mon Nov  9 09:22:01 2009
New Revision: 20752

Modified:
   dijit/trunk/_editor/RichText.js
Log:
Make WebKit focus to beginning programmatically.  \!strict Doesn't remove the space, but focuses a bit better.  fixes #10268

Modified: dijit/trunk/_editor/RichText.js
==============================================================================
--- dijit/trunk/_editor/RichText.js	(original)
+++ dijit/trunk/_editor/RichText.js	Mon Nov  9 09:22:01 2009
@@ -468,10 +468,10 @@
 		}else if(dojo.isMoz){
 			// workaround bug where can't select then delete text (until user types something
 			// into the editor)... and/or issue where typing doesn't erase selected text
+			this._cursorToStart = true;
 			html = " ";
 		}
 
-
 		var font = [ _cs.fontWeight, _cs.fontSize, _cs.fontFamily ].join(" ");
 
 		// line height is tricky - applying a units value will mess things up.
@@ -927,6 +927,14 @@
 		//		Move focus to this editor
 		if(!dojo.isIE){
 			dijit.focus(this.iframe);
+			if(this._cursorToStart){ 
+				delete this._cursorToStart;
+				if(this.editNode.childNodes && 
+					this.editNode.childNodes.length === 1 && 
+					this.editNode.innerHTML === " "){
+						this.placeCursorAtStart();
+				}
+			}
 		}else if(this.editNode && this.editNode.focus){
 			// editNode may be hidden in display:none div, lets just punt in this case
 			//this.editNode.focus(); -> causes IE to scroll always (strict and quirks mode) to the top the Iframe
@@ -1343,6 +1351,7 @@
 
 			// Use   to avoid webkit problems where editor is disabled until the user clicks it
 			if(!html && dojo.isWebKit){
+				this._cursorToStart = true;
 				html = " ";
 			}
 			node.innerHTML = html;
@@ -1367,7 +1376,10 @@
 		}else if(this.window && this.window.getSelection){ // Moz
 			html = this._preFilterContent(html);
 			this.execCommand("selectall");
-			if(!html){ html = " "; }
+			if(!html){ 
+				this._cursorToStart = true;
+				html = " "; 
+			}
 			this.execCommand("inserthtml", html);
 			this._preDomFilterContent(this.editNode);
 		}else if(this.document && this.document.selection){//IE


More information about the Dojo-checkins mailing list