Add text reaction (#1462)
This commit is contained in:
parent
5eafa37cdd
commit
144cf71368
2 changed files with 27 additions and 1 deletions
|
@ -13,6 +13,7 @@ import React, {
|
||||||
import {
|
import {
|
||||||
Badge,
|
Badge,
|
||||||
Box,
|
Box,
|
||||||
|
Chip,
|
||||||
Icon,
|
Icon,
|
||||||
IconButton,
|
IconButton,
|
||||||
Icons,
|
Icons,
|
||||||
|
@ -623,6 +624,7 @@ export function EmojiBoard({
|
||||||
onEmojiSelect,
|
onEmojiSelect,
|
||||||
onCustomEmojiSelect,
|
onCustomEmojiSelect,
|
||||||
onStickerSelect,
|
onStickerSelect,
|
||||||
|
allowTextCustomEmoji,
|
||||||
}: {
|
}: {
|
||||||
tab?: EmojiBoardTab;
|
tab?: EmojiBoardTab;
|
||||||
onTabChange?: (tab: EmojiBoardTab) => void;
|
onTabChange?: (tab: EmojiBoardTab) => void;
|
||||||
|
@ -632,6 +634,7 @@ export function EmojiBoard({
|
||||||
onEmojiSelect?: (unicode: string, shortcode: string) => void;
|
onEmojiSelect?: (unicode: string, shortcode: string) => void;
|
||||||
onCustomEmojiSelect?: (mxc: string, shortcode: string) => void;
|
onCustomEmojiSelect?: (mxc: string, shortcode: string) => void;
|
||||||
onStickerSelect?: (mxc: string, shortcode: string) => void;
|
onStickerSelect?: (mxc: string, shortcode: string) => void;
|
||||||
|
allowTextCustomEmoji?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const emojiTab = tab === EmojiBoardTab.Emoji;
|
const emojiTab = tab === EmojiBoardTab.Emoji;
|
||||||
const stickerTab = tab === EmojiBoardTab.Sticker;
|
const stickerTab = tab === EmojiBoardTab.Sticker;
|
||||||
|
@ -777,11 +780,33 @@ export function EmojiBoard({
|
||||||
<Box direction="Column" gap="200">
|
<Box direction="Column" gap="200">
|
||||||
{onTabChange && <EmojiBoardTabs tab={tab} onTabChange={onTabChange} />}
|
{onTabChange && <EmojiBoardTabs tab={tab} onTabChange={onTabChange} />}
|
||||||
<Input
|
<Input
|
||||||
|
data-emoji-board-search
|
||||||
variant="SurfaceVariant"
|
variant="SurfaceVariant"
|
||||||
size="400"
|
size="400"
|
||||||
placeholder="Search"
|
placeholder="Search"
|
||||||
maxLength={50}
|
maxLength={50}
|
||||||
after={<Icon src={Icons.Search} size="50" />}
|
after={
|
||||||
|
allowTextCustomEmoji && result?.query ? (
|
||||||
|
<Chip
|
||||||
|
variant="Primary"
|
||||||
|
radii="Pill"
|
||||||
|
after={<Icon src={Icons.ArrowRight} size="50" />}
|
||||||
|
onClick={() => {
|
||||||
|
const searchInput = document.querySelector<HTMLInputElement>(
|
||||||
|
'[data-emoji-board-search="true"]'
|
||||||
|
);
|
||||||
|
const textReaction = searchInput?.value.trim();
|
||||||
|
if (!textReaction) return;
|
||||||
|
onCustomEmojiSelect?.(textReaction, textReaction);
|
||||||
|
requestClose();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text size="L400">React</Text>
|
||||||
|
</Chip>
|
||||||
|
) : (
|
||||||
|
<Icon src={Icons.Search} size="50" />
|
||||||
|
)
|
||||||
|
}
|
||||||
onChange={handleOnChange}
|
onChange={handleOnChange}
|
||||||
autoFocus={!mobileOrTablet()}
|
autoFocus={!mobileOrTablet()}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -734,6 +734,7 @@ export const Message = as<'div', MessageProps>(
|
||||||
<EmojiBoard
|
<EmojiBoard
|
||||||
imagePackRooms={imagePackRooms ?? []}
|
imagePackRooms={imagePackRooms ?? []}
|
||||||
returnFocusOnDeactivate={false}
|
returnFocusOnDeactivate={false}
|
||||||
|
allowTextCustomEmoji
|
||||||
onEmojiSelect={(key) => {
|
onEmojiSelect={(key) => {
|
||||||
onReactionToggle(mEvent.getId()!, key);
|
onReactionToggle(mEvent.getId()!, key);
|
||||||
setEmojiBoard(false);
|
setEmojiBoard(false);
|
||||||
|
|
Loading…
Reference in a new issue