Fix: type-script new change (#5159)

### What problem does this PR solve?
```
fixed type-script on MessageInput change to TextArea
```
_Briefly describe what this PR aims to solve. Include background context
that will help reviewers understand the purpose of the PR._

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
so95 2025-02-25 10:42:31 +07:00 committed by GitHub
parent 9c9f2dbe3f
commit e2448fb6dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 16 additions and 22 deletions

View File

@ -30,12 +30,12 @@ import get from 'lodash/get';
import { Paperclip } from 'lucide-react';
import {
ChangeEventHandler,
KeyboardEventHandler,
memo,
useCallback,
useEffect,
useRef,
useState,
KeyboardEventHandler,
} from 'react';
import FileIcon from '../file-icon';
import styles from './index.less';
@ -64,7 +64,7 @@ interface IProps {
sendDisabled: boolean;
sendLoading: boolean;
onPressEnter(documentIds: string[]): void;
onInputChange: ChangeEventHandler<HTMLInputElement>;
onInputChange: ChangeEventHandler<HTMLTextAreaElement>;
conversationId: string;
uploadMethod?: string;
isShared?: boolean;
@ -216,7 +216,9 @@ const MessageInput = ({
placeholder={t('sendPlaceholder')}
value={value}
disabled={disabled}
className={classNames({ [styles.inputWrapper]: fileList.length === 0 })}
className={classNames({
[styles.inputWrapper]: fileList.length === 0,
})}
onKeyDown={handleInputKeyDown}
onChange={onInputChange}
autoSize={{ minRows: 1, maxRows: 6 }}

View File

@ -284,7 +284,7 @@ export const useScrollToBottom = (messages?: unknown) => {
export const useHandleMessageInputChange = () => {
const [value, setValue] = useState('');
const handleInputChange: ChangeEventHandler<HTMLInputElement> = (e) => {
const handleInputChange: ChangeEventHandler<HTMLTextAreaElement> = (e) => {
const value = e.target.value;
const nextValue = value.replaceAll('\\n', '\n').replaceAll('\\t', '\t');
setValue(nextValue);

View File

@ -341,7 +341,7 @@ export const useSelectNextMessages = () => {
export const useHandleMessageInputChange = () => {
const [value, setValue] = useState('');
const handleInputChange: ChangeEventHandler<HTMLInputElement> = (e) => {
const handleInputChange: ChangeEventHandler<HTMLTextAreaElement> = (e) => {
const value = e.target.value;
const nextValue = value.replaceAll('\\n', '\n').replaceAll('\\t', '\t');
setValue(nextValue);

View File

@ -1,12 +1,12 @@
import MessageItem from '@/components/message-item';
import { MessageType } from '@/constants/chat';
import { useTranslate } from '@/hooks/common-hooks';
import { useGetFileIcon } from '@/pages/chat/hooks';
import { buildMessageItemReference } from '@/pages/chat/utils';
import { Button, Flex, Input, Spin } from 'antd';
import { Flex, Spin } from 'antd';
import { useSendNextMessage } from './hooks';
import MessageInput from '@/components/message-input';
import PdfDrawer from '@/components/pdf-drawer';
import { useClickDrawer } from '@/components/pdf-drawer/hooks';
import { useFetchFlow } from '@/hooks/flow-hooks';
@ -29,7 +29,6 @@ const FlowChatBox = () => {
const { visible, hideModal, documentId, selectedChunk, clickDocumentButton } =
useClickDrawer();
useGetFileIcon();
const { t } = useTranslate('chat');
const { data: userInfo } = useFetchUserInfo();
const { data: canvasInfo } = useFetchFlow();
@ -67,21 +66,15 @@ const FlowChatBox = () => {
</div>
<div ref={ref} />
</Flex>
<Input
size="large"
placeholder={t('sendPlaceholder')}
<MessageInput
showUploadIcon={false}
value={value}
suffix={
<Button
type="primary"
onClick={handlePressEnter}
loading={sendLoading}
>
{t('send')}
</Button>
}
sendLoading={sendLoading}
disabled={false}
sendDisabled={sendLoading}
conversationId=""
onPressEnter={handlePressEnter}
onChange={handleInputChange}
onInputChange={handleInputChange}
/>
</Flex>
<PdfDrawer

View File

@ -16,7 +16,6 @@ const ChatDrawer = ({ visible, hideModal }: IModalProps<any>) => {
getContainer={false}
width={getDrawerWidth()}
mask={false}
// zIndex={10000}
>
<FlowChatBox></FlowChatBox>
</Drawer>