Plain text with line feeds issue

Last post 06-10-2008, 9:28 AM by beckie. 7 replies.
Sort Posts: Previous Next
  •  04-09-2006, 1:43 PM 18031

    Plain text with line feeds issue

    Hi,
     
    The Editor1.PlainTextWithLineFeeds returns line feeds as
     
    <br>&nbsp;
     
    together with a trailing space character. This is causing problems when trying to use Cute Editor to lay out plain text documents such as for email systems. The idea of plain text with a line feed is great, but why does it have to have '&nbsp;' together with a trailing space?
     
    The line feeds property ought to just deliver either <br> on it's own, or, because it IS meant to be plain text, simply a newline, thus: \n
     
    Can you please help with this? At the end of the day, I just want users to be able to lay out a document in plain text format for email systems, which means stripping the body of HTML and swapping new lines with '\n'.
     
    Many thanks
    Gerardicus
  •  04-10-2006, 3:49 AM 18043 in reply to 18031

    Re: Plain text with line feeds issue

    Gerardicus,
     
    Thanks for the nice suggestions.
     
    I will put some thoughts on this issue.
     
    For the time being you can use the following temp workaround:
     
    //Retrieves the CuteEditor HTML content in plain text format
    string plainText= Editor1.PlainTextWithLinefeeds;
     
    //Replace all <br>s to \n
    plainText = plainText.Replace("<br>","\n");
     
     
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  04-10-2006, 4:02 AM 18046 in reply to 18043

    Re: Plain text with line feeds issue

    Hi Adam,
     
    thanks for the reply. In the mean time, I've used the following to remove any extra html not wanted:

    string
    plainbody = Editor1.PlainTextWithLinefeeds;
    string stripped = plainbody.Replace("<br> &nbsp;", "<br>");
    stripped = stripped.Replace(
    " &nbsp;", "");
    stripped = stripped.Replace(
    "&nbsp; ", "");
    stripped = stripped.Replace(
    "&nbsp;", "");
    stripped = stripped.Replace(
    "<br> ", "<br>");
    stripped = stripped.Replace(
    "<p> ", "<br><br>");
    stripped = stripped.Replace(
    "<p>", "<br><br>");
    stripped = stripped.Replace(
    "<br>", "\r\n");
     
    I did some testing to see just what was returned using PlainTextWithLineFeeds and found that the above seems to get rid of all unwanted html and leave only '\r\n' for line feeds.
     
    Of course, when I load the body from the database, for editing in Cute, I need to replace all '\r\n' with '<br>' again so that is shows properly in Cute.
     
    Regards
    Gerardicus
  •  04-10-2006, 4:25 AM 18047 in reply to 18046

    Re: Plain text with line feeds issue

    Actually,
     
    the best idea would be to have a plain old multi-line text box replace the HTML editor window for plain text editing, but still enabling some of the editor features such as Code Snippets to work with the plain text box. Then no conversion of text would have to take place at all.
     
    Gerardicus
  •  04-26-2006, 11:47 PM 18514 in reply to 18046

    Re: Plain text with line feeds issue

    I have been using this fix and very happy with it.
    The thing is, we deal with foreign text as well and I wonder about translating all the escaped chars back to unicode chars. So I am working on this one to see if I can get anywhere.
  •  06-04-2008, 7:51 PM 41131 in reply to 18043

    Re: Plain text with line feeds issue


    //Retrieves the CuteEditor HTML content in plain text format
    string plainText= Editor1.PlainTextWithLinefeeds;
     
    Is there any way to do this on the JavaScript side?  I need to extract the plain text with linefeeds before the form is submitted.
     
    Thanks
     
  •  06-06-2008, 1:07 PM 41212 in reply to 41131

    Re: Plain text with line feeds issue

    Use the following code:
     
    // get the editor client ID
    var editor1=document.getElementById('<%=Editor1.ClientID%>');
     
     //Get the editor content
    var editdoc=editor1.GetDocument();
    alert(innerText(editdoc.body));
    function innerText(elm){ if(document.all) { return elm.innerText; } else { return elm.textContent; } }

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  06-10-2008, 9:28 AM 41289 in reply to 41212

    Re: Plain text with line feeds issue

    Thanks Adam.  That gives me exactly what I want.
View as RSS news feed in XML