jQuery.contentEditable is a light-weight WYSIWYG rich text editor plugin that uses contentEditable support in modern browsers for in-place HTML editing.
Initially developed for DraftEssay.com (which incidentally, this was written in), I have decided to open-source it to encourage development.
Example
Click on this text and type something. Press "Save Changes" to get the changed HTML of the editable areas.
Dependencies
jQuery ContentEditable depends on jQuery and shortcut.js for keyboard shortcuts, as given below.
Download
The source is hosted on BitBucket, which you can clone like so:
$ hg clone https://bitbucket.org/freshcode/jquery.contenteditable
Usage
This is a widget and can only be edited by hovering and looking for the orange bar
- Include jQuery 1.4 or higher.
- Include shortcut.js (included with package).
- Include jquery.contenteditable.js
- Link to jquery.contenteditable.css for toolbar styles
Some jQuery Calls:
- To initialise the toolbar, call $(".fresheditable").fresheditor();
- To start/stop editing, call $(".fresheditable").fresheditor("edit", true); for editable elements.
- To save, call $(".fresheditable").fresheditor("save", function(id, content) { ... }); to have the callback function called for each editable element being saved.
Keyboard Shortcuts
- Tab indents the selected content
- Shift+Tab outdents selected content
- Ctrl+B makes text bold
- Ctrl+I makes text italic
- Ctrl+U underlines text
- Ctrl+L inserts a link
- Ctrl+Alt+0 formats a paragraph
- Ctrl+Alt+1 through Ctrl+Alt+5 adds headings 1 through 5
- Ctrl+J creates an unordered list, like this one
- Ctrl+K creates an ordered list.