import { UserListItem } from '@/components/UserListItem'; import { getMessageTextDecorators } from '@/plugin/common'; import { stopPropagation } from '@/utils/dom-helper'; import React from 'react'; import { Mention, MentionsInput } from 'react-mentions'; import { t } from 'tailchat-shared'; import { useChatInputMentionsContext } from './context'; import './input.less'; interface ChatInputBoxInputProps extends Omit< React.InputHTMLAttributes, 'value' | 'onChange' > { inputRef?: React.Ref; value: string; onChange: (message: string, mentions: string[]) => void; } export const ChatInputBoxInput: React.FC = React.memo( (props) => { const { users, placeholder, disabled } = useChatInputMentionsContext(); return ( props.onChange( newValue, mentions.map((m) => m.id) ) } onKeyDown={props.onKeyDown} onPaste={props.onPaste} onContextMenu={stopPropagation} allowSuggestionsAboveCursor={true} forceSuggestionsAboveCursor={true} > `@${display}`} appendSpaceOnAdd={true} renderSuggestion={(suggestion) => ( )} markup={getMessageTextDecorators().mention('__id__', '__display__')} /> ); } ); ChatInputBoxInput.displayName = 'ChatInputBoxInput';