From 144cf7136887e2a31522511d42c3065ba17ade58 Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Thu, 19 Oct 2023 22:20:38 +1100 Subject: [PATCH] Add text reaction (#1462) --- src/app/components/emoji-board/EmojiBoard.tsx | 27 ++++++++++++++++++- src/app/organisms/room/message/Message.tsx | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/app/components/emoji-board/EmojiBoard.tsx b/src/app/components/emoji-board/EmojiBoard.tsx index 067ebe3..94ba14c 100644 --- a/src/app/components/emoji-board/EmojiBoard.tsx +++ b/src/app/components/emoji-board/EmojiBoard.tsx @@ -13,6 +13,7 @@ import React, { import { Badge, Box, + Chip, Icon, IconButton, Icons, @@ -623,6 +624,7 @@ export function EmojiBoard({ onEmojiSelect, onCustomEmojiSelect, onStickerSelect, + allowTextCustomEmoji, }: { tab?: EmojiBoardTab; onTabChange?: (tab: EmojiBoardTab) => void; @@ -632,6 +634,7 @@ export function EmojiBoard({ onEmojiSelect?: (unicode: string, shortcode: string) => void; onCustomEmojiSelect?: (mxc: string, shortcode: string) => void; onStickerSelect?: (mxc: string, shortcode: string) => void; + allowTextCustomEmoji?: boolean; }) { const emojiTab = tab === EmojiBoardTab.Emoji; const stickerTab = tab === EmojiBoardTab.Sticker; @@ -777,11 +780,33 @@ export function EmojiBoard({ {onTabChange && } } + after={ + allowTextCustomEmoji && result?.query ? ( + } + onClick={() => { + const searchInput = document.querySelector( + '[data-emoji-board-search="true"]' + ); + const textReaction = searchInput?.value.trim(); + if (!textReaction) return; + onCustomEmojiSelect?.(textReaction, textReaction); + requestClose(); + }} + > + React + + ) : ( + + ) + } onChange={handleOnChange} autoFocus={!mobileOrTablet()} /> diff --git a/src/app/organisms/room/message/Message.tsx b/src/app/organisms/room/message/Message.tsx index f5d2550..e26f366 100644 --- a/src/app/organisms/room/message/Message.tsx +++ b/src/app/organisms/room/message/Message.tsx @@ -734,6 +734,7 @@ export const Message = as<'div', MessageProps>( { onReactionToggle(mEvent.getId()!, key); setEmojiBoard(false);