通用评论

1
  1. {"version":3,"sources":["../../../src/components/EditComment/EditComment.js"],"names":["EditComment","props","handleSubmit","bind","state","value","getInitValue","fileList","text","files","app","action","commentId","replyId","replyPage","onBeforeUpdateComment","length","IMAGE_SPLIT","forEach","file","thumbUrl","substr","slice","sUpdateComment","content","sUpdateReply","handleClose","newContent","images","indexOf","split","pop","join","map","item","index","uid","renderTextWithReply","intl","get","newText","user_id","setState","getEmojiToolIcon","getImageToolIcon","React","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;AAEA;;;;AACA;;;;AACA;;;;AACA;;AACA;;AACA;;;;;;;;;;;;IACMA,W;;;AACJ,uBAAYC,KAAZ,EAAmB;AAAA;;AAAA,0HACXA,KADW;;AAEjB,UAAKC,YAAL,GAAoB,MAAKA,YAAL,CAAkBC,IAAlB,OAApB;AACA,UAAKC,KAAL,GAAa;AACXC,aAAO,MAAKC,YAAL,CAAkBL,KAAlB,EAAyBI,KADrB;AAEXE,gBAAU,MAAKD,YAAL,CAAkBL,KAAlB,EAAyBM;AAFxB,KAAb;AAHiB;AAOlB;;;;uCAEuC;AAAA,2BAAzBC,IAAyB;AAAA,UAAzBA,IAAyB,6BAAlB,EAAkB;AAAA,4BAAdC,KAAc;AAAA,UAAdA,KAAc,8BAAN,EAAM;AAAA,UAC9BF,QAD8B,GACjB,KAAKH,KADY,CAC9BG,QAD8B;AAAA,mBAEiB,KAAKN,KAFtB;AAAA,UAE9BS,GAF8B,UAE9BA,GAF8B;AAAA,UAEzBC,MAFyB,UAEzBA,MAFyB;AAAA,UAEjBC,SAFiB,UAEjBA,SAFiB;AAAA,UAENC,OAFM,UAENA,OAFM;AAAA,UAEGC,SAFH,UAEGA,SAFH;;AAGtC,UAAIT,QAAQG,IAAZ;AACAE,UAAIK,qBAAJ;AACA,UAAIR,YAAYA,SAASS,MAAzB,EAAiC;AAC/BX,iBAASY,qBAAT;AACAV,iBAASW,OAAT,CAAiB,gBAAQ;AACvBb,mBAAYc,KAAKC,Q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e,KAAKC,gBAAL,EAtBjB;AAuBE,mCAAsB,QAvBxB;AAwBE,oCAAuB,QAxBzB;AAyBE,2BAAeN,6BAAKC,GAAL,CAAS,gBAAT;AAzBjB;AAFJ;AAPF,OADF;AAyCD;;;;EA/HuBM,gBAAMC,S;;kBAkIjB,uBAAQ9C,WAAR,C","file":"EditComment.js","sourcesContent":["import React from \"react\";\nimport { Modal, Icon } from \"antd\";\nimport intl from \"react-intl-universal\";\nimport CommentInput from \"../CommentInput\";\nimport Editor from \"../Editor\";\nimport { IMAGE_SPLIT } from \"../../constant\";\nimport \"./EditComment.css\";\nimport Comment from \"../../Comment\";\nclass EditComment extends React.Component {\n constructor(props) {\n super(props);\n this.handleSubmit = this.handleSubmit.bind(this);\n this.state = {\n value: this.getInitValue(props).value,\n fileList: this.getInitValue(props).fileList\n };\n }\n\n handleSubmit({ text = \"\", files = [] }) {\n const { fileList } = this.state;\n const { app, action, commentId, replyId, replyPage } = this.props;\n let value = text;\n app.onBeforeUpdateComment();\n if (fileList && fileList.length) {\n value += IMAGE_SPLIT;\n fileList.forEach(file => {\n value += `${file.thumbUrl},`;\n });\n }\n if (value.substr(-1) === \",\") {\n value = value.slice(0, -1);\n }\n if (action === \"comment\") {\n app.sUpdateComment({ commentId, content: value });\n } else {\n app.sUpdateReply({ commentId, content: value, replyId, replyPage });\n }\n this.props.handleClose();\n }\n\n getInitValue(props) {\n const { content } = props;\n let newContent = content.content;\n let images = \"\";\n if (newContent.indexOf(IMAGE_SPLIT) !== -1) {\n newContent = newContent.split(IMAGE_SPLIT);\n images = newContent.pop();\n newContent = newContent.join(\"\");\n }\n let fileList = [];\n if (images !== \"\") {\n fileList = images.split(\",\");\n fileList = fileList.map((item, index) => {\n return {\n thumbUrl: item,\n uid: index\n };\n });\n }\n const value = this.renderTextWithReply(newContent, content);\n return { value, fileList };\n }\n\n getEmojiToolIcon() {\n return (\n <div className=\"expression-btn-wrap\">\n <Icon type=\"smile\" className=\"icon\" />\n <span className=\"icon-tool-text\">{intl.get(\"bilingually.emoji\")}</span>\n </div>\n );\n }\n\n getImageToolIcon() {\n return (\n <div className=\"picture-btn-wrap\">\n <Icon type=\"picture\" className=\"icon\" />\n <span className=\"icon-tool-text\">{intl.get(\"bilingually.pic\")}</span>\n </div>\n );\n }\n\n renderTextWithReply(text, content) {\n let newText = text;\n // const { reply } = content;\n // if (reply) {\n // newText = `${newText} //@${reply.user_name} ${reply.content}`;\n // if (reply.reply) {\n // return this.renderTextWithReply(newText, reply);\n // }\n // }\n return newText;\n }\n\n render() {\n return (\n <Modal\n visible={true}\n footer={null}\n wrapClassName=\"editCommetModal\"\n onCancel={this.props.handleClose}\n >\n <div className=\"title\">{intl.get(\"comment.edit\")}</div>\n <CommentInput\n content={\n <Editor\n maxUpload={9}\n autoFocus\n // {...this.props.editorProps}\n action={this.props.action}\n replyId={this.props.replyId}\n commentId={this.props.commentId}\n userId={this.props.content.user_id}\n fileList={this.state.fileList}\n value={this.state.value}\n onChange={value => {\n this.setState({\n value\n });\n }}\n handleChangeFileList={fileList => {\n this.setState({\n fileList\n });\n }}\n onSubmit={this.handleSubmit}\n emojiToolIcon={this.getEmojiToolIcon()}\n imageToolIcon={this.getImageToolIcon()}\n emojiPopoverPlacement=\"bottom\"\n uploadPopoverPlacement=\"bottom\"\n btnSubmitText={intl.get(\"comment.update\")}\n />\n }\n />\n </Modal>\n );\n }\n}\n\nexport default Comment(EditComment);\n"]}