# rich-text-editor-paste-cleanup

> Rich text editor cleaning Word formatting during paste actions to retain consistent editor styles.

**Framework:** blazor  **Component:** RichTextEditor  **Variant:** paste-cleanup

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/blazor/rich-text-editor-paste-cleanup.json
```

**Install Package(s)**

```bash
dotnet add package Syncfusion.Blazor.RichTextEditor
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/rich-text-editor-paste-cleanup/RichTextEditor.razor

```razor
@page "/rich-text-editor/paste-cleanup"
@using Syncfusion.Blazor.DropDowns
@using Syncfusion.Blazor.RichTextEditor
<div class="col-lg-8 control-section">
    <div class="">
        <SfRichTextEditor @bind-Value="@Value">
            <RichTextEditorPasteCleanupSettings Prompt="@Prompt" PlainText="@Plaintext" KeepFormat="@Keepformat" DeniedAttributes="@Deniedattr"
                                                AllowedStyleProperties="@Allowedstyle" DeniedTags="@Deniedtags" />
        </SfRichTextEditor>
    </div>
</div>
<PropertyPanel ControlSecClass="col-lg-8">
        <table id="property" title="Properties">
            <tbody>
                <tr>
                    <td>
                        <div>Format Option</div>
                    </td>
                    <td>
                        <div>
                            <SfDropDownList @ref="DropObj" TItem="PasteOptions" TValue="string" PopupHeight="200px" @bind-Value="PasteDefaultValue" DataSource="@Options">
                                <DropDownListFieldSettings Text="Text" Value="Id" />
                                <DropDownListEvents TValue="string" TItem="PasteOptions" ValueChange="ValueChange" />
                            </SfDropDownList>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div>Denied Tags </div>
                    </td>
                    <td>
                        <div>
                            <input type="text" @bind="@DeniedTagsText" class="e-input" @onblur="DeniedTagsblur" placeholder="img[!href], h1" aria-label="Denied Tags"/>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div>Denied Attributes </div>
                    </td>
                    <td>
                        <div>
                            <input type="text" @bind="@DeniedAttributesText" class="e-input" @onblur="DeniedAttributesblur" placeholder="id, title" aria-label="Denied Attributes"/>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div>Allowed Style Properties </div>
                    </td>
                    <td>
                        <div>
                            <input type="text" @bind="@AllowedStylePropertiesText" class="e-input" @onblur="AllowedStylePropertiesblur" placeholder="href, style" aria-label="Style Properties"/>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
</PropertyPanel>
<style>
    .sf-property-section table td {
        width: 50%;
    }
    .sf-property-section table div {
        padding-left: 10px;
        padding-top: 10px;
    }
    .sf-property-section {
        padding-top: 20px;
    }
    .sf-property-section .e-icons.e-settings,
    .sf-property-panel-header {
        height: 0;
    }
</style>
@code {
    private SfDropDownList<string, PasteOptions>? DropObj;
    private string PasteDefaultValue { get; set; } = "prompt";
    private bool Prompt = true;
    private bool Plaintext = false;
    private bool Keepformat = false;
    private string? DeniedTagsText { get; set; }
    private string? DeniedAttributesText { get; set; }
    private string? AllowedStylePropertiesText { get; set; }
    private string[]? Deniedtags { get; set; }
    private string[]? Deniedattr { get; set; }
    private string[] Allowedstyle { get; set; } = new string[]
    {
        "background", "background-color", "border", "border-bottom", "border-left", "border-radius",
        "border-right", "border-style", "border-top", "border-width", "clear", "color", "cursor",
        "direction", "display", "float", "font", "font-family", "font-size", "font-weight", "font-style",
        "height", "left", "line-height", "margin", "margin-top", "margin-left",
        "margin-right", "margin-bottom", "max-height", "max-width", "min-height", "min-width",
        "overflow", "overflow-x", "overflow-y", "padding", "padding-bottom", "padding-left", "padding-right",
        "padding-top", "position", "right", "table-layout", "text-align", "text-decoration", "text-indent",
        "top", "vertical-align", "visibility", "white-space", "width"
    };
    private string Value { get; set; } = @"<h4>Paste Cleanup in Rich Text Editor<br></h4><p>The Rich Text Editor automatically <strong>cleans up formatted content</strong> when you paste from external sources like Word, Google Docs, or web pages.</p><p><b>Paste Cleanup properties:</b></p><ul>
                <li><strong>Prompt </strong>- specifies whether to enable the prompt when pasting in Rich Text Editor
                </li>
                <li><strong>Plain Text </strong>- specifies whether to paste as plain text or not in Rich Text Editor.
                </li>
                <li><strong>Keep Format</strong>- specifies whether to keep or remove the format when pasting in Rich Text Editor.
                </li>
                <li><strong>Denied Tags</strong> - specifies the tags to restrict when pasting in Rich Text Editor.
                </li>
                <li><strong>Denied Attributes</strong> - specifies the attributes to restrict when pasting in Rich Text Editor.
                </li>
                <li><strong>Allowed Style Properties</strong> - specifies the allowed style properties when pasting in Rich Text Editor.
                </li>
            </ul><p><span><strong>Try It Out!</strong></span></p><p>Copy content from a web page or document and paste it here. The editor will display a prompt and allow you to input your options.</p>";
    private class PasteOptions
    {
        public string? Id { get; set; }
        public string? Text { get; set; }
    }
    private List<PasteOptions> Options = new List<PasteOptions>()
    {
        new PasteOptions(){ Id= "prompt", Text= "Prompt" },
        new PasteOptions(){ Id= "plainText", Text= "Plain Text" },
        new PasteOptions(){ Id= "keepFormat", Text= "Keep Format" },
        new PasteOptions(){ Id= "cleanFormat", Text= "Clean Format" },
    };
    private void ValueChange(@Syncfusion.Blazor.DropDowns.ChangeEventArgs<string, PasteOptions> args)
    {
        if (args.Value == "prompt")
        {
            this.Prompt = true;
        }
        else if (args.Value == "plainText")
        {
            this.Prompt = false;
            this.Plaintext = true;
        }
        else if (args.Value == "keepFormat")
        {
            this.Prompt = false;
            this.Plaintext = false;
            this.Keepformat = true;
        }
        else if (args.Value == "cleanFormat")
        {
            this.Prompt = false;
            this.Plaintext = false;
            this.Keepformat = false;
        }
    }
    private void DeniedTagsblur(Microsoft.AspNetCore.Components.Web.FocusEventArgs e)
    {
        if (this.DeniedTagsText != null)
        {
            this.Deniedtags = this.DeniedTagsText.Split(',');
        }
    }
    private void DeniedAttributesblur(Microsoft.AspNetCore.Components.Web.FocusEventArgs e)
    {
        if (this.DeniedAttributesText != null)
        {
            this.Deniedattr = this.DeniedAttributesText.Split(',');
        }
    }
    private void AllowedStylePropertiesblur(Microsoft.AspNetCore.Components.Web.FocusEventArgs e)
    {
        if (this.AllowedStylePropertiesText != null)
        {
            this.Allowedstyle = this.AllowedStylePropertiesText.Split(',');
        }
    }
}
```
