= WYSIWYG/JavaScript Editors = == Description == This is for integrating HTML Editors such as [http://tinymce.moxiecode.com/ TinyMCE] and [http://www.fckeditor.net/ FCKEditor] in {{{formal}}} forms. I haven't done this with Kupu yet, as it requires some digging for which I haven't summoned the motivation. This was trivial to implement for TinyMCE and FCKEditor because the solution is 100% JavaScript/HTML (this does not seem to be the case for Kupu). These two are useful since they are both multi-platform/-browser and come with an LGPL license. It is my opinion that TinyMCE is a better choice based solely on the fact that it is much faster and lighter-weight. FCKEditor seems to include a great deal of extra functionality for which I have never had need. == Dependencies == === formal === If you are like me, then you will find this easiest to test with the "examples" that come bundled with {{{formal}}}. For convenience, I encorage you to make a copy of the {{{formal}}} svn working directory in order to safely make the changes indicated below. === !JavaScript === These examples show how to integrate [http://tinymce.moxiecode.com/ TinyMCE] and [http://www.fckeditor.net FCKEditor]. * Download and uncompress the tarballs for each project * Only move the "jscripts/tiny_mce" directory from the uncompressed "tinymce" directory into "formal/js" * Move the entire uncompressed FCKeditor directory into "formal/js" == Changes to the Bundled Examples == In "formal/examples/main.py", add the following two lines to the {{{examples}}} list (I put mine after {{{ReSTWidgetFormPage}}}): {{{ 'formal.examples.wysiwyg.TinyMCEFormPage', 'formal.examples.wysiwyg.FCKEditorFormPage', }}} In the same file, add the following after the {{{FormExamplePage}}} class: {{{ class TinyMCEExamplePage(FormExamplePage): docFactory = loaders.stan( T.invisible[ DOCTYPE, T.html[ T.head[ CHARSET, T.title(data=T.directive('title'), render=rend.data), T.link(rel='stylesheet', type='text/css', href=url.root.child('examples.css')), T.link(rel='stylesheet', type='text/css', href=url.root.child('formal.css')), T.script(type='text/javascript', src='js/formal.js'), T.script(type='text/javascript', src='js/tiny_mce/tiny_mce.js'), T.script(type='text/javascript', language='JavaScript')[ 'tinyMCE.init({mode:"textareas"});' ], ], T.body[ T.h1(data=T.directive('title'), render=rend.data), T.p(data=T.directive('description'), render=rend.data), T.directive('form example'), ], ], ], ) class FCKEditorExamplePage(FormExamplePage): docFactory = loaders.stan( T.invisible[ DOCTYPE, T.html[ T.head[ CHARSET, T.title(data=T.directive('title'), render=rend.data), T.link(rel='stylesheet', type='text/css', href=url.root.child('examples.css')), T.link(rel='stylesheet', type='text/css', href=url.root.child('formal.css')), T.script(type='text/javascript', src='js/formal.js'), T.script(type='text/javascript', src='js/FCKeditor/fckeditor.js'), T.script(type='text/javascript', language='JavaScript')[ '''window.onload = function() { var oFCKeditor = new FCKeditor('example-aText'); oFCKeditor.BasePath = "js/FCKeditor/"; oFCKeditor.ReplaceTextarea(); } ''' ], ], T.body[ T.h1(data=T.directive('title'), render=rend.data), T.p(data=T.directive('description'), render=rend.data), T.directive('form example'), ], ], ], ) }}} {{{ #!html
}}} {{{ #!html