# rich-text-editor-format-painter

> Rich text editor with a file browser for inserting server images from available storage.

**Framework:** blazor  **Component:** RichTextEditor  **Variant:** format-painter

## 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-format-painter.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-format-painter/RichTextEditor.razor

```razor
@page "/rich-text-editor/format-painter"
@using Syncfusion.Blazor.Popups
@using Syncfusion.Blazor.RichTextEditor
@using Syncfusion.Blazor.DropDowns
@using System.ComponentModel.DataAnnotations;
@using System.Text.RegularExpressions
<div class="col-lg-8 control-section" id="rte-format-painter">
    <SfRichTextEditor @ref="EditorRef">
        <RichTextEditorToolbarSettings Items="@tools" />
        <RichTextEditorFormatPainterSettings AllowedFormats="@allowedFormats" DeniedFormats="@deniedFormats" />
        <h3>Format Painter in Rich Text Editor</h3><p>The <strong data-start="50" data-end="68">Format Painter</strong> allows you to quickly copy and apply text formatting within the editor, saving time and ensuring consistency.</p><h5>How to Use Format Painter?</h5>
        <ul><li><strong>Select the text</strong> with the formatting you want to copy.</li><li>Click the <strong>Format Painter</strong> button (paintbrush icon) in the toolbar.</li><li>The cursor changes to a <strong>paintbrush</strong> icon.</li><li><strong>Click and drag</strong> over the text where you want to apply the copied format.</li><li>Release the mouse button, and the formatting will be applied.</li></ul><h5>Why Use Format Painter?</h5>
        <ul><li><strong>Saves time</strong> when formatting large documents.</li><li><strong>Ensures consistency</strong> in text styles. </li><li><strong>Easy to use</strong> for writers, editors, and content creators.</li></ul>
    </SfRichTextEditor>
</div>
<PropertyPanel ControlSecClass="col-lg-8" CollapseChanged="CollapseChange">
    <div id="property" title="Properties" class="property-panel-table">
        <table id="property" title="Properties">
            <tbody>
                <tr>
                    <td>
                        <div>Allowed Formats</div>
                    </td>
                    <td>
                        <div>
                            <input type="text" @bind="@allowedFormatText" class="e-input" @onblur="allowedFormatsPainterBlur" placeholder="span; strong; em; sup; sub; code;" />
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div>Denied Formats</div>
                    </td>
                    <td>
                        <div>
                            <input type="text" @bind="@deniedFormatText" class="e-input" @onblur="deniedFormatPainterBlur" placeholder="span(important)[title]{background-color,color};" />
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</PropertyPanel>
<style>
    .sf-property-section {
        padding-top: 20px;
    }
</style>
@code {
    private SfRichTextEditor? EditorRef;
    private string? allowedFormatText { get; set; }
    private string? allowedFormats { get; set; } = "b; em; font; sub; sup; kbd; i; s; u; code; strong; span; p; div; h1; h2; h3; h4; h5; h6; blockquote; ol; ul; li; pre;";
    private string? deniedFormats { get; set; } = null;
    private string? deniedFormatText { get; set; }
    private void allowedFormatsPainterBlur ( Microsoft.AspNetCore.Components.Web.FocusEventArgs e )
    {
        if (!string.IsNullOrWhiteSpace (this.allowedFormatText))
        {
            this.allowedFormats = this.allowedFormatText;
        }
        else
        {
            this.allowedFormats = "b; em; font; sub; sup; kbd; i; s; u; code; strong; span; p; div; h1; h2; h3; h4; h5; h6; blockquote; table; thead; tbody; tr; td; th; ol; ul; li; pre; (*)[*]{*}";
        }
    }
    private void deniedFormatPainterBlur ( Microsoft.AspNetCore.Components.Web.FocusEventArgs e )
    {
        if (!string.IsNullOrWhiteSpace (this.deniedFormatText))
        {
            this.deniedFormats = this.deniedFormatText;
        }
        else
        {
            this.deniedFormats = null;
        }
    }
    private List<ToolbarItemModel> tools = new List<ToolbarItemModel> ()
    {
        new ToolbarItemModel() { Command = ToolbarCommand.FormatPainter },
        new ToolbarItemModel() { Command = ToolbarCommand.Bold },
        new ToolbarItemModel() { Command = ToolbarCommand.Italic },
        new ToolbarItemModel() { Command = ToolbarCommand.Underline },
        new ToolbarItemModel() { Command = ToolbarCommand.StrikeThrough },
        new ToolbarItemModel() { Command = ToolbarCommand.FontName }
    };
    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);
            StateHasChanged();
            this.EditorRef?.RefreshUIAsync();
        }
    }
    private void CollapseChange(bool collapse)
    {
        StateHasChanged();
        this.EditorRef?.RefreshUIAsync();
    }
}

```
