Skip to content

Commit

Permalink
upgraded to CodeMirror 5.37.0
Browse files Browse the repository at this point in the history
  • Loading branch information
w8tcha committed Apr 22, 2018
1 parent af4b9f1 commit 714b5e6
Show file tree
Hide file tree
Showing 15 changed files with 134 additions and 20 deletions.
8 changes: 5 additions & 3 deletions codemirror/js/addon/fold/xml-fold.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,14 @@
CodeMirror.registerHelper("fold", "xml", function(cm, start) {
var iter = new Iter(cm, start.line, 0);
for (;;) {
var openTag = toNextTag(iter), end;
if (!openTag || !(end = toTagEnd(iter)) || iter.line != start.line) return;
var openTag = toNextTag(iter)
if (!openTag || iter.line != start.line) return
var end = toTagEnd(iter)
if (!end) return
if (!openTag[1] && end != "selfClose") {
var startPos = Pos(iter.line, iter.ch);
var endPos = findMatchingClose(iter, openTag[2]);
return endPos && {from: startPos, to: endPos.from};
return endPos && cmp(endPos.from, startPos) > 0 ? {from: startPos, to: endPos.from} : null
}
}
});
Expand Down
19 changes: 16 additions & 3 deletions codemirror/js/addon/hint/sql-hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,23 @@
if (search.charAt(0) == "." || search.charAt(0) == identifierQuote) {
start = nameCompletion(cur, token, result, editor);
} else {
addMatches(result, search, defaultTable, function(w) {return w;});
addMatches(result, search, tables, function(w) {return w;});
addMatches(result, search, defaultTable, function(w) {return {text:w, className: "CodeMirror-hint-table CodeMirror-hint-default-table"};});
addMatches(
result,
search,
tables,
function(w) {
if (typeof w === 'object') {
w.className = "CodeMirror-hint-table";
} else {
w = {text: w, className: "CodeMirror-hint-table"};
}

return w;
}
);
if (!disableKeywords)
addMatches(result, search, keywords, function(w) {return w.toUpperCase();});
addMatches(result, search, keywords, function(w) {return {text: w.toUpperCase(), className: "CodeMirror-hint-keyword"};});
}

return {list: result, from: Pos(cur.line, start), to: Pos(cur.line, end)};
Expand Down
2 changes: 1 addition & 1 deletion codemirror/js/codemirror.addons.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions codemirror/js/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -9005,7 +9005,7 @@ ContentEditableInput.prototype.setUneditable = function (node) {
};

ContentEditableInput.prototype.onKeyPress = function (e) {
if (e.charCode == 0) { return }
if (e.charCode == 0 || this.composing) { return }
e.preventDefault()
if (!this.cm.isReadOnly())
{ operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0) }
Expand Down Expand Up @@ -9658,7 +9658,7 @@ CodeMirror.fromTextArea = fromTextArea

addLegacyProps(CodeMirror)

CodeMirror.version = "5.36.0"
CodeMirror.version = "5.37.0"

return CodeMirror;

