This is a migrated thread and some comments may be shown as answers.

RadEditor not wrapping when using <pre> tag

4 Answers 160 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Yuvaraj
Top achievements
Rank 1
Yuvaraj asked on 30 Jul 2018, 05:30 AM
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.

4 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 30 Jul 2018, 10:38 AM
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.
0
Yuvaraj
Top achievements
Rank 1
answered on 30 Jul 2018, 11:04 AM

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.

 

0
Rumen
Telerik team
answered on 30 Jul 2018, 03:22 PM
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.
0
Yuvaraj
Top achievements
Rank 1
answered on 31 Jul 2018, 08:12 AM

Hi Rumen ,

 

Thanks a lot. It works perfect.

 

Tags
Editor
Asked by
Yuvaraj
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Yuvaraj
Top achievements
Rank 1
Share this question
or