patch_file/ckeditor/plugins/codemirror/js/codemirror.addons.min.js

54 lines
24 KiB
JavaScript
Raw Normal View History

2019-09-28 11:48:59 +00:00
(function(b){"object"==typeof exports&&"object"==typeof module?b(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],b):b(CodeMirror)})(function(b){function k(c,f){var e=c.getRange(a(f.line,f.ch-1),a(f.line,f.ch+1));return 2==e.length?e:null}function h(c){for(var f={name:"autoCloseBrackets",Backspace:function(f){var e,j,i;if(f.getOption("disableInput"))return b.Pass;e=f.listSelections();for(i=0;i<e.length;i++)if(!e[i].empty()||(j=k(f,e[i].head),!j||
0!=c.indexOf(j)%2))return b.Pass;for(i=e.length-1;0<=i;i--)j=e[i].head,f.replaceRange("",a(j.line,j.ch-1),a(j.line,j.ch+1))}},e="",i=0;i<c.length;i+=2)(function(c,i){c!=i&&(e=e+i);f["'"+c+"'"]=function(j){var f,p,m,h,n,g;if(j.getOption("disableInput"))return b.Pass;f=j.listSelections();for(m=0;m<f.length;m++){if(h=f[m],n=h.head,c=="'"&&j.getTokenTypeAt(n)=="comment")return b.Pass;if(g=j.getRange(n,a(n.line,n.ch+1)),h.empty())if(c==i&&g==i)g=j.getRange(n,a(n.line,n.ch+3))==c+c+c?"skipThree":"skip";
else if(c==i&&n.ch>1&&j.getRange(a(n.line,n.ch-2),n)==c+c&&(n.ch<=2||j.getRange(a(n.line,n.ch-3),a(n.line,n.ch-2))!=c))g="addFour";else if(!(c==i&&b.isWordChar(g))&&(j.getLine(n.line).length==n.ch||e.indexOf(g)>=0||d.test(g)))g="both";else return b.Pass;else g="surround";if(p){if(p!=g)return b.Pass}else p=g}j.operation(function(){var a,f;if(p=="skip")j.execCommand("goCharRight");else if(p=="skipThree")for(f=0;f<3;f++)j.execCommand("goCharRight");else if(p=="surround"){a=j.getSelections();for(f=0;f<
a.length;f++)a[f]=c+a[f]+i;j.replaceSelections(a,"around")}else p=="both"?(j.replaceSelection(c+i,null),j.execCommand("goCharLeft")):p=="addFour"&&(j.replaceSelection(c+c+c+c,"before"),j.execCommand("goCharRight"))})};c!=i&&(f["'"+i+"'"]=function(c){for(var f=c.listSelections(),e,d=0;d<f.length;d++)if(e=f[d],!e.empty()||c.getRange(e.head,a(e.head.line,e.head.ch+1))!=i)return b.Pass;c.execCommand("goCharRight")})})(c.charAt(i),c.charAt(i+1));return f}function g(c){return function(a){var e,i,d;if(a.getOption("disableInput"))return b.Pass;
e=a.listSelections();for(i=0;i<e.length;i++)if(!e[i].empty()||(d=k(a,e[i].head),!d||0!=c.indexOf(d)%2))return b.Pass;a.operation(function(){var c,j;a.replaceSelection("\n\n",null);a.execCommand("goCharLeft");e=a.listSelections();for(c=0;c<e.length;c++)j=e[c].head.line,a.indentLine(j,null,!0),a.indentLine(j+1,null,!0)})}}var d=/\s/,a=b.Pos;b.defineOption("autoCloseBrackets",!1,function(c,a,e){var i,d,l;(e!=b.Init&&e&&c.removeKeyMap("autoCloseBrackets"),a)&&(i="()[]{}''\"\"",d="[]{}",typeof a=="string"?
i=a:typeof a=="object"&&(a.pairs!=null&&(i=a.pairs),a.explode!=null&&(d=a.explode)),l=h(i),d&&(l.Enter=g(d)),c.addKeyMap(l))})});
(function(b){"object"==typeof exports&&"object"==typeof module?b(require("../../lib/codemirror"),require("../fold/xml-fold")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../fold/xml-fold"],b):b(CodeMirror)})(function(b){function k(c){var f,e,i,o,l,j;if(c.getOption("disableInput"))return b.Pass;f=c.listSelections();e=[];for(l=0;l<f.length;l++){if(!f[l].empty())return b.Pass;j=f[l].head;o=c.getTokenAt(j);var q=b.innerMode(c.getMode(),o.state),p=q.state;if("xml"!=q.mode.name||
!p.tagName)return b.Pass;var m=c.getOption("autoCloseTags"),k="html"==q.mode.configuration,q="object"==typeof m&&m.dontCloseTags||k&&d,k="object"==typeof m&&m.indentTags||k&&a,m=p.tagName;if(o.end>j.ch&&(m=m.slice(0,m.length-o.end+j.ch)),i=m.toLowerCase(),!m||"string"==o.type&&(o.end!=j.ch||!/[\"\']/.test(o.string.charAt(o.string.length-1))||1==o.string.length)||"tag"==o.type&&"closeTag"==p.type||o.string.indexOf("/")==o.string.length-1||q&&-1<h(q,i)||g(c,m,j,p,!0))return b.Pass;o=k&&-1<h(k,i);e[l]=
{indent:o,text:">"+(o?"\n\n":"")+"</"+m+">",newPos:o?b.Pos(j.line+1,0):b.Pos(j.line,j.ch+1)}}for(l=f.length-1;0<=l;l--)i=e[l],c.replaceRange(i.text,f[l].head,f[l].anchor,"+insert"),j=c.listSelections().slice(0),j[l]={head:i.newPos,anchor:i.newPos},c.setSelections(j),i.indent&&(c.indentLine(i.newPos.line,null,!0),c.indentLine(i.newPos.line+1,null,!0))}function h(a,f){if(a.indexOf)return a.indexOf(f);for(var e=0,i=a.length;e<i;++e)if(a[e]==f)return e;return-1}function g(a,f,e,i,d){var l,j,q;if(!b.scanForClosingTag||
(l=Math.min(a.lastLine()+1,e.line+500),j=b.scanForClosingTag(a,e,null,l),!j||j.tag!=f))return!1;e=i.context;for(d=d?1:0;e&&e.tagName==f;e=e.prev)++d;e=j.to;for(j=1;j<d;j++){if(q=b.scanForClosingTag(a,e,null,l),!q||q.tag!=f)return!1;e=q.to}return!0}b.defineOption("autoCloseTags",!1,function(a,f,e){if(e!=b.Init&&e&&a.removeKeyMap("autoCloseTags"),f){e={name:"autoCloseTags"};(typeof f!="object"||f.whenClosing)&&(e["'/'"]=function(a){var c;a:{var e,j,f;if(a.getOption("disableInput"))c=b.Pass;else{e=a.listSelections();
j=[];for(f=0;f<e.length;f++){if(!e[f].empty()){c=b.Pass;break a}var d=e[f].head,m=a.getTokenAt(d),h=b.innerMode(a.getMode(),m.state),n=h.state;if(m.type=="string"||m.string.charAt(0)!="<"||m.start!=d.ch-1||h.mode.name!="xml"||!n.context||!n.context.tagName||g(a,n.context.tagName,d,n)){c=b.Pass;break a}j[f]="/"+n.context.tagName+">"}a.replaceSelections(j)}}return c});(typeof f!="object"||f.whenOpening)&&(e["'>'"]=function(a){return k(a)});a.addKeyMap(e)}});var d="area base br col command embed hr img input keygen link meta param source track wbr".split(" "),
a="applet blockquote body button div dl fieldset form frameset h1 h2 h3 h4 h5 h6 head html iframe layer legend object ol p select table ul".split(" ")});
(function(){function b(b){var d=b.getCursor(),a=b.getTokenAt(d),c=CodeMirror.innerMode(b.getMode(),a.state).mode,f,e,i,h;if("comment"==a.type&&c.blockCommentStart&&(e=a.string.indexOf(c.blockCommentEnd),i=b.getRange(CodeMirror.Pos(d.line,0),CodeMirror.Pos(d.line,a.end)),-1==e||e!=a.string.length-c.blockCommentEnd.length))if(0==a.string.indexOf(c.blockCommentStart)){if(f=i.slice(0,a.start),!/^\s*$/.test(f)){f="";for(d=0;d<a.start;++d)f+=" "}}else-1!=(h=i.indexOf(c.blockCommentContinue))&&h+c.blockCommentContinue.length>
a.start&&/^\s*$/.test(i.slice(0,h))&&(f=i.slice(0,h));if(null!=f)b.replaceSelection("\n"+f+c.blockCommentContinue,"end");else return CodeMirror.Pass}for(var k=["clike","css","javascript"],h=0;h<k.length;++h)CodeMirror.extendMode(k[h],{blockCommentStart:"/*",blockCommentEnd:"*/",blockCommentContinue:" * "});CodeMirror.defineOption("continueComments",null,function(h,d,a){a&&a!=CodeMirror.Init&&h.removeKeyMap("continueComment");a={name:"continueComment"};a["string"==typeof d?d:"Enter"]=b;h.addKeyMap(a)})})();
(function(b){"object"==typeof exports&&"object"==typeof module?b(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],b):b(CodeMirror)})(function(b){function k(a,e,d,j){var b=a.getLineHandle(e.line),g=e.ch-1,b=0<=g&&f[b.text.charAt(g)]||f[b.text.charAt(++g)],m,k,n;return b?(m=">"==b.charAt(1)?1:-1,d&&0<m!=(g==e.ch))?null:(k=a.getTokenTypeAt(c(e.line,g+1)),n=h(a,c(e.line,g+(0<m?1:0)),m,k||null,j),null==n)?null:{from:c(e.line,g),to:n&&n.pos,match:n&&
n.ch==b.charAt(0),forward:0<m}:null}function h(a,e,b,j,d){for(var h=d&&d.maxScanLineLength||1E4,m=d&&d.maxScanLines||1E3,g=[],d=d&&d.bracketRegex?d.bracketRegex:/[(){}[\]]/,m=0<b?Math.min(e.line+m,a.lastLine()+1):Math.max(a.firstLine()-1,e.line-m),n,k,t,v,w,u=e.line;u!=m;u+=b)if((n=a.getLine(u),n)&&(k=0<b?0:n.length-1,t=0<b?n.length:-1,!(n.length>h)))for(u==e.line&&(k=e.ch-(0>b?1:0));k!=t;k+=b)if(v=n.charAt(k),d.test(v)&&(void 0===j||a.getTokenTypeAt(c(u,k+1))==j))if(w=f[v],">"==w.charAt(1)==0<b)g.push(v);
else if(g.length)g.pop();else return{pos:c(u,k),ch:v};return u-b==(0<b?a.lastLine():a.firstLine())?!1:null}function g(e,f,b){for(var j=e.state.matchBrackets.maxHighlightLineLength||1E3,d=[],h=e.listSelections(),m,g,n=0;n<h.length;n++)(m=h[n].empty()&&k(e,h[n].head,!1,b))&&e.getLine(m.from.line).length<=j&&(g=m.match?"CodeMirror-matchingbracket":"CodeMirror-nonmatchingbracket",d.push(e.markText(m.from,c(m.from.line,m.from.ch+1),{className:g})),m.to&&e.getLine(m.to.line).length<=j&&d.push(e.markText(m.to,
c(m.to.line,m.to.ch+1),{className:g})));if(d.length)if(a&&e.state.focused&&e.display.input.focus(),b=function(){e.operation(function(){for(var a=0;a<d.length;a++)d[a].clear()})},f)setTimeout(b,800);else return b}function d(a){a.operation(function(){e&&(e(),e=null);e=g(a,!1,a.state.matchBrackets)})}var a=/MSIE \d/.test(navigator.userAgent)&&(null==document.documentMode||8>document.documentMode),c=b.Pos,f={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},e=null;b.defineOption("matchBrackets",
!1,function(a,e,c){if(c&&c!=b.Init&&a.off("cursorActivity",d),e){a.state.matchBrackets=typeof e=="object"?e:{};a.on("cursorActivity",d)}});b.defineExtension("matchBrackets",function(){g(this,!0)});b.defineExtension("findMatchingBracket",function(a,e,c){return k(this,a,e,c)});b.defineExtension("scanForBracket",function(a,e,c,j){return h(this,a,e,c,j)})});
(function(b){"object"==typeof exports&&"object"==typeof module?b(require("../../lib/codemirror"),require("../fold/xml-fold")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../fold/xml-fold"],b):b(CodeMirror)})(function(b){function k(b){b.state.tagHit&&b.state.tagHit.clear();b.state.tagOther&&b.state.tagOther.clear();b.state.tagHit=b.state.tagOther=null}function h(d){d.state.failedTagMatch=!1;d.operation(function(){var a,c,f,e,i;(k(d),d.somethingSelected())||(a=d.getCursor(),
c=d.getViewport(),c.from=Math.min(c.from,a.line),c.to=Math.max(a.line+1,c.to),f=b.findMatchingTag(d,a,c),f)&&(d.state.matchBothTags&&(e="open"==f.at?f.open:f.close,e&&(d.state.tagHit=d.markText(e.from,e.to,{className:"CodeMirror-matchingtag"}))),i="close"==f.at?f.open:f.close,i?d.state.tagOther=d.markText(i.from,i.to,{className:"CodeMirror-matchingtag"}):d.state.failedTagMatch=!0)})}function g(b){b.state.failedTagMatch&&h(b)}b.defineOption("matchTags",!1,function(d,a,c){if(c&&c!=b.Init&&(d.off("cursorActivity",
h),d.off("viewportChange",g),k(d)),a){d.state.matchBothTags=typeof a=="object"&&a.bothTags;d.on("cursorActivity",h);d.on("viewportChange",g);h(d)}});b.commands.toMatchingTag=function(d){var a=b.findMatchingTag(d,d.getCursor()),c;a&&(c="close"==a.at?a.open:a.close,c&&d.extendSelection(c.to,c.from))}});
(function(b){"object"==typeof exports&&"object"==typeof module?b(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],b):b(CodeMirror)})(function(b){b.defineOption("showTrailingSpace",!1,function(k,h,g){g==b.Init&&(g=false);g&&!h?k.removeOverlay("trailingspace"):!g&&h&&k.addOverlay({token:function(b){for(var a=b.string.length,c=a;c&&/\s/.test(b.string.charAt(c-1));--c);return c>b.pos?(b.pos=c,null):(b.pos=a,"trailingspace")},name:"trailingspace"})})});
(function(b){"object"==typeof exports&&"object"==typeof module?b(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],b):b(CodeMirror)})(function(b){function k(a,c,f,e){function d(b){var j=k(a,c),f,i;if(!j||j.to.line-j.from.line<l)return null;f=a.findMarksAt(j.from);for(i=0;i<f.length;++i)if(f[i].__isFold&&"fold"!==e){if(!b)return null;j.cleared=!0;f[i].clear()}return j}var k,l,j,q;if(f&&f.call?(k=f,f=null):k=g(a,f,"rangeFinder"),"number"==typeof c&&
(c=b.Pos(c,0)),l=g(a,f,"minFoldSize"),j=d(!0),g(a,f,"scanUp"))for(;!j&&c.line>a.firstLine();)c=b.Pos(c.line-1,0),j=d(!1);j&&(!j.cleared&&"unfold"!==e)&&(f=h(a,f),b.on(f,"mousedown",function(a){q.clear();b.e_preventDefault(a)}),q=a.markText(j.from,j.to,{replacedWith:f,clearOnEnter:!0,__isFold:!0}),q.on("clear",function(e,c){b.signal(a,"unfold",a,e,c)}),b.signal(a,"fold",a,j.from,j.to))}function h(a,c){var b=g(a,c,"widget"),e;return"string"==typeof b&&(e=document.createTextNode(b),b=document.createElement("span"),
b.appendChild(e),b.className="CodeMirror-foldmarker"),b}function g(a,c,b){return c&&void 0!==c[b]?c[b]:(a=a.options.foldOptions)&&void 0!==a[b]?a[b]:d[b]}b.newFoldFunction=function(a,b){return function(f,e){k(f,e,{rangeFinder:a,widget:b})}};b.defineExtension("foldCode",function(a,b,f){k(this,a,b,f)});b.defineExtension("isFolded",function(a){for(var a=this.findMarksAt(a),b=0;b<a.length;++b)if(a[b].__isFold)return!0});b.commands.toggleFold=function(a){a.foldCode(a.getCursor())};b.commands.fold=function(a){a.foldCode(a.getCursor(),
null,"fold")};b.commands.unfold=function(a){a.foldCode(a.getCursor(),null,"unfold")};b.commands.foldAll=function(a){a.operation(function(){for(var c=a.firstLine(),f=a.lastLine();c<=f;c++)a.foldCode(b.Pos(c,0),null,"fold")})};b.commands.unfoldAll=function(a){a.operation(function(){for(var c=a.firstLine(),f=a.lastLine();c<=f;c++)a.foldCode(b.Pos(c,0),null,"unfold")})};b.registerHelper("fold","combine",function(){var a=Array.prototype.slice.call(arguments,0);return function(b,f){for(var e,d=0;d<a.length;++d)if(e=
a[d](b,f),e)return e}});b.registerHelper("fold","auto",function(a,b){for(var d=a.getHelpers(b,"fold"),e,i=0;i<d.length;i++)if(e=d[i](a,b),e)return e});var d={rangeFinder:b.fold.auto,widget:"↔",minFoldSize:0,scanUp:!1};b.defineOption("foldOptions",null)});
(function(b){"object"==typeof exports&&"object"==typeof module?b(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],b):b(CodeMirror)})(function(b){b.registerHelper("fold","brace",function(k,h){function g(e){for(var j,f=h.ch,i=0;;)if(j=0>=f?-1:a.lastIndexOf(e,f-1),-1==j){if(1==i)break;i=1;f=a.length}else{if(1==i&&j<h.ch)break;if(c=k.getTokenTypeAt(b.Pos(d,j+1)),!/^(comment|string)/.test(c))return j+1;f=j-1}}var d=h.line,a=k.getLine(d),c,f="{",e="}",
i=g("{"),o,l,j,q,p,m,r,n,s;if(null==i&&(f="[",e="]",i=g("[")),null!=i){o=1;l=k.lastLine();p=d;a:for(;p<=l;++p){m=k.getLine(p);for(r=p==d?i:0;!(n=m.indexOf(f,r),s=m.indexOf(e,r),0>n&&(n=m.length),0>s&&(s=m.length),r=Math.min(n,s),r==m.length);){if(k.getTokenTypeAt(b.Pos(p,r+1))==c)if(r==n)++o;else if(!--o){j=p;q=r;break a}++r}}if(null!=j&&(d!=j||q!=i))return{from:b.Pos(d,i),to:b.Pos(j,q)}}});b.registerHelper("fold","import",function(k,h){function g(a){var e,c,d,h;if(a<k.firstLine()||a>k.lastLine()||
(e=k.getTokenAt(b.Pos(a,1)),/\S/.test(e.string)||(e=k.getTokenAt(b.Pos(a,e.end+1))),"keyword"!=e.type||"import"!=e.string))return null;c=a;for(a=Math.min(k.lastLine(),a+10);c<=a;++c)if(d=k.getLine(c),h=d.indexOf(";"),-1!=h)return{startCh:e.end,end:b.Pos(c,h)}}var h=h.line,d=g(h),a,c;if(!d||g(h-1)||(a=g(h-2))&&a.end.line==h-1)return null;for(a=d.end;!(c=g(a.line+1),null==c);)a=c.end;return{from:k.clipPos(b.Pos(h,d.startCh+1)),to:a}});b.registerHelper("fold","include",function(k,h){function g(a){if(a<
k.firstLine()||a>k.lastLine())return null;var e=k.getTokenAt(b.Pos(a,1));return/\S/.test(e.string)||(e=k.getTokenAt(b.Pos(a,e.end+1))),"meta"==e.type&&"#include"==e.string.slice(0,8)?e.start+8:void 0}var h=h.line,d=g(h),a,c;if(null==d||null!=g(h-1))return null;for(a=h;!(c=g(a+1),null==c);)++a;return{from:b.Pos(h,d+1),to:k.clipPos(b.Pos(a))}})});
(function(b){"object"==typeof exports&&"object"==typeof module?b(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],b):b(CodeMirror)})(function(b){function k(a,b,e,c){this.line=b;this.ch=e;this.cm=a;this.text=a.getLine(b);this.min=c?c.from:a.firstLine();this.max=c?c.to-1:a.lastLine()}function h(a,b){var e=a.cm.getTokenTypeAt(o(a.line,b));return e&&/\btag\b/.test(e)}function g(a){if(!(a.line>=a.max))return a.ch=0,a.text=a.cm.getLine(++a.line),!0}
function d(a){if(!(a.line<=a.min))return a.text=a.cm.getLine(--a.line),a.ch=a.text.length,!0}function a(a){for(var b,e,c;;){if(b=a.text.indexOf(">",a.ch),-1==b)if(g(a))continue;else break;if(h(a,b+1))return e=a.text.lastIndexOf("/",b),c=-1<e&&!/\S/.test(a.text.slice(e+1,b)),a.ch=b+1,c?"selfClose":"regular";a.ch=b+1}}function c(a){for(var b,e;;){if(b=a.ch?a.text.lastIndexOf("<",a.ch-1):-1,-1==b)if(d(a))continue;else break;if(h(a,b+1)){if(l.lastIndex=b,a.ch=b,e=l.exec(a.text),e&&e.index==b)return e}else a.ch=
b}}function f(a){for(;;){l.lastIndex=a.ch;var b=l.exec(a.text);if(!b)if(g(a))continue;else break;if(h(a,b.index+1))return a.ch=b.index+b[0].length,b;a.ch=b.index+1}}function e(b,e){for(var c=[],d;;){var i=f(b),h,g=b.line,k=b.ch-(i?i[0].length:0);if(!i||!(h=a(b)))break;if("selfClose"!=h)if(i[1]){for(d=c.length-1;0<=d;--d)if(c[d]==i[2]){c.length=d;break}if(0>d&&(!e||e==i[2]))return{tag:i[2],from:o(g,k),to:o(b.line,b.ch)}}else c.push(i[2])}}function i(a,b){for(var e=[],f,i;;){var g;a:{g=a;for(var k=
void 0,l=i=void 0;;){if(k=g.ch?g.text.lastIndexOf(">",g.ch-1):-1,-1==k)if(d(g))continue;else{g=void 0;break a}if(h(g,k+1)){g=(i=g.text.lastIndexOf("/",k),l=-1<i&&!/\S/.test(g.text.slice(i+1,k)),g.ch=k+1,l?"selfClose":"regular");break a}else g.ch=k}g=void 0}if(f=g,!f)break;if("selfClose"==f)c(a);else{l=a.line;g=a.ch;k=c(a);if(!k)break;if(k[1])e.push(k[2]);else{for(i=e.length-1;0<=i;--i)if(e[i]==k[2]){e.length=i;break}if(0>i&&(!b||b==k[2]))return{tag:k[2],from:o(a.line,a.ch),to:o(l,g)}}}}}var o=b.Pos,
l=RegExp("<(/?)([A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*)","g");b.registerHelper("fold","xml",function(b,c){for(var d=new k(b,c.line,0),i,g,h;!(i=f(d),
!i||d.line!=c.line||!(g=a(d)));)if(!i[1]&&"selfClose"!=g)return c=o(d.line,d.ch),h=e(d,i[2]),h&&{from:c,to:h.from}});b.findMatchingTag=function(b,d,f){var g=new k(b,d.line,d.ch,f),h;if(-1!=g.text.indexOf(">")||-1!=g.text.indexOf("<")){var l=a(g),s=l&&o(g.line,g.ch),t=l&&c(g);if(l&&"selfClose"!=l&&t&&!(0<(g.line-d.line||g.ch-d.ch)))return h={from:o(g.line,g.ch),to:s,tag:t[2]},t[1]?{open:i(g,t[2]),close:h,at:"close"}:(g=new k(b,s.line,s.ch,f),{open:h,close:e(g,t[2]),at:"open"})}};b.findEnclosingTag=
function(a,b,c){for(var d=new k(a,b.line,b.ch,c),f,g,h;!(f=i(d),!f);)if(g=new k(a,b.line,b.ch,c),h=e(g,f.tag),h)return{open:f,close:h}};b.scanForClosingTag=function(a,b,c,d){a=new k(a,b.line,b.ch,d?{from:0,to:d}:null);return e(a,c)}});
(function(){CodeMirror.defineExtension("autoFormatAll",function(b,k){for(var h=this,g=h.getMode(),d=h.getRange(b,k).split("\n"),a=CodeMirror.copyState(g,h.getTokenAt(b).state),c=h.getOption("tabSize"),f="",e=0,i=0==b.ch,o,l=0;l<d.length;++l){for(o=new CodeMirror.StringStream(d[l],c);!o.eol();){var j=CodeMirror.innerMode(g,a),q=g.token(o,a),p=o.current();o.start=o.pos;(!i||/\S/.test(p))&&(f+=p,i=!1);if(!i&&j.mode.newlineAfterToken&&j.mode.newlineAfterToken(q,p,o.string.slice(o.pos)||d[l+1]||"",j.state))f+=
"\n",i=!0,++e}!o.pos&&g.blankLine&&g.blankLine(a);!i&&l<d.length-1&&(f+="\n",i=!0,++e)}h.operation(function(){h.replaceRange(f,b,k);for(var a=b.line+1,c=b.line+e;a<=c;++a)h.indentLine(a,"smart");h.setCursor({line:0,ch:0})})})})();
(function(){function b(b){for(var h=[/for\s*?\((.*?)\)/g,/&#?[a-z0-9]+;[\s\S]/g,/\"(.*?)((\")|$)/g,/\/\*(.*?)(\*\/|$)/g,/^\/\/.*/g],g=[],d,a,c=0;c<h.length;c++)for(d=0;d<b.length;)if(a=b.substr(d).match(h[c]),null!=a)g.push({start:d+a.index,end:d+a.index+a[0].length}),d+=a.index+Math.max(1,a[0].length);else break;return g.sort(function(a,b){return a.start-b.start}),g}CodeMirror.extendMode("css",{commentStart:"/*",commentEnd:"*/",newlineAfterToken:function(b,h){return/^[;{}]$/.test(h)}});CodeMirror.extendMode("javascript",
{commentStart:"/*",commentEnd:"*/",wordWrapChars:[";","\\{","\\}"],autoFormatLineBreaks:function(k){var h=0,g=this.jsonMode?function(a){return a.replace(/([,{])/g,"$1\n").replace(/}/g,"\n}")}:function(a){return a.replace(/(;|\{|\})([^\r\n;])/g,"$1\n$2")},d=b(k),a="",c;if(null!=d){for(c=0;c<d.length;c++)d[c].start>h&&(a+=g(k.substring(h,d[c].start)),h=d[c].start),d[c].start<=h&&d[c].end>=h&&(a+=k.substring(h,d[c].end),h=d[c].end);h<k.length&&(a+=g(k.substr(h)))}else a=g(k);return a.replace(/^\n*|\n*$/,
"")}});CodeMirror.extendMode("xml",{commentStart:"<\!--",commentEnd:"--\>",noBreak:!1,noBreakEmpty:null,tagType:"",tagName:"",isXML:!1,newlineAfterToken:function(b,h,g){var d=!1,a=null,c="",f;if(this.isXML="xml"==this.configuration?!0:!1,"comment"==b||/<\!--/.test(g))return!1;if("tag"==b){if(0==h.indexOf("<")&&0==!h.indexOf("</")&&(this.tagType="open",a=h.match(/^<\s*?([\w]+?)$/i),this.tagName=null!=a?a[1]:"",c=this.tagName.toLowerCase(),-1!="|label|li|option|textarea|title|a|b|bdi|bdo|big|center|cite|del|em|font|i|img|ins|s|small|span|strike|strong|sub|sup|u|".indexOf("|"+
c+"|")&&(this.noBreak=!0)),0==h.indexOf(">")&&"open"==this.tagType)return(this.tagType="",f=this.isXML?"[^<]*?":"",RegExp("^"+f+"</s*?"+this.tagName+"s*?>","i").test(g))?(this.noBreak=!1,this.isXML||(this.tagName=""),!1):(d=this.noBreak,this.noBreak=!1,d?!1:!0);if(0==h.indexOf("</")&&(this.tagType="close",a=h.match(/^<\/\s*?([\w]+?)$/i),null!=a&&(c=a[1].toLowerCase()),-1!="|a|b|bdi|bdo|big|center|cite|del|em|font|i|img|ins|s|small|span|strike|strong|sub|sup|u|".indexOf("|"+c+"|")&&(this.noBreak=!0)),
0==h.indexOf(">")&&"close"==this.tagType)return(this.tagType="",0==g.indexOf("<")&&(a=g.match(/^<\/?\s*?([\w]+?)(\s|>)/i),c=null!=a?a[1].toLowerCase():"",-1=="|label|li|option|textarea|title|a|b|bdi|bdo|big|center|cite|del|em|font|i|img|ins|s|small|span|strike|strong|sub|sup|u|".indexOf("|"+c+"|")))?(this.noBreak=!1,!0):(d=this.noBreak,this.noBreak=!1,d?!1:!0)}return 0==g.indexOf("<")?(this.noBreak=!1,this.isXML&&""!=this.tagName)?(this.tagName="",!1):(a=g.match(/^<\/?\s*?([\w]+?)(\s|>)/i),c=null!=
a?a[1].toLowerCase():"",-1!="|label|li|option|textarea|title|a|b|bdi|bdo|big|center|cite|del|em|font|i|img|ins|s|small|span|strike|strong|sub|sup|u|".indexOf("|"+c+"|")?!1:!0):!1}});CodeMirror.defineExtension("commentRange",function(b,h,g){var d=this,a=CodeMirror.innerMode(d.getMode(),d.getTokenAt(h).state).mode;d.operation(function(){if(b)d.replaceRange(a.commentEnd,g),d.replaceRange(a.commentStart,h),h.line==g.line&&h.ch==g.ch&&d.setCursor(h.line,h.ch+a.commentStart.length);else{var c=d.getRange(h,
g),f=c.indexOf(a.commentStart),e=c.lastIndexOf(a.commentEnd);-1<f&&-1<e&&e>f&&(c=c.substr(0,f)+c.substring(f+a.commentStart.length,e)+c.substr(e+a.commentEnd.length));d.replaceRange(c,h,g)}})});CodeMirror.defineExtension("autoIndentRange",function(b,h){var g=this;this.operation(function(){for(var d=b.line;d<=h.line;d++)g.indentLine(d,"smart")})});CodeMirror.defineExtension("autoFormatRange",function(b,h){for(var g=this,d=g.getMode(),a=g.getRange(b,h).split("\n"),c=CodeMirror.copyState(d,g.getTokenAt(b).state),
f=g.getOption("tabSize"),e="",i=0,o=0==b.ch,l,j=0;j<a.length;++j){for(l=new CodeMirror.StringStream(a[j],f);!l.eol();){var q=CodeMirror.innerMode(d,c),p=d.token(l,c),m=l.current();l.start=l.pos;(!o||/\S/.test(m))&&(e+=m,o=!1);if(!o&&q.mode.newlineAfterToken&&q.mode.newlineAfterToken(p,m,l.string.slice(l.pos)||a[j+1]||"",q.state))e+="\n",o=!0,++i}!l.pos&&d.blankLine&&d.blankLine(c);!o&&j<a.length-1&&(e+="\n",o=!0,++i)}g.operation(function(){g.replaceRange(e,b,h);for(var a=b.line+1,c=b.line+i;a<=c;++a)g.indentLine(a,
"smart");g.setSelection(b,g.getCursor(!1))})})})();
(function(b){"object"==typeof exports&&"object"==typeof module?b(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],b):b(CodeMirror)})(function(b){function k(b){"object"==typeof b&&(this.minChars=b.minChars,this.style=b.style,this.showToken=b.showToken,this.delay=b.delay);null==this.style&&(this.style=c);null==this.minChars&&(this.minChars=a);null==this.delay&&(this.delay=f);this.overlay=this.timeout=null}function h(a){var b=a.state.matchHighlighter;
clearTimeout(b.timeout);b.timeout=setTimeout(function(){g(a)},b.delay)}function g(a){a.operation(function(){var b=a.state.matchHighlighter,c,f,g;if(b.overlay&&(a.removeOverlay(b.overlay),b.overlay=null),!a.somethingSelected()&&b.showToken){c=!0===b.showToken?/[\w$]/:b.showToken;g=a.getCursor();f=a.getLine(g.line);for(var h=g=g.ch;g&&c.test(f.charAt(g-1));)--g;for(;h<f.length&&c.test(f.charAt(h));)++h;g<h&&a.addOverlay(b.overlay=d(f.slice(g,h),c,b.style))}else(c=a.getCursor("from"),f=a.getCursor("to"),
c.line==f.line)&&(g=a.getRange(c,f).replace(/^\s+|\s+$/g,""),g.length>=b.minChars&&a.addOverlay(b.overlay=d(g,!1,b.style)))})}function d(a,b,c){return{token:function(d){if(d.match(a)&&(!b||(!d.start||!b.test(d.string.charAt(d.start-1)))&&(d.pos==d.string.length||!b.test(d.string.charAt(d.pos)))))return c;d.next();d.skipTo(a.charAt(0))||d.skipToEnd()}}}var a=2,c="matchhighlight",f=100;b.defineOption("highlightSelectionMatches",!1,function(a,c,d){if(d&&d!=b.Init){(d=a.state.matchHighlighter.overlay)&&
a.removeOverlay(d);clearTimeout(a.state.matchHighlighter.timeout);a.state.matchHighlighter=null;a.off("cursorActivity",h)}if(c){a.state.matchHighlighter=new k(c);g(a);a.on("cursorActivity",h)}})});