-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
App.tsx
55 lines (51 loc) · 2.14 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import React, { useState } from 'react';
import GitHubCorners from '@uiw/react-github-corners';
import Github from '@uiw/react-shields/esm/github';
import Npm from '@uiw/react-shields/esm/npm';
import logo from './logo.svg';
import './App.css';
import MarkdownPreview, { MarkdownPreviewRef } from '../';
import MDStr from '../README.md';
let val = 1;
const App = () => {
const [value, setValue] = useState('');
const ref = React.createRef<MarkdownPreviewRef>();
return (
<div className="App">
<GitHubCorners zIndex={9999} fixed target="__blank" href="https://github.com/uiwjs/react-markdown-preview" />
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<a href="https://github.com/uiwjs/react-markdown-preview" target="_blank" rel="noopener noreferrer">
React Markdown Preview
</a>
<p>
React component preview markdown text in web browser. The minimal amount of CSS to replicate the GitHub
Markdown style.
</p>
</header>
<div className="App-editor">
<button onClick={() => setValue('# Markdown ' + val++)}>set value</button>
<textarea
placeholder="Please enter the Markdown code!"
value={value}
onChange={(e) => setValue(e.target.value)}
/>
<MarkdownPreview ref={ref} className="App-editor-preview" source={value} />
</div>
<MarkdownPreview className="App-markdown" source={MDStr.replace(/([\s\S]*)<!--dividing-->/, '')} />
<div className="App-footer">
<Github user="uiwjs" repo="react-markdown-preview">
<Github.Social type="forks" href="https://github.com/uiwjs/react-markdown-preview" />
<Github.Social type="stars" href="https://github.com/uiwjs/react-markdown-preview/stargazers" />
<Github.Social type="watchers" href="https://github.com/uiwjs/react-markdown-preview/watchers" />
</Github>
<Npm.Version
scope="@uiw"
packageName="react-markdown-preview"
href="https://www.npmjs.com/package/@uiw/react-markdown-preview"
/>
</div>
</div>
);
};
export default App;