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

Paragraphs are turned into line breaks when using Paste Plain Text in RadEditor

1 Answer 84 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Judy.Wang
Top achievements
Rank 1
Veteran
Judy.Wang asked on 26 Feb 2021, 09:14 PM

Hi Telerik Team,

we are experience an issue which happens on Telerik demo site too, is there any way we can fix it?

 

Steps to Reproduce :

1. go to link https://demos.telerik.com/aspnet-ajax/editor/examples/overview/defaultcs.aspx

2. Highlight and copy some HTML( you can copy html bottom of the page )
3. Use Paste as Plain Text to paste your content.

4. check RadEditor html, <p> has been replaced by <br/>

 

you can check the detailed info in the attachment too,

 

Thanks,

Lan

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 01 Mar 2021, 03:58 PM

Hi Judy,

The reported behavior is the intended and expected behavior by design. Here is the code responsible for the PastePlainText functionality:

	//Paste with Stripping
	Telerik.Web.UI.Editor.CommandList.PastePlainText = function(commandName, editor, commandArgs) {
		var cleanAndPaste = function(content) {
			if (content) {
				var plainText = content.replace(/\&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
				plainText = utils.replaceNewLineWithBr(plainText);
				if (plainText) editor.pasteHtml(plainText, commandName);
			}
		};

var browser = Telerik.Web.Browser;

	var utils = $E.Utils = 
		replaceNewLineWithBr: function (textData)
		{
			try
			{
				textData = textData.replace(/\n/g, "<br>");
				return textData;
			}
			catch (exc) { }
		},

The case is also discussed in the following forum https://www.telerik.com/forums/pasting-plain-text-as-paragraphs-in-lt-p-gt-tags-rather-than-with-lt-br-gt-tags

 

Regards,
Rumen
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Editor
Asked by
Judy.Wang
Top achievements
Rank 1
Veteran
Answers by
Rumen
Telerik team
Share this question
or