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