Chrome, Safari: copy \ paste text from editor to editor add some strange formatting

2 posts, 0 answers
  1. mizery
    mizery avatar
    1 posts
    Member since:
    Jan 2010

    Posted 25 Oct 2011 Link to this post

    Hello,

    We found some strange problem with copy \ paste functionality which can be reproduced on your demo in Chrome and Safari browsers.

    Steps to reproduce:
    1. Open editor in Chrome.
    2. Write some text like "Test copy paste".
    3. Copy this text (you can use Ctrl+C or browser Copy).
    4. Paste this text in to editor. Text is paste with some additional formatting like:

    <div style="padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-image: none; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; text-align: left; word-wrap: break-word;">Test copy paste</div>

    Could this problem be resolved in some way? Because we support these browsers and our users can do very often such actions.

    I used Google Chrome 14.0 to reproduce this bug.

    Kind regards,
    Anna
  2. Rumen
    Admin
    Rumen avatar
    14359 posts

    Posted 25 Oct 2011 Link to this post

    Hi Anna,

    The reported problem is a browser behavior. The content area is a standard editable IFRAME element and the copy process is controlled by the browser and operating system. I was able to reproduce the same problem with an HTML page and editable IFRAME as well as with our competitors' editors.

    The process when copying content from RadEditor and pasting it again in it can be controlled using the OnClientPasteHtml event of the control. Here is an example:

    The OnClientPasteHtml event is also fired when the Paste (Ctrl+V) command is executed. It is useful in scenarios when the pasted content should be modified and inserted in the content area:

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

    if (commandName == "Paste")
    {
    //strip here the unwanted tags and formatting and paste the modified content
    var newContent = value;
    args.set_value(newContent); //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.

    However, it is not possible to control the paste process in MS Word, because this program does not offer API for handling the paste process.



    Greetings,
    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
Back to Top