feat: add reactions

This commit is contained in:
Paul Makles
2022-07-16 15:17:02 +01:00
parent dbe8a64ffc
commit 084c90613f
7 changed files with 95 additions and 20 deletions

View File

@@ -25,15 +25,21 @@ const Emoji = styled.img`
}
`;
const RE_EMOJI = /:([a-zA-Z0-9_+]+):/g;
const RE_ULID = /^[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}$/;
export function RenderEmoji({ match }: CustomComponentProps) {
const [fail, setFail] = useState(false);
const url =
match in emojiDictionary
? parseEmoji(emojiDictionary[match as keyof typeof emojiDictionary])
: `${
clientController.getAvailableClient().configuration?.features
.autumn.url
}/emojis/${match}`;
const url = RE_ULID.test(match)
? `${
clientController.getAvailableClient().configuration?.features
.autumn.url
}/emojis/${match}`
: parseEmoji(
match in emojiDictionary
? emojiDictionary[match as keyof typeof emojiDictionary]
: match,
);
if (fail) return <span>{`:${match}:`}</span>;
@@ -49,9 +55,6 @@ export function RenderEmoji({ match }: CustomComponentProps) {
);
}
const RE_EMOJI = /:([a-zA-Z0-9_+]+):/g;
const RE_ULID = /^[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}$/;
export const remarkEmoji = createComponent(
"emoji",
RE_EMOJI,

View File

@@ -6,9 +6,9 @@ import { visit } from "unist-util-visit";
* Props given to custom components
*/
export interface CustomComponentProps {
type: string;
type?: string;
match: string;
arg1: string;
arg1?: string;
}
/**