File tree 2 files changed +42
-16
lines changed
src/components/md-to-html
2 files changed +42
-16
lines changed Original file line number Diff line number Diff line change 1
- PlainBelt
2
- =========
1
+ [ ![ Test] ( https://github.com/plainbelt/plainbelt/actions/workflows/test.yml/badge.svg )] ( https://github.com/plainbelt/plainbelt/actions/workflows/test.yml )
3
2
4
- > A toolbelt for all your plain text
3
+ # PlainBelt
5
4
5
+ > A toolbelt for your plain text
6
6
7
7
## Development setup
8
8
11
11
yarn start
12
12
```
13
13
14
- Enjoy!
14
+ ## Build binary
15
+
16
+ ```
17
+ yarn package
18
+ ```
19
+
20
+ Checkout the ` release ` folder and enjoy!
Original file line number Diff line number Diff line change
1
+ /* eslint-disable react/no-danger */
1
2
import React , { useState } from 'react' ;
2
3
import marked from 'marked' ;
3
4
4
5
const Md2Html = ( ) => {
5
6
const [ md , setMd ] = useState ( '# Hello\n> This is a quote' ) ;
7
+ const [ preview , setPreview ] = useState ( false ) ;
6
8
7
9
const handleChange = ( evt : { target : { value : string } } ) =>
8
10
setMd ( evt . target . value ) ;
9
11
10
12
return (
11
- < div className = "flex min-h-full" >
12
- < textarea
13
- onChange = { handleChange }
14
- className = "flex-1 min-h-full bg-white p-4"
15
- value = { md }
16
- />
17
- < div className = "mx-1" />
18
- < textarea
19
- className = "flex-1 min-h-full bg-blue-100 p-4"
20
- value = { marked ( md ) }
21
- disabled
22
- />
13
+ < div className = "min-h-full flex flex-col" >
14
+ < div className = "flex justify-end mb-1" >
15
+ < button
16
+ type = "button"
17
+ className = "rounded bg-gray-300 px-2 py-1 outline-none text-sm text-gray-600"
18
+ onClick = { ( ) => setPreview ( ! preview ) }
19
+ >
20
+ { preview ? 'Raw HTML' : 'Preview' }
21
+ </ button >
22
+ </ div >
23
+ < div className = "flex min-h-full flex-1" >
24
+ < textarea
25
+ onChange = { handleChange }
26
+ className = "flex-1 min-h-full bg-white p-4"
27
+ value = { md }
28
+ />
29
+ < div className = "mx-1" />
30
+ { preview ? (
31
+ < section
32
+ className = "flex-1 min-h-full bg-blue-50 p-4 prose"
33
+ dangerouslySetInnerHTML = { { __html : marked ( md ) } }
34
+ />
35
+ ) : (
36
+ < textarea
37
+ className = "flex-1 min-h-full bg-blue-100 p-4"
38
+ value = { marked ( md ) }
39
+ disabled
40
+ />
41
+ ) }
42
+ </ div >
23
43
</ div >
24
44
) ;
25
45
} ;
You can’t perform that action at this time.
0 commit comments