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

All URLs when copied in the design view become fully qualitfied

1 Answer 42 Views
Editor
This is a migrated thread and some comments may be shown as answers.
mkerchenski
Top achievements
Rank 1
mkerchenski asked on 21 Nov 2012, 02:37 PM

All URLs when copied in the design view of the RadEditor become fully qualified. This happens in IE, Chrome, and Firefox. 


Steps to reproduce:

 

  1. In design view, copy existing link.
  2. Paste that link in design view


I was able to reproduce this on your demo page http://demos.telerik.com/aspnet-ajax/editor/examples/overview/defaultcs.aspx

 

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 21 Nov 2012, 04:16 PM
Hello,

I am aware of this browser behavior and it is described in the description of the following live demo: OnClientPasteHtml. When copying and pasting a link or an image with a relative path in Internet Explorer, the browser automatically converts the path to absolute. The code below demonstrates how to attach to the OnClientPasteHtml event and strip the desired url path using the StripPathFilter content filter. The StripPathsFilter() method receives as a parameter an array of strings (devided by a white space) that will be stripped from the absolute path.

<script type="text/javascript">
function OnClientPasteHtml(sender, args)
{
var commandName = args.get_commandName();
var value = args.get_value();

if (commandName == "Paste")
{
// The StripPathsFilter() method receives as a parameter an array of strings (devided by a white space) that will be stripped from the absolute links.
var domainName = "http://" + window.location.host; //returns the hostname and port number of the current URL
var filter = new Telerik.Web.UI.Editor.StripPathsFilter([domainName]); //strip the domain name from the absolute path

var contentElement = document.createElement("SPAN");
contentElement.innerHTML = value;
var newElement = filter.getHtmlContent(contentElement);
alert(newElement.outerHTML);
args.set_value(newElement.outerHTML); //set the modified pasted content in the editor
}
}
</script>

Please, note that the OnClientPasteHtml event fires the Paste command only when the StripFormattingOnPaste property is not set to "NoneSupressCleanMessage". In this case the editor does not process the pasted content and pastes it without modifications.



Kind 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.
Tags
Editor
Asked by
mkerchenski
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or