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`.
|
- **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`.
|
- **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`.
|
||||||
|
- **placeholder**: Custom placeholder that should be displayed
|
||||||
- **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.
|
||||||
- **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing).
|
- **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`.
|
- **singleLineBreaks**: If set to `false`, disable parsing GFM single line breaks. Defaults to `true`.
|
||||||
@ -131,6 +132,7 @@ var simplemde = new SimpleMDE({
|
|||||||
strikethrough: false,
|
strikethrough: false,
|
||||||
underscoresBreakWords: true,
|
underscoresBreakWords: true,
|
||||||
},
|
},
|
||||||
|
placeholder: "Type here...",
|
||||||
previewRender: function(plainText) {
|
previewRender: function(plainText) {
|
||||||
return customMarkdownParser(plainText); // Returns HTML from a custom parser
|
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
|
/* 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. */
|
flickering artifacts. */
|
||||||
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -551,6 +551,10 @@ span.CodeMirror-selectedtext { background: none; }
|
|||||||
content: 'words: '
|
content: 'words: '
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.editor-statusbar .characters:before {
|
||||||
|
content: 'characters: '
|
||||||
|
}
|
||||||
|
|
||||||
.editor-preview {
|
.editor-preview {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
position: absolute;
|
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(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){
|
(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");
|
CodeMirror = global.CodeMirror = require("codemirror");
|
||||||
; var __browserify_shim_require__=require;(function browserifyShim(module, define, require) {
|
; var __browserify_shim_require__=require;(function browserifyShim(module, define, require) {
|
||||||
// Initialize data globally to reduce memory consumption
|
// Initialize data globally to reduce memory consumption
|
||||||
@ -105,7 +105,7 @@ if(!String.prototype.includes) {
|
|||||||
}).call(global, module, undefined, undefined);
|
}).call(global, module, undefined, undefined);
|
||||||
|
|
||||||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
}).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){
|
(function (global){
|
||||||
; var __browserify_shim_require__=require;(function browserifyShim(module, exports, require, define, browserify_shim__define__module__export__) {
|
; var __browserify_shim_require__=require;(function browserifyShim(module, exports, require, define, browserify_shim__define__module__export__) {
|
||||||
'use strict';
|
'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
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
// 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
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
// 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
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
// 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
|
else if (typeof define == "function" && define.amd) // AMD
|
||||||
return define([], mod);
|
return define([], mod);
|
||||||
else // Plain browser env
|
else // Plain browser env
|
||||||
this.CodeMirror = mod();
|
(this || window).CodeMirror = mod();
|
||||||
})(function() {
|
})(function() {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
@ -2159,10 +2221,6 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||||||
if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
|
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,
|
// This will be set to an array of strings when copying, so that,
|
||||||
// when pasting, we know what kind of selections the copied text
|
// when pasting, we know what kind of selections the copied text
|
||||||
// was made out of.
|
// was made out of.
|
||||||
@ -2217,7 +2275,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||||||
var pasted = e.clipboardData && e.clipboardData.getData("text/plain");
|
var pasted = e.clipboardData && e.clipboardData.getData("text/plain");
|
||||||
if (pasted) {
|
if (pasted) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!isReadOnly(cm) && !cm.options.disableInput)
|
if (!cm.isReadOnly() && !cm.options.disableInput)
|
||||||
runInOp(cm, function() { applyTextInput(cm, pasted, 0, null, "paste"); });
|
runInOp(cm, function() { applyTextInput(cm, pasted, 0, null, "paste"); });
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2320,13 +2378,14 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
on(te, "paste", function(e) {
|
on(te, "paste", function(e) {
|
||||||
if (handlePaste(e, cm)) return true;
|
if (signalDOMEvent(cm, e) || handlePaste(e, cm)) return
|
||||||
|
|
||||||
cm.state.pasteIncoming = true;
|
cm.state.pasteIncoming = true;
|
||||||
input.fastPoll();
|
input.fastPoll();
|
||||||
});
|
});
|
||||||
|
|
||||||
function prepareCopyCut(e) {
|
function prepareCopyCut(e) {
|
||||||
|
if (signalDOMEvent(cm, e)) return
|
||||||
if (cm.somethingSelected()) {
|
if (cm.somethingSelected()) {
|
||||||
lastCopied = cm.getSelections();
|
lastCopied = cm.getSelections();
|
||||||
if (input.inaccurateSelection) {
|
if (input.inaccurateSelection) {
|
||||||
@ -2354,7 +2413,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||||||
on(te, "copy", prepareCopyCut);
|
on(te, "copy", prepareCopyCut);
|
||||||
|
|
||||||
on(display.scroller, "paste", function(e) {
|
on(display.scroller, "paste", function(e) {
|
||||||
if (eventInWidget(display, e)) return;
|
if (eventInWidget(display, e) || signalDOMEvent(cm, e)) return;
|
||||||
cm.state.pasteIncoming = true;
|
cm.state.pasteIncoming = true;
|
||||||
input.focus();
|
input.focus();
|
||||||
});
|
});
|
||||||
@ -2488,7 +2547,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||||||
// in which case reading its value would be expensive.
|
// in which case reading its value would be expensive.
|
||||||
if (this.contextMenuPending || !cm.state.focused ||
|
if (this.contextMenuPending || !cm.state.focused ||
|
||||||
(hasSelection(input) && !prevInput && !this.composing) ||
|
(hasSelection(input) && !prevInput && !this.composing) ||
|
||||||
isReadOnly(cm) || cm.options.disableInput || cm.state.keySeq)
|
cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var text = input.value;
|
var text = input.value;
|
||||||
@ -2639,7 +2698,9 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||||||
var div = input.div = display.lineDiv;
|
var div = input.div = display.lineDiv;
|
||||||
disableBrowserMagic(div);
|
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) {
|
on(div, "compositionstart", function(e) {
|
||||||
var data = e.data;
|
var data = e.data;
|
||||||
@ -2677,11 +2738,12 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||||||
|
|
||||||
on(div, "input", function() {
|
on(div, "input", function() {
|
||||||
if (input.composing) return;
|
if (input.composing) return;
|
||||||
if (isReadOnly(cm) || !input.pollContent())
|
if (cm.isReadOnly() || !input.pollContent())
|
||||||
runInOp(input.cm, function() {regChange(cm);});
|
runInOp(input.cm, function() {regChange(cm);});
|
||||||
});
|
});
|
||||||
|
|
||||||
function onCopyCut(e) {
|
function onCopyCut(e) {
|
||||||
|
if (signalDOMEvent(cm, e)) return
|
||||||
if (cm.somethingSelected()) {
|
if (cm.somethingSelected()) {
|
||||||
lastCopied = cm.getSelections();
|
lastCopied = cm.getSelections();
|
||||||
if (e.type == "cut") cm.replaceSelection("", null, "cut");
|
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); }
|
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
|
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 (rng) {
|
||||||
sel.removeAllRanges();
|
if (!gecko && this.cm.state.focused) {
|
||||||
sel.addRange(rng);
|
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);
|
if (old && sel.anchorNode == null) sel.addRange(old);
|
||||||
else if (gecko) this.startGracePeriod();
|
else if (gecko) this.startGracePeriod();
|
||||||
}
|
}
|
||||||
@ -2902,7 +2969,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||||||
this.div.focus();
|
this.div.focus();
|
||||||
},
|
},
|
||||||
applyComposition: function(composing) {
|
applyComposition: function(composing) {
|
||||||
if (isReadOnly(this.cm))
|
if (this.cm.isReadOnly())
|
||||||
operation(this.cm, regChange)(this.cm)
|
operation(this.cm, regChange)(this.cm)
|
||||||
else if (composing.data && composing.data != composing.startData)
|
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);
|
||||||
@ -2914,7 +2981,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||||||
|
|
||||||
onKeyPress: function(e) {
|
onKeyPress: function(e) {
|
||||||
e.preventDefault();
|
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);
|
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
|
// Give beforeSelectionChange handlers a change to influence a
|
||||||
// selection update.
|
// selection update.
|
||||||
function filterSelectionChange(doc, sel) {
|
function filterSelectionChange(doc, sel, options) {
|
||||||
var obj = {
|
var obj = {
|
||||||
ranges: sel.ranges,
|
ranges: sel.ranges,
|
||||||
update: function(ranges) {
|
update: function(ranges) {
|
||||||
@ -3227,7 +3294,8 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||||||
for (var i = 0; i < ranges.length; i++)
|
for (var i = 0; i < ranges.length; i++)
|
||||||
this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
|
this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
|
||||||
clipPos(doc, ranges[i].head));
|
clipPos(doc, ranges[i].head));
|
||||||
}
|
},
|
||||||
|
origin: options && options.origin
|
||||||
};
|
};
|
||||||
signal(doc, "beforeSelectionChange", doc, obj);
|
signal(doc, "beforeSelectionChange", doc, obj);
|
||||||
if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, 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) {
|
function setSelectionNoUndo(doc, sel, options) {
|
||||||
if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
|
if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
|
||||||
sel = filterSelectionChange(doc, sel);
|
sel = filterSelectionChange(doc, sel, options);
|
||||||
|
|
||||||
var bias = options && options.bias ||
|
var bias = options && options.bias ||
|
||||||
(cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
|
(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;
|
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 &&
|
type == "single" && (contained = sel.contains(start)) > -1 &&
|
||||||
(cmp((contained = sel.ranges[contained]).from(), start) < 0 || start.xRel > 0) &&
|
(cmp((contained = sel.ranges[contained]).from(), start) < 0 || start.xRel > 0) &&
|
||||||
(cmp(contained.to(), 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);
|
e_preventDefault(e);
|
||||||
if (ie) lastDrop = +new Date;
|
if (ie) lastDrop = +new Date;
|
||||||
var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
|
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
|
// Might be a file drop, in which case we simply extract the text
|
||||||
// and insert it.
|
// and insert it.
|
||||||
if (files && files.length && window.FileReader && window.File) {
|
if (files && files.length && window.FileReader && window.File) {
|
||||||
@ -5142,7 +5210,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||||||
cm.display.input.ensurePolled();
|
cm.display.input.ensurePolled();
|
||||||
var prevShift = cm.display.shift, done = false;
|
var prevShift = cm.display.shift, done = false;
|
||||||
try {
|
try {
|
||||||
if (isReadOnly(cm)) cm.state.suppressEdits = true;
|
if (cm.isReadOnly()) cm.state.suppressEdits = true;
|
||||||
if (dropShift) cm.display.shift = false;
|
if (dropShift) cm.display.shift = false;
|
||||||
done = bound(cm) != Pass;
|
done = bound(cm) != Pass;
|
||||||
} finally {
|
} finally {
|
||||||
@ -6303,6 +6371,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||||||
signal(this, "overwriteToggle", this, this.state.overwrite);
|
signal(this, "overwriteToggle", this, this.state.overwrite);
|
||||||
},
|
},
|
||||||
hasFocus: function() { return this.display.input.getField() == activeElt(); },
|
hasFocus: function() { return this.display.input.getField() == activeElt(); },
|
||||||
|
isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit); },
|
||||||
|
|
||||||
scrollTo: methodOp(function(x, y) {
|
scrollTo: methodOp(function(x, y) {
|
||||||
if (x != null || y != null) resolveScrollToPos(this);
|
if (x != null || y != null) resolveScrollToPos(this);
|
||||||
@ -8149,7 +8218,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||||||
if (nextChange == pos) { // Update current marker set
|
if (nextChange == pos) { // Update current marker set
|
||||||
spanStyle = spanEndStyle = spanStartStyle = title = css = "";
|
spanStyle = spanEndStyle = spanStartStyle = title = css = "";
|
||||||
collapsed = null; nextChange = Infinity;
|
collapsed = null; nextChange = Infinity;
|
||||||
var foundBookmarks = [];
|
var foundBookmarks = [], endStyles
|
||||||
for (var j = 0; j < spans.length; ++j) {
|
for (var j = 0; j < spans.length; ++j) {
|
||||||
var sp = spans[j], m = sp.marker;
|
var sp = spans[j], m = sp.marker;
|
||||||
if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
|
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.className) spanStyle += " " + m.className;
|
||||||
if (m.css) css = (css ? css + ";" : "") + m.css;
|
if (m.css) css = (css ? css + ";" : "") + m.css;
|
||||||
if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle;
|
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.title && !title) title = m.title;
|
||||||
if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
|
if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
|
||||||
collapsed = sp;
|
collapsed = sp;
|
||||||
@ -8170,6 +8239,9 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||||||
nextChange = sp.from;
|
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) {
|
if (collapsed && (collapsed.from || 0) == pos) {
|
||||||
buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
|
buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
|
||||||
collapsed.marker, collapsed.from == null);
|
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);
|
extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
|
||||||
}),
|
}),
|
||||||
extendSelections: docMethodOp(function(heads, options) {
|
extendSelections: docMethodOp(function(heads, options) {
|
||||||
extendSelections(this, clipPosArray(this, heads, options));
|
extendSelections(this, clipPosArray(this, heads), options);
|
||||||
}),
|
}),
|
||||||
extendSelectionsBy: docMethodOp(function(f, 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) {
|
setSelections: docMethodOp(function(ranges, primary, options) {
|
||||||
if (!ranges.length) return;
|
if (!ranges.length) return;
|
||||||
@ -9937,12 +10010,12 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
|
|||||||
|
|
||||||
// THE END
|
// THE END
|
||||||
|
|
||||||
CodeMirror.version = "5.9.1";
|
CodeMirror.version = "5.10.1";
|
||||||
|
|
||||||
return CodeMirror;
|
return CodeMirror;
|
||||||
});
|
});
|
||||||
|
|
||||||
},{}],7:[function(require,module,exports){
|
},{}],8:[function(require,module,exports){
|
||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
// 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");
|
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
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||||
|
|
||||||
@ -10697,7 +10770,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function footnoteLink(stream, state) {
|
function footnoteLink(stream, state) {
|
||||||
if (stream.match(/^[^\]]*\]:/, false)) {
|
if (stream.match(/^([^\]\\]|\\.)*\]:/, false)) {
|
||||||
state.f = footnoteLinkInside;
|
state.f = footnoteLinkInside;
|
||||||
stream.next(); // Consume [
|
stream.next(); // Consume [
|
||||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||||
@ -10716,7 +10789,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||||||
return returnType;
|
return returnType;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream.match(/^[^\]]+/, true);
|
stream.match(/^([^\]\\]|\\.)+/, true);
|
||||||
|
|
||||||
return tokenTypes.linkText;
|
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
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
// 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: "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: "Cypher", mime: "application/x-cypher-query", mode: "cypher", ext: ["cyp", "cypher"]},
|
||||||
{name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"]},
|
{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: "CSS", mime: "text/css", mode: "css", ext: ["css"]},
|
||||||
{name: "CQL", mime: "text/x-cassandra", mode: "sql", ext: ["cql"]},
|
{name: "CQL", mime: "text/x-cassandra", mode: "sql", ext: ["cql"]},
|
||||||
{name: "D", mime: "text/x-d", mode: "d", ext: ["d"]},
|
{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: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy"]},
|
||||||
{name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]},
|
{name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]},
|
||||||
{name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]},
|
{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: "Haxe", mime: "text/x-haxe", mode: "haxe", ext: ["hx"]},
|
||||||
{name: "HXML", mime: "text/x-hxml", mode: "haxe", ext: ["hxml"]},
|
{name: "HXML", mime: "text/x-hxml", mode: "haxe", ext: ["hxml"]},
|
||||||
{name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded", ext: ["aspx"], alias: ["asp", "aspx"]},
|
{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"]},
|
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", 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: "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: "Jinja2", mime: "null", mode: "jinja2"},
|
||||||
{name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]},
|
{name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]},
|
||||||
{name: "Kotlin", mime: "text/x-kotlin", mode: "clike", ext: ["kt"]},
|
{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
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||||
|
|
||||||
@ -11092,54 +11168,56 @@ CodeMirror.defineMIME("text/x-markdown", "markdown");
|
|||||||
})(function(CodeMirror) {
|
})(function(CodeMirror) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
CodeMirror.defineMode("xml", function(config, parserConfig) {
|
var htmlConfig = {
|
||||||
var indentUnit = config.indentUnit;
|
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
|
||||||
var multilineTagIndentFactor = parserConfig.multilineTagIndentFactor || 1;
|
'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
|
||||||
var multilineTagIndentPastTag = parserConfig.multilineTagIndentPastTag;
|
'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
|
||||||
if (multilineTagIndentPastTag == null) multilineTagIndentPastTag = true;
|
'track': true, 'wbr': true, 'menuitem': true},
|
||||||
|
implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
|
||||||
|
'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
|
||||||
|
'th': true, 'tr': true},
|
||||||
|
contextGrabbers: {
|
||||||
|
'dd': {'dd': true, 'dt': true},
|
||||||
|
'dt': {'dd': true, 'dt': true},
|
||||||
|
'li': {'li': true},
|
||||||
|
'option': {'option': true, 'optgroup': true},
|
||||||
|
'optgroup': {'optgroup': true},
|
||||||
|
'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
|
||||||
|
'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
|
||||||
|
'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
|
||||||
|
'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
|
||||||
|
'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
|
||||||
|
'rp': {'rp': true, 'rt': true},
|
||||||
|
'rt': {'rp': true, 'rt': true},
|
||||||
|
'tbody': {'tbody': true, 'tfoot': true},
|
||||||
|
'td': {'td': true, 'th': true},
|
||||||
|
'tfoot': {'tbody': true},
|
||||||
|
'th': {'td': true, 'th': true},
|
||||||
|
'thead': {'tbody': true, 'tfoot': true},
|
||||||
|
'tr': {'tr': true}
|
||||||
|
},
|
||||||
|
doNotIndent: {"pre": true},
|
||||||
|
allowUnquoted: true,
|
||||||
|
allowMissing: true,
|
||||||
|
caseFold: true
|
||||||
|
}
|
||||||
|
|
||||||
var Kludges = parserConfig.htmlMode ? {
|
var xmlConfig = {
|
||||||
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
|
autoSelfClosers: {},
|
||||||
'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
|
implicitlyClosed: {},
|
||||||
'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
|
contextGrabbers: {},
|
||||||
'track': true, 'wbr': true, 'menuitem': true},
|
doNotIndent: {},
|
||||||
implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
|
allowUnquoted: false,
|
||||||
'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
|
allowMissing: false,
|
||||||
'th': true, 'tr': true},
|
caseFold: false
|
||||||
contextGrabbers: {
|
}
|
||||||
'dd': {'dd': true, 'dt': true},
|
|
||||||
'dt': {'dd': true, 'dt': true},
|
CodeMirror.defineMode("xml", function(editorConf, config_) {
|
||||||
'li': {'li': true},
|
var indentUnit = editorConf.indentUnit
|
||||||
'option': {'option': true, 'optgroup': true},
|
var config = {}
|
||||||
'optgroup': {'optgroup': true},
|
var defaults = config_.htmlMode ? htmlConfig : xmlConfig
|
||||||
'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
|
for (var prop in defaults) config[prop] = defaults[prop]
|
||||||
'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
|
for (var prop in config_) config[prop] = config_[prop]
|
||||||
'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
|
|
||||||
'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
|
|
||||||
'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
|
|
||||||
'rp': {'rp': true, 'rt': true},
|
|
||||||
'rt': {'rp': true, 'rt': true},
|
|
||||||
'tbody': {'tbody': true, 'tfoot': true},
|
|
||||||
'td': {'td': true, 'th': true},
|
|
||||||
'tfoot': {'tbody': true},
|
|
||||||
'th': {'td': true, 'th': true},
|
|
||||||
'thead': {'tbody': true, 'tfoot': true},
|
|
||||||
'tr': {'tr': true}
|
|
||||||
},
|
|
||||||
doNotIndent: {"pre": true},
|
|
||||||
allowUnquoted: true,
|
|
||||||
allowMissing: true,
|
|
||||||
caseFold: true
|
|
||||||
} : {
|
|
||||||
autoSelfClosers: {},
|
|
||||||
implicitlyClosed: {},
|
|
||||||
contextGrabbers: {},
|
|
||||||
doNotIndent: {},
|
|
||||||
allowUnquoted: false,
|
|
||||||
allowMissing: false,
|
|
||||||
caseFold: false
|
|
||||||
};
|
|
||||||
var alignCDATA = parserConfig.alignCDATA;
|
|
||||||
|
|
||||||
// Return variables for tokenizers
|
// Return variables for tokenizers
|
||||||
var type, setStyle;
|
var type, setStyle;
|
||||||
@ -11269,7 +11347,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
|||||||
this.tagName = tagName;
|
this.tagName = tagName;
|
||||||
this.indent = state.indented;
|
this.indent = state.indented;
|
||||||
this.startOfLine = startOfLine;
|
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;
|
this.noIndent = true;
|
||||||
}
|
}
|
||||||
function popContext(state) {
|
function popContext(state) {
|
||||||
@ -11282,8 +11360,8 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
parentTagName = state.context.tagName;
|
parentTagName = state.context.tagName;
|
||||||
if (!Kludges.contextGrabbers.hasOwnProperty(parentTagName) ||
|
if (!config.contextGrabbers.hasOwnProperty(parentTagName) ||
|
||||||
!Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
|
!config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
popContext(state);
|
popContext(state);
|
||||||
@ -11314,7 +11392,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
|||||||
if (type == "word") {
|
if (type == "word") {
|
||||||
var tagName = stream.current();
|
var tagName = stream.current();
|
||||||
if (state.context && state.context.tagName != tagName &&
|
if (state.context && state.context.tagName != tagName &&
|
||||||
Kludges.implicitlyClosed.hasOwnProperty(state.context.tagName))
|
config.implicitlyClosed.hasOwnProperty(state.context.tagName))
|
||||||
popContext(state);
|
popContext(state);
|
||||||
if (state.context && state.context.tagName == tagName) {
|
if (state.context && state.context.tagName == tagName) {
|
||||||
setStyle = "tag";
|
setStyle = "tag";
|
||||||
@ -11350,7 +11428,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
|||||||
var tagName = state.tagName, tagStart = state.tagStart;
|
var tagName = state.tagName, tagStart = state.tagStart;
|
||||||
state.tagName = state.tagStart = null;
|
state.tagName = state.tagStart = null;
|
||||||
if (type == "selfcloseTag" ||
|
if (type == "selfcloseTag" ||
|
||||||
Kludges.autoSelfClosers.hasOwnProperty(tagName)) {
|
config.autoSelfClosers.hasOwnProperty(tagName)) {
|
||||||
maybePopContext(state, tagName);
|
maybePopContext(state, tagName);
|
||||||
} else {
|
} else {
|
||||||
maybePopContext(state, tagName);
|
maybePopContext(state, tagName);
|
||||||
@ -11363,12 +11441,12 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
|||||||
}
|
}
|
||||||
function attrEqState(type, stream, state) {
|
function attrEqState(type, stream, state) {
|
||||||
if (type == "equals") return attrValueState;
|
if (type == "equals") return attrValueState;
|
||||||
if (!Kludges.allowMissing) setStyle = "error";
|
if (!config.allowMissing) setStyle = "error";
|
||||||
return attrState(type, stream, state);
|
return attrState(type, stream, state);
|
||||||
}
|
}
|
||||||
function attrValueState(type, stream, state) {
|
function attrValueState(type, stream, state) {
|
||||||
if (type == "string") return attrContinuedState;
|
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";
|
setStyle = "error";
|
||||||
return attrState(type, stream, state);
|
return attrState(type, stream, state);
|
||||||
}
|
}
|
||||||
@ -11378,12 +11456,14 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
startState: function() {
|
startState: function(baseIndent) {
|
||||||
return {tokenize: inText,
|
var state = {tokenize: inText,
|
||||||
state: baseState,
|
state: baseState,
|
||||||
indented: 0,
|
indented: baseIndent || 0,
|
||||||
tagName: null, tagStart: null,
|
tagName: null, tagStart: null,
|
||||||
context: null};
|
context: null}
|
||||||
|
if (baseIndent != null) state.baseIndent = baseIndent
|
||||||
|
return state
|
||||||
},
|
},
|
||||||
|
|
||||||
token: function(stream, state) {
|
token: function(stream, state) {
|
||||||
@ -11416,19 +11496,19 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
|||||||
return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
|
return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
|
||||||
// Indent the starts of attribute names.
|
// Indent the starts of attribute names.
|
||||||
if (state.tagName) {
|
if (state.tagName) {
|
||||||
if (multilineTagIndentPastTag)
|
if (config.multilineTagIndentPastTag !== false)
|
||||||
return state.tagStart + state.tagName.length + 2;
|
return state.tagStart + state.tagName.length + 2;
|
||||||
else
|
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);
|
var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
|
||||||
if (tagAfter && tagAfter[1]) { // Closing tag spotted
|
if (tagAfter && tagAfter[1]) { // Closing tag spotted
|
||||||
while (context) {
|
while (context) {
|
||||||
if (context.tagName == tagAfter[2]) {
|
if (context.tagName == tagAfter[2]) {
|
||||||
context = context.prev;
|
context = context.prev;
|
||||||
break;
|
break;
|
||||||
} else if (Kludges.implicitlyClosed.hasOwnProperty(context.tagName)) {
|
} else if (config.implicitlyClosed.hasOwnProperty(context.tagName)) {
|
||||||
context = context.prev;
|
context = context.prev;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
@ -11436,25 +11516,30 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
|||||||
}
|
}
|
||||||
} else if (tagAfter) { // Opening tag spotted
|
} else if (tagAfter) { // Opening tag spotted
|
||||||
while (context) {
|
while (context) {
|
||||||
var grabbers = Kludges.contextGrabbers[context.tagName];
|
var grabbers = config.contextGrabbers[context.tagName];
|
||||||
if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
|
if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
|
||||||
context = context.prev;
|
context = context.prev;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (context && !context.startOfLine)
|
while (context && context.prev && !context.startOfLine)
|
||||||
context = context.prev;
|
context = context.prev;
|
||||||
if (context) return context.indent + indentUnit;
|
if (context) return context.indent + indentUnit;
|
||||||
else return 0;
|
else return state.baseIndent || 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
electricInput: /<\/[\s\w:]+>$/,
|
electricInput: /<\/[\s\w:]+>$/,
|
||||||
blockCommentStart: "<!--",
|
blockCommentStart: "<!--",
|
||||||
blockCommentEnd: "-->",
|
blockCommentEnd: "-->",
|
||||||
|
|
||||||
configuration: parserConfig.htmlMode ? "html" : "xml",
|
configuration: config.htmlMode ? "html" : "xml",
|
||||||
helperType: parserConfig.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){
|
(function (global){
|
||||||
/**
|
/**
|
||||||
* marked - a markdown parser
|
* 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 : {})
|
}).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
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
// 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*/
|
/*global require,module*/
|
||||||
"use strict";
|
"use strict";
|
||||||
var CodeMirror = require("codemirror");
|
var CodeMirror = require("codemirror");
|
||||||
@ -12809,6 +12894,7 @@ require("./codemirror/tablist");
|
|||||||
require("codemirror/addon/display/fullscreen.js");
|
require("codemirror/addon/display/fullscreen.js");
|
||||||
require("codemirror/mode/markdown/markdown.js");
|
require("codemirror/mode/markdown/markdown.js");
|
||||||
require("codemirror/addon/mode/overlay.js");
|
require("codemirror/addon/mode/overlay.js");
|
||||||
|
require("codemirror/addon/display/placeholder.js");
|
||||||
require("codemirror/mode/gfm/gfm.js");
|
require("codemirror/mode/gfm/gfm.js");
|
||||||
require("codemirror/mode/xml/xml.js");
|
require("codemirror/mode/xml/xml.js");
|
||||||
require("spell-checker");
|
require("spell-checker");
|
||||||
@ -13136,7 +13222,7 @@ function toggleSideBySide(editor) {
|
|||||||
var wrapper = cm.getWrapperElement();
|
var wrapper = cm.getWrapperElement();
|
||||||
var preview = wrapper.nextSibling;
|
var preview = wrapper.nextSibling;
|
||||||
var toolbarButton = editor.toolbarElements["side-by-side"];
|
var toolbarButton = editor.toolbarElements["side-by-side"];
|
||||||
|
var useSideBySideListener = false;
|
||||||
if(/editor-preview-active-side/.test(preview.className)) {
|
if(/editor-preview-active-side/.test(preview.className)) {
|
||||||
preview.className = preview.className.replace(
|
preview.className = preview.className.replace(
|
||||||
/\s*editor-preview-active-side\s*/g, ""
|
/\s*editor-preview-active-side\s*/g, ""
|
||||||
@ -13154,6 +13240,7 @@ function toggleSideBySide(editor) {
|
|||||||
}, 1);
|
}, 1);
|
||||||
toolbarButton.className += " active";
|
toolbarButton.className += " active";
|
||||||
wrapper.className += " CodeMirror-sided";
|
wrapper.className += " CodeMirror-sided";
|
||||||
|
useSideBySideListener = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide normal preview if active
|
// Hide normal preview if active
|
||||||
@ -13168,13 +13255,20 @@ function toggleSideBySide(editor) {
|
|||||||
toolbar_div.className = toolbar_div.className.replace(/\s*disabled-for-preview*/g, "");
|
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() {
|
|
||||||
preview.innerHTML = editor.options.previewRender(editor.value(), preview);
|
preview.innerHTML = editor.options.previewRender(editor.value(), preview);
|
||||||
});
|
};
|
||||||
|
|
||||||
|
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",
|
className: "fa fa-question-circle",
|
||||||
title: "Markdown Guide",
|
title: "Markdown Guide",
|
||||||
default: true
|
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,
|
autofocus: (options.autofocus === true) ? true : false,
|
||||||
extraKeys: keyMaps,
|
extraKeys: keyMaps,
|
||||||
lineWrapping: (options.lineWrapping === false) ? false : true,
|
lineWrapping: (options.lineWrapping === false) ? false : true,
|
||||||
allowDropFileTypes: ["text/plain"]
|
allowDropFileTypes: ["text/plain"],
|
||||||
|
placeholder: options.placeholder || el.getAttribute("placeholder") || ""
|
||||||
});
|
});
|
||||||
|
|
||||||
if(options.toolbar !== false) {
|
if(options.toolbar !== false) {
|
||||||
@ -14074,6 +14186,11 @@ SimpleMDE.prototype.createStatusbar = function(status) {
|
|||||||
cm.on("update", function() {
|
cm.on("update", function() {
|
||||||
el.innerHTML = wordCount(cm.getValue());
|
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") {
|
} else if(name === "lines") {
|
||||||
el.innerHTML = "0";
|
el.innerHTML = "0";
|
||||||
cm.on("update", function() {
|
cm.on("update", function() {
|
||||||
@ -14228,5 +14345,5 @@ SimpleMDE.prototype.isFullscreenActive = function() {
|
|||||||
|
|
||||||
module.exports = SimpleMDE;
|
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: '
|
content: 'words: '
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.editor-statusbar .characters:before {
|
||||||
|
content: 'characters: '
|
||||||
|
}
|
||||||
|
|
||||||
.editor-preview {
|
.editor-preview {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -318,3 +322,7 @@
|
|||||||
.CodeMirror .CodeMirror-code .cm-strikethrough {
|
.CodeMirror .CodeMirror-code .cm-strikethrough {
|
||||||
text-decoration: line-through;
|
text-decoration: line-through;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.CodeMirror .CodeMirror-placeholder{
|
||||||
|
opacity: .5;
|
||||||
|
}
|
||||||
|
@ -6,6 +6,7 @@ require("./codemirror/tablist");
|
|||||||
require("codemirror/addon/display/fullscreen.js");
|
require("codemirror/addon/display/fullscreen.js");
|
||||||
require("codemirror/mode/markdown/markdown.js");
|
require("codemirror/mode/markdown/markdown.js");
|
||||||
require("codemirror/addon/mode/overlay.js");
|
require("codemirror/addon/mode/overlay.js");
|
||||||
|
require("codemirror/addon/display/placeholder.js");
|
||||||
require("codemirror/mode/gfm/gfm.js");
|
require("codemirror/mode/gfm/gfm.js");
|
||||||
require("codemirror/mode/xml/xml.js");
|
require("codemirror/mode/xml/xml.js");
|
||||||
require("spell-checker");
|
require("spell-checker");
|
||||||
@ -15,18 +16,39 @@ var marked = require("marked");
|
|||||||
// Some variables
|
// Some variables
|
||||||
var isMac = /Mac/.test(navigator.platform);
|
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 = {
|
var shortcuts = {
|
||||||
"Cmd-B": toggleBold,
|
"toggleBold": "Cmd-B",
|
||||||
"Cmd-I": toggleItalic,
|
"toggleItalic": "Cmd-I",
|
||||||
"Cmd-K": drawLink,
|
"drawLink": "Cmd-K",
|
||||||
"Cmd-H": toggleHeadingSmaller,
|
"toggleHeadingSmaller": "Cmd-H",
|
||||||
"Shift-Cmd-H": toggleHeadingBigger,
|
"toggleHeadingBigger": "Shift-Cmd-H",
|
||||||
"Cmd-Alt-I": drawImage,
|
"drawImage": "Cmd-Alt-I",
|
||||||
"Cmd-'": toggleBlockquote,
|
"toggleBlockquote": "Cmd-'",
|
||||||
"Cmd-Alt-L": toggleOrderedList,
|
"toggleOrderedList": "Cmd-Alt-L",
|
||||||
"Cmd-L": toggleUnorderedList,
|
"toggleUnorderedList": "Cmd-L",
|
||||||
"Cmd-Alt-C": toggleCodeBlock,
|
"toggleCodeBlock": "Cmd-Alt-C",
|
||||||
"Cmd-P": togglePreview
|
"togglePreview": "Cmd-P",
|
||||||
|
"toggleSideBySide": "F9",
|
||||||
|
"toggleFullScreen": "F11"
|
||||||
};
|
};
|
||||||
|
|
||||||
var isMobile = function() {
|
var isMobile = function() {
|
||||||
@ -54,13 +76,17 @@ function fixShortcut(name) {
|
|||||||
/**
|
/**
|
||||||
* Create icon element for toolbar.
|
* Create icon element for toolbar.
|
||||||
*/
|
*/
|
||||||
function createIcon(options, enableTooltips) {
|
function createIcon(options, enableTooltips, shortcuts) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
var el = document.createElement("a");
|
var el = document.createElement("a");
|
||||||
enableTooltips = (enableTooltips == undefined) ? true : enableTooltips;
|
enableTooltips = (enableTooltips == undefined) ? true : enableTooltips;
|
||||||
|
|
||||||
if(options.title && 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) {
|
if(isMac) {
|
||||||
el.title = el.title.replace("Ctrl", "⌘");
|
el.title = el.title.replace("Ctrl", "⌘");
|
||||||
@ -333,7 +359,7 @@ function toggleSideBySide(editor) {
|
|||||||
var wrapper = cm.getWrapperElement();
|
var wrapper = cm.getWrapperElement();
|
||||||
var preview = wrapper.nextSibling;
|
var preview = wrapper.nextSibling;
|
||||||
var toolbarButton = editor.toolbarElements["side-by-side"];
|
var toolbarButton = editor.toolbarElements["side-by-side"];
|
||||||
|
var useSideBySideListener = false;
|
||||||
if(/editor-preview-active-side/.test(preview.className)) {
|
if(/editor-preview-active-side/.test(preview.className)) {
|
||||||
preview.className = preview.className.replace(
|
preview.className = preview.className.replace(
|
||||||
/\s*editor-preview-active-side\s*/g, ""
|
/\s*editor-preview-active-side\s*/g, ""
|
||||||
@ -351,6 +377,7 @@ function toggleSideBySide(editor) {
|
|||||||
}, 1);
|
}, 1);
|
||||||
toolbarButton.className += " active";
|
toolbarButton.className += " active";
|
||||||
wrapper.className += " CodeMirror-sided";
|
wrapper.className += " CodeMirror-sided";
|
||||||
|
useSideBySideListener = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide normal preview if active
|
// Hide normal preview if active
|
||||||
@ -365,13 +392,20 @@ function toggleSideBySide(editor) {
|
|||||||
toolbar_div.className = toolbar_div.className.replace(/\s*disabled-for-preview*/g, "");
|
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() {
|
|
||||||
preview.innerHTML = editor.options.previewRender(editor.value(), preview);
|
preview.innerHTML = editor.options.previewRender(editor.value(), preview);
|
||||||
});
|
};
|
||||||
|
|
||||||
|
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",
|
name: "bold",
|
||||||
action: toggleBold,
|
action: toggleBold,
|
||||||
className: "fa fa-bold",
|
className: "fa fa-bold",
|
||||||
title: "Bold (Ctrl+B)",
|
title: ["Bold", "toggleBold"],
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
"italic": {
|
"italic": {
|
||||||
name: "italic",
|
name: "italic",
|
||||||
action: toggleItalic,
|
action: toggleItalic,
|
||||||
className: "fa fa-italic",
|
className: "fa fa-italic",
|
||||||
title: "Italic (Ctrl+I)",
|
title: ["Italic", "toggleItalic"],
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
"strikethrough": {
|
"strikethrough": {
|
||||||
name: "strikethrough",
|
name: "strikethrough",
|
||||||
action: toggleStrikethrough,
|
action: toggleStrikethrough,
|
||||||
className: "fa fa-strikethrough",
|
className: "fa fa-strikethrough",
|
||||||
title: "Strikethrough"
|
title: ["Strikethrough", "toggleStrikethrough"]
|
||||||
},
|
},
|
||||||
"heading": {
|
"heading": {
|
||||||
name: "heading",
|
name: "heading",
|
||||||
action: toggleHeadingSmaller,
|
action: toggleHeadingSmaller,
|
||||||
className: "fa fa-header",
|
className: "fa fa-header",
|
||||||
title: "Heading (Ctrl+H)",
|
title: ["Heading", "toggleHeadingSmaller"],
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
"heading-smaller": {
|
"heading-smaller": {
|
||||||
name: "heading-smaller",
|
name: "heading-smaller",
|
||||||
action: toggleHeadingSmaller,
|
action: toggleHeadingSmaller,
|
||||||
className: "fa fa-header fa-header-x fa-header-smaller",
|
className: "fa fa-header fa-header-x fa-header-smaller",
|
||||||
title: "Smaller Heading (Ctrl+H)"
|
title: ["Smaller Heading", "toggleHeadingSmaller"]
|
||||||
},
|
},
|
||||||
"heading-bigger": {
|
"heading-bigger": {
|
||||||
name: "heading-bigger",
|
name: "heading-bigger",
|
||||||
action: toggleHeadingBigger,
|
action: toggleHeadingBigger,
|
||||||
className: "fa fa-header fa-header-x fa-header-bigger",
|
className: "fa fa-header fa-header-x fa-header-bigger",
|
||||||
title: "Bigger Heading (Shift+Ctrl+H)"
|
title: ["Bigger Heading", "toggleHeadingBigger"]
|
||||||
},
|
},
|
||||||
"heading-1": {
|
"heading-1": {
|
||||||
name: "heading-1",
|
name: "heading-1",
|
||||||
action: toggleHeading1,
|
action: toggleHeading1,
|
||||||
className: "fa fa-header fa-header-x fa-header-1",
|
className: "fa fa-header fa-header-x fa-header-1",
|
||||||
title: "Big Heading"
|
title: ["Big Heading", "toggleHeading1"]
|
||||||
},
|
},
|
||||||
"heading-2": {
|
"heading-2": {
|
||||||
name: "heading-2",
|
name: "heading-2",
|
||||||
action: toggleHeading2,
|
action: toggleHeading2,
|
||||||
className: "fa fa-header fa-header-x fa-header-2",
|
className: "fa fa-header fa-header-x fa-header-2",
|
||||||
title: "Medium Heading"
|
title: ["Medium Heading", "toggleHeading2"]
|
||||||
},
|
},
|
||||||
"heading-3": {
|
"heading-3": {
|
||||||
name: "heading-3",
|
name: "heading-3",
|
||||||
action: toggleHeading3,
|
action: toggleHeading3,
|
||||||
className: "fa fa-header fa-header-x fa-header-3",
|
className: "fa fa-header fa-header-x fa-header-3",
|
||||||
title: "Small Heading"
|
title: ["Small Heading", "toggleHeading3"]
|
||||||
},
|
},
|
||||||
"separator-1": {
|
"separator-1": {
|
||||||
name: "separator-1"
|
name: "separator-1"
|
||||||
@ -731,27 +765,27 @@ var toolbarBuiltInButtons = {
|
|||||||
name: "code",
|
name: "code",
|
||||||
action: toggleCodeBlock,
|
action: toggleCodeBlock,
|
||||||
className: "fa fa-code",
|
className: "fa fa-code",
|
||||||
title: "Code (Ctrl+Alt+C)"
|
title: ["Code", "toggleCodeBlock"]
|
||||||
},
|
},
|
||||||
"quote": {
|
"quote": {
|
||||||
name: "quote",
|
name: "quote",
|
||||||
action: toggleBlockquote,
|
action: toggleBlockquote,
|
||||||
className: "fa fa-quote-left",
|
className: "fa fa-quote-left",
|
||||||
title: "Quote (Ctrl+')",
|
title: ["Quote", "toggleBlockquote"],
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
"unordered-list": {
|
"unordered-list": {
|
||||||
name: "unordered-list",
|
name: "unordered-list",
|
||||||
action: toggleUnorderedList,
|
action: toggleUnorderedList,
|
||||||
className: "fa fa-list-ul",
|
className: "fa fa-list-ul",
|
||||||
title: "Generic List (Ctrl+L)",
|
title: ["Generic List", "toggleUnorderedList"],
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
"ordered-list": {
|
"ordered-list": {
|
||||||
name: "ordered-list",
|
name: "ordered-list",
|
||||||
action: toggleOrderedList,
|
action: toggleOrderedList,
|
||||||
className: "fa fa-list-ol",
|
className: "fa fa-list-ol",
|
||||||
title: "Numbered List (Ctrl+Alt+L)",
|
title: ["Numbered List", "toggleOrderedList"],
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
"separator-2": {
|
"separator-2": {
|
||||||
@ -761,27 +795,27 @@ var toolbarBuiltInButtons = {
|
|||||||
name: "link",
|
name: "link",
|
||||||
action: drawLink,
|
action: drawLink,
|
||||||
className: "fa fa-link",
|
className: "fa fa-link",
|
||||||
title: "Create Link (Ctrl+K)",
|
title: ["Create Link", "drawLink"],
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
"image": {
|
"image": {
|
||||||
name: "image",
|
name: "image",
|
||||||
action: drawImage,
|
action: drawImage,
|
||||||
className: "fa fa-picture-o",
|
className: "fa fa-picture-o",
|
||||||
title: "Insert Image (Ctrl+Alt+I)",
|
title: ["Insert Image", "drawImage"],
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
"table": {
|
"table": {
|
||||||
name: "table",
|
name: "table",
|
||||||
action: drawTable,
|
action: drawTable,
|
||||||
className: "fa fa-table",
|
className: "fa fa-table",
|
||||||
title: "Insert Table"
|
title: ["Insert Table", "drawTable"]
|
||||||
},
|
},
|
||||||
"horizontal-rule": {
|
"horizontal-rule": {
|
||||||
name: "horizontal-rule",
|
name: "horizontal-rule",
|
||||||
action: drawHorizontalRule,
|
action: drawHorizontalRule,
|
||||||
className: "fa fa-minus",
|
className: "fa fa-minus",
|
||||||
title: "Insert Horizontal Line"
|
title: ["Insert Horizontal Line", "drawHorizontalRule"]
|
||||||
},
|
},
|
||||||
"separator-3": {
|
"separator-3": {
|
||||||
name: "separator-3"
|
name: "separator-3"
|
||||||
@ -790,36 +824,51 @@ var toolbarBuiltInButtons = {
|
|||||||
name: "preview",
|
name: "preview",
|
||||||
action: togglePreview,
|
action: togglePreview,
|
||||||
className: "fa fa-eye no-disable",
|
className: "fa fa-eye no-disable",
|
||||||
title: "Toggle Preview (Ctrl+P)",
|
title: ["Toggle Preview", "togglePreview"],
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
"side-by-side": {
|
"side-by-side": {
|
||||||
name: "side-by-side",
|
name: "side-by-side",
|
||||||
action: toggleSideBySide,
|
action: toggleSideBySide,
|
||||||
className: "fa fa-columns no-disable no-mobile",
|
className: "fa fa-columns no-disable no-mobile",
|
||||||
title: "Toggle Side by Side (F9)",
|
title: ["Toggle Side by Side", "toggleSideBySide"],
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
"fullscreen": {
|
"fullscreen": {
|
||||||
name: "fullscreen",
|
name: "fullscreen",
|
||||||
action: toggleFullScreen,
|
action: toggleFullScreen,
|
||||||
className: "fa fa-arrows-alt no-disable no-mobile",
|
className: "fa fa-arrows-alt no-disable no-mobile",
|
||||||
title: "Toggle Fullscreen (F11)",
|
title: ["Toggle Fullscreen", "toggleFullScreen"],
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
"guide": {
|
"guide": {
|
||||||
name: "guide",
|
name: "guide",
|
||||||
action: "http://nextstepwebs.github.io/simplemde-markdown-editor/markdown-guide",
|
action: "http://nextstepwebs.github.io/simplemde-markdown-editor/markdown-guide",
|
||||||
className: "fa fa-question-circle",
|
className: "fa fa-question-circle",
|
||||||
title: "Markdown Guide",
|
title: ["Markdown Guide", null],
|
||||||
default: true
|
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"]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var insertTexts = {
|
var insertTexts = {
|
||||||
link: ["[", "](http://)"],
|
link: ["[", "](http://)"],
|
||||||
image: [""],
|
image: [""],
|
||||||
table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],
|
table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],
|
||||||
horizontalRule: ["", "\n\n-----\n\n"]
|
horizontalRule: ["", "\n\n-----\n\n"]
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -925,6 +974,10 @@ function SimpleMDE(options) {
|
|||||||
options.blockStyles = extend({}, blockStyles, options.blockStyles || {});
|
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
|
// Change unique_id to uniqueId for backwards compatibility
|
||||||
if(options.autosave != undefined && options.autosave.unique_id != undefined && options.autosave.unique_id != "")
|
if(options.autosave != undefined && options.autosave.unique_id != undefined && options.autosave.unique_id != "")
|
||||||
options.autosave.uniqueId = options.autosave.unique_id;
|
options.autosave.uniqueId = options.autosave.unique_id;
|
||||||
@ -995,14 +1048,18 @@ SimpleMDE.prototype.render = function(el) {
|
|||||||
var self = this;
|
var self = this;
|
||||||
var keyMaps = {};
|
var keyMaps = {};
|
||||||
|
|
||||||
for(var key in shortcuts) {
|
for(var key in options.shortcuts) {
|
||||||
(function(key) {
|
// null stands for "do not bind this command"
|
||||||
keyMaps[fixShortcut(key)] = function() {
|
if(options.shortcuts[key] !== null && bindings[key] !== null) {
|
||||||
shortcuts[key](self);
|
(function(key) {
|
||||||
};
|
keyMaps[fixShortcut(options.shortcuts[key])] = function() {
|
||||||
})(key);
|
bindings[key](self);
|
||||||
|
};
|
||||||
|
})(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
keyMaps["Enter"] = "newlineAndIndentContinueMarkdownList";
|
keyMaps["Enter"] = "newlineAndIndentContinueMarkdownList";
|
||||||
keyMaps["Tab"] = "tabAndIndentMarkdownList";
|
keyMaps["Tab"] = "tabAndIndentMarkdownList";
|
||||||
keyMaps["Shift-Tab"] = "shiftTabAndUnindentMarkdownList";
|
keyMaps["Shift-Tab"] = "shiftTabAndUnindentMarkdownList";
|
||||||
@ -1047,7 +1104,8 @@ SimpleMDE.prototype.render = function(el) {
|
|||||||
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,
|
||||||
allowDropFileTypes: ["text/plain"]
|
allowDropFileTypes: ["text/plain"],
|
||||||
|
placeholder: options.placeholder || el.getAttribute("placeholder") || ""
|
||||||
});
|
});
|
||||||
|
|
||||||
if(options.toolbar !== false) {
|
if(options.toolbar !== false) {
|
||||||
@ -1210,7 +1268,7 @@ SimpleMDE.prototype.createToolbar = function(items) {
|
|||||||
if(item === "|") {
|
if(item === "|") {
|
||||||
el = createSep();
|
el = createSep();
|
||||||
} else {
|
} else {
|
||||||
el = createIcon(item, self.options.toolbarTips);
|
el = createIcon(item, self.options.toolbarTips, self.options.shortcuts);
|
||||||
}
|
}
|
||||||
|
|
||||||
// bind events, special for info
|
// bind events, special for info
|
||||||
@ -1271,6 +1329,11 @@ SimpleMDE.prototype.createStatusbar = function(status) {
|
|||||||
cm.on("update", function() {
|
cm.on("update", function() {
|
||||||
el.innerHTML = wordCount(cm.getValue());
|
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") {
|
} else if(name === "lines") {
|
||||||
el.innerHTML = "0";
|
el.innerHTML = "0";
|
||||||
cm.on("update", function() {
|
cm.on("update", function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user