通用评论

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. "use strict";
  2. 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; }; }();
  3. var _react = require("react");
  4. var _react2 = _interopRequireDefault(_react);
  5. var _reactDom = require("react-dom");
  6. var _reactDom2 = _interopRequireDefault(_reactDom);
  7. var _App = require("./App");
  8. var _App2 = _interopRequireDefault(_App);
  9. var _registerServiceWorker = require("./registerServiceWorker");
  10. var _registerServiceWorker2 = _interopRequireDefault(_registerServiceWorker);
  11. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13. 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; }
  14. 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; }
  15. // e.g.
  16. // import { Button, Icon } from "antd";
  17. var Index = function (_Component) {
  18. _inherits(Index, _Component);
  19. function Index(props) {
  20. _classCallCheck(this, Index);
  21. var _this = _possibleConstructorReturn(this, (Index.__proto__ || Object.getPrototypeOf(Index)).call(this, props));
  22. _this.state = {
  23. value: ""
  24. };
  25. _this.handleChangeValue = _this.handleChangeValue.bind(_this);
  26. _this.handleChangeSubmit = _this.handleChangeSubmit.bind(_this);
  27. return _this;
  28. }
  29. _createClass(Index, [{
  30. key: "handleChangeValue",
  31. value: function handleChangeValue(value) {
  32. this.setState({ value: value });
  33. console.log("handleChangeValue value: ", value);
  34. }
  35. }, {
  36. key: "handleChangeSubmit",
  37. value: function handleChangeSubmit(value) {
  38. var _this2 = this;
  39. this.setState({ loading: true }, function () {
  40. setTimeout(function () {
  41. _this2.setState({ loading: false });
  42. }, 2000);
  43. });
  44. console.log("submit value: ", value);
  45. }
  46. }, {
  47. key: "render",
  48. value: function render() {
  49. // 最简单的用法
  50. return _react2.default.createElement(
  51. _App2.default,
  52. { type: 1, businessId: "test" },
  53. _react2.default.createElement(_App.Editor, null)
  54. );
  55. // e.g.
  56. // 复杂的用户法
  57. // const props = {
  58. // type: 1,
  59. // businessId: "1",
  60. // API: "http://api.links123.net/comment/v1",
  61. // showList: true
  62. // };
  63. // const editorProps = {
  64. // showEmoji: true,
  65. // placeholder: "说点什么吧",
  66. // rows: 5,
  67. // btnLoading: this.state.loading,
  68. // btnDisable: this.state.loading,
  69. // btnSubmitText: "提交",
  70. // value: this.state.value,
  71. // onChange: v => this.handleChangeValue(v),
  72. // onSubmit: v => this.handleChangeSubmit(v),
  73. // button: (
  74. // <Button
  75. // type="primary"
  76. // ghost
  77. // // onClick={() => console.log('click btn: ', this.state.value)}
  78. // >
  79. // 自定义按钮
  80. // </Button>
  81. // ),
  82. // emojiToolIcon: <Icon type="smile" style={{ fontSize: 23 }} />,
  83. // imageToolIcon: (
  84. // <Icon type="cloud-upload-o" style={{ fontSize: 25, marginLeft: 10 }} />
  85. // )
  86. // };
  87. // return (
  88. // <App {...props}>
  89. // <Editor {...editorProps} />
  90. // </App>
  91. // );
  92. }
  93. }]);
  94. return Index;
  95. }(_react.Component);
  96. _reactDom2.default.render(_react2.default.createElement(Index, null), document.getElementById("root-comment"));
  97. (0, _registerServiceWorker2.default)();
  98. //# sourceMappingURL=index.js.map