HI,
i am pasting bellow content in RadEditor's through OnClientPasteHtml function,
hello<br><br><a href="http://www.gmail.com">gmail</a><br><br><a href="http://www.facebook.com">facebook</a><br><br><br>If you no longer wish to receive these emails, simply click on the following link:<a href="[!RPLINK:GLOBALUNSUBSCRIBE!]">Unsubscribe</a>
after pasting the data displaying as
hello<br><br><a href="<a href='http://www.gmail.com">gmail</a><br><br><a'>http://www.gmail.com">gmail</a><br><br><a</a> href="<a href='http://www.facebook.com">facebook</a><br><br><br>If'>http://www.facebook.com">facebook</a><br><br><br>If</a> you no longer wish to receive these emails, simply click on the following link:<a href="[!RPLINK:GLOBALUNSUBSCRIBE!]">Unsubscribe</a>
checkout anchor tag structure is not in proper in content after pasting.
Editor properties,
<telerik:RadEditor ID="textRadEditor" EditModes="Design" runat="server" Width="100%"
EnableResize="false" OnClientLoad="GetContentLength" OnClientPasteHtml="OnClientPasteHtmlToText"
Height="550px">
<Tools>
<telerik:EditorToolGroup>
<telerik:EditorTool Name="convertToTEXT" Text="Convert HTML to TEXT" ShowText="true"
ShowIcon="false" />
<telerik:EditorSeparator />
<telerik:EditorTool Name="InsertEditorLinks" ShowIcon="false" ShowText="true" Text="Insert Link" />
</telerik:EditorToolGroup>
</Tools>
<CssFiles>
<telerik:EditorCssFile Value="~/Editor/RadEditorTools/EditorContentArea.css" />
</CssFiles>
</telerik:RadEditor>
Script,
function OnClientPasteHtmlToText(sender, args) {
//debugger;
var val = args.get_value();
var name = args.get_name();
if (name == "Paste") {
//debugger;
var editor = $find("<%=textRadEditor.ClientID%>")
if (document.getElementById("hdTextPaste").value != "true") {
var oSelElem1 =val ;
var pattern = /<a[^>]*>(.*?)<\/a>/gi
var code = oSelElem1.match(pattern);
if (code != null) {
for (i = 0; i < code.length; i++) {
var url = code[i].match(/href=\"(.*?)\"/)[1];
var text = code[i].match(/<a[^>]*>(.*?)<\/a>/)[1];
if (text.toLowerCase().search("<img") >= 0)
oSelElem1 = oSelElem1.replace(code[i], url);
else
oSelElem1 = oSelElem1.replace(code[i], text + ':' + url);
}
editor.pasteHtml(oSelElem1);
var plainText = editor.get_text();
editor.set_html("");
plainText = plainText.replace(/((\r\n|\r|\n)\s*)\2/g, "$2");
plainText = plainText.replace(/\t/g, ' ').replace(/ /g, ' ').replace(/\r\n|\n|\r/g, '<br />');
editor.set_html(plainText);
document.getElementById('<%= hdCampEditorTab2.ClientID %>').value = "1";
}
}
}
}
any idea?
Regards,
Anwar
i am pasting bellow content in RadEditor's through OnClientPasteHtml function,
hello<br><br><a href="http://www.gmail.com">gmail</a><br><br><a href="http://www.facebook.com">facebook</a><br><br><br>If you no longer wish to receive these emails, simply click on the following link:<a href="[!RPLINK:GLOBALUNSUBSCRIBE!]">Unsubscribe</a>
after pasting the data displaying as
hello<br><br><a href="<a href='http://www.gmail.com">gmail</a><br><br><a'>http://www.gmail.com">gmail</a><br><br><a</a> href="<a href='http://www.facebook.com">facebook</a><br><br><br>If'>http://www.facebook.com">facebook</a><br><br><br>If</a> you no longer wish to receive these emails, simply click on the following link:<a href="[!RPLINK:GLOBALUNSUBSCRIBE!]">Unsubscribe</a>
checkout anchor tag structure is not in proper in content after pasting.
Editor properties,
<telerik:RadEditor ID="textRadEditor" EditModes="Design" runat="server" Width="100%"
EnableResize="false" OnClientLoad="GetContentLength" OnClientPasteHtml="OnClientPasteHtmlToText"
Height="550px">
<Tools>
<telerik:EditorToolGroup>
<telerik:EditorTool Name="convertToTEXT" Text="Convert HTML to TEXT" ShowText="true"
ShowIcon="false" />
<telerik:EditorSeparator />
<telerik:EditorTool Name="InsertEditorLinks" ShowIcon="false" ShowText="true" Text="Insert Link" />
</telerik:EditorToolGroup>
</Tools>
<CssFiles>
<telerik:EditorCssFile Value="~/Editor/RadEditorTools/EditorContentArea.css" />
</CssFiles>
</telerik:RadEditor>
Script,
function OnClientPasteHtmlToText(sender, args) {
//debugger;
var val = args.get_value();
var name = args.get_name();
if (name == "Paste") {
//debugger;
var editor = $find("<%=textRadEditor.ClientID%>")
if (document.getElementById("hdTextPaste").value != "true") {
var oSelElem1 =val ;
var pattern = /<a[^>]*>(.*?)<\/a>/gi
var code = oSelElem1.match(pattern);
if (code != null) {
for (i = 0; i < code.length; i++) {
var url = code[i].match(/href=\"(.*?)\"/)[1];
var text = code[i].match(/<a[^>]*>(.*?)<\/a>/)[1];
if (text.toLowerCase().search("<img") >= 0)
oSelElem1 = oSelElem1.replace(code[i], url);
else
oSelElem1 = oSelElem1.replace(code[i], text + ':' + url);
}
editor.pasteHtml(oSelElem1);
var plainText = editor.get_text();
editor.set_html("");
plainText = plainText.replace(/((\r\n|\r|\n)\s*)\2/g, "$2");
plainText = plainText.replace(/\t/g, ' ').replace(/ /g, ' ').replace(/\r\n|\n|\r/g, '<br />');
editor.set_html(plainText);
document.getElementById('<%= hdCampEditorTab2.ClientID %>').value = "1";
}
}
}
}
any idea?
Regards,
Anwar