Well, I couldn’t believe how easy it was to make our new editor use TinyMCE – I just downloaded the new version (3.0.4.1 – http://tinymce.moxiecode.com/download.php), hooked it up to our code and it ran out of the box.
Since you may not have done this yourself, I’ll just run you through how we use TinyMCE:
- make a TEXTAREA that you plan to work with; there are some complications if you want or have multiple TEXTAREAs but this is not an issue for us
- include TinyMCE: <script type="text/javascript" src="=/jscripts/tiny_mce/tiny_mce.js"></script>
- call the initalizer function: tinyMCE.init(initd)
That’s it, you have an editor. “initd” is a dictionary that describes how to set up TinyMCE. This is our setup:
initd = {
onchange_callback : "tinymce_onchange_callback",
theme_advanced_buttons1 :
"bullist,numlist,outdent,indent,separator,justifyleft,justifycenter,separator,link,unlink,image,separator,bold,italic,strikethrough,separator,sub,sup,forecolor,backcolor,separator,code",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
dialog_type : "modal",
theme_advanced_resize_horizontal : false,
entity_encoding : "numeric",
force_p_newlines : true,
force_br_newlines : false,
convert_newlines_to_brs : false,
relative_urls : false,
remove_script_host : false,
verify_html : false,
auto_reset_designmode : true,
remove_linebreaks : false,
theme_advanced_resizing : true,
mode : "textareas",
theme : "advanced",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_path_location : "bottom",
plugins : "inlinepopups",
content_css : "/:root/include/common/tinymce.css"
};
You’ll have to modify the location of the CSS file and the callback (so we know whether the document has been edited!) to
something you prefer to use, but you get the idea.
Also note that you may have to do some magic to move the data between the TinyMCE window and the TEXTAREA:
- To move the data into the TEXTAREA, do: tinyMCE.triggerSave()
-
To go the other way:
tinyMCE.updateContent(idName), where idName is the DOM ID of the TEXTAREA; whoops -- in version 3.x use tinyMCE.activeEditor.load();
Version 2 of TinyMCE misbehaved if you tried to create an editor in a hidden DIV (i.e. with display: none); I’m not sure if this issue is gone or not but try to avoid doing it.




