How to make tinymce paste in plain text by default How to make tinymce paste in plain text by default javascript javascript

How to make tinymce paste in plain text by default


For the tinyMCE 3X or 4X things have change a little.now you can do this and it works fine.

tinymce.init({    plugins: "paste",    paste_as_text: true});


I have solved this problem with this code

tinyMCE.init({...plugins : "paste",paste_text_sticky : true,setup : function(ed) {    ed.onInit.add(function(ed) {      ed.pasteAsPlainText = true;    });  }....})


EDIT: this solution is for version 3.x, for 4.x version read the answer from @Paulo Neves

The problem is that Paste plugin automatically resets plain text paste on every paste. So all we need to do - set it back. The following code should help.

tinyMCE.init({...oninit : "setPlainText",plugins : "paste"....});

The definition of setPlainText

 function setPlainText() {        var ed = tinyMCE.get('elm1');        ed.pasteAsPlainText = true;          //adding handlers crossbrowser        if (tinymce.isOpera || /Firefox\/2/.test(navigator.userAgent)) {            ed.onKeyDown.add(function (ed, e) {                if (((tinymce.isMac ? e.metaKey : e.ctrlKey) && e.keyCode == 86) || (e.shiftKey && e.keyCode == 45))                    ed.pasteAsPlainText = true;            });        } else {                        ed.onPaste.addToTop(function (ed, e) {                ed.pasteAsPlainText = true;            });        }    }

So now it always will be plain.