tinymce
How do you set the focus of a TinyMCE textarea element?
Finally found an answer… use the command: tinymce.execCommand(‘mceFocus’,false,’id_of_textarea’); For my purposes, ‘id_of_texterea’ was “description”, ie <textarea id=”description” … ></textarea> In the form element that preceded my textarea, I added the execCommand above to the element’s “onblur” action.
TinyMce Allow all Html tag
[*] You can set valid_elements : ‘*[*]’, to allow all html tags.
TinyMCE Paste As Plain Text
This is what i do to get paste plain text. 1. paste_preprocess setting (in tinymce init) paste_preprocess : function(pl, o) { //example: keep bold,italic,underline and paragraphs //o.content = strip_tags( o.content,'<b><u><i><p>’ ); // remove all tags => plain text o.content = strip_tags( o.content,” ); }, 2. function strip_tags (on the main document) // Strips HTML and … Read more
How do I find out what version of TinyMCE I am running?
Having a look at the source of tinymce (file tiny_mce_src.js, which is easier to read than, tiny_mce.js which is minified) : var tinymce = { majorVersion : ‘3’, minorVersion : ‘2.5’, releaseDate : ‘2009-06-29′, // lots of code ^^ })(); So, I’d say that, in Javascript, something like this : tinymce.majorVersion + ‘.’ + tinymce.minorVersion … Read more
How to detect changes in TinyMCE?
I’m late to the party, but for future reference here is how you do it in TinyMCE 4.X: tinyMCE.init({ setup:function(ed) { ed.on(‘change’, function(e) { console.log(‘the event object ‘, e); console.log(‘the editor object ‘, ed); console.log(‘the content ‘, ed.getContent()); }); } });
Problem when retrieving text in JSON format containing line breaks with jQuery
If you would like to keep the line breaks, you might try: function parse($text) { // Damn pesky carriage returns… $text = str_replace(“\r\n”, “\n”, $text); $text = str_replace(“\r”, “\n”, $text); // JSON requires new line characters be escaped $text = str_replace(“\n”, “\\n”, $text); return $text; }
how to add font-size toolbar in tinyMCE?
All you need to do is to add fontsizeselect to your toolbar config param: toolbar: “sizeselect | bold italic | fontselect | fontsizeselect”, Update: tinymce.init({ fontsize_formats: “8pt 10pt 12pt 14pt 18pt 24pt 36pt” });
Inserting text in TinyMCE Editor where the cursor is
You should use the command mceInsertContent. See the TinyMCE documentation. tinymce.activeEditor.execCommand(‘mceInsertContent’, false, “some text”);