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