richTextEditor: Rich Text-Editor
Most browsers have some sort of WYSIWYG (what you see is what you get) text editing function. Sadly, not all browsers implement this in the same manner. This classbehaviour function allows any textarea to be turned into a "rich" text-editor with a single classname.
The scripted version a normal textarea
When the "richTextEditor" classname is added to this textarea, the WYSIWG functions are turned on and a bank of buttons is imported from an external XML file. To work in Gecko based browsers, like Firefox, the editable area needs to be an iframe, so this is imported as well and takes the place of the textarea. The contents are constantly synchronized between the iframe and the texteditor so the submitted page will contain the edited text in a form element.
-
The "Text-mode" button switches the WYSIWG editor on and off and allows for manual editing of the generated HTML markup.
-
The "Resize" button lets the editor grow larger to give more room to work in.
Not all functions seem to work as well in all browsers and by no means is this implementation complete yet, but there is enough functionality to offer a useful text-editor.
Required Files
-
jQuery Addon Script: jquery.classbehaviours.richtexteditor.js
- Prerequisite Script: jquery.classbehaviours.togglenextnode.js
- Prerequisite Script: jquery.classbehaviours.js
- Example Markup: richTextEditor.html
- Example Stylesheet: richTextEditor.css
- Example XML: richTextEditor.xml
Comments on this Article