File tree Expand file tree Collapse file tree 1 file changed +48
-2
lines changed
Expand file tree Collapse file tree 1 file changed +48
-2
lines changed Original file line number Diff line number Diff line change 2626 A markdown editor with preview, implemented with React.js and TypeScript.
2727</p >
2828
29- ## Quick Start
29+ ## Install
3030
3131``` bash
3232npm i @uiwjs/react-markdown-editor
33- ```
33+ ```
34+
35+ ## Basic Usage
36+
37+ ``` jsx
38+ import MarkdownEditor from ' @uiwjs/react-markdown-editor' ;
39+ import React from ' react' ;
40+ import ReactDOM from ' react-dom' ;
41+
42+
43+ class App extends React .Component {
44+ constructor () {
45+ super ();
46+ this .state = {
47+ markdown: ' # This is a H1 \n ## This is a H2 \n ###### This is a H6' ,
48+ };
49+ this .updateMarkdown = this .updateMarkdown .bind (this );
50+ }
51+
52+ updateMarkdown (value ) {
53+ this .setState ({ markdown: value });
54+ }
55+
56+ render () {
57+ return (
58+ < MarkdownEditor
59+ value= {this .state .markdown }
60+ onChange= {this .updateMarkdown }
61+ / >
62+ );
63+ }
64+ }
65+
66+ ReactDOM .render (
67+ < App / > ,
68+ document .getElementById (' app' )
69+ );
70+ ```
71+
72+ ## Props
73+
74+ - value (* string* ) - the raw markdown that will be converted to html (** required** )
75+ - onChange (* function* ) - called when a change is made (** required** )
76+
77+ ## License
78+
79+ [ MIT © Kenny Wong] ( ./LICENSE )
You can’t perform that action at this time.
0 commit comments