2

after getting the contentState from server and "converting From Raw" Im displaying it inside an Editor and it shows only the native emojis.

event though that before sending it to the server, the chat editor displayed the emojis right

this is the process

    const contentState = convertFromRaw(JSON.parse(comment.message))
    const editorState = EditorState.createWithContent(contentState)
    <ChatTemplate 
                  user={currentUser === comment.userId} 
                  value={editorState} 
                  time={moment(comment.createdAt).startOf('second').fromNow()} />

and the editor

  const ChatTemplate = (p)=>(
       <div className='globalMassage-cont' data-user={p.user} >
         <div className='globalMassage-value'>
           <Editor
             editorState={p.value}
             plugins={plugins}
             readOnly
            />
         </div>
       </div>
     )

the imports and constants

import Editor, { createEditorStateWithText } from "draft-js-plugins-editor";
import createEmojiPlugin from "draft-js-emoji-plugin";
import { EditorState, ContentState, convertFromRaw } from "draft-js";
const emojiPlugin = createEmojiPlugin();
const { EmojiSuggestions, EmojiSelect } = emojiPlugin;
const plugins = [emojiPlugin];
elad BA
  • 1,760
  • 11
  • 17

0 Answers0