feat: clipboard paste (#1663)

This commit is contained in:
Yuhao
2023-12-01 10:04:14 +08:00
committed by GitHub
parent 1b3a98425f
commit faa88aafe8
4 changed files with 89 additions and 5 deletions

View File

@@ -23,7 +23,7 @@ import type { DataSet } from '@/models/datasets'
import ChatImageUploader from '@/app/components/base/image-uploader/chat-image-uploader'
import ImageList from '@/app/components/base/image-uploader/image-list'
import { TransferMethod, type VisionFile, type VisionSettings } from '@/types/app'
import { useImageFiles } from '@/app/components/base/image-uploader/hooks'
import { useClipboardUploader, useImageFiles } from '@/app/components/base/image-uploader/hooks'
export type IChatProps = {
configElem?: React.ReactNode
@@ -101,6 +101,7 @@ const Chat: FC<IChatProps> = ({
onImageLinkLoadSuccess,
onClear,
} = useImageFiles()
const { onPaste } = useClipboardUploader({ onUpload, visionConfig, files })
const isUseInputMethod = useRef(false)
const [query, setQuery] = React.useState('')
@@ -305,6 +306,7 @@ const Chat: FC<IChatProps> = ({
onChange={handleContentChange}
onKeyUp={handleKeyUp}
onKeyDown={handleKeyDown}
onPaste={onPaste}
autoSize
/>
<div className="absolute bottom-2 right-2 flex items-center h-8">