How to make tinymce paste in plain text by default

How to make tinymce paste in plain text by default

Googled it thousands of times, No one gives a complete solution of how to make Tinymce paste in plain text by default and strip out any formatting without clicking the “paste as text” button.
Any Ideas of how to implement that? or how to enable the “paste as text” button automatically?
Thank you

Solutions/Answers:

Solution 1:

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.

Solution 2:

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
});

Solution 3:

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;
    });
  }
....
})

Solution 4:

Just ran into this one myself and discovered that as of TinyMCE 3.4.2 you can simply:

paste_text_sticky: true,
paste_text_sticky_default: true

…which was nice.

Solution 5:

I think the easiest way would be this:

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

Solution 6:

Isn’t it better to use:

var ed = tinyMCE.activeEditor;

instead of:

var ed = tinyMCE.get('elm1');