syncfusion/blazor-ui-components-skills / skills/syncfusion-blazor-rich-text-editor
syncfusion-blazor-rich-text-editor
VerifiedImplements the Syncfusion Blazor Rich Text Editor (SfRichTextEditor) from Syncfusion.Blazor.RichTextEditor. Supports HTML, Markdown, and IFrame editor modes. Use this skills for toolbar configuration, image/video/audio insertion, table management, paste cleanup, import/export Word/PDF, accessibility, globalization, RTL, and inline or custom toolbar tool scenarios in Blazor applications.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 11.1 KB |
| references/accessibility-globalization.md | markdown | 6.7 KB |
| references/built-in-tools.md | markdown | 6.7 KB |
| references/custom-tools.md | markdown | 9.1 KB |
| references/data-binding.md | markdown | 4.6 KB |
| references/editor-modes.md | markdown | 5.8 KB |
| references/events.md | markdown | 23.6 KB |
| references/getting-started.md | markdown | 4.9 KB |
| references/images-and-media.md | markdown | 7.2 KB |
| references/import-export.md | markdown | 8.1 KB |
| references/inline-mode.md | markdown | 4.3 KB |
| references/methods.md | markdown | 10.3 KB |
| references/paste-and-cleanup.md | markdown | 6.7 KB |
| references/properties.md | markdown | 12.2 KB |
| references/tables.md | markdown | 8.1 KB |
| references/text-formatting.md | markdown | 7.0 KB |
| references/toolbar.md | markdown | 6.9 KB |
references/methods.md
View on GitHub````markdown
# SfRichTextEditor – Public Methods
## Table of Contents
- [Focus & Selection](#focus--selection)
- [Content Retrieval](#content-retrieval)
- [Command Execution](#command-execution)
- [Toolbar Control](#toolbar-control)
- [Dialog & UI Control](#dialog--ui-control)
- [Undo / Redo](#undo--redo)
- [CommandName Enum Reference](#commandname-enum-reference)
- [ToolbarCommand Enum Reference](#toolbarcommand-enum-reference)
- [DialogType Enum Reference](#dialogtype-enum-reference)
---
## Focus & Selection
**`FocusAsync()`**
Sets the focus on the editor, enabling user interaction.
**Returns:** `Task`
**`FocusOutAsync()`**
Removes the focus from the editor.
**Returns:** `Task`
**`SaveSelectionAsync()`**
Saves the current selection range. Call before any async operation that might move focus, then restore with `RestoreSelectionAsync()`.
**Returns:** `Task`
**`RestoreSelectionAsync()`**
Restores the previously saved selection range.
**Returns:** `Task`
**`SelectAllAsync()`**
Selects all content in the editor.
**Returns:** `Task`
**`GetSelectionAsync()`**
Retrieves the HTML markup of the currently selected content.
**Returns:** `Task<string>`
---
## Content Retrieval
**`GetTextAsync()`**
Gets the plain-text content of the editor (HTML tags stripped).
**Returns:** `Task<string>`
**`GetSelectedHtmlAsync()`**
Gets the HTML value of the selected content as a string.
**Returns:** `Task<string>`
**`GetCharCountAsync()`**
Retrieves the number of characters in the editor.
**Returns:** `Task<double>`
**`GetXhtmlAsync()`**
Retrieves XHTML-validated HTML content. Requires `EnableXhtml="true"`.
**Returns:** `Task<string>`
---
## Command Execution
All `ExecuteCommandAsync` overloads take a `CommandName` value (see [CommandName Enum Reference](#commandname-enum-reference)).
### Simple command (no arguments)
```csharp
await rteObj.ExecuteCommandAsync(CommandName.Bold);
await rteObj.ExecuteCommandAsync(CommandName.Undo);
await rteObj.ExecuteCommandAsync(CommandName.InsertParagraph);
```
### Command with a string value
```csharp
// Insert raw HTML at the cursor
await rteObj.ExecuteCommandAsync(CommandName.InsertHTML, "<strong>Hello</strong>");
// Insert plain text
await rteObj.ExecuteCommandAsync(CommandName.InsertText, "typed text");
```
### Insert / edit an image
```csharp
await rteObj.ExecuteCommandAsync(
CommandName.InsertImage,
new ImageCommandsArgs
{
Url = "https://example.com/photo.jpg",
AltText = "A photo",
Width = new CommandsWidth { Width = "300px", MaxWidth = "100%" },
Height = new CommandsHeight { Height = "200px" },
CssClass = "rounded"
}
);
```
### Insert / edit a link
```csharp
await rteObj.ExecuteCommandAsync(
CommandName.CreateLink,
new LinkCommandsArgs
{
Url = "https://syncfusion.com",
Text = "Syncfusion",
Title = "Visit Syncfusion",
Target = "_blank"
}
);
```
### Insert a table
```csharp
await rteObj.ExecuteCommandAsync(
CommandName.InsertTable,
new TableCommandsArgs { Rows = 3, Columns = 4 }
);
```
### Insert a video
```csharp
await rteObj.ExecuteCommandAsync(
CommandName.Video,
new VideoCommandsArgs
{
Url = "https://example.com/video.mp4",
Width = new CommandsWidth { Width = "560px" },
Height = new CommandsHeight { Height = "315px" }
}
);
```
### Insert audio
```csharp
await rteObj.ExecuteCommandAsync(
CommandName.Audio,
new AudioCommandsArgs { Url = "https://example.com/sound.mp3" }
);
```
### Insert a code block
```csharp
await rteObj.ExecuteCommandAsync(
CommandName.InsertCodeBlock,
new CodeBlockCommandArgs { Language = "typescript", Label = "TypeScript" },
new ExecuteCommandOption { Undo = true }
);
```
### Format Painter
```csharp
// Copy formatting from current selection
await rteObj.ExecuteCommandAsync(CommandName.CopyFormatPainter, new FormatPainterParams
{
Action = FormatPainterAction.CopyFormat
});
// Apply copied formatting to new selection
await rteObj.ExecuteCommandAsync(CommandName.ApplyFormatPainter, new FormatPainterParams
{
Action = FormatPainterAction.PasteFormat,
Options = new FormatPainterOptions
{
AllowedFormats = "b;strong;i;em;u",
DeniedFormats = "span[style]"
}
});
```
**`ExecuteCommandOption`**
| Property | Type | Description |
|---|---|---|
| `Undo` | `bool` | When `true`, the command is added to the undo stack so it can be reversed |
---
## Toolbar Control
**`EnableToolbarItem(List<ToolbarCommand>? items)`**
Enables the specified toolbar items, making them interactive.
```csharp
rteObj.EnableToolbarItem(new List<ToolbarCommand>
{
ToolbarCommand.Bold,
ToolbarCommand.Italic
});
```
**`DisableToolbarItem(List<ToolbarCommand>? items)`**
Disables the specified toolbar items, preventing their use.
```csharp
rteObj.DisableToolbarItem(new List<ToolbarCommand>
{
ToolbarCommand.Image,
ToolbarCommand.CreateTable
});
```
**`RemoveToolbarItem(List<ToolbarCommand> items)`**
Removes the specified toolbar items from the toolbar entirely.
```csharp
rteObj.RemoveToolbarItem(new List<ToolbarCommand>
{
ToolbarCommand.FullScreen,
ToolbarCommand.Print
});
```
---
## Dialog & UI Control
**`ShowDialogAsync(DialogType type)`**
Opens a specific insert/import dialog programmatically.
```csharp
// Open the insert-image dialog
await rteObj.ShowDialogAsync(DialogType.InsertImage);
```
**`CloseDialogAsync(DialogType type)`**
Closes the specified dialog.
```csharp
await rteObj.CloseDialogAsync(DialogType.InsertLink);
```
**`ShowInlineToolbarAsync()`** / **`HideInlineToolbarAsync()`**
Shows or hides the inline quick toolbar.
**`ShowFullScreenAsync()`**
Expands the editor to fill the viewport (full-screen mode).
**`ShowSourceCodeAsync()`**
Toggles the HTML/Markdown source code view.
**`PrintAsync()`**
Opens the browser print dialog for the editor content.
**`RefreshUIAsync()`**
Forces a UI refresh — useful after programmatic content changes.
---
## Undo / Redo
**`ClearUndoRedoAsync()`**
Clears both the undo and redo stacks and disables the undo/redo toolbar buttons. Use after loading new content programmatically to give the user a clean history.
```csharp
// Load fresh content then reset history
rteObj.Value = "<p>New document</p>";
await rteObj.ClearUndoRedoAsync();
```
---
## CommandName Enum Reference
| Value | Description |
|---|---|
| `ApplyFormatPainter` | Apply previously copied formatting |
| `Audio` | Insert/manage audio |
| `BackgroundColor` | Set text background color |
| `Blockquote` | Toggle blockquote |
| `Bold` | Toggle bold |
| `BulletFormatList` | Insert bullet list |
| `Checklist` | Insert checklist |
| `CopyFormatPainter` | Copy formatting from selection |
| `CreateLink` | Insert or edit a hyperlink |
| `EditImage` | Edit an existing image |
| `EditLink` | Edit an existing link |
| `ExportPdf` | Export content to PDF |
| `ExportWord` | Export content to Word |
| `FontColor` | Set text color |
| `FontName` | Set font family |
| `FontSize` | Set font size |
| `FormatBlock` | Apply block format |
| `Heading` | Apply heading |
| `ImportWord` | Import from Word |
| `Indent` | Indent content |
| `InsertBrOnReturn` | Insert `<br>` on Enter |
| `InsertCode` | Insert inline code |
| `InsertCodeBlock` | Insert code block with language |
| `InsertHTML` | Insert raw HTML at cursor |
| `InsertHorizontalRule` | Insert `<hr>` |
| `InsertImage` | Insert an image |
| `InsertOrderedList` | Insert numbered list |
| `InsertParagraph` | Insert paragraph break |
| `InsertTable` | Insert a table |
| `InsertText` | Insert plain text at cursor |
| `InsertUnorderedList` | Insert bullet list |
| `Italic` | Toggle italic |
| `JustifyCenter` | Center align |
| `JustifyFull` | Justify align |
| `JustifyLeft` | Left align |
| `JustifyRight` | Right align |
| `Lowercase` | Convert to lowercase |
| `NumberFormatList` | Insert number format list |
| `Outdent` | Outdent content |
| `Redo` | Redo last undone action |
| `RemoveFormat` | Clear all formatting |
| `StrikeThrough` | Toggle strikethrough |
| `Subscript` | Toggle subscript |
| `Superscript` | Toggle superscript |
| `Underline` | Toggle underline |
| `Undo` | Undo last action |
| `Uppercase` | Convert to uppercase |
| `Video` | Insert/manage video |
---
## ToolbarCommand Enum Reference
Used by `EnableToolbarItem`, `DisableToolbarItem`, `RemoveToolbarItem`.
| Value | Description |
|---|---|
| `Alignments` | Alignment dropdown |
| `Audio` | Audio insertion tool |
| `BackgroundColor` | Background colour picker |
| `Blockquote` | Blockquote toggle |
| `Bold` | Bold toggle |
| `BulletFormatList` | Bullet format list |
| `Checklist` | Checklist tool |
| `ClearFormat` | Clear formatting |
| `CodeBlock` | Code block insertion |
| `CreateLink` | Insert/edit link |
| `CreateTable` | Insert table |
| `ExportPdf` | Export to PDF |
| `ExportWord` | Export to Word |
| `FontColor` | Font colour picker |
| `FontName` | Font family selector |
| `FontSize` | Font size selector |
| `FormatPainter` | Format Painter tool |
| `Formats` | Format block dropdown |
| `FullScreen` | Full-screen toggle |
| `HorizontalLine` | Insert horizontal rule |
| `HorizontalSeparator` | Toolbar separator |
| `Image` | Image insertion tool |
| `ImportWord` | Import Word document |
| `Indent` | Indent |
| `InlineCode` | Inline code |
| `InsertCode` | Insert code |
| `Italic` | Italic toggle |
| `LineHeight` | Line height selector |
| `LowerCase` | Convert to lowercase |
| `Maximize` | Maximize |
| `Minimize` | Minimize |
| `NumberFormatList` | Number format list |
| `OrderedList` | Ordered list |
| `Outdent` | Outdent |
| `Preview` | Preview mode |
| `Print` | Print |
| `Redo` | Redo |
| `RemoveLink` | Remove hyperlink |
| `Separator` | Toolbar separator |
| `SourceCode` | HTML source view |
| `StrikeThrough` | Strikethrough |
| `SubScript` | Subscript |
| `SuperScript` | Superscript |
| `Underline` | Underline |
| `Undo` | Undo |
| `UnorderedList` | Unordered list |
| `UpperCase` | Convert to uppercase |
| `Video` | Video insertion tool |
---
## DialogType Enum Reference
Used by `ShowDialogAsync` and `CloseDialogAsync`.
| Value | Description |
|---|---|
| `ImportWord` | Word document import dialog |
| `InsertAudio` | Audio insertion dialog |
| `InsertImage` | Image insertion dialog |
| `InsertLink` | Hyperlink insertion dialog |
| `InsertTable` | Table insertion dialog |
| `InsertVideo` | Video insertion dialog |
````
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |