In this project we are going to create a simple text editor. We are going to begin with text areas and add a couple of buttons that insert HTML tags for us. In doing this project, we will make use of the jQuery techniques we learned in the previous chapter, as well as behaviors and some of the utility functions we saw earlier in this chapter.
Note
There are already several rich text editors available for Drupal, all of which are more advanced than the simple tool we will create here. The WYSIWYG API module is poised to become the de facto text editor going forward. It can be found at http://drupal.org/project/wysiwyg.
Our editor will have two buttons—a B button to make some text bold, and an I button to add italics. The editor will insert markup into the text so that the tags are visible to the user. For example, if the user types in the string This is bold, highlights the word "bold", and presses the B button, she or he will see the text This is <strong>...