syncfusion-blazor-smart-rich-text-editor

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Syncfusion Blazor Smart Rich Text Editor

Syncfusion Blazor 智能富文本编辑器

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
.
本技能全面介绍如何实现和配置Syncfusion Blazor 智能富文本编辑器
SfSmartRichTextEditor
)——一款AI驱动的WYSIWYG编辑器,在功能完备的
SfRichTextEditor
基础上扩展了智能内容辅助能力。支持OpenAI、Azure OpenAI、Ollama及自定义AI后端,提供智能操作下拉工具栏、AI查询对话框(快捷键
Alt+Enter
),并可通过
AssistViewSettings
完全自定义AI助手弹窗。

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
当用户需要以下操作时,可使用本技能:
  • 在Blazor Server或Web App项目中安装并设置
    SfSmartRichTextEditor
  • 配置AI后端:OpenAI、Azure OpenAI、Ollama或自定义
    IChatClient
  • Program.cs
    中注册
    IChatInferenceService
    /
    SyncfusionAIService
  • 使用智能操作下拉工具栏执行AI命令(总结、扩展、调整语气)
  • ToolbarItemModel
    列表中添加
    Name = "AI Commands"
    Name = "AI Query"
    以渲染AI工具栏按钮
  • 使用
    Alt+Enter
    打开AI查询对话框,输入自由格式的AI提示词
  • 配置
    AssistViewSettings
    Commands
    Suggestions
    Prompts
    Placeholder
    MaxPromptHistory
    、弹窗尺寸
  • 自定义AI助手弹窗(
    BannerTemplate
    HeaderToolbarSettings
    PromptToolbarSettings
    ResponseToolbarSettings
  • 处理AI事件:
    AIPromptRequested
    AIResponseStopped
    AIToolbarItemClicked
    AIPopupOpening
    AIPopupClosing
  • 使用AI助手方法:
    ShowAIPopupAsync
    HideAIPopupAsync
    ExecuteAIPromptAsync
    UpdateAIResponseAsync
    GetAIPromptHistoryAsync
    ClearAIPromptHistoryAsync
  • 为AI助手弹窗设置样式或动画(
    .e-rte-aiquery-dialog
  • 使用所有继承自
    SfRichTextEditor
    的功能:工具栏、图片、表格、事件、方法、数据绑定、粘贴清理、导入/导出、无障碍支持

Quick Start

快速开始

1. Install NuGet packages:
bash
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
:
csharp
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
:
razor
@using Syncfusion.Blazor
@using Syncfusion.Blazor.SmartRichTextEditor
4. Add CSS/JS in
App.razor
(Server) or
index.html
(WASM):
html
<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:
razor
@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>
1. 安装NuGet包:
bash
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. 在
Program.cs
中注册服务:
csharp
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. 添加到
_Imports.razor
razor
@using Syncfusion.Blazor
@using Syncfusion.Blazor.SmartRichTextEditor
4. 在
App.razor
(Server端)或
index.html
(WASM端)中添加CSS/JS:
html
<link href="_content/Syncfusion.Blazor.Themes/tailwind.css" rel="stylesheet" />
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js"></script>
5. 添加组件:
razor
@rendermode InteractiveServer

<SfSmartRichTextEditor>
    <h2>欢迎使用智能富文本编辑器</h2>
    <p>选中文本后使用智能操作工具栏,或按Alt+Enter打开AI查询对话框。</p>
    <AssistViewSettings Placeholder="请让AI重写或生成内容。" />
</SfSmartRichTextEditor>

Navigation Guide

导航指南

Getting Started & AI Service Setup

快速入门与AI服务设置

📄 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
📄 阅读: references/getting-started.md
  • NuGet安装:
    Syncfusion.Blazor.SmartRichTextEditor
    +
    Syncfusion.Blazor.Themes
  • Blazor Server App(Visual Studio和VS Code)及Blazor Web App(.NET 8+)的完整设置流程
  • Program.cs
    中配置OpenAI、Azure OpenAI、Ollama及自定义
    IChatClient
  • Web App的
    AddInteractiveServerComponents()
    注册模式
  • CSS主题与JS脚本引用(.NET 6至.NET 10)
  • 添加带
    AssistViewSettings
    的组件
  • 内容检索方法(
    GetTextAsync
    GetCharCountAsync
  • 常见设置问题及修复方案

AI Backend Configuration

AI后端配置

📄 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
📄 阅读: references/ai-backends.md
  • OpenAI:API密钥、支持的模型(
    gpt-4-turbo
    gpt-4
    gpt-3.5-turbo
    )、
    OpenAIClient
    设置、环境变量与用户机密
  • Azure OpenAI:资源部署、
    AzureOpenAIClient
    +
    ApiKeyCredential
    appsettings.json
    配置、托管标识(推荐生产环境使用)、HIPAA/SOC 2合规性、监控、成本优化
  • Ollama:本地模型安装(
    mistral
    llama2
    )、
    OllamaApiClient
    +
    OllamaSharp
    NuGet包、Docker Compose、GPU加速、模型推荐
  • 自定义
    IChatClient
    :为内部/专有AI实现
    IChatClient
    、在
    Program.cs
    中注册、流式响应、重试逻辑、错误处理、企业AI API示例

AssistViewSettings — Properties

AssistViewSettings — 属性

📄 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
📄 阅读: references/assist-view-settings.md
  • Commands
    List<AICommands>
    ):带嵌套子命令和图标CSS的智能操作下拉菜单
  • PopupMaxHeight
    /
    PopupWidth
    :控制弹窗尺寸(CSS值或像素数)
  • Placeholder
    :AI提示文本框中的占位符文本
  • Prompts
    List<AssistViewPrompt>
    ):加载到弹窗中的预定义提示词/响应模板
  • Suggestions
    List<string>
    ):AI弹窗中显示的快速建议标签
  • MaxPromptHistory
    :保留的最大对话条目数(默认:20)
  • BannerTemplate
    :AI弹窗的自定义品牌/页眉
    RenderFragment
  • HeaderToolbarSettings
    /
    PromptToolbarSettings
    /
    ResponseToolbarSettings
    :使用
    AssistViewToolbarItem
    自定义工具栏

AssistViewSettings — Events

AssistViewSettings — 事件

📄 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
📄 阅读: references/ai-events.md
  • AIPromptRequested
    AssistViewPromptRequestedEventArgs
    ):在调用AI前拦截/修改提示词;设置
    Cancel=true
    可阻止请求;修改
    Response
    PromptSuggestions
    ResponseToolbarItems
  • AIResponseStopped
    ResponseStoppedEventArgs
    ):用户点击“停止响应”;提供
    DataIndex
    Prompt
  • AIToolbarItemClicked
    AssistViewToolbarItemClickedEventArgs
    ):处理自定义工具栏按钮点击;访问
    Item
    DataIndex
    Event
    ;设置
    Cancel=true
  • AIPopupOpening
    BeforeOpenEventArgs
    ):设置
    args.Cancel = true
    可取消弹窗打开;访问
    Element
    引用
  • AIPopupClosing
    BeforeCloseEventArgs
    ):取消弹窗关闭;访问
    ClosedBy
    IsInteracted
    PreventFocus

AssistViewSettings — Methods

AssistViewSettings — 方法

📄 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
📄 阅读: references/ai-methods.md
  • ShowAIPopupAsync()
    :以编程方式打开AI助手弹窗
  • HideAIPopupAsync()
    :关闭AI助手弹窗
  • ExecuteAIPromptAsync(string prompt)
    :以编程方式发送提示词(模拟用户输入)
  • UpdateAIResponseAsync(string response, bool isFinalUpdate)
    :流式传输或注入AI响应;设置
    isFinalUpdate=true
    可隐藏停止按钮
  • GetAIPromptHistoryAsync()
    :以
    AssistViewPrompt[]
    形式检索所有保存的提示词/响应(按时间顺序,受
    MaxPromptHistory
    限制)
  • ClearAIPromptHistoryAsync()
    :重置所有对话历史
  • 结合
    @ref
    使用全部六种方法的完整示例

AI Popup Appearance & CSS

