NewLineMode="P" is acting like NewLineMode="Br"

6 posts, 0 answers
  1. Aaron
    Aaron avatar
    24 posts
    Member since:
    Jan 2009

    Posted 07 May 2012 Link to this post

    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

  2. Rumen
    Admin
    Rumen avatar
    14417 posts

    Posted 10 May 2012 Link to this post

    Hi,

    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
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Aaron
    Aaron avatar
    24 posts
    Member since:
    Jan 2009

    Posted 14 May 2012 Link to this post

    Thanks for the Reply, Rumen.

    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&nbsp;&nbsp;&nbsp;&nbsp; Label&nbsp;&nbsp;&nbsp;&nbsp; 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 "&nbsp;"  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
  4. Aaron
    Aaron avatar
    24 posts
    Member since:
    Jan 2009

    Posted 15 May 2012 Link to this post

    Hi, just have a few findings.  First, it appears the client method get_html() in the RadEditor.js file now takes two parameters, but I can't find an explanation for the second parameter.  Could someone explain what that parameter's purpose is?  I don't believe that this really has anything to do with my issue, but would like to know what it does.

    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&nbsp;&nbsp;&nbsp;&nbsp; Label&nbsp;&nbsp;&nbsp;&nbsp; 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 &nbsp; 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

  5. Aaron
    Aaron avatar
    24 posts
    Member since:
    Jan 2009

    Posted 15 May 2012 Link to this post

    I believe that I have fixed our issues.

    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,

     

    "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");

     

     

     

            if ($telerik.isFirefox) {

     

                a = a.replace(/[\u00a0]/g,

     

    "&nbsp;");

     

            } 
            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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");               
                      b=b.replace(/[\u00a0]/g,"&nbsp;");      
                      d.append(b);

              }
    }


    The difference being the b=b.replace(/[\u00a0]/g,"&nbsp;"); 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 &nbsp;  

    Thank you

    Aaron
  6. Rumen
    Admin
    Rumen avatar
    14417 posts

    Posted 17 May 2012 Link to this post

    Hi,

    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, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
                if ($telerik.isFirefox) {
                    stringToAppend = stringToAppend.replace(/[\u00a0]/g, "&nbsp;");
                }
                sb.append(stringToAppend);
            }
        }
    </script>

    All the best,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top