Skip to content

Commit ff2bf43

Browse files
author
- -
committed
update doc
1 parent bc252b4 commit ff2bf43

File tree

3 files changed

+138
-114
lines changed

3 files changed

+138
-114
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ import 'github-markdown-css'
123123
## Dependencies
124124

125125
* [SimpleMDE](https://github.com/NextStepWebs/simplemde-markdown-editor)
126+
* [Highlight.js](https://github.com/isagalaev/highlight.js)
126127

127128
## Licence
128129

_config.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

doc/configuration_en.md

Lines changed: 137 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Configuration
1+
## [SimpleMDE Configuration](https://github.com/NextStepWebs/simplemde-markdown-editor#Configuration)
22

33
- **autoDownloadFontAwesome**: If set to `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.
44
- **autofocus**: If set to `true`, autofocuses the editor. Defaults to `false`.
@@ -15,7 +15,7 @@
1515
- **hideIcons**: An array of icon names to hide. Can be used to hide specific icons shown by default without completely customizing the toolbar.
1616
- **indentWithTabs**: If set to `false`, indent using spaces instead of tabs. Defaults to `true`.
1717
- **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://)"]`.
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://)']`.
1919
- horizontalRule
2020
- image
2121
- link
@@ -30,7 +30,7 @@
3030
- **promptURLs**: If set to `true`, a JS alert window appears asking for the link or image URL. Defaults to `false`.
3131
- **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing).
3232
- **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">`
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'>`
3434
- **shortcuts**: Keyboard shortcuts associated with this instance. Defaults to the [array of shortcuts](#keyboard-shortcuts).
3535
- **showIcons**: An array of icon names to show. Can be used to show specific icons hidden by default without completely customizing the toolbar.
3636
- **spellChecker**: If set to `false`, disable the spell checker. Defaults to `true`.
@@ -43,79 +43,85 @@
4343

4444
```JavaScript
4545
// Most options demonstrate the non-default behavior
46-
var simplemde = new SimpleMDE({
47-
autofocus: true,
48-
autosave: {
49-
enabled: true,
50-
uniqueId: "MyUniqueID",
51-
delay: 1000,
52-
},
53-
blockStyles: {
54-
bold: "__",
55-
italic: "_"
56-
},
57-
element: document.getElementById("MyID"),
58-
forceSync: true,
59-
hideIcons: ["guide", "heading"],
60-
indentWithTabs: false,
61-
initialValue: "Hello world!",
62-
insertTexts: {
63-
horizontalRule: ["", "\n\n-----\n\n"],
64-
image: ["![](http://", ")"],
65-
link: ["[", "](http://)"],
66-
table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],
67-
},
68-
lineWrapping: false,
69-
parsingConfig: {
70-
allowAtxHeaderWithoutSpace: true,
71-
strikethrough: false,
72-
underscoresBreakWords: true,
73-
},
74-
placeholder: "Type here...",
75-
previewRender: function(plainText) {
76-
return customMarkdownParser(plainText); // Returns HTML from a custom parser
77-
},
78-
previewRender: function(plainText, preview) { // Async method
79-
setTimeout(function(){
80-
preview.innerHTML = customMarkdownParser(plainText);
81-
}, 250);
82-
83-
return "Loading...";
84-
},
85-
promptURLs: true,
86-
renderingConfig: {
87-
singleLineBreaks: false,
88-
codeSyntaxHighlighting: true,
89-
},
90-
shortcuts: {
91-
drawTable: "Cmd-Alt-T"
92-
},
93-
showIcons: ["code", "table"],
94-
spellChecker: false,
95-
status: false,
96-
status: ["autosave", "lines", "words", "cursor"], // Optional usage
97-
status: ["autosave", "lines", "words", "cursor", {
98-
className: "keystrokes",
99-
defaultValue: function(el) {
100-
this.keystrokes = 0;
101-
el.innerHTML = "0 Keystrokes";
102-
},
103-
onUpdate: function(el) {
104-
el.innerHTML = ++this.keystrokes + " Keystrokes";
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+
}
105115
}
106-
}], // Another optional usage, with a custom status bar item that counts keystrokes
107-
styleSelectedText: false,
108-
tabSize: 4,
109-
toolbar: false,
110-
toolbarTips: false,
111-
});
116+
}
117+
}
112118
```
113119
114120
#### Toolbar icons
115121
116-
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)").
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)').
117123
118-
Additionally, you can add a separator between any icons by adding `"|"` to the toolbar array.
124+
Additionally, you can add a separator between any icons by adding `'|'` to the toolbar array.
119125
120126
Name | Action | Tooltip<br>Class
121127
:--- | :----- | :--------------
@@ -146,30 +152,42 @@ Customize the toolbar using the `toolbar` option like:
146152
147153
```JavaScript
148154
// Customize only the order of existing buttons
149-
var simplemde = new SimpleMDE({
150-
toolbar: ["bold", "italic", "heading", "|", "quote"],
151-
});
155+
export default {
156+
data () {
157+
return {
158+
configs: {
159+
toolbar: ['bold', 'italic', 'heading', '|', 'quote']
160+
}
161+
}
162+
}
163+
}
152164

153165
// Customize all information and/or add your own icons
154-
var simplemde = new SimpleMDE({
155-
toolbar: [{
156-
name: "bold",
157-
action: SimpleMDE.toggleBold,
158-
className: "fa fa-bold",
159-
title: "Bold",
160-
},
161-
{
162-
name: "custom",
163-
action: function customFunction(editor){
164-
// Add your own code
165-
},
166-
className: "fa fa-star",
167-
title: "Custom Button",
168-
},
169-
"|", // Separator
170-
...
171-
],
172-
});
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+
}
173191
```
174192
175193
#### Keyboard shortcuts
@@ -178,34 +196,40 @@ SimpleMDE comes with an array of predefined keyboard shortcuts, but they can be
178196
179197
Shortcut | Action
180198
:------- | :-----
181-
*Cmd-'* | "toggleBlockquote"
182-
*Cmd-B* | "toggleBold"
183-
*Cmd-E* | "cleanBlock"
184-
*Cmd-H* | "toggleHeadingSmaller"
185-
*Cmd-I* | "toggleItalic"
186-
*Cmd-K* | "drawLink"
187-
*Cmd-L* | "toggleUnorderedList"
188-
*Cmd-P* | "togglePreview"
189-
*Cmd-Alt-C* | "toggleCodeBlock"
190-
*Cmd-Alt-I* | "drawImage"
191-
*Cmd-Alt-L* | "toggleOrderedList"
192-
*Shift-Cmd-H* | "toggleHeadingBigger"
193-
*F9* | "toggleSideBySide"
194-
*F11* | "toggleFullScreen"
199+
*Cmd-'* | 'toggleBlockquote'
200+
*Cmd-B* | 'toggleBold'
201+
*Cmd-E* | 'cleanBlock'
202+
*Cmd-H* | 'toggleHeadingSmaller'
203+
*Cmd-I* | 'toggleItalic'
204+
*Cmd-K* | 'drawLink'
205+
*Cmd-L* | 'toggleUnorderedList'
206+
*Cmd-P* | 'togglePreview'
207+
*Cmd-Alt-C* | 'toggleCodeBlock'
208+
*Cmd-Alt-I* | 'drawImage'
209+
*Cmd-Alt-L* | 'toggleOrderedList'
210+
*Shift-Cmd-H* | 'toggleHeadingBigger'
211+
*F9* | 'toggleSideBySide'
212+
*F11* | 'toggleFullScreen'
195213
196214
Here is how you can change a few, while leaving others untouched:
197215
198216
```JavaScript
199-
var simplemde = new SimpleMDE({
200-
shortcuts: {
201-
"toggleOrderedList": "Ctrl-Alt-K", // alter the shortcut for toggleOrderedList
202-
"toggleCodeBlock": null, // unbind Ctrl-Alt-C
203-
"drawTable": "Cmd-Alt-T" // bind Cmd-Alt-T to drawTable action, which doesn't come with a default shortcut
217+
export default {
218+
data () {
219+
return {
220+
configs: {
221+
shortcuts: {
222+
'toggleOrderedList': 'Ctrl-Alt-K', // alter the shortcut for toggleOrderedList
223+
'toggleCodeBlock': null, // unbind Ctrl-Alt-C
224+
'drawTable': 'Cmd-Alt-T' // bind Cmd-Alt-T to drawTable action, which doesn't come with a default shortcut
225+
}
226+
}
227+
}
204228
}
205-
});
229+
}
206230
```
207231
208-
Shortcuts are automatically converted between platforms. If you define a shortcut as "Cmd-B", on PC that shortcut will be changed to "Ctrl-B". Conversely, a shortcut defined as "Ctrl-B" will become "Cmd-B" for Mac users.
232+
Shortcuts are automatically converted between platforms. If you define a shortcut as 'Cmd-B', on PC that shortcut will be changed to 'Ctrl-B'. Conversely, a shortcut defined as 'Ctrl-B' will become 'Cmd-B' for Mac users.
209233
210234
The list of actions that can be bound is the same as the list of built-in actions available for [toolbar buttons](#toolbar-icons).
211235

0 commit comments

Comments
 (0)