tiny_mce.rhtml
1.74 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<%= javascript_include_tag 'tinymce/jscripts/tiny_mce/tiny_mce.js' %>
<script type="text/javascript">
var myplugins = "searchreplace,print,media,table";
if (tinymce.isIE) {
// the paste plugin is only useful in Internet Explorer
myplugins = "paste," + myplugins;
}
tinyMCE.init({
mode : "textareas",
theme : "advanced",
relative_urls : false,
remove_script_host : true,
document_base_url : <%= environment.top_url.to_json %>,
plugins: myplugins,
theme_advanced_toolbar_location : "top",
theme_advanced_layout_manager: 'SimpleLayout',
theme_advanced_buttons1 : "print,separator,copy,paste,separator,undo,redo,separator,search,replace,separator,fontsizeselect,formatselect",
theme_advanced_buttons2 : "bold,italic,underline,strikethrough,separator,bullist,numlist,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,link,unlink,image,table,separator,cleanup,code",
theme_advanced_buttons3 : "",
theme_advanced_blockformats :"p,address,pre,h2,h3,h4,h5,h6",
paste_auto_cleanup_on_paste : true,
paste_insert_word_content_callback : "convertWord",
paste_use_dialog: false,
apply_source_formatting : true,
content_css: '/stylesheets/tinymce.css',
language: <%= tinymce_language.inspect %>
});
function convertWord(type, content) {
switch (type) {
// Gets executed before the built in logic performes it's cleanups
case "before":
//content = content.toLowerCase(); // Some dummy logic
break;
// Gets executed after the built in logic performes it's cleanups
case "after":
content = content.replace(/<!--\s*-->/, '');
break;
}
return content;
}
</script>