🎨 Rich Text Editor API
Basic Usage
// Create and render editor
let editor = new RichTextEditor()
.setContainer('#editor-container')
.setContent('<h2>Welcome!</h2><p>Start editing...</p>')
.render();
API Methods
Set Content
Get Content
Clear
Insert HTML
Get Stats
Focus
Method Chaining Examples
// Method chaining
editor.clear().setContent('<p>New content</p>').focus();
// Configuration
editor.setPlaceholder('Enter your text here...');
// Get HTML output
const html = editor.getContent();
// Get statistics
const stats = editor.getStats(); // {words, characters, htmlLength}
Features
✅
Self-contained
- All HTML/CSS included in JS
✅
API-based
- Clean method chaining interface
✅
Smart paste
- Preserves formatting, removes unwanted styles
✅
Font controls
- Family and size selection
✅
Text formatting
- Bold, italic, underline, strikethrough
✅
Structure
- Headers, paragraphs, lists, blockquotes
✅
Links
- Insert and manage hyperlinks
✅
Alignment
- Left, center, right, justify
✅
Keyboard shortcuts
- Standard shortcuts supported
✅
Debug tools
- Console logging for development