Skip to content

Commit 59cb695

Browse files
author
- -
committed
update doc
1 parent 812b3e0 commit 59cb695

File tree

2 files changed

+256
-2
lines changed

2 files changed

+256
-2
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ export default {
9595
}
9696
```
9797

98-
## Theme
98+
## [Editor Theme](https://github.com/xcatliu/simplemde-theme-base/wiki/List-of-themes)
99+
100+
## Markdown style
99101
> e.g. 使用Github的markdown样式
100102
101103
[github-markdown-css](https://github.com/sindresorhus/github-markdown-css)
@@ -128,4 +130,4 @@ import 'github-markdown-css'
128130

129131
vue-simplemde is open source and released under the MIT Licence.
130132

131-
Copyright (c) 2016 F-loat
133+
Copyright (c) 2017 F-loat

doc/configuration_zh.md

Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
## [SimpleMDE 配置](https://github.com/NextStepWebs/simplemde-markdown-editor#Configuration)
2+
3+
- **autoDownloadFontAwesome**: 如果设置为 `true`, force downloads Font Awesome (used for icons). If set to `false`, prevents downloading. Defaults to `undefined`, which will intelligently check whether Font Awesome has already been included, then download accordingly.
4+
- **autofocus**: If set to `true`, autofocuses the editor. Defaults to `false`.
5+
- **autosave**: *Saves the text that's being written and will load it back in the future. It will forget the text when the form it's contained in is submitted.*
6+
- **enabled**: If set to `true`, autosave the text. Defaults to `false`.
7+
- **delay**: Delay between saves, in milliseconds. Defaults to `10000` (10s).
8+
- **uniqueId**: You must set a unique string identifier so that SimpleMDE can autosave. Something that separates this from other instances of SimpleMDE elsewhere on your website.
9+
- **blockStyles**: Customize how certain buttons that style blocks of text behave.
10+
- **bold** Can be set to `**` or `__`. Defaults to `**`.
11+
- **code** Can be set to ```` ``` ```` or `~~~`. Defaults to ```` ``` ````.
12+
- **italic** Can be set to `*` or `_`. Defaults to `*`.
13+
- **element**: The DOM element for the textarea to use. Defaults to the first textarea on the page.
14+
- **forceSync**: If set to `true`, force text changes made in SimpleMDE to be immediately stored in original textarea. Defaults to `false`.
15+
- **hideIcons**: An array of icon names to hide. Can be used to hide specific icons shown by default without completely customizing the toolbar.
16+
- **indentWithTabs**: If set to `false`, indent using spaces instead of tabs. Defaults to `true`.
17+
- **initialValue**: If set, will customize the initial value of the editor.
18+
- **insertTexts**: Customize how certain buttons that insert text behave. Takes an array with two elements. The first element will be the text inserted before the cursor or highlight, and the second element will be inserted after. For example, this is the default link value: `['[', '](http://)']`.
19+
- horizontalRule
20+
- image
21+
- link
22+
- table
23+
- **lineWrapping**: If set to `false`, disable line wrapping. Defaults to `true`.
24+
- **parsingConfig**: Adjust settings for parsing the Markdown during editing (not previewing).
25+
- **allowAtxHeaderWithoutSpace**: If set to `true`, will render headers without a space after the `#`. Defaults to `false`.
26+
- **strikethrough**: If set to `false`, will not process GFM strikethrough syntax. Defaults to `true`.
27+
- **underscoresBreakWords**: If set to `true`, let underscores be a delimiter for separating words. Defaults to `false`.
28+
- **placeholder**: Custom placeholder that should be displayed
29+
- **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews.
30+
- **promptURLs**: If set to `true`, a JS alert window appears asking for the link or image URL. Defaults to `false`.
31+
- **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing).
32+
- **singleLineBreaks**: If set to `false`, disable parsing GFM single line breaks. Defaults to `true`.
33+
- **codeSyntaxHighlighting**: If set to `true`, will highlight using [highlight.js](https://github.com/isagalaev/highlight.js). Defaults to `false`. To use this feature you must include highlight.js on your page. For example, include the script and the CSS files like:<br>`<script src='https://cdn.jsdelivr.net/highlight.js/latest/highlight.min.js'></script>`<br>`<link rel='stylesheet' href='https://cdn.jsdelivr.net/highlight.js/latest/styles/github.min.css'>`
34+
- **shortcuts**: Keyboard shortcuts associated with this instance. Defaults to the [array of shortcuts](#keyboard-shortcuts).
35+
- **showIcons**: An array of icon names to show. Can be used to show specific icons hidden by default without completely customizing the toolbar.
36+
- **spellChecker**: If set to `false`, disable the spell checker. Defaults to `true`.
37+
- **status**: If set to `false`, hide the status bar. Defaults to the array of built-in status bar items.
38+
- Optionally, you can set an array of status bar items to include, and in what order. You can even define your own custom status bar items.
39+
- **styleSelectedText**: If set to `false`, remove the `CodeMirror-selectedtext` class from selected lines. Defaults to `true`.
40+
- **tabSize**: If set, customize the tab size. Defaults to `2`.
41+
- **toolbar**: If set to `false`, hide the toolbar. Defaults to the [array of icons](#toolbar-icons).
42+
- **toolbarTips**: If set to `false`, disable toolbar button tips. Defaults to `true`.
43+
44+
```JavaScript
45+
// Most options demonstrate the non-default behavior
46+
export default {
47+
data () {
48+
return {
49+
configs: {
50+
autofocus: true,
51+
autosave: {
52+
enabled: true,
53+
uniqueId: 'MyUniqueID',
54+
delay: 1000
55+
},
56+
blockStyles: {
57+
bold: '__',
58+
italic: '_'
59+
},
60+
element: document.getElementById('MyID'),
61+
forceSync: true,
62+
hideIcons: ['guide', 'heading'],
63+
indentWithTabs: false,
64+
initialValue: 'Hello world!',
65+
insertTexts: {
66+
horizontalRule: ['', '\n\n-----\n\n'],
67+
image: ['![](http://', ')'],
68+
link: ['[', '](http://)'],
69+
table: ['', '\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n']
70+
},
71+
lineWrapping: false,
72+
parsingConfig: {
73+
allowAtxHeaderWithoutSpace: true,
74+
strikethrough: false,
75+
underscoresBreakWords: true
76+
},
77+
placeholder: 'Type here...',
78+
previewRender: function(plainText) {
79+
return customMarkdownParser(plainText) // Returns HTML from a custom parser
80+
},
81+
previewRender: function(plainText, preview) { // Async method
82+
setTimeout(function(){
83+
preview.innerHTML = customMarkdownParser(plainText)
84+
}, 250)
85+
86+
return 'Loading...'
87+
},
88+
promptURLs: true,
89+
renderingConfig: {
90+
singleLineBreaks: false,
91+
codeSyntaxHighlighting: true
92+
},
93+
shortcuts: {
94+
drawTable: 'Cmd-Alt-T'
95+
},
96+
showIcons: ['code', 'table'],
97+
spellChecker: false,
98+
status: false,
99+
status: ['autosave', 'lines', 'words', 'cursor'], // Optional usage
100+
status: ['autosave', 'lines', 'words', 'cursor', {
101+
className: 'keystrokes',
102+
defaultValue: function(el) {
103+
this.keystrokes = 0
104+
el.innerHTML = '0 Keystrokes'
105+
},
106+
onUpdate: function(el) {
107+
el.innerHTML = ++this.keystrokes + ' Keystrokes'
108+
}
109+
}], // Another optional usage, with a custom status bar item that counts keystrokes
110+
styleSelectedText: false,
111+
tabSize: 4,
112+
toolbar: false,
113+
toolbarTips: false
114+
}
115+
}
116+
}
117+
}
118+
```
119+
120+
#### Toolbar icons
121+
122+
Below are the built-in toolbar icons (only some of which are enabled by default), which can be reorganized however you like. 'Name' is the name of the icon, referenced in the JS. 'Action' is either a function or a URL to open. 'Class' is the class given to the icon. 'Tooltip' is the small tooltip that appears via the `title='` attribute. Note that shortcut hints are added automatically and reflect the specified action if it has a keybind assigned to it (i.e. with the value of `action` set to `bold` and that of `tooltip` set to `Bold`, the final text the user will see would be 'Bold (Ctrl-B)').
123+
124+
Additionally, you can add a separator between any icons by adding `'|'` to the toolbar array.
125+
126+
Name | Action | Tooltip<br>Class
127+
:--- | :----- | :--------------
128+
bold | toggleBold | Bold<br>fa fa-bold
129+
italic | toggleItalic | Italic<br>fa fa-italic
130+
strikethrough | toggleStrikethrough | Strikethrough<br>fa fa-strikethrough
131+
heading | toggleHeadingSmaller | Heading<br>fa fa-header
132+
heading-smaller | toggleHeadingSmaller | Smaller Heading<br>fa fa-header
133+
heading-bigger | toggleHeadingBigger | Bigger Heading<br>fa fa-lg fa-header
134+
heading-1 | toggleHeading1 | Big Heading<br>fa fa-header fa-header-x fa-header-1
135+
heading-2 | toggleHeading2 | Medium Heading<br>fa fa-header fa-header-x fa-header-2
136+
heading-3 | toggleHeading3 | Small Heading<br>fa fa-header fa-header-x fa-header-3
137+
code | toggleCodeBlock | Code<br>fa fa-code
138+
quote | toggleBlockquote | Quote<br>fa fa-quote-left
139+
unordered-list | toggleUnorderedList | Generic List<br>fa fa-list-ul
140+
ordered-list | toggleOrderedList | Numbered List<br>fa fa-list-ol
141+
clean-block | cleanBlock | Clean block<br>fa fa-eraser fa-clean-block
142+
link | drawLink | Create Link<br>fa fa-link
143+
image | drawImage | Insert Image<br>fa fa-picture-o
144+
table | drawTable | Insert Table<br>fa fa-table
145+
horizontal-rule | drawHorizontalRule | Insert Horizontal Line<br>fa fa-minus
146+
preview | togglePreview | Toggle Preview<br>fa fa-eye no-disable
147+
side-by-side | toggleSideBySide | Toggle Side by Side<br>fa fa-columns no-disable no-mobile
148+
fullscreen | toggleFullScreen | Toggle Fullscreen<br>fa fa-arrows-alt no-disable no-mobile
149+
guide | [This link](https://simplemde.com/markdown-guide) | Markdown Guide<br>fa fa-question-circle
150+
151+
Customize the toolbar using the `toolbar` option like:
152+
153+
```JavaScript
154+
// Customize only the order of existing buttons
155+
export default {
156+
data () {
157+
return {
158+
configs: {
159+
toolbar: ['bold', 'italic', 'heading', '|', 'quote']
160+
}
161+
}
162+
}
163+
}
164+
165+
// Customize all information and/or add your own icons
166+
export default {
167+
data () {
168+
return {
169+
configs: {
170+
toolbar: [{
171+
name: 'bold',
172+
action: SimpleMDE.toggleBold,
173+
className: 'fa fa-bold',
174+
title: 'Bold'
175+
},
176+
{
177+
name: 'custom',
178+
action: function customFunction(editor){
179+
// Add your own code
180+
},
181+
className: 'fa fa-star',
182+
title: 'Custom Button'
183+
},
184+
'|' // Separator
185+
...
186+
]
187+
}
188+
}
189+
}
190+
}
191+
```
192+
193+
#### 快捷键
194+
195+
simplemde带有预定义键盘快捷键的数组,可以用一个配置选项改变。默认的列表如下:
196+
197+
快捷键 | 操作
198+
:------- | :-----
199+
*Cmd-'* | 'toggleBlockquote'
200+
*Cmd-B* | '加粗'
201+
*Cmd-E* | 'cleanBlock'
202+
*Cmd-H* | '降低标题级别'
203+
*Cmd-I* | '斜体'
204+
*Cmd-K* | '插入链接'
205+
*Cmd-L* | '插入无序列表'
206+
*Cmd-P* | '预览'
207+
*Cmd-Alt-C* | '插入代码块'
208+
*Cmd-Alt-I* | '插入图片'
209+
*Cmd-Alt-L* | '插入有序列表'
210+
*Shift-Cmd-H* | '提高标题级别'
211+
*F9* | '全屏预览'
212+
*F11* | '全屏'
213+
214+
可以只修改部分快捷键,其他保持不变:
215+
216+
```JavaScript
217+
export default {
218+
data () {
219+
return {
220+
configs: {
221+
shortcuts: {
222+
'toggleOrderedList': 'Ctrl-Alt-K', // 改变插入有序列表的快捷
223+
'toggleCodeBlock': null, // 不绑定插入代码块的快捷键
224+
'drawTable': 'Cmd-Alt-T' // 绑定没有预设快捷键的操作,插入表格
225+
}
226+
}
227+
}
228+
}
229+
}
230+
```
231+
232+
快捷键会在平台之间自动转换。如果你定义一个快捷键为“Cmd-B”,在PC机上的快捷键将更改为“Ctrl-B”。反之亦然。
233+
234+
可以绑定的操作列表与[工具栏按钮](#toolbar-icons)的内置操作列表相同。
235+
236+
#### 高度
237+
238+
改变最小高度:
239+
240+
```CSS
241+
.markdown-editor .CodeMirror, .markdown-editor .CodeMirror-scroll {
242+
min-height: 200px;
243+
}
244+
```
245+
246+
设置高度为一个固定值:
247+
248+
```CSS
249+
.markdown-editor .CodeMirror {
250+
height: 300px;
251+
}
252+
```

0 commit comments

Comments
 (0)