draft-js编辑器只显示本机表情符号

时间:2018-05-28 12:15:32

标签: reactjs draftjs draft-js-plugins

从服务器获取contentState后,"转换自Raw" 我在编辑器中显示它,它只显示本机的表情符号。

事件虽然在发送到服务器之前,聊天编辑器显示了正确的表情符号

这是过程

    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()} />

和编辑

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

导入和常量

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];

0 个答案:

没有答案