fix: 初始化
This commit is contained in:
5
packages/icpx-organization/public/js/bootstrap.min.css
vendored
Normal file
5
packages/icpx-organization/public/js/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
7
packages/icpx-organization/public/js/bootstrap.min.js
vendored
Normal file
7
packages/icpx-organization/public/js/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
packages/icpx-organization/public/js/codemirror.min.css
vendored
Normal file
2
packages/icpx-organization/public/js/codemirror.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
packages/icpx-organization/public/js/codemirror.min.js
vendored
Normal file
1
packages/icpx-organization/public/js/codemirror.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
98860
packages/icpx-organization/public/js/echarts.js
Normal file
98860
packages/icpx-organization/public/js/echarts.js
Normal file
File diff suppressed because it is too large
Load Diff
366
packages/icpx-organization/public/js/jquery.format.js
Normal file
366
packages/icpx-organization/public/js/jquery.format.js
Normal file
@ -0,0 +1,366 @@
|
||||
/*
|
||||
* format - jQuery plugin to pretty-print or minify text in XML, JSON, CSS and SQL formats.
|
||||
* https://github.com/zachofalltrades/jquery.format
|
||||
*
|
||||
* Version - 0.1
|
||||
* Copyright (c) 2013 Zach Shelton
|
||||
* http://zachofalltrades.net
|
||||
*
|
||||
* Based on vkbeautify by Vadim Kiryukhin
|
||||
* http://www.eslinstructor.net/vkbeautify/
|
||||
*
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
*/
|
||||
(function( $ ) {
|
||||
|
||||
/**
|
||||
* utility function called from constructor of Formatter
|
||||
*/
|
||||
function createShiftArr(step) {
|
||||
var space = ' ';
|
||||
if ( isNaN(parseInt(step)) ) { // argument is string
|
||||
space = step;
|
||||
} else { // argument is integer
|
||||
space = new Array(step + 1).join(' '); //space is result of join (a string), not an array
|
||||
}
|
||||
var shift = ['\n']; // array of shifts
|
||||
for(var ix=0;ix<100;ix++){
|
||||
shift.push(shift[ix]+space);
|
||||
}
|
||||
return shift;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function isSubquery(str, parenthesisLevel) {
|
||||
return parenthesisLevel - (str.replace(/\(/g,'').length - str.replace(/\)/g,'').length );
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function split_sql(str, tab) {
|
||||
return str.replace(/\s{1,}/g," ")
|
||||
.replace(/ AND /ig,"~::~"+tab+tab+"AND ")
|
||||
.replace(/ BETWEEN /ig,"~::~"+tab+"BETWEEN ")
|
||||
.replace(/ CASE /ig,"~::~"+tab+"CASE ")
|
||||
.replace(/ ELSE /ig,"~::~"+tab+"ELSE ")
|
||||
.replace(/ END /ig,"~::~"+tab+"END ")
|
||||
.replace(/ FROM /ig,"~::~FROM ")
|
||||
.replace(/ GROUP\s{1,}BY/ig,"~::~GROUP BY ")
|
||||
.replace(/ HAVING /ig,"~::~HAVING ")
|
||||
//.replace(/ SET /ig," SET~::~")
|
||||
.replace(/ IN /ig," IN ")
|
||||
.replace(/ JOIN /ig,"~::~JOIN ")
|
||||
.replace(/ CROSS~::~{1,}JOIN /ig,"~::~CROSS JOIN ")
|
||||
.replace(/ INNER~::~{1,}JOIN /ig,"~::~INNER JOIN ")
|
||||
.replace(/ LEFT~::~{1,}JOIN /ig,"~::~LEFT JOIN ")
|
||||
.replace(/ RIGHT~::~{1,}JOIN /ig,"~::~RIGHT JOIN ")
|
||||
.replace(/ ON /ig,"~::~"+tab+"ON ")
|
||||
.replace(/ OR /ig,"~::~"+tab+tab+"OR ")
|
||||
.replace(/ ORDER\s{1,}BY/ig,"~::~ORDER BY ")
|
||||
.replace(/ OVER /ig,"~::~"+tab+"OVER ")
|
||||
.replace(/\(\s{0,}SELECT /ig,"~::~(SELECT ")
|
||||
.replace(/\)\s{0,}SELECT /ig,")~::~SELECT ")
|
||||
.replace(/ THEN /ig," THEN~::~"+tab+"")
|
||||
.replace(/ UNION /ig,"~::~UNION~::~")
|
||||
.replace(/ USING /ig,"~::~USING ")
|
||||
.replace(/ WHEN /ig,"~::~"+tab+"WHEN ")
|
||||
.replace(/ WHERE /ig,"~::~WHERE ")
|
||||
.replace(/ WITH /ig,"~::~WITH ")
|
||||
//.replace(/\,\s{0,}\(/ig,",~::~( ")
|
||||
//.replace(/\,/ig,",~::~"+tab+tab+"")
|
||||
.replace(/ ALL /ig," ALL ")
|
||||
.replace(/ AS /ig," AS ")
|
||||
.replace(/ ASC /ig," ASC ")
|
||||
.replace(/ DESC /ig," DESC ")
|
||||
.replace(/ DISTINCT /ig," DISTINCT ")
|
||||
.replace(/ EXISTS /ig," EXISTS ")
|
||||
.replace(/ NOT /ig," NOT ")
|
||||
.replace(/ NULL /ig," NULL ")
|
||||
.replace(/ LIKE /ig," LIKE ")
|
||||
.replace(/\s{0,}SELECT /ig,"SELECT ")
|
||||
.replace(/\s{0,}UPDATE /ig,"UPDATE ")
|
||||
.replace(/ SET /ig," SET ")
|
||||
.replace(/~::~{1,}/g,"~::~")
|
||||
.split('~::~');
|
||||
};
|
||||
|
||||
|
||||
var Formatter = function (options) {
|
||||
this.init(options);
|
||||
//TODO - if options object maps any functions, add them as appropriately named methods
|
||||
var methodName = this.options.method;
|
||||
if (!$.isFunction(this[methodName])) {
|
||||
$.error("'" + methodName + "' is not a Formatter method.");
|
||||
};
|
||||
this.format = function(text) { //alias to currently selected method
|
||||
return this[this.options.method].call(this, text);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* putting the methods into the prototype instead of the constructor method
|
||||
* enables more efficient on-the-fly creation of Formatter instances
|
||||
*/
|
||||
Formatter.prototype = {
|
||||
options: {},
|
||||
|
||||
init: function(options) {
|
||||
this.options = $.extend({}, $.fn.format.defaults, options);
|
||||
this.step = this.options.step;
|
||||
this.preserveComments = this.options.preserveComments;
|
||||
this.shift = createShiftArr(this.step);
|
||||
},
|
||||
|
||||
xml: function(text) {
|
||||
var ar = text.replace(/>\s{0,}</g,"><")
|
||||
.replace(/</g,"~::~<")
|
||||
.replace(/\s*xmlns\:/g,"~::~xmlns:")
|
||||
.replace(/\s*xmlns\=/g,"~::~xmlns=")
|
||||
.split('~::~'),
|
||||
len = ar.length,
|
||||
inComment = false,
|
||||
deep = 0,
|
||||
str = '',
|
||||
ix = 0;
|
||||
|
||||
for(ix=0;ix<len;ix++) {
|
||||
// start comment or <![CDATA[...]]> or <!DOCTYPE //
|
||||
if(ar[ix].search(/<!/) > -1) {
|
||||
str += this.shift[deep]+ar[ix];
|
||||
inComment = true;
|
||||
// end comment or <![CDATA[...]]> //
|
||||
if(ar[ix].search(/-->/) > -1 || ar[ix].search(/\]>/) > -1 || ar[ix].search(/!DOCTYPE/) > -1 ) {
|
||||
inComment = false;
|
||||
}
|
||||
} else
|
||||
// end comment or <![CDATA[...]]> //
|
||||
if(ar[ix].search(/-->/) > -1 || ar[ix].search(/\]>/) > -1) {
|
||||
str += ar[ix];
|
||||
inComment = false;
|
||||
} else
|
||||
// <elm></elm> //
|
||||
if( /^<\w/.exec(ar[ix-1]) && /^<\/\w/.exec(ar[ix]) &&
|
||||
/^<[\w:\-\.\,]+/.exec(ar[ix-1]) == /^<\/[\w:\-\.\,]+/.exec(ar[ix])[0].replace('/','')) {
|
||||
str += ar[ix];
|
||||
if(!inComment) deep--;
|
||||
} else
|
||||
// <elm> //
|
||||
if(ar[ix].search(/<\w/) > -1 && ar[ix].search(/<\//) == -1 && ar[ix].search(/\/>/) == -1 ) {
|
||||
str = !inComment ? str += this.shift[deep++]+ar[ix] : str += ar[ix];
|
||||
} else
|
||||
// <elm>...</elm> //
|
||||
if(ar[ix].search(/<\w/) > -1 && ar[ix].search(/<\//) > -1) {
|
||||
str = !inComment ? str += this.shift[deep]+ar[ix] : str += ar[ix];
|
||||
} else
|
||||
// </elm> //
|
||||
if(ar[ix].search(/<\//) > -1) {
|
||||
str = !inComment ? str += this.shift[--deep]+ar[ix] : str += ar[ix];
|
||||
} else
|
||||
// <elm/> //
|
||||
if(ar[ix].search(/\/>/) > -1 ) {
|
||||
str = !inComment ? str += this.shift[deep]+ar[ix] : str += ar[ix];
|
||||
} else
|
||||
// <? xml ... ?> //
|
||||
if(ar[ix].search(/<\?/) > -1) {
|
||||
str += this.shift[deep]+ar[ix];
|
||||
} else
|
||||
// xmlns //
|
||||
if( ar[ix].search(/xmlns\:/) > -1 || ar[ix].search(/xmlns\=/) > -1) {
|
||||
str += this.shift[deep]+ar[ix];
|
||||
}
|
||||
|
||||
else {
|
||||
str += ar[ix];
|
||||
}
|
||||
}
|
||||
|
||||
return (str[0] == '\n') ? str.slice(1) : str;
|
||||
},
|
||||
|
||||
xmlmin: function(text) {
|
||||
var str = this.preserveComments ? text
|
||||
: text.replace(/\<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)\>/g,"")
|
||||
.replace(/[ \r\n\t]{1,}xmlns/g, ' xmlns');
|
||||
return str.replace(/>\s{0,}</g,"><");
|
||||
},
|
||||
|
||||
json: function(text) {
|
||||
if ( typeof JSON === 'undefined' ) return text;
|
||||
if ( typeof text === "string" ) {
|
||||
return JSON.stringify(JSON.parse(text), null, this.step);
|
||||
}
|
||||
if ( typeof text === "object" ) {
|
||||
return JSON.stringify(text, null, this.step);
|
||||
}
|
||||
return text; // text is not string nor object
|
||||
},
|
||||
|
||||
jsonmin: function(text) {
|
||||
if (typeof JSON === 'undefined' ) {
|
||||
return text;
|
||||
}
|
||||
return JSON.stringify(JSON.parse(text), null, 0);
|
||||
},
|
||||
|
||||
css: function(text) {
|
||||
var ar = text.replace(/\s{1,}/g,' ')
|
||||
.replace(/\{/g,"{~::~")
|
||||
.replace(/\}/g,"~::~}~::~")
|
||||
.replace(/\;/g,";~::~")
|
||||
.replace(/\/\*/g,"~::~/*")
|
||||
.replace(/\*\//g,"*/~::~")
|
||||
.replace(/~::~\s{0,}~::~/g,"~::~")
|
||||
.split('~::~'),
|
||||
len = ar.length,
|
||||
deep = 0,
|
||||
str = '',
|
||||
ix = 0;
|
||||
|
||||
for(ix=0;ix<len;ix++) {
|
||||
|
||||
if( /\{/.exec(ar[ix])) {
|
||||
str += this.shift[deep++]+ar[ix];
|
||||
} else
|
||||
if( /\}/.exec(ar[ix])) {
|
||||
str += this.shift[--deep]+ar[ix];
|
||||
} else
|
||||
if( /\*\\/.exec(ar[ix])) {
|
||||
str += this.shift[deep]+ar[ix];
|
||||
}
|
||||
else {
|
||||
str += this.shift[deep]+ar[ix];
|
||||
}
|
||||
}
|
||||
return str.replace(/^\n{1,}/,'');
|
||||
},
|
||||
|
||||
cssmin: function(text) {
|
||||
var str = this.preserveComments ? text : text.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\//g,"") ;
|
||||
return str.replace(/\s{1,}/g,' ')
|
||||
.replace(/\{\s{1,}/g,"{")
|
||||
.replace(/\}\s{1,}/g,"}")
|
||||
.replace(/\;\s{1,}/g,";")
|
||||
.replace(/\/\*\s{1,}/g,"/*")
|
||||
.replace(/\*\/\s{1,}/g,"*/");
|
||||
},
|
||||
|
||||
sql: function(text) {
|
||||
|
||||
var ar_by_quote = text.replace(/\s{1,}/g," ")
|
||||
.replace(/\'/ig,"~::~\'")
|
||||
.split('~::~'),
|
||||
len = ar_by_quote.length,
|
||||
ar = [],
|
||||
deep = 0,
|
||||
tab = this.step,//+this.step,
|
||||
parenthesisLevel = 0,
|
||||
str = '',
|
||||
ix = 0;
|
||||
|
||||
for(ix=0;ix<len;ix++) {
|
||||
if(ix%2) {
|
||||
ar = ar.concat(ar_by_quote[ix]);
|
||||
} else {
|
||||
ar = ar.concat(split_sql(ar_by_quote[ix], tab) );
|
||||
}
|
||||
}
|
||||
|
||||
len = ar.length;
|
||||
for(ix=0;ix<len;ix++) {
|
||||
|
||||
parenthesisLevel = isSubquery(ar[ix], parenthesisLevel);
|
||||
|
||||
if( /\s{0,}\s{0,}SELECT\s{0,}/.exec(ar[ix])) {
|
||||
ar[ix] = ar[ix].replace(/\,/g,",\n"+tab+tab+"");
|
||||
}
|
||||
|
||||
if( /\s{0,}\s{0,}SET\s{0,}/.exec(ar[ix])) {
|
||||
ar[ix] = ar[ix].replace(/\,/g,",\n"+tab+tab+"");
|
||||
}
|
||||
|
||||
if( /\s{0,}\(\s{0,}SELECT\s{0,}/.exec(ar[ix])) {
|
||||
deep++;
|
||||
str += this.shift[deep]+ar[ix];
|
||||
} else
|
||||
if( /\'/.exec(ar[ix]) ) {
|
||||
if(parenthesisLevel<1 && deep) {
|
||||
deep--;
|
||||
}
|
||||
str += ar[ix];
|
||||
}
|
||||
else {
|
||||
str += this.shift[deep]+ar[ix];
|
||||
if(parenthesisLevel<1 && deep) {
|
||||
deep--;
|
||||
}
|
||||
}
|
||||
}
|
||||
str = str.replace(/^\n{1,}/,'').replace(/\n{1,}/g,"\n");
|
||||
return str;
|
||||
},
|
||||
|
||||
sqlmin: function(text) {
|
||||
return text.replace(/\s{1,}/g," ").replace(/\s{1,}\(/,"(").replace(/\s{1,}\)/,")");
|
||||
}
|
||||
|
||||
};//end Formatter.prototype
|
||||
|
||||
|
||||
/**
|
||||
* DOM chaining version
|
||||
*/
|
||||
$.fn.format = function(options) {
|
||||
var fmt = new Formatter(options);
|
||||
// var methodName = fmt.options.method;
|
||||
// if (!$.isFunction(fmt[methodName])) {
|
||||
// $.error("'" + methodName + "' is not a Formatter method.")
|
||||
// };
|
||||
// console.log("call " + methodName + " on " + $.type(this));
|
||||
// console.log(this);
|
||||
return this.each(function() {
|
||||
// console.log($.type(this));
|
||||
// console.log(this);
|
||||
var node = $(this);
|
||||
// console.log($.type(node));
|
||||
// console.log(node);
|
||||
var text = node.val();
|
||||
// console.log("text ==>\n" + text);
|
||||
text = fmt.format(text);
|
||||
node.val(text);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* utility version
|
||||
*/
|
||||
$.format = function(text, options) {
|
||||
var fmt = new Formatter(options);
|
||||
// var methodName = fmt.options.method;
|
||||
// if (!$.isFunction(fmt[methodName])) {
|
||||
// $.error("'" + methodName + "' is not a Formatter method.")
|
||||
// };
|
||||
// console.log("call " + methodName + " on " + $.type(text));
|
||||
// console.log(text);
|
||||
// return fmt[methodName].call(fmt, text);
|
||||
return fmt.format(text);
|
||||
};
|
||||
|
||||
/**
|
||||
* default configuration
|
||||
*/
|
||||
$.fn.format.defaults = {
|
||||
method: 'xml', // the method to be called
|
||||
step: ' ', // 4 spaces
|
||||
preserveComments: false //applies to cssmin and xmlmin functions
|
||||
};
|
||||
|
||||
|
||||
})(jQuery);
|
||||
|
4
packages/icpx-organization/public/js/jquery.min.js
vendored
Normal file
4
packages/icpx-organization/public/js/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
24129
packages/icpx-organization/public/js/wangeditor.js
Normal file
24129
packages/icpx-organization/public/js/wangeditor.js
Normal file
File diff suppressed because one or more lines are too long
49
packages/icpx-organization/public/js/x6.js
Normal file
49
packages/icpx-organization/public/js/x6.js
Normal file
File diff suppressed because one or more lines are too long
402
packages/icpx-organization/public/js/xml.js
Normal file
402
packages/icpx-organization/public/js/xml.js
Normal file
@ -0,0 +1,402 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var htmlConfig = {
|
||||
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
|
||||
'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
|
||||
'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
|
||||
'track': true, 'wbr': true, 'menuitem': true},
|
||||
implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
|
||||
'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
|
||||
'th': true, 'tr': true},
|
||||
contextGrabbers: {
|
||||
'dd': {'dd': true, 'dt': true},
|
||||
'dt': {'dd': true, 'dt': true},
|
||||
'li': {'li': true},
|
||||
'option': {'option': true, 'optgroup': true},
|
||||
'optgroup': {'optgroup': true},
|
||||
'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
|
||||
'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
|
||||
'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
|
||||
'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
|
||||
'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
|
||||
'rp': {'rp': true, 'rt': true},
|
||||
'rt': {'rp': true, 'rt': true},
|
||||
'tbody': {'tbody': true, 'tfoot': true},
|
||||
'td': {'td': true, 'th': true},
|
||||
'tfoot': {'tbody': true},
|
||||
'th': {'td': true, 'th': true},
|
||||
'thead': {'tbody': true, 'tfoot': true},
|
||||
'tr': {'tr': true}
|
||||
},
|
||||
doNotIndent: {"pre": true},
|
||||
allowUnquoted: true,
|
||||
allowMissing: true,
|
||||
caseFold: true
|
||||
}
|
||||
|
||||
var xmlConfig = {
|
||||
autoSelfClosers: {},
|
||||
implicitlyClosed: {},
|
||||
contextGrabbers: {},
|
||||
doNotIndent: {},
|
||||
allowUnquoted: false,
|
||||
allowMissing: false,
|
||||
allowMissingTagName: false,
|
||||
caseFold: false
|
||||
}
|
||||
|
||||
CodeMirror.defineMode("xml", function(editorConf, config_) {
|
||||
var indentUnit = editorConf.indentUnit
|
||||
var config = {}
|
||||
var defaults = config_.htmlMode ? htmlConfig : xmlConfig
|
||||
for (var prop in defaults) config[prop] = defaults[prop]
|
||||
for (var prop in config_) config[prop] = config_[prop]
|
||||
|
||||
// Return variables for tokenizers
|
||||
var type, setStyle;
|
||||
|
||||
function inText(stream, state) {
|
||||
function chain(parser) {
|
||||
state.tokenize = parser;
|
||||
return parser(stream, state);
|
||||
}
|
||||
|
||||
var ch = stream.next();
|
||||
if (ch == "<") {
|
||||
if (stream.eat("!")) {
|
||||
if (stream.eat("[")) {
|
||||
if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
|
||||
else return null;
|
||||
} else if (stream.match("--")) {
|
||||
return chain(inBlock("comment", "-->"));
|
||||
} else if (stream.match("DOCTYPE", true, true)) {
|
||||
stream.eatWhile(/[\w\._\-]/);
|
||||
return chain(doctype(1));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else if (stream.eat("?")) {
|
||||
stream.eatWhile(/[\w\._\-]/);
|
||||
state.tokenize = inBlock("meta", "?>");
|
||||
return "meta";
|
||||
} else {
|
||||
type = stream.eat("/") ? "closeTag" : "openTag";
|
||||
state.tokenize = inTag;
|
||||
return "tag bracket";
|
||||
}
|
||||
} else if (ch == "&") {
|
||||
var ok;
|
||||
if (stream.eat("#")) {
|
||||
if (stream.eat("x")) {
|
||||
ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
|
||||
} else {
|
||||
ok = stream.eatWhile(/[\d]/) && stream.eat(";");
|
||||
}
|
||||
} else {
|
||||
ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
|
||||
}
|
||||
return ok ? "atom" : "error";
|
||||
} else {
|
||||
stream.eatWhile(/[^&<]/);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
inText.isInText = true;
|
||||
|
||||
function inTag(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (ch == ">" || (ch == "/" && stream.eat(">"))) {
|
||||
state.tokenize = inText;
|
||||
type = ch == ">" ? "endTag" : "selfcloseTag";
|
||||
return "tag bracket";
|
||||
} else if (ch == "=") {
|
||||
type = "equals";
|
||||
return null;
|
||||
} else if (ch == "<") {
|
||||
state.tokenize = inText;
|
||||
state.state = baseState;
|
||||
state.tagName = state.tagStart = null;
|
||||
var next = state.tokenize(stream, state);
|
||||
return next ? next + " tag error" : "tag error";
|
||||
} else if (/[\'\"]/.test(ch)) {
|
||||
state.tokenize = inAttribute(ch);
|
||||
state.stringStartCol = stream.column();
|
||||
return state.tokenize(stream, state);
|
||||
} else {
|
||||
stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);
|
||||
return "word";
|
||||
}
|
||||
}
|
||||
|
||||
function inAttribute(quote) {
|
||||
var closure = function(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
if (stream.next() == quote) {
|
||||
state.tokenize = inTag;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "string";
|
||||
};
|
||||
closure.isInAttribute = true;
|
||||
return closure;
|
||||
}
|
||||
|
||||
function inBlock(style, terminator) {
|
||||
return function(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
if (stream.match(terminator)) {
|
||||
state.tokenize = inText;
|
||||
break;
|
||||
}
|
||||
stream.next();
|
||||
}
|
||||
return style;
|
||||
}
|
||||
}
|
||||
|
||||
function doctype(depth) {
|
||||
return function(stream, state) {
|
||||
var ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (ch == "<") {
|
||||
state.tokenize = doctype(depth + 1);
|
||||
return state.tokenize(stream, state);
|
||||
} else if (ch == ">") {
|
||||
if (depth == 1) {
|
||||
state.tokenize = inText;
|
||||
break;
|
||||
} else {
|
||||
state.tokenize = doctype(depth - 1);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
return "meta";
|
||||
};
|
||||
}
|
||||
|
||||
function Context(state, tagName, startOfLine) {
|
||||
this.prev = state.context;
|
||||
this.tagName = tagName;
|
||||
this.indent = state.indented;
|
||||
this.startOfLine = startOfLine;
|
||||
if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
|
||||
this.noIndent = true;
|
||||
}
|
||||
function popContext(state) {
|
||||
if (state.context) state.context = state.context.prev;
|
||||
}
|
||||
function maybePopContext(state, nextTagName) {
|
||||
var parentTagName;
|
||||
while (true) {
|
||||
if (!state.context) {
|
||||
return;
|
||||
}
|
||||
parentTagName = state.context.tagName;
|
||||
if (!config.contextGrabbers.hasOwnProperty(parentTagName) ||
|
||||
!config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
|
||||
return;
|
||||
}
|
||||
popContext(state);
|
||||
}
|
||||
}
|
||||
|
||||
function baseState(type, stream, state) {
|
||||
if (type == "openTag") {
|
||||
state.tagStart = stream.column();
|
||||
return tagNameState;
|
||||
} else if (type == "closeTag") {
|
||||
return closeTagNameState;
|
||||
} else {
|
||||
return baseState;
|
||||
}
|
||||
}
|
||||
function tagNameState(type, stream, state) {
|
||||
if (type == "word") {
|
||||
state.tagName = stream.current();
|
||||
setStyle = "tag";
|
||||
return attrState;
|
||||
} else if (config.allowMissingTagName && type == "endTag") {
|
||||
setStyle = "tag bracket";
|
||||
return attrState(type, stream, state);
|
||||
} else {
|
||||
setStyle = "error";
|
||||
return tagNameState;
|
||||
}
|
||||
}
|
||||
function closeTagNameState(type, stream, state) {
|
||||
if (type == "word") {
|
||||
var tagName = stream.current();
|
||||
if (state.context && state.context.tagName != tagName &&
|
||||
config.implicitlyClosed.hasOwnProperty(state.context.tagName))
|
||||
popContext(state);
|
||||
if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) {
|
||||
setStyle = "tag";
|
||||
return closeState;
|
||||
} else {
|
||||
setStyle = "tag error";
|
||||
return closeStateErr;
|
||||
}
|
||||
} else if (config.allowMissingTagName && type == "endTag") {
|
||||
setStyle = "tag bracket";
|
||||
return closeState(type, stream, state);
|
||||
} else {
|
||||
setStyle = "error";
|
||||
return closeStateErr;
|
||||
}
|
||||
}
|
||||
|
||||
function closeState(type, _stream, state) {
|
||||
if (type != "endTag") {
|
||||
setStyle = "error";
|
||||
return closeState;
|
||||
}
|
||||
popContext(state);
|
||||
return baseState;
|
||||
}
|
||||
function closeStateErr(type, stream, state) {
|
||||
setStyle = "error";
|
||||
return closeState(type, stream, state);
|
||||
}
|
||||
|
||||
function attrState(type, _stream, state) {
|
||||
if (type == "word") {
|
||||
setStyle = "attribute";
|
||||
return attrEqState;
|
||||
} else if (type == "endTag" || type == "selfcloseTag") {
|
||||
var tagName = state.tagName, tagStart = state.tagStart;
|
||||
state.tagName = state.tagStart = null;
|
||||
if (type == "selfcloseTag" ||
|
||||
config.autoSelfClosers.hasOwnProperty(tagName)) {
|
||||
maybePopContext(state, tagName);
|
||||
} else {
|
||||
maybePopContext(state, tagName);
|
||||
state.context = new Context(state, tagName, tagStart == state.indented);
|
||||
}
|
||||
return baseState;
|
||||
}
|
||||
setStyle = "error";
|
||||
return attrState;
|
||||
}
|
||||
function attrEqState(type, stream, state) {
|
||||
if (type == "equals") return attrValueState;
|
||||
if (!config.allowMissing) setStyle = "error";
|
||||
return attrState(type, stream, state);
|
||||
}
|
||||
function attrValueState(type, stream, state) {
|
||||
if (type == "string") return attrContinuedState;
|
||||
if (type == "word" && config.allowUnquoted) {setStyle = "string"; return attrState;}
|
||||
setStyle = "error";
|
||||
return attrState(type, stream, state);
|
||||
}
|
||||
function attrContinuedState(type, stream, state) {
|
||||
if (type == "string") return attrContinuedState;
|
||||
return attrState(type, stream, state);
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function(baseIndent) {
|
||||
var state = {tokenize: inText,
|
||||
state: baseState,
|
||||
indented: baseIndent || 0,
|
||||
tagName: null, tagStart: null,
|
||||
context: null}
|
||||
if (baseIndent != null) state.baseIndent = baseIndent
|
||||
return state
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (!state.tagName && stream.sol())
|
||||
state.indented = stream.indentation();
|
||||
|
||||
if (stream.eatSpace()) return null;
|
||||
type = null;
|
||||
var style = state.tokenize(stream, state);
|
||||
if ((style || type) && style != "comment") {
|
||||
setStyle = null;
|
||||
state.state = state.state(type || style, stream, state);
|
||||
if (setStyle)
|
||||
style = setStyle == "error" ? style + " error" : setStyle;
|
||||
}
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter, fullLine) {
|
||||
var context = state.context;
|
||||
// Indent multi-line strings (e.g. css).
|
||||
if (state.tokenize.isInAttribute) {
|
||||
if (state.tagStart == state.indented)
|
||||
return state.stringStartCol + 1;
|
||||
else
|
||||
return state.indented + indentUnit;
|
||||
}
|
||||
if (context && context.noIndent) return CodeMirror.Pass;
|
||||
if (state.tokenize != inTag && state.tokenize != inText)
|
||||
return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
|
||||
// Indent the starts of attribute names.
|
||||
if (state.tagName) {
|
||||
if (config.multilineTagIndentPastTag !== false)
|
||||
return state.tagStart + state.tagName.length + 2;
|
||||
else
|
||||
return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1);
|
||||
}
|
||||
if (config.alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
|
||||
var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
|
||||
if (tagAfter && tagAfter[1]) { // Closing tag spotted
|
||||
while (context) {
|
||||
if (context.tagName == tagAfter[2]) {
|
||||
context = context.prev;
|
||||
break;
|
||||
} else if (config.implicitlyClosed.hasOwnProperty(context.tagName)) {
|
||||
context = context.prev;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (tagAfter) { // Opening tag spotted
|
||||
while (context) {
|
||||
var grabbers = config.contextGrabbers[context.tagName];
|
||||
if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
|
||||
context = context.prev;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (context && context.prev && !context.startOfLine)
|
||||
context = context.prev;
|
||||
if (context) return context.indent + indentUnit;
|
||||
else return state.baseIndent || 0;
|
||||
},
|
||||
|
||||
electricInput: /<\/[\s\w:]+>$/,
|
||||
blockCommentStart: "<!--",
|
||||
blockCommentEnd: "-->",
|
||||
|
||||
configuration: config.htmlMode ? "html" : "xml",
|
||||
helperType: config.htmlMode ? "html" : "xml",
|
||||
|
||||
skipAttribute: function(state) {
|
||||
if (state.state == attrValueState)
|
||||
state.state = attrState
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/xml", "xml");
|
||||
CodeMirror.defineMIME("application/xml", "xml");
|
||||
if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
|
||||
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
|
||||
|
||||
});
|
Reference in New Issue
Block a user