Shared Media / Links: Add Copy Link context action
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d893eaee37
commit
6c028eda2a
@ -12,6 +12,7 @@ import {
|
|||||||
} from '../../global/helpers';
|
} from '../../global/helpers';
|
||||||
import { selectWebPageFromMessage } from '../../global/selectors';
|
import { selectWebPageFromMessage } from '../../global/selectors';
|
||||||
import buildClassName from '../../util/buildClassName';
|
import buildClassName from '../../util/buildClassName';
|
||||||
|
import { copyTextToClipboard } from '../../util/clipboard';
|
||||||
import { formatPastTimeShort } from '../../util/dates/oldDateFormat';
|
import { formatPastTimeShort } from '../../util/dates/oldDateFormat';
|
||||||
import trimText from '../../util/trimText';
|
import trimText from '../../util/trimText';
|
||||||
import { renderMessageSummary } from './helpers/renderMessageText';
|
import { renderMessageSummary } from './helpers/renderMessageText';
|
||||||
@ -128,6 +129,15 @@ const WebLink = ({
|
|||||||
|
|
||||||
if (!url) return undefined;
|
if (!url) return undefined;
|
||||||
|
|
||||||
|
const mergedContextActions: MenuItemContextAction[] | undefined = contextActions && [
|
||||||
|
{
|
||||||
|
title: lang('CopyLink'),
|
||||||
|
icon: 'copy',
|
||||||
|
handler: () => copyTextToClipboard(url),
|
||||||
|
},
|
||||||
|
...contextActions,
|
||||||
|
];
|
||||||
|
|
||||||
const truncatedDescription = !senderTitle && description && trimText(description, MAX_TEXT_LENGTH);
|
const truncatedDescription = !senderTitle && description && trimText(description, MAX_TEXT_LENGTH);
|
||||||
|
|
||||||
const className = buildClassName(
|
const className = buildClassName(
|
||||||
@ -152,7 +162,7 @@ const WebLink = ({
|
|||||||
message={message}
|
message={message}
|
||||||
isProtected={isProtected}
|
isProtected={isProtected}
|
||||||
observeIntersection={observeIntersection}
|
observeIntersection={observeIntersection}
|
||||||
contextActions={contextActions}
|
contextActions={mergedContextActions}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<div className="content">
|
<div className="content">
|
||||||
@ -198,7 +208,7 @@ const WebLink = ({
|
|||||||
onCloseAnimationEnd={handleContextMenuHide}
|
onCloseAnimationEnd={handleContextMenuHide}
|
||||||
withPortal
|
withPortal
|
||||||
>
|
>
|
||||||
{contextActions.map((action) => (
|
{mergedContextActions!.map((action) => (
|
||||||
('isSeparator' in action) ? (
|
('isSeparator' in action) ? (
|
||||||
<MenuSeparator key={action.key || 'separator'} />
|
<MenuSeparator key={action.key || 'separator'} />
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user