Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
580
Catching paste events?
posted

I'd like to write some code that, when a user tries to paste something into the HTML editor, it cleans up the text that is pasted in.  You know, like if they are pasting something they copied from Word or another web page, I want to remove a lot of the junk formatting that is in the paste.  Kinda like what the Paste from Word icon does, but I want to capture a right-click Paste or a control-V.

 

  • 24497
    posted

    Hi,

    WebHtmlEditor does not process those events. The best I can do is give you information about some internal functionality which may help you. To process Ctrl+V you may use something like below. For paste from mouse or other events you may do similar.

    <script type="text/javascript">
    function editorKey(evt)
    {
     
    if(evt.keyCode == 86 && evt.ctrlKey)
       alert(
    'paste');
    }
     

    var edit = iged_getById('WebHtmlEditor1');
    var elem = edit._elem;
    if(elem.contentWindow)
      elem = elem.contentWindow.document;
    edit._addLsnr(elem,
    "keydown", editorKey);
    </script>