Skip to content

Commit ae15509

Browse files
committed
Update website example.
1 parent a38508f commit ae15509

File tree

2 files changed

+56
-30
lines changed

2 files changed

+56
-30
lines changed

Diff for: website/App.less

+10-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@ body, html {
77
.warpper {
88
padding: 20px;
99
margin: 0 auto;
10-
text-align: center;
11-
width: 950px;
10+
max-width: 950px;
11+
.title {
12+
padding: 0 0 20px 0;
13+
font-weight: bold;
14+
font-size: 16px;
15+
}
16+
.header {
17+
text-align: center;
18+
}
1219
.doc-tools {
13-
padding: 30px 0 0 0;
20+
padding: 30px 0 30px 0;
1421
font-size: 12px;
1522
label {
1623
user-select: none;

Diff for: website/App.tsx

+46-27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import GithubCorner from './GithubCorner';
3-
import MDEditor, { IMDEditorProps } from '../';
3+
import MDEditor, { IMDEditorProps, commands } from '../';
44
import Logo from './Logo';
55
import './App.less';
66

@@ -9,22 +9,10 @@ const mdStr = `
99
<img src="https://raw.githubusercontent.com/uiwjs/react-markdown-editor/4884f29f2aad59bf7f512184ba3726d76bbd7170/website/logo.svg?sanitize=true">
1010
</p>
1111
12-
# Markdown Editor for React
13-
## 大标题
14-
### 小标题
15-
#### 小标题
16-
##### 小标题
17-
###### 小标题
18-
19-
<p align="center">
20-
<style>
21-
body {
22-
padding: 100px;
23-
}
24-
</style>
25-
A markdown editor with <b>preview</b>, implemented with React.js and TypeScript.
26-
</p>
27-
12+
\`\`\`javascript
13+
// Preview Markdown!
14+
<MDEditor.Markdown source="Preview Markdown!" />
15+
\`\`\`
2816
2917
<p align="center">
3018
A markdown editor with preview, implemented with React.js and TypeScript.
@@ -89,6 +77,24 @@ Licensed under the MIT License.
8977
**粗体文本** __粗体文本__
9078
***粗斜体文本*** ___粗斜体文本___
9179
80+
# Markdown Editor for React
81+
## Title Name
82+
### Title Name
83+
#### Title Name
84+
##### Title Name
85+
###### Title Name
86+
87+
<p align="center">
88+
<style>
89+
body {
90+
padding: 100px;
91+
}
92+
</style>
93+
A markdown editor with <b>preview</b>, implemented with React.js and TypeScript.
94+
</p>
95+
96+
97+
9298
\`\`\`javascript
9399
$(document).ready(function () {
94100
alert('hello world');
@@ -138,9 +144,9 @@ def g(x):
138144
139145
---
140146
141-
| 表头 | 表头 |
147+
| Header | Header |
142148
| --- | --- |
143-
| 事实上 | 事实上 |
149+
| Content | Content |
144150
145151
这个链接用 1 作为网址变量 [Google][1].
146152
这个链接用 yahoo 作为网址变量 [Yahoo!][yahoo].
@@ -154,6 +160,7 @@ def g(x):
154160
export default function App() {
155161
const [state, setVisiable] = React.useState({
156162
visiableDragbar: true,
163+
value: mdStr,
157164
preview: 'edit',
158165
});
159166
const upDataVisiable = (keyName, e) => {
@@ -164,35 +171,47 @@ export default function App() {
164171
}
165172
return (
166173
<div className="warpper">
167-
<Logo />
174+
<header className="header">
175+
<Logo />
176+
</header>
168177
<GithubCorner url="https://github.com/uiwjs/react-md-editor" />
169178
<MDEditor
170-
value={mdStr}
179+
value={state.value}
171180
height={400}
172181
visiableDragbar={state.visiableDragbar}
173182
preview={state.preview as IMDEditorProps['preview']}
174-
onChange={(value) => {
175-
console.log('【onChange】', value);
183+
onChange={(newValue) => {
184+
setVisiable({ ...state, value: newValue });
176185
}}
177186
/>
178187
<div className="doc-tools">
179188
<label>
180189
<input type="checkbox" checked={state.visiableDragbar} onChange={upDataVisiable.bind(this, 'visiableDragbar')} />
181-
是否显示拖拽工具
190+
{state.visiableDragbar ? 'Show' : 'Hidden'} Drag Bar
182191
</label>
183192
<label>
184193
<input type="radio" name="preview" value="edit" checked={state.preview === 'edit'} onChange={upPreview.bind(this)} />
185-
编辑
194+
Edit
186195
</label>
187196
<label>
188197
<input type="radio" name="preview" value="live" checked={state.preview === 'live'} onChange={upPreview.bind(this)} />
189-
实时编辑
198+
Live Preview
190199
</label>
191200
<label>
192201
<input type="radio" name="preview" value="preview" checked={state.preview === 'preview'} onChange={upPreview.bind(this)} />
193-
预览
202+
Preview
194203
</label>
195204
</div>
205+
<div className="title">Custom toolbar</div>
206+
<MDEditor
207+
value="Hello Markdown!"
208+
commands={[
209+
commands.bold, commands.hr, commands.italic, commands.divider,
210+
commands.codeEdit, commands.codeLive, commands.codePreview, commands.divider,
211+
commands.fullscreen,
212+
]}
213+
/>
214+
<MDEditor.Markdown source={state.value} />
196215
</div>
197216
)
198217
}

0 commit comments

Comments
 (0)