Skip to content

Commit 6eae597

Browse files
committed
Merge pull request sparksuite#277 from NextStepWebs/development
Allow destroying instance, Prompts, README changes, Fix bugs, More
2 parents 6318fc1 + 507e8ce commit 6eae597

File tree

11 files changed

+1998
-853
lines changed

11 files changed

+1998
-853
lines changed

README.md

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# SimpleMDE - Markdown Editor
22
A drop-in JavaScript textarea replacement for writing beautiful and understandable Markdown. The WYSIWYG-esque editor allows users who may be less experienced with Markdown to use familiar toolbar buttons and shortcuts. In addition, the syntax is rendered while editing to clearly show the expected result. Headings are larger, emphasized words are italicized, links are underlined, etc. SimpleMDE is one of the first editors to feature both built-in autosaving and spell checking.
33

4-
[**Demo**](http://nextstepwebs.github.io/simplemde-markdown-editor)
4+
[**Demo**](https://simplemde.com)
55

6-
[![Preview](http://i.imgur.com/zqWfJwO.png)](http://nextstepwebs.github.io/simplemde-markdown-editor)
6+
[![Preview](http://i.imgur.com/zqWfJwO.png)](https://simplemde.com)
77

88
## Why not a WYSIWYG editor or pure Markdown?
99
WYSIWYG editors that produce HTML are often complex and buggy. Markdown solves this problem in many ways, plus Markdown can be rendered natively on more platforms than HTML. However, Markdown is not a syntax that an average user will be familiar with, nor is it visually clear while editing. In otherwords, for an unfamiliar user, the syntax they write will make little sense until they click the preview button. SimpleMDE has been designed to bridge this gap for non-technical users who are less familiar with or just learning Markdown syntax.
@@ -75,8 +75,10 @@ simplemde.value("This text will appear in the editor");
7575
- **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.
7676
- **blockStyles**: Customize how certain buttons that style blocks of text behave.
7777
- **bold** Can be set to `**` or `__`. Defaults to `**`.
78+
- **code** Can be set to ```` ``` ```` or `~~~`. Defaults to ```` ``` ````.
7879
- **italic** Can be set to `*` or `_`. Defaults to `*`.
7980
- **element**: The DOM element for the textarea to use. Defaults to the first textarea on the page.
81+
- **forceSync**: If set to `true`, force text changes made in SimpleMDE to be immediately stored in original textarea. Defaults to `false`.
8082
- **hideIcons**: An array of icon names to hide. Can be used to hide specific icons shown by default without completely customizing the toolbar.
8183
- **indentWithTabs**: If set to `false`, indent using spaces instead of tabs. Defaults to `true`.
8284
- **initialValue**: If set, will customize the initial value of the editor.
@@ -92,6 +94,7 @@ simplemde.value("This text will appear in the editor");
9294
- **underscoresBreakWords**: If set to `true`, let underscores be a delimiter for separating words. Defaults to `false`.
9395
- **placeholder**: Custom placeholder that should be displayed
9496
- **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews.
97+
- **promptURLs**: If set to `true`, a JS alert window appears asking for the link or image URL. Defaults to `false`.
9598
- **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing).
9699
- **singleLineBreaks**: If set to `false`, disable parsing GFM single line breaks. Defaults to `true`.
97100
- **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">`
@@ -118,6 +121,7 @@ var simplemde = new SimpleMDE({
118121
italic: "_"
119122
},
120123
element: document.getElementById("MyID"),
124+
forceSync: true,
121125
hideIcons: ["guide", "heading"],
122126
indentWithTabs: false,
123127
initialValue: "Hello world!",
@@ -144,6 +148,7 @@ var simplemde = new SimpleMDE({
144148

145149
return "Loading...";
146150
},
151+
promptURLs: true,
147152
renderingConfig: {
148153
singleLineBreaks: false,
149154
codeSyntaxHighlighting: true,
@@ -200,7 +205,7 @@ horizontal-rule | drawHorizontalRule | Insert Horizontal Line<br>fa fa-minus
200205
preview | togglePreview | Toggle Preview<br>fa fa-eye no-disable
201206
side-by-side | toggleSideBySide | Toggle Side by Side<br>fa fa-columns no-disable no-mobile
202207
fullscreen | toggleFullScreen | Toggle Fullscreen<br>fa fa-arrows-alt no-disable no-mobile
203-
guide | [This link](http://nextstepwebs.github.io/simplemde-markdown-editor/markdown-guide) | Markdown Guide<br>fa fa-question-circle
208+
guide | [This link](https://simplemde.com/markdown-guide) | Markdown Guide<br>fa fa-question-circle
204209

205210
Customize the toolbar using the `toolbar` option like:
206211

@@ -297,6 +302,16 @@ simplemde.codemirror.on("change", function(){
297302
});
298303
```
299304

305+
## Removing SimpleMDE from textarea
306+
You can revert to the initial textarea by calling the `toTextArea` method. Note that this clears up the autosave (if enabled) associated with it. The textarea will retain any text from the destroyed SimpleMDE instance.
307+
308+
```JavaScript
309+
var simplemde = new SimpleMDE();
310+
...
311+
simplemde.toTextArea();
312+
simplemde = null;
313+
```
314+
300315
## Useful methods
301316
The following self-explanatory methods may be of use while developing with SimpleMDE.
302317

@@ -309,25 +324,6 @@ simplemde.clearAutosavedValue(); // no returned value
309324
```
310325

311326
## How it works
312-
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 depends on [Font Awesome](http://fortawesome.github.io/Font-Awesome/).
327+
SimpleMDE began as an improvement of [lepture's Editor project](https://github.com/lepture/editor), but has now taken on an identity of its own. It is bundled with [CodeMirror](https://github.com/codemirror/codemirror) and depends on [Font Awesome](http://fortawesome.github.io/Font-Awesome/).
313328

314329
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 have been added to the top and bottom, respectively. Previews are rendered by [Marked](https://github.com/chjj/marked) using GFM.
315-
316-
## What's changed?
317-
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:
318-
319-
- Upgraded from CodeMirror 3 to CodeMirror 5
320-
- Many changes to the style, appearance, and user friendliness
321-
- Interface more closely resembles Bootstrap
322-
- Now mobile friendly
323-
- Option to autosave the text as you type
324-
- Now spell checks what you write
325-
- The text editor now automatically grows as you type more
326-
- Fixed a large amount of bugs
327-
- Switched to Font Awesome icons
328-
- Improved preview rendering in many ways
329-
- Improved as-you-type appearance of headers and code blocks
330-
- Simplified the toolbar
331-
- Many new options during instantiation
332-
- New icons and tooltips
333-
- Additional keyboard shortcuts

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simplemde",
3-
"version": "1.10.0",
3+
"version": "1.10.1",
44
"homepage": "https://github.com/NextStepWebs/simplemde-markdown-editor",
55
"authors": [
66
"Wes Cossick"

0 commit comments

Comments
 (0)