Update CodeMirror to version 5.49.0 (#8381)
* Update CodeMirror to version 5.49.0 * Update CodeMirror versions in librejs and VERSIONS
This commit is contained in:
parent
6fa14ac3c8
commit
1e9b330525
352 changed files with 14625 additions and 2451 deletions
|
@ -1,17 +1,23 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
mod(require("../../lib/codemirror"), require("../css/css"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
define(["../../lib/codemirror", "../css/css"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("sass", function(config) {
|
||||
var cssMode = CodeMirror.mimeModes["text/css"];
|
||||
var propertyKeywords = cssMode.propertyKeywords || {},
|
||||
colorKeywords = cssMode.colorKeywords || {},
|
||||
valueKeywords = cssMode.valueKeywords || {},
|
||||
fontProperties = cssMode.fontProperties || {};
|
||||
|
||||
function tokenRegexp(words) {
|
||||
return new RegExp("^" + words.join("|"));
|
||||
}
|
||||
|
@ -25,6 +31,12 @@ CodeMirror.defineMode("sass", function(config) {
|
|||
|
||||
var pseudoElementsRegexp = /^::?[a-zA-Z_][\w\-]*/;
|
||||
|
||||
var word;
|
||||
|
||||
function isEndLine(stream) {
|
||||
return !stream.peek() || stream.match(/\s+$/, false);
|
||||
}
|
||||
|
||||
function urlTokens(stream, state) {
|
||||
var ch = stream.peek();
|
||||
|
||||
|
@ -76,6 +88,9 @@ CodeMirror.defineMode("sass", function(config) {
|
|||
|
||||
if (endingString) {
|
||||
if (nextChar !== quote && greedy) { stream.next(); }
|
||||
if (isEndLine(stream)) {
|
||||
state.cursorHalf = 0;
|
||||
}
|
||||
state.tokenizer = tokenBase;
|
||||
return "string";
|
||||
} else if (nextChar === "#" && peekChar === "{") {
|
||||
|
@ -147,14 +162,20 @@ CodeMirror.defineMode("sass", function(config) {
|
|||
// first half i.e. before : for key-value pairs
|
||||
// including selectors
|
||||
|
||||
if (ch === "-") {
|
||||
if (stream.match(/^-\w+-/)) {
|
||||
return "meta";
|
||||
}
|
||||
}
|
||||
|
||||
if (ch === ".") {
|
||||
stream.next();
|
||||
if (stream.match(/^[\w-]+/)) {
|
||||
indent(state);
|
||||
return "atom";
|
||||
return "qualifier";
|
||||
} else if (stream.peek() === "#") {
|
||||
indent(state);
|
||||
return "atom";
|
||||
return "tag";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,11 +184,11 @@ CodeMirror.defineMode("sass", function(config) {
|
|||
// ID selectors
|
||||
if (stream.match(/^[\w-]+/)) {
|
||||
indent(state);
|
||||
return "atom";
|
||||
return "builtin";
|
||||
}
|
||||
if (stream.peek() === "#") {
|
||||
indent(state);
|
||||
return "atom";
|
||||
return "tag";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,37 +241,48 @@ CodeMirror.defineMode("sass", function(config) {
|
|||
// Indent Directives
|
||||
if (stream.match(/^@(else if|if|media|else|for|each|while|mixin|function)/)) {
|
||||
indent(state);
|
||||
return "meta";
|
||||
return "def";
|
||||
}
|
||||
|
||||
// Other Directives
|
||||
if (ch === "@") {
|
||||
stream.next();
|
||||
stream.eatWhile(/[\w-]/);
|
||||
return "meta";
|
||||
return "def";
|
||||
}
|
||||
|
||||
if (stream.eatWhile(/[\w-]/)){
|
||||
if(stream.match(/ *: *[\w-\+\$#!\("']/,false)){
|
||||
return "property";
|
||||
word = stream.current().toLowerCase();
|
||||
var prop = state.prevProp + "-" + word;
|
||||
if (propertyKeywords.hasOwnProperty(prop)) {
|
||||
return "property";
|
||||
} else if (propertyKeywords.hasOwnProperty(word)) {
|
||||
state.prevProp = word;
|
||||
return "property";
|
||||
} else if (fontProperties.hasOwnProperty(word)) {
|
||||
return "property";
|
||||
}
|
||||
return "tag";
|
||||
}
|
||||
else if(stream.match(/ *:/,false)){
|
||||
indent(state);
|
||||
state.cursorHalf = 1;
|
||||
return "atom";
|
||||
state.prevProp = stream.current().toLowerCase();
|
||||
return "property";
|
||||
}
|
||||
else if(stream.match(/ *,/,false)){
|
||||
return "atom";
|
||||
return "tag";
|
||||
}
|
||||
else{
|
||||
indent(state);
|
||||
return "atom";
|
||||
return "tag";
|
||||
}
|
||||
}
|
||||
|
||||
if(ch === ":"){
|
||||
if (stream.match(pseudoElementsRegexp)){ // could be a pseudo-element
|
||||
return "keyword";
|
||||
return "variable-3";
|
||||
}
|
||||
stream.next();
|
||||
state.cursorHalf=1;
|
||||
|
@ -264,7 +296,7 @@ CodeMirror.defineMode("sass", function(config) {
|
|||
stream.next();
|
||||
// Hex numbers
|
||||
if (stream.match(/[0-9a-fA-F]{6}|[0-9a-fA-F]{3}/)){
|
||||
if(!stream.peek()){
|
||||
if (isEndLine(stream)) {
|
||||
state.cursorHalf = 0;
|
||||
}
|
||||
return "number";
|
||||
|
@ -273,7 +305,7 @@ CodeMirror.defineMode("sass", function(config) {
|
|||
|
||||
// Numbers
|
||||
if (stream.match(/^-?[0-9\.]+/)){
|
||||
if(!stream.peek()){
|
||||
if (isEndLine(stream)) {
|
||||
state.cursorHalf = 0;
|
||||
}
|
||||
return "number";
|
||||
|
@ -281,14 +313,14 @@ CodeMirror.defineMode("sass", function(config) {
|
|||
|
||||
// Units
|
||||
if (stream.match(/^(px|em|in)\b/)){
|
||||
if(!stream.peek()){
|
||||
if (isEndLine(stream)) {
|
||||
state.cursorHalf = 0;
|
||||
}
|
||||
return "unit";
|
||||
}
|
||||
|
||||
if (stream.match(keywordsRegexp)){
|
||||
if(!stream.peek()){
|
||||
if (isEndLine(stream)) {
|
||||
state.cursorHalf = 0;
|
||||
}
|
||||
return "keyword";
|
||||
|
@ -296,7 +328,7 @@ CodeMirror.defineMode("sass", function(config) {
|
|||
|
||||
if (stream.match(/^url/) && stream.peek() === "(") {
|
||||
state.tokenizer = urlTokens;
|
||||
if(!stream.peek()){
|
||||
if (isEndLine(stream)) {
|
||||
state.cursorHalf = 0;
|
||||
}
|
||||
return "atom";
|
||||
|
@ -306,23 +338,21 @@ CodeMirror.defineMode("sass", function(config) {
|
|||
if (ch === "$") {
|
||||
stream.next();
|
||||
stream.eatWhile(/[\w-]/);
|
||||
if(!stream.peek()){
|
||||
if (isEndLine(stream)) {
|
||||
state.cursorHalf = 0;
|
||||
}
|
||||
return "variable-3";
|
||||
return "variable-2";
|
||||
}
|
||||
|
||||
// bang character for !important, !default, etc.
|
||||
if (ch === "!") {
|
||||
stream.next();
|
||||
if(!stream.peek()){
|
||||
state.cursorHalf = 0;
|
||||
}
|
||||
state.cursorHalf = 0;
|
||||
return stream.match(/^[\w]+/) ? "keyword": "operator";
|
||||
}
|
||||
|
||||
if (stream.match(opRegexp)){
|
||||
if(!stream.peek()){
|
||||
if (isEndLine(stream)) {
|
||||
state.cursorHalf = 0;
|
||||
}
|
||||
return "operator";
|
||||
|
@ -330,14 +360,24 @@ CodeMirror.defineMode("sass", function(config) {
|
|||
|
||||
// attributes
|
||||
if (stream.eatWhile(/[\w-]/)) {
|
||||
if(!stream.peek()){
|
||||
if (isEndLine(stream)) {
|
||||
state.cursorHalf = 0;
|
||||
}
|
||||
return "attribute";
|
||||
word = stream.current().toLowerCase();
|
||||
if (valueKeywords.hasOwnProperty(word)) {
|
||||
return "atom";
|
||||
} else if (colorKeywords.hasOwnProperty(word)) {
|
||||
return "keyword";
|
||||
} else if (propertyKeywords.hasOwnProperty(word)) {
|
||||
state.prevProp = stream.current().toLowerCase();
|
||||
return "property";
|
||||
} else {
|
||||
return "tag";
|
||||
}
|
||||
}
|
||||
|
||||
//stream.eatSpace();
|
||||
if(!stream.peek()){
|
||||
if (isEndLine(stream)) {
|
||||
state.cursorHalf = 0;
|
||||
return null;
|
||||
}
|
||||
|
@ -407,7 +447,7 @@ CodeMirror.defineMode("sass", function(config) {
|
|||
return state.scopes[0].offset;
|
||||
}
|
||||
};
|
||||
});
|
||||
}, "css");
|
||||
|
||||
CodeMirror.defineMIME("text/x-sass", "sass");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue