syncfusion-aspnetcore-inline-ai-assist
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSyncfusion ASP.NET Core Inline AI Assist Control
Syncfusion ASP.NET Core Inline AI Assist控件
Overview
概述
The Inline AI Assist is a Syncfusion ASP.NET Core control that provides intelligent text processing capabilities with:
- Real-time prompt processing connected to AI services (OpenAI, Azure Cognitive Services)
- Multiple response modes: Inline (in-place updates) or Popup (floating dialog)
- Command popups with built-in and custom command items
- Response action items for user feedback and content acceptance
- Event lifecycle: created, promptRequest, open, close
- Public methods: addResponse, executePrompt, showPopup, hidePopup, showCommandPopup, hideCommandPopup
- Template support: Custom editor templates and response templates
- Globalization: Localization (L10n) and RTL support
Inline AI Assist是Syncfusion ASP.NET Core的一款控件,具备智能文本处理能力,包括:
- 实时提示处理:连接至AI服务(OpenAI、Azure Cognitive Services)
- 多种响应模式:Inline(原地更新)或Popup(浮动对话框)
- 命令弹窗:包含内置和自定义命令项
- 响应操作项:用于用户反馈和内容确认
- 事件生命周期:created、promptRequest、open、close
- 公共方法:addResponse、executePrompt、showPopup、hidePopup、showCommandPopup、hideCommandPopup
- 模板支持:自定义编辑器模板和响应模板
- 全球化:本地化(L10n)和RTL支持
Documentation Navigation Guide
文档导航指南
Getting Started
快速开始
📄 Read: references/getting-started.md
- Prerequisites and system requirements
- ASP.NET Core project setup with Razor pages
- NuGet package installation (Syncfusion.EJ2.AspNet.Core)
- Tag helper configuration in _ViewImports.cshtml
- Script and stylesheet resources setup
- Basic control rendering and first run
📄 阅读: references/getting-started.md
- 前提条件和系统要求
- 基于Razor页面的ASP.NET Core项目搭建
- NuGet包安装(Syncfusion.EJ2.AspNet.Core)
- _ViewImports.cshtml中的标签助手配置
- 脚本和样式资源设置
- 基础控件渲染与首次运行
Positioning and Response Modes
定位与响应模式
📄 Read: references/positioning-and-modes.md
- Configure relateTo property (position relative to elements)
- Configure target property (where control appends)
- ResponseMode property: Inline vs Popup modes
- Dynamic mode switching
- Complete positioning examples with use cases
📄 阅读: references/positioning-and-modes.md
- 配置relateTo属性(相对于元素定位)
- 配置target属性(控件追加位置)
- ResponseMode属性:Inline与Popup模式对比
- 动态模式切换
- 完整定位示例及使用场景
Command Configuration
命令配置
📄 Read: references/command-configuration.md
- CommandSettings and command items
- Command properties (id, label, prompt, iconCss, disabled, groupBy, tooltip)
- PopupWidth and PopupHeight configuration
- Command grouping and organization
- ItemSelect event handling
- Advanced command scenarios
📄 阅读: references/command-configuration.md
- CommandSettings与命令项
- 命令属性(id、label、prompt、iconCss、disabled、groupBy、tooltip)
- PopupWidth和PopupHeight配置
- 命令分组与组织
- ItemSelect事件处理
- 高级命令场景
Events and Handlers
事件与处理器
📄 Read: references/events-and-handlers.md
- created event (control rendering completion)
- promptRequest event (with async handling)
- open event (popup opened)
- close event (popup closed)
- Event flow and lifecycle
- Best practices for event handlers
📄 阅读: references/events-and-handlers.md
- created事件(控件渲染完成)
- promptRequest事件(支持异步处理)
- open事件(弹窗打开)
- close事件(弹窗关闭)
- 事件流与生命周期
- 事件处理器最佳实践
Public Methods and APIs
公共方法与API
📄 Read: references/methods-and-apis.md
- addResponse() - Add response programmatically
- executePrompt() - Execute prompt dynamically
- showPopup() - Open popup with optional positioning
- hidePopup() - Close popup
- showCommandPopup() - Show command menu
- hideCommandPopup() - Hide command menu
📄 阅读: references/methods-and-apis.md
- addResponse() - 以编程方式添加响应
- executePrompt() - 动态执行提示
- showPopup() - 打开弹窗(可选定位)
- hidePopup() - 关闭弹窗
- showCommandPopup() - 显示命令菜单
- hideCommandPopup() - 隐藏命令菜单
Inline Assist Features
Inline Assist功能
📄 Read: references/inline-assist-features.md
- Prompt property configuration
- Prompts collection (history management)
- Placeholder text customization
- Z-index property
- Popup width and height configuration
- CssClass for custom styling
- Managing prompt-response collections
📄 阅读: references/inline-assist-features.md
- Prompt属性配置
- Prompts集合(历史记录管理)
- 占位符文本自定义
- Z-index属性
- 弹窗宽度和高度配置
- 用于自定义样式的CssClass
- 提示-响应集合管理
Response Settings and Templates
响应设置与模板
📄 Read: references/response-settings-templates.md
- ResponseSettings configuration
- Built-in response items (accept/reject)
- Custom response items and grouping
- EditorTemplate for footer customization
- ResponseTemplate for response items
- Template syntax and context variables
- ItemSelect event handling
📄 阅读: references/response-settings-templates.md
- ResponseSettings配置
- 内置响应项(接受/拒绝)
- 自定义响应项与分组
- 用于页脚自定义的EditorTemplate
- 用于响应项的ResponseTemplate
- 模板语法与上下文变量
- ItemSelect事件处理
Advanced Features
高级功能
📄 Read: references/advanced-features.md
- Public methods (addResponse, executePrompt, showPopup, hidePopup, showCommandPopup, hideCommandPopup)
- Inline toolbar settings and positioning
- Toolbar items (type, text, iconCss, alignment, tooltip)
- TabIndex for keyboard navigation
- Globalization: L10n and localization
- RTL (enableRtl property)
- Accessibility features
📄 阅读: references/advanced-features.md
- 公共方法(addResponse、executePrompt、showPopup、hidePopup、showCommandPopup、hideCommandPopup)
- Inline工具栏设置与定位
- 工具栏项(type、text、iconCss、alignment、tooltip)
- 用于键盘导航的TabIndex
- 全球化:L10n与本地化
- RTL(enableRtl属性)
- 无障碍功能
Quick Start Example
快速开始示例
razor
@using Syncfusion.EJ2.InteractiveChat;
<style>
#editableText {
width: 100%;
min-height: 120px;
max-height: 300px;
overflow-y: auto;
font-size: 16px;
padding: 12px;
border-radius: 4px;
border: 1px solid;
}
</style>
<div class="container" style="height: 350px; width: 650px;">
<button id="summarizeBtn" class="e-btn e-primary" onclick="onSummarizeClick()">Summarize</button>
<div id="editableText" contenteditable="true">
<p>Add your content here for AI processing...</p>
</div>
<ejs-inlineaiassist id="defaultInlineAssist"
relateTo="#summarizeBtn"
created="onCreated"
promptRequest="onPromptRequest">
<e-inlineaiassist-responsesettings itemSelect="onItemSelect"></e-inlineaiassist-responsesettings>
</ejs-inlineaiassist>
</div>
<script>
var inlineAssist;
function onCreated() {
inlineAssist = this;
}
function onPromptRequest(args) {
setTimeout(function () {
var response = 'Connect to your AI service for real processing...';
inlineAssist.addResponse(response);
}, 1000);
}
function onItemSelect(args) {
if (args.command.label === 'Accept') {
document.getElementById('editableText').innerHTML =
'<p>' + inlineAssist.prompts[inlineAssist.prompts.length - 1].response + '</p>';
inlineAssist.hidePopup();
}
}
function onSummarizeClick() {
if (inlineAssist) {
inlineAssist.showPopup();
}
}
</script>razor
@using Syncfusion.EJ2.InteractiveChat;
<style>
#editableText {
width: 100%;
min-height: 120px;
max-height: 300px;
overflow-y: auto;
font-size: 16px;
padding: 12px;
border-radius: 4px;
border: 1px solid;
}
</style>
<div class="container" style="height: 350px; width: 650px;">
<button id="summarizeBtn" class="e-btn e-primary" onclick="onSummarizeClick()">Summarize</button>
<div id="editableText" contenteditable="true">
<p>Add your content here for AI processing...</p>
</div>
<ejs-inlineaiassist id="defaultInlineAssist"
relateTo="#summarizeBtn"
created="onCreated"
promptRequest="onPromptRequest">
<e-inlineaiassist-responsesettings itemSelect="onItemSelect"></e-inlineaiassist-responsesettings>
</ejs-inlineaiassist>
</div>
<script>
var inlineAssist;
function onCreated() {
inlineAssist = this;
}
function onPromptRequest(args) {
setTimeout(function () {
var response = 'Connect to your AI service for real processing...';
inlineAssist.addResponse(response);
}, 1000);
}
function onItemSelect(args) {
if (args.command.label === 'Accept') {
document.getElementById('editableText').innerHTML =
'<p>' + inlineAssist.prompts[inlineAssist.prompts.length - 1].response + '</p>';
inlineAssist.hidePopup();
}
}
function onSummarizeClick() {
if (inlineAssist) {
inlineAssist.showPopup();
}
}
</script>Common Patterns
常见模式
1. Setup Inline vs Popup Modes
1. 设置Inline与Popup模式
razor
<!-- Popup mode (default) -->
<ejs-inlineaiassist id="assist1" responseMode="Popup" relateTo="#btn"></ejs-inlineaiassist>
<!-- Inline mode (updates content in-place) -->
<ejs-inlineaiassist id="assist2" responseMode="Inline" relateTo="#btn"></ejs-inlineaiassist>razor
<!-- Popup模式(默认) -->
<ejs-inlineaiassist id="assist1" responseMode="Popup" relateTo="#btn"></ejs-inlineaiassist>
<!-- Inline模式(原地更新内容) -->
<ejs-inlineaiassist id="assist2" responseMode="Inline" relateTo="#btn"></ejs-inlineaiassist>2. Add Command Popups
2. 添加命令弹窗
razor
<ejs-inlineaiassist id="assist3" relateTo="#btn">
<e-inlineaiassist-commandsettings
commands="commandsData"
popupWidth="250px"
popupHeight="200px"
itemSelect="onCommandSelect">
</e-inlineaiassist-commandsettings>
</ejs-inlineaiassist>razor
<ejs-inlineaiassist id="assist3" relateTo="#btn">
<e-inlineaiassist-commandsettings
commands="commandsData"
popupWidth="250px"
popupHeight="200px"
itemSelect="onCommandSelect">
</e-inlineaiassist-commandsettings>
</ejs-inlineaiassist>3. Handle Events
3. 处理事件
razor
<ejs-inlineaiassist id="assist4"
created="onCreated"
promptRequest="onPromptRequest"
open="onOpen"
close="onClose">
</ejs-inlineaiassist>razor
<ejs-inlineaiassist id="assist4"
created="onCreated"
promptRequest="onPromptRequest"
open="onOpen"
close="onClose">
</ejs-inlineaiassist>4. Use Public Methods
4. 使用公共方法
javascript
// Show popup at current position
inlineAssist.showPopup();
// Execute prompt dynamically
inlineAssist.executePrompt('Your prompt text');
// Add response programmatically
inlineAssist.addResponse('Response text');
// Hide popup
inlineAssist.hidePopup();javascript
// 在当前位置显示弹窗
inlineAssist.showPopup();
// 动态执行提示
inlineAssist.executePrompt('Your prompt text');
// 以编程方式添加响应
inlineAssist.addResponse('Response text');
// 隐藏弹窗
inlineAssist.hidePopup();Key Props
关键属性
| Property | Purpose | Example |
|---|---|---|
| Position control relative to DOM element | |
| Specify where control appends in DOM | |
| Display mode for responses | |
| Default prompt text | |
| Control width | |
| Control height | |
| Textarea placeholder text | |
| Stacking context | |
| Right-to-left layout | |
| Localization language | |
| Custom CSS class | |
| 属性 | 用途 | 示例 |
|---|---|---|
| 相对于DOM元素定位控件 | |
| 指定控件在DOM中的追加位置 | |
| 响应的显示模式 | |
| 默认提示文本 | |
| 控件宽度 | |
| 控件高度 | |
| 文本框占位符文本 | |
| 堆叠层级 | |
| 从右到左布局 | |
| 本地化语言 | |
| 自定义CSS类 | |
Common Use Cases
常见使用场景
-
Content Summarization Tool
- Place button near text editor
- Use Popup mode for full interface
- Add Accept/Reject response items
- Connect promptRequest to summarization API
-
Inline Text Suggestions
- Use Inline mode for in-place updates
- Minimal UI footprint
- Quick acceptance workflow
- Stream responses for real-time feedback
-
Multi-Command Workflow
- Show command popup for quick actions
- Group commands by category (Improve, Edit)
- Handle each command's promptRequest differently
- Dynamic response handling per command
-
Accessibility-Focused Implementation
- Enable RTL for Arabic/Hebrew content
- Use localization for multiple languages
- Configure tab navigation with tabIndex
- Use semantic templates
-
内容摘要工具
- 在文本编辑器附近放置按钮
- 使用Popup模式获取完整界面
- 添加接受/拒绝响应项
- 将promptRequest连接至摘要API
-
内嵌文本建议
- 使用Inline模式进行原地更新
- 最小化UI占用空间
- 快速确认流程
- 流式响应实现实时反馈
-
多命令工作流
- 显示命令弹窗以快速执行操作
- 按类别(优化、编辑)分组命令
- 针对每个命令的promptRequest进行差异化处理
- 按命令动态处理响应
-
无障碍友好实现
- 为阿拉伯语/希伯来语内容启用RTL
- 使用本地化支持多语言
- 配置tabIndex实现键盘导航
- 使用语义化模板