No Description

App.tsx 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import * as React from "react";
  2. import ReactMde, { ReactMdeTypes } from "../src";
  3. import * as Showdown from "showdown";
  4. export interface AppState {
  5. mdeState: ReactMdeTypes.MdeState;
  6. }
  7. export class App extends React.Component<{}, AppState> {
  8. converter: Showdown.Converter;
  9. constructor(props) {
  10. super(props);
  11. this.state = {
  12. mdeState: {
  13. markdown: "**Hello world!!!**",
  14. },
  15. };
  16. this.converter = new Showdown.Converter({
  17. tables: true,
  18. simplifiedAutoLink: true,
  19. strikethrough: true,
  20. tasklists: true,
  21. });
  22. }
  23. handleValueChange = (mdeState: ReactMdeTypes.MdeState) => {
  24. this.setState({ mdeState });
  25. }
  26. render() {
  27. return (
  28. <div className="container">
  29. <ReactMde
  30. onChange={this.handleValueChange}
  31. editorState={this.state.mdeState}
  32. generateMarkdownPreview={(markdown) => Promise.resolve(this.converter.makeHtml(markdown))}
  33. />
  34. </div>
  35. );
  36. }
  37. }