Paste Plain Text Always

2 posts, 1 answers
  1. Eli
    Eli avatar
    11 posts
    Member since:
    Mar 2011

    Posted 12 Dec 2014 Link to this post

    How would I get pasted content into the RadEditor to always "Paste Plain Text".  I want the exact same thing to happen as when I right click and select "Paste Plain Text"

    I am unable to find the right StripFormattingOptions to simulate it exactly.  Removing all Word Content leaves other HTML and <p> tags.  If I remove "AllExceptNewLines" it puts a double space (two BR tags) every place there should only be a singe space.

    When I right click and choose Paste Plain Text it correctly puts a single <br /> tag after each line. 

    I attached #1 the original (email in this case).  #2 I attached the way the content looks using right click "Paste Plain Text" and #3 I attached what it looks like when removing "AllExceptNewLines"
  2. Answer
    Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 15 Dec 2014 Link to this post

    Hi Eli,

    The described issue is logged as a bug. You can follow the progress of the task with this feedback portal item.

    You can workaround this by manipulating the content that is pasted via the OnClientPasteHtml event:
    <telerik:RadEditor runat="server" ID="RadEditor1"
        OnClientPasteHtml="OnClientPasteHtml"
        StripFormattingOptions="AllExceptNewLines">
    </telerik:RadEditor>
     
    <script type="text/javascript">
        function OnClientPasteHtml(editor, args) {
            var commandName = args.get_commandName();
            var contentToPaste = args.get_value();
     
            if (commandName === "Paste") {
                contentToPaste = contentToPaste.replace(/(<br\/>)+/gi, "<br/>");
     
                args.set_value(contentToPaste);
            }
        }
    </script>


    Regards,
    Ianko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top