【发布时间】:2019-03-29 12:10:48
【问题描述】:
我使用 Draft-js 在 Web 应用程序中显示编辑器。但我在草稿编辑器中显示文件上传选项时遇到问题。
你可以在这里查看演示https://jpuri.github.io/react-draft-wysiwyg/#/
请检查下面的代码并提出解决方案:
import React, { Component } from 'react';
import logo from './logo.svg';
import { EditorState } from 'draft-js';
import { Editor } from 'react-draft-wysiwyg';
import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css';
class App extends Component {
constructor(props) {
super(props);
this.state = {
editorState: EditorState.createEmpty(),
};
}
onEditorStateChange: Function = (editorState) => {
this.setState({
editorState,
});
};
render() {
const { editorState } = this.state;
return (
<div className="App">
<header className="App-header">
<Editor
editorState={editorState}
toolbarClassName="toolbarClassName"
wrapperClassName="wrapperClassName"
editorClassName="editorClassName"
onEditorStateChange={this.onEditorStateChange}
toolbar={{
inline: { inDropdown: true },
list: { inDropdown: true },
textAlign: { inDropdown: true },
link: { inDropdown: true },
history: { inDropdown: true },
inputAccept: 'application/pdf,text/plain,application/vnd.openxmlformatsofficedocument.wordprocessingml.document,application/msword,application/vnd.ms-excel'
}}
/>
</header>
</div>
);
}
}
export default App;
【问题讨论】:
标签: reactjs blogs rich-text-editor draftjs