CLEditor

CLEditor is a jQuery-based WYSIWYG editor. It turns a textarea control into a WYSIWYG document editor with a word processor-like interface.

Redaxscript has an Editor module available, but in Redaxscript 1.2.1 it is rather lacking when it comes to inserting pictures and hyperlinks. (The awesome Henry Ruhs has fixed most - if not all - of these problems in the forthcoming Redaxscript 2.0) However, I decided to look for an alternative editor and integrate it into Redaxscript as a module.

After trawling the net for a WYSIWYG editor that was small, open source and still currently maintained I settled on CLEditor. It is a jQuery plugin, and since Redaxscript already uses jQuery that should be one less component to worry about. CLEditor also has a simple method of extending functionality by adding plugins with custom buttons and functionality.

I added three extra buttons, one to add Redaxscript functions, one to add Redaxscript page breaks (read more... links) and one to add the ability to paste code with formatting preserved. Since plugins can also have their own stylesheets I was able to style the Redaxscript functions and page breaks in the editor so that they were visible without breaking the underlying HTML.

Apart from adding the CLEditor plugin files and the Redaxscript insallation and loader files, I had to add a startup script to the module to add a CLEditor object to the Redaxscript textarea and I had to modify one function in the core of CLEditor.

CLEditor creates a path to its image files at run-time from the path of the included CLEditor script file. However, Redaxscript uses its loader to load all scripts so there is no path to find. For a Redaxscript module, the images path will always be fixed so I simply changed the imagespath() function to return a fixed value. This was the only functional change required.

Additionally, I ran the code through the Redaxscript static analysis tools and jsHint threw up hundreds of errors! I refactored the code to fix all the errors so my version of the code now integrates with my Redaxscript project without breaking any of the rules.

If you want to use CLEditor in you own Redaxscript installation, you can get everything you need in a zip file here. CLEditor is dual licensed under the MIT License and GPL v2. My modified version and the Redaxscript plugin are dual licensed under the same terms.

To install CLEditor, unzip the file into the Redaxscript modules folder and CLEditor will automatically appear in the list of modules in the Redaxscript control panel. It installs and uninstalls the same as any other Redaxscript module. The module has been tested with Redaxscript 1.2.1 and with the current development build (which will one day soon become Redaxscipt 2.0).

If you have questions or comments about CLEditor in Redaxscript you can contact me via the Redaxscript Facebook group.