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/paste-and-cleanup.md
View on GitHub# Paste and Cleanup
## Table of Contents
- [Paste Cleanup Settings](#paste-cleanup-settings)
- [Paste Modes](#paste-modes)
- [Denied Tags and Attributes](#denied-tags-and-attributes)
- [Allowed Style Properties](#allowed-style-properties)
- [Accessing Pasted Content](#accessing-pasted-content)
- [Pasting Large Content (SignalR Buffer)](#pasting-large-content-signalr-buffer)
- [Enter Key Behaviour](#enter-key-behaviour)
- [Undo / Redo Manager](#undo--redo-manager)
---
## Paste Cleanup Settings
> **Security:** Always keep `EnableHtmlSanitizer="true"` when accepting untrusted content. Use `DeniedTags` to block `script`, `iframe`, `object`, `embed`.
The `RichTextEditorPasteCleanupSettings` child component controls how content pasted from Word, Outlook, Excel, or other websites is sanitised before insertion.
| Property | Type | Default | Description |
|---|---|---|---|
| `Prompt` | `bool` | `false` | Show a dialog offering Keep / Clean / Plain Text options |
| `PlainText` | `bool` | `false` | Strip all tags and paste as plain text |
| `KeepFormat` | `bool` | `true` | Retain the source formatting (filtered by `AllowedStyleProperties`) |
| `DeniedTags` | `string[]` | `null` | HTML tags to remove from pasted content |
| `DeniedAttributes` | `string[]` | `null` | HTML attributes to strip from pasted content |
| `AllowedStyleProperties` | `string[]` | (extensive list) | CSS properties to preserve when `KeepFormat` is `true` |
> **Mutual exclusivity rules:**
> - `Prompt = true` overrides `PlainText` and `KeepFormat`
> - `PlainText = true` requires `Prompt = false`; ignores `KeepFormat` and `AllowedStyleProperties`
> - `AllowedStyleProperties` is only applied when `KeepFormat = true`
---
## Paste Modes
### Prompt Dialog
Lets the user choose how to paste each time:
```razor
<SfRichTextEditor>
<RichTextEditorPasteCleanupSettings Prompt="true" />
</SfRichTextEditor>
```
Prompt options:
1. **Keep** — preserve source formatting (respects `AllowedStyleProperties` / `DeniedTags`)
2. **Clean** — strip inline styles, keep structural tags
3. **Plain Text** — discard all markup
### Plain Text
Always paste without any markup:
```razor
<SfRichTextEditor>
<RichTextEditorPasteCleanupSettings PlainText="true" Prompt="false" />
</SfRichTextEditor>
```
### Keep Format (Default)
Retain source formatting filtered through the allowed-style list:
```razor
<SfRichTextEditor>
<RichTextEditorPasteCleanupSettings KeepFormat="true" PlainText="false" Prompt="false" />
</SfRichTextEditor>
```
### Clean Format
Strip all inline styles but keep structural HTML tags (`<p>`, `<ul>`, `<table>`, etc.):
```razor
<!-- All three flags false = clean format -->
<SfRichTextEditor>
<RichTextEditorPasteCleanupSettings Prompt="false" PlainText="false" KeepFormat="false" />
</SfRichTextEditor>
```
---
## Denied Tags and Attributes
Remove specific tags or attributes from pasted content:
```razor
<SfRichTextEditor>
<RichTextEditorPasteCleanupSettings
DeniedTags="@DeniedTags"
DeniedAttributes="@DeniedAttrs" />
</SfRichTextEditor>
@code {
// "a" → remove all anchor tags
// "a[!href]" → remove anchors that have no href
// "a[href,target]" → remove anchors that have href AND target
private string[] DeniedTags = new[] { "a[!href]", "script", "style" };
private string[] DeniedAttrs = new[] { "class", "id", "title" };
}
```
> `DeniedTags` and `DeniedAttributes` apply in both KeepFormat and Clean Format modes, but **not** when `PlainText = true` (plain text already has no tags).
---
## Allowed Style Properties
Restrict which CSS properties survive when `KeepFormat = true`:
```razor
<SfRichTextEditor>
<RichTextEditorPasteCleanupSettings
KeepFormat="true"
AllowedStyleProperties="@AllowedStyles" />
</SfRichTextEditor>
@code {
// Only colour and font-size will be preserved; all other inline styles are removed
private string[] AllowedStyles = new[] { "color", "font-size", "font-weight" };
}
```
---
## Accessing Pasted Content
Use the `AfterPasteCleanup` event to inspect or modify the cleaned HTML after it has been sanitised but before it is committed:
```razor
<SfRichTextEditor>
<RichTextEditorEvents AfterPasteCleanup="@OnPasted" />
</SfRichTextEditor>
@code {
private void OnPasted(PasteCleanupArgs args)
{
// args.Value holds the sanitised HTML string
Console.WriteLine("Pasted HTML: " + args.Value);
}
}
```
---
## Pasting Large Content (SignalR Buffer)
Pasting large blocks of text over SignalR can trigger a reconnect warning. Increase the maximum receive message size in `Program.cs`:
```csharp
// Blazor Server (Program.cs)
builder.Services.AddSignalR(options =>
{
options.MaximumReceiveMessageSize = 1_024_000_000; // ~1 GB
});
```
```csharp
// Blazor WebAssembly (Program.cs)
builder.Services.AddSignalR(options =>
{
options.MaximumReceiveMessageSize = 1_024_000_000;
});
await builder.Build().RunAsync();
```
---
## Enter Key Behaviour
Customise the HTML tag inserted when `Enter` or `Shift+Enter` is pressed:
| Property | Default | Options | Description |
|---|---|---|---|
| `EnterKey` | `EnterKeyTag.P` | `P`, `DIV`, `BR` | Tag created on `Enter` |
| `ShiftEnterKey` | `ShiftEnterKeyTag.BR` | `BR`, `P`, `DIV` | Tag created on `Shift+Enter` |
```razor
<SfRichTextEditor EnterKey="EnterKeyTag.DIV" ShiftEnterKey="ShiftEnterKeyTag.P">
<div>Pressing Enter inserts a DIV; Shift+Enter inserts a P.</div>
</SfRichTextEditor>
```
> Inside a `<pre>` (code block) tag, Enter always inserts `<br>` regardless of `EnterKey`. Press Enter twice to exit the `<pre>` block.
---
## Undo / Redo Manager
### Configure Steps and Timer
```razor
<SfRichTextEditor UndoRedoSteps="50" UndoRedoTimer="400">
<!-- Keeps 50 undo steps, records every 400 ms -->
</SfRichTextEditor>
```
| Property | Default | Description |
|---|---|---|
| `UndoRedoSteps` | `30` | Number of undo/redo history entries to retain; set to `0` to disable |
| `UndoRedoTimer` | `300` | Interval (ms) between undo history snapshots |
### Clear the Stack Programmatically
```razor
<SfRichTextEditor @ref="Rte">
<p>Editor content here.</p>
</SfRichTextEditor>
<button @onclick="ClearHistory">Clear History</button>
@code {
private SfRichTextEditor Rte = default!;
private async Task ClearHistory()
{
await Rte.ClearUndoRedoAsync();
}
}
```
### Track Custom Tool Actions in Undo Stack
Pass `ExecuteCommandOption { Undo = true }` to include programmatic insertions in the undo history:
```razor
@code {
private async Task InsertTemplate()
{
await Rte.ExecuteCommandAsync(
CommandName.InsertHTML,
"<p><strong>Template text</strong></p>",
new ExecuteCommandOption { Undo = true });
}
}
```
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 |