forked from farhoodlabs/paperclip
fix: embed uploaded images inline in comments via paperclip button
The paperclip button in comments uploaded images to the issue-level attachment section but didn't insert a markdown image reference into the comment body. Now it uses the imageUploadHandler to get the URL and appends an inline image to the comment text. Fixes #272 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -335,10 +335,16 @@ export function CommentThread({
|
|||||||
|
|
||||||
async function handleAttachFile(evt: ChangeEvent<HTMLInputElement>) {
|
async function handleAttachFile(evt: ChangeEvent<HTMLInputElement>) {
|
||||||
const file = evt.target.files?.[0];
|
const file = evt.target.files?.[0];
|
||||||
if (!file || !onAttachImage) return;
|
if (!file) return;
|
||||||
setAttaching(true);
|
setAttaching(true);
|
||||||
try {
|
try {
|
||||||
await onAttachImage(file);
|
if (imageUploadHandler) {
|
||||||
|
const url = await imageUploadHandler(file);
|
||||||
|
const markdown = ``;
|
||||||
|
setBody((prev) => prev ? `${prev}\n${markdown}` : markdown);
|
||||||
|
} else if (onAttachImage) {
|
||||||
|
await onAttachImage(file);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
setAttaching(false);
|
setAttaching(false);
|
||||||
if (attachInputRef.current) attachInputRef.current.value = "";
|
if (attachInputRef.current) attachInputRef.current.value = "";
|
||||||
@@ -367,7 +373,7 @@ export function CommentThread({
|
|||||||
contentClassName="min-h-[60px] text-sm"
|
contentClassName="min-h-[60px] text-sm"
|
||||||
/>
|
/>
|
||||||
<div className="flex items-center justify-end gap-3">
|
<div className="flex items-center justify-end gap-3">
|
||||||
{onAttachImage && (
|
{(imageUploadHandler || onAttachImage) && (
|
||||||
<div className="mr-auto flex items-center gap-3">
|
<div className="mr-auto flex items-center gap-3">
|
||||||
<input
|
<input
|
||||||
ref={attachInputRef}
|
ref={attachInputRef}
|
||||||
|
|||||||
Reference in New Issue
Block a user