|
|
@ -6,7 +6,7 @@ import { isEnterHotkey } from '@/utils/hot-key';
|
|
|
|
import React, { useRef, useState } from 'react';
|
|
|
|
import React, { useRef, useState } from 'react';
|
|
|
|
import { ChatInputAddon } from './Addon';
|
|
|
|
import { ChatInputAddon } from './Addon';
|
|
|
|
import { ClipboardHelper } from './clipboard-helper';
|
|
|
|
import { ClipboardHelper } from './clipboard-helper';
|
|
|
|
import { ChatInputActionContext } from './context';
|
|
|
|
import { ChatInputActionContext, useChatInputMentionsContext } from './context';
|
|
|
|
import { uploadMessageImage } from './utils';
|
|
|
|
import { uploadMessageImage } from './utils';
|
|
|
|
import { ChatInputBoxInput } from './input';
|
|
|
|
import { ChatInputBoxInput } from './input';
|
|
|
|
import {
|
|
|
|
import {
|
|
|
@ -31,6 +31,7 @@ export const ChatInputBox: React.FC<ChatInputBoxProps> = React.memo((props) => {
|
|
|
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
|
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
|
|
const [message, setMessage] = useState('');
|
|
|
|
const [message, setMessage] = useState('');
|
|
|
|
const [mentions, setMentions] = useState<string[]>([]);
|
|
|
|
const [mentions, setMentions] = useState<string[]>([]);
|
|
|
|
|
|
|
|
const { disabled } = useChatInputMentionsContext();
|
|
|
|
const handleSendMsg = useEvent(async () => {
|
|
|
|
const handleSendMsg = useEvent(async () => {
|
|
|
|
await props.onSendMsg(message, {
|
|
|
|
await props.onSendMsg(message, {
|
|
|
|
mentions: _uniq(mentions), // 发送前去重
|
|
|
|
mentions: _uniq(mentions), // 发送前去重
|
|
|
@ -110,6 +111,8 @@ export const ChatInputBox: React.FC<ChatInputBoxProps> = React.memo((props) => {
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{!disabled && (
|
|
|
|
|
|
|
|
<>
|
|
|
|
<div className="px-2 flex space-x-1">
|
|
|
|
<div className="px-2 flex space-x-1">
|
|
|
|
{pluginChatInputButtons.map((item, i) =>
|
|
|
|
{pluginChatInputButtons.map((item, i) =>
|
|
|
|
React.cloneElement(item.render(), {
|
|
|
|
React.cloneElement(item.render(), {
|
|
|
@ -131,6 +134,8 @@ export const ChatInputBox: React.FC<ChatInputBoxProps> = React.memo((props) => {
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<ChatDropArea />
|
|
|
|
<ChatDropArea />
|
|
|
|
|
|
|
|
</>
|
|
|
|
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</ChatInputActionContext.Provider>
|
|
|
|
</ChatInputActionContext.Provider>
|
|
|
|