{"version":3,"sources":["../../../src/components/Editor/index.js"],"names":["TextArea","client","window","OSS","Wrapper","accessKeyId","oss","access_key_id","accessKeySecret","access_key_secret","stsToken","security_token","endpoint","OSS_ENDPOINT","bucket","OSS_BUCKET","uploadPath","path","file","format","shortid","generate","type","split","UploadToOss","url","Promise","resolve","reject","multipartUpload","then","data","catch","error","Editor","props","state","showUpload","value","fileList","fileMap","uploadVisible","handleChange","bind","handleClickEmoji","handleChangeFileList","handleShowUpload","handleUpload","handleSubmit","handlePaste","resetState","handleEmojiScroll","app","currentUser","user_id","sOssSts","onRef","e","emoji","preventDefault","deltaY","next","prev","setState","onChange","list","length","maxUpload","slice","uid","map","item","thumbUrl","OSS_LINK","items","clipboardData","i","indexOf","getAsFile","reader","FileReader","readAsDataURL","onloadend","DRIVER_LICENSE_PATH","concat","name","Date","valueOf","msg","message","ERROR_DEFAULT","showError","onError","response","maxLength","intl","get","files","forEach","push","beforeSubmit","text","res","onSubmit","action","onCommentSuccess","btnDisabled","rows","showEmoji","multiple","emojiPopoverPlacement","uploadPopoverPlacement","uploadOverlayClassName","btnLoading","button","emojiToolIcon","imageToolIcon","autoFocus","placeholder","btnSubmitText","disabledSubmit","checkDisabledSubmit","inputValue","uploadFileList","isLogin","target","zIndex","width","height","node","emojiList","visible","minHeight","margin","uploadRef","color","fontWeight","count","React","cloneElement","onClick","marginLeft","location","href","LOGINLINK","Component","propTypes","PropTypes","number","string","bool","closeUploadWhenBlur","func","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;AACA;;;;AAEA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;AACA;;AACA;;;;AACA;;;;AACA;;;;AAOA;;;;;;;;;;IAEQA,Q,mBAAAA,Q;;;AAER,IAAMC,SAAS,SAATA,MAAS,MAAO;AACpB,SAAO,IAAIC,OAAOC,GAAP,CAAWC,OAAf,CAAuB;AAC5BC,iBAAaC,IAAIC,aADW;AAE5BC,qBAAiBF,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,oBAAUE,MAfR;AAgBjBpC,cAAYkC,oBAAUG,IAhBL;AAiBjB5C,eAAayC,oBAAUG,IAjBN;AAkBjBpC,UAAQiC,oBAAUlB,IAlBD;AAmBjBd,iBAAegC,oBAAUlB,IAnBR;AAoBjBb,iBAAe+B,oBAAUlB,IApBR;AAqBjBtC,aAAWwD,oBAAUG,IArBJ;AAsBjB1D,WAASuD,oBAAUK,IAtBF;AAuBjB1D,aAAWqD,oBAAUC;AAvBJ,CAAnB;;AA0BAlH,OAAOuH,YAAP,GAAsB;AACpB9C,QAAM,CADc;AAEpB;AACAC,aAAW,IAHS;AAIpBvE,cAAY,IAJQ;AAKpBwE,YAAU,IALU;AAMpBC,yBAAuB,YANH;AAOpByC,uBAAqB,KAPD;AAQpBxC,0BAAwB,YARJ;AASpBC,0BAAwB,EATJ;AAUpB7C,aAAW,CAVS;AAWpB;AACA8C,cAAY,KAZQ;AAapBP,eAAa,KAbO;AAcpBf,aAAW,IAdS;AAepBG,aAAW,IAfS;AAgBpBjD,wBAAsB,gCAAM,CAAE;AAhBV,CAAtB;;kBAmBe,uBAAQX,MAAR,C","file":"index.js","sourcesContent":["import React, { Fragment } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { Icon, Button, Popover, Input, message } from \"antd\";\nimport classnames from \"classnames\";\nimport intl from \"react-intl-universal\";\nimport dayjs from \"dayjs\";\nimport shortid from \"shortid\";\nimport { OSS_LINK } from \"../../constant\";\nimport { isFunction } from \"../../helper\";\nimport Upload from \"./Upload\";\nimport Emoji from \"./Emoji\";\nimport Comment from \"../../Comment\";\nimport {\n OSS_ENDPOINT,\n OSS_BUCKET,\n DRIVER_LICENSE_PATH,\n ERROR_DEFAULT\n} from \"../../constant\";\nimport \"./index.css\";\n\nconst { TextArea } = Input;\n\nconst client = oss => {\n return new window.OSS.Wrapper({\n accessKeyId: oss.access_key_id,\n accessKeySecret: oss.access_key_secret,\n stsToken: oss.security_token,\n endpoint: OSS_ENDPOINT, //常量,你可以自己定义\n bucket: OSS_BUCKET\n });\n};\n\nconst uploadPath = (path, file) => {\n return `${path}/${dayjs().format(\"YYYYMMDD\")}/${shortid.generate()}.${\n file.type.split(\"/\")[1]\n }`;\n};\n\nconst UploadToOss = (oss, path, file) => {\n const url = uploadPath(path, file);\n return new Promise((resolve, reject) => {\n client(oss)\n .multipartUpload(url, file)\n .then(data => {\n resolve(data);\n })\n .catch(error => {\n reject(error);\n });\n });\n};\n\nclass Editor extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n showUpload: false,\n value: props.value || \"\", // 编辑器里面的值\n fileList: props.fileList || [], // 图片列表\n fileMap: {}, // 已经上传的图片路径和 uid 的映射 { uid: path }\n uploadVisible: false\n };\n this.handleChange = this.handleChange.bind(this);\n this.handleClickEmoji = this.handleClickEmoji.bind(this);\n this.handleChangeFileList = this.handleChangeFileList.bind(this);\n this.handleShowUpload = this.handleShowUpload.bind(this);\n this.handleUpload = this.handleUpload.bind(this);\n this.handleSubmit = this.handleSubmit.bind(this);\n this.handlePaste = this.handlePaste.bind(this);\n this.resetState = this.resetState.bind(this);\n this.handleEmojiScroll = this.handleEmojiScroll.bind(this);\n }\n\n componentDidMount() {\n if (this.props.app.currentUser && this.props.app.currentUser.user_id > 0) {\n this.props.app.sOssSts();\n }\n if (isFunction(this.props.onRef)) {\n this.props.onRef(this);\n }\n }\n\n handleEmojiScroll(e) {\n if (!this.emoji) {\n return;\n }\n e.preventDefault();\n if (e.deltaY > 0) {\n this.emoji.next();\n } else if (e.deltaY < 0) {\n this.emoji.prev();\n }\n }\n\n /**\n * 编辑器的值改变事件\n * 将最新的值存储到 state 中\n * @param {string} value 输入的值\n */\n handleChange(value) {\n this.setState({ value });\n if (this.props.onChange) {\n this.props.onChange(value);\n }\n }\n\n /**\n * 点击 emoji 的事件\n * 点击后,需要将改 emoji 插入到编辑器中\n * 插入的值为 [emoji chinese name]\n * 参数 emoji 即为 emoji chinese name\n * @param {string}} emoji emoji 的中文,如 微笑\n */\n handleClickEmoji(emoji) {\n let value = this.props.value || this.state.value;\n value += `[${emoji}]`;\n this.handleChange(value);\n }\n\n /**\n * 监听文件列表改变事件\n * @param {Array} fileList 文件列表\n */\n handleChangeFileList(fileList) {\n let list = fileList;\n if (fileList.length > this.props.maxUpload) {\n list = fileList.slice(0, this.props.maxUpload);\n }\n this.props.handleChangeFileList(list);\n this.setState({ fileList: list });\n }\n\n /**\n * 控制上传 Popover 的显示和隐藏\n * @param {boolean} showUpload 是否显示上传的 Popover\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 /**\n * 上传文件\n * @param {object} param 文件对象\n */\n handleUpload({ uid, path }) {\n const { fileMap } = this.state;\n let { fileList } = this.state;\n fileMap[uid] = path;\n fileList = fileList.map(item => {\n if (item.uid === uid) {\n item.thumbUrl = OSS_LINK + path;\n }\n return item;\n });\n this.props.handleChangeFileList(fileList);\n this.setState({ fileMap, fileList });\n }\n\n /**\n * 粘贴回调\n */\n handlePaste(e) {\n if (this.state.fileList.length >= this.props.maxUpload) {\n return;\n }\n const items = e.clipboardData && e.clipboardData.items;\n let file = null;\n if (items && items.length) {\n for (let i = 0; i < items.length; i++) {\n if (items[i].type.indexOf(\"image\") !== -1) {\n file = items[i].getAsFile();\n break;\n }\n }\n }\n this.setState({\n uploadVisible: true\n });\n let reader = new FileReader();\n reader.readAsDataURL(file);\n reader.onloadend = () => {\n // DRIVER_LICENSE_PATH oss 的存储路径位置\n UploadToOss(this.props.app.oss, DRIVER_LICENSE_PATH, file)\n .then(data => {\n const fileList = this.state.fileList.concat({\n url: OSS_LINK + data.name,\n thumbUrl: OSS_LINK + data.name,\n type: file.type,\n uid: new Date().valueOf()\n });\n this.props.handleChangeFileList(fileList);\n this.setState({\n fileList\n });\n })\n .catch(e => {\n const msg = e.message || ERROR_DEFAULT;\n if (this.props.showError) {\n message.error(msg);\n }\n if (this.props.onError) {\n this.props.onError(msg, { response: e.response });\n }\n });\n };\n }\n\n /**\n * 提交编辑器内容\n * 提交功能,交给父组件来实现\n * 需要父组件传入 onSubmit\n */\n handleSubmit() {\n const { maxLength } = this.props;\n let { value, fileMap, fileList } = this.state;\n if (value.length > maxLength) {\n // message.error(`字数不得超过${maxLength}字`);\n message.error(intl.get(\"editor.maxLength\", { maxLength }));\n return;\n }\n const files = [];\n if (fileList.length) {\n fileList.forEach(item => {\n if (item.url) {\n files.push(item.url);\n return;\n }\n if (!fileMap[item.uid]) {\n return;\n }\n files.push(`${OSS_LINK}${fileMap[item.uid]}`);\n });\n }\n if (this.props.beforeSubmit) {\n Promise.resolve(this.props.beforeSubmit({ text: value, files })).then(\n res => {\n if (!(res === false)) {\n this.props.onSubmit({ text: value, files }, (res, action) => {\n this.resetState();\n if (action === \"comment\" && this.props.onCommentSuccess) {\n this.props.onCommentSuccess(res);\n }\n });\n }\n }\n );\n } else {\n this.props.onSubmit({ text: value, files }, (res, action) => {\n this.resetState();\n if (action === \"comment\" && this.props.onCommentSuccess) {\n this.props.onCommentSuccess(res);\n }\n });\n }\n }\n\n resetState() {\n this.handleChange(\"\");\n this.handleChangeFileList([]);\n this.setState({\n showUpload: false,\n value: \"\",\n fileList: [],\n fileMap: {}\n });\n }\n\n checkDisabledSubmit() {\n const { btnDisabled, value, fileList } = this.props;\n if (btnDisabled) {\n return true;\n }\n if (value && value !== \"\") {\n return false;\n }\n if (this.state.value && this.state.value !== \"\") {\n return false;\n }\n if (fileList && fileList.length > 0) {\n return false;\n }\n if (this.state.fileList.length > 0) {\n return false;\n }\n return true;\n }\n\n render() {\n const {\n value,\n // placeholder,\n rows,\n showEmoji,\n showUpload,\n multiple,\n emojiPopoverPlacement,\n uploadPopoverPlacement,\n uploadOverlayClassName,\n fileList,\n maxUpload,\n // btnSubmitText,\n btnLoading,\n button,\n emojiToolIcon,\n imageToolIcon,\n maxLength,\n autoFocus,\n app\n } = this.props;\n let placeholder = this.props.placeholder || intl.get(\"editor.placeholder\");\n let btnSubmitText =\n this.props.btnSubmitText || intl.get(\"editor.SubmitBtn\");\n const handleSubmit = this.handleSubmit;\n const disabledSubmit = this.checkDisabledSubmit();\n const inputValue = value || this.state.value;\n const uploadFileList = fileList || this.state.fileList;\n const isLogin = app.currentUser && app.currentUser.user_id > 0;\n return (\n
\n {isLogin ? (\n \n maxLength\n })}\n >
\n
\n this.handleChange(e.target.value)}\n rows={rows}\n placeholder={placeholder}\n autoFocus={autoFocus}\n />\n\n
\n
\n {showEmoji && (\n \n {\n this.emoji = node;\n }}\n emojiList={this.props.app.emojiList}\n />\n
\n }\n overlayClassName=\"comment-emoji-popover\"\n >\n {emojiToolIcon || (\n \n )}\n \n )}\n\n {showUpload ? (\n {\n this.setState({\n uploadVisible: visible\n });\n }}\n content={\n \n (this.uploadRef = node)}\n multiple={multiple}\n onChangeFileList={this.handleChangeFileList}\n onUpload={this.handleUpload}\n maxUpload={maxUpload}\n fileList={uploadFileList}\n showError={this.props.showError}\n onError={this.props.onError}\n />\n
\n
\n }\n title={\n
\n \n {intl.get(\"editor.uploadTip\")}\n {maxUpload >= 2 ? (\n \n {intl.get(\"editor.uploadCount\", {\n count: maxUpload - uploadFileList.length\n })}\n \n ) : null}\n \n
\n }\n >\n {imageToolIcon ? (\n React.cloneElement(imageToolIcon, {\n onClick: () => this.handleShowUpload(true)\n })\n ) : (\n this.handleShowUpload(true)}\n />\n )}\n \n ) : null}\n
\n\n
\n {button ? (\n React.cloneElement(button, {\n onClick: button.props.onClick || handleSubmit\n })\n ) : (\n this.handleSubmit()}\n type=\"primary\"\n loading={btnLoading}\n disabled={disabledSubmit}\n >\n {btnSubmitText}\n \n )}\n
\n
\n \n \n ) : (\n \n
\n {intl.get(\"comment.unlogin\")}\n
\n
\n {\n window.location.href = `${app.LOGINLINK}?f=${window.location.href}`;\n }}\n >\n {intl.get(\"account.login\")}\n \n
\n
\n )}\n \n );\n }\n}\n\nEditor.propTypes = {\n rows: PropTypes.number,\n placeholder: PropTypes.string,\n showEmoji: PropTypes.bool,\n emojiPopoverPlacement: PropTypes.string,\n showUpload: PropTypes.bool,\n uploadPopoverPlacement: PropTypes.string,\n uploadOverlayClassName: PropTypes.string,\n multiple: PropTypes.bool,\n closeUploadWhenBlur: PropTypes.bool,\n maxUpload: PropTypes.number,\n value: PropTypes.string,\n onChange: PropTypes.func,\n onSubmit: PropTypes.func,\n beforeSubmit: PropTypes.func,\n btnSubmitText: PropTypes.string,\n btnLoading: PropTypes.bool,\n btnDisabled: PropTypes.bool,\n button: PropTypes.node,\n emojiToolIcon: PropTypes.node,\n imageToolIcon: PropTypes.node,\n showError: PropTypes.bool,\n onError: PropTypes.func,\n maxLength: PropTypes.number\n};\n\nEditor.defaultProps = {\n rows: 5,\n // placeholder: \"说点什么吧\",\n showEmoji: true,\n showUpload: true,\n multiple: true,\n emojiPopoverPlacement: \"bottomLeft\",\n closeUploadWhenBlur: false,\n uploadPopoverPlacement: \"bottomLeft\",\n uploadOverlayClassName: \"\",\n maxUpload: 1,\n // btnSubmitText: \"发表\",\n btnLoading: false,\n btnDisabled: false,\n showError: true,\n maxLength: 5000,\n handleChangeFileList: () => {}\n};\n\nexport default Comment(Editor);\n"]}