I am using a radeditor in an application and we are just upgrading to a newer Telerik dll. I believe the dll that we were using prior was from Q3 of 2010 where the NewLineBr property was still in use. We are now trying to use the NewLineMode with the editor and then retrieve the html on the client using
radeditor.get_html(true)
The problem we are having is the text is coming back as if we were using the property NewLineMode="Br" instead of NewLineMode="P". When we use the escape sequence of ctrl + M, then the text that is returned is formatted as if we are using NewLineMode="P", but not when we just press the Enter key. Do we need to make additional changes to the RadEditor, or to some other setting to get the NewLineMode="P" functionality to work how we intend it to work?
Below is a simplified code snippet of the RadEditor we are using, I have removed the NewLineBr property and added the NewLineMode="P" property, but am not getting the expected results.
<telerik:RadEditor ID="Editor1" runat="server" EditModes="Design" Height="140px" NewLineMode="P"
. Font-Names="Arial" Font-Size="10pt" StripFormattingOptions="AllExceptNewLines" OnClientPasteHtml="OnEditorPasteHtml"
ConvertToXhtml="True" ToolbarMode="Default" >
Please let me know what additional changes may be needed.
Thank you for any help that you can offer and let me know if you have any questions.
Aaron
5 Answers, 1 is accepted
I am not aware of this issue and I was unable to replicate it as shown in the following video: http://screencast.com/t/PcNuhYeV32.
Could you please modify the attached project so that it demonstrates the reported problem and send it back for examination on our end?
Regards,
Rumen
the Telerik team
I believe that we found the solution to the original problem. We did not have the new RadEditor.js file loaded that we are referencing in our aspx page. Once we starting using the new file, the NewLineMode started to be applied correctly.
However, we have noticed that when we enter a line with a value, then 5 spaces, a value, then 5 more spaces and then one last value similar to:
1 Label 1
and then retrieve that with radeditor.get_html(true)
we are getting a result like this:
<p>1 Label 1</p>
Formerly, we would get
<p>1 Label 1</p>
Is there a certain change that we need to make in order to get the blank space " " to be returned instead of the non-breaking space " " I have tried to use false as the input parameter, but that did not make any difference to this issue.
Do i need to create a custom function to be added onclientload? Is there another parameter on the radeditor that needs to be changed that has been added? Please let me know if there are any questions.
Thanks again for your help.
Aaron
Second, my problem appears to be within this method:
Telerik.Web.UI.Editor.ConvertToXhtmlFilter.prototype = { getHtmlContent: function(b)
In the older file, when I pass in an object with the "1 Label 1" I get back the desired result of "1 Label 1".
But when I do this within the new file I get back the original with the four and then one space returned.
I believe I have the same properties set in both instances but am getting varied results.
Thanks again for any help.
Aaron
The problem stems from the change of the _appendTextNode function in the RadEditor.js
The old function looks like this:
_appendTextNode:
function(d, b) {
var a = String(d.nodeValue);
var c = d.parentNode.nodeName.toLowerCase();
if (!$telerik.isIE && (c == "style" || c == "script")) {
b.append(a);
}
else
{
a = a.replace(/\&/g,
"&").replace(/</g, "<").replace(/>/g, ">");
if ($telerik.isFirefox) {
a = a.replace(/[\u00a0]/g,
" ");
}
b.append(a);
}
}
The new file function is this:
_appendTextNode:function(a,d)
{
var b=String(a.nodeValue);
var c=a.parentNode.nodeName.toLowerCase();
if(!$telerik.isIE&&(c=="style"||c=="script"))
{
d.append(b);
}
else
{
b=b.replace(/\&/g,"&").replace(/</g,"<").replace(/>/g,">");
b=b.replace(/[\u00a0]/g," ");
d.append(b);
}
}
The difference being the b=b.replace(/[\u00a0]/g," "); taking the check for the firefix browser out. Our app is intended to only run in IE, so this caused the change.
We believe that was an intended change and we will have to adjust our code to be able to be compatible with this change.
Could someone tell me if this is indeed the intended change? And if so, what you would suggest in order to handle our need to use multiple spaces without changing them to
Thank you
Aaron
Yes, this change is intended. You can easily overwrite the _appendTextNode function:
<telerik:RadEditor ID="RadEditor1" Runat="server" NewLineMode="p"></telerik:RadEditor>
<script type="text/javascript">
Telerik.Web.UI.Editor.ConvertToXhtmlFilter.prototype._appendTextNode = function (node, sb) {
var stringToAppend = String(node.nodeValue);
var parentNodeName = node.parentNode.nodeName.toLowerCase();
if (!$telerik.isIE && (parentNodeName == "style" || parentNodeName == "script")) {
//should not escape inside style and script nodes
sb.append(stringToAppend);
}
else {
stringToAppend = stringToAppend.replace(/\&/g, "&").replace(/</g, "<").replace(/>/g, ">");
if ($telerik.isFirefox) {
stringToAppend = stringToAppend.replace(/[\u00a0]/g, " ");
}
sb.append(stringToAppend);
}
}
</script>
All the best,
Rumen
the Telerik team