TextBar Drupal module for Markdown and Textile
Here’s a treat for Drupal users who support the Markdown and Textile input formats on their sites. The TextBar module adds a formatting toolbar for these input formats to Drupal’s content and comment texarea fields.
To try out the TextBar right now, you can comment on this message. (You don’t need to save your comment unless you want to :-) but you’ll be able to try out the toolbar while editing it.)
You can try it with both the Markdown and Textile input formats (and if you select the Filtered HTML format the toolbar will disappear). The Textile input filter is not actually installed on this site, though, because of a conflict between the Markdown and Textile modules. So you won’t be able to actually post a comment in Textile, but you can see how the TextBar generates Textile codes.
The TextBar is not a WYSIWYG editor like htmlArea, FCKeditor, or Xinha. Drupal’s textarea remains a textarea, and the TextBar merely provides a way to enter the Markdown or Textile formatting codes. It’s not as slick as the WYSIWYG editors, but it’s very fast and simple.
If you’ve used the excellent DokuWiki, the TextBar will look very familiar, because that’s what I ported the code from. DokuWiki in turn got it from MediaWiki and phpBB. Many thanks to the authors of these programs for making it so easy to port this code to Drupal.
There are no settings or options in this version. Simply install the textbar module and enable it in the admin/modules panel. Then you should see the toolbar on content body, comment, and block editing pages, but only when the selected input format has either “Markdown” or “Textile” in the name. The toolbar will show and hide itself when you switch between these formats and any other input formats.
There are a number of loose ends. In particular, the internal and external link buttons could use some improvement, and I didn’t implement the image button from DokuWiki’s toolbar. Also, I’d like to move the toolbar right above the textarea field instead of having the “Body: *” or similar text in between. (Not as easy as it sounds.) But it’s useful enough that I thought I’d release this version for comments before submitting it to the Drupal module collection.
At this point, I’ve only tested on Firefox and Internet Explorer. The DokuWiki toolbar does support other browsers, so if I’ve broken something on another browser it should be easy enough to fix.
If you like the TextBar, you can download it here. Your feedback would be greatly appreciated.
Update: I found one bug: If Markdown is the only input format enabled, the TextBar does not show. I’ll fix it shortly. In the meantime, a quick and dirty fix is to change
textbar_getInputFormatName() to return either