mirror of
https://github.com/sparksuite/simplemde-markdown-editor.git
synced 2025-09-24 16:40:55 -06:00
Merge 16042564a193bb4845a6dfe6dfc19edcaf03d2ef into 5f3a67dae25f8e855a2cf8a617cc116267223e02
This commit is contained in:
commit
a59ae2fe47
@ -90,6 +90,7 @@ simplemde.value("This text will appear in the editor");
|
||||
- **allowAtxHeaderWithoutSpace**: If set to `true`, will render headers without a space after the `#`. Defaults to `false`.
|
||||
- **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`.
|
||||
- **placeholder**: Custom placeholder that should be displayed
|
||||
- **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews.
|
||||
- **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`.
|
||||
@ -131,6 +132,7 @@ var simplemde = new SimpleMDE({
|
||||
strikethrough: false,
|
||||
underscoresBreakWords: true,
|
||||
},
|
||||
placeholder: "Type here...",
|
||||
previewRender: function(plainText) {
|
||||
return customMarkdownParser(plainText); // Returns HTML from a custom parser
|
||||
},
|
||||
|
@ -171,7 +171,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
||||
}
|
||||
|
||||
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
||||
before actuall scrolling happens, thus preventing shaking and
|
||||
before actual scrolling happens, thus preventing shaking and
|
||||
flickering artifacts. */
|
||||
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
||||
position: absolute;
|
||||
@ -551,6 +551,10 @@ span.CodeMirror-selectedtext { background: none; }
|
||||
content: 'words: '
|
||||
}
|
||||
|
||||
.editor-statusbar .characters:before {
|
||||
content: 'characters: '
|
||||
}
|
||||
|
||||
.editor-preview {
|
||||
padding: 10px;
|
||||
position: absolute;
|
||||
|
File diff suppressed because one or more lines are too long
@ -7,7 +7,7 @@
|
||||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.SimpleMDE = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
||||
(function (global){
|
||||
|
||||
; Typo = global.Typo = require("D:\\My Web Sites\\simplemde-markdown-editor\\node_modules\\codemirror-spell-checker\\src\\js\\typo.js");
|
||||
; Typo = global.Typo = require("C:\\Users\\Jamie Wohletz\\Documents\\Code\\simplemde-markdown-editor\\node_modules\\codemirror-spell-checker\\src\\js\\typo.js");
|
||||
CodeMirror = global.CodeMirror = require("codemirror");
|
||||
; var __browserify_shim_require__=require;(function browserifyShim(module, define, require) {
|
||||
// Initialize data globally to reduce memory consumption
|
||||
@ -105,7 +105,7 @@ if(!String.prototype.includes) {
|
||||
}).call(global, module, undefined, undefined);
|
||||
|
||||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
},{"D:\\My Web Sites\\simplemde-markdown-editor\\node_modules\\codemirror-spell-checker\\src\\js\\typo.js":2,"codemirror":6}],2:[function(require,module,exports){
|
||||
},{"C:\\Users\\Jamie Wohletz\\Documents\\Code\\simplemde-markdown-editor\\node_modules\\codemirror-spell-checker\\src\\js\\typo.js":2,"codemirror":7}],2:[function(require,module,exports){
|
||||
(function (global){
|
||||
; var __browserify_shim_require__=require;(function browserifyShim(module, exports, require, define, browserify_shim__define__module__export__) {
|
||||
'use strict';
|
||||
@ -922,7 +922,69 @@ Typo.prototype = {
|
||||
}
|
||||
});
|
||||
|
||||
},{"../../lib/codemirror":6}],4:[function(require,module,exports){
|
||||
},{"../../lib/codemirror":7}],4:[function(require,module,exports){
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
|
||||
var prev = old && old != CodeMirror.Init;
|
||||
if (val && !prev) {
|
||||
cm.on("blur", onBlur);
|
||||
cm.on("change", onChange);
|
||||
onChange(cm);
|
||||
} else if (!val && prev) {
|
||||
cm.off("blur", onBlur);
|
||||
cm.off("change", onChange);
|
||||
clearPlaceholder(cm);
|
||||
var wrapper = cm.getWrapperElement();
|
||||
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
|
||||
}
|
||||
|
||||
if (val && !cm.hasFocus()) onBlur(cm);
|
||||
});
|
||||
|
||||
function clearPlaceholder(cm) {
|
||||
if (cm.state.placeholder) {
|
||||
cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
|
||||
cm.state.placeholder = null;
|
||||
}
|
||||
}
|
||||
function setPlaceholder(cm) {
|
||||
clearPlaceholder(cm);
|
||||
var elt = cm.state.placeholder = document.createElement("pre");
|
||||
elt.style.cssText = "height: 0; overflow: visible";
|
||||
elt.className = "CodeMirror-placeholder";
|
||||
var placeHolder = cm.getOption("placeholder")
|
||||
if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder)
|
||||
elt.appendChild(placeHolder)
|
||||
cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
|
||||
}
|
||||
|
||||
function onBlur(cm) {
|
||||
if (isEmpty(cm)) setPlaceholder(cm);
|
||||
}
|
||||
function onChange(cm) {
|
||||
var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
|
||||
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : "");
|
||||
|
||||
if (empty) setPlaceholder(cm);
|
||||
else clearPlaceholder(cm);
|
||||
}
|
||||
|
||||
function isEmpty(cm) {
|
||||
return (cm.lineCount() === 1) && (cm.getLine(0) === "");
|
||||
}
|
||||
});
|
||||
|
||||
},{"../../lib/codemirror":7}],5:[function(require,module,exports){
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
@ -975,7 +1037,7 @@ Typo.prototype = {
|
||||
};
|
||||
});
|
||||
|
||||
},{"../../lib/codemirror":6}],5:[function(require,module,exports){
|
||||
},{"../../lib/codemirror":7}],6:[function(require,module,exports){
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
@ -1062,7 +1124,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
|
||||
});
|
||||
|
||||
},{"../../lib/codemirror":6}],6:[function(require,module,exports){
|
||||
},{"../../lib/codemirror":7}],7:[function(require,module,exports){
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
@ -1078,7 +1140,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
return define([], mod);
|
||||
else // Plain browser env
|
||||
this.CodeMirror = mod();
|
||||
(this || window).CodeMirror = mod();
|
||||
})(function() {
|
||||
"use strict";
|
||||
|
||||
@ -2159,10 +2221,6 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
|
||||
}
|
||||
|
||||
function isReadOnly(cm) {
|
||||
return cm.options.readOnly || cm.doc.cantEdit;
|
||||
}
|
||||
|
||||
// This will be set to an array of strings when copying, so that,
|
||||
// when pasting, we know what kind of selections the copied text
|
||||
// was made out of.
|
||||
@ -2217,7 +2275,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
var pasted = e.clipboardData && e.clipboardData.getData("text/plain");
|
||||
if (pasted) {
|
||||
e.preventDefault();
|
||||
if (!isReadOnly(cm) && !cm.options.disableInput)
|
||||
if (!cm.isReadOnly() && !cm.options.disableInput)
|
||||
runInOp(cm, function() { applyTextInput(cm, pasted, 0, null, "paste"); });
|
||||
return true;
|
||||
}
|
||||
@ -2320,13 +2378,14 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
});
|
||||
|
||||
on(te, "paste", function(e) {
|
||||
if (handlePaste(e, cm)) return true;
|
||||
if (signalDOMEvent(cm, e) || handlePaste(e, cm)) return
|
||||
|
||||
cm.state.pasteIncoming = true;
|
||||
input.fastPoll();
|
||||
});
|
||||
|
||||
function prepareCopyCut(e) {
|
||||
if (signalDOMEvent(cm, e)) return
|
||||
if (cm.somethingSelected()) {
|
||||
lastCopied = cm.getSelections();
|
||||
if (input.inaccurateSelection) {
|
||||
@ -2354,7 +2413,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
on(te, "copy", prepareCopyCut);
|
||||
|
||||
on(display.scroller, "paste", function(e) {
|
||||
if (eventInWidget(display, e)) return;
|
||||
if (eventInWidget(display, e) || signalDOMEvent(cm, e)) return;
|
||||
cm.state.pasteIncoming = true;
|
||||
input.focus();
|
||||
});
|
||||
@ -2488,7 +2547,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
// in which case reading its value would be expensive.
|
||||
if (this.contextMenuPending || !cm.state.focused ||
|
||||
(hasSelection(input) && !prevInput && !this.composing) ||
|
||||
isReadOnly(cm) || cm.options.disableInput || cm.state.keySeq)
|
||||
cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
|
||||
return false;
|
||||
|
||||
var text = input.value;
|
||||
@ -2639,7 +2698,9 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
var div = input.div = display.lineDiv;
|
||||
disableBrowserMagic(div);
|
||||
|
||||
on(div, "paste", function(e) { handlePaste(e, cm); })
|
||||
on(div, "paste", function(e) {
|
||||
if (!signalDOMEvent(cm, e)) handlePaste(e, cm);
|
||||
})
|
||||
|
||||
on(div, "compositionstart", function(e) {
|
||||
var data = e.data;
|
||||
@ -2677,11 +2738,12 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
|
||||
on(div, "input", function() {
|
||||
if (input.composing) return;
|
||||
if (isReadOnly(cm) || !input.pollContent())
|
||||
if (cm.isReadOnly() || !input.pollContent())
|
||||
runInOp(input.cm, function() {regChange(cm);});
|
||||
});
|
||||
|
||||
function onCopyCut(e) {
|
||||
if (signalDOMEvent(cm, e)) return
|
||||
if (cm.somethingSelected()) {
|
||||
lastCopied = cm.getSelections();
|
||||
if (e.type == "cut") cm.replaceSelection("", null, "cut");
|
||||
@ -2757,8 +2819,13 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
try { var rng = range(start.node, start.offset, end.offset, end.node); }
|
||||
catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
|
||||
if (rng) {
|
||||
if (!gecko && this.cm.state.focused) {
|
||||
sel.collapse(start.node, start.offset);
|
||||
if (!rng.collapsed) sel.addRange(rng);
|
||||
} else {
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(rng);
|
||||
}
|
||||
if (old && sel.anchorNode == null) sel.addRange(old);
|
||||
else if (gecko) this.startGracePeriod();
|
||||
}
|
||||
@ -2902,7 +2969,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
this.div.focus();
|
||||
},
|
||||
applyComposition: function(composing) {
|
||||
if (isReadOnly(this.cm))
|
||||
if (this.cm.isReadOnly())
|
||||
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);
|
||||
@ -2914,7 +2981,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
|
||||
onKeyPress: function(e) {
|
||||
e.preventDefault();
|
||||
if (!isReadOnly(this.cm))
|
||||
if (!this.cm.isReadOnly())
|
||||
operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0);
|
||||
},
|
||||
|
||||
@ -3219,7 +3286,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
|
||||
// Give beforeSelectionChange handlers a change to influence a
|
||||
// selection update.
|
||||
function filterSelectionChange(doc, sel) {
|
||||
function filterSelectionChange(doc, sel, options) {
|
||||
var obj = {
|
||||
ranges: sel.ranges,
|
||||
update: function(ranges) {
|
||||
@ -3227,7 +3294,8 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
for (var i = 0; i < ranges.length; i++)
|
||||
this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
|
||||
clipPos(doc, ranges[i].head));
|
||||
}
|
||||
},
|
||||
origin: options && options.origin
|
||||
};
|
||||
signal(doc, "beforeSelectionChange", doc, obj);
|
||||
if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj);
|
||||
@ -3253,7 +3321,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
|
||||
function setSelectionNoUndo(doc, sel, options) {
|
||||
if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
|
||||
sel = filterSelectionChange(doc, sel);
|
||||
sel = filterSelectionChange(doc, sel, options);
|
||||
|
||||
var bias = options && options.bias ||
|
||||
(cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
|
||||
@ -4679,7 +4747,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
}
|
||||
|
||||
var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained;
|
||||
if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) &&
|
||||
if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() &&
|
||||
type == "single" && (contained = sel.contains(start)) > -1 &&
|
||||
(cmp((contained = sel.ranges[contained]).from(), start) < 0 || start.xRel > 0) &&
|
||||
(cmp(contained.to(), start) > 0 || start.xRel < 0))
|
||||
@ -4903,7 +4971,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
e_preventDefault(e);
|
||||
if (ie) lastDrop = +new Date;
|
||||
var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
|
||||
if (!pos || isReadOnly(cm)) return;
|
||||
if (!pos || cm.isReadOnly()) return;
|
||||
// Might be a file drop, in which case we simply extract the text
|
||||
// and insert it.
|
||||
if (files && files.length && window.FileReader && window.File) {
|
||||
@ -5142,7 +5210,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
cm.display.input.ensurePolled();
|
||||
var prevShift = cm.display.shift, done = false;
|
||||
try {
|
||||
if (isReadOnly(cm)) cm.state.suppressEdits = true;
|
||||
if (cm.isReadOnly()) cm.state.suppressEdits = true;
|
||||
if (dropShift) cm.display.shift = false;
|
||||
done = bound(cm) != Pass;
|
||||
} finally {
|
||||
@ -6303,6 +6371,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
signal(this, "overwriteToggle", this, this.state.overwrite);
|
||||
},
|
||||
hasFocus: function() { return this.display.input.getField() == activeElt(); },
|
||||
isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit); },
|
||||
|
||||
scrollTo: methodOp(function(x, y) {
|
||||
if (x != null || y != null) resolveScrollToPos(this);
|
||||
@ -8149,7 +8218,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
if (nextChange == pos) { // Update current marker set
|
||||
spanStyle = spanEndStyle = spanStartStyle = title = css = "";
|
||||
collapsed = null; nextChange = Infinity;
|
||||
var foundBookmarks = [];
|
||||
var foundBookmarks = [], endStyles
|
||||
for (var j = 0; j < spans.length; ++j) {
|
||||
var sp = spans[j], m = sp.marker;
|
||||
if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
|
||||
@ -8162,7 +8231,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
if (m.className) spanStyle += " " + m.className;
|
||||
if (m.css) css = (css ? css + ";" : "") + m.css;
|
||||
if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle;
|
||||
if (m.endStyle && sp.to == nextChange) spanEndStyle += " " + m.endStyle;
|
||||
if (m.endStyle && sp.to == nextChange) (endStyles || (endStyles = [])).push(m.endStyle, sp.to)
|
||||
if (m.title && !title) title = m.title;
|
||||
if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
|
||||
collapsed = sp;
|
||||
@ -8170,6 +8239,9 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
nextChange = sp.from;
|
||||
}
|
||||
}
|
||||
if (endStyles) for (var j = 0; j < endStyles.length; j += 2)
|
||||
if (endStyles[j + 1] == nextChange) spanEndStyle += " " + endStyles[j]
|
||||
|
||||
if (collapsed && (collapsed.from || 0) == pos) {
|
||||
buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
|
||||
collapsed.marker, collapsed.from == null);
|
||||
@ -8517,10 +8589,11 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
|
||||
}),
|
||||
extendSelections: docMethodOp(function(heads, options) {
|
||||
extendSelections(this, clipPosArray(this, heads, options));
|
||||
extendSelections(this, clipPosArray(this, heads), options);
|
||||
}),
|
||||
extendSelectionsBy: docMethodOp(function(f, options) {
|
||||
extendSelections(this, map(this.sel.ranges, f), options);
|
||||
var heads = map(this.sel.ranges, f);
|
||||
extendSelections(this, clipPosArray(this, heads), options);
|
||||
}),
|
||||
setSelections: docMethodOp(function(ranges, primary, options) {
|
||||
if (!ranges.length) return;
|
||||
@ -9937,12 +10010,12 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
|
||||
// THE END
|
||||
|
||||
CodeMirror.version = "5.9.1";
|
||||
CodeMirror.version = "5.10.1";
|
||||
|
||||
return CodeMirror;
|
||||
});
|
||||
|
||||
},{}],7:[function(require,module,exports){
|
||||
},{}],8:[function(require,module,exports){
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
@ -10074,7 +10147,7 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) {
|
||||
CodeMirror.defineMIME("text/x-gfm", "gfm");
|
||||
});
|
||||
|
||||
},{"../../addon/mode/overlay":5,"../../lib/codemirror":6,"../markdown/markdown":8}],8:[function(require,module,exports){
|
||||
},{"../../addon/mode/overlay":6,"../../lib/codemirror":7,"../markdown/markdown":9}],9:[function(require,module,exports){
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
@ -10697,7 +10770,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
||||
}
|
||||
|
||||
function footnoteLink(stream, state) {
|
||||
if (stream.match(/^[^\]]*\]:/, false)) {
|
||||
if (stream.match(/^([^\]\\]|\\.)*\]:/, false)) {
|
||||
state.f = footnoteLinkInside;
|
||||
stream.next(); // Consume [
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
@ -10716,7 +10789,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
||||
return returnType;
|
||||
}
|
||||
|
||||
stream.match(/^[^\]]+/, true);
|
||||
stream.match(/^([^\]\\]|\\.)+/, true);
|
||||
|
||||
return tokenTypes.linkText;
|
||||
}
|
||||
@ -10879,7 +10952,7 @@ CodeMirror.defineMIME("text/x-markdown", "markdown");
|
||||
|
||||
});
|
||||
|
||||
},{"../../lib/codemirror":6,"../meta":9,"../xml/xml":10}],9:[function(require,module,exports){
|
||||
},{"../../lib/codemirror":7,"../meta":10,"../xml/xml":11}],10:[function(require,module,exports){
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
@ -10910,6 +10983,7 @@ CodeMirror.defineMIME("text/x-markdown", "markdown");
|
||||
{name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"], alias: ["lisp"]},
|
||||
{name: "Cypher", mime: "application/x-cypher-query", mode: "cypher", ext: ["cyp", "cypher"]},
|
||||
{name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"]},
|
||||
{name: "Crystal", mime: "text/x-crystal", mode: "crystal", ext: ["cr"]},
|
||||
{name: "CSS", mime: "text/css", mode: "css", ext: ["css"]},
|
||||
{name: "CQL", mime: "text/x-cassandra", mode: "sql", ext: ["cql"]},
|
||||
{name: "D", mime: "text/x-d", mode: "d", ext: ["d"]},
|
||||
@ -10937,6 +11011,7 @@ CodeMirror.defineMIME("text/x-markdown", "markdown");
|
||||
{name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy"]},
|
||||
{name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]},
|
||||
{name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]},
|
||||
{name: "Haskell (Literate)", mime: "text/x-literate-haskell", mode: "haskell-literate", ext: ["lhs"]},
|
||||
{name: "Haxe", mime: "text/x-haxe", mode: "haxe", ext: ["hx"]},
|
||||
{name: "HXML", mime: "text/x-hxml", mode: "haxe", ext: ["hxml"]},
|
||||
{name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded", ext: ["aspx"], alias: ["asp", "aspx"]},
|
||||
@ -10950,6 +11025,7 @@ CodeMirror.defineMIME("text/x-markdown", "markdown");
|
||||
mode: "javascript", ext: ["js"], alias: ["ecmascript", "js", "node"]},
|
||||
{name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"], alias: ["json5"]},
|
||||
{name: "JSON-LD", mime: "application/ld+json", mode: "javascript", ext: ["jsonld"], alias: ["jsonld"]},
|
||||
{name: "JSX", mime: "text/jsx", mode: "jsx", ext: ["jsx"]},
|
||||
{name: "Jinja2", mime: "null", mode: "jinja2"},
|
||||
{name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]},
|
||||
{name: "Kotlin", mime: "text/x-kotlin", mode: "clike", ext: ["kt"]},
|
||||
@ -11078,7 +11154,7 @@ CodeMirror.defineMIME("text/x-markdown", "markdown");
|
||||
};
|
||||
});
|
||||
|
||||
},{"../lib/codemirror":6}],10:[function(require,module,exports){
|
||||
},{"../lib/codemirror":7}],11:[function(require,module,exports){
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
@ -11092,13 +11168,7 @@ CodeMirror.defineMIME("text/x-markdown", "markdown");
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("xml", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit;
|
||||
var multilineTagIndentFactor = parserConfig.multilineTagIndentFactor || 1;
|
||||
var multilineTagIndentPastTag = parserConfig.multilineTagIndentPastTag;
|
||||
if (multilineTagIndentPastTag == null) multilineTagIndentPastTag = true;
|
||||
|
||||
var Kludges = parserConfig.htmlMode ? {
|
||||
var htmlConfig = {
|
||||
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
|
||||
'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
|
||||
'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
|
||||
@ -11130,7 +11200,9 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
||||
allowUnquoted: true,
|
||||
allowMissing: true,
|
||||
caseFold: true
|
||||
} : {
|
||||
}
|
||||
|
||||
var xmlConfig = {
|
||||
autoSelfClosers: {},
|
||||
implicitlyClosed: {},
|
||||
contextGrabbers: {},
|
||||
@ -11138,8 +11210,14 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
||||
allowUnquoted: false,
|
||||
allowMissing: false,
|
||||
caseFold: false
|
||||
};
|
||||
var alignCDATA = parserConfig.alignCDATA;
|
||||
}
|
||||
|
||||
CodeMirror.defineMode("xml", function(editorConf, config_) {
|
||||
var indentUnit = editorConf.indentUnit
|
||||
var config = {}
|
||||
var defaults = config_.htmlMode ? htmlConfig : xmlConfig
|
||||
for (var prop in defaults) config[prop] = defaults[prop]
|
||||
for (var prop in config_) config[prop] = config_[prop]
|
||||
|
||||
// Return variables for tokenizers
|
||||
var type, setStyle;
|
||||
@ -11269,7 +11347,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
||||
this.tagName = tagName;
|
||||
this.indent = state.indented;
|
||||
this.startOfLine = startOfLine;
|
||||
if (Kludges.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
|
||||
if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
|
||||
this.noIndent = true;
|
||||
}
|
||||
function popContext(state) {
|
||||
@ -11282,8 +11360,8 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
||||
return;
|
||||
}
|
||||
parentTagName = state.context.tagName;
|
||||
if (!Kludges.contextGrabbers.hasOwnProperty(parentTagName) ||
|
||||
!Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
|
||||
if (!config.contextGrabbers.hasOwnProperty(parentTagName) ||
|
||||
!config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
|
||||
return;
|
||||
}
|
||||
popContext(state);
|
||||
@ -11314,7 +11392,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
||||
if (type == "word") {
|
||||
var tagName = stream.current();
|
||||
if (state.context && state.context.tagName != tagName &&
|
||||
Kludges.implicitlyClosed.hasOwnProperty(state.context.tagName))
|
||||
config.implicitlyClosed.hasOwnProperty(state.context.tagName))
|
||||
popContext(state);
|
||||
if (state.context && state.context.tagName == tagName) {
|
||||
setStyle = "tag";
|
||||
@ -11350,7 +11428,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
||||
var tagName = state.tagName, tagStart = state.tagStart;
|
||||
state.tagName = state.tagStart = null;
|
||||
if (type == "selfcloseTag" ||
|
||||
Kludges.autoSelfClosers.hasOwnProperty(tagName)) {
|
||||
config.autoSelfClosers.hasOwnProperty(tagName)) {
|
||||
maybePopContext(state, tagName);
|
||||
} else {
|
||||
maybePopContext(state, tagName);
|
||||
@ -11363,12 +11441,12 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
||||
}
|
||||
function attrEqState(type, stream, state) {
|
||||
if (type == "equals") return attrValueState;
|
||||
if (!Kludges.allowMissing) setStyle = "error";
|
||||
if (!config.allowMissing) setStyle = "error";
|
||||
return attrState(type, stream, state);
|
||||
}
|
||||
function attrValueState(type, stream, state) {
|
||||
if (type == "string") return attrContinuedState;
|
||||
if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return attrState;}
|
||||
if (type == "word" && config.allowUnquoted) {setStyle = "string"; return attrState;}
|
||||
setStyle = "error";
|
||||
return attrState(type, stream, state);
|
||||
}
|
||||
@ -11378,12 +11456,14 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
return {tokenize: inText,
|
||||
startState: function(baseIndent) {
|
||||
var state = {tokenize: inText,
|
||||
state: baseState,
|
||||
indented: 0,
|
||||
indented: baseIndent || 0,
|
||||
tagName: null, tagStart: null,
|
||||
context: null};
|
||||
context: null}
|
||||
if (baseIndent != null) state.baseIndent = baseIndent
|
||||
return state
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
@ -11416,19 +11496,19 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
||||
return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
|
||||
// Indent the starts of attribute names.
|
||||
if (state.tagName) {
|
||||
if (multilineTagIndentPastTag)
|
||||
if (config.multilineTagIndentPastTag !== false)
|
||||
return state.tagStart + state.tagName.length + 2;
|
||||
else
|
||||
return state.tagStart + indentUnit * multilineTagIndentFactor;
|
||||
return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1);
|
||||
}
|
||||
if (alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
|
||||
if (config.alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
|
||||
var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
|
||||
if (tagAfter && tagAfter[1]) { // Closing tag spotted
|
||||
while (context) {
|
||||
if (context.tagName == tagAfter[2]) {
|
||||
context = context.prev;
|
||||
break;
|
||||
} else if (Kludges.implicitlyClosed.hasOwnProperty(context.tagName)) {
|
||||
} else if (config.implicitlyClosed.hasOwnProperty(context.tagName)) {
|
||||
context = context.prev;
|
||||
} else {
|
||||
break;
|
||||
@ -11436,25 +11516,30 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
||||
}
|
||||
} else if (tagAfter) { // Opening tag spotted
|
||||
while (context) {
|
||||
var grabbers = Kludges.contextGrabbers[context.tagName];
|
||||
var grabbers = config.contextGrabbers[context.tagName];
|
||||
if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
|
||||
context = context.prev;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (context && !context.startOfLine)
|
||||
while (context && context.prev && !context.startOfLine)
|
||||
context = context.prev;
|
||||
if (context) return context.indent + indentUnit;
|
||||
else return 0;
|
||||
else return state.baseIndent || 0;
|
||||
},
|
||||
|
||||
electricInput: /<\/[\s\w:]+>$/,
|
||||
blockCommentStart: "<!--",
|
||||
blockCommentEnd: "-->",
|
||||
|
||||
configuration: parserConfig.htmlMode ? "html" : "xml",
|
||||
helperType: parserConfig.htmlMode ? "html" : "xml"
|
||||
configuration: config.htmlMode ? "html" : "xml",
|
||||
helperType: config.htmlMode ? "html" : "xml",
|
||||
|
||||
skipAttribute: function(state) {
|
||||
if (state.state == attrValueState)
|
||||
state.state = attrState
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@ -11465,7 +11550,7 @@ if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
|
||||
|
||||
});
|
||||
|
||||
},{"../../lib/codemirror":6}],11:[function(require,module,exports){
|
||||
},{"../../lib/codemirror":7}],12:[function(require,module,exports){
|
||||
(function (global){
|
||||
/**
|
||||
* marked - a markdown parser
|
||||
@ -12754,7 +12839,7 @@ if (typeof module !== 'undefined' && typeof exports === 'object') {
|
||||
}());
|
||||
|
||||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
},{}],12:[function(require,module,exports){
|
||||
},{}],13:[function(require,module,exports){
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
@ -12800,7 +12885,7 @@ CodeMirror.commands.shiftTabAndUnindentMarkdownList = function (cm) {
|
||||
}
|
||||
};
|
||||
|
||||
},{"codemirror":6}],13:[function(require,module,exports){
|
||||
},{"codemirror":7}],14:[function(require,module,exports){
|
||||
/*global require,module*/
|
||||
"use strict";
|
||||
var CodeMirror = require("codemirror");
|
||||
@ -12809,6 +12894,7 @@ require("./codemirror/tablist");
|
||||
require("codemirror/addon/display/fullscreen.js");
|
||||
require("codemirror/mode/markdown/markdown.js");
|
||||
require("codemirror/addon/mode/overlay.js");
|
||||
require("codemirror/addon/display/placeholder.js");
|
||||
require("codemirror/mode/gfm/gfm.js");
|
||||
require("codemirror/mode/xml/xml.js");
|
||||
require("spell-checker");
|
||||
@ -13136,7 +13222,7 @@ function toggleSideBySide(editor) {
|
||||
var wrapper = cm.getWrapperElement();
|
||||
var preview = wrapper.nextSibling;
|
||||
var toolbarButton = editor.toolbarElements["side-by-side"];
|
||||
|
||||
var useSideBySideListener = false;
|
||||
if(/editor-preview-active-side/.test(preview.className)) {
|
||||
preview.className = preview.className.replace(
|
||||
/\s*editor-preview-active-side\s*/g, ""
|
||||
@ -13154,6 +13240,7 @@ function toggleSideBySide(editor) {
|
||||
}, 1);
|
||||
toolbarButton.className += " active";
|
||||
wrapper.className += " CodeMirror-sided";
|
||||
useSideBySideListener = true;
|
||||
}
|
||||
|
||||
// Hide normal preview if active
|
||||
@ -13168,13 +13255,20 @@ function toggleSideBySide(editor) {
|
||||
toolbar_div.className = toolbar_div.className.replace(/\s*disabled-for-preview*/g, "");
|
||||
}
|
||||
|
||||
// Start preview with the current text
|
||||
var sideBySideRenderingFunction = function() {
|
||||
preview.innerHTML = editor.options.previewRender(editor.value(), preview);
|
||||
};
|
||||
|
||||
// Updates preview
|
||||
cm.on("update", function() {
|
||||
if(!cm.sideBySideRenderingFunction) {
|
||||
cm.sideBySideRenderingFunction = sideBySideRenderingFunction;
|
||||
}
|
||||
|
||||
if(useSideBySideListener) {
|
||||
preview.innerHTML = editor.options.previewRender(editor.value(), preview);
|
||||
});
|
||||
cm.on("update", cm.sideBySideRenderingFunction);
|
||||
} else {
|
||||
cm.off("update", cm.sideBySideRenderingFunction);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -13616,6 +13710,23 @@ var toolbarBuiltInButtons = {
|
||||
className: "fa fa-question-circle",
|
||||
title: "Markdown Guide",
|
||||
default: true
|
||||
},
|
||||
"separator-4": {
|
||||
name: "separator-4"
|
||||
},
|
||||
"undo": {
|
||||
name: "undo",
|
||||
action: undo,
|
||||
className: "fa fa-undo no-disable",
|
||||
title: "Undo",
|
||||
default: true
|
||||
},
|
||||
"redo": {
|
||||
name: "redo",
|
||||
action: redo,
|
||||
className: "fa fa-repeat no-disable",
|
||||
title: "Redo",
|
||||
default: true
|
||||
}
|
||||
};
|
||||
|
||||
@ -13850,7 +13961,8 @@ SimpleMDE.prototype.render = function(el) {
|
||||
autofocus: (options.autofocus === true) ? true : false,
|
||||
extraKeys: keyMaps,
|
||||
lineWrapping: (options.lineWrapping === false) ? false : true,
|
||||
allowDropFileTypes: ["text/plain"]
|
||||
allowDropFileTypes: ["text/plain"],
|
||||
placeholder: options.placeholder || el.getAttribute("placeholder") || ""
|
||||
});
|
||||
|
||||
if(options.toolbar !== false) {
|
||||
@ -14074,6 +14186,11 @@ SimpleMDE.prototype.createStatusbar = function(status) {
|
||||
cm.on("update", function() {
|
||||
el.innerHTML = wordCount(cm.getValue());
|
||||
});
|
||||
} else if(name == "characters") {
|
||||
el.innerHTML = "0";
|
||||
cm.on("update", function() {
|
||||
el.innerHTML = cm.getValue().length;
|
||||
});
|
||||
} else if(name === "lines") {
|
||||
el.innerHTML = "0";
|
||||
cm.on("update", function() {
|
||||
@ -14228,5 +14345,5 @@ SimpleMDE.prototype.isFullscreenActive = function() {
|
||||
|
||||
module.exports = SimpleMDE;
|
||||
|
||||
},{"./codemirror/tablist":12,"codemirror":6,"codemirror/addon/display/fullscreen.js":3,"codemirror/addon/edit/continuelist.js":4,"codemirror/addon/mode/overlay.js":5,"codemirror/mode/gfm/gfm.js":7,"codemirror/mode/markdown/markdown.js":8,"codemirror/mode/xml/xml.js":10,"marked":11,"spell-checker":1}]},{},[13])(13)
|
||||
},{"./codemirror/tablist":13,"codemirror":7,"codemirror/addon/display/fullscreen.js":3,"codemirror/addon/display/placeholder.js":4,"codemirror/addon/edit/continuelist.js":5,"codemirror/addon/mode/overlay.js":6,"codemirror/mode/gfm/gfm.js":8,"codemirror/mode/markdown/markdown.js":9,"codemirror/mode/xml/xml.js":11,"marked":12,"spell-checker":1}]},{},[14])(14)
|
||||
});
|
2
dist/simplemde.min.css
vendored
2
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
@ -210,6 +210,10 @@
|
||||
content: 'words: '
|
||||
}
|
||||
|
||||
.editor-statusbar .characters:before {
|
||||
content: 'characters: '
|
||||
}
|
||||
|
||||
.editor-preview {
|
||||
padding: 10px;
|
||||
position: absolute;
|
||||
@ -318,3 +322,7 @@
|
||||
.CodeMirror .CodeMirror-code .cm-strikethrough {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-placeholder{
|
||||
opacity: .5;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ require("./codemirror/tablist");
|
||||
require("codemirror/addon/display/fullscreen.js");
|
||||
require("codemirror/mode/markdown/markdown.js");
|
||||
require("codemirror/addon/mode/overlay.js");
|
||||
require("codemirror/addon/display/placeholder.js");
|
||||
require("codemirror/mode/gfm/gfm.js");
|
||||
require("codemirror/mode/xml/xml.js");
|
||||
require("spell-checker");
|
||||
@ -15,18 +16,39 @@ var marked = require("marked");
|
||||
// Some variables
|
||||
var isMac = /Mac/.test(navigator.platform);
|
||||
|
||||
// Mapping of actions that can be bound to keyboard shortcuts
|
||||
var bindings = {
|
||||
"toggleBold": toggleBold,
|
||||
"toggleItalic": toggleItalic,
|
||||
"drawLink": drawLink,
|
||||
"toggleHeadingSmaller": toggleHeadingSmaller,
|
||||
"toggleHeadingBigger": toggleHeadingBigger,
|
||||
"drawImage": drawImage,
|
||||
"toggleBlockquote": toggleBlockquote,
|
||||
"toggleOrderedList": toggleOrderedList,
|
||||
"toggleUnorderedList": toggleUnorderedList,
|
||||
"toggleCodeBlock": toggleCodeBlock,
|
||||
"togglePreview": togglePreview,
|
||||
// the two below are handled manually during SimpleMDE's initialization
|
||||
// phase and the null value tells the bootstrapper to skip them
|
||||
"toggleSideBySide": null,
|
||||
"toggleFullScreen": null
|
||||
};
|
||||
|
||||
var shortcuts = {
|
||||
"Cmd-B": toggleBold,
|
||||
"Cmd-I": toggleItalic,
|
||||
"Cmd-K": drawLink,
|
||||
"Cmd-H": toggleHeadingSmaller,
|
||||
"Shift-Cmd-H": toggleHeadingBigger,
|
||||
"Cmd-Alt-I": drawImage,
|
||||
"Cmd-'": toggleBlockquote,
|
||||
"Cmd-Alt-L": toggleOrderedList,
|
||||
"Cmd-L": toggleUnorderedList,
|
||||
"Cmd-Alt-C": toggleCodeBlock,
|
||||
"Cmd-P": togglePreview
|
||||
"toggleBold": "Cmd-B",
|
||||
"toggleItalic": "Cmd-I",
|
||||
"drawLink": "Cmd-K",
|
||||
"toggleHeadingSmaller": "Cmd-H",
|
||||
"toggleHeadingBigger": "Shift-Cmd-H",
|
||||
"drawImage": "Cmd-Alt-I",
|
||||
"toggleBlockquote": "Cmd-'",
|
||||
"toggleOrderedList": "Cmd-Alt-L",
|
||||
"toggleUnorderedList": "Cmd-L",
|
||||
"toggleCodeBlock": "Cmd-Alt-C",
|
||||
"togglePreview": "Cmd-P",
|
||||
"toggleSideBySide": "F9",
|
||||
"toggleFullScreen": "F11"
|
||||
};
|
||||
|
||||
var isMobile = function() {
|
||||
@ -54,13 +76,17 @@ function fixShortcut(name) {
|
||||
/**
|
||||
* Create icon element for toolbar.
|
||||
*/
|
||||
function createIcon(options, enableTooltips) {
|
||||
function createIcon(options, enableTooltips, shortcuts) {
|
||||
options = options || {};
|
||||
var el = document.createElement("a");
|
||||
enableTooltips = (enableTooltips == undefined) ? true : enableTooltips;
|
||||
|
||||
if(options.title && enableTooltips) {
|
||||
el.title = options.title;
|
||||
el.title = options.title[0];
|
||||
|
||||
if(shortcuts[options.title[1]]) {
|
||||
el.title = options.title[0] + " (" + fixShortcut(shortcuts[options.title[1]]) + ")";
|
||||
}
|
||||
|
||||
if(isMac) {
|
||||
el.title = el.title.replace("Ctrl", "⌘");
|
||||
@ -333,7 +359,7 @@ function toggleSideBySide(editor) {
|
||||
var wrapper = cm.getWrapperElement();
|
||||
var preview = wrapper.nextSibling;
|
||||
var toolbarButton = editor.toolbarElements["side-by-side"];
|
||||
|
||||
var useSideBySideListener = false;
|
||||
if(/editor-preview-active-side/.test(preview.className)) {
|
||||
preview.className = preview.className.replace(
|
||||
/\s*editor-preview-active-side\s*/g, ""
|
||||
@ -351,6 +377,7 @@ function toggleSideBySide(editor) {
|
||||
}, 1);
|
||||
toolbarButton.className += " active";
|
||||
wrapper.className += " CodeMirror-sided";
|
||||
useSideBySideListener = true;
|
||||
}
|
||||
|
||||
// Hide normal preview if active
|
||||
@ -365,13 +392,20 @@ function toggleSideBySide(editor) {
|
||||
toolbar_div.className = toolbar_div.className.replace(/\s*disabled-for-preview*/g, "");
|
||||
}
|
||||
|
||||
// Start preview with the current text
|
||||
var sideBySideRenderingFunction = function() {
|
||||
preview.innerHTML = editor.options.previewRender(editor.value(), preview);
|
||||
};
|
||||
|
||||
// Updates preview
|
||||
cm.on("update", function() {
|
||||
if(!cm.sideBySideRenderingFunction) {
|
||||
cm.sideBySideRenderingFunction = sideBySideRenderingFunction;
|
||||
}
|
||||
|
||||
if(useSideBySideListener) {
|
||||
preview.innerHTML = editor.options.previewRender(editor.value(), preview);
|
||||
});
|
||||
cm.on("update", cm.sideBySideRenderingFunction);
|
||||
} else {
|
||||
cm.off("update", cm.sideBySideRenderingFunction);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -671,58 +705,58 @@ var toolbarBuiltInButtons = {
|
||||
name: "bold",
|
||||
action: toggleBold,
|
||||
className: "fa fa-bold",
|
||||
title: "Bold (Ctrl+B)",
|
||||
title: ["Bold", "toggleBold"],
|
||||
default: true
|
||||
},
|
||||
"italic": {
|
||||
name: "italic",
|
||||
action: toggleItalic,
|
||||
className: "fa fa-italic",
|
||||
title: "Italic (Ctrl+I)",
|
||||
title: ["Italic", "toggleItalic"],
|
||||
default: true
|
||||
},
|
||||
"strikethrough": {
|
||||
name: "strikethrough",
|
||||
action: toggleStrikethrough,
|
||||
className: "fa fa-strikethrough",
|
||||
title: "Strikethrough"
|
||||
title: ["Strikethrough", "toggleStrikethrough"]
|
||||
},
|
||||
"heading": {
|
||||
name: "heading",
|
||||
action: toggleHeadingSmaller,
|
||||
className: "fa fa-header",
|
||||
title: "Heading (Ctrl+H)",
|
||||
title: ["Heading", "toggleHeadingSmaller"],
|
||||
default: true
|
||||
},
|
||||
"heading-smaller": {
|
||||
name: "heading-smaller",
|
||||
action: toggleHeadingSmaller,
|
||||
className: "fa fa-header fa-header-x fa-header-smaller",
|
||||
title: "Smaller Heading (Ctrl+H)"
|
||||
title: ["Smaller Heading", "toggleHeadingSmaller"]
|
||||
},
|
||||
"heading-bigger": {
|
||||
name: "heading-bigger",
|
||||
action: toggleHeadingBigger,
|
||||
className: "fa fa-header fa-header-x fa-header-bigger",
|
||||
title: "Bigger Heading (Shift+Ctrl+H)"
|
||||
title: ["Bigger Heading", "toggleHeadingBigger"]
|
||||
},
|
||||
"heading-1": {
|
||||
name: "heading-1",
|
||||
action: toggleHeading1,
|
||||
className: "fa fa-header fa-header-x fa-header-1",
|
||||
title: "Big Heading"
|
||||
title: ["Big Heading", "toggleHeading1"]
|
||||
},
|
||||
"heading-2": {
|
||||
name: "heading-2",
|
||||
action: toggleHeading2,
|
||||
className: "fa fa-header fa-header-x fa-header-2",
|
||||
title: "Medium Heading"
|
||||
title: ["Medium Heading", "toggleHeading2"]
|
||||
},
|
||||
"heading-3": {
|
||||
name: "heading-3",
|
||||
action: toggleHeading3,
|
||||
className: "fa fa-header fa-header-x fa-header-3",
|
||||
title: "Small Heading"
|
||||
title: ["Small Heading", "toggleHeading3"]
|
||||
},
|
||||
"separator-1": {
|
||||
name: "separator-1"
|
||||
@ -731,27 +765,27 @@ var toolbarBuiltInButtons = {
|
||||
name: "code",
|
||||
action: toggleCodeBlock,
|
||||
className: "fa fa-code",
|
||||
title: "Code (Ctrl+Alt+C)"
|
||||
title: ["Code", "toggleCodeBlock"]
|
||||
},
|
||||
"quote": {
|
||||
name: "quote",
|
||||
action: toggleBlockquote,
|
||||
className: "fa fa-quote-left",
|
||||
title: "Quote (Ctrl+')",
|
||||
title: ["Quote", "toggleBlockquote"],
|
||||
default: true
|
||||
},
|
||||
"unordered-list": {
|
||||
name: "unordered-list",
|
||||
action: toggleUnorderedList,
|
||||
className: "fa fa-list-ul",
|
||||
title: "Generic List (Ctrl+L)",
|
||||
title: ["Generic List", "toggleUnorderedList"],
|
||||
default: true
|
||||
},
|
||||
"ordered-list": {
|
||||
name: "ordered-list",
|
||||
action: toggleOrderedList,
|
||||
className: "fa fa-list-ol",
|
||||
title: "Numbered List (Ctrl+Alt+L)",
|
||||
title: ["Numbered List", "toggleOrderedList"],
|
||||
default: true
|
||||
},
|
||||
"separator-2": {
|
||||
@ -761,27 +795,27 @@ var toolbarBuiltInButtons = {
|
||||
name: "link",
|
||||
action: drawLink,
|
||||
className: "fa fa-link",
|
||||
title: "Create Link (Ctrl+K)",
|
||||
title: ["Create Link", "drawLink"],
|
||||
default: true
|
||||
},
|
||||
"image": {
|
||||
name: "image",
|
||||
action: drawImage,
|
||||
className: "fa fa-picture-o",
|
||||
title: "Insert Image (Ctrl+Alt+I)",
|
||||
title: ["Insert Image", "drawImage"],
|
||||
default: true
|
||||
},
|
||||
"table": {
|
||||
name: "table",
|
||||
action: drawTable,
|
||||
className: "fa fa-table",
|
||||
title: "Insert Table"
|
||||
title: ["Insert Table", "drawTable"]
|
||||
},
|
||||
"horizontal-rule": {
|
||||
name: "horizontal-rule",
|
||||
action: drawHorizontalRule,
|
||||
className: "fa fa-minus",
|
||||
title: "Insert Horizontal Line"
|
||||
title: ["Insert Horizontal Line", "drawHorizontalRule"]
|
||||
},
|
||||
"separator-3": {
|
||||
name: "separator-3"
|
||||
@ -790,29 +824,44 @@ var toolbarBuiltInButtons = {
|
||||
name: "preview",
|
||||
action: togglePreview,
|
||||
className: "fa fa-eye no-disable",
|
||||
title: "Toggle Preview (Ctrl+P)",
|
||||
title: ["Toggle Preview", "togglePreview"],
|
||||
default: true
|
||||
},
|
||||
"side-by-side": {
|
||||
name: "side-by-side",
|
||||
action: toggleSideBySide,
|
||||
className: "fa fa-columns no-disable no-mobile",
|
||||
title: "Toggle Side by Side (F9)",
|
||||
title: ["Toggle Side by Side", "toggleSideBySide"],
|
||||
default: true
|
||||
},
|
||||
"fullscreen": {
|
||||
name: "fullscreen",
|
||||
action: toggleFullScreen,
|
||||
className: "fa fa-arrows-alt no-disable no-mobile",
|
||||
title: "Toggle Fullscreen (F11)",
|
||||
title: ["Toggle Fullscreen", "toggleFullScreen"],
|
||||
default: true
|
||||
},
|
||||
"guide": {
|
||||
name: "guide",
|
||||
action: "http://nextstepwebs.github.io/simplemde-markdown-editor/markdown-guide",
|
||||
className: "fa fa-question-circle",
|
||||
title: "Markdown Guide",
|
||||
title: ["Markdown Guide", null],
|
||||
default: true
|
||||
},
|
||||
"separator-4": {
|
||||
name: "separator-4"
|
||||
},
|
||||
"undo": {
|
||||
name: "undo",
|
||||
action: undo,
|
||||
className: "fa fa-undo no-disable",
|
||||
title: ["Undo", "undo"]
|
||||
},
|
||||
"redo": {
|
||||
name: "redo",
|
||||
action: redo,
|
||||
className: "fa fa-repeat no-disable",
|
||||
title: ["Redo", "redo"]
|
||||
}
|
||||
};
|
||||
|
||||
@ -925,6 +974,10 @@ function SimpleMDE(options) {
|
||||
options.blockStyles = extend({}, blockStyles, options.blockStyles || {});
|
||||
|
||||
|
||||
// Merging the shortcuts, with the given options
|
||||
options.shortcuts = extend({}, shortcuts, options.shortcuts || {});
|
||||
|
||||
|
||||
// Change unique_id to uniqueId for backwards compatibility
|
||||
if(options.autosave != undefined && options.autosave.unique_id != undefined && options.autosave.unique_id != "")
|
||||
options.autosave.uniqueId = options.autosave.unique_id;
|
||||
@ -995,13 +1048,17 @@ SimpleMDE.prototype.render = function(el) {
|
||||
var self = this;
|
||||
var keyMaps = {};
|
||||
|
||||
for(var key in shortcuts) {
|
||||
for(var key in options.shortcuts) {
|
||||
// null stands for "do not bind this command"
|
||||
if(options.shortcuts[key] !== null && bindings[key] !== null) {
|
||||
(function(key) {
|
||||
keyMaps[fixShortcut(key)] = function() {
|
||||
shortcuts[key](self);
|
||||
keyMaps[fixShortcut(options.shortcuts[key])] = function() {
|
||||
bindings[key](self);
|
||||
};
|
||||
})(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
keyMaps["Enter"] = "newlineAndIndentContinueMarkdownList";
|
||||
keyMaps["Tab"] = "tabAndIndentMarkdownList";
|
||||
@ -1047,7 +1104,8 @@ SimpleMDE.prototype.render = function(el) {
|
||||
autofocus: (options.autofocus === true) ? true : false,
|
||||
extraKeys: keyMaps,
|
||||
lineWrapping: (options.lineWrapping === false) ? false : true,
|
||||
allowDropFileTypes: ["text/plain"]
|
||||
allowDropFileTypes: ["text/plain"],
|
||||
placeholder: options.placeholder || el.getAttribute("placeholder") || ""
|
||||
});
|
||||
|
||||
if(options.toolbar !== false) {
|
||||
@ -1210,7 +1268,7 @@ SimpleMDE.prototype.createToolbar = function(items) {
|
||||
if(item === "|") {
|
||||
el = createSep();
|
||||
} else {
|
||||
el = createIcon(item, self.options.toolbarTips);
|
||||
el = createIcon(item, self.options.toolbarTips, self.options.shortcuts);
|
||||
}
|
||||
|
||||
// bind events, special for info
|
||||
@ -1271,6 +1329,11 @@ SimpleMDE.prototype.createStatusbar = function(status) {
|
||||
cm.on("update", function() {
|
||||
el.innerHTML = wordCount(cm.getValue());
|
||||
});
|
||||
} else if(name == "characters") {
|
||||
el.innerHTML = "0";
|
||||
cm.on("update", function() {
|
||||
el.innerHTML = cm.getValue().length;
|
||||
});
|
||||
} else if(name === "lines") {
|
||||
el.innerHTML = "0";
|
||||
cm.on("update", function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user