Skip to content

EditorSender Input Box ๐ŸŒบ โ€‹

Introduction โ€‹

EditorSender is here! ๐Ÿ™Š Designed specifically for multimodal models and custom prompt scenarios, this input box component solves core development needs such as tag insertion, content mentions, and custom prompt input, better showcasing the power of multimodal functionality.

๐Ÿ“Œ Warning

There are certain development differences between the EditorSender component and the Sender component. Please choose according to your actual needs.

Code Demonstrations โ€‹

Basic Usage โ€‹

This is an EditorSender input box, the simplest usage example.

Placeholder Text โ€‹

Set the placeholder text of the input box via placeholder.

Auto Focus โ€‹

Set input box auto focus via auto-focus property. It will automatically focus after the input box is generated.

State Properties โ€‹

You can implement component states through simple properties.

๐Ÿ’Œ Info

  • Through the loading property, you can control the loading state of the built-in button in the input box.
  • Through the disabled property, you can control whether the built-in button of the input box is disabled.
  • Through the clearable property, you can control whether the input box shows a delete button to clear the content.

Variant - Vertical Style โ€‹

Deep Thinking

Set the variant of the input box via the variant property. [ Default 'default' | Vertical layout 'updown' ]

This property changes the input box from a left-right layout to a vertical layout. The top part is the input box, and the bottom part is the built-in prefix and action list bar.

Custom Action List โ€‹

Use the #action-list slot to customize the action list content of the input box. You can combine it with the getCurrentValue method of the component Ref instance to get the current value of the input box.

๐Ÿ“Œ Warning

Before version 1.0.81, when using custom slots, the built-in action buttons would be sacrificed. In version 1.0.81, we introduced streaming request hooks that allow users to better control streaming requests and thus better define their own #action-list slots. For details, please check out our project template's recommended request library, comparable to Axios: hook-fetch.

This friendly reminder was updated on: 2025-08-06

๐Ÿ’Œ Info

When you use the #action-list slot, the built-in input box action buttons will be hidden. You can combine it with component instance methods to implement richer operations.

Custom Prefix โ€‹

Use the #prefix slot to customize the prefix content of the input box.

Custom Header โ€‹

Use the #header slot to customize the header content of the input box. You can also set the header animation time through the headerAnimationTimer property.

Custom Input Box Style โ€‹

Easily control the style of the input box through customStyle. You can set maxHeight to limit the height of the input box, which will display a scrollbar when the content exceeds the specified height.

Maximum Input Length โ€‹

Limit the maximum number of characters in the input box via maxLength.

๐Ÿ’” Danger

This configuration has a relatively high performance cost. Please do not set it unless necessary (like Doubao and Wenxin Yiyan, which do not limit this). Do not sacrifice major functions for minor features.

Submission Methods โ€‹

Control line break and submit mode through submitType. Default is 'enter', which means Enter to submit and 'shift + Enter' to line break.

๐Ÿ’Œ Info

  • submitType='enter' sets Enter to submit and 'shift + Enter' to line break.
  • submitType='shiftEnter' sets 'shift + Enter' to submit and Enter to line break.

Advanced Usage โ€‹

Insert Text Content โ€‹

Use the component Ref to call the setText method to insert text content at the cursor position.

Insert HTML Content โ€‹

Use the component Ref to call the setHtml method to insert HTML content at the cursor position.

๐Ÿ“Œ Warning

The inserted HTML tags must be inline or inline-block elements. If you need block-level element tags, please insert inline elements and then modify their CSS properties to block-level elements.

Insert Select Tag โ€‹

Configure the select tag configuration array via the selectList property.

Use the component Ref to call the setSelectTag method to insert select tag content at the cursor position. This method accepts two parameters: the first is the identifier of the select tag, and the second is the option identifier (default value) of the select tag.

๐Ÿ’Œ Info

You can also call the openSelectDialog method from outside to open the select tag popup. This method accepts a configuration object with the following type:

ts
interface SelectDialogOption {
  key: string;
  elm: HTMLElement;
  beforeText?: string;
  afterText?: string;
}
Expand to view configuration array type
ts
interface SelectTag {
  dialogTitle: string, // Select tag popup title
  key: string, // Select tag identifier, used when inserting select tags
  options: SelectItem[] // Select tag options array
}

interface SelectItem {
  id: string, // Select tag option identifier
  name: string, // Select tag option name
  preview?: string | URL // Select tag option preview image
}

Insert Input Tag โ€‹

Configure the select tag configuration array via the selectList property. Use the component Ref to call the setInputTag method to insert input tag content at the cursor position.

This method accepts three parameters: the first is the identifier of the input tag (custom defined), the second is the placeholder of the input tag, and the third is the default value of the input tag.

Insert User Tag โ€‹

Configure the user tag configuration array via the userList property. @ triggers the user tag popup.

Use the component Ref to call the setUserTag method to insert user tag content at the cursor position. This method accepts one parameter: the identifier of the user tag. If you want to support pinyin search, please configure the pinyin property for the user tag.

Expand to view configuration array type
ts
interface UserInfo {
  id: string, // User identifier
  name: string, // User name
  avatar?: string | URL, // User avatar
  pinyin?: string // Pinyin of user name, used for search
}

Insert Custom Tag โ€‹

Configure the custom tag configuration array via the customTrigger property.

Use the component Ref to call the setCustomTag method to insert custom tag content at the cursor position. This method accepts two parameters: the first is the identifier prefix of the custom tag, and the second is the id of the tag list item to be inserted.

