Real-world implementations and use cases for the RSL Text Editor
A full-featured editor for creating blog posts with title, excerpt, and rich content. Includes word count tracking and live preview.
Welcome to the RSL Text Editor! This component makes it easy to add rich text editing to your applications.
Here are some key features:
<div id="blog-editor"
data-rsl-text-editor
data-toolbar="full"
data-placeholder="Write your blog post content here..."
data-min-height="300px"
data-show-count="true">
</div>
<script>
// Get the editor instance
var editor = RSL.TextEditor.getInstance('#blog-editor');
// Listen for changes
document.querySelector('#blog-editor').addEventListener('rsl-editor-change', function(e) {
console.log('Word count:', e.detail.wordCount);
});
// Get content for saving
function saveBlog() {
var html = editor.getValue();
var wordCount = editor.getWordCount();
// Send to your API...
}
</script>
A minimal editor for user comments with a 500 character limit. Shows visual feedback as the user approaches the limit.
<div data-rsl-text-editor
data-toolbar="minimal"
data-placeholder="Write your comment..."
data-char-limit="500"
data-min-height="100px">
</div>
A basic toolbar editor for composing emails with essential formatting options.
<div data-rsl-text-editor
data-toolbar="basic"
data-placeholder="Compose your email..."
data-min-height="200px">
</div>
Build your own toolbar with only the buttons you need.
<div data-rsl-text-editor
data-toolbar="custom"
data-toolbar-buttons="bold,italic,underline,link,image,blockquote,source"
data-placeholder="Custom toolbar...">
</div>
<!-- Available buttons: -->
<!-- heading, bold, italic, underline, strikethrough -->
<!-- link, image -->
<!-- ul, ol -->
<!-- alignLeft, alignCenter, alignRight -->
<!-- blockquote, code -->
<!-- undo, redo -->
<!-- removeFormat, source -->
An editor with a word limit for academic submissions or contests. Visual feedback shows progress toward the limit.
<div data-rsl-text-editor
data-toolbar="full"
data-word-limit="500"
data-min-height="350px"
data-max-height="500px">
</div>
Control the editor via JavaScript - set content, get values, execute commands.
// Get editor instance
var editor = RSL.TextEditor.getInstance('#api-editor');
// Set content programmatically
editor.setValue('<p>Hello <strong>World</strong>!</p>');
// Get content
var html = editor.getValue(); // HTML
var text = editor.getText(); // Plain text
var words = editor.getWordCount();
var chars = editor.getCharCount();
// Insert HTML at cursor
editor.insertHTML('<hr><p>Inserted content</p>');
// Execute formatting commands
editor.execCommand('bold');
editor.execCommand('italic');
// Toggle source view
editor.toggleSource();
// Focus/blur
editor.focus();
editor.blur();
// Clear
editor.clear();
Check out the API reference or try the interactive playground.
API Reference Open Playground