Issues with Pasting

4 posts, 0 answers
  1. Jason
    Jason avatar
    9 posts
    Member since:
    May 2012

    Posted 13 Nov 2012 Link to this post

    The Goal:
    I would like for CTRL+V to paste a "PasteFromWordNoFontsNoSizes" action without going through the pop-up window when in a non IE browser.

    The Code:
    <tool name="PasteFromWordNoFontsNoSizes" shortcut="CTRL+V" />

    When I test your demo product page, I notice that I am able to do the following:
    1. I can paste using CTRL+V, this doesn't require the pop-up, in all major browsers.
    2. I can paste both normal, and plain text using the built in browser options by right-click (no pop-up).
    3. If I use the action menu items in the toolbar, I am forced to use the pop-up.

    I'm wondering, since I can paste normally using Chrome/Safari/FF on your demo, can we apply content stripping automatically at this level?

    What I have tried:
    I tried to only reference the "PasteFromWordNoFontsNoSizes" action in the contextMenu, and not in the toolbar.

    <ContextMenu forElement="*">
          <tool name="PasteFromWordNoFontsNoSizes" shortcut="CTRL+V" />
    </ContextMenu>

    This results in the following:

    1. Chrome: I cannot paste using CTRL+V at all.
    2. FireFox: I can paste using CTRL+V, but it's treating it like a normal PASTE action, font formatting is not getting striped.
    3. IE: I can paste using CTRL+V and it works as anticipated.

    Bottom line:

    Is there anyway I can allow paste through CTRL+V that will strip formatting like "PasteFromWordNoFontsNoSizes" without using a pop-up to do so?

  2. Jason
    Jason avatar
    9 posts
    Member since:
    May 2012

    Posted 13 Nov 2012 Link to this post

    More things tried:

    I added the following code to the page to attempt to strip things during the paste:

    <telerik:CmsRadEditor runat="server" ID="RadEditor1"
    StripFormattingOptions
    ="MSWord,Css,Font,Span,ConvertWordLists">

    Then, I changed the toolsfile.xml to the following:

    <tool name="Paste" shortcut="CTRL+V" />

    This actually works really well. However, I cannot get Chrome to Paste at all. neither the icon, nor the CTRL=V seems to work in Chrome. I won't prompt a pop-up to paste, or do anything actually. This is strange because I CAN paste in Chrome on your demo product page... any thoughts?

    Is there anyway I can set Chrome to have a different CTRL=V shortcut than the other browsers? Or some other solution?
  3. Cheri Verdend
    Cheri Verdend avatar
    24 posts
    Member since:
    Apr 2004

    Posted 15 Nov 2012 Link to this post

    I have a related issue and question.

    I have StripFormattingOptions="MSWordRemoveall,Css,Font,Span" on my radEditor. Most of the time that successfully strips all Word formatting. But once a month or so I find a record in my database with  class="msonormal" or other Word formatting tags. Although I haven't been able to replicate the conditions where the StripFormatting fails, and I don't have a way of tracking which user pasted the content, I assume there must be a loophole (a particular browser/OS combination, or keyboard shortcut) that effectively bypasses the StripFormatting action. Do you have any ideas of how this could happen, and is there a workaround?

    I've considered stripping the Word formatting on Submit. Unfortunately my users would not see the format changes before being redirected elsewhere after the Submit. So that won't work. Is there a way to check for Word formatting on Submit, and if detected, to abort the Submit and alert the user to apply the manual format stripper before re-submitting the page?

  4. Rumen
    Admin
    Rumen avatar
    14009 posts

    Posted 16 Nov 2012 Link to this post

    Hi,

    The onpaste event is not supported by the oldest Chrome/Safari/Firefox versions and the StripFormattingOptions property cannot work in them, because they do not offer an event to capture the pasted content and strip it.

    That is why we have provided the ability to strip the formatting on submit as shown in this article: Cleaning Word Formatting On Page Load And On Submit.

    I am also not sure why StripFormattingOptions is not working in your local project but is working in the live demos, but this is the way to strip the formatting on paste without showing a Paste Strip dialog. You can inspect your page for JavaScript errors and double check whether you have set the property correctly and it settings are working in the different browsers. If you would like you can open a support ticket and provide a simple working project where the problem is reproducible and I will debug it.

    Best 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.
Back to Top