TinyEditor is a simple JavaScript WYSIWYG editor that is both lightweight (8KB) and standalone. It can easily be customized to integrate with any website through CSS and the multitude of parameters. It handles most of the basic formatting needs and has some functionality built in to help keep the rendered markup as clean as possible. The icons are courtesy of and have been combined into a sprite so there are only a few HTTP requests for the editor. I plan on adding some updates in the future to support font color, a full-screen mode, and a paste from Word option.
To initialize the script use the following:
01 | new TINY.editor.edit( 'editor' ,{ |
06 | controlclass: 'tecontrol' , |
08 | dividerclass: 'tedivider' , |
09 | controls:[ 'bold' , 'italic' , 'underline' , 'strikethrough' , '|' , 'subscript' , 'superscript' , '|' , 'orderedlist' , 'unorderedlist' , '|' , 'outdent' , 'indent' , '|' , 'leftalign' , 'centeralign' , 'rightalign' , 'blockjustify' , '|' , 'unformat' , '|' , 'undo' , 'redo' , 'n' , 'font' , 'size' , 'style' , '|' , 'image' , 'hr' , 'link' , 'unlink' , '|' , 'cut' , 'copy' , 'paste' , 'print' ], |
11 | fonts:[ 'Verdana' , 'Arial' , 'Georgia' , 'Trebuchet MS' ], |
14 | content: 'starting content' , |
15 | css: 'body{background-color:#ccc}' , |
17 | footerclass: 'tefooter' , |
18 | toggle:{text: 'source' ,activetext: 'wysiwyg' ,cssclass: 'toggle' }, |
19 | resize:{cssclass: 'resize' } |
The first parameter taken by TINY.editor.edit is the variable name used for the object instance. Keep in mind that before posting you will need to call the instance.post() function to ensure that the latest changes in the WYSIWYG translate into the text area. This script has been tested in all major
1/8/2010 – Resolved a couple IE and Chrome issues and added some cleanup for Safari/Chrome. Thanks for the reports.
1/12/2010 – Resolved issue with conversion to lower case and the header row class.
0 comments:
Post a Comment