RadEditor not wrapping when using <pre> tag

5 posts, 0 answers
  1. Yuvaraj
    Yuvaraj avatar
    3 posts
    Member since:
    Jun 2017

    Posted 30 Jul 2018 Link to this post

    We intially had textarea being used in our application. When we changed to RadEditor, all our old records did not apply line breaks, since there were no <br> tags. They had new line characters. So I am using <pre> tag inside RadEditor to display them in next line. But now there is an issue while we copy and paste text from an editor. The text wrapping does not occur and we get horizontal scroll. Need help to wrap the text.
  2. Rumen
    Admin
    Rumen avatar
    14100 posts

    Posted 30 Jul 2018 Link to this post

    Hi Yuvaraj,

    The content area of RadEditor is an editable iframe/div element with applied contenteditable="true" and the copy and paste operation is handled by the browser. 

    Can you explain where do you paste the copied from RadEditor content: in RadEditor again, in a textarea, in MS Word, in another editable element or in other location?


    What you can try is to not wrap the original content in <pre> tags, but to replace the line feeds with <br> symbols prior loading the content in RadEditor:

    RadEditor1.Content = contentToBeLoaded.Replace(System.Environment.NewLine, "<br>");

    You can find more information at https://stackoverflow.com/questions/4611591/code-vs-pre-vs-samp-for-inline-and-block-code-snippets.

    Best regards,
    Rumen
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Yuvaraj
    Yuvaraj avatar
    3 posts
    Member since:
    Jun 2017

    Posted 30 Jul 2018 in reply to Rumen Link to this post

    Hi Rumen ,

    My end users are doing the copy paste operation. They could copy from anywhere, it could be notepad, notepad++, word ....

    Also I will not be able wrap original content. They consist of many paragraphs which were entered in a textarea, which I had earlier. The next line in textarea will not <br> tag, but it will be a next line character saved in db. There are several thousands of records entered, so I wont be able to modify them manually.

     

  4. Rumen
    Admin
    Rumen avatar
    14100 posts

    Posted 30 Jul 2018 Link to this post

    Hello,

    You can wrap the pre tag with the following CSS class as instructed in StackOverflow

    <style>
        pre {
        white-space: pre-wrap;       /* Since CSS 2.1 */
        white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
        white-space: -pre-wrap;      /* Opera 4-6 */
        white-space: -o-pre-wrap;    /* Opera 7 */
        word-wrap: break-word;       /* Internet Explorer 5.5+ */
        }
    </style>
    <pre>dasddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd</pre>

    To apply this class to the Content area of RadEditor set the CssFiles property to point to a CSS file and set the above class in the file. For more information see this article: External CSS Files and Customize Content Area.

    Kind regards,
    Rumen
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  5. Yuvaraj
    Yuvaraj avatar
    3 posts
    Member since:
    Jun 2017

    Posted 31 Jul 2018 in reply to Rumen Link to this post

    Hi Rumen ,

     

    Thanks a lot. It works perfect.

     

Back to Top