mirror of
https://github.com/Ionaru/easy-markdown-editor
synced 2025-07-06 17:44:27 -06:00
Merge pull request #114 from NextStepWebs/development
Intelligently download Font Awesome, New options, Bug fixes
This commit is contained in:
commit
f32e103944
26
README.md
26
README.md
@ -21,12 +21,6 @@ SimpleMDE is also available on [jsDelivr](http://www.jsdelivr.com/#!simplemde).
|
|||||||
<script src="//cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
|
<script src="//cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
SimpleMDE depends on Font Awesome (load via MaxCDN for best performance).
|
|
||||||
|
|
||||||
```HTML
|
|
||||||
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css">
|
|
||||||
```
|
|
||||||
|
|
||||||
And then load SimpleMDE on the first textarea on a page
|
And then load SimpleMDE on the first textarea on a page
|
||||||
|
|
||||||
```HTML
|
```HTML
|
||||||
@ -65,28 +59,30 @@ simplemde.value("This text will appear in the editor");
|
|||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
|
- **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.
|
||||||
- **autofocus**: If set to `true`, autofocuses the editor. Defaults to `false`.
|
- **autofocus**: If set to `true`, autofocuses the editor. Defaults to `false`.
|
||||||
- **autosave**: *Saves the text that's being written. It will forget the text when the form is submitted.*
|
- **autosave**: *Saves the text that's being written. It will forget the text when the form is submitted.*
|
||||||
- **enabled**: If set to `true`, autosave the text. Defaults to `false`.
|
- **enabled**: If set to `true`, autosave the text. Defaults to `false`.
|
||||||
- **delay**: Delay between saves, in milliseconds. Defaults to `10000` (10s).
|
- **delay**: Delay between saves, in milliseconds. Defaults to `10000` (10s).
|
||||||
- **unique_id**: You must set a unique identifier so that SimpleMDE can autosave. Something that separates this from other textareas.
|
- **unique_id**: You must set a unique identifier so that SimpleMDE can autosave. Something that separates this from other textareas.
|
||||||
- **element**: The DOM element for the textarea to use. Defaults to the first textarea on the page.
|
- **element**: The DOM element for the textarea to use. Defaults to the first textarea on the page.
|
||||||
|
- **hideIcons**: An array of icon names to hide. Can be used to hide specific icons without completely customizing the toolbar.
|
||||||
- **indentWithTabs**: If set to `false`, indent using spaces instead of tabs. Defaults to `true`.
|
- **indentWithTabs**: If set to `false`, indent using spaces instead of tabs. Defaults to `true`.
|
||||||
- **initialValue**: If set, will customize the initial value of the editor.
|
- **initialValue**: If set, will customize the initial value of the editor.
|
||||||
- **lineWrapping**: If set to `false`, disable line wrapping. Defaults to `true`.
|
- **lineWrapping**: If set to `false`, disable line wrapping. Defaults to `true`.
|
||||||
- **parsingConfig**: Adjust settings for parsing the Markdown during editing (not previewing).
|
- **parsingConfig**: Adjust settings for parsing the Markdown during editing (not previewing).
|
||||||
- **allowAtxHeaderWithoutSpace**: If set to `true`, will render headers without a space after the `#`. Defaults to `false`.
|
- **allowAtxHeaderWithoutSpace**: If set to `true`, will render headers without a space after the `#`. Defaults to `false`.
|
||||||
- **fencedCodeBlocks**: If set to `false`, will not process GFM fenced code blocks syntax. Defaults to `true`.
|
|
||||||
- **strikethrough**: If set to `false`, will not process GFM strikethrough syntax. Defaults to `true`.
|
- **strikethrough**: If set to `false`, will not process GFM strikethrough syntax. Defaults to `true`.
|
||||||
- **underscoresBreakWords**: If set to `true`, let underscores be a delimiter for separating words. Defaults to `false`.
|
- **underscoresBreakWords**: If set to `true`, let underscores be a delimiter for separating words. Defaults to `false`.
|
||||||
- **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews.
|
- **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews.
|
||||||
- **singleLineBreaks**: If set to `false`, disable parsing GFM single line breaks. Defaults to `true`.
|
- **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing).
|
||||||
|
- **singleLineBreaks**: If set to `false`, disable parsing GFM single line breaks. Defaults to `true`.
|
||||||
|
- **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">`
|
||||||
- **spellChecker**: If set to `false`, disable the spell checker. Defaults to `true`.
|
- **spellChecker**: If set to `false`, disable the spell checker. Defaults to `true`.
|
||||||
- **status**: If set to `false`, hide the status bar. Defaults to `true`.
|
- **status**: If set to `false`, hide the status bar. Defaults to `true`.
|
||||||
- Optionally, you can set an array of status bar elements to include, and in what order.
|
- Optionally, you can set an array of status bar elements to include, and in what order.
|
||||||
- **tabSize**: If set, customize the tab size. Defaults to `2`.
|
- **tabSize**: If set, customize the tab size. Defaults to `2`.
|
||||||
- **toolbar**: If set to `false`, hide the toolbar. Defaults to the [array of icons](#toolbar-icons).
|
- **toolbar**: If set to `false`, hide the toolbar. Defaults to the [array of icons](#toolbar-icons).
|
||||||
- **toolbarGuideIcon**: If set to `false`, disable guide icon in the toolbar. Defaults to `true`.
|
|
||||||
- **toolbarTips**: If set to `false`, disable toolbar button tips. Defaults to `true`.
|
- **toolbarTips**: If set to `false`, disable toolbar button tips. Defaults to `true`.
|
||||||
|
|
||||||
```JavaScript
|
```JavaScript
|
||||||
@ -98,12 +94,12 @@ var simplemde = new SimpleMDE({
|
|||||||
delay: 1000,
|
delay: 1000,
|
||||||
},
|
},
|
||||||
element: document.getElementById("MyID"),
|
element: document.getElementById("MyID"),
|
||||||
|
hideIcons: ["guide", "heading"],
|
||||||
indentWithTabs: false,
|
indentWithTabs: false,
|
||||||
initialValue: "Hello world!",
|
initialValue: "Hello world!",
|
||||||
lineWrapping: false,
|
lineWrapping: false,
|
||||||
parsingConfig: {
|
parsingConfig: {
|
||||||
allowAtxHeaderWithoutSpace: true,
|
allowAtxHeaderWithoutSpace: true,
|
||||||
fencedCodeBlocks: false,
|
|
||||||
strikethrough: false,
|
strikethrough: false,
|
||||||
underscoresBreakWords: true,
|
underscoresBreakWords: true,
|
||||||
},
|
},
|
||||||
@ -117,13 +113,15 @@ var simplemde = new SimpleMDE({
|
|||||||
|
|
||||||
return "Loading...";
|
return "Loading...";
|
||||||
}
|
}
|
||||||
|
renderingConfig: {
|
||||||
singleLineBreaks: false,
|
singleLineBreaks: false,
|
||||||
|
codeSyntaxHighlighting: true,
|
||||||
|
},
|
||||||
spellChecker: false,
|
spellChecker: false,
|
||||||
status: false,
|
status: false,
|
||||||
status: ['autosave', 'lines', 'words', 'cursor'], // Optional usage
|
status: ['autosave', 'lines', 'words', 'cursor'], // Optional usage
|
||||||
tabSize: 4,
|
tabSize: 4,
|
||||||
toolbar: false,
|
toolbar: false,
|
||||||
toolbarGuideIcon: false,
|
|
||||||
toolbarTips: false,
|
toolbarTips: false,
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
@ -150,9 +148,9 @@ ordered-list | toggleOrderedList | Numbered List (Ctrl+Alt+L)<br>fa fa-list-ol
|
|||||||
link | drawLink | Create Link (Ctrl+K)<br>fa fa-link
|
link | drawLink | Create Link (Ctrl+K)<br>fa fa-link
|
||||||
image | drawImage | Insert Image (Ctrl+Alt+I)<br>fa fa-picture-o
|
image | drawImage | Insert Image (Ctrl+Alt+I)<br>fa fa-picture-o
|
||||||
horizontal-rule | drawHorizontalRule | Insert Horizontal Line<br>fa fa-minus
|
horizontal-rule | drawHorizontalRule | Insert Horizontal Line<br>fa fa-minus
|
||||||
preview | togglePreview | Toggle Preview (Ctrl+P)<br>fa fa-eye
|
preview | togglePreview | Toggle Preview (Ctrl+P)<br>fa fa-eye no-disable
|
||||||
side-by-side | toggleSideBySide | Toggle Side by Side (F9)<br>fa fa-columns
|
side-by-side | toggleSideBySide | Toggle Side by Side (F9)<br>fa fa-columns no-disable no-mobile
|
||||||
fullscreen | toggleFullScreen | Toggle Fullscreen (F11)<br>fa fa-arrows-alt
|
fullscreen | toggleFullScreen | Toggle Fullscreen (F11)<br>fa fa-arrows-alt no-disable no-mobile
|
||||||
guide | [This link](http://nextstepwebs.github.io/simplemde-markdown-editor/markdown-guide) | Markdown Guide<br>fa fa-question-circle
|
guide | [This link](http://nextstepwebs.github.io/simplemde-markdown-editor/markdown-guide) | Markdown Guide<br>fa fa-question-circle
|
||||||
|
|
||||||
Customize the toolbar using the `toolbar` option like:
|
Customize the toolbar using the `toolbar` option like:
|
||||||
|
4
dist/simplemde.min.css
vendored
4
dist/simplemde.min.css
vendored
File diff suppressed because one or more lines are too long
16
dist/simplemde.min.js
vendored
16
dist/simplemde.min.js
vendored
File diff suppressed because one or more lines are too long
@ -19,10 +19,9 @@ gulp.task("downloads-codemirror", function(callback) {
|
|||||||
var download_urls = [
|
var download_urls = [
|
||||||
"https://raw.githubusercontent.com/codemirror/CodeMirror/master/lib/codemirror.js",
|
"https://raw.githubusercontent.com/codemirror/CodeMirror/master/lib/codemirror.js",
|
||||||
"https://raw.githubusercontent.com/codemirror/CodeMirror/master/addon/edit/continuelist.js",
|
"https://raw.githubusercontent.com/codemirror/CodeMirror/master/addon/edit/continuelist.js",
|
||||||
//"https://raw.githubusercontent.com/codemirror/CodeMirror/master/addon/edit/tablist.js", //waiting for PRs
|
|
||||||
"https://raw.githubusercontent.com/codemirror/CodeMirror/master/addon/display/fullscreen.js",
|
"https://raw.githubusercontent.com/codemirror/CodeMirror/master/addon/display/fullscreen.js",
|
||||||
"https://raw.githubusercontent.com/codemirror/CodeMirror/master/addon/mode/overlay.js",
|
"https://raw.githubusercontent.com/codemirror/CodeMirror/master/addon/mode/overlay.js",
|
||||||
//"https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/gfm/gfm.js", //waiting for PRs
|
"https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/gfm/gfm.js",
|
||||||
"https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/markdown/markdown.js",
|
"https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/markdown/markdown.js",
|
||||||
"https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/xml/xml.js"];
|
"https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/xml/xml.js"];
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "simplemde",
|
"name": "simplemde",
|
||||||
"version": "1.7.1",
|
"version": "1.7.2",
|
||||||
"description": "A simple, beautiful, and embeddable JavaScript markdown editor. Features autosaving and spell checking.",
|
"description": "A simple, beautiful, and embeddable JavaScript markdown editor. Features autosaving and spell checking.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"embeddable",
|
"embeddable",
|
||||||
|
@ -177,7 +177,7 @@
|
|||||||
content: "▼";
|
content: "▼";
|
||||||
}
|
}
|
||||||
|
|
||||||
.editor-toolbar.disabled-for-preview a:not(.fa-eye):not(.fa-arrows-alt):not(.fa-columns) {
|
.editor-toolbar.disabled-for-preview a:not(.no-disable) {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-color: transparent;
|
border-color: transparent;
|
||||||
@ -185,7 +185,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media only screen and (max-width: 700px) {
|
@media only screen and (max-width: 700px) {
|
||||||
.editor-toolbar a.fa-columns {
|
.editor-toolbar a.no-mobile {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1534,6 +1534,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
readOnlyChanged: function(val) {
|
||||||
|
if (!val) this.reset();
|
||||||
|
},
|
||||||
|
|
||||||
setUneditable: nothing,
|
setUneditable: nothing,
|
||||||
|
|
||||||
needsContentAttribute: false
|
needsContentAttribute: false
|
||||||
@ -1552,7 +1556,6 @@
|
|||||||
init: function(display) {
|
init: function(display) {
|
||||||
var input = this, cm = input.cm;
|
var input = this, cm = input.cm;
|
||||||
var div = input.div = display.lineDiv;
|
var div = input.div = display.lineDiv;
|
||||||
div.contentEditable = "true";
|
|
||||||
disableBrowserMagic(div);
|
disableBrowserMagic(div);
|
||||||
|
|
||||||
on(div, "paste", function(e) { handlePaste(e, cm); })
|
on(div, "paste", function(e) { handlePaste(e, cm); })
|
||||||
@ -1593,7 +1596,7 @@
|
|||||||
|
|
||||||
on(div, "input", function() {
|
on(div, "input", function() {
|
||||||
if (input.composing) return;
|
if (input.composing) return;
|
||||||
if (!input.pollContent())
|
if (isReadOnly(cm) || !input.pollContent())
|
||||||
runInOp(input.cm, function() {regChange(cm);});
|
runInOp(input.cm, function() {regChange(cm);});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1818,19 +1821,26 @@
|
|||||||
this.div.focus();
|
this.div.focus();
|
||||||
},
|
},
|
||||||
applyComposition: function(composing) {
|
applyComposition: function(composing) {
|
||||||
if (composing.data && composing.data != composing.startData)
|
if (isReadOnly(this.cm))
|
||||||
|
operation(this.cm, regChange)(this.cm)
|
||||||
|
else if (composing.data && composing.data != composing.startData)
|
||||||
operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel);
|
operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel);
|
||||||
},
|
},
|
||||||
|
|
||||||
setUneditable: function(node) {
|
setUneditable: function(node) {
|
||||||
node.setAttribute("contenteditable", "false");
|
node.contentEditable = "false"
|
||||||
},
|
},
|
||||||
|
|
||||||
onKeyPress: function(e) {
|
onKeyPress: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
if (!isReadOnly(this.cm))
|
||||||
operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0);
|
operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
readOnlyChanged: function(val) {
|
||||||
|
this.div.contentEditable = String(val != "nocursor")
|
||||||
|
},
|
||||||
|
|
||||||
onContextMenu: nothing,
|
onContextMenu: nothing,
|
||||||
resetPosition: nothing,
|
resetPosition: nothing,
|
||||||
|
|
||||||
@ -5389,8 +5399,8 @@
|
|||||||
cm.display.disabled = true;
|
cm.display.disabled = true;
|
||||||
} else {
|
} else {
|
||||||
cm.display.disabled = false;
|
cm.display.disabled = false;
|
||||||
if (!val) cm.display.input.reset();
|
|
||||||
}
|
}
|
||||||
|
cm.display.input.readOnlyChanged(val)
|
||||||
});
|
});
|
||||||
option("disableInput", false, function(cm, val) {if (!val) cm.display.input.reset();}, true);
|
option("disableInput", false, function(cm, val) {if (!val) cm.display.input.reset();}, true);
|
||||||
option("dragDrop", true, dragDropChanged);
|
option("dragDrop", true, dragDropChanged);
|
||||||
@ -8093,24 +8103,30 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var noHandlers = []
|
||||||
|
function getHandlers(emitter, type, copy) {
|
||||||
|
var arr = emitter._handlers && emitter._handlers[type]
|
||||||
|
if (copy) return arr && arr.length > 0 ? arr.slice() : noHandlers
|
||||||
|
else return arr || noHandlers
|
||||||
|
}
|
||||||
|
|
||||||
var off = CodeMirror.off = function(emitter, type, f) {
|
var off = CodeMirror.off = function(emitter, type, f) {
|
||||||
if (emitter.removeEventListener)
|
if (emitter.removeEventListener)
|
||||||
emitter.removeEventListener(type, f, false);
|
emitter.removeEventListener(type, f, false);
|
||||||
else if (emitter.detachEvent)
|
else if (emitter.detachEvent)
|
||||||
emitter.detachEvent("on" + type, f);
|
emitter.detachEvent("on" + type, f);
|
||||||
else {
|
else {
|
||||||
var arr = emitter._handlers && emitter._handlers[type];
|
var handlers = getHandlers(emitter, type, false)
|
||||||
if (!arr) return;
|
for (var i = 0; i < handlers.length; ++i)
|
||||||
for (var i = 0; i < arr.length; ++i)
|
if (handlers[i] == f) { handlers.splice(i, 1); break; }
|
||||||
if (arr[i] == f) { arr.splice(i, 1); break; }
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var signal = CodeMirror.signal = function(emitter, type /*, values...*/) {
|
var signal = CodeMirror.signal = function(emitter, type /*, values...*/) {
|
||||||
var arr = emitter._handlers && emitter._handlers[type];
|
var handlers = getHandlers(emitter, type, true)
|
||||||
if (!arr) return;
|
if (!handlers.length) return;
|
||||||
var args = Array.prototype.slice.call(arguments, 2);
|
var args = Array.prototype.slice.call(arguments, 2);
|
||||||
for (var i = 0; i < arr.length; ++i) arr[i].apply(null, args);
|
for (var i = 0; i < handlers.length; ++i) handlers[i].apply(null, args);
|
||||||
};
|
};
|
||||||
|
|
||||||
var orphanDelayedCallbacks = null;
|
var orphanDelayedCallbacks = null;
|
||||||
@ -8123,8 +8139,8 @@
|
|||||||
// them to be executed when the last operation ends, or, if no
|
// them to be executed when the last operation ends, or, if no
|
||||||
// operation is active, when a timeout fires.
|
// operation is active, when a timeout fires.
|
||||||
function signalLater(emitter, type /*, values...*/) {
|
function signalLater(emitter, type /*, values...*/) {
|
||||||
var arr = emitter._handlers && emitter._handlers[type];
|
var arr = getHandlers(emitter, type, false)
|
||||||
if (!arr) return;
|
if (!arr.length) return;
|
||||||
var args = Array.prototype.slice.call(arguments, 2), list;
|
var args = Array.prototype.slice.call(arguments, 2), list;
|
||||||
if (operationGroup) {
|
if (operationGroup) {
|
||||||
list = operationGroup.delayedCallbacks;
|
list = operationGroup.delayedCallbacks;
|
||||||
@ -8164,8 +8180,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hasHandler(emitter, type) {
|
function hasHandler(emitter, type) {
|
||||||
var arr = emitter._handlers && emitter._handlers[type];
|
return getHandlers(emitter, type).length > 0
|
||||||
return arr && arr.length > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add on and off methods to a constructor's prototype, to make
|
// Add on and off methods to a constructor's prototype, to make
|
||||||
@ -8819,7 +8834,7 @@
|
|||||||
|
|
||||||
// THE END
|
// THE END
|
||||||
|
|
||||||
CodeMirror.version = "5.6.1";
|
CodeMirror.version = "5.7.1";
|
||||||
|
|
||||||
return CodeMirror;
|
return CodeMirror;
|
||||||
});
|
});
|
||||||
|
@ -11,13 +11,9 @@
|
|||||||
})(function(CodeMirror) {
|
})(function(CodeMirror) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var urlRE = /^((?:coap|doi|javascript|aaa|aaas|about|acap|cap|cid|crid|data|dav|dict|dns|file|ftp|geo|go|gopher|h323|http|https|iax|icap|im|imap|info|ipp|iris|iris\.beep|iris\.xpc|iris\.xpcs|iris\.lwz|ldap|mailto|mid|msrp|msrps|mtqp|mupdate|news|nfs|ni|nih|nntp|opaquelocktoken|pop|pres|rtsp|service|session|shttp|sieve|sip|sips|sms|snmp|soap\.beep|soap\.beeps|tag|tel|telnet|tftp|thismessage|tn3270|tip|tv|urn|vemmi|ws|wss|xcon|xcon-userid|xmlrpc\.beep|xmlrpc\.beeps|xmpp|z39\.50r|z39\.50s|adiumxtra|afp|afs|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|chrome|chrome-extension|com-eventbrite-attendee|content|cvs|dlna-playsingle|dlna-playcontainer|dtn|dvb|ed2k|facetime|feed|finger|fish|gg|git|gizmoproject|gtalk|hcp|icon|ipn|irc|irc6|ircs|itms|jar|jms|keyparc|lastfm|ldaps|magnet|maps|market|message|mms|ms-help|msnim|mumble|mvn|notes|oid|palm|paparazzi|platform|proxy|psyc|query|res|resource|rmi|rsync|rtmp|secondlife|sftp|sgn|skype|smb|soldat|spotify|ssh|steam|svn|teamspeak|things|udp|unreal|ut2004|ventrilo|view-source|webcal|wtai|wyciwyg|xfire|xri|ymsgr:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i
|
var urlRE = /^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|tag|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i
|
||||||
|
|
||||||
CodeMirror.defineMode("gfm", function(config, modeConfig) {
|
CodeMirror.defineMode("gfm", function(config, modeConfig) {
|
||||||
// Should GitHub spice be added (like linking #Num, SHA, etc.)
|
|
||||||
if (modeConfig.gitHubSpice === undefined)
|
|
||||||
modeConfig.gitHubSpice = true;
|
|
||||||
|
|
||||||
var codeDepth = 0;
|
var codeDepth = 0;
|
||||||
function blankLine(state) {
|
function blankLine(state) {
|
||||||
state.code = false;
|
state.code = false;
|
||||||
@ -43,7 +39,7 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) {
|
|||||||
|
|
||||||
// Hack to prevent formatting override inside code blocks (block and inline)
|
// Hack to prevent formatting override inside code blocks (block and inline)
|
||||||
if (state.codeBlock) {
|
if (state.codeBlock) {
|
||||||
if (stream.match(/^```/)) {
|
if (stream.match(/^```+/)) {
|
||||||
state.codeBlock = false;
|
state.codeBlock = false;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -53,7 +49,7 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) {
|
|||||||
if (stream.sol()) {
|
if (stream.sol()) {
|
||||||
state.code = false;
|
state.code = false;
|
||||||
}
|
}
|
||||||
if (stream.sol() && stream.match(/^```/)) {
|
if (stream.sol() && stream.match(/^```+/)) {
|
||||||
stream.skipToEnd();
|
stream.skipToEnd();
|
||||||
state.codeBlock = true;
|
state.codeBlock = true;
|
||||||
return null;
|
return null;
|
||||||
@ -84,7 +80,7 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) {
|
|||||||
}
|
}
|
||||||
if (stream.sol() || state.ateSpace) {
|
if (stream.sol() || state.ateSpace) {
|
||||||
state.ateSpace = false;
|
state.ateSpace = false;
|
||||||
if (modeConfig.gitHubSpice) {
|
if (modeConfig.gitHubSpice !== false) {
|
||||||
if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/)) {
|
if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/)) {
|
||||||
// User/Project@SHA
|
// User/Project@SHA
|
||||||
// User@SHA
|
// User@SHA
|
||||||
@ -101,7 +97,8 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (stream.match(urlRE) &&
|
if (stream.match(urlRE) &&
|
||||||
stream.string.slice(stream.start - 2, stream.start) != "](") {
|
stream.string.slice(stream.start - 2, stream.start) != "](" &&
|
||||||
|
(stream.start == 0 || /\W/.test(stream.string.charAt(stream.start - 1)))) {
|
||||||
// URLs
|
// URLs
|
||||||
// Taken from http://daringfireball.net/2010/07/improved_regex_for_matching_urls
|
// Taken from http://daringfireball.net/2010/07/improved_regex_for_matching_urls
|
||||||
// And then (issue #1160) simplified to make it not crash the Chrome Regexp engine
|
// And then (issue #1160) simplified to make it not crash the Chrome Regexp engine
|
||||||
@ -118,7 +115,7 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) {
|
|||||||
var markdownConfig = {
|
var markdownConfig = {
|
||||||
underscoresBreakWords: false,
|
underscoresBreakWords: false,
|
||||||
taskLists: true,
|
taskLists: true,
|
||||||
fencedCodeBlocks: true,
|
fencedCodeBlocks: '```',
|
||||||
strikethrough: true
|
strikethrough: true
|
||||||
};
|
};
|
||||||
for (var attr in modeConfig) {
|
for (var attr in modeConfig) {
|
||||||
|
@ -39,8 +39,10 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||||||
if (modeCfg.underscoresBreakWords === undefined)
|
if (modeCfg.underscoresBreakWords === undefined)
|
||||||
modeCfg.underscoresBreakWords = true;
|
modeCfg.underscoresBreakWords = true;
|
||||||
|
|
||||||
// Turn on fenced code blocks? ("```" to start/end)
|
// Use `fencedCodeBlocks` to configure fenced code blocks. false to
|
||||||
if (modeCfg.fencedCodeBlocks === undefined) modeCfg.fencedCodeBlocks = false;
|
// disable, string to specify a precise regexp that the fence should
|
||||||
|
// match, and true to allow three or more backticks or tildes (as
|
||||||
|
// per CommonMark).
|
||||||
|
|
||||||
// Turn on task lists? ("- [ ] " and "- [x] ")
|
// Turn on task lists? ("- [ ] " and "- [x] ")
|
||||||
if (modeCfg.taskLists === undefined) modeCfg.taskLists = false;
|
if (modeCfg.taskLists === undefined) modeCfg.taskLists = false;
|
||||||
@ -74,7 +76,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||||||
, taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE
|
, taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE
|
||||||
, atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/
|
, atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/
|
||||||
, setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/
|
, setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/
|
||||||
, textRE = /^[^#!\[\]*_\\<>` "'(~]+/;
|
, textRE = /^[^#!\[\]*_\\<>` "'(~]+/
|
||||||
|
, fencedCodeRE = new RegExp("^(" + (modeCfg.fencedCodeBlocks === true ? "~~~+|```+" : modeCfg.fencedCodeBlocks) +
|
||||||
|
")[ \\t]*([\\w+#]*)");
|
||||||
|
|
||||||
function switchInline(stream, state, f) {
|
function switchInline(stream, state, f) {
|
||||||
state.f = state.inline = f;
|
state.f = state.inline = f;
|
||||||
@ -86,6 +90,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||||||
return f(stream, state);
|
return f(stream, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function lineIsEmpty(line) {
|
||||||
|
return !line || !/\S/.test(line.string)
|
||||||
|
}
|
||||||
|
|
||||||
// Blocks
|
// Blocks
|
||||||
|
|
||||||
@ -110,7 +117,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||||||
state.trailingSpace = 0;
|
state.trailingSpace = 0;
|
||||||
state.trailingSpaceNewLine = false;
|
state.trailingSpaceNewLine = false;
|
||||||
// Mark this line as blank
|
// Mark this line as blank
|
||||||
state.thisLineHasContent = false;
|
state.prevLine = state.thisLine
|
||||||
|
state.thisLine = null
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +149,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||||||
var match = null;
|
var match = null;
|
||||||
if (state.indentationDiff >= 4) {
|
if (state.indentationDiff >= 4) {
|
||||||
stream.skipToEnd();
|
stream.skipToEnd();
|
||||||
if (prevLineIsIndentedCode || !state.prevLineHasContent) {
|
if (prevLineIsIndentedCode || lineIsEmpty(state.prevLine)) {
|
||||||
state.indentation -= 4;
|
state.indentation -= 4;
|
||||||
state.indentedCode = true;
|
state.indentedCode = true;
|
||||||
return code;
|
return code;
|
||||||
@ -155,7 +163,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||||||
if (modeCfg.highlightFormatting) state.formatting = "header";
|
if (modeCfg.highlightFormatting) state.formatting = "header";
|
||||||
state.f = state.inline;
|
state.f = state.inline;
|
||||||
return getType(state);
|
return getType(state);
|
||||||
} else if (state.prevLineHasContent && !state.quote && !prevLineIsList && !prevLineIsIndentedCode && (match = stream.match(setextHeaderRE))) {
|
} else if (!lineIsEmpty(state.prevLine) && !state.quote && !prevLineIsList &&
|
||||||
|
!prevLineIsIndentedCode && (match = stream.match(setextHeaderRE))) {
|
||||||
state.header = match[0].charAt(0) == '=' ? 1 : 2;
|
state.header = match[0].charAt(0) == '=' ? 1 : 2;
|
||||||
if (modeCfg.highlightFormatting) state.formatting = "header";
|
if (modeCfg.highlightFormatting) state.formatting = "header";
|
||||||
state.f = state.inline;
|
state.f = state.inline;
|
||||||
@ -170,7 +179,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||||||
} else if (stream.match(hrRE, true)) {
|
} else if (stream.match(hrRE, true)) {
|
||||||
state.hr = true;
|
state.hr = true;
|
||||||
return hr;
|
return hr;
|
||||||
} else if ((!state.prevLineHasContent || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) {
|
} else if ((lineIsEmpty(state.prevLine) || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) {
|
||||||
var listType = null;
|
var listType = null;
|
||||||
if (stream.match(ulRE, true)) {
|
if (stream.match(ulRE, true)) {
|
||||||
listType = 'ul';
|
listType = 'ul';
|
||||||
@ -187,9 +196,10 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||||||
state.f = state.inline;
|
state.f = state.inline;
|
||||||
if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType];
|
if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType];
|
||||||
return getType(state);
|
return getType(state);
|
||||||
} else if (modeCfg.fencedCodeBlocks && stream.match(/^```[ \t]*([\w+#]*)/, true)) {
|
} else if (modeCfg.fencedCodeBlocks && (match = stream.match(fencedCodeRE, true))) {
|
||||||
|
state.fencedChars = match[1]
|
||||||
// try switching mode
|
// try switching mode
|
||||||
state.localMode = getMode(RegExp.$1);
|
state.localMode = getMode(match[2]);
|
||||||
if (state.localMode) state.localState = state.localMode.startState();
|
if (state.localMode) state.localState = state.localMode.startState();
|
||||||
state.f = state.block = local;
|
state.f = state.block = local;
|
||||||
if (modeCfg.highlightFormatting) state.formatting = "code-block";
|
if (modeCfg.highlightFormatting) state.formatting = "code-block";
|
||||||
@ -213,7 +223,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function local(stream, state) {
|
function local(stream, state) {
|
||||||
if (stream.sol() && stream.match("```", false)) {
|
if (stream.sol() && state.fencedChars && stream.match(state.fencedChars, false)) {
|
||||||
state.localMode = state.localState = null;
|
state.localMode = state.localState = null;
|
||||||
state.f = state.block = leavingLocal;
|
state.f = state.block = leavingLocal;
|
||||||
return null;
|
return null;
|
||||||
@ -226,9 +236,10 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function leavingLocal(stream, state) {
|
function leavingLocal(stream, state) {
|
||||||
stream.match("```");
|
stream.match(state.fencedChars);
|
||||||
state.block = blockNormal;
|
state.block = blockNormal;
|
||||||
state.f = inlineNormal;
|
state.f = inlineNormal;
|
||||||
|
state.fencedChars = null;
|
||||||
if (modeCfg.highlightFormatting) state.formatting = "code-block";
|
if (modeCfg.highlightFormatting) state.formatting = "code-block";
|
||||||
state.code = true;
|
state.code = true;
|
||||||
var returnType = getType(state);
|
var returnType = getType(state);
|
||||||
@ -656,8 +667,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||||||
return {
|
return {
|
||||||
f: blockNormal,
|
f: blockNormal,
|
||||||
|
|
||||||
prevLineHasContent: false,
|
prevLine: null,
|
||||||
thisLineHasContent: false,
|
thisLine: null,
|
||||||
|
|
||||||
block: blockNormal,
|
block: blockNormal,
|
||||||
htmlState: null,
|
htmlState: null,
|
||||||
@ -680,7 +691,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||||||
quote: 0,
|
quote: 0,
|
||||||
trailingSpace: 0,
|
trailingSpace: 0,
|
||||||
trailingSpaceNewLine: false,
|
trailingSpaceNewLine: false,
|
||||||
strikethrough: false
|
strikethrough: false,
|
||||||
|
fencedChars: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -688,8 +700,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||||||
return {
|
return {
|
||||||
f: s.f,
|
f: s.f,
|
||||||
|
|
||||||
prevLineHasContent: s.prevLineHasContent,
|
prevLine: s.prevLine,
|
||||||
thisLineHasContent: s.thisLineHasContent,
|
thisLine: s.this,
|
||||||
|
|
||||||
block: s.block,
|
block: s.block,
|
||||||
htmlState: s.htmlState && CodeMirror.copyState(htmlMode, s.htmlState),
|
htmlState: s.htmlState && CodeMirror.copyState(htmlMode, s.htmlState),
|
||||||
@ -715,7 +727,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||||||
indentedCode: s.indentedCode,
|
indentedCode: s.indentedCode,
|
||||||
trailingSpace: s.trailingSpace,
|
trailingSpace: s.trailingSpace,
|
||||||
trailingSpaceNewLine: s.trailingSpaceNewLine,
|
trailingSpaceNewLine: s.trailingSpaceNewLine,
|
||||||
md_inside: s.md_inside
|
md_inside: s.md_inside,
|
||||||
|
fencedChars: s.fencedChars
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -724,22 +737,22 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||||||
// Reset state.formatting
|
// Reset state.formatting
|
||||||
state.formatting = false;
|
state.formatting = false;
|
||||||
|
|
||||||
if (stream.sol()) {
|
if (stream != state.thisLine) {
|
||||||
var forceBlankLine = !!state.header || state.hr;
|
var forceBlankLine = state.header || state.hr;
|
||||||
|
|
||||||
// Reset state.header and state.hr
|
// Reset state.header and state.hr
|
||||||
state.header = 0;
|
state.header = 0;
|
||||||
state.hr = false;
|
state.hr = false;
|
||||||
|
|
||||||
if (stream.match(/^\s*$/, true) || forceBlankLine) {
|
if (stream.match(/^\s*$/, true) || forceBlankLine) {
|
||||||
state.prevLineHasContent = false;
|
|
||||||
blankLine(state);
|
blankLine(state);
|
||||||
return forceBlankLine ? this.token(stream, state) : null;
|
if (!forceBlankLine) return null
|
||||||
} else {
|
state.prevLine = null
|
||||||
state.prevLineHasContent = state.thisLineHasContent;
|
|
||||||
state.thisLineHasContent = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state.prevLine = state.thisLine
|
||||||
|
state.thisLine = stream
|
||||||
|
|
||||||
// Reset state.taskList
|
// Reset state.taskList
|
||||||
state.taskList = false;
|
state.taskList = false;
|
||||||
|
|
||||||
|
@ -313,7 +313,8 @@ function toggleSideBySide(editor) {
|
|||||||
* instead of just appearing.
|
* instead of just appearing.
|
||||||
*/
|
*/
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
if(!cm.getOption("fullScreen")) toggleFullScreen(editor);
|
if(!cm.getOption("fullScreen"))
|
||||||
|
toggleFullScreen(editor);
|
||||||
preview.className += ' editor-preview-active-side'
|
preview.className += ' editor-preview-active-side'
|
||||||
}, 1);
|
}, 1);
|
||||||
toolbarButton.className += ' active';
|
toolbarButton.className += ' active';
|
||||||
@ -704,19 +705,19 @@ var toolbarBuiltInButtons = {
|
|||||||
"preview": {
|
"preview": {
|
||||||
name: "preview",
|
name: "preview",
|
||||||
action: togglePreview,
|
action: togglePreview,
|
||||||
className: "fa fa-eye",
|
className: "fa fa-eye no-disable",
|
||||||
title: "Toggle Preview (Ctrl+P)",
|
title: "Toggle Preview (Ctrl+P)",
|
||||||
},
|
},
|
||||||
"side-by-side": {
|
"side-by-side": {
|
||||||
name: "side-by-side",
|
name: "side-by-side",
|
||||||
action: toggleSideBySide,
|
action: toggleSideBySide,
|
||||||
className: "fa fa-columns",
|
className: "fa fa-columns no-disable no-mobile",
|
||||||
title: "Toggle Side by Side (F9)",
|
title: "Toggle Side by Side (F9)",
|
||||||
},
|
},
|
||||||
"fullscreen": {
|
"fullscreen": {
|
||||||
name: "fullscreen",
|
name: "fullscreen",
|
||||||
action: toggleFullScreen,
|
action: toggleFullScreen,
|
||||||
className: "fa fa-arrows-alt",
|
className: "fa fa-arrows-alt no-disable no-mobile",
|
||||||
title: "Toggle Fullscreen (F11)",
|
title: "Toggle Fullscreen (F11)",
|
||||||
},
|
},
|
||||||
"guide": {
|
"guide": {
|
||||||
@ -733,11 +734,41 @@ var toolbar = ["bold", "italic", "heading", "|", "quote", "unordered-list", "ord
|
|||||||
* Interface of SimpleMDE.
|
* Interface of SimpleMDE.
|
||||||
*/
|
*/
|
||||||
function SimpleMDE(options) {
|
function SimpleMDE(options) {
|
||||||
|
// Handle options parameter
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
|
|
||||||
// Used later to refer to it's parent
|
// Used later to refer to it's parent
|
||||||
options.parent = this;
|
options.parent = this;
|
||||||
|
|
||||||
|
|
||||||
|
// Check if Font Awesome needs to be auto downloaded
|
||||||
|
var autoDownloadFA = true;
|
||||||
|
|
||||||
|
if(options.autoDownloadFontAwesome === false) {
|
||||||
|
autoDownloadFA = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(options.autoDownloadFontAwesome !== true) {
|
||||||
|
var styleSheets = document.styleSheets;
|
||||||
|
for(var i = 0; i < styleSheets.length; i++) {
|
||||||
|
if(!styleSheets[i].href)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(styleSheets[i].href.indexOf("//maxcdn.bootstrapcdn.com/font-awesome/") > -1) {
|
||||||
|
autoDownloadFA = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(autoDownloadFA) {
|
||||||
|
var link = document.createElement("link");
|
||||||
|
link.rel = "stylesheet";
|
||||||
|
link.href = "https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css";
|
||||||
|
document.getElementsByTagName("head")[0].appendChild(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Find the textarea to use
|
// Find the textarea to use
|
||||||
if(options.element) {
|
if(options.element) {
|
||||||
this.element = options.element;
|
this.element = options.element;
|
||||||
@ -747,6 +778,7 @@ function SimpleMDE(options) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Handle toolbar and status bar
|
// Handle toolbar and status bar
|
||||||
if(options.toolbar !== false)
|
if(options.toolbar !== false)
|
||||||
options.toolbar = options.toolbar || SimpleMDE.toolbar;
|
options.toolbar = options.toolbar || SimpleMDE.toolbar;
|
||||||
@ -755,6 +787,7 @@ function SimpleMDE(options) {
|
|||||||
options.status = ['autosave', 'lines', 'words', 'cursor'];
|
options.status = ['autosave', 'lines', 'words', 'cursor'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Add default preview rendering function
|
// Add default preview rendering function
|
||||||
if(!options.previewRender) {
|
if(!options.previewRender) {
|
||||||
options.previewRender = function(plainText) {
|
options.previewRender = function(plainText) {
|
||||||
@ -763,15 +796,19 @@ function SimpleMDE(options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set default options for parsing config
|
// Set default options for parsing config
|
||||||
options.parsingConfig = options.parsingConfig || {};
|
options.parsingConfig = options.parsingConfig || {};
|
||||||
|
|
||||||
|
|
||||||
// Update this options
|
// Update this options
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
|
|
||||||
// Auto render
|
// Auto render
|
||||||
this.render();
|
this.render();
|
||||||
|
|
||||||
|
|
||||||
// The codemirror component is only available after rendering
|
// The codemirror component is only available after rendering
|
||||||
// so, the setter for the initialValue can only run after
|
// so, the setter for the initialValue can only run after
|
||||||
// the element has been rendered
|
// the element has been rendered
|
||||||
@ -790,13 +827,27 @@ SimpleMDE.toolbar = toolbar;
|
|||||||
*/
|
*/
|
||||||
SimpleMDE.prototype.markdown = function(text) {
|
SimpleMDE.prototype.markdown = function(text) {
|
||||||
if(window.marked) {
|
if(window.marked) {
|
||||||
|
// Initialize
|
||||||
|
var markedOptions = {};
|
||||||
|
|
||||||
|
|
||||||
// Update options
|
// Update options
|
||||||
if(this.options && this.options.singleLineBreaks !== false) {
|
if(this.options && this.options.renderingConfig && this.options.renderingConfig.singleLineBreaks !== false) {
|
||||||
marked.setOptions({
|
markedOptions.breaks = true;
|
||||||
breaks: true
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.options && this.options.renderingConfig && this.options.renderingConfig.codeSyntaxHighlighting === true && window.hljs) {
|
||||||
|
markedOptions.highlight = function(code) {
|
||||||
|
return hljs.highlightAuto(code).value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Set options
|
||||||
|
marked.setOptions(markedOptions);
|
||||||
|
|
||||||
|
|
||||||
|
// Return
|
||||||
return marked(text);
|
return marked(text);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -863,7 +914,8 @@ SimpleMDE.prototype.render = function(el) {
|
|||||||
lineNumbers: false,
|
lineNumbers: false,
|
||||||
autofocus: (options.autofocus === true) ? true : false,
|
autofocus: (options.autofocus === true) ? true : false,
|
||||||
extraKeys: keyMaps,
|
extraKeys: keyMaps,
|
||||||
lineWrapping: (options.lineWrapping === false) ? false : true
|
lineWrapping: (options.lineWrapping === false) ? false : true,
|
||||||
|
allowDroppedFileTypes: ["text/plain"]
|
||||||
});
|
});
|
||||||
|
|
||||||
if(options.toolbar !== false) {
|
if(options.toolbar !== false) {
|
||||||
@ -998,6 +1050,9 @@ SimpleMDE.prototype.createToolbar = function(items) {
|
|||||||
if(items[i].name == "guide" && self.options.toolbarGuideIcon === false)
|
if(items[i].name == "guide" && self.options.toolbarGuideIcon === false)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if(self.options.hideIcons && self.options.hideIcons.indexOf(items[i].name) != -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
(function(item) {
|
(function(item) {
|
||||||
var el;
|
var el;
|
||||||
if(item === '|') {
|
if(item === '|') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user