Merge pull request #551 from mvanhorn/osc/272-fix-comment-image-attachments
fix: embed uploaded images inline in comments via paperclip button
This commit is contained in:
@@ -377,10 +377,17 @@ 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 safeName = file.name.replace(/[[\]]/g, "\\$&");
|
||||||
|
const markdown = ``;
|
||||||
|
setBody((prev) => prev ? `${prev}\n\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 = "";
|
||||||
@@ -415,7 +422,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