1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-02 20:15:26 +02:00

moved emberjs to gui folder

This commit is contained in:
Harvey Kandola 2017-07-19 14:48:33 +01:00
parent 6a18d18f91
commit dc49dbbeff
999 changed files with 677 additions and 651 deletions

68
gui/public/codemirror/mode/sass/index.html vendored Executable file
View file

@ -0,0 +1,68 @@
<!doctype html>
<title>CodeMirror: Sass mode</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../../doc/docs.css">
<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>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
<li><a class=active href="#">Sass</a>
</ul>
</div>
<article>
<h2>Sass mode</h2>
<form><textarea id="code" name="code">// Variable Definitions
$page-width: 800px
$sidebar-width: 200px
$primary-color: #eeeeee
// Global Attributes
body
font:
family: sans-serif
size: 30em
weight: bold
// Scoped Styles
#contents
width: $page-width
#sidebar
float: right
width: $sidebar-width
#main
width: $page-width - $sidebar-width
background: $primary-color
h2
color: blue
#footer
height: 200px
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers : true,
matchBrackets : true,
mode: "sass"
});
</script>
<p><strong>MIME types defined:</strong> <code>text/x-sass</code>.</p>
</article>

454
gui/public/codemirror/mode/sass/sass.js vendored Executable file
View file

