11import MarkdownEditor from '../' ;
22import '@uiw/reset.css/reset.less' ;
3- import * as React from 'react' ;
3+ import React , { useState } from 'react' ;
44import DocumentStr from '../README.md' ;
55import styles from './App.module.less' ;
66import Footer from './components/Footer' ;
@@ -9,50 +9,35 @@ import MarkdownPreview from '@uiw/react-markdown-preview';
99import Logo from './Logo' ;
1010
1111const DocumentStrSource = DocumentStr . replace ( / ( [ \s \S ] * ) < ! - - d i v i d i n g - - > / , '' ) . replace ( / ^ \n * / g, '' ) ;
12-
13- interface IAppState {
14- mdstr : string ;
15- visible : boolean ;
16- }
17-
1812let count = 1 ;
1913
20- export default class App extends React . Component < any , IAppState > {
21- constructor ( props : any ) {
22- super ( props ) ;
23- this . state = {
24- mdstr : DocumentStrSource ,
25- visible : true ,
26- }
27- }
28- public render ( ) {
29- return (
30- < div className = { styles . warpper } >
31- < GithubCorner fixed target = "__blank" href = "https://github.com/uiwjs/react-markdown-editor" />
32- < div className = { styles . logo } >
33- < Logo />
34- </ div >
35- < div className = { styles . editor } >
36- < button onClick = { ( ) => {
37- count += 1 ;
38- this . setState ( { mdstr : `String ${ count } ` } ) ;
39- } } > Modify Markdown</ button >
40- < button onClick = { ( ) => {
41- this . setState ( { visible : ! this . state . visible } )
42- } } > { this . state . visible ? 'Show' : 'Hide' } </ button >
43- < MarkdownEditor
44- visible = { this . state . visible }
45- options = { {
46- autofocus : true ,
47- showCursorWhenSelecting : true ,
48- } }
49- height = { 500 }
50- value = { this . state . mdstr }
51- />
52- </ div >
53- < MarkdownPreview source = { DocumentStrSource } className = { styles . doc } />
54- < Footer name = "Kenny Wong" href = "https://github.com/uiwjs/react-markdown-editor" github = "https://github.com/uiwjs/react-markdown-editor" year = { 2019 } />
14+ export default function App ( ) {
15+ const [ visible , setVisible ] = useState ( true ) ;
16+ const [ mdstr , setMdstr ] = useState < string > ( DocumentStrSource ) ;
17+ return (
18+ < div className = { styles . warpper } >
19+ < GithubCorner fixed target = "__blank" href = "https://github.com/uiwjs/react-markdown-editor" />
20+ < div className = { styles . logo } >
21+ < Logo />
5522 </ div >
56- ) ;
57- }
58- }
23+ < div className = { styles . editor } >
24+ < button onClick = { ( ) => {
25+ count += 1 ;
26+ setMdstr ( `String ${ count } ` ) ;
27+ } } > Modify Markdown</ button >
28+ < button onClick = { ( ) => setVisible ( ! visible ) } > { visible ? 'Show' : 'Hide' } </ button >
29+ < MarkdownEditor
30+ visible = { visible }
31+ options = { {
32+ autofocus : true ,
33+ showCursorWhenSelecting : true ,
34+ } }
35+ height = { 500 }
36+ value = { mdstr }
37+ />
38+ </ div >
39+ < MarkdownPreview source = { DocumentStrSource } className = { styles . doc } />
40+ < Footer name = "Kenny Wong" href = "https://github.com/uiwjs/react-markdown-editor" github = "https://github.com/uiwjs/react-markdown-editor" year = { 2019 } />
41+ </ div >
42+ ) ;
43+ }
0 commit comments