Support forums
in

Pasting from Word

Last post 02-05-2013, 7:41 PM by astearns. 2 replies.
Sort Posts: Previous Next
  •  02-01-2013, 8:12 PM 76787

    Pasting from Word

    Recently purchased the editor and only have one issue:

     

    I was able to recreate on the demo.

    When pasting form word, paragraphs are pasted with <p>  tags. Is there a way to change this to <div> instead?

  •  02-04-2013, 10:08 AM 76790 in reply to 76787

    Re: Pasting from Word

    Hi astearns,

     

    You can catch the paste command, then replace the code to match your own requirement by API "RichTextEditor_OnPasteFilter".

     

    This event is raised before the data is pasted into RichTextEditor. It allows you intercept the paste function and filter the content being pasted. 

    Example:

    <script type='text/javascript'>
    function RichTextEditor_OnPasteFilter(editor,info)
    {
    	var html=info.Arguments[0];
    	var cmd=info.Arguments[1];
    	info.ReturnValue="<br/>You fire "+cmd+" to paste {<hr/>"+html+"<hr/>}.";
    }
    </script>
     

    Regards,

     

    Ken 

  •  02-05-2013, 7:41 PM 76802 in reply to 76790

    Re: Pasting from Word

    Hi Ken,

     

    thanks for the reply that accomplished what I wanted. Posting my solution here in case it is useful to anyone else:

     

    <script type='text/javascript'>
        function RichTextEditor_OnPasteFilter(editor, info) {
            var html = info.Arguments[0];
            var cmd = info.Arguments[1];
            html = html.replace(/<p>/g,"<div>");
            html = html.replace(/<\/p>/g,"</div>");
            info.ReturnValue = html;
        }
    </script>

    Out of curiosity, why isn't there a setting in config.js for this? It's not hard to change now that I know how but seems like it would be easier with a setting. 

     

    Thanks again! 

View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems