views:

846

answers:

1

I need to cleanup the HTML of pasted text into TinyMCE by passing it to a webservice and then getting it back into the textarea. So I need to override the Ctrl+V in TinyMCE to caputre the text, do a background request, and on return continue with whatever the paste handler was for TinyMCE. First off, where is TinyMCE's Ctrl+V handler, and is there a non-destructive way to override it? (instead of changing the source code)

+2  A: 

You could write a plug-in that handles the ctrl+v event and passes it through or modify the paste plug-in. The following code is found at plugins/paste/editor_plugin.js and it handles the ctrl+v event.

  handleEvent : function(e) {
          // Force paste dialog if non IE browser
          if (!tinyMCE.isRealIE && tinyMCE.getParam("paste_auto_cleanup_on_paste", false) && e.ctrlKey && e.keyCode == 86 && e.type == "keydown") {
             window.setTimeout('tinyMCE.selectedInstance.execCommand("mcePasteText",true)', 1);
             return tinyMCE.cancelEvent(e);
          }

          return true;
       },

Here is some more information about creating plug-ins for tinyMCE.

Aleksi