Expand to view configuration array type
ts
interface CustomTag {
  dialogTitle: string,
  prefix: string,
  tagList: TagInfo[]
}

interface TagInfo {
  id: string,
  name: string,
  pinyin?: string
}

Mixed Tag Override Writing โ€‹

Set mixed tags via the setMixTags method of the component Ref instance. Mixed tags will overwrite existing content.

Prefix Prompt Tag โ€‹

Open and close the prefix tip tag via the openTipTag and closeTipTag methods of the component Ref instance.

Asynchronous Loading of @Members โ€‹

Configure async matching function via asyncMatchFun property. @ triggers user tag popup.

Custom Mention Popup โ€‹

Configure async matching function via asyncMatchFun property. @ triggers user tag popup.

Device Type (PC/H5) โ€‹

Set the device type using the device property, default is pc

๐Ÿ“Œ Warning

When passing h5, pay attention to the interaction of the pop-up selection function and refer to the custom pop-up selection function to implement the interaction

Properties โ€‹

Property NameTypeRequiredDefault ValueDescription
placeholderStringNo'Please enter content'Input box placeholder text
device'pc' | 'h5'No'pc'Device type using the editor. PC has built-in rich popup selection features; H5 requires custom popup implementation
autoFocusBooleanNofalseWhether to automatically focus on the input box after component mounting
variant'default' | 'updown'No'default'Input box variant type. 'default' is horizontal layout; 'updown' is vertical layout
userListUserInfo[]No[]User list for @mention functionality
customTriggerCustomTag[]No[]Extended custom popup trigger configuration list
selectListSelectTag[]No[]Configuration list for tag dropdown selection options
maxLengthNumberNoundefinedLimit the maximum number of characters in the input box. High performance cost, not recommended unless necessary
submitType'enter' | 'shiftEnter'No'enter'Control line break and submission mode: 'enter' for Enter submit/Shift+Enter line break; 'shiftEnter' for Shift+Enter submit/Enter line break
customStyleRecord<string, any>No{}Used to modify the style of the input box
loadingBooleanNofalseLoading state of the send button. Shows loading animation when true
disabledBooleanNofalseWhether to disable the input box. Disabled boxes cannot be entered or operated
clearableBooleanNofalseWhether to show the clear button
headerAnimationTimerNumberNo300Duration of header expansion/collapse animation, in ms
asyncMatchFun(searchVal: string) => Promise<UserInfo[]>NoundefinedMethod for asynchronously loading group members, used for remote search in @mention functionality
customDialogBooleanNofalseWhether to enable custom popup. When enabled, internal popups will not be created; popup logic must be implemented manually

Events โ€‹

Event NameDescriptionCallback Parameters
submitTriggered when submitting contentpayload: SubmitResult - Contains various submitted content
changeTriggered when input content changesNone
cancelTriggered when canceling loading stateNone
showAtDialogTriggered when showing @user popupNone
showSelectDialogTriggered when showing select tag popupkey: string - Tag key name, elm: HTMLElement - Trigger element
showTagDialogTriggered when showing custom tag popupprefix: string - Tag prefix

Ref Instance Methods โ€‹

Method NameTypeDescription
getCurrentValue() => SubmitResultGet the current content of the input box, including text, HTML, and various tag information
focusToStart() => voidFocus the cursor to the beginning of the text
focusToEnd() => voidFocus the cursor to the end of the text
blur() => voidRemove focus from the input box
selectAll() => voidSelect all content in the input box
clear(txt?: string) => voidClear the input box content. Optional parameter txt is the text to insert after clearing
setSelectTag(key: string, tagId: string) => voidInsert a select tag
setInputTag(key: string, placeholder: string, defaultValue?: string) => voidInsert an input tag
setUserTag(userId: string) => voidInsert a @mention tag
setCustomTag(prefix: string, id: string) => voidInsert a custom trigger tag
setMixTags(tags: MixTag[][]) => voidInsert multiple tags in a mixed manner
setHtml(html: string) => voidInsert HTML snippet at current cursor position (inline or inline-block elements recommended)
setText(txt: string) => voidInsert text at current cursor position
openSelectDialog(option: SelectDialogOption) => voidExternally call to open tag selection popup
customSetUser(user: UserInfo) => voidWrite @mention tag in custom popup (private API, automatically truncates trigger)
customSetTag(prefix: string, tag: TagInfo) => voidWrite custom trigger tag in custom popup (private API, automatically truncates trigger)
updateSelectTag(elm: HTMLElement, tag: TagInfo) => voidUpdate select tag content
openTipTag(options: TipOptions) => voidOpen prefix prompt tag
closeTipTag() => voidClose prefix prompt tag
chatChatArea instanceExposed chat instance object
opNodeChatOperateNode instanceExposed ChatNode operation object
chatStateChatState objectExposed component state object

Slots โ€‹

Slot NameParametersDescription
#header-Used for customizing input box header content
#prefix-Used for customizing input box prefix content
#action-list-Used for customizing input box action list content
#footer-Used for customizing input box footer content

Features โ€‹

  1. Full-type Tag Engine: Seamlessly supports multiple tag types such as @users, select tags, and custom tags. Tag insertion/update/management is a breeze, meeting complex content tagging needs.

  2. Cross-device Adaptive Interaction: PC has a built-in popup system, while H5 supports custom popups. Automatically adapts to different device operation habits, balancing native experience with customization freedom.