Display reactions below messages
This commit is contained in:
24
matrixgw_frontend/src/widgets/EmojiIcon.tsx
Normal file
24
matrixgw_frontend/src/widgets/EmojiIcon.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Emoji, EmojiStyle } from "emoji-picker-react";
|
||||
|
||||
function emojiUnicode(emoji: string): string {
|
||||
let comp;
|
||||
if (emoji.length === 1) {
|
||||
comp = emoji.charCodeAt(0);
|
||||
}
|
||||
comp =
|
||||
(emoji.charCodeAt(0) - 0xd800) * 0x400 +
|
||||
(emoji.charCodeAt(1) - 0xdc00) +
|
||||
0x10000;
|
||||
if (comp < 0) {
|
||||
comp = emoji.charCodeAt(0);
|
||||
}
|
||||
const s = comp.toString(16);
|
||||
return s.includes("f") ? s : `${s}-fe0f`;
|
||||
}
|
||||
|
||||
export function EmojiIcon(p: { emojiKey: string }): React.ReactElement {
|
||||
const unified = emojiUnicode(p.emojiKey);
|
||||
return (
|
||||
<Emoji unified={unified ?? ""} emojiStyle={EmojiStyle.GOOGLE} size={18} />
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user