diff --git a/web/app/components/base/action-button/index.css b/web/app/components/base/action-button/index.css index b87dbc8d4a..5ed29742db 100644 --- a/web/app/components/base/action-button/index.css +++ b/web/app/components/base/action-button/index.css @@ -16,7 +16,7 @@ } .action-btn-l { - @apply p-1.5 w-[34px] h-[34px] rounded-lg + @apply p-1.5 w-8 h-8 rounded-lg } /* m is for the regular button */ diff --git a/web/app/components/base/chat/chat/chat-input-area/hooks.ts b/web/app/components/base/chat/chat/chat-input-area/hooks.ts new file mode 100644 index 0000000000..3559cb8799 --- /dev/null +++ b/web/app/components/base/chat/chat/chat-input-area/hooks.ts @@ -0,0 +1,36 @@ +import { + useCallback, + useEffect, + useMemo, + useRef, + useState, +} from 'react' +import type { TextAreaRef } from 'rc-textarea' + +export const useTextAreaHeight = () => { + const textareaRef = useRef(null) + const [height, setHeight] = useState(0) + + const handleComputeHeight = () => { + const textareaElement = textareaRef.current?.resizableTextArea.textArea + if (textareaElement) { + const { height } = textareaElement.getBoundingClientRect() + + setHeight(height) + } + } + + useEffect(() => { + handleComputeHeight() + }, []) + + const handleTextareaResize = useCallback(() => { + handleComputeHeight() + }, []) + + return { + textareaRef, + handleTextareaResize, + isMultipleLine: useMemo(() => height > 32, [height]), + } +} diff --git a/web/app/components/base/chat/chat/chat-input-area/index.tsx b/web/app/components/base/chat/chat/chat-input-area/index.tsx new file mode 100644 index 0000000000..be49248cb6 --- /dev/null +++ b/web/app/components/base/chat/chat/chat-input-area/index.tsx @@ -0,0 +1,51 @@ +import { + memo, +} from 'react' +import Textarea from 'rc-textarea' +import { RiSendPlane2Fill } from '@remixicon/react' +import { useTextAreaHeight } from './hooks' +import Button from '@/app/components/base/button' +import { FileUploaderInChatInput } from '@/app/components/base/file-uploader' +import cn from '@/utils/classnames' + +const ChatInputArea = () => { + const { + textareaRef, + handleTextareaResize, + isMultipleLine, + } = useTextAreaHeight() + + return ( +
+