"use strict"; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; 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; }; }(); var _react = require("react"); var _react2 = _interopRequireDefault(_react); var _reactDom = require("react-dom"); var _reactDom2 = _interopRequireDefault(_reactDom); var _App = require("./App"); var _App2 = _interopRequireDefault(_App); 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; } // import registerServiceWorker from "./registerServiceWorker"; var Index = function (_React$Component) { _inherits(Index, _React$Component); function Index(props) { _classCallCheck(this, Index); var _this = _possibleConstructorReturn(this, (Index.__proto__ || Object.getPrototypeOf(Index)).call(this, props)); _this.state = { fileList: [{ uid: "1", name: "xxx.png", status: "done", response: "success", // custom error message to show url: "//links-comment.oss-cn-beijing.aliyuncs.com/comment/20190617/UCs7aXEjW.jpeg" }] }; return _this; } _createClass(Index, [{ key: "render", value: function render() { var _this2 = this; return _react2.default.createElement( _App2.default, _extends({ showAlertComment: true, showAlertReply: true, showAlertFavor: true, showError: true }, this.props), _react2.default.createElement(_App.Editor, _extends({ maxUpload: 9, autoFocus: true }, this.props.editorProps, { fileList: this.state.fileList, handleChangeFileList: function handleChangeFileList(fileList) { _this2.setState({ fileList: fileList }); } })) ); } }]); return Index; }(_react2.default.Component); /** * 渲染评论组件 * @param {object} config 编辑器配置 * - {string} id 渲染评论的DOM的 ID * - {number} type 评论的 type * - {string} businessId 评论的 businessId * - {string} API, API 前缀, 默认 http://api.links123.net/comment/v1 */ function renderComment(config) { if (!config.id) { throw new Error("id is required"); } if (!config.type) { throw new Error("type is required"); } if (!config.businessId) { // throw new Error("businessId is required"); config.businessId = "test"; console.warn("没有传入 businessId 参数,默认使用: test"); } if (!config.API) { // throw new Error("API is required"); config.API = "http://api.links123.net/comment/v1"; console.warn("没有传入 API 参数,默认使用: http://api.links123.net/comment/v1"); } _reactDom2.default.render(_react2.default.createElement(Index, config), document.getElementById(config.id)); // registerServiceWorker(); } window.renderComment = renderComment; if (process.env.NODE_ENV !== "production") { renderComment({ id: "root-comment", type: 1, businessId: "test", businessUserId: 4, userId: 71299, onCountChange: function onCountChange(c) { console.log(c); }, editorProps: { // emojiPopoverPlacement: "bottom", // uploadPopoverPlacement: "top" } }); } // renderComment({ // id: "root-comment", // type: 1, // businessId: "test", // API: 'http://api.links123.net/comment/v1', // }); //# sourceMappingURL=index.js.map