123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- import React, { Component } from "react";
- import ReactDOM from "react-dom";
- // e.g.
- // import { Button, Icon } from "antd";
- // import App, { Editor, RenderText } from "./App";
- import App, { Editor } from "./App";
- import registerServiceWorker from "./registerServiceWorker";
-
- class Index extends Component {
- constructor(props) {
- super(props);
- this.state = {
- value: ""
- };
- this.handleChangeValue = this.handleChangeValue.bind(this);
- this.handleChangeSubmit = this.handleChangeSubmit.bind(this);
- }
-
- handleChangeValue(value) {
- this.setState({ value });
- console.log("handleChangeValue value: ", value);
- }
-
- handleChangeSubmit({ text, files }) {
- this.setState({ loading: true }, () => {
- setTimeout(() => {
- this.setState({ loading: false });
- }, 2000);
- });
- console.log("submit text: ", text);
- console.log("submit files: ", files);
- }
-
- render() {
- // 最简单的用法
- return (
- <App
- type={1}
- businessId="test"
- showAlertComment
- showAlertReply
- showAlertFavor
- showError={false}
- onError={msg => {
- console.log(`-----------${msg}`);
- }}
- >
- <Editor
- maxUpload={4}
- beforeSubmit={() => {
- return new Promise(resolve => {
- resolve(true);
- });
- }}
- showError={false}
- onError={msg => {
- console.log(`-----------${msg}`);
- }}
- />
- </App>
- );
-
- // 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>
- // );
- }
- }
-
- ReactDOM.render(<Index />, document.getElementById("root-comment"));
- registerServiceWorker();
|