All URLs when copied in the design view become fully qualitfied

2 posts, 0 answers
  1. mkerchenski
    mkerchenski avatar
    8 posts
    Member since:
    Jun 2012

    Posted 21 Nov 2012 Link to this post


    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

     

  2. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 21 Nov 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top