lemmy-ui/src/shared/components/common/emoji-mart.tsx

34 lines
770 B
TypeScript
Raw Normal View History

2022-11-27 18:02:32 +00:00
import { Component } from "inferno";
import { getEmojiMart } from "../../utils";
interface EmojiMartProps {
onEmojiClick?(val: any): any;
pickerOptions: any;
}
export class EmojiMart extends Component<
EmojiMartProps
> {
constructor(props: any, context: any) {
super(props, context);
this.handleEmojiClick = this.handleEmojiClick.bind(this);
}
componentDidMount() {
let div: any = document.getElementById("emoji-picker");
if (div) {
div.appendChild(getEmojiMart(this.handleEmojiClick, this.props.pickerOptions));
}
}
render() {
return (
<div id="emoji-picker"></div>
);
}
handleEmojiClick(e: any) {
this.props.onEmojiClick?.(e);
}
}