Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 单击时所见即所得工具栏不工作?_Javascript_Reactjs_React Draft Wysiwyg - Fatal编程技术网

Javascript 单击时所见即所得工具栏不工作?

Javascript 单击时所见即所得工具栏不工作?,javascript,reactjs,react-draft-wysiwyg,Javascript,Reactjs,React Draft Wysiwyg,当我按下“正常”、“图像”、“链接”等按钮时,它没有下拉菜单,这是怎么回事 import React,{Component,Fragment}来自'React'; 从'draft js'导入{EditorState,ContentState,convertToRaw,convertFromHTML}; 从“react draft wysiwyg”导入{Editor}; 导入“../../../node_modules/react draft wysiwyg/dist/react draft w

当我按下“正常”、“图像”、“链接”等按钮时,它没有下拉菜单,这是怎么回事

import React,{Component,Fragment}来自'React';
从'draft js'导入{EditorState,ContentState,convertToRaw,convertFromHTML};
从“react draft wysiwyg”导入{Editor};
导入“../../../node_modules/react draft wysiwyg/dist/react draft wysiwyg.css”;
从“draftjs到html”导入draftToHtml;
//从“html到draftjs”导入htmlToDraft;
类DraftEditor扩展组件{
建造师(道具){
超级(道具)
此.state={
editorState:editorState.createEmpty(),
}
}
componentDidMount(){
console.log(this.props.defaultValue)
if(this.props.defaultValue){
这是我的国家({
editorState:editorState.createWithContent(
ContentState.createFromBlockArray(
convertFromHTML(this.props.defaultValue)
)
)
})
}
}
onEditorStateChange=(editorState)=>{
const html=draftToHtml(convertToRaw(editorState.getCurrentContent()))
this.setState({editorState:editorState},()=>{
this.props.onEditorStateChange(html)
});
};
render(){
const{editorState}=this.state;
返回(
{/*  */}
);
}
}
导出默认绘图编辑器
import React, { Component, Fragment } from 'react';
import { EditorState, ContentState, convertToRaw, convertFromHTML } from 'draft-js';
import { Editor } from 'react-draft-wysiwyg';
import '../../../node_modules/react-draft-wysiwyg/dist/react-draft-wysiwyg.css';
import draftToHtml from 'draftjs-to-html';
// import htmlToDraft from 'html-to-draftjs';

class DraftEditor extends Component {
  constructor(props) {
    super(props)
    this.state = {
      editorState: EditorState.createEmpty(),
    }
  }

  componentDidMount() {
    console.log(this.props.defaultValue)
    if (this.props.defaultValue) {
      this.setState({
        editorState: EditorState.createWithContent(
          ContentState.createFromBlockArray(
            convertFromHTML(this.props.defaultValue)
          )
        )
      })
    }
  }

  onEditorStateChange = (editorState) => {
    const html = draftToHtml(convertToRaw(editorState.getCurrentContent()))
    this.setState({ editorState: editorState }, () => {
      this.props.onEditorStateChange(html)
    });
  };

  render() {
    const { editorState } = this.state;
    return (
      <Fragment>
        <Editor
          editorState={editorState}
          // wrapperClassName="demo-wrapper"
          // editorClassName="demo-editor"
          toolbarClassName="toolbarClassName"
          wrapperClassName="wrapperClassName"
          editorClassName="editorClassName"
          onEditorStateChange={this.onEditorStateChange}
        />
        {/* <textarea
          disabled
          value={draftToHtml(convertToRaw(editorState.getCurrentContent()))}
        /> */}
      </Fragment>
    );
  }
}
export default DraftEditor