# EditorSender Input Box
# Overview
EditorSender is a powerful rich text input component built on ChatArea, providing rich text editing and tag insertion capabilities. It's particularly suitable for scenarios requiring complex content input, such as AI conversations and template editing. Key features include:
- Rich text editing with support for multiple tag types (select tags, input tags, user tags, custom tags)
- @ mention functionality with async user list loading
- Custom trigger characters (e.g., #, !)
- Flexible dialog system supporting both built-in and custom dialogs
- Multiple layout variants (default and up-down layouts)
- Extensible slot system
- Comprehensive API for programmatic operations
- For more features, please visit ChatArea (opens new window) to view
# Examples
# Basic Usage
The simplest way to use the component with basic rich text input functionality.
# Tag Features
Supports insertion and management of various tag types including select tags and input tags.
# @ Mention Feature
Supports @ mentioning users with static user lists or async loading.
Static User List
Async User Loading
# Custom Triggers
Configure custom trigger characters like #topics, !tools, etc.
# Layout Variants
Two layout modes available: default layout and up-down layout.
Default Layout
Up-Down Layout
# Custom Dialogs
Support for fully custom dialogs to meet special interaction requirements.
# Advanced Features
Demonstrates all advanced editor features including text operations, tag insertion, mixed content, and more.
# Props
| Property | Description | Type | Default |
|---|---|---|---|
| placeholder | Input placeholder text | String | '请输入内容' |
| device | Device type, affects dialog interaction: 'pc','h5' | String | 'pc' |
| autoFocus | Auto focus on mount | Boolean | false |
| variant | Layout variant: 'default', 'updown' | String | 'default' |
| selectList | Select tag configuration list | Array | [] |
| userList | User list for @ mentions | Array | [] |
| customTrigger | Custom trigger configuration | Array | [] |
| maxLength | Maximum character limit | Number | undefined |
| submitType | Submit shortcut: 'enter', 'shiftEnter' | String | 'enter' |
| customStyle | Custom input box styles | Object | {} |
| loading | Loading state | Boolean | false |
| disabled | Disabled state | Boolean | false |
| clearable | Show clear button | Boolean | false |
| headerAnimationTimer | Header animation duration (ms) | Number | 300 |
| asyncMatchFun | Async match function for @ mentions | Function | undefined |
| customDialog | Use custom dialogs | Boolean | false |
# selectList Configuration
[
{
dialogTitle: 'Dialog title',
key: 'Unique key',
options: [
{
id: 'Option ID',
name: 'Option name',
preview: 'Preview image URL (optional)',
},
],
},
];
# userList Configuration
[
{
id: 'User ID',
name: 'Username',
avatar: 'Avatar URL (optional)',
},
];
# customTrigger Configuration
[
{
dialogTitle: 'Dialog title',
prefix: 'Trigger character (e.g., #, !)',
tagList: [
{
id: 'Tag ID',
name: 'Tag name',
},
],
},
];
# Methods
| Method | Description | Parameters |
|---|---|---|
| getCurrentValue | Get current editor content | - |
| focusToStart | Move cursor to start | - |
| focusToEnd | Move cursor to end | - |
| onBlur | Blur the editor | - |
| selectAll | Select all content | - |
| onClear | Clear content | (text?: string) |
| setText | Insert text | (text: string) |
| setHtml | Insert HTML | (html: string) |
| setSelectTag | Insert select tag | (key: string, tagId: string) |
| setInputTag | Insert input tag | (key: string, placeholder: string, defaultValue?: string) |
| setUserTag | Insert user tag | (userId: string) |
| setCustomTag | Insert custom tag | (prefix: string, id: string) |
| setMixTags | Set mixed content | (tags: Array) |
| openSelectDialog | Open select dialog | (option: { key, elm, beforeText?, afterText? }) |
| openTipTag | Show tip tag | (options: { tagLabel, popoverLabel }) |
| closeTipTag | Close tip tag | - |
| customSetUser | Custom dialog set user | (user: object) |
| customSetTag | Custom dialog set tag | (prefix: string, tag: object) |
| updateSelectTag | Update select tag | (elm: Element, tag: object) |
# Events
| Event | Description | Parameters |
|---|---|---|
| submit | Triggered on submit | { text, html, inputTags, userTags, selectTags, customTags } |
| change | Triggered on content change | - |
| cancel | Triggered on cancel | - |
| show-at-dialog | Triggered when @ dialog should show | - |
| show-select-dialog | Triggered when select dialog should show | (key: string, elm: Element) |
| show-tag-dialog | Triggered when custom tag dialog should show | (prefix: string) |
# Slots
| Slot | Description |
|---|---|
| header | Header content |
| footer | Footer content |
| prefix | Prefix content |
| action-list | Action button list |
# Notes
- Performance: The
maxLengthconfiguration has significant performance overhead, avoid using unless necessary - Custom Dialogs: When
customDialogis true, you need to implement all dialog logic - Async Loading: When using
asyncMatchFun, the function must return an array matching the user list format - Device Adaptation: The
deviceproperty affects dialog interaction, custom dialogs are recommended for mobile - HTML Insertion: Content inserted via
setHtmlmust be inline or inline-block elements