import React from "react"; import PropTypes from "prop-types"; import { Icon, Button, Popover, Input } from "antd"; import { MAX_UPLOAD_NUMBER } from "../../constant"; import Upload from "./Upload"; import Emoji from "./Emoji"; import "./index.css"; const { TextArea } = Input; // 设置 Editor 组件的默认值 // 不能在 Editor.defaultProps 中设置 // 因为 Editor 在 ComponentInput 中调用 // 在 ComponentInput 中,需要使用 Editor 的 props 覆盖 ComponentInput 传入的 props const EditorDefaultProps = { rows: 5, placeholder: "说点什么吧...", showEmoji: true, showUpload: true, submitText: "发表", onChange: () => {} }; class Editor extends React.Component { constructor(props) { super(props); this.state = { showUpload: false }; this.handleClickEmoji = this.handleClickEmoji.bind(this); this.handleShowUpload = this.handleShowUpload.bind(this); } componentDidMount() {} handleClickEmoji(emojiId) { this.props.onChangeEmoji(emojiId); } handleShowUpload(showUpload) { if (typeof showUpload === "boolean") { this.setState({ showUpload: showUpload }); } else { this.setState({ showUpload: !this.state.showUpload }); } } render() { const props = { ...EditorDefaultProps, ...this.props }; const { value, onChange, onSubmit, loading, placeholder, fileList, onChangeFileList, rows, onUpload, showEmoji, showUpload, submitText } = props; return (