executing code after paste from word

Last post 02-28-2012, 6:32 AM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  02-27-2012, 9:24 AM 73211

    executing code after paste from word

    Hi,
     
    Is it possible to execute the 'clean code' function after a paste from word?
    'The remove MS WORd format' button should be automaticly be executed after the paste.
    It would be possible to regsiter a custom button including the 'paste' and 'clean code' functions, but:
    How do I catch the 'CTRL-V' command. Because that is what a lot of people are using.
    Would it be possible to execute code after any paste command?
     
    thx 
  •  02-28-2012, 6:32 AM 73237 in reply to 73211

    Re: executing code after paste from word

    Hi dbots,
     
    How to execute code after paste command
     
    <%@ Page Language="C#" %>
    <%@ Register Namespace="CuteEditor" Assembly="CuteEditor" TagPrefix="CE" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>example</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <CE:Editor ID="Editor1" runat="server">
                </CE:Editor>
            </div>
        </form>
    </body>
    </html>
    <script>
    function CuteEditor_OnCommand(editor,command,ui,value)
     {
         //Paste
         //PasteText
         //PasteWord
         //PasteAsHTML
        if(command=="PasteWord")
        {
            //execute your own code
        }
    }
    </script>
     
     
    How to catch hot key Ctrl + V
     
    <%@ Page Language="C#" %>
    <%@ Register Namespace="CuteEditor" Assembly="CuteEditor" TagPrefix="CE" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>example</title>
    </head>
    <script runat="server">
        protected override void OnLoad(EventArgs e)
        {
            Editor1.Text = "use hot key ctrl+v";
            base.OnLoad(e);
        }
    </script>
    <body>
        <form id="form1" runat="server">
            <CE:Editor ID="Editor1" runat="server">
            </CE:Editor>
            <p>Try hot key Ctrl + V</p>
         </form>
    </body>
    </html>
    <script>
    function CuteEditor_OnInitialized(editor) {
        var editwin = editor.GetWindow();
        var editdoc = editor.GetDocument();
        function forFirefox(oEvent) {
            if (oEvent.ctrlKey && oEvent.keyCode == 86) {
                alert("ctrl + v");
            }
        }
        if (window.attachEvent) {
            editdoc.onkeydown = function () {
                if (editwin.event.ctrlKey && editwin.event.keyCode == 86) {
                    alert("ctrl + v");
                }
           }
        }
        else if (window.addEventListener) {
            editdoc.addEventListener("keydown", forFirefox, false)
        }
    }
    </script>
     
    Regards,
     
    Ken 
View as RSS news feed in XML