mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 09:13:14 +00:00
feat: support pasting images from clipboard into prompt bar (#1512)
The prompt bar only accepted images via drag-and-drop or the file picker. Pasting an image from the clipboard inserted the file name as text instead of attaching the image. Add an onPaste handler that extracts image files from the clipboard and attaches them as pending images. Co-authored-by: Brendan Whiting <16016903+bwhiting2356@users.noreply.github.com> Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
This commit is contained in:
parent
2e9e25916c
commit
639058a8b6
1 changed files with 19 additions and 0 deletions
|
|
@ -271,6 +271,24 @@ export const CloudPromptBar = memo(function CloudPromptBarComponent({
|
|||
[addFiles]
|
||||
)
|
||||
|
||||
const handlePaste = useCallback(
|
||||
(e: React.ClipboardEvent<HTMLTextAreaElement>) => {
|
||||
const items = e.clipboardData?.items
|
||||
if (!items) return
|
||||
const files: Array<File> = []
|
||||
for (const item of Array.from(items)) {
|
||||
if (item.kind === "file") {
|
||||
const file = item.getAsFile()
|
||||
if (file && SUPPORTED_IMAGE_TYPES.has(file.type)) files.push(file)
|
||||
}
|
||||
}
|
||||
if (files.length === 0) return
|
||||
e.preventDefault()
|
||||
void addFiles(files)
|
||||
},
|
||||
[addFiles]
|
||||
)
|
||||
|
||||
const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
||||
if (e.key === "Enter" && !e.shiftKey && canSubmit) {
|
||||
e.preventDefault()
|
||||
|
|
@ -359,6 +377,7 @@ export const CloudPromptBar = memo(function CloudPromptBarComponent({
|
|||
value={value}
|
||||
onChange={(e) => setValue(e.target.value)}
|
||||
onKeyDown={handleKeyDown}
|
||||
onPaste={handlePaste}
|
||||
placeholder={busy ? "Send a message to queue next..." : placeholder}
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue