{"version":3,"sources":["../../../src/components/ContentItem/index.js"],"names":["dayjs","locale","extend","relativeTime","CommentItem","props","state","showInput","handleToggleInput","bind","renderTextWithReply","setState","text","content","newText","reply","user_name","commentId","replyId","action","showReply","onShowReply","app","newContent","images","indexOf","IMAGE_SPLIT","split","pop","join","user_avatar","avatar","marginLeft","created","format","fromNow","__html","map","item","index","maxWidth","reply_count","userId","user_id","sDeleteReply","id","sDeleteComment","sReplyFavor","favored","sCommentFavor","favor_count","children","Component","propTypes","PropTypes","object","isRequired","oneOf","func","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;AACA;;;;AAEA;;;;AACA;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;AACA;;AACA;;;;;;;;;;AAEAA,gBAAMC,MAAN,CAAa,OAAb;AACAD,gBAAME,MAAN,CAAaC,sBAAb;;IAEMC,W;;;AACJ,uBAAYC,KAAZ,EAAmB;AAAA;;AAAA,0HACXA,KADW;;AAEjB,UAAKC,KAAL,GAAa;AACXC,iBAAW;AADA,KAAb;AAGA,UAAKC,iBAAL,GAAyB,MAAKA,iBAAL,CAAuBC,IAAvB,OAAzB;AACA,UAAKC,mBAAL,GAA2B,MAAKA,mBAAL,CAAyBD,IAAzB,OAA3B;AANiB;AAOlB;;;;wCAEmB;AAClB,WAAKE,QAAL,CAAc,EAAEJ,WAAW,CAAC,KAAKD,KAAL,CAAWC,SAAzB,EAAd;AACD;;;wCAEmBK,I,EAAMC,O,EAAS;AACjC,UAAIC,UAAUF,IAAd;AADiC,UAEzBG,KAFyB,GAEfF,OAFe,CAEzBE,KAFyB;;AAGjC,UAAIA,KAAJ,EAAW;AACT;AACA;AACA;AACAD,kBAAaA,OAAb,YAA2BC,MAAMC,SAAjC,SAA8CD,MAAMF,OAApD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAIE,MAAMA,KAAV,EAAiB;AACf,iBAAO,KAAKL,mBAAL,CAAyBI,OAAzB,EAAkCC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sBAAI2B,aAAJ,CAAkBpC,QAAQgC,EAA1B,EAA8BhC,QAAQmC,OAAtC;AACD;AATH;AAWE;AACE,sBAAK,QADP;AAEE,2BACEnC,QAAQmC,OAAR,GACI,+BADJ,GAEI;AALR,gBAXF;AAAA;AAmBSnC,sBAAQqC;AAnBjB;AA/BF;AArCF,SAJF;AAiGG3C,qBACC,8BAAC,sBAAD;AACE,mBAASe,IAAI6B,QADf;AAEE,kBAAQhC,MAFV;AAGE,mBAASD,OAHX;AAIE,qBAAWD,SAJb;AAKE,oBAAU,KAAKT;AALjB;AAlGJ,OADF;AA6GD;;;;EArKuB4C,gB;;AAwK1BhD,YAAYiD,SAAZ,GAAwB;AACtBxC,WAASyC,oBAAUC,MAAV,CAAiBC,UADJ;AAEtB;AACA;AACA;AACArC,UAAQmC,oBAAUG,KAAV,CAAgB,CAAC,SAAD,EAAY,OAAZ,EAAqB,cAArB,CAAhB,CALc;AAMtBpC,eAAaiC,oBAAUI;AAND,CAAxB;;AASAtD,YAAYuD,YAAZ,GAA2B;AACzBxC,UAAQ,SADiB;AAEzBE,eAAa,uBAAM,CAAG;AAFG,CAA3B;;kBAKe,uBAAQjB,WAAR,C","file":"index.js","sourcesContent":["import React, { Component } from \"react\";\r\nimport PropTypes from \"prop-types\";\r\nimport { Avatar, Icon, Tooltip, Popconfirm } from \"antd\";\r\nimport dayjs from \"dayjs\";\r\nimport \"dayjs/locale/zh-cn\";\r\nimport relativeTime from \"dayjs/plugin/relativeTime\";\r\nimport Comment from \"../../Comment\";\r\nimport CommentInput from \"../CommentInput\";\r\nimport avatar from \"../../avatar\";\r\nimport { renderContent } from \"../../helper\";\r\nimport { IMAGE_SPLIT } from \"../../constant\";\r\nimport \"./index.css\";\r\n\r\ndayjs.locale(\"zh-cn\");\r\ndayjs.extend(relativeTime);\r\n\r\nclass CommentItem extends Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n showInput: false\r\n };\r\n this.handleToggleInput = this.handleToggleInput.bind(this);\r\n this.renderTextWithReply = this.renderTextWithReply.bind(this);\r\n }\r\n\r\n handleToggleInput() {\r\n this.setState({ showInput: !this.state.showInput });\r\n }\r\n\r\n renderTextWithReply(text, content) {\r\n let newText = text;\r\n const { reply } = content;\r\n if (reply) {\r\n // newText = `${newText} //@${\r\n // reply.user_name\r\n // } ${reply.content}`;\r\n newText = `${newText} //@${reply.user_name} ${reply.content}`;\r\n // newText = (\r\n // \r\n // {newText}\r\n // @{reply.user_name}{reply.content}\r\n // \r\n // )\r\n if (reply.reply) {\r\n return this.renderTextWithReply(newText, reply);\r\n }\r\n }\r\n return newText;\r\n }\r\n\r\n render() {\r\n const {\r\n commentId,\r\n replyId,\r\n content,\r\n action,\r\n showReply,\r\n onShowReply,\r\n app\r\n } = this.props;\r\n\r\n const { showInput } = this.state;\r\n\r\n let newContent = content.content;\r\n let images = \"\";\r\n if (newContent.indexOf(IMAGE_SPLIT) !== -1) {\r\n newContent = newContent.split(IMAGE_SPLIT);\r\n images = newContent.pop();\r\n newContent = newContent.join(\"\");\r\n }\r\n\r\n return (\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n {/* \r\n {content.user_name || \"暂无昵称\"}\r\n */}\r\n {content.user_name || \"游客\"}\r\n \r\n \r\n {dayjs(content.created * 1000).fromNow()}\r\n \r\n \r\n
\r\n \r\n
\r\n {images.split(\",\").map((item, index) => {\r\n return (\r\n \r\n );\r\n })}\r\n
\r\n
\r\n {content.reply_count ? (\r\n
\r\n \r\n {content.reply_count} 条回复\r\n {showReply ? : }\r\n \r\n
\r\n ) : null}\r\n {\r\n app.userId === content.user_id &&\r\n {\r\n if (replyId) {\r\n app.sDeleteReply(content.id, commentId);\r\n return;\r\n }\r\n app.sDeleteComment(content.id);\r\n }} okText=\"确定\" cancelText=\"取消\">\r\n \r\n   删除\r\n \r\n \r\n }\r\n \r\n   回复\r\n \r\n {\r\n if (replyId) {\r\n // 如果有 replyId,则说明是评论的回复\r\n app.sReplyFavor(content.id, commentId, content.favored);\r\n return;\r\n }\r\n app.sCommentFavor(content.id, content.favored);\r\n }}\r\n >\r\n \r\n  {content.favor_count}\r\n
\r\n\r\n
\r\n
\r\n\r\n {showInput && (\r\n \r\n )}\r\n \r\n );\r\n }\r\n}\r\n\r\nCommentItem.propTypes = {\r\n content: PropTypes.object.isRequired,\r\n // comment 评论\r\n // reply 评论的回复\r\n // replyToReply 回复的回复\r\n action: PropTypes.oneOf([\"comment\", \"reply\", \"replyToReply\"]),\r\n onShowReply: PropTypes.func\r\n};\r\n\r\nCommentItem.defaultProps = {\r\n action: \"comment\",\r\n onShowReply: () => { }\r\n};\r\n\r\nexport default Comment(CommentItem);\r\n"]}