mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-06 08:38:37 +00:00
Add a way to copy message links.
Remove focus from auto complete after click, fixes #12.
This commit is contained in:
2
external/lang
vendored
2
external/lang
vendored
Submodule external/lang updated: 3048948e65...d27cbcf7a8
@@ -264,6 +264,7 @@ export function useAutoComplete(
|
|||||||
function onClick(ev: JSX.TargetedMouseEvent<HTMLButtonElement>) {
|
function onClick(ev: JSX.TargetedMouseEvent<HTMLButtonElement>) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
selectCurrent(document.querySelector("#message")!);
|
selectCurrent(document.querySelector("#message")!);
|
||||||
|
setFocused(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onKeyDown(e: KeyboardEvent) {
|
function onKeyDown(e: KeyboardEvent) {
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ interface ContextMenuData {
|
|||||||
|
|
||||||
type Action =
|
type Action =
|
||||||
| { action: "copy_id"; id: string }
|
| { action: "copy_id"; id: string }
|
||||||
|
| { action: "copy_message_link"; message: Message }
|
||||||
| { action: "copy_selection" }
|
| { action: "copy_selection" }
|
||||||
| { action: "copy_text"; content: string }
|
| { action: "copy_text"; content: string }
|
||||||
| { action: "mark_as_read"; channel: Channel }
|
| { action: "mark_as_read"; channel: Channel }
|
||||||
@@ -145,6 +146,16 @@ function ContextMenus(props: Props) {
|
|||||||
case "copy_id":
|
case "copy_id":
|
||||||
writeClipboard(data.id);
|
writeClipboard(data.id);
|
||||||
break;
|
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":
|
case "copy_selection":
|
||||||
writeClipboard(document.getSelection()?.toString() ?? "");
|
writeClipboard(document.getSelection()?.toString() ?? "");
|
||||||
break;
|
break;
|
||||||
@@ -846,6 +857,13 @@ function ContextMenus(props: Props) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (message) {
|
||||||
|
generateAction({
|
||||||
|
action: "copy_message_link",
|
||||||
|
message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
generateAction(
|
generateAction(
|
||||||
{ action: "copy_id", id },
|
{ action: "copy_id", id },
|
||||||
sid
|
sid
|
||||||
|
|||||||
Reference in New Issue
Block a user