123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- "use strict";
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
-
- var _modal = require("antd/es/modal");
-
- var _modal2 = _interopRequireDefault(_modal);
-
- var _icon = require("antd/es/icon");
-
- var _icon2 = _interopRequireDefault(_icon);
-
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
-
- require("antd/es/modal/style");
-
- require("antd/es/icon/style");
-
- var _react = require("react");
-
- var _react2 = _interopRequireDefault(_react);
-
- var _reactIntlUniversal = require("react-intl-universal");
-
- var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
-
- var _CommentInput = require("../CommentInput");
-
- var _CommentInput2 = _interopRequireDefault(_CommentInput);
-
- var _Editor = require("../Editor");
-
- var _Editor2 = _interopRequireDefault(_Editor);
-
- var _constant = require("../../constant");
-
- require("./EditComment.css");
-
- var _Comment = require("../../Comment");
-
- var _Comment2 = _interopRequireDefault(_Comment);
-
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
- var EditComment = function (_React$Component) {
- _inherits(EditComment, _React$Component);
-
- function EditComment(props) {
- _classCallCheck(this, EditComment);
-
- var _this = _possibleConstructorReturn(this, (EditComment.__proto__ || Object.getPrototypeOf(EditComment)).call(this, props));
-
- _this.handleSubmit = _this.handleSubmit.bind(_this);
- _this.state = {
- value: _this.getInitValue(props).value,
- fileList: _this.getInitValue(props).fileList
- };
- return _this;
- }
-
- _createClass(EditComment, [{
- key: "handleSubmit",
- value: function handleSubmit(_ref) {
- var _ref$text = _ref.text,
- text = _ref$text === undefined ? "" : _ref$text,
- _ref$files = _ref.files,
- files = _ref$files === undefined ? [] : _ref$files;
- var fileList = this.state.fileList;
- var _props = this.props,
- app = _props.app,
- action = _props.action,
- commentId = _props.commentId,
- replyId = _props.replyId,
- replyPage = _props.replyPage;
-
- var value = text;
- app.onBeforeUpdateComment();
- if (fileList && fileList.length) {
- value += _constant.IMAGE_SPLIT;
- fileList.forEach(function (file) {
- value += file.thumbUrl + ",";
- });
- }
- if (value.substr(-1) === ",") {
- value = value.slice(0, -1);
- }
- if (action === "comment") {
- app.sUpdateComment({ commentId: commentId, content: value });
- } else {
- app.sUpdateReply({ commentId: commentId, content: value, replyId: replyId, replyPage: replyPage });
- }
- this.props.handleClose();
- }
- }, {
- key: "getInitValue",
- value: function getInitValue(props) {
- var content = props.content;
-
- var newContent = content.content;
- var images = "";
- if (newContent.indexOf(_constant.IMAGE_SPLIT) !== -1) {
- newContent = newContent.split(_constant.IMAGE_SPLIT);
- images = newContent.pop();
- newContent = newContent.join("");
- }
- var fileList = [];
- if (images !== "") {
- fileList = images.split(",");
- fileList = fileList.map(function (item, index) {
- return {
- thumbUrl: item,
- uid: index
- };
- });
- }
- var value = this.renderTextWithReply(newContent, content);
- return { value: value, fileList: fileList };
- }
- }, {
- key: "getEmojiToolIcon",
- value: function getEmojiToolIcon() {
- return _react2.default.createElement(
- "div",
- { className: "expression-btn-wrap" },
- _react2.default.createElement(_icon2.default, { type: "smile", className: "icon" }),
- _react2.default.createElement(
- "span",
- { className: "icon-tool-text" },
- _reactIntlUniversal2.default.get("bilingually.emoji")
- )
- );
- }
- }, {
- key: "getImageToolIcon",
- value: function getImageToolIcon() {
- return _react2.default.createElement(
- "div",
- { className: "picture-btn-wrap" },
- _react2.default.createElement(_icon2.default, { type: "picture", className: "icon" }),
- _react2.default.createElement(
- "span",
- { className: "icon-tool-text" },
- _reactIntlUniversal2.default.get("bilingually.pic")
- )
- );
- }
- }, {
- key: "renderTextWithReply",
- value: function renderTextWithReply(text, content) {
- var newText = text;
- // const { reply } = content;
- // if (reply) {
- // newText = `${newText} //@${reply.user_name} ${reply.content}`;
- // if (reply.reply) {
- // return this.renderTextWithReply(newText, reply);
- // }
- // }
- return newText;
- }
- }, {
- key: "render",
- value: function render() {
- var _this2 = this;
-
- return _react2.default.createElement(
- _modal2.default,
- {
- visible: true,
- footer: null,
- wrapClassName: "editCommetModal",
- onCancel: this.props.handleClose
- },
- _react2.default.createElement(
- "div",
- { className: "title" },
- _reactIntlUniversal2.default.get("comment.edit")
- ),
- _react2.default.createElement(_CommentInput2.default, {
- content: _react2.default.createElement(_Editor2.default, {
- maxUpload: 9,
- autoFocus: true
- // {...this.props.editorProps}
- , action: this.props.action,
- replyId: this.props.replyId,
- commentId: this.props.commentId,
- userId: this.props.content.user_id,
- fileList: this.state.fileList,
- value: this.props.preRenderValue && this.props.preRenderValue(this.state.value),
- onChange: function onChange(value) {
- _this2.setState({
- value: value
- });
- },
- handleChangeFileList: function handleChangeFileList(fileList) {
- _this2.setState({
- fileList: fileList
- });
- },
- onSubmit: this.handleSubmit,
- emojiToolIcon: this.getEmojiToolIcon(),
- imageToolIcon: this.getImageToolIcon(),
- emojiPopoverPlacement: "bottom",
- uploadPopoverPlacement: "bottom",
- btnSubmitText: _reactIntlUniversal2.default.get("comment.update")
- })
- })
- );
- }
- }]);
-
- return EditComment;
- }(_react2.default.Component);
-
- exports.default = (0, _Comment2.default)(EditComment);
- //# sourceMappingURL=EditComment.js.map
|