mirror of
https://github.com/revoltchat/revite.git
synced 2024-12-25 07:02:10 -05:00
Add a way to copy message links.
Remove focus from auto complete after click, fixes #12.
This commit is contained in:
parent
bb6ac68c8e
commit
2f06112921
3 changed files with 20 additions and 1 deletions
2
external/lang
vendored
2
external/lang
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 3048948e65b8214b065a6103347db78e2719e8ba
|
||||
Subproject commit d27cbcf7a8d7663d924ecb67de283b2fea901788
|
|
@ -264,6 +264,7 @@ export function useAutoComplete(
|
|||
function onClick(ev: JSX.TargetedMouseEvent<HTMLButtonElement>) {
|
||||
ev.preventDefault();
|
||||
selectCurrent(document.querySelector("#message")!);
|
||||
setFocused(false);
|
||||
}
|
||||
|
||||
function onKeyDown(e: KeyboardEvent) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue