diff --git a/external/lang b/external/lang index 3048948e..d27cbcf7 160000 --- a/external/lang +++ b/external/lang @@ -1 +1 @@ -Subproject commit 3048948e65b8214b065a6103347db78e2719e8ba +Subproject commit d27cbcf7a8d7663d924ecb67de283b2fea901788 diff --git a/src/components/common/AutoComplete.tsx b/src/components/common/AutoComplete.tsx index e7e21c96..2e840774 100644 --- a/src/components/common/AutoComplete.tsx +++ b/src/components/common/AutoComplete.tsx @@ -264,6 +264,7 @@ export function useAutoComplete( function onClick(ev: JSX.TargetedMouseEvent) { ev.preventDefault(); selectCurrent(document.querySelector("#message")!); + setFocused(false); } function onKeyDown(e: KeyboardEvent) { diff --git a/src/lib/ContextMenus.tsx b/src/lib/ContextMenus.tsx index 4a87e26f..954b137b 100644 --- a/src/lib/ContextMenus.tsx +++ b/src/lib/ContextMenus.tsx @@ -71,6 +71,7 @@ interface ContextMenuData { type Action = | { action: "copy_id"; id: string } + | { action: "copy_message_link"; message: Message } | { action: "copy_selection" } | { action: "copy_text"; content: string } | { action: "mark_as_read"; channel: Channel } @@ -145,6 +146,16 @@ function ContextMenus(props: Props) { case "copy_id": writeClipboard(data.id); break; + case "copy_message_link": + { + let pathname = `/channel/${data.message.channel_id}/${data.message._id}`; + const channel = data.message.channel; + if (channel?.channel_type === "TextChannel") + pathname = `/server/${channel.server_id}${pathname}`; + + writeClipboard(window.origin + pathname); + } + break; case "copy_selection": writeClipboard(document.getSelection()?.toString() ?? ""); break; @@ -846,6 +857,13 @@ function ContextMenus(props: Props) { } } + if (message) { + generateAction({ + action: "copy_message_link", + message, + }); + } + generateAction( { action: "copy_id", id }, sid