import React, { useState, useRef, ReactElement } from 'react'; import Editor, { createEditorStateWithText } from '@draft-js-plugins/editor'; import createEmojiPlugin from '@draft-js-plugins/emoji'; import editorStyles from './editorStyles.css'; const emojiPlugin = createEmojiPlugin({ useNativeArt: true, }); const { EmojiSuggestions, EmojiSelect } = emojiPlugin; const plugins = [emojiPlugin]; const text = `Cool, we can have all sorts of Emojis here. 🙌 🌿☃️🎉🙈 aaaand maybe a few more here 🐲☀️🗻 Quite fun!`; const CustomEmojiEditor = (): ReactElement => { const [editorState, setEditorState] = useState( createEditorStateWithText(text) ); const editor = useRef(); const onChange = (value): void => { setEditorState(value); }; const focus = (): void => { editor.current.focus(); }; return (
{ editor.current = element; }} />
); }; export default CustomEmojiEditor;