通用评论 vedio

index.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import React, { Component } from "react";
  2. import ReactDOM from "react-dom";
  3. // e.g.
  4. // import { Button, Icon } from "antd";
  5. // import App, { Editor, RenderText } from "./App";
  6. import App, { Editor } from "./App";
  7. import registerServiceWorker from "./registerServiceWorker";
  8. class Index extends Component {
  9. constructor(props) {
  10. super(props);
  11. this.state = {
  12. value: ""
  13. };
  14. this.handleChangeValue = this.handleChangeValue.bind(this);
  15. this.handleChangeSubmit = this.handleChangeSubmit.bind(this);
  16. }
  17. handleChangeValue(value) {
  18. this.setState({ value });
  19. console.log("handleChangeValue value: ", value);
  20. }
  21. handleChangeSubmit({ text, files }) {
  22. this.setState({ loading: true }, () => {
  23. setTimeout(() => {
  24. this.setState({ loading: false });
  25. }, 2000);
  26. });
  27. console.log("submit text: ", text);
  28. console.log("submit files: ", files);
  29. }
  30. render() {
  31. // 最简单的用法
  32. return (
  33. <App
  34. type={1}
  35. businessId="test"
  36. showAlertComment
  37. showAlertReply
  38. showAlertFavor
  39. showError={false}
  40. onError={msg => {
  41. console.log(`-----------${msg}`);
  42. }}
  43. >
  44. <Editor
  45. maxUpload={4}
  46. beforeSubmit={() => {
  47. return true;
  48. }}
  49. showError={false}
  50. onError={msg => {
  51. console.log(`-----------${msg}`);
  52. }}
  53. />
  54. </App>
  55. );
  56. // e.g.
  57. // 复杂的用户法
  58. // const props = {
  59. // type: 1,
  60. // businessId: "1",
  61. // API: "http://api.links123.net/comment/v1",
  62. // showList: true
  63. // };
  64. // const editorProps = {
  65. // showEmoji: true,
  66. // placeholder: "说点什么吧",
  67. // rows: 5,
  68. // btnLoading: this.state.loading,
  69. // btnDisable: this.state.loading,
  70. // btnSubmitText: "提交",
  71. // value: this.state.value,
  72. // onChange: v => this.handleChangeValue(v),
  73. // onSubmit: v => this.handleChangeSubmit(v),
  74. // button: (
  75. // <Button
  76. // type="primary"
  77. // ghost
  78. // // onClick={() => console.log('click btn: ', this.state.value)}
  79. // >
  80. // 自定义按钮
  81. // </Button>
  82. // ),
  83. // emojiToolIcon: <Icon type="smile" style={{ fontSize: 23 }} />,
  84. // imageToolIcon: (
  85. // <Icon type="cloud-upload-o" style={{ fontSize: 25, marginLeft: 10 }} />
  86. // )
  87. // };
  88. // return (
  89. // <App {...props}>
  90. // <Editor {...editorProps} />
  91. // </App>
  92. // );
  93. }
  94. }
  95. ReactDOM.render(<Index />, document.getElementById("root-comment"));
  96. registerServiceWorker();