Rebuild project

pull/277/head
Wes Cossick 8 years ago
parent 26391efa26
commit 747b3ef065

@ -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 actual scrolling happens, thus preventing shaking and before actuall 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;
@ -203,7 +203,6 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
white-space: normal; white-space: normal;
height: 100%; height: 100%;
display: inline-block; display: inline-block;
vertical-align: top;
margin-bottom: -30px; margin-bottom: -30px;
/* Hack to make IE7 behave */ /* Hack to make IE7 behave */
*zoom:1; *zoom:1;

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("/Users/wescossick/Documents/Websites/simplemde-markdown-editor/node_modules/codemirror-spell-checker/src/js/typo.js"); ; Typo = global.Typo = require("D:\\My Web Sites\\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 : {})
},{"/Users/wescossick/Documents/Websites/simplemde-markdown-editor/node_modules/codemirror-spell-checker/src/js/typo.js":2,"codemirror":7}],2:[function(require,module,exports){ },{"D:\\My Web Sites\\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';
@ -1140,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 || window).CodeMirror = mod(); this.CodeMirror = mod();
})(function() { })(function() {
"use strict"; "use strict";
@ -1670,7 +1670,6 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px"; d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px"; d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent"
if (sizes.right && sizes.bottom) { if (sizes.right && sizes.bottom) {
d.scrollbarFiller.style.display = "block"; d.scrollbarFiller.style.display = "block";
@ -1915,9 +1914,9 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
function setDocumentHeight(cm, measure) { function setDocumentHeight(cm, measure) {
cm.display.sizer.style.minHeight = measure.docHeight + "px"; cm.display.sizer.style.minHeight = measure.docHeight + "px";
cm.display.heightForcer.style.top = measure.docHeight + "px"; var total = measure.docHeight + cm.display.barHeight;
cm.display.gutters.style.height = Math.max(measure.docHeight + cm.display.barHeight + scrollGap(cm), cm.display.heightForcer.style.top = total + "px";
measure.clientHeight) + "px"; cm.display.gutters.style.height = Math.max(total + scrollGap(cm), measure.clientHeight) + "px";
} }
// Read the actual heights of the rendered lines, and update their // Read the actual heights of the rendered lines, and update their
@ -2222,6 +2221,10 @@ 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.
@ -2276,7 +2279,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 (!cm.isReadOnly() && !cm.options.disableInput) if (!isReadOnly(cm) && !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;
} }
@ -2379,14 +2382,13 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
}); });
on(te, "paste", function(e) { on(te, "paste", function(e) {
if (signalDOMEvent(cm, e) || handlePaste(e, cm)) return if (handlePaste(e, cm)) return true;
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) {
@ -2414,7 +2416,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) || signalDOMEvent(cm, e)) return; if (eventInWidget(display, e)) return;
cm.state.pasteIncoming = true; cm.state.pasteIncoming = true;
input.focus(); input.focus();
}); });
@ -2548,7 +2550,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) ||
cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq) isReadOnly(cm) || cm.options.disableInput || cm.state.keySeq)
return false; return false;
var text = input.value; var text = input.value;
@ -2610,11 +2612,10 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
if (reset && cm.doc.sel.contains(pos) == -1) if (reset && cm.doc.sel.contains(pos) == -1)
operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll); operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll);
var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText; var oldCSS = te.style.cssText;
input.wrapper.style.cssText = "position: absolute" input.wrapper.style.position = "absolute";
var wrapperBox = input.wrapper.getBoundingClientRect() te.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) +
te.style.cssText = "position: absolute; width: 30px; height: 30px; top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: " +
"px; left: " + (e.clientX - wrapperBox.left - 5) + "px; z-index: 1000; background: " +
(ie ? "rgba(255, 255, 255, .05)" : "transparent") + (ie ? "rgba(255, 255, 255, .05)" : "transparent") +
"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);"; "; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
if (webkit) var oldScrollY = window.scrollY; // Work around Chrome issue (#2712) if (webkit) var oldScrollY = window.scrollY; // Work around Chrome issue (#2712)
@ -2645,7 +2646,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
} }
function rehide() { function rehide() {
input.contextMenuPending = false; input.contextMenuPending = false;
input.wrapper.style.cssText = oldWrapperCSS input.wrapper.style.position = "relative";
te.style.cssText = oldCSS; te.style.cssText = oldCSS;
if (ie && ie_version < 9) display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos); if (ie && ie_version < 9) display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos);
@ -2700,9 +2701,7 @@ 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) { on(div, "paste", function(e) { handlePaste(e, cm); })
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;
@ -2740,12 +2739,11 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
on(div, "input", function() { on(div, "input", function() {
if (input.composing) return; if (input.composing) return;
if (cm.isReadOnly() || !input.pollContent()) if (isReadOnly(cm) || !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");
@ -2821,13 +2819,8 @@ 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) {
if (!gecko && this.cm.state.focused) { sel.removeAllRanges();
sel.collapse(start.node, start.offset); sel.addRange(rng);
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();
} }
@ -2971,7 +2964,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
this.div.focus(); this.div.focus();
}, },
applyComposition: function(composing) { applyComposition: function(composing) {
if (this.cm.isReadOnly()) if (isReadOnly(this.cm))
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);
@ -2983,7 +2976,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
onKeyPress: function(e) { onKeyPress: function(e) {
e.preventDefault(); e.preventDefault();
if (!this.cm.isReadOnly()) if (!isReadOnly(this.cm))
operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0); operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0);
}, },
@ -3288,7 +3281,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, options) { function filterSelectionChange(doc, sel) {
var obj = { var obj = {
ranges: sel.ranges, ranges: sel.ranges,
update: function(ranges) { update: function(ranges) {
@ -3296,8 +3289,7 @@ 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);
@ -3323,7 +3315,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, options); sel = filterSelectionChange(doc, sel);
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);
@ -4268,7 +4260,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
display.scroller.scrollTop = doc.scrollTop; display.scroller.scrollTop = doc.scrollTop;
} }
if (op.scrollLeft != null && (display.scroller.scrollLeft != op.scrollLeft || op.forceScroll)) { if (op.scrollLeft != null && (display.scroller.scrollLeft != op.scrollLeft || op.forceScroll)) {
doc.scrollLeft = Math.max(0, Math.min(display.scroller.scrollWidth - display.scroller.clientWidth, op.scrollLeft)); doc.scrollLeft = Math.max(0, Math.min(display.scroller.scrollWidth - displayWidth(cm), op.scrollLeft));
display.scrollbars.setScrollLeft(doc.scrollLeft); display.scrollbars.setScrollLeft(doc.scrollLeft);
display.scroller.scrollLeft = doc.scrollLeft; display.scroller.scrollLeft = doc.scrollLeft;
alignHorizontally(cm); alignHorizontally(cm);
@ -4564,7 +4556,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
return dx * dx + dy * dy > 20 * 20; return dx * dx + dy * dy > 20 * 20;
} }
on(d.scroller, "touchstart", function(e) { on(d.scroller, "touchstart", function(e) {
if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e)) { if (!isMouseLikeTouchEvent(e)) {
clearTimeout(touchFinished); clearTimeout(touchFinished);
var now = +new Date; var now = +new Date;
d.activeTouch = {start: now, moved: false, d.activeTouch = {start: now, moved: false,
@ -4693,7 +4685,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
// not interfere with, such as a scrollbar or widget. // not interfere with, such as a scrollbar or widget.
function onMouseDown(e) { function onMouseDown(e) {
var cm = this, display = cm.display; var cm = this, display = cm.display;
if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) return; if (display.activeTouch && display.input.supportsTouch() || signalDOMEvent(cm, e)) return;
display.shift = e.shiftKey; display.shift = e.shiftKey;
if (eventInWidget(display, e)) { if (eventInWidget(display, e)) {
@ -4749,7 +4741,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 && !cm.isReadOnly() && if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) &&
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))
@ -4973,7 +4965,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 || cm.isReadOnly()) return; if (!pos || isReadOnly(cm)) 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) {
@ -5212,7 +5204,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 (cm.isReadOnly()) cm.state.suppressEdits = true; if (isReadOnly(cm)) 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 {
@ -5945,9 +5937,10 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
function findPosH(doc, pos, dir, unit, visually) { function findPosH(doc, pos, dir, unit, visually) {
var line = pos.line, ch = pos.ch, origDir = dir; var line = pos.line, ch = pos.ch, origDir = dir;
var lineObj = getLine(doc, line); var lineObj = getLine(doc, line);
var possible = true;
function findNextLine() { function findNextLine() {
var l = line + dir; var l = line + dir;
if (l < doc.first || l >= doc.first + doc.size) return false if (l < doc.first || l >= doc.first + doc.size) return (possible = false);
line = l; line = l;
return lineObj = getLine(doc, l); return lineObj = getLine(doc, l);
} }
@ -5957,16 +5950,14 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
if (!boundToLine && findNextLine()) { if (!boundToLine && findNextLine()) {
if (visually) ch = (dir < 0 ? lineRight : lineLeft)(lineObj); if (visually) ch = (dir < 0 ? lineRight : lineLeft)(lineObj);
else ch = dir < 0 ? lineObj.text.length : 0; else ch = dir < 0 ? lineObj.text.length : 0;
} else return false } else return (possible = false);
} else ch = next; } else ch = next;
return true; return true;
} }
if (unit == "char") { if (unit == "char") moveOnce();
moveOnce() else if (unit == "column") moveOnce(true);
} else if (unit == "column") { else if (unit == "word" || unit == "group") {
moveOnce(true)
} else if (unit == "word" || unit == "group") {
var sawType = null, group = unit == "group"; var sawType = null, group = unit == "group";
var helper = doc.cm && doc.cm.getHelper(pos, "wordChars"); var helper = doc.cm && doc.cm.getHelper(pos, "wordChars");
for (var first = true;; first = false) { for (var first = true;; first = false) {
@ -5987,7 +5978,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
} }
} }
var result = skipAtomic(doc, Pos(line, ch), pos, origDir, true); var result = skipAtomic(doc, Pos(line, ch), pos, origDir, true);
if (!cmp(pos, result)) result.hitSide = true; if (!possible) result.hitSide = true;
return result; return result;
} }
@ -6374,7 +6365,6 @@ 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);
@ -8221,7 +8211,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 = [], endStyles var foundBookmarks = [];
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) {
@ -8234,7 +8224,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) (endStyles || (endStyles = [])).push(m.endStyle, sp.to) if (m.endStyle && sp.to == nextChange) spanEndStyle += " " + m.endStyle;
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;
@ -8242,17 +8232,14 @@ 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 == pos) for (var j = 0; j < foundBookmarks.length; ++j)
buildCollapsedSpan(builder, 0, foundBookmarks[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);
if (collapsed.to == null) return; if (collapsed.to == null) return;
if (collapsed.to == pos) collapsed = false; if (collapsed.to == pos) collapsed = false;
} }
if (!collapsed && foundBookmarks.length) for (var j = 0; j < foundBookmarks.length; ++j)
buildCollapsedSpan(builder, 0, foundBookmarks[j]);
} }
if (pos >= len) break; if (pos >= len) break;
@ -8592,11 +8579,10 @@ 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) {
var heads = map(this.sel.ranges, f); extendSelections(this, map(this.sel.ranges, f), options);
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;
@ -8749,9 +8735,9 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
var spans = line.markedSpans; var spans = line.markedSpans;
if (spans) for (var i = 0; i < spans.length; i++) { if (spans) for (var i = 0; i < spans.length; i++) {
var span = spans[i]; var span = spans[i];
if (!(span.to != null && lineNo == from.line && from.ch > span.to || if (!(lineNo == from.line && from.ch > span.to ||
span.from == null && lineNo != from.line || span.from == null && lineNo != from.line||
span.from != null && lineNo == to.line && span.from > to.ch) && lineNo == to.line && span.from > to.ch) &&
(!filter || filter(span.marker))) (!filter || filter(span.marker)))
found.push(span.marker.parent || span.marker); found.push(span.marker.parent || span.marker);
} }
@ -10013,7 +9999,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
// THE END // THE END
CodeMirror.version = "5.12.1"; CodeMirror.version = "5.9.1";
return CodeMirror; return CodeMirror;
}); });
@ -10166,8 +10152,8 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) {
CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
var htmlMode = CodeMirror.getMode(cmCfg, "text/html"); var htmlFound = CodeMirror.modes.hasOwnProperty("xml");
var htmlModeMissing = htmlMode.name == "null" var htmlMode = CodeMirror.getMode(cmCfg, htmlFound ? {name: "xml", htmlMode: true} : "text/plain");
function getMode(name) { function getMode(name) {
if (CodeMirror.findModeByName) { if (CodeMirror.findModeByName) {
@ -10208,6 +10194,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
if (modeCfg.tokenTypeOverrides === undefined) if (modeCfg.tokenTypeOverrides === undefined)
modeCfg.tokenTypeOverrides = {}; modeCfg.tokenTypeOverrides = {};
var codeDepth = 0;
var tokenTypes = { var tokenTypes = {
header: "header", header: "header",
code: "comment", code: "comment",
@ -10272,7 +10260,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
state.quote = 0; state.quote = 0;
// Reset state.indentedCode // Reset state.indentedCode
state.indentedCode = false; state.indentedCode = false;
if (htmlModeMissing && state.f == htmlBlock) { if (!htmlFound && state.f == htmlBlock) {
state.f = inlineNormal; state.f = inlineNormal;
state.block = blockNormal; state.block = blockNormal;
} }
@ -10366,7 +10354,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
if (state.localMode) state.localState = state.localMode.startState(); if (state.localMode) state.localState = state.localMode.startState();
state.f = state.block = local; state.f = state.block = local;
if (modeCfg.highlightFormatting) state.formatting = "code-block"; if (modeCfg.highlightFormatting) state.formatting = "code-block";
state.code = -1 state.code = true;
return getType(state); return getType(state);
} }
@ -10375,21 +10363,18 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
function htmlBlock(stream, state) { function htmlBlock(stream, state) {
var style = htmlMode.token(stream, state.htmlState); var style = htmlMode.token(stream, state.htmlState);
if (!htmlModeMissing) { if ((htmlFound && state.htmlState.tagStart === null &&
var inner = CodeMirror.innerMode(htmlMode, state.htmlState) (!state.htmlState.context && state.htmlState.tokenize.isInText)) ||
if ((inner.mode.name == "xml" && inner.state.tagStart === null && (state.md_inside && stream.current().indexOf(">") > -1)) {
(!inner.state.context && inner.state.tokenize.isInText)) || state.f = inlineNormal;
(state.md_inside && stream.current().indexOf(">") > -1)) { state.block = blockNormal;
state.f = inlineNormal; state.htmlState = null;
state.block = blockNormal;
state.htmlState = null;
}
} }
return style; return style;
} }
function local(stream, state) { function local(stream, state) {
if (state.fencedChars && stream.match(state.fencedChars, false)) { if (stream.sol() && state.fencedChars && stream.match(state.fencedChars, false)) {
state.localMode = state.localState = null; state.localMode = state.localState = null;
state.f = state.block = leavingLocal; state.f = state.block = leavingLocal;
return null; return null;
@ -10407,9 +10392,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
state.f = inlineNormal; state.f = inlineNormal;
state.fencedChars = null; state.fencedChars = null;
if (modeCfg.highlightFormatting) state.formatting = "code-block"; if (modeCfg.highlightFormatting) state.formatting = "code-block";
state.code = 1 state.code = true;
var returnType = getType(state); var returnType = getType(state);
state.code = 0 state.code = false;
return returnType; return returnType;
} }
@ -10532,6 +10517,15 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
var ch = stream.next(); var ch = stream.next();
if (ch === '\\') {
stream.next();
if (modeCfg.highlightFormatting) {
var type = getType(state);
var formattingEscape = tokenTypes.formatting + "-escape";
return type ? type + " " + formattingEscape : formattingEscape;
}
}
// Matches link titles present on next line // Matches link titles present on next line
if (state.linkTitle) { if (state.linkTitle) {
state.linkTitle = false; state.linkTitle = false;
@ -10550,32 +10544,26 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
if (ch === '`') { if (ch === '`') {
var previousFormatting = state.formatting; var previousFormatting = state.formatting;
if (modeCfg.highlightFormatting) state.formatting = "code"; if (modeCfg.highlightFormatting) state.formatting = "code";
var t = getType(state);
var before = stream.pos;
stream.eatWhile('`'); stream.eatWhile('`');
var count = stream.current().length var difference = 1 + stream.pos - before;
if (state.code == 0) { if (!state.code) {
state.code = count codeDepth = difference;
return getType(state) state.code = true;
} else if (count == state.code) { // Must be exact return getType(state);
var t = getType(state)
state.code = 0
return t
} else { } else {
state.formatting = previousFormatting if (difference === codeDepth) { // Must be exact
return getType(state) state.code = false;
return t;
}
state.formatting = previousFormatting;
return getType(state);
} }
} else if (state.code) { } else if (state.code) {
return getType(state); return getType(state);
} }
if (ch === '\\') {
stream.next();
if (modeCfg.highlightFormatting) {
var type = getType(state);
var formattingEscape = tokenTypes.formatting + "-escape";
return type ? type + " " + formattingEscape : formattingEscape;
}
}
if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) { if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
stream.match(/\[[^\]]*\]/); stream.match(/\[[^\]]*\]/);
state.inline = state.f = linkHref; state.inline = state.f = linkHref;
@ -10771,7 +10759,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";
@ -10790,7 +10778,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
return returnType; return returnType;
} }
stream.match(/^([^\]\\]|\\.)+/, true); stream.match(/^[^\]]+/, true);
return tokenTypes.linkText; return tokenTypes.linkText;
} }
@ -10843,7 +10831,6 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
linkText: false, linkText: false,
linkHref: false, linkHref: false,
linkTitle: false, linkTitle: false,
code: 0,
em: false, em: false,
strong: false, strong: false,
header: 0, header: 0,
@ -10979,14 +10966,12 @@ CodeMirror.defineMIME("text/x-markdown", "markdown");
{name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]}, {name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]},
{name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp"]}, {name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp"]},
{name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj"]}, {name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj"]},
{name: "ClojureScript", mime: "text/x-clojurescript", mode: "clojure", ext: ["cljs"]},
{name: "Closure Stylesheets (GSS)", mime: "text/x-gss", mode: "css", ext: ["gss"]}, {name: "Closure Stylesheets (GSS)", mime: "text/x-gss", mode: "css", ext: ["gss"]},
{name: "CMake", mime: "text/x-cmake", mode: "cmake", ext: ["cmake", "cmake.in"], file: /^CMakeLists.txt$/}, {name: "CMake", mime: "text/x-cmake", mode: "cmake", ext: ["cmake", "cmake.in"], file: /^CMakeLists.txt$/},
{name: "CoffeeScript", mime: "text/x-coffeescript", mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]}, {name: "CoffeeScript", mime: "text/x-coffeescript", mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]},
{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"]},
@ -11004,7 +10989,6 @@ CodeMirror.defineMIME("text/x-markdown", "markdown");
{name: "Embedded Ruby", mime: "application/x-erb", mode: "htmlembedded", ext: ["erb"]}, {name: "Embedded Ruby", mime: "application/x-erb", mode: "htmlembedded", ext: ["erb"]},
{name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"]}, {name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"]},
{name: "Factor", mime: "text/x-factor", mode: "factor", ext: ["factor"]}, {name: "Factor", mime: "text/x-factor", mode: "factor", ext: ["factor"]},
{name: "FCL", mime: "text/x-fcl", mode: "fcl"},
{name: "Forth", mime: "text/x-forth", mode: "forth", ext: ["forth", "fth", "4th"]}, {name: "Forth", mime: "text/x-forth", mode: "forth", ext: ["forth", "fth", "4th"]},
{name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90"]}, {name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90"]},
{name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]}, {name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]},
@ -11012,10 +10996,9 @@ CodeMirror.defineMIME("text/x-markdown", "markdown");
{name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]}, {name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]},
{name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history).md$/i}, {name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history).md$/i},
{name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]}, {name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]},
{name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"]}, {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"]},
@ -11029,7 +11012,6 @@ 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"]},
@ -11041,7 +11023,7 @@ CodeMirror.defineMIME("text/x-markdown", "markdown");
{name: "MariaDB SQL", mime: "text/x-mariadb", mode: "sql"}, {name: "MariaDB SQL", mime: "text/x-mariadb", mode: "sql"},
{name: "Mathematica", mime: "text/x-mathematica", mode: "mathematica", ext: ["m", "nb"]}, {name: "Mathematica", mime: "text/x-mathematica", mode: "mathematica", ext: ["m", "nb"]},
{name: "Modelica", mime: "text/x-modelica", mode: "modelica", ext: ["mo"]}, {name: "Modelica", mime: "text/x-modelica", mode: "modelica", ext: ["mo"]},
{name: "MUMPS", mime: "text/x-mumps", mode: "mumps", ext: ["mps"]}, {name: "MUMPS", mime: "text/x-mumps", mode: "mumps"},
{name: "MS SQL", mime: "text/x-mssql", mode: "sql"}, {name: "MS SQL", mime: "text/x-mssql", mode: "sql"},
{name: "MySQL", mime: "text/x-mysql", mode: "sql"}, {name: "MySQL", mime: "text/x-mysql", mode: "sql"},
{name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx", file: /nginx.*\.conf$/i}, {name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx", file: /nginx.*\.conf$/i},
@ -11084,6 +11066,7 @@ CodeMirror.defineMIME("text/x-markdown", "markdown");
{name: "SQL", mime: "text/x-sql", mode: "sql", ext: ["sql"]}, {name: "SQL", mime: "text/x-sql", mode: "sql", ext: ["sql"]},
{name: "Squirrel", mime: "text/x-squirrel", mode: "clike", ext: ["nut"]}, {name: "Squirrel", mime: "text/x-squirrel", mode: "clike", ext: ["nut"]},
{name: "Swift", mime: "text/x-swift", mode: "swift", ext: ["swift"]}, {name: "Swift", mime: "text/x-swift", mode: "swift", ext: ["swift"]},
{name: "MariaDB", mime: "text/x-mariadb", mode: "sql"},
{name: "sTeX", mime: "text/x-stex", mode: "stex"}, {name: "sTeX", mime: "text/x-stex", mode: "stex"},
{name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx"], alias: ["tex"]}, {name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx"], alias: ["tex"]},
{name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v"]}, {name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v"]},
@ -11171,56 +11154,54 @@ CodeMirror.defineMIME("text/x-markdown", "markdown");
})(function(CodeMirror) { })(function(CodeMirror) {
"use strict"; "use strict";
var htmlConfig = { CodeMirror.defineMode("xml", function(config, parserConfig) {
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true, var indentUnit = config.indentUnit;
'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true, var multilineTagIndentFactor = parserConfig.multilineTagIndentFactor || 1;
'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true, var multilineTagIndentPastTag = parserConfig.multilineTagIndentPastTag;
'track': true, 'wbr': true, 'menuitem': true}, if (multilineTagIndentPastTag == null) multilineTagIndentPastTag = true;
implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true, var Kludges = parserConfig.htmlMode ? {
'th': true, 'tr': true}, autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
contextGrabbers: { 'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
'dd': {'dd': true, 'dt': true}, 'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
'dt': {'dd': true, 'dt': true}, 'track': true, 'wbr': true, 'menuitem': true},
'li': {'li': true}, implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
'option': {'option': true, 'optgroup': true}, 'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
'optgroup': {'optgroup': true}, 'th': true, 'tr': true},
'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true, contextGrabbers: {
'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true, 'dd': {'dd': true, 'dt': true},
'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true, 'dt': {'dd': true, 'dt': true},
'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true, 'li': {'li': true},
'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true}, 'option': {'option': true, 'optgroup': true},
'rp': {'rp': true, 'rt': true}, 'optgroup': {'optgroup': true},
'rt': {'rp': true, 'rt': true}, 'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
'tbody': {'tbody': true, 'tfoot': true}, 'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
'td': {'td': true, 'th': true}, 'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
'tfoot': {'tbody': true}, 'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
'th': {'td': true, 'th': true}, 'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
'thead': {'tbody': true, 'tfoot': true}, 'rp': {'rp': true, 'rt': true},
'tr': {'tr': true} 'rt': {'rp': true, 'rt': true},
}, 'tbody': {'tbody': true, 'tfoot': true},
doNotIndent: {"pre": true}, 'td': {'td': true, 'th': true},
allowUnquoted: true, 'tfoot': {'tbody': true},
allowMissing: true, 'th': {'td': true, 'th': true},
caseFold: true 'thead': {'tbody': true, 'tfoot': true},
} 'tr': {'tr': true}
},
var xmlConfig = { doNotIndent: {"pre": true},
autoSelfClosers: {}, allowUnquoted: true,
implicitlyClosed: {}, allowMissing: true,
contextGrabbers: {}, caseFold: true
doNotIndent: {}, } : {
allowUnquoted: false, autoSelfClosers: {},
allowMissing: false, implicitlyClosed: {},
caseFold: false contextGrabbers: {},
} doNotIndent: {},
allowUnquoted: false,
CodeMirror.defineMode("xml", function(editorConf, config_) { allowMissing: false,
var indentUnit = editorConf.indentUnit caseFold: false
var config = {} };
var defaults = config_.htmlMode ? htmlConfig : xmlConfig var alignCDATA = parserConfig.alignCDATA;
for (var prop in defaults) config[prop] = defaults[prop]
for (var prop in config_) config[prop] = config_[prop]
// Return variables for tokenizers // Return variables for tokenizers
var type, setStyle; var type, setStyle;
@ -11350,7 +11331,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
this.tagName = tagName; this.tagName = tagName;
this.indent = state.indented; this.indent = state.indented;
this.startOfLine = startOfLine; this.startOfLine = startOfLine;
if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent)) if (Kludges.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
this.noIndent = true; this.noIndent = true;
} }
function popContext(state) { function popContext(state) {
@ -11363,8 +11344,8 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
return; return;
} }
parentTagName = state.context.tagName; parentTagName = state.context.tagName;
if (!config.contextGrabbers.hasOwnProperty(parentTagName) || if (!Kludges.contextGrabbers.hasOwnProperty(parentTagName) ||
!config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) { !Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
return; return;
} }
popContext(state); popContext(state);
@ -11395,9 +11376,9 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
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 &&
config.implicitlyClosed.hasOwnProperty(state.context.tagName)) Kludges.implicitlyClosed.hasOwnProperty(state.context.tagName))
popContext(state); popContext(state);
if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) { if (state.context && state.context.tagName == tagName) {
setStyle = "tag"; setStyle = "tag";
return closeState; return closeState;
} else { } else {
@ -11431,7 +11412,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
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" ||
config.autoSelfClosers.hasOwnProperty(tagName)) { Kludges.autoSelfClosers.hasOwnProperty(tagName)) {
maybePopContext(state, tagName); maybePopContext(state, tagName);
} else { } else {
maybePopContext(state, tagName); maybePopContext(state, tagName);
@ -11444,12 +11425,12 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
} }
function attrEqState(type, stream, state) { function attrEqState(type, stream, state) {
if (type == "equals") return attrValueState; if (type == "equals") return attrValueState;
if (!config.allowMissing) setStyle = "error"; if (!Kludges.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" && config.allowUnquoted) {setStyle = "string"; return attrState;} if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return attrState;}
setStyle = "error"; setStyle = "error";
return attrState(type, stream, state); return attrState(type, stream, state);
} }
@ -11459,14 +11440,12 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
} }
return { return {
startState: function(baseIndent) { startState: function() {
var state = {tokenize: inText, return {tokenize: inText,
state: baseState, state: baseState,
indented: baseIndent || 0, indented: 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) {
@ -11499,19 +11478,19 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
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 (config.multilineTagIndentPastTag !== false) if (multilineTagIndentPastTag)
return state.tagStart + state.tagName.length + 2; return state.tagStart + state.tagName.length + 2;
else else
return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1); return state.tagStart + indentUnit * multilineTagIndentFactor;
} }
if (config.alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0; if (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 (config.implicitlyClosed.hasOwnProperty(context.tagName)) { } else if (Kludges.implicitlyClosed.hasOwnProperty(context.tagName)) {
context = context.prev; context = context.prev;
} else { } else {
break; break;
@ -11519,30 +11498,25 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
} }
} else if (tagAfter) { // Opening tag spotted } else if (tagAfter) { // Opening tag spotted
while (context) { while (context) {
var grabbers = config.contextGrabbers[context.tagName]; var grabbers = Kludges.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.prev && !context.startOfLine) while (context && !context.startOfLine)
context = context.prev; context = context.prev;
if (context) return context.indent + indentUnit; if (context) return context.indent + indentUnit;
else return state.baseIndent || 0; else return 0;
}, },
electricInput: /<\/[\s\w:]+>$/, electricInput: /<\/[\s\w:]+>$/,
blockCommentStart: "<!--", blockCommentStart: "<!--",
blockCommentEnd: "-->", blockCommentEnd: "-->",
configuration: config.htmlMode ? "html" : "xml", configuration: parserConfig.htmlMode ? "html" : "xml",
helperType: config.htmlMode ? "html" : "xml", helperType: parserConfig.htmlMode ? "html" : "xml"
skipAttribute: function(state) {
if (state.state == attrValueState)
state.state = attrState
}
}; };
}); });
@ -14377,6 +14351,13 @@ SimpleMDE.prototype.render = function(el) {
placeholder: options.placeholder || el.getAttribute("placeholder") || "" placeholder: options.placeholder || el.getAttribute("placeholder") || ""
}); });
if(options.forceSync === true) {
var cm = this.codemirror;
cm.on("change", function() {
cm.save();
});
}
this.gui = {}; this.gui = {};
if(options.toolbar !== false) { if(options.toolbar !== false) {
@ -14394,8 +14375,24 @@ SimpleMDE.prototype.render = function(el) {
this._rendered = this.element; this._rendered = this.element;
}; };
// Safari, in Private Browsing Mode, looks like it supports localStorage but all calls to setItem throw QuotaExceededError. We're going to detect this and set a variable accordingly.
function isLocalStorageAvailable() {
if(typeof localStorage === "object") {
try {
localStorage.setItem("smde_localStorage", 1);
localStorage.removeItem("smde_localStorage");
} catch(e) {
return false;
}
} else {
return false;
}
return true;
}
SimpleMDE.prototype.autosave = function() { SimpleMDE.prototype.autosave = function() {
if(localStorage) { if(isLocalStorageAvailable()) {
var simplemde = this; var simplemde = this;
if(this.options.autosave.uniqueId == undefined || this.options.autosave.uniqueId == "") { if(this.options.autosave.uniqueId == undefined || this.options.autosave.uniqueId == "") {
@ -14448,7 +14445,7 @@ SimpleMDE.prototype.autosave = function() {
}; };
SimpleMDE.prototype.clearAutosavedValue = function() { SimpleMDE.prototype.clearAutosavedValue = function() {
if(localStorage) { if(isLocalStorageAvailable()) {
if(this.options.autosave == undefined || this.options.autosave.uniqueId == undefined || this.options.autosave.uniqueId == "") { if(this.options.autosave == undefined || this.options.autosave.uniqueId == undefined || this.options.autosave.uniqueId == "") {
console.log("SimpleMDE: You must set a uniqueId to clear the autosave value"); console.log("SimpleMDE: You must set a uniqueId to clear the autosave value");
return; return;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1516,13 +1516,13 @@ function isLocalStorageAvailable() {
try { try {
localStorage.setItem("smde_localStorage", 1); localStorage.setItem("smde_localStorage", 1);
localStorage.removeItem("smde_localStorage"); localStorage.removeItem("smde_localStorage");
} catch (e) { } catch(e) {
return false; return false;
} }
} else { } else {
return false; return false;
} }
return true; return true;
} }

Loading…
Cancel
Save