From d1fad2b2620c0ef9770a85dd51395e4c1f9be347 Mon Sep 17 00:00:00 2001 From: Jannis Braun <151788261+TheZwiss@users.noreply.github.com> Date: Wed, 25 Mar 2026 04:55:44 +0100 Subject: [PATCH] feat: add sourceUrl param to context menu with Copy Link and Open Link items --- .../src/components/chat/messageMenuItems.tsx | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/packages/web/src/components/chat/messageMenuItems.tsx b/packages/web/src/components/chat/messageMenuItems.tsx index 675fbd91..61b7ed49 100644 --- a/packages/web/src/components/chat/messageMenuItems.tsx +++ b/packages/web/src/components/chat/messageMenuItems.tsx @@ -2,6 +2,7 @@ import React from 'react'; import type { ContextMenuItem } from '../../stores/contextMenuStore'; import type { MessageWithUser } from '@backspace/shared'; import { saveImage, copyImageToClipboard } from '../../utils/imageActions'; +import { useUIStore } from '../../stores/uiStore'; const QUICK_EMOJIS = ['👍', '❤️', '😂', '😮']; @@ -21,6 +22,7 @@ interface MessageMenuParams { onOpenEmojiPicker: () => void; onMarkUnread: (messageId: string) => void; imageUrl?: string | null; + sourceUrl?: string | null; } export function buildMessageMenuItems(params: MessageMenuParams): ContextMenuItem[] { @@ -40,6 +42,7 @@ export function buildMessageMenuItems(params: MessageMenuParams): ContextMenuIte onOpenEmojiPicker, onMarkUnread, imageUrl, + sourceUrl, } = params; const items: ContextMenuItem[] = []; @@ -86,6 +89,38 @@ export function buildMessageMenuItems(params: MessageMenuParams): ContextMenuIte items.push({ key: 'image-sep', type: 'separator' }); } + // ── Link Actions (when URL text is suppressed) ────────────────────── + if (sourceUrl) { + items.push({ + key: 'copy-link', + type: 'action', + label: 'Copy Link', + icon: ( + + + + ), + onClick: () => { + navigator.clipboard.writeText(sourceUrl); + useUIStore.getState().addToast('Copied link', 'success', 3000); + }, + }); + items.push({ + key: 'open-link', + type: 'action', + label: 'Open Link', + icon: ( + + + + ), + onClick: () => { + window.open(sourceUrl, '_blank', 'noopener'); + }, + }); + items.push({ key: 'link-sep', type: 'separator' }); + } + // ── Quick Reaction Row ────────────────────────────────────────────────── if (canAddReactions) { items.push({ @@ -160,7 +195,7 @@ export function buildMessageMenuItems(params: MessageMenuParams): ContextMenuIte key: 'copy-text', type: 'action', label: 'Copy Text', - hidden: !message.content, + hidden: !message.content || !!sourceUrl, icon: (