TinyMCE: Simple config AND stripping formatting upon paste

Just a quick post to share my configuration options to get TinyMCE looking simple as possible for those times you don’t need 4 whole toolbars worth of buttons. This will also strip all formatting when there is content/images trying to be pasted into the text area. If you don’t care about stripping formatting, then only copy all the ‘theme_advanced_…’ and ‘theme : “advanced”‘ options into your init.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$('textarea.tinymce').tinymce({
// Location of TinyMCE script
script_url : 'tiny_mce/tiny_mce.js',

// General options
theme : "advanced",
plugins : "paste",

paste_auto_cleanup_on_paste : true,
paste_remove_styles: true,
paste_remove_styles_if_webkit: true,
paste_strip_class_attributes: true,

setup : function(ed) {
ed.onInit.add(function(ed) {
ed.pasteAsPlainText = true;
});
},

// Theme options
theme_advanced_buttons1 : "bold,italic,underline,bullist,undo,redo",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_buttons4 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",

theme_advanced_statusbar_location : "none"
});

Here’s what it’ll look like:

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.