From bc2fef45967691f9338ee8484effe8d0695197bf Mon Sep 17 00:00:00 2001 From: brecert Date: Tue, 7 Sep 2021 08:34:40 -0400 Subject: [PATCH] Add `shift+click` to link to a channel in the textarea --- src/components/navigation/left/ServerSidebar.tsx | 12 ++++++++++++ src/lib/ConditionalLink.tsx | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/navigation/left/ServerSidebar.tsx b/src/components/navigation/left/ServerSidebar.tsx index 61fca6b3..83adce2a 100644 --- a/src/components/navigation/left/ServerSidebar.tsx +++ b/src/components/navigation/left/ServerSidebar.tsx @@ -22,6 +22,7 @@ import { mapChannelWithUnread, useUnreads } from "./common"; import { ChannelButton } from "../items/ButtonItem"; import ConnectionStatus from "../items/ConnectionStatus"; +import { internalEmit } from "../../../lib/eventEmitter"; interface Props { unreads: Unreads; @@ -86,6 +87,17 @@ const ServerSidebar = observer((props: Props) => { return ( { + if (e.shiftKey) { + internalEmit( + "MessageBox", + "append", + `<#${entry._id}>`, + "mention", + ); + e.preventDefault() + } + }} key={entry._id} active={active} to={`/server/${server!._id}/channel/${entry._id}`}> diff --git a/src/lib/ConditionalLink.tsx b/src/lib/ConditionalLink.tsx index b2057c4d..fbe4fdd9 100644 --- a/src/lib/ConditionalLink.tsx +++ b/src/lib/ConditionalLink.tsx @@ -9,7 +9,7 @@ export default function ConditionalLink(props: Props) { const { active, ...linkProps } = props; if (active) { - return {props.children}; + return {props.children}; } return ; }