mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
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:
committed by
Lauris BH
parent
6fa14ac3c8
commit
1e9b330525
@@ -7,10 +7,11 @@
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="../css/css.js"></script>
|
||||
<script src="sass.js"></script>
|
||||
<style>.CodeMirror {border: 1px solid #ddd; font-size:12px; height: 400px}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
@@ -58,7 +59,8 @@ body
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers : true,
|
||||
matchBrackets : true
|
||||
matchBrackets : true,
|
||||
mode: "sass"
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@@ -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");
|
||||
|
||||
|
122
public/vendor/plugins/codemirror/mode/sass/test.js
vendored
Normal file
122
public/vendor/plugins/codemirror/mode/sass/test.js
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function() {
|
||||
var mode = CodeMirror.getMode({indentUnit: 2}, "sass");
|
||||
// Since Sass has an indent-based syntax, is almost impossible to test correctly the indentation in all cases.
|
||||
// So disable it for tests.
|
||||
mode.indent = undefined;
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
MT("comment",
|
||||
"[comment // this is a comment]",
|
||||
"[comment also this is a comment]")
|
||||
|
||||
MT("comment_multiline",
|
||||
"[comment /* this is a comment]",
|
||||
"[comment also this is a comment]")
|
||||
|
||||
MT("variable",
|
||||
"[variable-2 $page-width][operator :] [number 800][unit px]")
|
||||
|
||||
MT("global_attributes",
|
||||
"[tag body]",
|
||||
" [property font][operator :]",
|
||||
" [property family][operator :] [atom sans-serif]",
|
||||
" [property size][operator :] [number 30][unit em]",
|
||||
" [property weight][operator :] [atom bold]")
|
||||
|
||||
MT("scoped_styles",
|
||||
"[builtin #contents]",
|
||||
" [property width][operator :] [variable-2 $page-width]",
|
||||
" [builtin #sidebar]",
|
||||
" [property float][operator :] [atom right]",
|
||||
" [property width][operator :] [variable-2 $sidebar-width]",
|
||||
" [builtin #main]",
|
||||
" [property width][operator :] [variable-2 $page-width] [operator -] [variable-2 $sidebar-width]",
|
||||
" [property background][operator :] [variable-2 $primary-color]",
|
||||
" [tag h2]",
|
||||
" [property color][operator :] [keyword blue]")
|
||||
|
||||
// Sass allows to write the colon as first char instead of a "separator".
|
||||
// :color red
|
||||
// Not supported
|
||||
// MT("property_syntax",
|
||||
// "[qualifier .foo]",
|
||||
// " [operator :][property color] [keyword red]")
|
||||
|
||||
MT("import",
|
||||
"[def @import] [string \"sass/variables\"]",
|
||||
// Probably it should parsed as above: as a string even without the " or '
|
||||
// "[def @import] [string sass/baz]"
|
||||
"[def @import] [tag sass][operator /][tag baz]")
|
||||
|
||||
MT("def",
|
||||
"[def @if] [variable-2 $foo] [def @else]")
|
||||
|
||||
MT("tag_on_more_lines",
|
||||
"[tag td],",
|
||||
"[tag th]",
|
||||
" [property font-family][operator :] [string \"Arial\"], [atom serif]")
|
||||
|
||||
MT("important",
|
||||
"[qualifier .foo]",
|
||||
" [property text-decoration][operator :] [atom none] [keyword !important]",
|
||||
"[tag h1]",
|
||||
" [property font-size][operator :] [number 2.5][unit em]")
|
||||
|
||||
MT("selector",
|
||||
// SCSS doesn't highlight the :
|
||||
// "[tag h1]:[variable-3 before],",
|
||||
// "[tag h2]:[variable-3 before]",
|
||||
"[tag h1][variable-3 :before],",
|
||||
"[tag h2][variable-3 :before]",
|
||||
" [property content][operator :] [string \"::\"]")
|
||||
|
||||
MT("definition_mixin_equal",
|
||||
"[variable-2 $defined-bs-type][operator :] [atom border-box] [keyword !default]",
|
||||
"[meta =bs][operator (][variable-2 $bs-type][operator :] [variable-2 $defined-bs-type][operator )]",
|
||||
" [meta -webkit-][property box-sizing][operator :] [variable-2 $bs-type]",
|
||||
" [property box-sizing][operator :] [variable-2 $bs-type]")
|
||||
|
||||
MT("definition_mixin_with_space",
|
||||
"[variable-2 $defined-bs-type][operator :] [atom border-box] [keyword !default]",
|
||||
"[def @mixin] [tag bs][operator (][variable-2 $bs-type][operator :] [variable-2 $defined-bs-type][operator )] ",
|
||||
" [meta -moz-][property box-sizing][operator :] [variable-2 $bs-type]",
|
||||
" [property box-sizing][operator :] [variable-2 $bs-type]")
|
||||
|
||||
MT("numbers_start_dot_include_plus",
|
||||
// The % is not highlighted correctly
|
||||
// "[meta =button-links][operator (][variable-2 $button-base][operator :] [atom darken][operator (][variable-2 $color11], [number 10][unit %][operator )][operator )]",
|
||||
"[meta =button-links][operator (][variable-2 $button-base][operator :] [atom darken][operator (][variable-2 $color11], [number 10][operator %))]",
|
||||
" [property padding][operator :] [number .3][unit em] [number .6][unit em]",
|
||||
" [variable-3 +border-radius][operator (][number 8][unit px][operator )]",
|
||||
" [property background-color][operator :] [variable-2 $button-base]")
|
||||
|
||||
MT("include",
|
||||
"[qualifier .bar]",
|
||||
" [def @include] [tag border-radius][operator (][number 8][unit px][operator )]")
|
||||
|
||||
MT("reference_parent",
|
||||
"[qualifier .col]",
|
||||
" [property clear][operator :] [atom both]",
|
||||
// SCSS doesn't highlight the :
|
||||
// " &:[variable-3 after]",
|
||||
" &[variable-3 :after]",
|
||||
" [property content][operator :] [string '']",
|
||||
" [property clear][operator :] [atom both]")
|
||||
|
||||
MT("reference_parent_with_spaces",
|
||||
"[tag section]",
|
||||
" [property border-left][operator :] [number 20][unit px] [atom transparent] [atom solid] ",
|
||||
" &[qualifier .section3]",
|
||||
" [qualifier .title]",
|
||||
" [property color][operator :] [keyword white] ",
|
||||
" [qualifier .vermas]",
|
||||
" [property display][operator :] [atom none]")
|
||||
|
||||
MT("font_face",
|
||||
"[def @font-face]",
|
||||
" [property font-family][operator :] [string 'icomoon']",
|
||||
" [property src][operator :] [atom url][operator (][string fonts/icomoon.ttf][operator )]")
|
||||
})();
|
Reference in New Issue
Block a user