PDA

View Full Version : [2.2] HtmlEditor and Safari, insertHTML



jmcneese
11 May 2009, 9:52 AM
if anyone has had the problem that when using safari, the htmleditor will not allow insertion of HTML, here's an override:



Ext.override(Ext.form.HtmlEditor, {
insertAtCursor : function(text){
if(!this.activated){
return;
}
if(Ext.isIE){
this.win.focus();
var r = this.doc.selection.createRange();
if(r){
r.collapse(true);
r.pasteHTML(text);
this.syncValue();
this.deferFocus();
}
}else if(Ext.isGecko || Ext.isOpera){
this.win.focus();
this.execCmd('InsertHTML', text);
this.deferFocus();
}else if(Ext.isSafari){
this.execCmd('InsertHTML', '');
this.execCmd('InsertHTML', text);
this.deferFocus();
}
}
});