import Editor, { createEditorStateWithText } from '@draft-js-plugins/editor'; import React, { ReactElement, useRef, useState } from 'react'; import { EditorState } from 'draft-js'; import createEmojiPlugin from '@draft-js-plugins/emoji'; import editorStyles from './editorStyles.css'; const emojiPlugin = createEmojiPlugin(); 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 SimpleEmojiEditor = (): ReactElement => { const [editorState, setEditorState] = useState( createEditorStateWithText(text) ); const editor = useRef(); const onChange = (value: EditorState): void => { setEditorState(value); }; const focus = (): void => { editor.current.focus(); }; return (
{ editor.current = element; }} />
); }; export default SimpleEmojiEditor;