Hi there,

I'd like to build my own WYSIWYG/BBCode editor for a CMS project I'm working on.

I need three main functions:

  1. Format text (Bold, Italic, Underline);
  2. Align text (Left, Centre, Right);
  3. Insert Image (From a list of uploaded images stored in a MySQL database)

I have already written the BBCode controller in PHP, and so I just have to make the buttons that will add the bbcode when you click on them.

The add image button I'm not sure about yet. I guess I could run a sql query on login of the contents of the database table, and store an array of image urls and thumbnails into a session, then have a 'pop-up' display the list of images you can choose from.

Anyway, first thing's first. I need to be able to add the bbcode around text highlighted by the user, exactly like I am able to do with this handy SitePoint WYSIWYG editor I am using right now. So I need to grab the highlighted text with jQuery and then I can append the '[,b]' and '[/b]' round it.

Does anyone have any idea how I can do that?

Ok, thanks in advance.