You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
simplemde-markdown-editor/README.md

88 lines
3.5 KiB
Markdown

9 years ago
# SimpleMDE - Markdown Editor
A drop-in JavaScript textarea replacement for writing beautiful and understandable markdown. The WYSIWYG-esque editor allows users to modify the markdown with toolbar buttons and shortcuts. WYSIWYG editors that produce HTML are often complex and buggy. Markdown solves this problem in many ways, but is less visually clear while editing. SimpleMDE has been designed to bridge this gap for non-technical users who are less familiar with or just learning Markdown syntax.
9 years ago
9 years ago
[Demo](http://nextstepwebs.github.io/simplemde-markdown-editor)
[![Preview](http://i.imgur.com/b9hFHFT.png)](http://nextstepwebs.github.io/simplemde-markdown-editor)
9 years ago
9 years ago
## Quick start
SimpleMDE is available on [jsDelivr](http://www.jsdelivr.com/#!simplemde). Font Awesome is available on MaxCDN.
9 years ago
```
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css">
9 years ago
<link rel="stylesheet" href="//cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
<script src="//cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
9 years ago
```
9 years ago
And then load SimpleMDE on the first textarea on a page
9 years ago
```
9 years ago
var simplemde = new SimpleMDE();
simplemde.render();
9 years ago
```
9 years ago
#### Use a specific textarea
9 years ago
Pure JavaScript method
```
9 years ago
var simplemde = new SimpleMDE(document.getElementById("MyID"));
simplemde.render();
9 years ago
```
jQuery method
```
9 years ago
var simplemde = new SimpleMDE($("#MyID")[0]);
simplemde.render();
9 years ago
```
## Get the content
```
9 years ago
simplemde.codemirror.getValue();
9 years ago
```
## Configuration
- **element**: The DOM element for the textarea to use. Defaults to the first textarea on the page.
- **status**: If set `false`, hide the status bar. Defaults to `true`.
- **toolbar**: If set `false`, hide the toolbar. Defaults to `true`.
- **autofocus**: If set `true`, autofocuses the editor. Defaults to `false`.
- **lineWrapping**: If set `false`, disable line wrapping. Defaults to `true`.
- **lineNumbers**: If set `true`, shows line numbers. Defaults to `false`.
- **indentWithTabs**: If set `false`, indent using spaces instead of tabs. Defaults to `true`.
- **tabSize**: If set, customize the tab size. Defaults to `'2'`.
9 years ago
```
9 years ago
new SimpleMDE({
element: document.getElementById("MyID"),
status: false,
toolbar: false,
autofocus: true,
lineWrapping: false,
lineNumbers: true,
indentWithTabs: false,
tabSize: '4',
9 years ago
});
```
9 years ago
## How it works
9 years ago
SimpleMDE is an improvement of [lepture's Editor project](https://github.com/lepture/editor) and includes a great many number of changes. It is bundled with [CodeMirror](https://github.com/codemirror/codemirror) and [Font Awesome](http://fortawesome.github.io/Font-Awesome/).
9 years ago
9 years ago
CodeMirror is the backbone of the project and parses much of the markdown syntax as it's being written. This allows us to add styles to the markdown that's being written. Additionally, a toolbar and status bar has been added to the top and bottom, respectively. Previews are rendered by [Marked](https://github.com/chjj/marked).
9 years ago
9 years ago
## What's changed?
9 years ago
As mentioned earlier, SimpleMDE is an improvement of [lepture's Editor project](https://github.com/lepture/editor). So you might be wondering, what's changed? Quite a bit actually. Here's some notable changes:
- Upgraded from CodeMirror 3 to CodeMirror 5
- Many changes to the style, appearance, and userfriendliness
- Interface more closely resembles Bootstrap
- Now mobile friendly
- The text editor now automatically grows as you type more
- Fixed a large amount of bugs
- Switched to Font Awesome icons
- Improved preview rendering in many ways
- Improved as-you-type appearance of headers and code blocks
- Simplified the toolbar