mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-17 03:10:38 +09:00
feat(ui): open gallery when clicking images in chat messages
Clicking an image in a chat message now opens the same ImageGalleryModal used by the attachments gallery. Matches by contentPath or assetId. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
parent
c830c64727
commit
d0920da459
3 changed files with 45 additions and 5 deletions
|
|
@ -1356,6 +1356,28 @@ export function IssueDetail() {
|
|||
const attachmentList = attachments ?? [];
|
||||
const imageAttachments = attachmentList.filter(isImageAttachment);
|
||||
const nonImageAttachments = attachmentList.filter((a) => !isImageAttachment(a));
|
||||
|
||||
const handleChatImageClick = useCallback(
|
||||
(src: string) => {
|
||||
// Try exact contentPath match first
|
||||
let idx = imageAttachments.findIndex((a) => a.contentPath === src);
|
||||
if (idx < 0) {
|
||||
// Try matching by asset ID extracted from /api/assets/{assetId}/content URLs
|
||||
const assetMatch = src.match(/\/api\/assets\/([^/]+)\/content/);
|
||||
if (assetMatch) {
|
||||
idx = imageAttachments.findIndex((a) => a.assetId === assetMatch[1]);
|
||||
}
|
||||
}
|
||||
if (idx >= 0) {
|
||||
setGalleryIndex(idx);
|
||||
setGalleryOpen(true);
|
||||
} else {
|
||||
// Image not in attachment list — open in new tab
|
||||
window.open(src, "_blank");
|
||||
}
|
||||
},
|
||||
[imageAttachments],
|
||||
);
|
||||
const hasAttachments = attachmentList.length > 0;
|
||||
const attachmentUploadButton = (
|
||||
<>
|
||||
|
|
@ -1897,6 +1919,7 @@ export function IssueDetail() {
|
|||
await interruptQueuedComment.mutateAsync(runningIssueRun.id);
|
||||
}
|
||||
: undefined}
|
||||
onImageClick={handleChatImageClick}
|
||||
/>
|
||||
</TabsContent>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue