Commit 3cf704aee6474c85c4847e39bc30bf68053a4980
Committed by
Antonio Terceiro
1 parent
dd161fc1
Exists in
master
and in
29 other branches
ActionItem925: enhancements to the text editor
Showing
3 changed files
with
30 additions
and
7 deletions
Show diff stats
app/helpers/language_helper.rb
app/views/shared/tiny_mce.rhtml
1 | -<%= javascript_include_tag 'tiny_mce/tiny_mce.js' %> | |
1 | +<%= javascript_include_tag 'tinymce/jscripts/tiny_mce/tiny_mce.js' %> | |
2 | 2 | <script type="text/javascript"> |
3 | 3 | tinyMCE.init({ |
4 | 4 | mode : "textareas", |
5 | 5 | theme : "advanced", |
6 | - plugins: "paste,searchreplace,print", | |
6 | + plugins: "paste,searchreplace,print,media", | |
7 | 7 | theme_advanced_toolbar_location : "top", |
8 | 8 | theme_advanced_layout_manager: 'SimpleLayout', |
9 | - theme_advanced_buttons1 : "print,separator,copy,paste,pastetext,pasteword,separator,undo,redo,separator,search,replace,separator,formatselect,separator,help", | |
9 | + theme_advanced_buttons1 : "print,separator,copy,paste,separator,undo,redo,separator,search,replace,separator,formatselect,separator,help", | |
10 | 10 | theme_advanced_buttons2 : "bold,italic,underline,strikethrough,separator,bullist,numlist,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,link,unlink,image,table,separator,cleanup,code", |
11 | 11 | theme_advanced_buttons3 : "", |
12 | + paste_auto_cleanup_on_paste : true, | |
13 | + paste_insert_word_content_callback : "convertWord", | |
14 | + paste_use_dialog: false, | |
12 | 15 | apply_source_formatting : true, |
13 | 16 | language: <%= tinymce_language.inspect %> |
14 | -}); | |
17 | + }); | |
18 | + | |
19 | +function convertWord(type, content) { | |
20 | + switch (type) { | |
21 | + // Gets executed before the built in logic performes it's cleanups | |
22 | + case "before": | |
23 | + //content = content.toLowerCase(); // Some dummy logic | |
24 | + break; | |
25 | + | |
26 | + // Gets executed after the built in logic performes it's cleanups | |
27 | + case "after": | |
28 | + content = content.replace(/<!--\s*-->/, ''); | |
29 | + break; | |
30 | + } | |
31 | + | |
32 | + return content; | |
33 | +} | |
15 | 34 | </script> |
35 | + | |
36 | + | |
37 | + | |
38 | + | ... | ... |
test/unit/language_helper_test.rb
... | ... | @@ -13,9 +13,9 @@ class LanguageHelperTest < Test::Unit::TestCase |
13 | 13 | assert_equal 'pt_BR', self.language |
14 | 14 | end |
15 | 15 | |
16 | - should 'downcase language for tinymce' do | |
16 | + should 'remove country code for TinyMCE' do | |
17 | 17 | self.expects(:language).returns('pt_BR') |
18 | - assert_equal 'pt_br', tinymce_language | |
18 | + assert_equal 'pt', tinymce_language | |
19 | 19 | end |
20 | 20 | |
21 | 21 | should 'downcase and use dash for HTML language' do | ... | ... |