Jan 04, 2015, 11:45 PM
[CLOSED] HtmlEditor currentRange in IE11
In the new version, and I met this problem?
http://forums.ext.net/showthread.php...r+currentRange
It will remind currentRange undefined When clicked the field.
http://forums.ext.net/showthread.php...r+currentRange
It will remind currentRange undefined When clicked the field.
onEditorEvent: function () {
if (Ext.isIE && !Ext.isIE11) {
this.currentRange = this.getDoc().selection.createRange();
}
this.updateToolbar();
},
I do not know the location of 'override' right:<%@ Page Language="C#" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.HtmlEditor1.Text = "<b>Some Initial HTML. You can edit it and submit to server.</b>";
}
}
protected void Submit(object sender, DirectEventArgs e)
{
X.Msg.Alert("Submit", "The following has been submitted:<br/><br/>" + this.HtmlEditor1.Text).Show();
}
</script>
<!DOCTYPE html>
<html>
<head runat="server">
<title>HtmlEditor - Ext.NET Examples</title>
<link href="/resources/css/examples.css" rel="stylesheet" />
<script type="text/javascript">
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();
}
}
});
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<h1>HtmlEditor</h1>
<p>Provides a lightweight HTML Editor component.</p>
<p>For more details, we would strongly recommend to read <a href="http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.HtmlEditor">the HtmlEditor ExtJS docs article</a> and <a href="http://forums.ext.net/showthread.php?20425&p=88270&viewfull=1#post88270">this Ext.NET forums thread</a> about possible problems with HtmlEditor.</p>
<br/>
<ext:HtmlEditor
ID="HtmlEditor1"
runat="server"
Width="600"
EnableAlignments="false"
EnableFontSize="false"
CreateLinkText="My CreateLinkText">
<ButtonTips>
<BackColor Text="My BackColor Tip" />
<Bold Text="My Bold Tip" />
</ButtonTips>
</ext:HtmlEditor>
<ext:Button runat="server" Text="Submit" OnDirectClick="Submit" />
</form>
</body>
</html>
Last edited by Daniil; Jan 15, 2015 at 12:16 PM.
Reason: [CLOSED]