mirror of
https://github.com/spacebarchat/client.git
synced 2024-11-22 02:12:38 +01:00
copy attachment link context menu item
This commit is contained in:
parent
c9b0a79039
commit
f946108b21
@ -64,6 +64,10 @@ const MessageContent = styled.div<{ sending?: boolean; failed?: boolean }>`
|
||||
color: ${(props) => (props.failed ? "var(--error)" : undefined)};
|
||||
`;
|
||||
|
||||
const MessageAttachment = styled.div`
|
||||
cursor: pointer;
|
||||
`;
|
||||
|
||||
function calculateImageRatio(width: number, height: number) {
|
||||
let o = 1;
|
||||
width > maxWidth && (o = maxWidth / width);
|
||||
@ -255,7 +259,36 @@ function Message({ message, isHeader, isSending, isFailed }: Props) {
|
||||
logger.warn(`Unknown attachment type: ${attachment.content_type}`);
|
||||
}
|
||||
|
||||
return <div key={attachment.id}>{a}</div>;
|
||||
return (
|
||||
<MessageAttachment
|
||||
key={attachment.id}
|
||||
onContextMenu={(e) => {
|
||||
// prevent propagation to the message container
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
contextMenu.open({
|
||||
position: {
|
||||
x: e.pageX,
|
||||
y: e.pageY,
|
||||
},
|
||||
items: [
|
||||
...contextMenuItems,
|
||||
{
|
||||
label: "Copy Attachment URL",
|
||||
onClick: () => {
|
||||
navigator.clipboard.writeText(attachment.url);
|
||||
},
|
||||
iconProps: {
|
||||
icon: "mdiLink",
|
||||
},
|
||||
} as IContextMenuItem,
|
||||
],
|
||||
});
|
||||
}}
|
||||
>
|
||||
{a}
|
||||
</MessageAttachment>
|
||||
);
|
||||
})}
|
||||
</MessageContent>
|
||||
) : (
|
||||
|
Loading…
Reference in New Issue
Block a user