Expand Down
2 changes: 1 addition & 1 deletion codemirror/js/codemirror.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion codemirror/js/codemirror.mode.bbcodemixed.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion codemirror/js/codemirror.mode.htmlmixed.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion codemirror/js/codemirror.mode.javascript.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions codemirror/js/codemirror.mode.php.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions codemirror/js/mode/clike/clike.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,10 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
defKeywords: words("class val var object interface fun"),
atoms: words("true false null this"),
hooks: {
"@": function(stream) {
stream.eatWhile(/[\w\$_]/);
return "meta";
},
'"': function(stream, state) {
state.tokenize = tokenKotlinString(stream.match('""'));
return state.tokenize(stream, state);
Expand Down
15 changes: 10 additions & 5 deletions codemirror/js/mode/javascript/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
var kw = keywords[word]
return ret(kw.type, kw.style, word)
}
if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\(\w]/, false))
if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false))
return ret("async", "keyword", word)
}
return ret("variable", "variable", word)
Expand Down Expand Up @@ -356,6 +356,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
} else if (isTS && value == "namespace") {
cx.marked = "keyword"
return cont(pushlex("form"), expression, block, poplex)
} else if (isTS && value == "abstract") {
cx.marked = "keyword"
return cont(statement)
} else {
return cont(pushlex("stat"), maybelabel);
}
Expand Down Expand Up @@ -562,7 +565,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
function typeexpr(type, value) {
if (value == "keyof" || value == "typeof") {
cx.marked = "keyword"
return cont(value == "keyof" ? typeexpr : expression)
return cont(value == "keyof" ? typeexpr : expressionNoComma)
}
if (type == "variable" || value == "void") {
cx.marked = "type"
Expand All @@ -572,6 +575,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType)
if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType)
if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType)
if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr)
}
function maybeReturnType(type) {
if (type == "=>") return cont(typeexpr)
Expand All @@ -588,9 +592,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
return cont(expression, maybetype, expect("]"), typeprop)
}
}
function typearg(type) {
if (type == "variable") return cont(typearg)
else if (type == ":") return cont(typeexpr)
function typearg(type, value) {
if (type == "variable" && cx.stream.match(/^\s*[?:]/, false) || value == "?") return cont(typearg)
if (type == ":") return cont(typeexpr)
return pass(typeexpr)
}
function afterType(type, value) {
if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
Expand Down
9 changes: 9 additions & 0 deletions codemirror/js/mode/javascript/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,15 @@
" [def META],",
"}")

TS("parenthesized type",
"[keyword class] [def Foo] {",
" [property x] [operator =] [keyword new] [variable A][operator <][type B], [type string][operator |](() [operator =>] [type void])[operator >]();",
" [keyword private] [property bar]();",
"}")

TS("abstract class",
"[keyword export] [keyword abstract] [keyword class] [def Foo] {}")

var jsonld_mode = CodeMirror.getMode(
{indentUnit: 2},
{name: "javascript", jsonld: true}
Expand Down
34 changes: 34 additions & 0 deletions codemirror/theme/gruvbox-dark.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
Name: gruvbox-dark
Author: kRkk (https://github.com/krkk)
Original gruvbox color scheme by Pavel Pertsev (https://github.com/morhetz/gruvbox)
*/

.cm-s-gruvbox-dark.CodeMirror, .cm-s-gruvbox-dark .CodeMirror-gutters { background-color: #282828; color: #bdae93; }
.cm-s-gruvbox-dark .CodeMirror-gutters {background: #282828; border-right: 0px;}
.cm-s-gruvbox-dark .CodeMirror-linenumber {color: #7c6f64;}
.cm-s-gruvbox-dark .CodeMirror-cursor { border-left: 1px solid #ebdbb2; }
.cm-s-gruvbox-dark div.CodeMirror-selected { background: #928374; }
.cm-s-gruvbox-dark span.cm-meta { color: #808000; }

.cm-s-gruvbox-dark span.cm-comment { color: #928374; }
.cm-s-gruvbox-dark span.cm-number, span.cm-atom { color: #d3869b; }
.cm-s-gruvbox-dark span.cm-keyword { color: #f84934; }

.cm-s-gruvbox-dark span.cm-variable { color: #ebdbb2; }
.cm-s-gruvbox-dark span.cm-variable-2 { color: #ebdbb2; }
.cm-s-gruvbox-dark span.cm-variable-3, .cm-s-gruvbox-dark span.cm-type { color: black; }
.cm-s-gruvbox-dark span.cm-operator { color: #ebdbb2; }
.cm-s-gruvbox-dark span.cm-def { color: #ebdbb2; }
.cm-s-gruvbox-dark span.cm-string { color: #b8bb26; }
.cm-s-gruvbox-dark span.cm-string-2 { color: #8ec07c; }
.cm-s-gruvbox-dark span.cm-qualifier { color: #555; }
.cm-s-gruvbox-dark span.cm-attribute { color: #8ec07c; }

.cm-s-gruvbox-dark .CodeMirror-activeline-background { background: #3c3836; }
.cm-s-gruvbox-dark .CodeMirror-matchingbracket { background: #928374; color:#282828 !important; }

.cm-s-gruvbox-dark span.cm-builtin { color: #fe8019; }
31 changes: 31 additions & 0 deletions codemirror/theme/idea.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
Name: IDEA default theme
From IntelliJ IDEA by JetBrains
*/

.cm-s-idea span.cm-meta { color: #808000; }
.cm-s-idea span.cm-number { color: #0000FF; }
.cm-s-idea span.cm-keyword { line-height: 1em; font-weight: bold; color: #000080; }
.cm-s-idea span.cm-atom { font-weight: bold; color: #000080; }
.cm-s-idea span.cm-def { color: #000000; }
.cm-s-idea span.cm-variable { color: black; }
.cm-s-idea span.cm-variable-2 { color: black; }
.cm-s-idea span.cm-variable-3, .cm-s-idea span.cm-type { color: black; }
.cm-s-idea span.cm-property { color: black; }
.cm-s-idea span.cm-operator { color: black; }
.cm-s-idea span.cm-comment { color: #808080; }
.cm-s-idea span.cm-string { color: #008000; }
.cm-s-idea span.cm-string-2 { color: #008000; }
.cm-s-idea span.cm-qualifier { color: #555; }
.cm-s-idea span.cm-error { color: #FF0000; }
.cm-s-idea span.cm-attribute { color: #0000FF; }
.cm-s-idea span.cm-tag { color: #000080; }
.cm-s-idea span.cm-link { color: #0000FF; }
.cm-s-idea .CodeMirror-activeline-background { background: #FFFAE3; }

.cm-s-idea span.cm-builtin { color: #30a; }
.cm-s-idea span.cm-bracket { color: #cc7; }
.cm-s-idea { font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;}


.cm-s-idea .CodeMirror-matchingbracket { outline:1px solid grey; color:black !important; }
16 changes: 16 additions & 0 deletions codemirror/theme/ssms.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.cm-s-ssms span.cm-keyword { color: blue; }
.cm-s-ssms span.cm-comment { color: darkgreen; }
.cm-s-ssms span.cm-string { color: red; }
.cm-s-ssms span.cm-def { color: black; }
.cm-s-ssms span.cm-variable { color: black; }
.cm-s-ssms span.cm-variable-2 { color: black; }
.cm-s-ssms span.cm-atom { color: darkgray; }
.cm-s-ssms .CodeMirror-linenumber { color: teal; }
.cm-s-ssms .CodeMirror-activeline-background { background: #ffffff; }
.cm-s-ssms span.cm-string-2 { color: #FF00FF; }
.cm-s-ssms span.cm-operator,
.cm-s-ssms span.cm-bracket,
.cm-s-ssms span.cm-punctuation { color: darkgray; }
.cm-s-ssms .CodeMirror-gutters { border-right: 3px solid #ffee62; background-color: #ffffff; }
.cm-s-ssms div.CodeMirror-selected { background: #ADD6FF; }

0 comments on commit 714b5e6

Please sign in to comment.