AI弹窗外观与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
📄 阅读: references/ai-appearance.md
  • AI弹窗的CSS选择器:
    .e-rte-aiquery-dialog
    .e-aiassistview
  • 自定义弹窗背景、边框、阴影
  • 针对
    .e-view-header
    .e-view-content .e-toolbar
    .e-footer
    子区域进行精细化控制
  • 完整的自定义弹窗样式示例

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)
📄 阅读: references/toolbar.md
  • 使用
    RichTextEditorToolbarSettings.Enable
    启用或禁用工具栏
  • 工具栏类型:展开式、多行式、滚动式、弹出式
  • 浮动工具栏与偏移配置
  • 工具栏位置(顶部或底部)
  • 使用
    ToolbarItemModel
    配置工具栏项
  • 自定义工具栏项(基于模板)

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
📄 阅读: references/built-in-tools.md
  • SfSmartRichTextEditor
    的默认工具栏项
  • AI专属工具栏项——
    Name = "AI Commands"
    (智能操作下拉菜单)和
    Name = "AI Query"
    (询问AI按钮);必须使用
    Name
    属性,而非
    ToolbarCommand
    枚举
  • 所有
    ToolbarCommand
    枚举值的完整列表
  • 文本格式、字体与样式、对齐方式、列表、超链接
  • 使用
    SfSmartRichTextEditor
    的图片/表格/链接快速工具栏项命令
  • 撤销/重做、全屏、打印、源代码、预览工具
  • 删除或重新排序默认工具栏项

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)
📄 阅读: references/text-formatting.md
  • 加粗、斜体、下划线、删除线、下标、上标、行内代码
  • 文本对齐(左对齐、居中、右对齐、两端对齐)
  • 有序/无序列表,支持自定义编号和项目符号样式
  • 标题格式(H1–H6、段落、块引用、代码块)
  • 行高配置
  • 水平线、格式刷、清除格式
  • Markdown自动格式(行内和块级快捷键)

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
📄 阅读: references/images-and-media.md
  • 从本地机器或URL插入图片
  • RichTextEditorImageSettings
    :SaveUrl、Path、AllowedTypes、EnableResize
  • Base64与服务器端上传对比
  • 图片快速工具栏配置
  • 视频和音频的插入与设置

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)
📄 阅读: references/tables.md
  • 使用
    CreateTable
    工具栏项创建表格
  • RichTextEditorTableSettings
    :宽度、调整大小、自定义样式
  • 表格快速工具栏:添加/删除行和列、合并单元格、属性设置
  • 高级表格操作(单元格选择、拆分、自定义边框)

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
📄 阅读: references/editor-modes.md
  • HTML编辑器模式(默认WYSIWYG)
  • Markdown编辑器模式(
    EditorMode.Markdown
  • IFrame与DIV渲染模式
  • 源代码视图切换

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
📄 阅读: references/inline-mode.md
  • 启用内联工具栏(
    InlineMode
  • 选中文本时显示内联工具栏
  • 使用场景:评论编辑器、原地内容编辑

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
    )
📄 阅读: references/custom-tools.md
  • 使用
    ToolbarItemModel
    和模板添加自定义工具栏按钮
  • 以编程方式使用
    ExecuteCommandAsync
    执行命令
  • 斜杠命令(
    /
    触发菜单)配置
  • 格式刷高级设置(
    RichTextEditorFormatPainterSettings

Events (RTE)

事件(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
📄 阅读: references/events.md
  • RichTextEditorEvents
    子组件的使用和绑定模式
  • 生命周期事件:
    Created
    Destroyed
  • 焦点/交互事件:
    Focus
    Blur
    OnToolbarClick
    SelectionChanged
  • 内容事件:
    ValueChange
    BeforePasteCleanup
    AfterPasteCleanup
  • 工具栏生命周期事件:
    OnActionBegin
    OnActionComplete
  • 对话框事件:
    OnDialogOpen
    DialogOpened
    OnDialogClose
    DialogClosed
  • 快速工具栏事件:
    OnQuickToolbarOpen
    QuickToolbarOpened
    QuickToolbarClosed
  • 图片事件:
    OnImageSelected
    BeforeUploadImage
    OnImageUploadSuccess
    OnImageUploadFailed
    ImageUploadChange
    OnImageDrop
    ImageDelete
  • 媒体事件:
    FileSelected
    FileUploading
    FileUploadSuccess
    FileUploadFailed
    FileUploadChange
    OnMediaDrop
    MediaDeleted
  • 调整大小事件:
    OnResizeStart
    OnResizeStop
  • 工具栏状态事件:
    UpdatedToolbarStatus
  • 导出事件:
    OnExport
    OnExportFailure
  • 斜杠菜单事件:
    SlashMenuItemSelecting
  • 包含所有属性的完整EventArgs类参考

Methods (RTE)

方法(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
📄 阅读: references/methods.md
  • 焦点与选择:
    FocusAsync
    FocusOutAsync
    SaveSelectionAsync
    RestoreSelectionAsync
    SelectAllAsync
    GetSelectionAsync
  • 内容检索:
    GetTextAsync
    GetSelectedHtmlAsync
    GetCharCountAsync
    GetXhtmlAsync
  • 命令执行:所有带类型参数的
    ExecuteCommandAsync
    重载(图片、链接、表格、视频、音频、代码块、格式刷)
  • 工具栏控制:
    EnableToolbarItem
    DisableToolbarItem
    RemoveToolbarItem
  • 对话框与UI控制:
    ShowDialogAsync
    CloseDialogAsync
    ShowFullScreenAsync
    PrintAsync
    RefreshUIAsync
    ShowSourceCodeAsync
  • 撤销/重做:
    ClearUndoRedoAsync
  • 完整的
    CommandName
    ToolbarCommand
    DialogType
    枚举参考

Properties (RTE)

属性(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
📄 阅读: references/properties.md
  • 内容与值:
    Value
    Placeholder
    Readonly
    Enabled
    MaxLength
    ShowCharCount
  • 编辑器行为:
    EditorMode
    EnterKey
    ShiftEnterKey
    EnableTabKey
    EnableAutoUrl
    EnableMarkdownAutoFormat
    EnableClipboardCleanup
    EnableXhtml
    EnableHtmlEncode
    EnableResize
  • 外观与布局:
    Height
    Width
    CssClass
    ShowTooltip
    FloatingToolbarOffset
  • IFrame模式:
    RichTextEditorIFrameSettings
    子组件,包含
    Enable
    Attributes
    Resources
  • 安全与清理:
    EnableHtmlSanitizer
    AdditionalSanitizeAttributes
    AdditionalSanitizeTags
    DeniedSanitizeSelectors
  • 键盘与快捷键:
    KeyConfigure
    ,包含完整的
    ShortcutKeys
    默认绑定表
  • 持久化与自动保存:
    EnablePersistence
    SaveInterval
    AutoSaveOnIdle
  • 撤销/重做配置:
    UndoRedoSteps
    UndoRedoTimer
  • HTTP集成:
    HttpClientInstance
  • 包含38个属性的完整汇总表

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
📄 阅读: references/data-binding.md
  • 使用
    @bind-Value
    进行双向绑定
  • 单向绑定与编程式值更新
  • 使用
    ValueChange
    事件检测编辑操作
  • 只读模式(
    Readonly
    属性)
  • 最大长度限制与字符计数显示

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
📄 阅读: references/paste-and-cleanup.md
  • RichTextEditorPasteCleanupSettings
    配置
  • 粘贴时剥离/保留特定HTML属性和样式
  • 强制粘贴纯文本
  • 回车键行为(
    EnterKey
    ShiftEnterKey
  • 撤销/重做管理器配置

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
📄 阅读: references/import-export.md
  • 将Word文档导入编辑器
  • 将内容导出为Word(.docx)和PDF格式
  • 导入/导出服务的HTTP客户端配置
  • 动态数据邮件合并
  • WebAssembly针对大文档的性能优化

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
📄 阅读: references/accessibility-globalization.md
  • WCAG 2.1合规细节
  • 键盘快捷键与导航参考
  • ARIA角色与屏幕阅读器支持
  • RTL布局(
    EnableRtl
  • 本地化与文化配置
  • XHTML验证

Common Patterns

常见模式

Basic Smart Rich Text Editor with AI

基础AI智能富文本编辑器

razor
@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>";
}
razor
@rendermode InteractiveServer
@using Syncfusion.Blazor.SmartRichTextEditor

<SfSmartRichTextEditor @bind-Value="@Content">
    <AssistViewSettings Placeholder="请让AI重写或生成内容。" />
</SfSmartRichTextEditor>

@code {
    private string Content { get; set; } = "<p>开始编辑...</p>";
}

AI with custom Smart Action commands

带自定义智能操作命令的AI编辑器

razor
<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"
    };
}
razor
<SfSmartRichTextEditor>
    <AssistViewSettings Commands="@MyCommands" Suggestions="@QuickSuggestions" />
</SfSmartRichTextEditor>

@code {
    private List<AICommands> MyCommands = new()
    {
        new AICommands { Text = "总结", Prompt = "简要总结此内容" },
        new AICommands { Text = "扩展", Prompt = "添加更多细节和示例" },
        new AICommands
        {
            Text = "翻译",
            Items = new List<AICommands>
            {
                new AICommands { Text = "翻译成法语", Prompt = "Translate to French" },
                new AICommands { Text = "翻译成西班牙语", Prompt = "Translate to Spanish" }
            }
        }
    };

    private List<string> QuickSuggestions = new()
    {
        "修正语法", "缩短文本", "更正式", "简化表达"
    };
}

Programmatic AI popup control

编程式控制AI弹窗

razor
<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");
}
razor
<SfSmartRichTextEditor>
    <AssistViewSettings @ref="AssistViewRef" MaxPromptHistory="10" />
</SfSmartRichTextEditor>
<button @onclick="OpenAI">打开AI</button>
<button @onclick="RunPrompt">执行提示词</button>

@code {
    private AssistViewSettings AssistViewRef;

    private async Task OpenAI() =>
        await AssistViewRef.ShowAIPopupAsync();

    private async Task RunPrompt() =>
        await AssistViewRef.ExecuteAIPromptAsync("提升文本清晰度");
}

Two-way bound editor with character count

带字符计数的双向绑定编辑器

razor
<SfSmartRichTextEditor @bind-Value="@HtmlContent" ShowCharCount="true" MaxLength="2000">
    <AssistViewSettings Placeholder="Ask AI for writing help." />
</SfSmartRichTextEditor>

@code {
    private string HtmlContent { get; set; } = string.Empty;
}
razor
<SfSmartRichTextEditor @bind-Value="@HtmlContent" ShowCharCount="true" MaxLength="2000">
    <AssistViewSettings Placeholder="请让AI协助写作。" />
</SfSmartRichTextEditor>

@code {
    private string HtmlContent { get; set; } = string.Empty;
}

Read-only display

只读显示模式

razor
<SfSmartRichTextEditor Value="@HtmlContent" Readonly="true">
    <RichTextEditorToolbarSettings Enable="false" />
</SfSmartRichTextEditor>
razor
<SfSmartRichTextEditor Value="@HtmlContent" Readonly="true">
    <RichTextEditorToolbarSettings Enable="false" />
</SfSmartRichTextEditor>

Markdown editor mode

Markdown编辑器模式

razor
<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!";
}
razor
<SfSmartRichTextEditor EditorMode="EditorMode.Markdown" @bind-Value="@MarkdownContent">
    <AssistViewSettings Placeholder="请让AI协助处理Markdown内容。" />
</SfSmartRichTextEditor>

@code {
    private string MarkdownContent { get; set; } = "**Hello** world!";
}

Handle AI prompt event to intercept requests

处理AI提示词事件以拦截请求

razor
<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;
    }
}
razor
<SfSmartRichTextEditor>
    <AssistViewSettings AIPromptRequested="OnAIPrompt" />
</SfSmartRichTextEditor>

@code {
    private async Task OnAIPrompt(AssistViewPromptRequestedEventArgs args)
    {
        // 在发送至AI前记录、验证或修改args.Prompt
        Console.WriteLine($"提示词: {args.Prompt}");
        // 如需取消请求:args.Cancel = true;
    }
}