Skip to content

Commit 0f55f3c

Browse files
committed
Update README.md
1 parent 9337b14 commit 0f55f3c

File tree

1 file changed

+131
-6
lines changed

1 file changed

+131
-6
lines changed

README.md

+131-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Bootstrap Markdown Editor
22

3-
Markdown editor for Bootstrap with preview, image upload support, shortcuts and other features.
3+
Markdown editor for Bootstrap with preview, image upload support, shortcuts and other features.
44
This is a jQuery plugin.
55

66
## Requirements
@@ -42,7 +42,7 @@ Optionally, include the script of Bootstrap to enable tooltips:
4242
<script src="dist/js/bootstrap-markdown-editor.js"></script>
4343
```
4444

45-
Create a div for the editor:
45+
Create a div for the editor with optional content in markdown format:
4646

4747
```html
4848
<div id="myEditor"># Test</div>
@@ -62,8 +62,8 @@ var markdownContent = $('#myEditor').markdownEditor('content');
6262

6363
## Implementing the preview
6464

65-
You have to implement the parsing of the Markdown.
66-
Bootstrap Markdown Editor provides you a callback where you have to parse the markdown and return the html.
65+
You have to implement the parsing of the Markdown.
66+
Bootstrap Markdown Editor provides you a callback where you have to parse the markdown and return the html.
6767
To activate the preview you have to use the following options:
6868

6969
```javascript
@@ -91,7 +91,7 @@ $('#myEditor').markdownEditor({
9191

9292
## Implementing the image upload
9393

94-
You have to implement the server side part of the upload process.
94+
You have to implement the server side part of the upload process.
9595
To activate the image uploads you have to use the following options:
9696

9797
```javascript
@@ -120,7 +120,7 @@ echo json_encode($uploadedFiles);
120120

121121
## Shortcuts
122122

123-
The following shortcuts are available.
123+
The following shortcuts are available.
124124
They can be used with or without selected text.
125125

126126
- **Ctrl-B / ⌘B**: Bold
@@ -131,3 +131,128 @@ They can be used with or without selected text.
131131

132132
### Options
133133

134+
The following options can be passed as an object at the initialization of the plugin:
135+
136+
```javascript
137+
$('#myEditor').markdownEditor({
138+
// Options
139+
});
140+
```
141+
142+
Also, you can override the plugin default options. Example:
143+
144+
```javascript
145+
$.fn.markdownEditor.defaults.width = '250px';
146+
```
147+
148+
#### width
149+
150+
**Type**: string
151+
**Default**: '100%'
152+
153+
The width of the editor
154+
155+
#### height
156+
157+
**Type**: string
158+
**Default**: '400px'
159+
160+
The height of the editor
161+
162+
#### fontSize
163+
164+
**Type**: string
165+
**Default**: '14px'
166+
167+
The font size of the editor
168+
169+
#### theme
170+
171+
**Type**: string
172+
**Default**: 'tomorrow'
173+
174+
The theme of the editor. See the available themes at the homepage of Ace (http://ace.c9.io)
175+
176+
#### fullscreen
177+
178+
**Type**: boolean
179+
**Default**: true
180+
181+
Enable / disable fullscreen
182+
183+
#### imageUpload
184+
185+
**Type**: boolean
186+
**Default**: false
187+
188+
Enable / disable the upload of images. If enabled, you have to specify the option `uploadPath`
189+
190+
#### uploadPath
191+
192+
**Type**: uploadPath
193+
**Default**: ''
194+
195+
The path of the server side script that receives the images. The script has to return an array of the **public path** of the successfully uploaded images in json format.
196+
197+
#### preview
198+
199+
**Type**: boolean
200+
**Default**: false
201+
202+
Enable / disable the preview. If enabled, you have to specify the option `onPreview`
203+
204+
#### onPreview
205+
206+
**Type**: function
207+
**Default**:
208+
209+
```javascript
210+
function (content, callback) {
211+
callback(content);
212+
}
213+
```
214+
215+
This callback is called when the user clicks on the preview button and has two parameters:
216+
**content** that contains the text in markdown.
217+
**callback** is function that you have to call with the parsed html as a parameter
218+
219+
#### label
220+
221+
**Type**: object
222+
**Default**:
223+
224+
```javascript
225+
{
226+
btnHeader1: 'Header 1',
227+
btnHeader2: 'Header 2',
228+
btnHeader3: 'Header 3',
229+
btnBold: 'Bold',
230+
btnItalic: 'Italic',
231+
btnLink: 'Link',
232+
btnImage: 'Insert image',
233+
btnUpload: 'Uplaod image',
234+
btnEdit: 'Edit',
235+
btnPreview: 'Preview',
236+
btnFullscreen: 'Fullscreen',
237+
loading: 'Loading'
238+
}
239+
```
240+
241+
This object contains the strings that can be translated
242+
243+
### Methods
244+
245+
The methods are invoked passing the name of the method as string.
246+
Only one method is available:
247+
248+
```javascript
249+
var content = $('#myEditor').markdownEditor('content'); // Returns the content of the editor
250+
```
251+
252+
## License
253+
254+
Licensed under MIT (https://github.com/inacho/bootstrap-markdown-editor/blob/master/LICENSE).
255+
256+
## Authors
257+
258+
[Ignacio de Tomás](https://github.com/inacho)

0 commit comments

Comments
 (0)