New 'libraries' folder in root instalation directory
This commit is contained in:
parent
05b6a91b0c
commit
006992b900
2267 changed files with 50 additions and 65 deletions
137
libraries/ckeditor/plugins/codemirror/js/mode/bbcode/bbcode.js
Normal file
137
libraries/ckeditor/plugins/codemirror/js/mode/bbcode/bbcode.js
Normal file
|
@ -0,0 +1,137 @@
|
|||
/**
|
||||
* @file bbcode.js
|
||||
* @brief BBCode mode for CodeMirror<http://codemirror.net/>
|
||||
* @author Ruslan Osmanov <rrosmanov@gmail.com>
|
||||
* @version 2.0
|
||||
* @date 12.10.2013
|
||||
*/
|
||||
|
||||
CodeMirror.defineMode("bbcode", function(config) {
|
||||
var settings, m, last;
|
||||
|
||||
settings = {
|
||||
bbCodeTags: "b i u s img quote code list table tr td size color url",
|
||||
bbCodeUnaryTags: "* :-) hr cut"
|
||||
};
|
||||
|
||||
if (config.hasOwnProperty("bbCodeTags")) {
|
||||
settings.bbCodeTags = config.bbCodeTags;
|
||||
}
|
||||
if (config.hasOwnProperty("bbCodeUnaryTags")) {
|
||||
settings.bbCodeUnaryTags = config.bbCodeUnaryTags;
|
||||
}
|
||||
|
||||
var helpers = {
|
||||
cont: function(style, lastType) {
|
||||
last = lastType;
|
||||
return style;
|
||||
},
|
||||
escapeRegEx: function(s) {
|
||||
return s.replace(/([\:\-\)\(\*\+\?\[\]])/g, '\\$1');
|
||||
}
|
||||
};
|
||||
|
||||
var regs = {
|
||||
validIdentifier: /[a-zA-Z0-9_]/,
|
||||
stringChar: /['"]/,
|
||||
tags: new RegExp("(?:" + helpers.escapeRegEx(settings.bbCodeTags).split(" ").join("|") + ")"),
|
||||
unaryTags: new RegExp("(?:" + helpers.escapeRegEx(settings.bbCodeUnaryTags).split(" ").join("|") + ")")
|
||||
};
|
||||
|
||||
var parsers = {
|
||||
tokenizer: function (stream, state) {
|
||||
if (stream.eatSpace()) return null;
|
||||
|
||||
if (stream.match('[', true)) {
|
||||
state.tokenize = parsers.bbcode;
|
||||
return helpers.cont("tag", "startTag");
|
||||
}
|
||||
|
||||
stream.next();
|
||||
return null;
|
||||
},
|
||||
inAttribute: function(quote) {
|
||||
return function(stream, state) {
|
||||
var prevChar = null;
|
||||
var currChar = null;
|
||||
while (!stream.eol()) {
|
||||
currChar = stream.peek();
|
||||
if (stream.next() == quote && prevChar !== '\\') {
|
||||
state.tokenize = parsers.bbcode;
|
||||
break;
|
||||
}
|
||||
prevChar = currChar;
|
||||
}
|
||||
return "string";
|
||||
};
|
||||
},
|
||||
bbcode: function (stream, state) {
|
||||
if (m = stream.match(']', true)) {
|
||||
state.tokenize = parsers.tokenizer;
|
||||
return helpers.cont("tag", null);
|
||||
}
|
||||
|
||||
if (stream.match('[', true)) {
|
||||
return helpers.cont("tag", "startTag");
|
||||
}
|
||||
|
||||
var ch = stream.next();
|
||||
if (regs.stringChar.test(ch)) {
|
||||
state.tokenize = parsers.inAttribute(ch);
|
||||
return helpers.cont("string", "string");
|
||||
} else if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/\d/);
|
||||
return helpers.cont("number", "number");
|
||||
} else {
|
||||
if (state.last == "whitespace") {
|
||||
stream.eatWhile(regs.validIdentifier);
|
||||
return helpers.cont("attribute", "modifier");
|
||||
} if (state.last == "property") {
|
||||
stream.eatWhile(regs.validIdentifier);
|
||||
return helpers.cont("property", null);
|
||||
} else if (/\s/.test(ch)) {
|
||||
last = "whitespace";
|
||||
return null;
|
||||
}
|
||||
|
||||
var str = "";
|
||||
if (ch != "/") {
|
||||
str += ch;
|
||||
}
|
||||
var c = null;
|
||||
while (c = stream.eat(regs.validIdentifier)) {
|
||||
str += c;
|
||||
}
|
||||
if (regs.unaryTags.test(str)) {
|
||||
return helpers.cont("atom", "atom");
|
||||
}
|
||||
if (regs.tags.test(str)) {
|
||||
return helpers.cont("keyword", "keyword");
|
||||
}
|
||||
if (/\s/.test(ch)) {
|
||||
return null;
|
||||
}
|
||||
return helpers.cont("tag", "tag");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
tokenize: parsers.tokenizer,
|
||||
mode: "bbcode",
|
||||
last: null
|
||||
};
|
||||
},
|
||||
token: function(stream, state) {
|
||||
var style = state.tokenize(stream, state);
|
||||
state.last = last;
|
||||
return style;
|
||||
},
|
||||
electricChars: ""
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-bbcode", "bbcode");
|
||||
// vim: et ts=2 sts=2 sw=2
|
|
@ -0,0 +1,73 @@
|
|||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: BBCode 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="bbcode.js"></script>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><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/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">BBCode</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>BBCode mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
[*] item [:-)]
|
||||
Normal text [b]Bold text[/b] [i]italic[/i] [s]strikethrough[/s]
|
||||
[hr]
|
||||
|
||||
[url]http://domain.com[/url]
|
||||
[url=http://domain.com?a=1&b=2]Link[/url]
|
||||
|
||||
[img]http://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/Go-home.svg/100px-Go-home.svg.png[/img]
|
||||
|
||||
[quote]quoted text[/quote]
|
||||
|
||||
[code]monospaced text[/code]
|
||||
|
||||
[size=15]Large Text[/size]
|
||||
|
||||
[color=red]Red Text[/color]
|
||||
or
|
||||
[color=#FF0000]Red Text[/color]
|
||||
or
|
||||
[color=FF0000]Red Text[/color]
|
||||
|
||||
[list] [*]Entry 1 [*]Entry 2 [/list]
|
||||
[list] *Entry 1 *Entry 2 [/list]
|
||||
|
||||
[table] [tr] [td]table data[/td] [/tr] [/table]
|
||||
|
||||
[code]Invalid 1[/b]
|
||||
[unknown]Invalid 1[/unknown]
|
||||
|
||||
[brackets][opening[/brackets]
|
||||
[brackets]closing][/brackets]
|
||||
[brackets][unmatched][/brackets]
|
||||
</textarea></form>
|
||||
|
||||
<script type="text/javascript">
|
||||
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
mode : "bbcode",
|
||||
tabSize : 2,
|
||||
indentUnit : 2,
|
||||
indentWithTabs : false,
|
||||
lineNumbers : true
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-bbcode</code>.</p>
|
||||
</article>
|
||||
<!-- vim: set ts=2 sts=2 sw=2 et: -->
|
Reference in a new issue