Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,20 @@ export const MessageContextMenu = (props: Props) => {
MessageInteraction.copyBodyToClipboard(text);
}, [text]);

const copyLinkFromMessage = useCallback(() => {
const linkMatch = text?.match(/https?:\/\/[^\s]+/);
const firstLink = linkMatch?.[0];

if (firstLink) {
navigator.clipboard.writeText(firstLink).then(() => {
window.log.info('Link copied to clipboard');
});
} else {
window.log.warn('No link found in message');
}
}, [text]);


const onSelect = useCallback(() => {
dispatch(toggleSelectedMessageId(messageId));
}, [dispatch, messageId]);
Expand Down Expand Up @@ -331,6 +345,7 @@ export const MessageContextMenu = (props: Props) => {
</ItemWithDataTestId>
) : null}
<ItemWithDataTestId onClick={copyText}>{window.i18n('copy')}</ItemWithDataTestId>
<ItemWithDataTestId onClick={copyLinkFromMessage}>{window.i18n('copyMessageLink') ?? 'Copy link in message'}</ItemWithDataTestId>
<ItemWithDataTestId
onClick={() => {
void showMessageInfoOverlay({ messageId, dispatch });
Expand Down