PDA

View Full Version : [CLOSED] [#477] HtmlEditor icw IE11



prost
Apr 28, 2014, 3:43 PM
Hi, I started migrating to V2.5 but get errors with the HtmlEditor control in IE11 (in Chrome it works).

When I click in the editor area of the HtmlEditor control I get a javascript error:


0x800a138f - JavaScript runtime error: Unable to get property 'createRange' of undefined or null reference

onEditorEvent:function(){if(Ext.isIE){this.current Range=this.getDoc().selection.createRange();}

I use Ext.dll (2.5.1.24957, for .NET 4.0).

The problem seems to be a local problem, on an other development computer I do not get the error.
I tried flushing browser cache/reboot/etc. but it does not help. Do you have any idea wat causes the problem?

Thanks,
Sander

Vladimir
Apr 28, 2014, 3:46 PM
The issue is fixed in SVN already, please update and retest

prost
Apr 30, 2014, 9:49 AM
With the latest version from SVN I do not get the error anymore when clicking in the editor.
When I however try to insert text in the editor using javascript I get a similar error:



0x800a138f - JavaScript runtime error: Unable to get property 'createRange' of undefined or null reference

insertAtCursor:function(text){if(!this.activated){ return;}
this.win.focus();if(Ext.isIE){var doc=this.getDoc(),r=this.currentRange||doc.selecti on.createRange();


doc.selection == undefined



<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Button ID="InsertTxtButton" runat="server"
Text="Insert txt">
<Listeners>
<Click Handler="#{Editor}.insertAtCursor('xyz...');" />
</Listeners>
</ext:Button>
<ext:HtmlEditor ID="Editor" runat="server"
Width="300"
Height="240">
</ext:HtmlEditor>
</form>
</body>
</html>


Ext.NET version: 2.5.1.29828

Thanks for your help.
Sander

Daniil
Apr 30, 2014, 1:34 PM
Thank you for the report. Please update and retest.

prost
Apr 30, 2014, 2:19 PM
Thank you for the report. Please update and retest.

I do not get the error anymore, but no text is inserted with the sample code. Is the sample correct?

Daniil
Apr 30, 2014, 6:45 PM
Yes, the sample is correct.

I confirm the insertAtCursor method doesn't work in IE11. There is a problem with that in IE11.
http://stackoverflow.com/questions/3398378/execcommand-inserthtml-in-internet-explorer

Here is a possible fix, but it wraps the inserted text in an additional span element. I cannot find a way to avoid it.

Fix

Ext.form.field.HtmlEditor.override({
insertAtCursor : function (text) {
var doc, r, nnode;

if (!this.activated) {
return;
}

this.win.focus();
if (Ext.isIE && !Ext.isIE11) {
doc = this.getDoc();
r = this.currentRange || doc.selection.createRange();

if (r) {
r.pasteHTML(text);
this.syncValue();
this.deferFocus();
}
} else if (Ext.isIE11) {
doc = this.getDoc();
r = doc.getSelection().getRangeAt(0);

nnode = doc.createElement("span"); // Is there any way to avoid that? I cannot find...
r.surroundContents(nnode);
nnode.innerHTML = text;
} else {
this.execCmd("InsertHTML", text);
this.deferFocus();
}
}
});

prost
Apr 30, 2014, 9:53 PM
The fix works, thanks Daniil!

Daniil
May 05, 2014, 6:27 AM
Thank you for confirming. I've committed the fix to the trunk, the revision #5819.