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

31 lines
703 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;
2022-11-27 18:02:32 +00:00
}
export class EmojiMart extends Component<EmojiMartProps> {
constructor(props: any, context: any) {
super(props, context);
this.handleEmojiClick = this.handleEmojiClick.bind(this);
}
componentDidMount() {
2023-06-05 21:31:12 +00:00
const div: any = document.getElementById("emoji-picker");
if (div) {
div.appendChild(
getEmojiMart(this.handleEmojiClick, this.props.pickerOptions)
);
2022-11-27 18:02:32 +00:00
}
}
2022-11-27 18:02:32 +00:00
render() {
return <div id="emoji-picker"></div>;
}
2022-11-27 18:02:32 +00:00
handleEmojiClick(e: any) {
this.props.onEmojiClick?.(e);
}
2022-11-27 18:02:32 +00:00
}