123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- "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: [
- // {
- // url:
- // "//links-comment.oss-cn-beijing.aliyuncs.com/comment/20190727/YQ-4VC1bL.jpeg",
- // type: "image/jpeg",
- // uid: "rc-upload-1564206005248-2"
- // }
- ],
- value: ""
- };
- 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,
- value: this.state.value,
- onChange: function onChange(value) {
- _this2.setState({ value: value });
- },
- handleChangeFileList: function handleChangeFileList(fileList) {
- _this2.setState({
- fileList: fileList
- });
- },
- allowEnterSubmit: true,
- limitOne: true
- }))
- );
- }
- }]);
-
- 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: 3,
- businessId: "5ea8320dedd68200018e733d",
- businessUserId: 4,
- userId: 58297,
- currentUser: {
- user_id: 58297
- },
- userAvaHoverData: {
- 71763: {
- nickname: "aaa",
- followers: 20,
- fans: 2,
- isFollowed: true
- },
- 71748: {
- nickname: "L0",
- followers: 10,
- fans: 11,
- isFollowed: false
- },
- 71299: {
- nickname: "narro",
- followers: 10,
- fans: 11,
- isFollowed: false
- },
- 58297: {
- nickname: "aaaaa",
- followers: 10,
- fans: 11,
- isFollowed: false
- }
- },
- showHoverCard: true,
- showEdit: true,
- userAvaClick: function userAvaClick(id) {
- console.log("userAvaClick", id);
- },
- getUserInfo: function getUserInfo(id) {
- console.log("getinfo:", id);
- },
- focus: function focus(id) {
- return new Promise(function (resolve, reject) {
- console.log("focus:", id);
- resolve();
- });
- },
- unFocus: function unFocus(id) {
- return new Promise(function (resolve, reject) {
- console.log("unFocus:", id);
- resolve();
- });
- },
- onCountChange: function onCountChange(c) {
- // console.log(c);
- },
- onDelete: function onDelete(type, data) {
- console.log(type, data);
- },
- onCommentFail: function onCommentFail(data) {
- console.log("onCommentFail", data);
- },
- onUpdateComment: function onUpdateComment(type, data) {
- console.log("onUpdateComment", type);
- },
- onBeforeUpdateComment: function onBeforeUpdateComment() {
- console.log("onBeforeUpdateComment");
- },
- sendMessage: function sendMessage(id) {
- console.log("sendMessage", id);
- },
- preRenderValue: function preRenderValue(value) {
- return "" + value;
- },
- editorProps: {
- onCommentSuccess: function onCommentSuccess(data) {
- console.log(data);
- }
- }
- });
- }
-
- // renderComment({
- // id: "root-comment",
- // type: 1,
- // businessId: "test",
- // API: 'http://api.links123.net/comment/v1',
- // });
- //# sourceMappingURL=index.js.map
|