Inserting text into Firefox rich text editor

I'm trying to build a light-weight rich text editor that works in Firefox. So far so good, as I have the usual bold, URL, image, etc., stuff working. Where I'm stuck is inserting text. For example, if you want to insert "forum tags" for quotes, which we don't put in as HTML, how is that done? In IE, you can do it like this...

var box = document.getElementById(ctrl).contentWindow;
box.document.designMode = "on";
...
function makeQuote(cmd)
{
var edittext = box.document.selection.createRange();
var original = edittext.htmlText;
edittext.pasteHTML('['+cmd+']'+original+'[/'+cmd+']');


So in this case, selecting text in the editor then triggering the event would yield something like:
[quote]this is a quote[/quote]

How is this done in Firefox?

5 Comments

  • Check out FCKEditor at http://www.fckeditor.net/



    It provides a full set of editing controls that work with both the IE and Mozilla/Firefox edit systems.



    Even if it's not suitable you could learn a thing or two from the source, it's LGPL'ed.



    [)amien

  • Check out http://www.freetextbox.com, works for both IE and Firefox!!

  • I'm well aware of FreeTextBox, and it's too bulky. It also doesn't render stuff in non-CSS mode in Firefox even though the latest version says it shoud.

  • unrelated, but: http://blogs.wwwcoder.com/jdee/archive/2005/05/09/4068.aspx

  • Hey Jeff,

    Did you ever get anywhere with this? I'm in the same boat right now with my website. All I want to do is has very light weight rich text editor for users add and information about products (bullets underlines) color

Comments have been disabled for this content.