Rebuild project

pull/114/head
Wes Cossick 9 years ago
parent a93f7a2570
commit d13b3d51cd

File diff suppressed because one or more lines are too long

@ -1534,6 +1534,10 @@
} }
}, },
readOnlyChanged: function(val) {
if (!val) this.reset();
},
setUneditable: nothing, setUneditable: nothing,
needsContentAttribute: false needsContentAttribute: false
@ -1552,7 +1556,6 @@
init: function(display) { init: function(display) {
var input = this, cm = input.cm; var input = this, cm = input.cm;
var div = input.div = display.lineDiv; var div = input.div = display.lineDiv;
div.contentEditable = "true";
disableBrowserMagic(div); disableBrowserMagic(div);
on(div, "paste", function(e) { handlePaste(e, cm); }) on(div, "paste", function(e) { handlePaste(e, cm); })
@ -1593,7 +1596,7 @@
on(div, "input", function() { on(div, "input", function() {
if (input.composing) return; if (input.composing) return;
if (!input.pollContent()) if (isReadOnly(cm) || !input.pollContent())
runInOp(input.cm, function() {regChange(cm);}); runInOp(input.cm, function() {regChange(cm);});
}); });
@ -1818,17 +1821,24 @@
this.div.focus(); this.div.focus();
}, },
applyComposition: function(composing) { applyComposition: function(composing) {
if (composing.data && composing.data != composing.startData) if (isReadOnly(this.cm))
operation(this.cm, regChange)(this.cm)
else if (composing.data && composing.data != composing.startData)
operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel); operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel);
}, },
setUneditable: function(node) { setUneditable: function(node) {
node.setAttribute("contenteditable", "false"); node.contentEditable = "false"
}, },
onKeyPress: function(e) { onKeyPress: function(e) {
e.preventDefault(); e.preventDefault();
operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0); if (!isReadOnly(this.cm))
operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0);
},
readOnlyChanged: function(val) {
this.div.contentEditable = String(val != "nocursor")
}, },
onContextMenu: nothing, onContextMenu: nothing,
@ -5389,8 +5399,8 @@
cm.display.disabled = true; cm.display.disabled = true;
} else { } else {
cm.display.disabled = false; cm.display.disabled = false;
if (!val) cm.display.input.reset();
} }
cm.display.input.readOnlyChanged(val)
}); });
option("disableInput", false, function(cm, val) {if (!val) cm.display.input.reset();}, true); option("disableInput", false, function(cm, val) {if (!val) cm.display.input.reset();}, true);
option("dragDrop", true, dragDropChanged); option("dragDrop", true, dragDropChanged);
@ -8093,24 +8103,30 @@
} }
}; };
var noHandlers = []
function getHandlers(emitter, type, copy) {
var arr = emitter._handlers && emitter._handlers[type]
if (copy) return arr && arr.length > 0 ? arr.slice() : noHandlers
else return arr || noHandlers
}
var off = CodeMirror.off = function(emitter, type, f) { var off = CodeMirror.off = function(emitter, type, f) {
if (emitter.removeEventListener) if (emitter.removeEventListener)
emitter.removeEventListener(type, f, false); emitter.removeEventListener(type, f, false);
else if (emitter.detachEvent) else if (emitter.detachEvent)
emitter.detachEvent("on" + type, f); emitter.detachEvent("on" + type, f);
else { else {
var arr = emitter._handlers && emitter._handlers[type]; var handlers = getHandlers(emitter, type, false)
if (!arr) return; for (var i = 0; i < handlers.length; ++i)
for (var i = 0; i < arr.length; ++i) if (handlers[i] == f) { handlers.splice(i, 1); break; }
if (arr[i] == f) { arr.splice(i, 1); break; }
} }
}; };
var signal = CodeMirror.signal = function(emitter, type /*, values...*/) { var signal = CodeMirror.signal = function(emitter, type /*, values...*/) {
var arr = emitter._handlers && emitter._handlers[type]; var handlers = getHandlers(emitter, type, true)
if (!arr) return; if (!handlers.length) return;
var args = Array.prototype.slice.call(arguments, 2); var args = Array.prototype.slice.call(arguments, 2);
for (var i = 0; i < arr.length; ++i) arr[i].apply(null, args); for (var i = 0; i < handlers.length; ++i) handlers[i].apply(null, args);
}; };
var orphanDelayedCallbacks = null; var orphanDelayedCallbacks = null;
@ -8123,8 +8139,8 @@
// them to be executed when the last operation ends, or, if no // them to be executed when the last operation ends, or, if no
// operation is active, when a timeout fires. // operation is active, when a timeout fires.
function signalLater(emitter, type /*, values...*/) { function signalLater(emitter, type /*, values...*/) {
var arr = emitter._handlers && emitter._handlers[type]; var arr = getHandlers(emitter, type, false)
if (!arr) return; if (!arr.length) return;
var args = Array.prototype.slice.call(arguments, 2), list; var args = Array.prototype.slice.call(arguments, 2), list;
if (operationGroup) { if (operationGroup) {
list = operationGroup.delayedCallbacks; list = operationGroup.delayedCallbacks;
@ -8164,8 +8180,7 @@
} }
function hasHandler(emitter, type) { function hasHandler(emitter, type) {
var arr = emitter._handlers && emitter._handlers[type]; return getHandlers(emitter, type).length > 0
return arr && arr.length > 0;
} }
// Add on and off methods to a constructor's prototype, to make // Add on and off methods to a constructor's prototype, to make
@ -8819,7 +8834,7 @@
// THE END // THE END
CodeMirror.version = "5.6.1"; CodeMirror.version = "5.7.1";
return CodeMirror; return CodeMirror;
}); });

