Problème when pasting from msword

4 posts, 0 answers
  1. ericc34
    ericc34 avatar
    91 posts
    Member since:
    Jul 2006

    Posted 31 Oct 2011 Link to this post

    Here's my big problem

    I paste this msword content to radeditor

    Test de formulaire

    Avec du rouge

    Du bleu

    Et du vert

    User highlight Test de formulaire and click custom button with this code :

    var selection = String(editor.getSelectionHtml());

                    //selection = selection.replace("<q>", "");
                    //selection = selection.replace("</q>", "");
                    //selection = selection.replace("<Q>", "");
                    //selection = selection.replace("</Q>", "");

                    //Remove all custom tags before insert new custom tags
                    var html = editor.get_html(false);
                    html = html.replace("<q>", "");
                    html = html.replace("</q>", "");
                    html = html.replace("<Q>", "");
                    html = html.replace("</Q>", "");

                    var newhtml = html.replace(selectedText, '<q>' + selectedText + '</q>');
                    //var newhtml = html.replace(selection, '<q>' + selection + '</q>');
                    editor.set_html(newhtml);

                    //Set schedule text
                    var txtScheduleText = $find("<%=txtScheduleText.ClientID%>");
                    txtScheduleText.set_mode(4);
                    txtScheduleText.set_html(selection);
                    txtScheduleText.set_mode(4);

    This code must replace selectedhtml text like this : <FONT size=3 face=calibri>Ceci est un test</FONT>  by <q><FONT size=3 face=calibri>Ceci est un test</FONT></q>

    The problem is that when i call var newhtml = html.replace(selection, '<q>' + selection + '</q>'); selection not exist in html because html look like this with msword special tag :

    <FONT face=georgia>

    <P style="MARGIN: 0cm 0cm 10pt" class=MsoNormal><FONT size=3 face=calibri>Ceci est un test<?xml:namespace prefix = o /><o:p></o:p></FONT></P>

    <P style="MARGIN: 0cm 0cm 10pt" class=MsoNormal><FONT color=#ff0000 size=3 face=calibri>En rouge<o:p></o:p></FONT></P>

    <P style="MARGIN: 0cm 0cm 10pt" class=MsoNormal><FONT color=#00b0f0 size=3 face=calibri>En bleu<o:p></o:p></FONT></P>

    <P style="MARGIN: 0cm 0cm 10pt" class=MsoNormal><FONT color=#00b050 size=3 face=calibri>En vert<o:p></o:p></FONT></P></FONT>

    Do you have a valid solution to replace my html selection ?

     

     

     

  2. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 01 Nov 2011 Link to this post

    Hello Ericc34,

    You can strip the Word formatting by setting the StripFormattingOptions property to "MSWord" and once the content is cleaned to replace the desired tags.

    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
  4. ericc34
    ericc34 avatar
    91 posts
    Member since:
    Jul 2006

    Posted 01 Nov 2011 Link to this post

    I'll try this and this dont't work

    Can you send me a sample of it using my code ?
  5. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 01 Nov 2011 Link to this post

    Please test the following demo: Cleaning Word Formatting.

    If you are able to replicate the issue when the radio button option is enabled than the problem is most likely due to that the "Allow Programmatic Clipboard access" setting of your IE browser is disabled.
    If this feature is disabled it is not possible to access the clipboard content and modify the pasted content. In such case you can enable the "Allow Programmatic Clipboard access" option or if this is not allowed to strip the content when submitting the content: Cleaning Word Formatting On Page Load And On Submit and replace the special tags on the server using the String.Replace method.


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