Formatting - Pasting From Word

7 posts, 0 answers
  1. Chris
    Chris avatar
    10 posts
    Member since:
    Jan 2012

    Posted 07 Feb 2012 Link to this post

    I have several people that do pasting from Word in to RadEditors. When they do, they get a dialog box:

    The content you are trying to paste has MS Word formatting.Would you like to clean it?

    They are given two options, which are OK and Cancel. When you click OK, everything's fine. When you click cancel, text still pastes in. I assume that this is because Cancel in this case means "no, I do not want to clean it, just paste it in." Am I correct?

    If so, here's the real issue: we do not want people to able to bypass this cleaning (basically, force them to click OK every time). I assume it's possible to force it with Javascript, but I need to know which event is fired in this case. Is it OnClientPasteHtml? (http://www.telerik.com/help/aspnet-ajax/editor-onclientpastehtml.html)

    Thanks,
    Chris Aumiller
  2. Richard
    Richard avatar
    479 posts
    Member since:
    Nov 2011

    Posted 09 Feb 2012 Link to this post

    Chris:

    You can mandate the behavior of RadEditor by manipulating the settings of the StripFormattingOnPaste property declaritively.

    If you set StripFormattingOnPaste="MSWordRemoveAll" the popup is bypassed and all Word formatting is stripped.

    The online demo: Editor/Cleaning Word Formatting demonstrates all of the options that can be set in the RadEditor to customize behavior.

    Cheers!
  3. Chris
    Chris avatar
    10 posts
    Member since:
    Jan 2012

    Posted 09 Feb 2012 Link to this post

    If I've been reading this right, though, not all browsers support the OnPaste event that triggers it. Am I correct?

    Thanks,
    Chris
  4. Richard
    Richard avatar
    479 posts
    Member since:
    Nov 2011

    Posted 09 Feb 2012 Link to this post

    Chris:

    I believe that there is cross-browser support for the OnPaste event, but it is handled differently by browsers. See the onpaste event | paste event reference article for insights.

    The alternative approach is defined in the above mentioned Editor/Cleaning Word Formatting demo:

    Formatting can also be stripped automatically on page submit for browsers that do not provide onpaste event using the OnClientSubmit event and FormatStripper command of RadEditor, e.g.

    <script type="text/javascript">
    function OnClientSubmit(editor)
    {
    editor.fire("FormatStripper", {value : "WORD"});
    }
    </script>
    <telerik:RadEditor runat="server" OnClientSubmit="OnClientSubmit"/>

    Cheers!
  5. Rumen
    Admin
    Rumen avatar
    14351 posts

    Posted 14 Feb 2012 Link to this post

    Hi,

    Indeed, Opera still does not offer onpaste event and for this reason the StripFormattingOptions does not function under it. You can instruct your clients to use the Paste from Word dialog to strip the formatting and / or strip the content on submit.

    Best regards,
    Rumen
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  6. Naga
    Naga avatar
    2 posts
    Member since:
    Sep 2009

    Posted 23 Sep 2013 Link to this post

    pasting from word, it will ask message : The content you are trying to paste has MS Word formatting.Would you like to clean it ?

    If I click on ok, I want to be clear all styles from Word,
    If I click on cancle, it will paste as it is from word.


    please let me know how can we solve this problem while pasting the text from MS word.

    Thanks,
    Naga. 
  7. Marin Bratanov
    Admin
    Marin Bratanov avatar
    5428 posts

    Posted 25 Sep 2013 Link to this post

    Hi Naga,

    This is not a problem, but the expected behavior. You can read my detailed explanation on the case here: http://www.telerik.com/community/forums/aspnet-ajax/editor/problem-with-rad-editor-on-paste-to-keep-ms-word-formatting.aspx#2802202.


    Regards,
    Marin Bratanov
    Telerik
    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 the blog feed now.
Back to Top