?
Path : /home/admin/public_html/old/media/editors/codemirror/mode/jsx/ |
Current File : /home/admin/public_html/old/media/editors/codemirror/mode/jsx/jsx.min.js |
!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("../xml/xml"),require("../javascript/javascript")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../javascript/javascript"],a):a(CodeMirror)}(function(a){"use strict";function b(a,b,c,d){this.state=a,this.mode=b,this.depth=c,this.prev=d}function c(d){return new b(a.copyState(d.mode,d.state),d.mode,d.depth,d.prev&&c(d.prev))}a.defineMode("jsx",function(d){function e(a){var b=a.tagName;a.tagName=null;var c=i.indent(a,"");return a.tagName=b,c}function f(a,b){return b.context.mode==i?g(a,b,b.context):h(a,b,b.context)}function g(c,g,h){if(2==h.depth)return c.match(/^.*?\*\//)?h.depth=1:c.skipToEnd(),"comment";if("{"==c.peek()){i.skipAttribute(h.state);var k=e(h.state),l=h.state.context;if(l&&c.match(/^[^>]*>\s*$/,!1)){for(;l.prev&&!l.startOfLine;)l=l.prev;l.startOfLine?k-=d.indentUnit:h.prev.state.lexical&&(k=h.prev.state.lexical.indented)}else 1==h.depth&&(k+=d.indentUnit);return g.context=new b(a.startState(j,k),j,0,g.context),null}if(1==h.depth){if("<"==c.peek())return i.skipAttribute(h.state),g.context=new b(a.startState(i,e(h.state)),i,0,g.context),null;if(c.match("//"))return c.skipToEnd(),"comment";if(c.match("/*"))return h.depth=2,f(c,g)}var m,n=i.token(c,h.state),o=c.current();return/\btag\b/.test(n)?/>$/.test(o)?h.state.context?h.depth=0:g.context=g.context.prev:/^</.test(o)&&(h.depth=1):!n&&(m=o.indexOf("{"))>-1&&c.backUp(o.length-m),n}function h(c,d,e){if("<"==c.peek()&&j.expressionAllowed(c,e.state))return j.skipExpression(e.state),d.context=new b(a.startState(i,j.indent(e.state,"")),i,0,d.context),null;var f=j.token(c,e.state);if(!f&&null!=e.depth){var g=c.current();"{"==g?e.depth++:"}"==g&&0==--e.depth&&(d.context=d.context.prev)}return f}var i=a.getMode(d,{name:"xml",allowMissing:!0,multilineTagIndentPastTag:!1}),j=a.getMode(d,"javascript");return{startState:function(){return{context:new b(a.startState(j),j)}},copyState:function(a){return{context:c(a.context)}},token:f,indent:function(a,b,c){return a.context.mode.indent(a.context.state,b,c)},innerMode:function(a){return a.context}}},"xml","javascript"),a.defineMIME("text/jsx","jsx")});