Syncfusion Blazor Smart Rich Text Editor
A comprehensive skill for implementing and configuring the Syncfusion Blazor Smart Rich Text Editor (SfSmartRichTextEditor) — an AI-powered WYSIWYG editor that extends the full-featured SfRichTextEditor with intelligent content assistance. Supports OpenAI, Azure OpenAI, Ollama, and custom AI backends. Provides a Smart Action dropdown toolbar, an AI query dialog (Alt+Enter), and a fully customizable AI Assistant popup via AssistViewSettings.
When to Use This Skill
Use this skill when the user needs to:
- Install and set up
SfSmartRichTextEditor in a Blazor Server or Web App project
- Configure an AI backend: OpenAI, Azure OpenAI, Ollama, or a custom
IChatClient
- Register
IChatInferenceService / SyncfusionAIService in Program.cs
- Use the Smart Action dropdown toolbar for AI commands (summarize, expand, adjust tone)
- Add
Name = "AI Commands" and Name = "AI Query" to ToolbarItemModel list to render AI toolbar buttons
- Open the AI Query dialog with
Alt+Enter for free-form AI prompts
- Configure
AssistViewSettings: Commands, Suggestions, Prompts, Placeholder, MaxPromptHistory, popup sizing
- Customize the AI Assistant popup (
BannerTemplate, HeaderToolbarSettings, PromptToolbarSettings, ResponseToolbarSettings)
- Handle AI events:
AIPromptRequested, AIResponseStopped, AIToolbarItemClicked, AIPopupOpening, AIPopupClosing
- Use AI Assistant methods:
ShowAIPopupAsync, HideAIPopupAsync, ExecuteAIPromptAsync, UpdateAIResponseAsync, GetAIPromptHistoryAsync, ClearAIPromptHistoryAsync
- Style or animate the AI Assistant popup (
.e-rte-aiquery-dialog)
- Use all inherited
SfRichTextEditor features: toolbar, images, tables, events, methods, data binding, paste cleanup, import/export, accessibility
Quick Start
1. Install NuGet packages:
dotnet add package Syncfusion.Blazor.SmartRichTextEditor
dotnet add package Syncfusion.Blazor.Themes
dotnet add package Microsoft.Extensions.AI
dotnet add package Microsoft.Extensions.AI.OpenAI
2. Register services in Program.cs:
using Syncfusion.Blazor;
using Syncfusion.Blazor.AI;
using Microsoft.Extensions.AI;
using OpenAI;
builder.Services.AddSyncfusionBlazor();
string openAIApiKey = "YOUR_API_KEY";
string openAIModel = "gpt-4";
OpenAIClient openAIClient = new OpenAIClient(openAIApiKey);
IChatClient chatClient = openAIClient.GetChatClient(openAIModel).AsIChatClient();
builder.Services.AddChatClient(chatClient);
builder.Services.AddSingleton<IChatInferenceService, SyncfusionAIService>();
3. Add to _Imports.razor:
@using Syncfusion.Blazor
@using Syncfusion.Blazor.SmartRichTextEditor
4. Add CSS/JS in App.razor (Server) or index.html (WASM):
<link href="_content/Syncfusion.Blazor.Themes/tailwind.css" rel="stylesheet" />
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js"></script>
5. Add the component:
@rendermode InteractiveServer
<SfSmartRichTextEditor>
<h2>Welcome to Smart Rich Text Editor</h2>
<p>Select text and use the Smart Action toolbar, or press Alt+Enter to open the AI Query dialog.</p>
<AssistViewSettings Placeholder="Ask AI to rewrite or generate content." />
</SfSmartRichTextEditor>
Navigation Guide
Getting Started & AI Service Setup
📄 Read: references/getting-started.md
- NuGet installation:
Syncfusion.Blazor.SmartRichTextEditor + Syncfusion.Blazor.Themes
- Full setup for Blazor Server App (Visual Studio and VS Code) and Blazor Web App (.NET 8+)
- OpenAI, Azure OpenAI, Ollama, and custom
IChatClient configuration in Program.cs
AddInteractiveServerComponents() registration pattern for Web App
- CSS theme and JS script references (.NET 6 through .NET 10)
- Adding the component with
AssistViewSettings
- Content retrieval methods (
GetTextAsync, GetCharCountAsync)
- Common setup issues and fixes
AI Backend Configuration
📄 Read: references/ai-backends.md
- OpenAI: API key, supported models (
gpt-4-turbo, gpt-4, gpt-3.5-turbo), OpenAIClient setup, environment variables and User Secrets
- Azure OpenAI: resource deployment,
AzureOpenAIClient + ApiKeyCredential, appsettings.json config, Managed Identity (production recommended), HIPAA/SOC 2 compliance, monitoring, cost optimization
- Ollama: local model installation (
mistral, llama2), OllamaApiClient + OllamaSharp NuGet, Docker Compose, GPU acceleration, model recommendations
- Custom
IChatClient: implementing IChatClient for internal/proprietary AI, registering in Program.cs, streaming responses, retry logic, error handling, corporate AI API example
AssistViewSettings — Properties
📄 Read: references/assist-view-settings.md
Commands (List<AICommands>): Smart Action dropdown with nested sub-commands and icon CSS
PopupMaxHeight / PopupWidth: control popup dimensions (CSS values or pixel numbers)
Placeholder: placeholder text in the AI prompt textarea
Prompts (List<AssistViewPrompt>): predefined prompt/response templates loaded into the popup
Suggestions (List<string>): quick suggestion chips shown in the AI popup
MaxPromptHistory: maximum conversation entries retained (default: 20)
BannerTemplate: custom branding/header RenderFragment for the AI popup
HeaderToolbarSettings / PromptToolbarSettings / ResponseToolbarSettings: toolbar customization with AssistViewToolbarItem
AssistViewSettings — Events
📄 Read: references/ai-events.md
AIPromptRequested (AssistViewPromptRequestedEventArgs): intercept/modify prompt before AI call; set Cancel=true to prevent; modify Response, PromptSuggestions, ResponseToolbarItems
AIResponseStopped (ResponseStoppedEventArgs): user clicked "Stop Responding"; provides DataIndex and Prompt
AIToolbarItemClicked (AssistViewToolbarItemClickedEventArgs): handle custom toolbar button clicks; access Item, DataIndex, Event; set Cancel=true
AIPopupOpening (BeforeOpenEventArgs): cancel popup opening with args.Cancel = true; access Element reference
AIPopupClosing (BeforeCloseEventArgs): cancel popup closing; access ClosedBy, IsInteracted, PreventFocus
AssistViewSettings — Methods
📄 Read: references/ai-methods.md
ShowAIPopupAsync(): open the AI Assistant popup programmatically
HideAIPopupAsync(): close the AI Assistant popup
ExecuteAIPromptAsync(string prompt): send a prompt programmatically (as if user typed it)
UpdateAIResponseAsync(string response, bool isFinalUpdate): stream or inject AI response; set isFinalUpdate=true to hide Stop button
GetAIPromptHistoryAsync(): retrieve all saved prompts/responses as AssistViewPrompt[] (chronological, limited to MaxPromptHistory)
ClearAIPromptHistoryAsync(): reset all conversation history
- Complete example combining all six methods with
@ref
AI Popup Appearance & CSS
📄 Read: references/ai-appearance.md
- CSS selectors for the AI popup:
.e-rte-aiquery-dialog, .e-aiassistview
- Customizing popup background, border, box-shadow
- Targeting
.e-view-header, .e-view-content .e-toolbar, .e-footer sub-sections for fine-grained control
- Full custom popup styling example
Toolbar Configuration
📄 Read: references/toolbar.md
- Enabling or disabling the toolbar with
RichTextEditorToolbarSettings.Enable
- Toolbar types: Expand, MultiRow, Scrollable, Popup
- Floating toolbar and offset configuration
- Toolbar position (top or bottom)
- Configuring toolbar items with
ToolbarItemModel
- Custom toolbar items (template-based)
Built-in Toolbar Tools Reference
📄 Read: references/built-in-tools.md
- Default toolbar items for
SfSmartRichTextEditor
- AI-specific toolbar items —
Name = "AI Commands" (Smart Action dropdown) and Name = "AI Query" (Ask AI button); must use Name property, NOT ToolbarCommand enum
- Complete list of all
ToolbarCommand enum values
- Text formatting, font & styling, alignment, lists, hyperlinks
- Image/table/link quick toolbar item commands using
SfSmartRichTextEditor
- Undo/redo, fullscreen, print, source code, preview tools
- Removing or reordering default toolbar items
Text Formatting
📄 Read: references/text-formatting.md
- Bold, italic, underline, strikethrough, subscript, superscript, inline code
- Text alignment (left, center, right, justify)
- Ordered/unordered lists with custom number and bullet styles
- Heading formats (H1–H6, paragraph, blockquote, code)
- Line height configuration
- Horizontal line, format painter, clear format
- Markdown auto-format (inline and block shortcuts)
Images, Video & Audio
📄 Read: references/images-and-media.md
- Image insertion from local machine or URL
RichTextEditorImageSettings: SaveUrl, Path, AllowedTypes, EnableResize
- Base64 vs server-side upload
- Image quick toolbar configuration
- Video and audio insertion and settings
Tables
📄 Read: references/tables.md
- Creating tables with
CreateTable toolbar item
RichTextEditorTableSettings: width, resize, custom styles
- Table quick toolbar: add/remove rows & columns, merge cells, properties
- Advanced table manipulation (cell selection, split, custom borders)
Editor Modes
📄 Read: references/editor-modes.md
- HTML editor mode (default WYSIWYG)
- Markdown editor mode (
EditorMode.Markdown)
- IFrame vs DIV rendering mode
- Source code view toggling
Inline Mode
📄 Read: references/inline-mode.md
- Enabling inline toolbar (
InlineMode)
- Inline toolbar display on text selection
- Use cases: comment editors, in-place content editing
Custom Tools & Exec Commands
📄 Read: references/custom-tools.md
- Adding custom toolbar buttons with
ToolbarItemModel and templates
- Executing commands programmatically with
ExecuteCommandAsync
- Slash commands (
/ trigger menu) configuration
- Format painter advanced settings (
RichTextEditorFormatPainterSettings)
Events (RTE)
📄 Read: references/events.md
RichTextEditorEvents child component usage and wiring pattern
- Lifecycle events:
Created, Destroyed
- Focus/interaction:
Focus, Blur, OnToolbarClick, SelectionChanged
- Content events:
ValueChange, BeforePasteCleanup, AfterPasteCleanup
- Toolbar lifecycle:
OnActionBegin, OnActionComplete
- Dialog events:
OnDialogOpen, DialogOpened, OnDialogClose, DialogClosed
- Quick toolbar:
OnQuickToolbarOpen, QuickToolbarOpened, QuickToolbarClosed
- Image events:
OnImageSelected, BeforeUploadImage, OnImageUploadSuccess, OnImageUploadFailed, ImageUploadChange, OnImageDrop, ImageDelete
- Media events:
FileSelected, FileUploading, FileUploadSuccess, FileUploadFailed, FileUploadChange, OnMediaDrop, MediaDeleted
- Resize events:
OnResizeStart, OnResizeStop
- Toolbar status:
UpdatedToolbarStatus
- Export events:
OnExport, OnExportFailure
- Slash menu:
SlashMenuItemSelecting
- Complete EventArgs class reference with all properties
Methods (RTE)
📄 Read: references/methods.md
- Focus & selection:
FocusAsync, FocusOutAsync, SaveSelectionAsync, RestoreSelectionAsync, SelectAllAsync, GetSelectionAsync
- Content retrieval:
GetTextAsync, GetSelectedHtmlAsync, GetCharCountAsync, GetXhtmlAsync
- Command execution: all
ExecuteCommandAsync overloads with typed args (image, link, table, video, audio, code block, format painter)
- Toolbar control:
EnableToolbarItem, DisableToolbarItem, RemoveToolbarItem
- Dialog & UI control:
ShowDialogAsync, CloseDialogAsync, ShowFullScreenAsync, PrintAsync, RefreshUIAsync, ShowSourceCodeAsync
- Undo/redo:
ClearUndoRedoAsync
- Full
CommandName, ToolbarCommand, and DialogType enum references
Properties (RTE)
📄 Read: references/properties.md
- Content & value:
Value, Placeholder, Readonly, Enabled, MaxLength, ShowCharCount
- Editor behaviour:
EditorMode, EnterKey, ShiftEnterKey, EnableTabKey, EnableAutoUrl, EnableMarkdownAutoFormat, EnableClipboardCleanup, EnableXhtml, EnableHtmlEncode, EnableResize
- Appearance & layout:
Height, Width, CssClass, ShowTooltip, FloatingToolbarOffset
- IFrame mode:
RichTextEditorIFrameSettings child component with Enable, Attributes, Resources
- Security & sanitization:
EnableHtmlSanitizer, AdditionalSanitizeAttributes, AdditionalSanitizeTags, DeniedSanitizeSelectors
- Keyboard & shortcuts:
KeyConfigure with full ShortcutKeys default bindings table
- Persistence & auto-save:
EnablePersistence, SaveInterval, AutoSaveOnIdle
- Undo/redo config:
UndoRedoSteps, UndoRedoTimer
- HTTP integration:
HttpClientInstance
- Full 38-property summary table
Data Binding & Value Management
📄 Read: references/data-binding.md
- Two-way binding with
@bind-Value
- One-way binding and programmatic value updates
ValueChange event for detecting edits
- Read-only mode (
Readonly property)
- Max length enforcement and character count display
Paste Cleanup
📄 Read: references/paste-and-cleanup.md
RichTextEditorPasteCleanupSettings configuration
- Stripping/keeping specific HTML attributes and styles on paste
- Forcing plain text paste
- Enter key behavior (
EnterKey, ShiftEnterKey)
- Undo/redo manager configuration
Import & Export
📄 Read: references/import-export.md
- Importing Word documents into the editor
- Exporting content to Word (.docx) and PDF
- HTTP client configuration for import/export services
- Mail merge with dynamic data
- WebAssembly performance optimizations for large documents
Accessibility & Globalization
📄 Read: references/accessibility-globalization.md
- WCAG 2.1 compliance details
- Keyboard shortcuts and navigation reference
- ARIA roles and screen reader support
- RTL layout (
EnableRtl)
- Localization and culture configuration
- XHTML validation
Common Patterns
Basic Smart Rich Text Editor with AI
@rendermode InteractiveServer
@using Syncfusion.Blazor.SmartRichTextEditor
<SfSmartRichTextEditor @bind-Value="@Content">
<AssistViewSettings Placeholder="Ask AI to rewrite or generate content." />
</SfSmartRichTextEditor>
@code {
private string Content { get; set; } = "<p>Start editing...</p>";
}
AI with custom Smart Action commands
<SfSmartRichTextEditor>
<AssistViewSettings Commands="@MyCommands" Suggestions="@QuickSuggestions" />
</SfSmartRichTextEditor>
@code {
private List<AICommands> MyCommands = new()
{
new AICommands { Text = "Summarize", Prompt = "Summarize this content concisely" },
new AICommands { Text = "Expand", Prompt = "Add more details and examples" },
new AICommands
{
Text = "Translate",
Items = new List<AICommands>
{
new AICommands { Text = "To French", Prompt = "Translate to French" },
new AICommands { Text = "To Spanish", Prompt = "Translate to Spanish" }
}
}
};
private List<string> QuickSuggestions = new()
{
"Fix grammar", "Make shorter", "More formal", "Simplify"
};
}
Programmatic AI popup control
<SfSmartRichTextEditor>
<AssistViewSettings @ref="AssistViewRef" MaxPromptHistory="10" />
</SfSmartRichTextEditor>
<button @onclick="OpenAI">Open AI</button>
<button @onclick="RunPrompt">Run Prompt</button>
@code {
private AssistViewSettings AssistViewRef;
private async Task OpenAI() =>
await AssistViewRef.ShowAIPopupAsync();
private async Task RunPrompt() =>
await AssistViewRef.ExecuteAIPromptAsync("Improve the clarity of this text");
}
Two-way bound editor with character count
<SfSmartRichTextEditor @bind-Value="@HtmlContent" ShowCharCount="true" MaxLength="2000">
<AssistViewSettings Placeholder="Ask AI for writing help." />
</SfSmartRichTextEditor>
@code {
private string HtmlContent { get; set; } = string.Empty;
}
Read-only display
<SfSmartRichTextEditor Value="@HtmlContent" Readonly="true">
<RichTextEditorToolbarSettings Enable="false" />
</SfSmartRichTextEditor>
Markdown editor mode
<SfSmartRichTextEditor EditorMode="EditorMode.Markdown" @bind-Value="@MarkdownContent">
<AssistViewSettings Placeholder="Ask AI to help with your Markdown content." />
</SfSmartRichTextEditor>
@code {
private string MarkdownContent { get; set; } = "**Hello** world!";
}
Handle AI prompt event to intercept requests
<SfSmartRichTextEditor>
<AssistViewSettings AIPromptRequested="OnAIPrompt" />
</SfSmartRichTextEditor>
@code {
private async Task OnAIPrompt(AssistViewPromptRequestedEventArgs args)
{
// Log, validate, or modify args.Prompt before it is sent to AI
Console.WriteLine($"Prompt: {args.Prompt}");
// To cancel: args.Cancel = true;
}
}
1---
2name: syncfusion-blazor-smart-rich-text-editor
3description: "Implements Syncfusion SfSmartRichTextEditor, an AI-enhanced WYSIWYG editor extending SfRichTextEditor in Blazor. Use this when configuring AI backends (OpenAI, Azure OpenAI, Ollama, custom IChatClient), Smart Action toolbar, AI query dialog, AssistViewSettings, AI popup events and methods, or any inherited Rich Text Editor features in Blazor Server and Web App."
4metadata:
5 author: "Syncfusion Inc"
6 version: "34.1.29"
7---
8
9# Syncfusion Blazor Smart Rich Text Editor
10
11A comprehensive skill for implementing and configuring the **Syncfusion Blazor Smart Rich Text Editor** (`SfSmartRichTextEditor`) — an AI-powered WYSIWYG editor that extends the full-featured `SfRichTextEditor` with intelligent content assistance. Supports OpenAI, Azure OpenAI, Ollama, and custom AI backends. Provides a Smart Action dropdown toolbar, an AI query dialog (`Alt+Enter`), and a fully customizable AI Assistant popup via `AssistViewSettings`.
12
13## When to Use This Skill
14
15Use this skill when the user needs to:
16- Install and set up `SfSmartRichTextEditor` in a Blazor Server or Web App project
17- Configure an AI backend: OpenAI, Azure OpenAI, Ollama, or a custom `IChatClient`
18- Register `IChatInferenceService` / `SyncfusionAIService` in `Program.cs`
19- Use the Smart Action dropdown toolbar for AI commands (summarize, expand, adjust tone)
20- Add `Name = "AI Commands"` and `Name = "AI Query"` to `ToolbarItemModel` list to render AI toolbar buttons
21- Open the AI Query dialog with `Alt+Enter` for free-form AI prompts
22- Configure `AssistViewSettings`: `Commands`, `Suggestions`, `Prompts`, `Placeholder`, `MaxPromptHistory`, popup sizing
23- Customize the AI Assistant popup (`BannerTemplate`, `HeaderToolbarSettings`, `PromptToolbarSettings`, `ResponseToolbarSettings`)
24- Handle AI events: `AIPromptRequested`, `AIResponseStopped`, `AIToolbarItemClicked`, `AIPopupOpening`, `AIPopupClosing`
25- Use AI Assistant methods: `ShowAIPopupAsync`, `HideAIPopupAsync`, `ExecuteAIPromptAsync`, `UpdateAIResponseAsync`, `GetAIPromptHistoryAsync`, `ClearAIPromptHistoryAsync`
26- Style or animate the AI Assistant popup (`.e-rte-aiquery-dialog`)
27- Use all inherited `SfRichTextEditor` features: toolbar, images, tables, events, methods, data binding, paste cleanup, import/export, accessibility
28
29## Quick Start
30
31**1. Install NuGet packages:**
32```bash
33dotnet add package Syncfusion.Blazor.SmartRichTextEditor
34dotnet add package Syncfusion.Blazor.Themes
35dotnet add package Microsoft.Extensions.AI
36dotnet add package Microsoft.Extensions.AI.OpenAI
37```
38
39**2. Register services in `Program.cs`:**
40```csharp
41using Syncfusion.Blazor;
42using Syncfusion.Blazor.AI;
43using Microsoft.Extensions.AI;
44using OpenAI;
45
46builder.Services.AddSyncfusionBlazor();
47
48string openAIApiKey = "YOUR_API_KEY";
49string openAIModel = "gpt-4";
50OpenAIClient openAIClient = new OpenAIClient(openAIApiKey);
51IChatClient chatClient = openAIClient.GetChatClient(openAIModel).AsIChatClient();
52builder.Services.AddChatClient(chatClient);
53builder.Services.AddSingleton<IChatInferenceService, SyncfusionAIService>();
54```
55
56**3. Add to `_Imports.razor`:**
57```razor
58@using Syncfusion.Blazor
59@using Syncfusion.Blazor.SmartRichTextEditor
60```
61
62**4. Add CSS/JS in `App.razor` (Server) or `index.html` (WASM):**
63```html
64<link href="_content/Syncfusion.Blazor.Themes/tailwind.css" rel="stylesheet" />
65<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js"></script>
66```
67
68**5. Add the component:**
69```razor
70@rendermode InteractiveServer
71
72<SfSmartRichTextEditor>
73 <h2>Welcome to Smart Rich Text Editor</h2>
74 <p>Select text and use the Smart Action toolbar, or press Alt+Enter to open the AI Query dialog.</p>
75 <AssistViewSettings Placeholder="Ask AI to rewrite or generate content." />
76</SfSmartRichTextEditor>
77```
78
79## Navigation Guide
80
81### Getting Started & AI Service Setup
82📄 **Read:** [references/getting-started.md](references/getting-started.md)
83- NuGet installation: `Syncfusion.Blazor.SmartRichTextEditor` + `Syncfusion.Blazor.Themes`
84- Full setup for Blazor Server App (Visual Studio and VS Code) and Blazor Web App (.NET 8+)
85- OpenAI, Azure OpenAI, Ollama, and custom `IChatClient` configuration in `Program.cs`
86- `AddInteractiveServerComponents()` registration pattern for Web App
87- CSS theme and JS script references (.NET 6 through .NET 10)
88- Adding the component with `AssistViewSettings`
89- Content retrieval methods (`GetTextAsync`, `GetCharCountAsync`)
90- Common setup issues and fixes
91
92### AI Backend Configuration
93📄 **Read:** [references/ai-backends.md](references/ai-backends.md)
94- **OpenAI**: API key, supported models (`gpt-4-turbo`, `gpt-4`, `gpt-3.5-turbo`), `OpenAIClient` setup, environment variables and User Secrets
95- **Azure OpenAI**: resource deployment, `AzureOpenAIClient` + `ApiKeyCredential`, `appsettings.json` config, Managed Identity (production recommended), HIPAA/SOC 2 compliance, monitoring, cost optimization
96- **Ollama**: local model installation (`mistral`, `llama2`), `OllamaApiClient` + `OllamaSharp` NuGet, Docker Compose, GPU acceleration, model recommendations
97- **Custom `IChatClient`**: implementing `IChatClient` for internal/proprietary AI, registering in `Program.cs`, streaming responses, retry logic, error handling, corporate AI API example
98
99### AssistViewSettings — Properties
100📄 **Read:** [references/assist-view-settings.md](references/assist-view-settings.md)
101- `Commands` (`List<AICommands>`): Smart Action dropdown with nested sub-commands and icon CSS
102- `PopupMaxHeight` / `PopupWidth`: control popup dimensions (CSS values or pixel numbers)
103- `Placeholder`: placeholder text in the AI prompt textarea
104- `Prompts` (`List<AssistViewPrompt>`): predefined prompt/response templates loaded into the popup
105- `Suggestions` (`List<string>`): quick suggestion chips shown in the AI popup
106- `MaxPromptHistory`: maximum conversation entries retained (default: 20)
107- `BannerTemplate`: custom branding/header `RenderFragment` for the AI popup
108- `HeaderToolbarSettings` / `PromptToolbarSettings` / `ResponseToolbarSettings`: toolbar customization with `AssistViewToolbarItem`
109
110### AssistViewSettings — Events
111📄 **Read:** [references/ai-events.md](references/ai-events.md)
112- `AIPromptRequested` (`AssistViewPromptRequestedEventArgs`): intercept/modify prompt before AI call; set `Cancel=true` to prevent; modify `Response`, `PromptSuggestions`, `ResponseToolbarItems`
113- `AIResponseStopped` (`ResponseStoppedEventArgs`): user clicked "Stop Responding"; provides `DataIndex` and `Prompt`
114- `AIToolbarItemClicked` (`AssistViewToolbarItemClickedEventArgs`): handle custom toolbar button clicks; access `Item`, `DataIndex`, `Event`; set `Cancel=true`
115- `AIPopupOpening` (`BeforeOpenEventArgs`): cancel popup opening with `args.Cancel = true`; access `Element` reference
116- `AIPopupClosing` (`BeforeCloseEventArgs`): cancel popup closing; access `ClosedBy`, `IsInteracted`, `PreventFocus`
117
118### AssistViewSettings — Methods
119📄 **Read:** [references/ai-methods.md](references/ai-methods.md)
120- `ShowAIPopupAsync()`: open the AI Assistant popup programmatically
121- `HideAIPopupAsync()`: close the AI Assistant popup
122- `ExecuteAIPromptAsync(string prompt)`: send a prompt programmatically (as if user typed it)
123- `UpdateAIResponseAsync(string response, bool isFinalUpdate)`: stream or inject AI response; set `isFinalUpdate=true` to hide Stop button
124- `GetAIPromptHistoryAsync()`: retrieve all saved prompts/responses as `AssistViewPrompt[]` (chronological, limited to `MaxPromptHistory`)
125- `ClearAIPromptHistoryAsync()`: reset all conversation history
126- Complete example combining all six methods with `@ref`
127
128### AI Popup Appearance & CSS
129📄 **Read:** [references/ai-appearance.md](references/ai-appearance.md)
130- CSS selectors for the AI popup: `.e-rte-aiquery-dialog`, `.e-aiassistview`
131- Customizing popup background, border, box-shadow
132- Targeting `.e-view-header`, `.e-view-content .e-toolbar`, `.e-footer` sub-sections for fine-grained control
133- Full custom popup styling example
134
135### Toolbar Configuration
136📄 **Read:** [references/toolbar.md](references/toolbar.md)
137- Enabling or disabling the toolbar with `RichTextEditorToolbarSettings.Enable`
138- Toolbar types: Expand, MultiRow, Scrollable, Popup
139- Floating toolbar and offset configuration
140- Toolbar position (top or bottom)
141- Configuring toolbar items with `ToolbarItemModel`
142- Custom toolbar items (template-based)
143
144### Built-in Toolbar Tools Reference
145📄 **Read:** [references/built-in-tools.md](references/built-in-tools.md)
146- Default toolbar items for `SfSmartRichTextEditor`
147- **AI-specific toolbar items** — `Name = "AI Commands"` (Smart Action dropdown) and `Name = "AI Query"` (Ask AI button); must use `Name` property, NOT `ToolbarCommand` enum
148- Complete list of all `ToolbarCommand` enum values
149- Text formatting, font & styling, alignment, lists, hyperlinks
150- Image/table/link quick toolbar item commands using `SfSmartRichTextEditor`
151- Undo/redo, fullscreen, print, source code, preview tools
152- Removing or reordering default toolbar items
153
154### Text Formatting
155📄 **Read:** [references/text-formatting.md](references/text-formatting.md)
156- Bold, italic, underline, strikethrough, subscript, superscript, inline code
157- Text alignment (left, center, right, justify)
158- Ordered/unordered lists with custom number and bullet styles
159- Heading formats (H1–H6, paragraph, blockquote, code)
160- Line height configuration
161- Horizontal line, format painter, clear format
162- Markdown auto-format (inline and block shortcuts)
163
164### Images, Video & Audio
165📄 **Read:** [references/images-and-media.md](references/images-and-media.md)
166- Image insertion from local machine or URL
167- `RichTextEditorImageSettings`: SaveUrl, Path, AllowedTypes, EnableResize
168- Base64 vs server-side upload
169- Image quick toolbar configuration
170- Video and audio insertion and settings
171
172### Tables
173📄 **Read:** [references/tables.md](references/tables.md)
174- Creating tables with `CreateTable` toolbar item
175- `RichTextEditorTableSettings`: width, resize, custom styles
176- Table quick toolbar: add/remove rows & columns, merge cells, properties
177- Advanced table manipulation (cell selection, split, custom borders)
178
179### Editor Modes
180📄 **Read:** [references/editor-modes.md](references/editor-modes.md)
181- HTML editor mode (default WYSIWYG)
182- Markdown editor mode (`EditorMode.Markdown`)
183- IFrame vs DIV rendering mode
184- Source code view toggling
185
186### Inline Mode
187📄 **Read:** [references/inline-mode.md](references/inline-mode.md)
188- Enabling inline toolbar (`InlineMode`)
189- Inline toolbar display on text selection
190- Use cases: comment editors, in-place content editing
191
192### Custom Tools & Exec Commands
193📄 **Read:** [references/custom-tools.md](references/custom-tools.md)
194- Adding custom toolbar buttons with `ToolbarItemModel` and templates
195- Executing commands programmatically with `ExecuteCommandAsync`
196- Slash commands (`/` trigger menu) configuration
197- Format painter advanced settings (`RichTextEditorFormatPainterSettings`)
198
199### Events (RTE)
200📄 **Read:** [references/events.md](references/events.md)
201- `RichTextEditorEvents` child component usage and wiring pattern
202- Lifecycle events: `Created`, `Destroyed`
203- Focus/interaction: `Focus`, `Blur`, `OnToolbarClick`, `SelectionChanged`
204- Content events: `ValueChange`, `BeforePasteCleanup`, `AfterPasteCleanup`
205- Toolbar lifecycle: `OnActionBegin`, `OnActionComplete`
206- Dialog events: `OnDialogOpen`, `DialogOpened`, `OnDialogClose`, `DialogClosed`
207- Quick toolbar: `OnQuickToolbarOpen`, `QuickToolbarOpened`, `QuickToolbarClosed`
208- Image events: `OnImageSelected`, `BeforeUploadImage`, `OnImageUploadSuccess`, `OnImageUploadFailed`, `ImageUploadChange`, `OnImageDrop`, `ImageDelete`
209- Media events: `FileSelected`, `FileUploading`, `FileUploadSuccess`, `FileUploadFailed`, `FileUploadChange`, `OnMediaDrop`, `MediaDeleted`
210- Resize events: `OnResizeStart`, `OnResizeStop`
211- Toolbar status: `UpdatedToolbarStatus`
212- Export events: `OnExport`, `OnExportFailure`
213- Slash menu: `SlashMenuItemSelecting`
214- Complete EventArgs class reference with all properties
215
216### Methods (RTE)
217📄 **Read:** [references/methods.md](references/methods.md)
218- Focus & selection: `FocusAsync`, `FocusOutAsync`, `SaveSelectionAsync`, `RestoreSelectionAsync`, `SelectAllAsync`, `GetSelectionAsync`
219- Content retrieval: `GetTextAsync`, `GetSelectedHtmlAsync`, `GetCharCountAsync`, `GetXhtmlAsync`
220- Command execution: all `ExecuteCommandAsync` overloads with typed args (image, link, table, video, audio, code block, format painter)
221- Toolbar control: `EnableToolbarItem`, `DisableToolbarItem`, `RemoveToolbarItem`
222- Dialog & UI control: `ShowDialogAsync`, `CloseDialogAsync`, `ShowFullScreenAsync`, `PrintAsync`, `RefreshUIAsync`, `ShowSourceCodeAsync`
223- Undo/redo: `ClearUndoRedoAsync`
224- Full `CommandName`, `ToolbarCommand`, and `DialogType` enum references
225
226### Properties (RTE)
227📄 **Read:** [references/properties.md](references/properties.md)
228- Content & value: `Value`, `Placeholder`, `Readonly`, `Enabled`, `MaxLength`, `ShowCharCount`
229- Editor behaviour: `EditorMode`, `EnterKey`, `ShiftEnterKey`, `EnableTabKey`, `EnableAutoUrl`, `EnableMarkdownAutoFormat`, `EnableClipboardCleanup`, `EnableXhtml`, `EnableHtmlEncode`, `EnableResize`
230- Appearance & layout: `Height`, `Width`, `CssClass`, `ShowTooltip`, `FloatingToolbarOffset`
231- IFrame mode: `RichTextEditorIFrameSettings` child component with `Enable`, `Attributes`, `Resources`
232- Security & sanitization: `EnableHtmlSanitizer`, `AdditionalSanitizeAttributes`, `AdditionalSanitizeTags`, `DeniedSanitizeSelectors`
233- Keyboard & shortcuts: `KeyConfigure` with full `ShortcutKeys` default bindings table
234- Persistence & auto-save: `EnablePersistence`, `SaveInterval`, `AutoSaveOnIdle`
235- Undo/redo config: `UndoRedoSteps`, `UndoRedoTimer`
236- HTTP integration: `HttpClientInstance`
237- Full 38-property summary table
238
239### Data Binding & Value Management
240📄 **Read:** [references/data-binding.md](references/data-binding.md)
241- Two-way binding with `@bind-Value`
242- One-way binding and programmatic value updates
243- `ValueChange` event for detecting edits
244- Read-only mode (`Readonly` property)
245- Max length enforcement and character count display
246
247### Paste Cleanup
248📄 **Read:** [references/paste-and-cleanup.md](references/paste-and-cleanup.md)
249- `RichTextEditorPasteCleanupSettings` configuration
250- Stripping/keeping specific HTML attributes and styles on paste
251- Forcing plain text paste
252- Enter key behavior (`EnterKey`, `ShiftEnterKey`)
253- Undo/redo manager configuration
254
255### Import & Export
256📄 **Read:** [references/import-export.md](references/import-export.md)
257- Importing Word documents into the editor
258- Exporting content to Word (.docx) and PDF
259- HTTP client configuration for import/export services
260- Mail merge with dynamic data
261- WebAssembly performance optimizations for large documents
262
263### Accessibility & Globalization
264📄 **Read:** [references/accessibility-globalization.md](references/accessibility-globalization.md)
265- WCAG 2.1 compliance details
266- Keyboard shortcuts and navigation reference
267- ARIA roles and screen reader support
268- RTL layout (`EnableRtl`)
269- Localization and culture configuration
270- XHTML validation
271
272## Common Patterns
273
274### Basic Smart Rich Text Editor with AI
275```razor
276@rendermode InteractiveServer
277@using Syncfusion.Blazor.SmartRichTextEditor
278
279<SfSmartRichTextEditor @bind-Value="@Content">
280 <AssistViewSettings Placeholder="Ask AI to rewrite or generate content." />
281</SfSmartRichTextEditor>
282
283@code {
284 private string Content { get; set; } = "<p>Start editing...</p>";
285}
286```
287
288### AI with custom Smart Action commands
289```razor
290<SfSmartRichTextEditor>
291 <AssistViewSettings Commands="@MyCommands" Suggestions="@QuickSuggestions" />
292</SfSmartRichTextEditor>
293
294@code {
295 private List<AICommands> MyCommands = new()
296 {
297 new AICommands { Text = "Summarize", Prompt = "Summarize this content concisely" },
298 new AICommands { Text = "Expand", Prompt = "Add more details and examples" },
299 new AICommands
300 {
301 Text = "Translate",
302 Items = new List<AICommands>
303 {
304 new AICommands { Text = "To French", Prompt = "Translate to French" },
305 new AICommands { Text = "To Spanish", Prompt = "Translate to Spanish" }
306 }
307 }
308 };
309
310 private List<string> QuickSuggestions = new()
311 {
312 "Fix grammar", "Make shorter", "More formal", "Simplify"
313 };
314}
315```
316
317### Programmatic AI popup control
318```razor
319<SfSmartRichTextEditor>
320 <AssistViewSettings @ref="AssistViewRef" MaxPromptHistory="10" />
321</SfSmartRichTextEditor>
322<button @onclick="OpenAI">Open AI</button>
323<button @onclick="RunPrompt">Run Prompt</button>
324
325@code {
326 private AssistViewSettings AssistViewRef;
327
328 private async Task OpenAI() =>
329 await AssistViewRef.ShowAIPopupAsync();
330
331 private async Task RunPrompt() =>
332 await AssistViewRef.ExecuteAIPromptAsync("Improve the clarity of this text");
333}
334```
335
336### Two-way bound editor with character count
337```razor
338<SfSmartRichTextEditor @bind-Value="@HtmlContent" ShowCharCount="true" MaxLength="2000">
339 <AssistViewSettings Placeholder="Ask AI for writing help." />
340</SfSmartRichTextEditor>
341
342@code {
343 private string HtmlContent { get; set; } = string.Empty;
344}
345```
346
347### Read-only display
348```razor
349<SfSmartRichTextEditor Value="@HtmlContent" Readonly="true">
350 <RichTextEditorToolbarSettings Enable="false" />
351</SfSmartRichTextEditor>
352```
353
354### Markdown editor mode
355```razor
356<SfSmartRichTextEditor EditorMode="EditorMode.Markdown" @bind-Value="@MarkdownContent">
357 <AssistViewSettings Placeholder="Ask AI to help with your Markdown content." />
358</SfSmartRichTextEditor>
359
360@code {
361 private string MarkdownContent { get; set; } = "**Hello** world!";
362}
363```
364
365### Handle AI prompt event to intercept requests
366```razor
367<SfSmartRichTextEditor>
368 <AssistViewSettings AIPromptRequested="OnAIPrompt" />
369</SfSmartRichTextEditor>
370
371@code {
372 private async Task OnAIPrompt(AssistViewPromptRequestedEventArgs args)
373 {
374 // Log, validate, or modify args.Prompt before it is sent to AI
375 Console.WriteLine($"Prompt: {args.Prompt}");
376 // To cancel: args.Cancel = true;
377 }
378}
379```