@ -0,0 +1,454 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"), require("../css/css"));
else if (typeof define == "function" && define.amd) // AMD
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("|"));
}
var keywords = ["true", "false", "null", "auto"];
var keywordsRegexp = new RegExp("^" + keywords.join("|"));
var operators = ["\\(", "\\)", "=", ">", "<", "==", ">=", "<=", "\\+", "-",
"\\!=", "/", "\\*", "%", "and", "or", "not", ";","\\{","\\}",":"];
var opRegexp = tokenRegexp(operators);
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();
if (ch === ")") {
stream.next();
state.tokenizer = tokenBase;
return "operator";
} else if (ch === "(") {
stream.next();
stream.eatSpace();
return "operator";
} else if (ch === "'" || ch === '"') {
state.tokenizer = buildStringTokenizer(stream.next());
return "string";
} else {
state.tokenizer = buildStringTokenizer(")", false);
return "string";
}
}
function comment(indentation, multiLine) {
return function(stream, state) {
if (stream.sol() && stream.indentation() <= indentation) {
state.tokenizer = tokenBase;
return tokenBase(stream, state);
}
if (multiLine && stream.skipTo("*/")) {
stream.next();
stream.next();
state.tokenizer = tokenBase;
} else {
stream.skipToEnd();
}
return "comment";
};
}
function buildStringTokenizer(quote, greedy) {
if (greedy == null) { greedy = true; }
function stringTokenizer(stream, state) {
var nextChar = stream.next();
var peekChar = stream.peek();
var previousChar = stream.string.charAt(stream.pos-2);
var endingString = ((nextChar !== "\\" && peekChar === quote) || (nextChar === quote && previousChar !== "\\"));
if (endingString) {
if (nextChar !== quote && greedy) { stream.next(); }
if (isEndLine(stream)) {
state.cursorHalf = 0;
}
state.tokenizer = tokenBase;
return "string";
} else if (nextChar === "#" && peekChar === "{") {
state.tokenizer = buildInterpolationTokenizer(stringTokenizer);
stream.next();
return "operator";
} else {
return "string";
}
}
return stringTokenizer;
}
function buildInterpolationTokenizer(currentTokenizer) {
return function(stream, state) {
if (stream.peek() === "}") {
stream.next();
state.tokenizer = currentTokenizer;
return "operator";
} else {
return tokenBase(stream, state);
}
};
}
function indent(state) {
if (state.indentCount == 0) {
state.indentCount++;
var lastScopeOffset = state.scopes[0].offset;
var currentOffset = lastScopeOffset + config.indentUnit;
state.scopes.unshift({ offset:currentOffset });
}
}
function dedent(state) {
if (state.scopes.length == 1) return;
state.scopes.shift();
}
function tokenBase(stream, state) {
var ch = stream.peek();
// Comment
if (stream.match("/*")) {
state.tokenizer = comment(stream.indentation(), true);
return state.tokenizer(stream, state);
}
if (stream.match("//")) {
state.tokenizer = comment(stream.indentation(), false);
return state.tokenizer(stream, state);
}
// Interpolation
if (stream.match("#{")) {
state.tokenizer = buildInterpolationTokenizer(tokenBase);
return "operator";
}
// Strings
if (ch === '"' || ch === "'") {
stream.next();
state.tokenizer = buildStringTokenizer(ch);
return "string";
}
if(!state.cursorHalf){// state.cursorHalf === 0
// 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 "qualifier";
} else if (stream.peek() === "#") {
indent(state);
return "tag";
}
}
if (ch === "#") {
stream.next();
// ID selectors
if (stream.match(/^[\w-]+/)) {
indent(state);
return "builtin";
}
if (stream.peek() === "#") {
indent(state);
return "tag";
}
}
// Variables
if (ch === "$") {
stream.next();
stream.eatWhile(/[\w-]/);
return "variable-2";
}
// Numbers
if (stream.match(/^-?[0-9\.]+/))
return "number";
// Units
if (stream.match(/^(px|em|in)\b/))
return "unit";
if (stream.match(keywordsRegexp))
return "keyword";
if (stream.match(/^url/) && stream.peek() === "(") {
state.tokenizer = urlTokens;
return "atom";
}
if (ch === "=") {
// Match shortcut mixin definition
if (stream.match(/^=[\w-]+/)) {
indent(state);
return "meta";
}
}
if (ch === "+") {
// Match shortcut mixin definition
if (stream.match(/^\+[\w-]+/)){
return "variable-3";
}
}
if(ch === "@"){
if(stream.match(/@extend/)){
if(!stream.match(/\s*[\w]/))
dedent(state);
}
}
// Indent Directives
if (stream.match(/^@(else if|if|media|else|for|each|while|mixin|function)/)) {
indent(state);
return "def";
}
// Other Directives
if (ch === "@") {
stream.next();
stream.eatWhile(/[\w-]/);
return "def";
}
if (stream.eatWhile(/[\w-]/)){
if(stream.match(/ *: *[\w-\+\$#!\("']/,false)){
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;
state.prevProp = stream.current().toLowerCase();
return "property";
}
else if(stream.match(/ *,/,false)){
return "tag";
}
else{
indent(state);
return "tag";
}
}
if(ch === ":"){
if (stream.match(pseudoElementsRegexp)){ // could be a pseudo-element
return "variable-3";
}
stream.next();
state.cursorHalf=1;
return "operator";
}
} // cursorHalf===0 ends here
else{
if (ch === "#") {
stream.next();
// Hex numbers
if (stream.match(/[0-9a-fA-F]{6}|[0-9a-fA-F]{3}/)){
if (isEndLine(stream)) {
state.cursorHalf = 0;
}
return "number";
}
}
// Numbers
if (stream.match(/^-?[0-9\.]+/)){
if (isEndLine(stream)) {
state.cursorHalf = 0;
}
return "number";
}
// Units
if (stream.match(/^(px|em|in)\b/)){
if (isEndLine(stream)) {
state.cursorHalf = 0;
}
return "unit";
}
if (stream.match(keywordsRegexp)){
if (isEndLine(stream)) {
state.cursorHalf = 0;
}
return "keyword";
}
if (stream.match(/^url/) && stream.peek() === "(") {
state.tokenizer = urlTokens;
if (isEndLine(stream)) {
state.cursorHalf = 0;
}
return "atom";
}
// Variables
if (ch === "$") {
stream.next();
stream.eatWhile(/[\w-]/);
if (isEndLine(stream)) {
state.cursorHalf = 0;
}
return "variable-2";
}
// bang character for !important, !default, etc.
if (ch === "!") {
stream.next();
state.cursorHalf = 0;
return stream.match(/^[\w]+/) ? "keyword": "operator";
}
if (stream.match(opRegexp)){
if (isEndLine(stream)) {
state.cursorHalf = 0;
}
return "operator";
}
// attributes
if (stream.eatWhile(/[\w-]/)) {
if (isEndLine(stream)) {
state.cursorHalf = 0;
}
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 (isEndLine(stream)) {
state.cursorHalf = 0;
return null;
}
} // else ends here
if (stream.match(opRegexp))
return "operator";
// If we haven't returned by now, we move 1 character
// and return an error
stream.next();
return null;
}
function tokenLexer(stream, state) {
if (stream.sol()) state.indentCount = 0;
var style = state.tokenizer(stream, state);
var current = stream.current();
if (current === "@return" || current === "}"){
dedent(state);
}
if (style !== null) {
var startOfToken = stream.pos - current.length;
var withCurrentIndent = startOfToken + (config.indentUnit * state.indentCount);
var newScopes = [];
for (var i = 0; i < state.scopes.length; i++) {
var scope = state.scopes[i];
if (scope.offset <= withCurrentIndent)
newScopes.push(scope);
}
state.scopes = newScopes;
}
return style;
}
return {
startState: function() {
return {
tokenizer: tokenBase,
scopes: [{offset: 0, type: "sass"}],
indentCount: 0,
cursorHalf: 0, // cursor half tells us if cursor lies after (1)
// or before (0) colon (well... more or less)
definedVars: [],
definedMixins: []
};
},
token: function(stream, state) {
var style = tokenLexer(stream, state);
state.lastToken = { style: style, content: stream.current() };
return style;
},
indent: function(state) {
return state.scopes[0].offset;
}
};
});
CodeMirror.defineMIME("text/x-sass", "sass");
});

122
gui/public/codemirror/mode/sass/test.js vendored Executable file
View file

@ -0,0 +1,122 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://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 )]")
})();