Implementing the Syncfusion ASP.NET Core Rich Text Editor
The Syncfusion ASP.NET Core Rich Text Editor (<ejs-richtexteditor>) is a single component that supports two editing modes:
- HTML mode (default) — WYSIWYG editor producing valid HTML markup
- Markdown mode (
editorMode="Markdown") — plain-text markdown editor with optional HTML preview
Both modes share the same tag helper, toolbar system, events, and most features. Choose the mode based on what your output format needs to be.
Editor Mode Decision
User wants to edit formatted content → output is HTML?
└─ Use default HTML mode (no editorMode needed)
User wants to write/edit Markdown text?
└─ Set editorMode="Markdown"
└─ Add Marked.js for live preview (see references/markdown-features.md)
When to Use This Skill
- Adding a rich text / WYSIWYG editor to an ASP.NET Core Razor page or MVC view
- Implementing a Markdown editor in ASP.NET Core
- Configuring toolbars, toolbar types, or custom toolbar tools
- Handling image, video, or audio uploads within the editor
- Inserting and managing tables
- Enabling inline editing, iframe mode, or resizable editor
- Integrating AI assistant, mentions, emoji picker, slash menu, or mail merge
- Getting, setting, or saving editor values; auto-save; character count
- Form validation with rich text content
- Read-only or disabled editor states
- XSS prevention and security
- Accessibility, keyboard support, globalization, RTL
- Handling editor events (lifecycle, focus, toolbar, upload, dialog, AI)
- Looking up available properties, types, and defaults
- Calling editor methods programmatically from JavaScript
Navigation Guide
Getting Started
📄 Read: references/getting-started.md
- NuGet installation and tag helper registration
- CDN stylesheet and script references
- Basic HTML editor (default mode)
- Basic Markdown editor (
editorMode="Markdown")
- Initial value binding via
ViewBag
- Toolbar configuration basics
Editor Modes & Display Options
📄 Read: references/editor-modes.md
- HTML mode vs Markdown mode (
editorMode property)
- IFrame mode for isolated editing (
iframeSettings)
- Inline editing mode (
inlineMode)
- Resizable editor (
enableResize)
- Setting editor height and width
Toolbar Configuration
📄 Read: references/toolbar.md
- Toolbar types: Expand, MultiRow, Scrollable, Popup
- Sticky / floating toolbar (
enableFloating, floatingToolbarOffset)
- Toolbar position (top / bottom)
- Quick toolbar for images, links, text, and tables
- HTML mode toolbar items reference
- Markdown mode toolbar items reference
Text Formatting
📄 Read: references/text-formatting.md
- Basic text styles: Bold, Italic, Underline, StrikeThrough, InlineCode
- Font name, size, color, background color
- Headings and paragraph formats
- Text alignments and indent/outdent
- Lists (ordered/unordered), blockquote, quotation formatting
Markdown Features
📄 Read: references/markdown-features.md
- Full supported markdown syntax reference
- Custom markdown format configuration
- Live Markdown-to-HTML preview with Marked.js
- Table and image insertion in Markdown mode
- Mention support in Markdown mode
Media & Links
📄 Read: references/media-and-links.md
- Image insertion, upload to server, drag-and-drop
- Image quick toolbar (caption, alt text, dimensions, alignment)
- Video and audio insertion
- Link insertion and quick toolbar
- File browser integration
Tables
📄 Read: references/table.md
- Inserting tables and configuring the CreateTable tool
- Table quick toolbar (rows, columns, merge, split, styles)
- Cell properties, background color, alignment
- Nesting tables
- Table selection and copy/paste
Smart Editing Features
📄 Read: references/smart-editing.md
- Emoji picker
- Slash menu
- Mentions integration with the Mention component
- Mail merge
- Format painter
- Code block formatting
AI Assistant
📄 Read: references/ai-assistant.md
- Enabling AICommands and AIQuery toolbar items
- Streaming and non-streaming AI response handling
AiAssistantPromptRequest event
addAIPromptResponse method
Editor Value & Content Management
📄 Read: references/editor-value.md
- Getting and setting HTML/Markdown values
getHtml(), getText(), getCharCount() methods
- Auto-save with
saveInterval
- Placeholder text
- Character count (
showCharCount, maxLength)
- HTML-encoded value (
enableHtmlEncode)
- Source code / code view editing
- Paste and clipboard cleanup
- Import and export (Word/PDF)
- Undo/redo management
Validation & Security
📄 Read: references/validation-security.md
- Form validation integration (
FormValidator)
- Read-only mode (
readonly)
- Disable editor (
enabled)
- XSS prevention (
enableHtmlSanitizer, beforeSanitizeHtml)
- XHTML validation
- Style encapsulation
Customization
📄 Read: references/customization.md
- Custom toolbar tools (template-based buttons)
- Built-in toolbar items reference
- CSS styling and theme customization
- Enter key / Shift+Enter key behavior (
enterKey, shiftEnterKey)
execCommand API for programmatic formatting
- Third-party integrations (CodeMirror)
enableToolbarItem / disableToolbarItem methods
Accessibility & Globalization
📄 Read: references/accessibility-globalization.md
- WCAG 2.2 AA compliance
- ARIA roles and attributes
- Keyboard shortcuts (HTML and Markdown modes)
- Localization and globalization (
locale, enableRtl)
Events
📄 Read: references/events.md
- Lifecycle events:
Created, Destroyed
- Focus/blur events:
Focus, Blur, Change
- Toolbar/command events:
ActionBegin, ActionComplete
- Paste/clipboard events:
BeforePasteCleanup, AfterPasteCleanup, BeforeClipboardWrite
- Dialog events:
BeforeDialogOpen, DialogOpen, BeforeDialogClose, DialogClose
- Popup events:
BeforePopupOpen, BeforePopupClose, BeforeQuickToolbarOpen
- Image upload events:
ImageSelected, BeforeImageUpload, ImageUploading, ImageUploadSuccess, ImageUploadFailed, ImageRemoving, AfterImageDelete, BeforeImageDrop
- Media upload events:
FileSelected, BeforeFileUpload, FileUploading, FileUploadSuccess, FileUploadFailed, FileRemoving, AfterMediaDelete, BeforeMediaDrop
- Security events:
BeforeSanitizeHtml
- Export events:
DocumentExporting
- AI Assistant events:
AiAssistantPromptRequest, AiAssistantStopRespondingClick, AiAssistantToolbarClick
Properties
📄 Read: references/properties.md
- Complete property reference with types, defaults, and descriptions
- Core properties:
Value, EditorMode, Placeholder, CssClass, Locale
- State flags:
Enabled, Readonly, EnableResize, EnablePersistence, EnableRtl, EnableTabKey
- Content & encoding:
EnableHtmlEncode, EnableHtmlSanitizer, EnableXhtml, EnableAutoUrl, EnableClipboardCleanup
- Character count & auto-save:
ShowCharCount, MaxLength, SaveInterval, AutoSaveOnIdle
- Key behavior:
EnterKey, ShiftEnterKey, FloatingToolbarOffset
- Undo/redo:
UndoRedoSteps, UndoRedoTimer
- Complex settings objects:
ToolbarSettings, QuickToolbarSettings, IframeSettings, InlineMode, InsertImageSettings, InsertVideoSettings, InsertAudioSettings, PasteCleanupSettings, TableSettings, FontFamily, FontColor, BackgroundColor, Format, SlashMenuSettings, EmojiPickerSettings, FormatPainterSettings, CodeBlockSettings, AiAssistantSettings, ImportWordSettings, ExportWordSettings, ExportPdfSettings, FileManagerSettings
Methods
📄 Read: references/methods.md
- Content methods:
getHtml(), getText(), getContent(), getSelectedHtml(), getXhtml(), getCharCount(), selectAll(), selectRange(), print()
- Command execution:
executeCommand() with full CommandName enum reference
- Toolbar methods:
enableToolbarItem(), disableToolbarItem(), removeToolbarItem()
- Focus methods:
focusIn(), focusOut()
- Inline toolbar:
showInlineToolbar(), hideInlineToolbar()
- Dialog methods:
showDialog(), closeDialog()
- Undo/redo:
clearUndoRedo()
- Source code:
showSourceCode()
- Full screen:
showFullScreen()
- Emoji picker:
showEmojiPicker()
- AI Assistant:
addAIPromptResponse(), executeAIPrompt(), getAIPromptHistory(), clearAIPromptHistory(), showAIAssistantPopup(), hideAIAssistantPopup()
- Lifecycle:
refresh(), refreshUI(), dataBind(), destroy()
- Security:
sanitizeHtml()
Quick Start
HTML Editor (default)
<!-- _ViewImports.cshtml -->
@addTagHelper *, Syncfusion.EJ2
<!-- _Layout.cshtml <head> -->
<link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/{{ site.ej2version }}/fluent.css" />
<script src="https://cdn.syncfusion.com/ej2/{{ site.ej2version }}/dist/ej2.min.js"></script>
<!-- _Layout.cshtml <body> end -->
<ejs-scripts></ejs-scripts>
<!-- Index.cshtml -->
<ejs-richtexteditor id="editor" value="@ViewBag.value">
<e-richtexteditor-toolbarsettings items="@ViewBag.tools"></e-richtexteditor-toolbarsettings>
</ejs-richtexteditor>
// HomeController.cs
public ActionResult Index()
{
ViewBag.value = "<p>Start editing here...</p>";
ViewBag.tools = new[] {
"Bold", "Italic", "Underline", "|",
"Formats", "Alignments", "OrderedList", "UnorderedList", "|",
"CreateLink", "Image", "CreateTable", "|",
"SourceCode", "|", "Undo", "Redo"
};
return View();
}
Markdown Editor
<ejs-richtexteditor id="markdown-editor" editorMode="Markdown" value="@ViewBag.value">
<e-richtexteditor-toolbarsettings items="@ViewBag.tools"></e-richtexteditor-toolbarsettings>
</ejs-richtexteditor>
public ActionResult Index()
{
ViewBag.value = "**Hello World** — start writing *markdown* here.";
ViewBag.tools = new[] {
"Bold", "Italic", "StrikeThrough", "InlineCode", "|",
"Formats", "Blockquote", "OrderedList", "UnorderedList", "|",
"CreateLink", "Image", "CreateTable", "|", "Undo", "Redo"
};
return View();
}
Common Patterns
Read editor value on form submit
<form id="form-element">
<ejs-richtexteditor id="rte" name="rteContent" value="@ViewBag.value"></ejs-richtexteditor>
<button type="submit">Submit</button>
</form>
<script>
document.querySelector('form').onsubmit = function () {
var rte = document.getElementById('rte').ej2_instances[0];
console.log(rte.getHtml());
};
</script>
Image upload to server
<ejs-richtexteditor id="editor">
<e-richtexteditor-insertimagesettings
saveUrl="/Home/SaveImage"
removeUrl="/Home/RemoveImage"
path="./Uploads/">
</e-richtexteditor-insertimagesettings>
</ejs-richtexteditor>
Inline editing
<ejs-richtexteditor id="inline" value="@ViewBag.value">
<e-richtexteditor-inlinemode enable="true"
</ejs-richtexteditor>
Character count with limit
<ejs-richtexteditor id="editor" showCharCount="true" maxLength="500" value="@ViewBag.value">
</ejs-richtexteditor>
1---2name: syncfusion-aspnetcore-rich-text-editor3description: Implements the Syncfusion ASP.NET Core Rich Text Editor (ejs-richtexteditor tag helper) supporting HTML (WYSIWYG) and Markdown editing modes. Set editorMode='Markdown' for Markdown; default is HTML. Use this skill for toolbar configuration, image upload, table editing, inline or iframe mode, AI assistant integration, mentions, and form validation with rich text in ASP.NET Core projects.4---56# Implementing the Syncfusion ASP.NET Core Rich Text Editor78The Syncfusion ASP.NET Core Rich Text Editor (`<ejs-richtexteditor>`) is a single component that supports two editing modes:910- **HTML mode** (default) — WYSIWYG editor producing valid HTML markup11- **Markdown mode** (`editorMode="Markdown"`) — plain-text markdown editor with optional HTML preview1213Both modes share the same tag helper, toolbar system, events, and most features. Choose the mode based on what your output format needs to be.1415## Editor Mode Decision1617```18User wants to edit formatted content → output is HTML?19 └─ Use default HTML mode (no editorMode needed)2021User wants to write/edit Markdown text?22 └─ Set editorMode="Markdown"23 └─ Add Marked.js for live preview (see references/markdown-features.md)24```2526## When to Use This Skill2728- Adding a rich text / WYSIWYG editor to an ASP.NET Core Razor page or MVC view29- Implementing a Markdown editor in ASP.NET Core30- Configuring toolbars, toolbar types, or custom toolbar tools31- Handling image, video, or audio uploads within the editor32- Inserting and managing tables33- Enabling inline editing, iframe mode, or resizable editor34- Integrating AI assistant, mentions, emoji picker, slash menu, or mail merge35- Getting, setting, or saving editor values; auto-save; character count36- Form validation with rich text content37- Read-only or disabled editor states38- XSS prevention and security39- Accessibility, keyboard support, globalization, RTL40- Handling editor events (lifecycle, focus, toolbar, upload, dialog, AI)41- Looking up available properties, types, and defaults42- Calling editor methods programmatically from JavaScript4344## Navigation Guide4546### Getting Started47📄 **Read:** [references/getting-started.md](references/getting-started.md)48- NuGet installation and tag helper registration49- CDN stylesheet and script references50- Basic HTML editor (default mode)51- Basic Markdown editor (`editorMode="Markdown"`)52- Initial value binding via `ViewBag`53- Toolbar configuration basics5455### Editor Modes & Display Options56📄 **Read:** [references/editor-modes.md](references/editor-modes.md)57- HTML mode vs Markdown mode (`editorMode` property)58- IFrame mode for isolated editing (`iframeSettings`)59- Inline editing mode (`inlineMode`)60- Resizable editor (`enableResize`)61- Setting editor height and width6263### Toolbar Configuration64📄 **Read:** [references/toolbar.md](references/toolbar.md)65- Toolbar types: Expand, MultiRow, Scrollable, Popup66- Sticky / floating toolbar (`enableFloating`, `floatingToolbarOffset`)67- Toolbar position (top / bottom)68- Quick toolbar for images, links, text, and tables69- HTML mode toolbar items reference70- Markdown mode toolbar items reference7172### Text Formatting73📄 **Read:** [references/text-formatting.md](references/text-formatting.md)74- Basic text styles: Bold, Italic, Underline, StrikeThrough, InlineCode75- Font name, size, color, background color76- Headings and paragraph formats77- Text alignments and indent/outdent78- Lists (ordered/unordered), blockquote, quotation formatting7980### Markdown Features81📄 **Read:** [references/markdown-features.md](references/markdown-features.md)82- Full supported markdown syntax reference83- Custom markdown format configuration84- Live Markdown-to-HTML preview with Marked.js85- Table and image insertion in Markdown mode86- Mention support in Markdown mode8788### Media & Links89📄 **Read:** [references/media-and-links.md](references/media-and-links.md)90- Image insertion, upload to server, drag-and-drop91- Image quick toolbar (caption, alt text, dimensions, alignment)92- Video and audio insertion93- Link insertion and quick toolbar94- File browser integration9596### Tables97📄 **Read:** [references/table.md](references/table.md)98- Inserting tables and configuring the CreateTable tool99- Table quick toolbar (rows, columns, merge, split, styles)100- Cell properties, background color, alignment101- Nesting tables102- Table selection and copy/paste103104### Smart Editing Features105📄 **Read:** [references/smart-editing.md](references/smart-editing.md)106- Emoji picker107- Slash menu108- Mentions integration with the Mention component109- Mail merge110- Format painter111- Code block formatting112113### AI Assistant114📄 **Read:** [references/ai-assistant.md](references/ai-assistant.md)115- Enabling AICommands and AIQuery toolbar items116- Streaming and non-streaming AI response handling117- `AiAssistantPromptRequest` event118- `addAIPromptResponse` method119120### Editor Value & Content Management121📄 **Read:** [references/editor-value.md](references/editor-value.md)122- Getting and setting HTML/Markdown values123- `getHtml()`, `getText()`, `getCharCount()` methods124- Auto-save with `saveInterval`125- Placeholder text126- Character count (`showCharCount`, `maxLength`)127- HTML-encoded value (`enableHtmlEncode`)128- Source code / code view editing129- Paste and clipboard cleanup130- Import and export (Word/PDF)131- Undo/redo management132133### Validation & Security134📄 **Read:** [references/validation-security.md](references/validation-security.md)135- Form validation integration (`FormValidator`)136- Read-only mode (`readonly`)137- Disable editor (`enabled`)138- XSS prevention (`enableHtmlSanitizer`, `beforeSanitizeHtml`)139- XHTML validation140- Style encapsulation141142### Customization143📄 **Read:** [references/customization.md](references/customization.md)144- Custom toolbar tools (template-based buttons)145- Built-in toolbar items reference146- CSS styling and theme customization147- Enter key / Shift+Enter key behavior (`enterKey`, `shiftEnterKey`)148- `execCommand` API for programmatic formatting149- Third-party integrations (CodeMirror)150- `enableToolbarItem` / `disableToolbarItem` methods151152### Accessibility & Globalization153📄 **Read:** [references/accessibility-globalization.md](references/accessibility-globalization.md)154- WCAG 2.2 AA compliance155- ARIA roles and attributes156- Keyboard shortcuts (HTML and Markdown modes)157- Localization and globalization (`locale`, `enableRtl`)158159### Events160📄 **Read:** [references/events.md](references/events.md)161- Lifecycle events: `Created`, `Destroyed`162- Focus/blur events: `Focus`, `Blur`, `Change`163- Toolbar/command events: `ActionBegin`, `ActionComplete`164- Paste/clipboard events: `BeforePasteCleanup`, `AfterPasteCleanup`, `BeforeClipboardWrite`165- Dialog events: `BeforeDialogOpen`, `DialogOpen`, `BeforeDialogClose`, `DialogClose`166- Popup events: `BeforePopupOpen`, `BeforePopupClose`, `BeforeQuickToolbarOpen`167- Image upload events: `ImageSelected`, `BeforeImageUpload`, `ImageUploading`, `ImageUploadSuccess`, `ImageUploadFailed`, `ImageRemoving`, `AfterImageDelete`, `BeforeImageDrop`168- Media upload events: `FileSelected`, `BeforeFileUpload`, `FileUploading`, `FileUploadSuccess`, `FileUploadFailed`, `FileRemoving`, `AfterMediaDelete`, `BeforeMediaDrop`169- Security events: `BeforeSanitizeHtml`170- Export events: `DocumentExporting`171- AI Assistant events: `AiAssistantPromptRequest`, `AiAssistantStopRespondingClick`, `AiAssistantToolbarClick`172173### Properties174📄 **Read:** [references/properties.md](references/properties.md)175- Complete property reference with types, defaults, and descriptions176- Core properties: `Value`, `EditorMode`, `Placeholder`, `CssClass`, `Locale`177- State flags: `Enabled`, `Readonly`, `EnableResize`, `EnablePersistence`, `EnableRtl`, `EnableTabKey`178- Content & encoding: `EnableHtmlEncode`, `EnableHtmlSanitizer`, `EnableXhtml`, `EnableAutoUrl`, `EnableClipboardCleanup`179- Character count & auto-save: `ShowCharCount`, `MaxLength`, `SaveInterval`, `AutoSaveOnIdle`180- Key behavior: `EnterKey`, `ShiftEnterKey`, `FloatingToolbarOffset`181- Undo/redo: `UndoRedoSteps`, `UndoRedoTimer`182- Complex settings objects: `ToolbarSettings`, `QuickToolbarSettings`, `IframeSettings`, `InlineMode`, `InsertImageSettings`, `InsertVideoSettings`, `InsertAudioSettings`, `PasteCleanupSettings`, `TableSettings`, `FontFamily`, `FontColor`, `BackgroundColor`, `Format`, `SlashMenuSettings`, `EmojiPickerSettings`, `FormatPainterSettings`, `CodeBlockSettings`, `AiAssistantSettings`, `ImportWordSettings`, `ExportWordSettings`, `ExportPdfSettings`, `FileManagerSettings`183184### Methods185📄 **Read:** [references/methods.md](references/methods.md)186- Content methods: `getHtml()`, `getText()`, `getContent()`, `getSelectedHtml()`, `getXhtml()`, `getCharCount()`, `selectAll()`, `selectRange()`, `print()`187- Command execution: `executeCommand()` with full `CommandName` enum reference188- Toolbar methods: `enableToolbarItem()`, `disableToolbarItem()`, `removeToolbarItem()`189- Focus methods: `focusIn()`, `focusOut()`190- Inline toolbar: `showInlineToolbar()`, `hideInlineToolbar()`191- Dialog methods: `showDialog()`, `closeDialog()`192- Undo/redo: `clearUndoRedo()`193- Source code: `showSourceCode()`194- Full screen: `showFullScreen()`195- Emoji picker: `showEmojiPicker()`196- AI Assistant: `addAIPromptResponse()`, `executeAIPrompt()`, `getAIPromptHistory()`, `clearAIPromptHistory()`, `showAIAssistantPopup()`, `hideAIAssistantPopup()`197- Lifecycle: `refresh()`, `refreshUI()`, `dataBind()`, `destroy()`198- Security: `sanitizeHtml()`199200---201202## Quick Start203204### HTML Editor (default)205206```razor207<!-- _ViewImports.cshtml -->208@addTagHelper *, Syncfusion.EJ2209210<!-- _Layout.cshtml <head> -->211<link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/{{ site.ej2version }}/fluent.css" />212<script src="https://cdn.syncfusion.com/ej2/{{ site.ej2version }}/dist/ej2.min.js"></script>213214<!-- _Layout.cshtml <body> end -->215<ejs-scripts></ejs-scripts>216217<!-- Index.cshtml -->218<ejs-richtexteditor id="editor" value="@ViewBag.value">219 <e-richtexteditor-toolbarsettings items="@ViewBag.tools"></e-richtexteditor-toolbarsettings>220</ejs-richtexteditor>221```222223```csharp224// HomeController.cs225public ActionResult Index()226{227 ViewBag.value = "<p>Start editing here...</p>";228 ViewBag.tools = new[] {229 "Bold", "Italic", "Underline", "|",230 "Formats", "Alignments", "OrderedList", "UnorderedList", "|",231 "CreateLink", "Image", "CreateTable", "|",232 "SourceCode", "|", "Undo", "Redo"233 };234 return View();235}236```237238### Markdown Editor239240```razor241<ejs-richtexteditor id="markdown-editor" editorMode="Markdown" value="@ViewBag.value">242 <e-richtexteditor-toolbarsettings items="@ViewBag.tools"></e-richtexteditor-toolbarsettings>243</ejs-richtexteditor>244```245246```csharp247public ActionResult Index()248{249 ViewBag.value = "**Hello World** — start writing *markdown* here.";250 ViewBag.tools = new[] {251 "Bold", "Italic", "StrikeThrough", "InlineCode", "|",252 "Formats", "Blockquote", "OrderedList", "UnorderedList", "|",253 "CreateLink", "Image", "CreateTable", "|", "Undo", "Redo"254 };255 return View();256}257```258259---260261## Common Patterns262263### Read editor value on form submit264265```razor266<form id="form-element">267 <ejs-richtexteditor id="rte" name="rteContent" value="@ViewBag.value"></ejs-richtexteditor>268 <button type="submit">Submit</button>269</form>270<script>271 document.querySelector('form').onsubmit = function () {272 var rte = document.getElementById('rte').ej2_instances[0];273 console.log(rte.getHtml());274 };275</script>276```277278### Image upload to server279280```razor281<ejs-richtexteditor id="editor">282 <e-richtexteditor-insertimagesettings283 saveUrl="/Home/SaveImage"284 removeUrl="/Home/RemoveImage"285 path="./Uploads/">286 </e-richtexteditor-insertimagesettings>287</ejs-richtexteditor>288```289290### Inline editing291292```razor293<ejs-richtexteditor id="inline" value="@ViewBag.value">294 <e-richtexteditor-inlinemode enable="true" onSelection="true"></e-richtexteditor-inlinemode>295</ejs-richtexteditor>296```297298### Character count with limit299300```razor301<ejs-richtexteditor id="editor" showCharCount="true" maxLength="500" value="@ViewBag.value">302</ejs-richtexteditor>303```