Rich text editor for Blazor (.NET 10) with keyboard accessibility, ARIA support, emoji picker (1800+ emojis via BlazorEmo), emoji autocomplete (first-item auto-selected on open), XSS protection. Tested on Chrome, Edge, Firefox. Native Blazor component. GPL-3.0 for open-source.
$ dotnet add package BlazorRTENative Blazor • Keyboard Accessible • Zero External Dependencies
| Browser | Status |
|---|---|
| Chrome | ✅ Tested |
| Edge | ✅ Tested |
| Firefox | ✅ Tested |
| Safari | ⚠️ Not tested |
⚠️ Important: BlazorRTE requires interactive rendering.
dotnet add package BlazorRTE
@page "/editor"
@using BlazorRTE.Components
@rendermode InteractiveServer
@* Required for JS interop! *@
<RichTextEditor @bind-Value="@content" Placeholder="Start typing..." />
@code { private string content = ""; }
Important: BlazorRTE requires interactive rendering. Add @rendermode InteractiveServer to your page or component.
Why is @rendermode required?
InteractiveServer, InteractiveWebAssembly, InteractiveAuto:smile for suggestions| Shortcut | Action | Chrome | Edge | Firefox |
|---|---|---|---|---|
Ctrl+B | Bold | ✅ | ✅ | ✅ |
Ctrl+I | Italic | ✅ | ✅ | ✅ |
Ctrl+U | Underline | ✅ | ✅ | ✅ |
Ctrl+Z | Undo | ✅ | ✅ | ✅ |
Ctrl+Y | Redo | ✅ | ✅ | ✅ |
Ctrl+Alt+1 | Heading 1 | ✅ | ✅ | ✅ |
Ctrl+Alt+2 | Heading 2 | ✅ | ✅ | ✅ |
Ctrl+Alt+3 | Heading 3 | ✅ | ✅ | ✅ |
Ctrl+L | Align Left | ✅ | ✅ | ❌ |
Ctrl+Enter | Horizontal Rule | ✅ | ✅ | ❌ |
Ctrl+Shift+X: Applies strikethrough but also right-aligns text| Key | Action |
|---|---|
← → | Move between buttons |
↓ | Open dropdown |
Enter / Space | Activate button |
Escape | Close dropdown |
Home | First button |
End | Last button |
For chat applications where Enter sends the message:
<RichTextEditor @bind-Value="@message"
BypassEnterKey="true" O
nEnterKeyPressed="SendMessage" />
@code {
private string message = "";
private async Task SendMessage()
{
// Send the message
await SendAsync(message);
message = "";
}
}
BypassEnterKey="true" - Enter triggers OnEnterKeyPressed instead of newlineShift+Enter - Insert newline when bypass is enabled[Parameter] public string Value { get; set; }
[Parameter] public EventCallback<string> ValueChanged { get; set; }
[Parameter] public string Placeholder { get; set; } = "Type your message...";
[Parameter] public bool ShowToolbar { get; set; } = true;
[Parameter] public int MaxLength { get; set; } = 5000;
[Parameter] public bool ShowCharacterCount { get; set; } = true;
[Parameter] public string MinHeight { get; set; } = "200px";
[Parameter] public string MaxHeight { get; set; } = "600px";
[Parameter] public bool DarkMode { get; set; } = false;
[Parameter] public bool EnableEmojiShortcodes { get; set; } = true;
[Parameter] public bool BypassEnterKey { get; set; } = false;
[Parameter] public string AriaLabel { get; set; } = "Rich text editor";
await ClearAsync(); // Clear all content
await FocusAsync(); // Focus the editor
string text = GetPlainText(); // Get plain text without HTML
BlazorRTE includes two ways to insert emojis:
Click the 😀 button in the toolbar to open a searchable emoji picker with:
Keyboard Shortcut: Ctrl+Shift+E
Quick Emoticons (: + 1 character) - Instant replacement:
:) → 😊 :( → 😔 :D → 😃 ;) → 😉 <3 → ❤️ :P → 😛
Autocomplete Search (: + 2+ characters) - Shows popup with suggestions:
:smile → 😊 (+ 9 more matches) :heart → ❤️ (+ 9 more matches) :rocket → 🚀 (+ 9 more matches) :thumbs → 👍 (+ 9 more matches)
Autocomplete Features:
↑ ↓ Enter Esc)Note: Emoji data is embedded (no external dependencies). Works offline!
BlazorRTE includes comprehensive unit tests using bUnit and xUnit.
Test Coverage:
Test Breakdown:
BlazorRTE includes enterprise-grade XSS protection:
<script>, event handlers)<iframe>, <object>, <embed>)javascript: URLs)onclick, onerror, etc.)Allowed tags: p, br, strong, em, u, s, h1-h6, ul, ol, li, a, hr, sub, sup, span, font
See LICENSE.txt for full GPL v3 terms.