mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Upgrading CodeMirror
issue #422 - upgraded CodeMirror to the latest version
This commit is contained in:
parent
f78ea7356f
commit
c11e30a17c
4 changed files with 689 additions and 425 deletions
1052
core/client/assets/vendor/codemirror/codemirror.js
vendored
1052
core/client/assets/vendor/codemirror/codemirror.js
vendored
File diff suppressed because it is too large
Load diff
|
@ -8,7 +8,12 @@
|
|||
<script src="../../addon/edit/continuelist.js"></script>
|
||||
<script src="../xml/xml.js"></script>
|
||||
<script src="markdown.js"></script>
|
||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
<style type="text/css">
|
||||
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
|
||||
.cm-s-default .cm-trailing-space-a:before,
|
||||
.cm-s-default .cm-trailing-space-b:before {position: absolute; content: "\00B7"; color: #777;}
|
||||
.cm-s-default .cm-trailing-space-new-line:before {position: absolute; content: "\21B5"; color: #777;}
|
||||
</style>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
||||
|
||||
var htmlFound = CodeMirror.mimeModes.hasOwnProperty("text/html");
|
||||
var htmlMode = CodeMirror.getMode(cmCfg, htmlFound ? "text/html" : "text/plain");
|
||||
var htmlFound = CodeMirror.modes.hasOwnProperty("xml");
|
||||
var htmlMode = CodeMirror.getMode(cmCfg, htmlFound ? {name: "xml", htmlMode: true} : "text/plain");
|
||||
var aliases = {
|
||||
html: "htmlmixed",
|
||||
js: "javascript",
|
||||
|
@ -103,6 +103,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
state.f = inlineNormal;
|
||||
state.block = blockNormal;
|
||||
}
|
||||
// Reset state.trailingSpace
|
||||
state.trailingSpace = 0;
|
||||
state.trailingSpaceNewLine = false;
|
||||
// Mark this line as blank
|
||||
state.thisLineHasContent = false;
|
||||
return null;
|
||||
|
@ -217,6 +220,12 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
}
|
||||
}
|
||||
|
||||
if (state.trailingSpaceNewLine) {
|
||||
styles.push("trailing-space-new-line");
|
||||
} else if (state.trailingSpace) {
|
||||
styles.push("trailing-space-" + (state.trailingSpace % 2 ? "a" : "b"));
|
||||
}
|
||||
|
||||
return styles.length ? styles.join(' ') : null;
|
||||
}
|
||||
|
||||
|
@ -308,11 +317,11 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
return type;
|
||||
}
|
||||
|
||||
if (ch === '<' && stream.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/, true)) {
|
||||
if (ch === '<' && stream.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/, false)) {
|
||||
return switchInline(stream, state, inlineElement(linkinline, '>'));
|
||||
}
|
||||
|
||||
if (ch === '<' && stream.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/, true)) {
|
||||
if (ch === '<' && stream.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/, false)) {
|
||||
return switchInline(stream, state, inlineElement(linkemail, '>'));
|
||||
}
|
||||
|
||||
|
@ -369,6 +378,14 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
}
|
||||
}
|
||||
|
||||
if (ch === ' ') {
|
||||
if (stream.match(/ +$/, false)) {
|
||||
state.trailingSpace++;
|
||||
} else if (state.trailingSpace) {
|
||||
state.trailingSpaceNewLine = true;
|
||||
}
|
||||
}
|
||||
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
|
@ -453,7 +470,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
taskList: false,
|
||||
list: false,
|
||||
listDepth: 0,
|
||||
quote: 0
|
||||
quote: 0,
|
||||
trailingSpace: 0,
|
||||
trailingSpaceNewLine: false
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -481,6 +500,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
list: s.list,
|
||||
listDepth: s.listDepth,
|
||||
quote: s.quote,
|
||||
trailingSpace: s.trailingSpace,
|
||||
trailingSpaceNewLine: s.trailingSpaceNewLine,
|
||||
md_inside: s.md_inside
|
||||
};
|
||||
},
|
||||
|
@ -504,6 +525,10 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
// Reset state.code
|
||||
state.code = false;
|
||||
|
||||
// Reset state.trailingSpace
|
||||
state.trailingSpace = 0;
|
||||
state.trailingSpaceNewLine = false;
|
||||
|
||||
state.f = state.block;
|
||||
var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, ' ').length;
|
||||
var difference = Math.floor((indentation - state.indentation) / 4) * 4;
|
||||
|
|
|
@ -5,6 +5,20 @@
|
|||
MT("plainText",
|
||||
"foo");
|
||||
|
||||
// Don't style single trailing space
|
||||
MT("trailingSpace1",
|
||||
"foo ");
|
||||
|
||||
// Two or more trailing spaces should be styled with line break character
|
||||
MT("trailingSpace2",
|
||||
"foo[trailing-space-a ][trailing-space-new-line ]");
|
||||
|
||||
MT("trailingSpace3",
|
||||
"foo[trailing-space-a ][trailing-space-b ][trailing-space-new-line ]");
|
||||
|
||||
MT("trailingSpace4",
|
||||
"foo[trailing-space-a ][trailing-space-b ][trailing-space-a ][trailing-space-new-line ]");
|
||||
|
||||
// Code blocks using 4 spaces (regardless of CodeMirror.tabSize value)
|
||||
MT("codeBlocksUsing4Spaces",
|
||||
" [comment foo]");
|
||||
|
@ -533,9 +547,15 @@
|
|||
MT("linkWeb",
|
||||
"[link <http://example.com/>] foo");
|
||||
|
||||
MT("linkWebDouble",
|
||||
"[link <http://example.com/>] foo [link <http://example.com/>]");
|
||||
|
||||
MT("linkEmail",
|
||||
"[link <user@example.com>] foo");
|
||||
|
||||
MT("linkEmailDouble",
|
||||
"[link <user@example.com>] foo [link <user@example.com>]");
|
||||
|
||||
MT("emAsterisk",
|
||||
"[em *foo*] bar");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue