How to build a basic rich text editor?

Are there any really basic tutorials for how to build a simple rich text editor?

  • I want to write my own rich text editor with javascript or jquery. I don't know where to start, so as bare bones as possible is ideal. EDIT: To response to the comment about reinventing the wheel - the reason why I want to this is because 1] some features I want to implement aren't available even in TinyMCE. 2] I have an idea to upgrade my website where alot of features of the site will interact with the editor. I think it'll take alot more work to modify another script for this purpose.

  • Answer:

    You'll have a mess to deal with when it comes to cross browser differences. You'll notice the edit here does not convert text inline as you edit it. If you're looking to make something like a basic notepad that has separate display, it's a matter of finding the carat and working around it and the words and whitespace nearby. If you're looking for a clean WYSIWYG editor, TinyMCE and openWYSIWYG both manipulate pages by inserting an iFrame, and setting the iFrame's properties to allow it to be edited. Before the page is submitted, they insert the iFrame's content into the original textbox, including the HTML and thus submit a pseudo rich-text item. Mozilla has a place to start for Firefox. https://developer.mozilla.org/en/Rich-Text%5FEditing%5Fin%5FMozilla

Eliyahu at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

Well since the only built in text controls are plain text you'll need to make your own. This means handling focus, capturing key presses and displaying the caret. I would start there.

Spencer Ruport

Your best bet is to take a look at how http://xinha.webfactional.com/ works. It is a great open source WYSIWYG editor. Other than that take a look http://www.google.com/#hl=en&q=javascript+rich+text+editor+&aq=f&oq=&aqi=g3&fp=Xmf0jJ9P%5FV0 to get started.

Andrew Siemer

"Are there any really basic tutorials for how to build a simple rich text editor?" Considering how much industry effort has gone into the ones currently available, I'm not sure there is a "simple rich text editor", much less a "basic tutorial". It's a very hard problem.

le dorfier

Well to start simply, create a row of same sized images for buttons. Give them all the same class file, then let Jquery process the onclick and capture the button name. Then based on the button name perform the required action. The basic framework shouldn't be so hard.

Tony Borf

I've found YUI's Rich Text Editor widget to be fairly small in size; perhaps you could tear that apart and see what they're up to? If nothing else, it's easily one of the smaller ones I've seen around, so you could probably implement that for your website. http://developer.yahoo.com/yui/editor/

Ryan McGrath

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.