@ -39,7 +39,7 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) {
// Hack to prevent formatting override inside code blocks (block and inline) // Hack to prevent formatting override inside code blocks (block and inline)
if (state.codeBlock) { if (state.codeBlock) {
if (stream.match(/^```/)) { if (stream.match(/^```+/)) {
state.codeBlock = false; state.codeBlock = false;
return null; return null;
} }
@ -49,7 +49,7 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) {
if (stream.sol()) { if (stream.sol()) {
state.code = false; state.code = false;
} }
if (stream.sol() && stream.match(/^```/)) { if (stream.sol() && stream.match(/^```+/)) {
stream.skipToEnd(); stream.skipToEnd();
state.codeBlock = true; state.codeBlock = true;
return null; return null;
@ -115,7 +115,7 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) {
var markdownConfig = { var markdownConfig = {
underscoresBreakWords: false, underscoresBreakWords: false,
taskLists: true, taskLists: true,
fencedCodeBlocks: true, fencedCodeBlocks: '```',
strikethrough: true strikethrough: true
}; };
for (var attr in modeConfig) { for (var attr in modeConfig) {

@ -39,8 +39,10 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
if (modeCfg.underscoresBreakWords === undefined) if (modeCfg.underscoresBreakWords === undefined)
modeCfg.underscoresBreakWords = true; modeCfg.underscoresBreakWords = true;
// Turn on fenced code blocks? ("```" to start/end) // Use `fencedCodeBlocks` to configure fenced code blocks. false to
if (modeCfg.fencedCodeBlocks === undefined) modeCfg.fencedCodeBlocks = false; // disable, string to specify a precise regexp that the fence should
// match, and true to allow three or more backticks or tildes (as
// per CommonMark).
// Turn on task lists? ("- [ ] " and "- [x] ") // Turn on task lists? ("- [ ] " and "- [x] ")
if (modeCfg.taskLists === undefined) modeCfg.taskLists = false; if (modeCfg.taskLists === undefined) modeCfg.taskLists = false;
@ -74,7 +76,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
, taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE , taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE
, atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/ , atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/
, setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/ , setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/
, textRE = /^[^#!\[\]*_\\<>` "'(~]+/; , textRE = /^[^#!\[\]*_\\<>` "'(~]+/
, fencedCodeRE = new RegExp("^(" + (modeCfg.fencedCodeBlocks === true ? "~~~+|```+" : modeCfg.fencedCodeBlocks) +
")[ \\t]*([\\w+#]*)");
function switchInline(stream, state, f) { function switchInline(stream, state, f) {
state.f = state.inline = f; state.f = state.inline = f;
@ -86,6 +90,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
return f(stream, state); return f(stream, state);
} }
function lineIsEmpty(line) {
return !line || !/\S/.test(line.string)
}
// Blocks // Blocks
@ -110,7 +117,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
state.trailingSpace = 0; state.trailingSpace = 0;
state.trailingSpaceNewLine = false; state.trailingSpaceNewLine = false;
// Mark this line as blank // Mark this line as blank
state.thisLineHasContent = false; state.prevLine = state.thisLine
state.thisLine = null
return null; return null;
} }
@ -141,7 +149,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
var match = null; var match = null;
if (state.indentationDiff >= 4) { if (state.indentationDiff >= 4) {
stream.skipToEnd(); stream.skipToEnd();
if (prevLineIsIndentedCode || !state.prevLineHasContent) { if (prevLineIsIndentedCode || lineIsEmpty(state.prevLine)) {
state.indentation -= 4; state.indentation -= 4;
state.indentedCode = true; state.indentedCode = true;
return code; return code;
@ -155,7 +163,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
if (modeCfg.highlightFormatting) state.formatting = "header"; if (modeCfg.highlightFormatting) state.formatting = "header";
state.f = state.inline; state.f = state.inline;
return getType(state); return getType(state);
} else if (state.prevLineHasContent && !state.quote && !prevLineIsList && !prevLineIsIndentedCode && (match = stream.match(setextHeaderRE))) { } else if (!lineIsEmpty(state.prevLine) && !state.quote && !prevLineIsList &&
!prevLineIsIndentedCode && (match = stream.match(setextHeaderRE))) {
state.header = match[0].charAt(0) == '=' ? 1 : 2; state.header = match[0].charAt(0) == '=' ? 1 : 2;
if (modeCfg.highlightFormatting) state.formatting = "header"; if (modeCfg.highlightFormatting) state.formatting = "header";
state.f = state.inline; state.f = state.inline;
@ -170,7 +179,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
} else if (stream.match(hrRE, true)) { } else if (stream.match(hrRE, true)) {
state.hr = true; state.hr = true;
return hr; return hr;
} else if ((!state.prevLineHasContent || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) { } else if ((lineIsEmpty(state.prevLine) || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) {
var listType = null; var listType = null;
if (stream.match(ulRE, true)) { if (stream.match(ulRE, true)) {
listType = 'ul'; listType = 'ul';
@ -187,9 +196,10 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
state.f = state.inline; state.f = state.inline;
if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType]; if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType];
return getType(state); return getType(state);
} else if (modeCfg.fencedCodeBlocks && stream.match(/^```[ \t]*([\w+#]*)/, true)) { } else if (modeCfg.fencedCodeBlocks && (match = stream.match(fencedCodeRE, true))) {
state.fencedChars = match[1]
// try switching mode // try switching mode
state.localMode = getMode(RegExp.$1); state.localMode = getMode(match[2]);
if (state.localMode) state.localState = state.localMode.startState(); if (state.localMode) state.localState = state.localMode.startState();
state.f = state.block = local; state.f = state.block = local;
if (modeCfg.highlightFormatting) state.formatting = "code-block"; if (modeCfg.highlightFormatting) state.formatting = "code-block";
@ -213,7 +223,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
} }
function local(stream, state) { function local(stream, state) {
if (stream.sol() && stream.match("```", false)) { if (stream.sol() && state.fencedChars && stream.match(state.fencedChars, false)) {
state.localMode = state.localState = null; state.localMode = state.localState = null;
state.f = state.block = leavingLocal; state.f = state.block = leavingLocal;
return null; return null;
@ -226,9 +236,10 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
} }
function leavingLocal(stream, state) { function leavingLocal(stream, state) {
stream.match("```"); stream.match(state.fencedChars);
state.block = blockNormal; state.block = blockNormal;
state.f = inlineNormal; state.f = inlineNormal;
state.fencedChars = null;
if (modeCfg.highlightFormatting) state.formatting = "code-block"; if (modeCfg.highlightFormatting) state.formatting = "code-block";
state.code = true; state.code = true;
var returnType = getType(state); var returnType = getType(state);
@ -656,8 +667,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
return { return {
f: blockNormal, f: blockNormal,
prevLineHasContent: false, prevLine: null,
thisLineHasContent: false, thisLine: null,
block: blockNormal, block: blockNormal,
htmlState: null, htmlState: null,
@ -680,7 +691,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
quote: 0, quote: 0,
trailingSpace: 0, trailingSpace: 0,
trailingSpaceNewLine: false, trailingSpaceNewLine: false,
strikethrough: false strikethrough: false,
fencedChars: null
}; };
}, },
@ -688,8 +700,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
return { return {
f: s.f, f: s.f,
prevLineHasContent: s.prevLineHasContent, prevLine: s.prevLine,
thisLineHasContent: s.thisLineHasContent, thisLine: s.this,
block: s.block, block: s.block,
htmlState: s.htmlState && CodeMirror.copyState(htmlMode, s.htmlState), htmlState: s.htmlState && CodeMirror.copyState(htmlMode, s.htmlState),
@ -715,7 +727,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
indentedCode: s.indentedCode, indentedCode: s.indentedCode,
trailingSpace: s.trailingSpace, trailingSpace: s.trailingSpace,
trailingSpaceNewLine: s.trailingSpaceNewLine, trailingSpaceNewLine: s.trailingSpaceNewLine,
md_inside: s.md_inside md_inside: s.md_inside,
fencedChars: s.fencedChars
}; };
}, },
@ -724,22 +737,22 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
// Reset state.formatting // Reset state.formatting
state.formatting = false; state.formatting = false;
if (stream.sol()) { if (stream != state.thisLine) {
var forceBlankLine = !!state.header || state.hr; var forceBlankLine = state.header || state.hr;
// Reset state.header and state.hr // Reset state.header and state.hr
state.header = 0; state.header = 0;
state.hr = false; state.hr = false;
if (stream.match(/^\s*$/, true) || forceBlankLine) { if (stream.match(/^\s*$/, true) || forceBlankLine) {
state.prevLineHasContent = false;
blankLine(state); blankLine(state);
return forceBlankLine ? this.token(stream, state) : null; if (!forceBlankLine) return null
} else { state.prevLine = null
state.prevLineHasContent = state.thisLineHasContent;
state.thisLineHasContent = true;
} }
state.prevLine = state.thisLine
state.thisLine = stream
// Reset state.taskList // Reset state.taskList
state.taskList = false; state.taskList = false;

@ -739,28 +739,28 @@ function SimpleMDE(options) {
// Used later to refer to it's parent // Used later to refer to it's parent
options.parent = this; options.parent = this;
// Check if Font Awesome needs to be auto downloaded // Check if Font Awesome needs to be auto downloaded
var autoDownloadFA = true; var autoDownloadFA = true;
if(options.autoDownloadFontAwesome === false){ if(options.autoDownloadFontAwesome === false) {
autoDownloadFA = false; autoDownloadFA = false;
} }
if(options.autoDownloadFontAwesome !== true){ if(options.autoDownloadFontAwesome !== true) {
var styleSheets = document.styleSheets; var styleSheets = document.styleSheets;
for(var i = 0; i < styleSheets.length; i++) { for(var i = 0; i < styleSheets.length; i++) {
if(!styleSheets[i].href) if(!styleSheets[i].href)
continue; continue;
if(styleSheets[i].href.indexOf("//maxcdn.bootstrapcdn.com/font-awesome/") > -1){ if(styleSheets[i].href.indexOf("//maxcdn.bootstrapcdn.com/font-awesome/") > -1) {
autoDownloadFA = false; autoDownloadFA = false;
} }
} }
} }
if(autoDownloadFA){ if(autoDownloadFA) {
var link = document.createElement("link"); var link = document.createElement("link");
link.rel = "stylesheet"; link.rel = "stylesheet";
link.href = "https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css"; link.href = "https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css";
@ -899,7 +899,8 @@ SimpleMDE.prototype.render = function(el) {
lineNumbers: false, lineNumbers: false,
autofocus: (options.autofocus === true) ? true : false, autofocus: (options.autofocus === true) ? true : false,
extraKeys: keyMaps, extraKeys: keyMaps,
lineWrapping: (options.lineWrapping === false) ? false : true lineWrapping: (options.lineWrapping === false) ? false : true,
allowDroppedFileTypes: ["text/plain"]
}); });
if(options.toolbar !== false) { if(options.toolbar !== false) {
@ -1033,7 +1034,7 @@ SimpleMDE.prototype.createToolbar = function(items) {
for(var i = 0; i < items.length; i++) { for(var i = 0; i < items.length; i++) {
if(items[i].name == "guide" && self.options.toolbarGuideIcon === false) if(items[i].name == "guide" && self.options.toolbarGuideIcon === false)
continue; continue;
if(self.options.hideIcons.indexOf(items[i].name) != -1) if(self.options.hideIcons.indexOf(items[i].name) != -1)
continue; continue;

Loading…
Cancel
Save