123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- "use strict";
-
- 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);
-
- var _registerServiceWorker = require("./registerServiceWorker");
-
- var _registerServiceWorker2 = _interopRequireDefault(_registerServiceWorker);
-
- 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; }
- // e.g.
- // import { Button, Icon } from "antd";
- // import App, { Editor, RenderText } from "./App";
-
-
- var Index = function (_Component) {
- _inherits(Index, _Component);
-
- function Index(props) {
- _classCallCheck(this, Index);
-
- var _this = _possibleConstructorReturn(this, (Index.__proto__ || Object.getPrototypeOf(Index)).call(this, props));
-
- _this.state = {
- value: ""
- };
- _this.handleChangeValue = _this.handleChangeValue.bind(_this);
- _this.handleChangeSubmit = _this.handleChangeSubmit.bind(_this);
- return _this;
- }
-
- _createClass(Index, [{
- key: "handleChangeValue",
- value: function handleChangeValue(value) {
- this.setState({ value: value });
- console.log("handleChangeValue value: ", value);
- }
- }, {
- key: "handleChangeSubmit",
- value: function handleChangeSubmit(_ref) {
- var _this2 = this;
-
- var text = _ref.text,
- files = _ref.files;
-
- this.setState({ loading: true }, function () {
- setTimeout(function () {
- _this2.setState({ loading: false });
- }, 2000);
- });
- console.log("submit text: ", text);
- console.log("submit files: ", files);
- }
- }, {
- key: "render",
- value: function render() {
- // 最简单的用法
- return _react2.default.createElement(
- _App2.default,
- {
- type: 1,
- businessId: "test",
- showAlertComment: true,
- showAlertReply: true,
- showAlertFavor: true,
- showError: false,
- userId: 71299,
- onError: function onError(msg, _ref2) {
- var response = _ref2.response;
-
- if (response.status === 401) {
- console.log("unlogined");
- }
- console.log("-----------" + msg);
- }
- },
- _react2.default.createElement(_App.Editor, {
- maxUpload: 4,
- autoFocus: true,
- beforeSubmit: function beforeSubmit() {
- return new Promise(function (resolve) {
- resolve(true);
- });
- },
- onCommentSuccess: function onCommentSuccess() {
- console.log("succ");
- },
- showError: false,
- onError: function onError(msg, _ref3) {
- var response = _ref3.response;
-
- if (response.status === 401) {
- console.log("unlogined");
- }
- console.log("-----------" + msg);
- }
- })
- );
-
- // e.g.
- // 复杂的用户法
- // const props = {
- // type: 1,
- // businessId: "1",
- // API: "http://api.links123.net/comment/v1",
- // showList: true
- // };
-
- // const editorProps = {
- // showEmoji: true,
- // placeholder: "说点什么吧",
- // rows: 5,
- // btnLoading: this.state.loading,
- // btnDisable: this.state.loading,
- // btnSubmitText: "提交",
- // value: this.state.value,
- // onChange: v => this.handleChangeValue(v),
- // onSubmit: v => this.handleChangeSubmit(v),
- // button: (
- // <Button
- // type="primary"
- // ghost
- // // onClick={() => console.log('click btn: ', this.state.value)}
- // >
- // 自定义按钮
- // </Button>
- // ),
- // emojiToolIcon: <Icon type="smile" style={{ fontSize: 23 }} />,
- // imageToolIcon: (
- // <Icon type="cloud-upload-o" style={{ fontSize: 25, marginLeft: 10 }} />
- // )
- // };
-
- // return (
- // <App {...props}>
- // <Editor {...editorProps} />
- // </App>
- // );
- }
- }]);
-
- return Index;
- }(_react.Component);
-
- _reactDom2.default.render(_react2.default.createElement(Index, null), document.getElementById("root-comment"));
- (0, _registerServiceWorker2.default)();
- //# sourceMappingURL=index.js.map
|