通用评论

EditComment.js.map 8.2KB

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","successCallback","handleClose","sUpdateComment","content","sUpdateReply","newContent","images","indexOf","split","pop","join","map","item","index","uid","renderTextWithReply","intl","get","newText","user_id","preRenderValue","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;;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,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AAL,CAAc;AACZvC;AADY,eAAd;AAGD,aAjBH;AAkBE,kCAAsB,wCAAY;AAChC,qBAAKuC,QAAL,CAAc;AACZrC;AADY,eAAd;AAGD,aAtBH;AAuBE,sBAAU,KAAKL,YAvBjB;AAwBE,2BAAe,KAAK2C,gBAAL,EAxBjB;AAyBE,2BAAe,KAAKC,gBAAL,EAzBjB;AA0BE,mCAAsB,QA1BxB;AA2BE,oCAAuB,QA3BzB;AA4BE,2BAAeP,6BAAKC,GAAL,CAAS,gBAAT;AA5BjB;AAFJ;AAPF,OADF;AA4CD;;;;EA3IuBO,gBAAMC,S;;kBA8IjB,uBAAQhD,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 // 成功回调,失败不自动关闭\n const successCallback = () => {\n this.props.handleClose();\n };\n if (action === \"comment\") {\n app.sUpdateComment({ commentId, content: value, successCallback });\n } else {\n app.sUpdateReply({\n commentId,\n content: value,\n replyId,\n replyPage,\n successCallback\n });\n }\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={\n this.props.preRenderValue &&\n this.props.preRenderValue(this.state.value)\n }\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"]}