通用评论

index.js.map 29KB

1
  1. {"version":3,"sources":["../../../src/components/Editor/index.js"],"names":["TextArea","Editor","props","state","showUpload","value","fileList","fileMap","uploadVisible","handleChange","bind","handleClickEmoji","handleChangeFileList","handleShowUpload","handleUpload","handleSubmit","handlePaste","resetState","handleEmojiScroll","handlePressEnter","invokeFileListChange","app","onRef","currentUser","user_id","id","sOssSts","e","emoji","preventDefault","deltaY","next","prev","setState","onChange","list","length","maxUpload","slice","uid","path","map","item","thumbUrl","OSS_LINK","limitOne","isMobile","file","status","includes","items","clipboardData","i","type","indexOf","getAsFile","reader","FileReader","readAsDataURL","onloadend","UploadToOss","oss","DRIVER_LICENSE_PATH","then","concat","url","data","name","Date","valueOf","catch","msg","message","ERROR_DEFAULT","showError","error","onError","response","maxLength","intl","get","files","forEach","push","beforeSubmit","Promise","resolve","text","res","onSubmit","action","onCommentSuccess","btnDisabled","allowEnterSubmit","shiftKey","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","uploadRef","count","React","cloneElement","onClick","marginLeft","window","location","href","LOGINLINK","Component","propTypes","PropTypes","number","string","bool","closeUploadWhenBlur","func","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;AACA;;;;AACA;;;;AACA;;;;AAEA;;;;AACA;;;;AACA;;;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;IAEQA,Q,mBAAAA,Q;;IAEFC,M;;;AACJ,kBAAYC,KAAZ,EAAmB;AAAA;;AAAA,gHACXA,KADW;;AAEjB,UAAKC,KAAL,GAAa;AACXC,kBAAY,KADD;AAEXC,aAAOH,MAAMG,KAAN,IAAe,EAFX,EAEe;AAC1BC,gBAAUJ,MAAMI,QAAN,IAAkB,EAHjB,EAGqB;A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,CAAnB;;AA8BAtI,OAAOyI,YAAP,GAAsB;AACpB3C,QAAM,CADc;AAEpB;AACAC,aAAW,IAHS;AAIpB5F,cAAY,IAJQ;AAKpB6F,YAAU,IALU;AAMpBC,yBAAuB,YANH;AAOpBsC,uBAAqB,KAPD;AAQpBrC,0BAAwB,YARJ;AASpBC,0BAAwB,EATJ;AAUpB/D,aAAW,CAVS;AAWpB;AACAgE,cAAY,KAZQ;AAapBT,eAAa,KAbO;AAcpBlB,aAAW,IAdS;AAepBI,aAAW,IAfS;AAgBpBzD,OAAK,EAhBe;AAiBpBT,wBAAsB,gCAAM,CAAE,CAjBV;AAkBpB;AACAiF,oBAAkB,KAnBE;AAoBpBhD,YAAU;AApBU,CAAtB;;kBAuBe,uBAAQ5C,MAAR,C","file":"index.js","sourcesContent":["import PropTypes from \"prop-types\";\nimport classnames from \"classnames\";\nimport React, { Fragment } from \"react\";\nimport intl from \"react-intl-universal\";\nimport { Icon, Button, Popover, Input, message } from \"antd\";\nimport Emoji from \"./Emoji\";\nimport Upload from \"./Upload\";\nimport Comment from \"../../Comment\";\nimport { isMobile } from \"./../../utils\";\nimport { OSS_LINK } from \"../../constant\";\nimport { isFunction } from \"../../helper\";\nimport { DRIVER_LICENSE_PATH, ERROR_DEFAULT } from \"../../constant\";\nimport \"./index.css\";\n\nconst { TextArea } = Input;\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 this.handlePressEnter = this.handlePressEnter.bind(this);\n this.invokeFileListChange = this.invokeFileListChange.bind(this);\n }\n\n componentDidMount() {\n const { app, onRef } = this.props;\n if (\n app.currentUser &&\n (app.currentUser.user_id > 0 || app.currentUser.id > 0)\n ) {\n app.sOssSts();\n }\n if (isFunction(onRef)) {\n 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.invokeFileListChange(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.setState({ fileMap });\n this.invokeFileListChange(fileList);\n }\n\n /**\n * **统一处理fileList的修改**\n * 1. upload\n * 2. paste\n * PS: 移动端需要做额外操作\n * -- evo 20200223\n */\n invokeFileListChange(fileList) {\n const { limitOne, handleChangeFileList } = this.props;\n handleChangeFileList(fileList);\n this.setState({ fileList });\n if (limitOne && isMobile) {\n const file = fileList[0];\n if (\n file &&\n file.status === \"done\" &&\n !file.thumbUrl.includes(\"data:image\")\n ) {\n this.setState({ uploadVisible: false });\n }\n }\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 if (file === null) return;\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 this.props.app\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.invokeFileListChange(fileList);\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 /**\n * **处理Enter事件**\n * 1. `allowEnterSubmit`为true时enter触发submit事件\n * 2. `e.preventDefault`为了防止enter事件后仍触发换行\n * 3. enter事件开启后,仍可以用`shift + enter`触发换行\n * -- evo 20200222\n */\n handlePressEnter(e) {\n if (this.props.allowEnterSubmit) {\n if (!e.shiftKey) {\n e.preventDefault();\n this.handleSubmit();\n }\n }\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 =\n app.currentUser &&\n (app.currentUser.user_id > 0 || app.currentUser.id > 0);\n\n return (\n <div className=\"comment-editor-container\" onPaste={this.handlePaste}>\n {isLogin ? (\n <Fragment>\n <div\n className={classnames({\n \"comment-editor-toolbar\": true,\n \"comment-editor-toolbar-error\": inputValue.length > maxLength\n })}\n ></div>\n <div className=\"comment-editor\">\n <TextArea\n value={inputValue}\n onChange={e => {\n this.handleChange(e.target.value);\n }}\n rows={rows}\n placeholder={placeholder}\n autoFocus={autoFocus}\n onPressEnter={this.handlePressEnter}\n />\n\n <div className=\"comment-toolbar\">\n <div className=\"comment-toolbar-left\">\n {showEmoji && (\n <Popover\n trigger=\"click\"\n placement={emojiPopoverPlacement}\n autoAdjustOverflow={false}\n overlayStyle={{ zIndex: 9999 }}\n content={\n <div\n style={{ width: 240, height: 205 }}\n onWheel={this.handleEmojiScroll}\n >\n <Emoji\n onClick={this.handleClickEmoji}\n ref={node => {\n this.emoji = node;\n }}\n emojiList={this.props.app.emojiList}\n />\n </div>\n }\n overlayClassName=\"comment-emoji-popover\"\n >\n {emojiToolIcon || (\n <Icon type=\"smile-o\" className=\"comment-toolbar-icon\" />\n )}\n </Popover>\n )}\n\n {showUpload ? (\n <Popover\n trigger=\"click\"\n // TODO: 针对非 react.js,直接使用 click 事件来控制展开或关闭\n visible={this.state.uploadVisible}\n placement={uploadPopoverPlacement}\n overlayClassName={uploadOverlayClassName}\n autoAdjustOverflow={false}\n overlayStyle={{ zIndex: 9999 }}\n onVisibleChange={visible => {\n this.setState({\n uploadVisible: visible\n });\n }}\n content={\n <div className=\"comment-img-popover\">\n <Upload\n onRef={node => (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 <div className=\"clearfix\" />\n </div>\n }\n title={\n <div className=\"comment-img-title\">\n <span>\n {intl.get(\"editor.uploadTip\")}\n {maxUpload >= 2 ? (\n <span className=\"comment-img-title-counter\">\n {intl.get(\"editor.uploadCount\", {\n count: maxUpload - uploadFileList.length\n })}\n </span>\n ) : null}\n </span>\n </div>\n }\n >\n {imageToolIcon ? (\n React.cloneElement(imageToolIcon, {\n onClick: () => this.handleShowUpload(true)\n })\n ) : (\n <Icon\n type=\"picture\"\n className=\"comment-toolbar-icon\"\n style={{ marginLeft: 20 }}\n onClick={() => this.handleShowUpload(true)}\n />\n )}\n </Popover>\n ) : null}\n </div>\n\n <div className=\"comment-toolbar-right\">\n {button ? (\n React.cloneElement(button, {\n onClick: button.props.onClick || handleSubmit\n })\n ) : (\n <Button\n onClick={() => this.handleSubmit()}\n type=\"primary\"\n loading={btnLoading}\n disabled={disabledSubmit}\n >\n {btnSubmitText}\n </Button>\n )}\n </div>\n </div>\n </div>\n </Fragment>\n ) : (\n <Fragment>\n <div className=\"comment-unlogin-tip\">\n {intl.get(\"comment.unlogin\")}\n </div>\n <div className=\"comment-unlogin-button\">\n <Button\n type=\"primary\"\n onClick={() => {\n window.location.href = `${app.LOGINLINK}?f=${window.location.href}`;\n }}\n >\n {intl.get(\"account.login\")}\n </Button>\n </div>\n </Fragment>\n )}\n </div>\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 // Enter事件相关\n allowEnterSubmit: PropTypes.bool,\n // 私信仅允许选中一个,此处可以优化为通用的limit\n limitOne: PropTypes.bool\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 app: {},\n handleChangeFileList: () => {},\n // Enter事件相关\n allowEnterSubmit: false,\n limitOne: false\n};\n\nexport default Comment(Editor);\n"]}