通用评论

1
  1. {"version":3,"sources":["../../../src/components/Editor/index.js"],"names":["TextArea","EditorDefaultProps","rows","placeholder","showEmoji","showUpload","submitText","onChange","Editor","props","state","handleClickEmoji","bind","handleShowUpload","emojiId","onChangeEmoji","setState","value","onSubmit","loading","fileList","onChangeFileList","onUpload","e","target","float","margin","width","zIndex","MAX_UPLOAD_NUMBER","minHeight","color","fontWeight","length","cursor","marginTop","marginLeft","React","Component","propTypes","PropTypes","number","string","bool","func"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;AACA;;;;AAEA;;AACA;;;;AACA;;;;AACA;;;;;;;;;;IAEQA,Q,mBAAAA,Q;AACR;AACA;AACA;AACA;;AACA,IAAMC,qBAAqB;AACzBC,QAAM,CADmB;AAEzBC,eAAa,UAFY;AAGzBC,aAAW,IAHc;AAIzBC,cAAY,IAJa;AAKzBC,cAAY,IALa;AAMzBC,YAAU,oBAAM,CAAE;AANO,CAA3B;;IASMC,M;;;AACJ,kBAAYC,KAAZ,EAAmB;AAAA;;AAAA,gHACXA,KADW;;AAEjB,UAAKC,KAAL,GAAa;AACXL,kBAAY;AADD,KAAb;AAGA,UAAKM,gBAAL,GAAwB,MAAKA,gBAAL,CAAsBC,IAAtB,OAAxB;AACA,UAAKC,gBAAL,GAAwB,MAAKA,gBAAL,CAAsBD,IAAtB,OAAxB;AANiB;AAOlB;;;;wCAEmB,CAAE;;;qCAELE,O,EAAS;AACxB,WAAKL,KAAL,CAAWM,aAAX,CAAyBD,OAAzB;AACD;;;qCAEgBT,U,EAAY;AAC3B,UAAI,OAAOA,UAAP,KAAsB,SAA1B,EAAqC;AACnC,aAAKW,QAAL,CAAc,EAAEX,YAAYA,UAAd,EAAd;AACD,OAFD,MAEO;AACL,aAAKW,QAAL,CAAc,EAAEX,YAAY,CAAC,KAAKK,KAAL,CAAWL,UAA1B,EAAd;AACD;AACF;;;6BAEQ;AAAA;;AACP,UAAMI,qBAAaR,kBAAb,EAAoC,KAA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L;AAKjBrC,cAAYkC,oBAAUE,MALL;AAMjBnC,YAAUiC,oBAAUI;AANH,CAAnB;;kBASepC,M","file":"index.js","sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { Icon, Button, Popover, Input } from \"antd\";\nimport { MAX_UPLOAD_NUMBER } from \"../../constant\";\nimport Upload from \"./Upload\";\nimport Emoji from \"./Emoji\";\nimport \"./index.css\";\n\nconst { TextArea } = Input;\n// 设置 Editor 组件的默认值\n// 不能在 Editor.defaultProps 中设置\n// 因为 Editor 在 ComponentInput 中调用\n// 在 ComponentInput 中,需要使用 Editor 的 props 覆盖 ComponentInput 传入的 props\nconst EditorDefaultProps = {\n rows: 5,\n placeholder: \"说点什么吧...\",\n showEmoji: true,\n showUpload: true,\n submitText: \"发表\",\n onChange: () => {}\n};\n\nclass Editor extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n showUpload: false\n };\n this.handleClickEmoji = this.handleClickEmoji.bind(this);\n this.handleShowUpload = this.handleShowUpload.bind(this);\n }\n\n componentDidMount() {}\n\n handleClickEmoji(emojiId) {\n this.props.onChangeEmoji(emojiId);\n }\n\n handleShowUpload(showUpload) {\n if (typeof showUpload === \"boolean\") {\n this.setState({ showUpload: showUpload });\n } else {\n this.setState({ showUpload: !this.state.showUpload });\n }\n }\n\n render() {\n const props = { ...EditorDefaultProps, ...this.props };\n const {\n value,\n onChange,\n onSubmit,\n loading,\n placeholder,\n fileList,\n onChangeFileList,\n rows,\n onUpload,\n showEmoji,\n showUpload,\n submitText\n } = props;\n\n return (\n <div className=\"editor\">\n <TextArea\n value={value}\n onChange={e => onChange(e.target.value)}\n rows={rows}\n placeholder={placeholder}\n />\n\n <div className=\"toolbar\">\n <div style={{ float: \"left\", margin: \"8px 11px\" }}>\n {showEmoji && (\n <Popover\n trigger=\"click\"\n placement=\"bottomLeft\"\n autoAdjustOverflow={false}\n content={\n <div style={{ width: 200 }}>\n <Emoji onClick={this.handleClickEmoji} />\n </div>\n }\n overlayClassName=\"feed\"\n >\n <Icon type=\"smile-o\" className=\"icon\" />\n </Popover>\n )}\n\n {showUpload && (\n <Popover\n visible={this.state.showUpload}\n overlayStyle={{ zIndex: 999 }}\n content={\n <div\n style={{ width: 112 * MAX_UPLOAD_NUMBER, minHeight: 100 }}\n >\n <Upload\n onChangeFileList={onChangeFileList}\n onUpload={onUpload}\n fileList={fileList}\n />\n </div>\n }\n placement=\"bottomLeft\"\n title={\n <div style={{ margin: \"5px auto\" }}>\n <span>\n 上传图片\n <span style={{ color: \"#666\", fontWeight: 400 }}>\n (您还能上传{MAX_UPLOAD_NUMBER - fileList.length}张图片)\n </span>\n </span>\n <Icon\n type=\"close\"\n onClick={() => this.handleShowUpload(false)}\n style={{\n float: \"right\",\n cursor: \"pointer\",\n marginTop: 4\n }}\n />\n </div>\n }\n >\n <Icon\n type=\"picture\"\n className=\"icon\"\n style={{ marginLeft: 10 }}\n onClick={() => this.handleShowUpload(true)}\n />\n </Popover>\n )}\n </div>\n\n <div style={{ float: \"right\", margin: \"5px 11px\" }}>\n <Button onClick={onSubmit} type=\"primary\" loading={loading}>\n {submitText}\n </Button>\n </div>\n </div>\n </div>\n );\n }\n}\n\nEditor.propTypes = {\n rows: PropTypes.number,\n placeholder: PropTypes.string,\n showEmoji: PropTypes.bool,\n showUpload: PropTypes.bool,\n submitText: PropTypes.string,\n onChange: PropTypes.func\n};\n\nexport default Editor;\n"]}