You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
easy-markdown-editor/dist/simplemde.min.js

13 lines
213 KiB
JavaScript

/**
* simplemde v1.7.1
* Copyright Next Step Webs, Inc.
* @link https://github.com/NextStepWebs/simplemde-markdown-editor
* @license MIT
*/
function fixShortcut(e){return e=isMac?e.replace("Ctrl","Cmd"):e.replace("Cmd","Ctrl")}function createIcon(e,t){e=e||{};var r=document.createElement("a");return t=void 0==t?!0:t,e.title&&t&&(r.title=e.title,isMac&&(r.title=r.title.replace("Ctrl","⌘"),r.title=r.title.replace("Alt","⌥"))),r.className=e.className,r}function createSep(){return el=document.createElement("i"),el.className="separator",el.innerHTML="|",el}function getState(e,t){t=t||e.getCursor("start");var r=e.getTokenAt(t);if(!r.type)return{};for(var n,i,o=r.type.split(" "),l={},a=0;a<o.length;a++)n=o[a],"strong"===n?l.bold=!0:"variable-2"===n?(i=e.getLine(t.line),/^\s*\d+\.\s/.test(i)?l["ordered-list"]=!0:l["unordered-list"]=!0):"atom"===n?l.quote=!0:"em"===n?l.italic=!0:"quote"===n?l.quote=!0:"strikethrough"===n?l.strikethrough=!0:"comment"===n&&(l.code=!0);return l}function toggleFullScreen(e){var t=e.codemirror;t.setOption("fullScreen",!t.getOption("fullScreen")),t.getOption("fullScreen")?(saved_overflow=document.body.style.overflow,document.body.style.overflow="hidden"):document.body.style.overflow=saved_overflow;var r=t.getWrapperElement();/fullscreen/.test(r.previousSibling.className)?r.previousSibling.className=r.previousSibling.className.replace(/\s*fullscreen\b/,""):r.previousSibling.className+=" fullscreen";var n=e.toolbarElements.fullscreen;/active/.test(n.className)?n.className=n.className.replace(/\s*active\s*/g,""):n.className+=" active";var i=t.getWrapperElement().nextSibling;/editor-preview-active-side/.test(i.className)&&toggleSideBySide(e)}function toggleBold(e){_toggleBlock(e,"bold","**")}function toggleItalic(e){_toggleBlock(e,"italic","*")}function toggleStrikethrough(e){_toggleBlock(e,"strikethrough","~~")}function toggleCodeBlock(e){_toggleBlock(e,"code","```\r\n","\r\n```")}function toggleBlockquote(e){var t=e.codemirror;_toggleLine(t,"quote")}function toggleHeadingSmaller(e){var t=e.codemirror;_toggleHeading(t,"smaller")}function toggleHeadingBigger(e){var t=e.codemirror;_toggleHeading(t,"bigger")}function toggleHeading1(e){var t=e.codemirror;_toggleHeading(t,void 0,1)}function toggleHeading2(e){var t=e.codemirror;_toggleHeading(t,void 0,2)}function toggleHeading3(e){var t=e.codemirror;_toggleHeading(t,void 0,3)}function toggleUnorderedList(e){var t=e.codemirror;_toggleLine(t,"unordered-list")}function toggleOrderedList(e){var t=e.codemirror;_toggleLine(t,"ordered-list")}function drawLink(e){var t=e.codemirror,r=getState(t);_replaceSelection(t,r.link,"[","](http://)")}function drawImage(e){var t=e.codemirror,r=getState(t);_replaceSelection(t,r.image,"![](http://",")")}function drawHorizontalRule(e){var t=e.codemirror,r=getState(t);_replaceSelection(t,r.image,"","\n\n-----\n\n")}function undo(e){var t=e.codemirror;t.undo(),t.focus()}function redo(e){var t=e.codemirror;t.redo(),t.focus()}function toggleSideBySide(e){var t=e.codemirror,r=t.getWrapperElement(),n=(r.firstChild,r.nextSibling),i=e.toolbarElements["side-by-side"];/editor-preview-active-side/.test(n.className)?(n.className=n.className.replace(/\s*editor-preview-active-side\s*/g,""),i.className=i.className.replace(/\s*active\s*/g,""),r.className=r.className.replace(/\s*CodeMirror-sided\s*/g," ")):(setTimeout(function(){t.getOption("fullScreen")||toggleFullScreen(e),n.className+=" editor-preview-active-side"},1),i.className+=" active",r.className+=" CodeMirror-sided");var o=r.lastChild;if(/editor-preview-active/.test(o.className)){o.className=o.className.replace(/\s*editor-preview-active\s*/g,"");var l=e.toolbarElements.preview,a=r.previousSibling;l.className=l.className.replace(/\s*active\s*/g,""),a.className=a.className.replace(/\s*disabled-for-preview*/g,"")}n.innerHTML=e.options.previewRender(e.value(),n),t.on("update",function(){n.innerHTML=e.options.previewRender(e.value(),n)})}function togglePreview(e){var t=e.codemirror,r=t.getWrapperElement(),n=r.previousSibling,i=e.toolbarElements.preview,o=r.lastChild;o&&/editor-preview/.test(o.className)||(o=document.createElement("div"),o.className="editor-preview",r.appendChild(o)),/editor-preview-active/.test(o.className)?(o.
i[o]=new de(a,s))}return i?fe(i,t.primIndex):t}function Oe(e,t,r,n){var i=!1,o=t,l=r||1;e.cantEdit=!1;e:for(;;){var a=Yn(e,o.line);if(a.markedSpans)for(var s=0;s<a.markedSpans.length;++s){var u=a.markedSpans[s],c=u.marker;if((null==u.from||(c.inclusiveLeft?u.from<=o.ch:u.from<o.ch))&&(null==u.to||(c.inclusiveRight?u.to>=o.ch:u.to>o.ch))){if(n&&(Tl(c,"beforeCursorEnter"),c.explicitlyCleared)){if(a.markedSpans){--s;continue}break}if(!c.atomic)continue;var h=c.find(0>l?-1:1);if(0==Wo(h,o)&&(h.ch+=l,h.ch<0?h=h.line>e.first?me(e,Eo(h.line-1)):null:h.ch>a.text.length&&(h=h.line<e.first+e.size-1?Eo(h.line+1,0):null),!h)){if(i)return n?(e.cantEdit=!0,Eo(e.first,0)):Oe(e,t,r,!0);i=!0,h=t,l=-l}o=h;continue e}}return o}}function Ee(e){e.display.input.showSelection(e.display.input.prepareSelection())}function We(e,t){for(var r=e.doc,n={},i=n.cursors=document.createDocumentFragment(),o=n.selection=document.createDocumentFragment(),l=0;l<r.sel.ranges.length;l++)if(t!==!1||l!=r.sel.primIndex){var a=r.sel.ranges[l],s=a.empty();(s||e.options.showCursorWhenSelecting)&&Ie(e,a.head,i),s||Pe(e,a,o)}return n}function Ie(e,t,r){var n=dt(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),i=r.appendChild(Bi("div"," ","CodeMirror-cursor"));if(i.style.left=n.left+"px",i.style.top=n.top+"px",i.style.height=Math.max(0,n.bottom-n.top)*e.options.cursorHeight+"px",n.other){var o=r.appendChild(Bi("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));o.style.display="",o.style.left=n.other.left+"px",o.style.top=n.other.top+"px",o.style.height=.85*(n.other.bottom-n.other.top)+"px"}}function Pe(e,t,r){function n(e,t,r,n){0>t&&(t=0),t=Math.round(t),n=Math.round(n),a.appendChild(Bi("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(null==r?c-e:r)+"px; height: "+(n-t)+"px"))}function i(t,r,i){function o(r,n){return ht(e,Eo(t,r),"div",h,n)}var a,s,h=Yn(l,t),d=h.text.length;return Qi(ni(h),r||0,null==i?d:i,function(e,t,l){var h,f,p,g=o(e,"left");if(e==t)h=g,f=p=g.left;else{if(h=o(t-1,"right"),"rtl"==l){var m=g;g=h,h=m}f=g.left,p=h.right}null==r&&0==e&&(f=u),h.top-g.top>3&&(n(f,g.top,null,g.bottom),f=u,g.bottom<h.top&&n(f,g.bottom,null,h.top)),null==i&&t==d&&(p=c),(!a||g.top<a.top||g.top==a.top&&g.left<a.left)&&(a=g),(!s||h.bottom>s.bottom||h.bottom==s.bottom&&h.right>s.right)&&(s=h),u+1>f&&(f=u),n(f,h.top,p-f,h.bottom)}),{start:a,end:s}}var o=e.display,l=e.doc,a=document.createDocumentFragment(),s=Ge(e.display),u=s.left,c=Math.max(o.sizerWidth,je(e)-o.sizer.offsetLeft)-s.right,h=t.from(),d=t.to();if(h.line==d.line)i(h.line,h.ch,d.ch);else{var f=Yn(l,h.line),p=Yn(l,d.line),g=vn(f)==vn(p),m=i(h.line,h.ch,g?f.text.length+1:null).end,v=i(d.line,g?0:null,d.ch).start;g&&(m.top<v.top-2?(n(m.right,m.top,null,m.bottom),n(u,v.top,v.left,v.bottom)):n(m.right,m.top,v.left-m.right,m.bottom)),m.bottom<v.top&&n(u,m.bottom,null,v.top)}r.appendChild(a)}function Fe(e){if(e.state.focused){var t=e.display;clearInterval(t.blinker);var r=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function _e(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,Pi(ze,e))}function ze(e){var t=e.doc;if(t.frontier<t.first&&(t.frontier=t.first),!(t.frontier>=e.display.viewTo)){var r=+new Date+e.options.workTime,n=nl(t.mode,Re(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(t.frontier>=e.display.viewFrom){var l=o.styles,a=o.text.length>e.options.maxHighlightLength,s=En(e,o,a?nl(t.mode,n):n,!0);o.styles=s.styles;var u=o.styleClasses,c=s.classes;c?o.styleClasses=c:u&&(o.styleClasses=null);for(var h=!l||l.length!=o.styles.length||u!=c&&(!u||!c||u.bgClass!=c.bgClass||u.textClass!=c.textClass),d=0;!h&&d<l.length;++d)h=l[d]!=o.styles[d];h&&i.push(t.frontier),o.stateAfter=a?n:nl(t.mode,n)}else o.text.length<=e.options.maxHighlightLength&&In(e,o.text,n),o.stateAfter=t.frontier%5==
e.state.focused=!0,jl(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),vo&&setTimeout(function(){e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Fe(e))}function mr(e){e.state.delayingBlurEvent||(e.state.focused&&(Tl(e,"blur",e),e.state.focused=!1,$l(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function vr(e,t){Gt(e.display,t)||yr(e,t)||e.display.input.onContextMenu(t)}function yr(e,t){return Mi(e,"gutterContextMenu")?Yt(e,t,"gutterContextMenu",!1,Tl):!1}function br(e,t){if(Wo(e,t.from)<0)return e;if(Wo(e,t.to)<=0)return Ko(t);var r=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;return e.line==t.to.line&&(n+=Ko(t).ch-t.to.ch),Eo(r,n)}function xr(e,t){for(var r=[],n=0;n<e.sel.ranges.length;n++){var i=e.sel.ranges[n];r.push(new de(br(i.anchor,t),br(i.head,t)))}return fe(r,e.sel.primIndex)}function wr(e,t,r){return e.line==t.line?Eo(r.line,e.ch-t.ch+r.ch):Eo(r.line+(e.line-t.line),e.ch)}function Cr(e,t,r){for(var n=[],i=Eo(e.first,0),o=i,l=0;l<t.length;l++){var a=t[l],s=wr(a.from,i,o),u=wr(Ko(a),i,o);if(i=a.to,o=u,"around"==r){var c=e.sel.ranges[l],h=Wo(c.head,c.anchor)<0;n[l]=new de(h?u:s,h?s:u)}else n[l]=new de(s,s)}return new he(n,e.sel.primIndex)}function Sr(e,t,r){var n={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return r&&(n.update=function(t,r,n,i){t&&(this.from=me(e,t)),r&&(this.to=me(e,r)),n&&(this.text=n),void 0!==i&&(this.origin=i)}),Tl(e,"beforeChange",e,n),e.cm&&Tl(e.cm,"beforeChange",e.cm,n),n.canceled?null:{from:n.from,to:n.to,text:n.text,origin:n.origin}}function kr(e,t,r){if(e.cm){if(!e.cm.curOp)return At(e.cm,kr)(e,t,r);if(e.cm.state.suppressEdits)return}if(!(Mi(e,"beforeChange")||e.cm&&Mi(e.cm,"beforeChange"))||(t=Sr(e,t,!0))){var n=Do&&!r&&an(e,t.from,t.to);if(n)for(var i=n.length-1;i>=0;--i)Lr(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text});else Lr(e,t)}}function Lr(e,t){if(1!=t.text.length||""!=t.text[0]||0!=Wo(t.from,t.to)){var r=xr(e,t);si(e,t,r,e.cm?e.cm.curOp.id:NaN),Nr(e,t,r,nn(e,t));var n=[];Kn(e,function(e,r){r||-1!=Di(n,e.history)||(yi(e.history,t),n.push(e.history)),Nr(e,t,null,nn(e,t))})}}function Mr(e,t,r){if(!e.cm||!e.cm.state.suppressEdits){for(var n,i=e.history,o=e.sel,l="undo"==t?i.done:i.undone,a="undo"==t?i.undone:i.done,s=0;s<l.length&&(n=l[s],r?!n.ranges||n.equals(e.sel):n.ranges);s++);if(s!=l.length){for(i.lastOrigin=i.lastSelOrigin=null;n=l.pop(),n.ranges;){if(hi(n,a),r&&!n.equals(e.sel))return void Te(e,n,{clearRedo:!1});o=n}var u=[];hi(o,a),a.push({changes:u,generation:i.generation}),i.generation=n.generation||++i.maxGeneration;for(var c=Mi(e,"beforeChange")||e.cm&&Mi(e.cm,"beforeChange"),s=n.changes.length-1;s>=0;--s){var h=n.changes[s];if(h.origin=t,c&&!Sr(e,h,!1))return void(l.length=0);u.push(oi(e,h));var d=s?xr(e,h):Hi(l);Nr(e,h,d,ln(e,h)),!s&&e.cm&&e.cm.scrollIntoView({from:h.from,to:Ko(h)});var f=[];Kn(e,function(e,t){t||-1!=Di(f,e.history)||(yi(e.history,h),f.push(e.history)),Nr(e,h,null,ln(e,h))})}}}}function Tr(e,t){if(0!=t&&(e.first+=t,e.sel=new he(Oi(e.sel.ranges,function(e){return new de(Eo(e.anchor.line+t,e.anchor.ch),Eo(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){Wt(e.cm,e.first,e.first-t,t);for(var r=e.cm.display,n=r.viewFrom;n<r.viewTo;n++)It(e.cm,n,"gutter")}}function Nr(e,t,r,n){if(e.cm&&!e.cm.curOp)return At(e.cm,Nr)(e,t,r,n);if(t.to.line<e.first)return void Tr(e,t.text.length-1-(t.to.line-t.from.line));if(!(t.from.line>e.lastLine())){if(t.from.line<e.first){var i=t.text.length-1-(e.first-t.from.line);Tr(e,i),t={from:Eo(e.first,0),to:Eo(t.to.line+i,t.to.ch),text:[Hi(t.text)],origin:t.origin}}var o=e.lastLine();t.to.line>o&&(t={from:t.from,to:Eo(o,Yn(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Zn(e,t.from,t.to),r||(r=xr(e,t)),e.cm?Ar(e.cm,t,n):$n(e,t,n),Ne(e,r,Dl)}}function Ar(e,t,r){var n=e.doc,i=e.display,l=t.from,a=t.to,s=!1,u=l.line;e.options.lineWrapping||(u=ei(vn(Yn(n,l.line))),n.iter(u,a.lin
return Pl[e]}function Hi(e){return e[e.length-1]}function Di(e,t){for(var r=0;r<e.length;++r)if(e[r]==t)return r;return-1}function Oi(e,t){for(var r=[],n=0;n<e.length;n++)r[n]=t(e[n],n);return r}function Ei(){}function Wi(e,t){var r;return Object.create?r=Object.create(e):(Ei.prototype=e,r=new Ei),t&&Ii(t,r),r}function Ii(e,t,r){t||(t={});for(var n in e)!e.hasOwnProperty(n)||r===!1&&t.hasOwnProperty(n)||(t[n]=e[n]);return t}function Pi(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function Fi(e,t){return t?t.source.indexOf("\\w")>-1&&Bl(e)?!0:t.test(e):Bl(e)}function _i(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function zi(e){return e.charCodeAt(0)>=768&&Rl.test(e)}function Bi(e,t,r,n){var i=document.createElement(e);if(r&&(i.className=r),n&&(i.style.cssText=n),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o<t.length;++o)i.appendChild(t[o]);return i}function Ri(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function qi(e,t){return Ri(e).appendChild(t)}function Ui(){for(var e=document.activeElement;e&&e.root&&e.root.activeElement;)e=e.root.activeElement;return e}function Gi(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function $i(e,t){for(var r=e.split(" "),n=0;n<r.length;n++)r[n]&&!Gi(r[n]).test(t)&&(t+=" "+r[n]);return t}function ji(e){if(document.body.getElementsByClassName)for(var t=document.body.getElementsByClassName("CodeMirror"),r=0;r<t.length;r++){var n=t[r].CodeMirror;n&&e(n)}}function Vi(){Vl||(Ki(),Vl=!0)}function Ki(){var e;Ll(window,"resize",function(){null==e&&(e=setTimeout(function(){e=null,ji(Ut)},100))}),Ll(window,"blur",function(){ji(mr)})}function Xi(e){if(null==Ul){var t=Bi("span","");qi(e,Bi("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(Ul=t.offsetWidth<=1&&t.offsetHeight>2&&!(go&&8>mo))}var r=Ul?Bi("span",""):Bi("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return r.setAttribute("cm-text",""),r}function Yi(e){if(null!=Gl)return Gl;var t=qi(e,document.createTextNode("AخA")),r=_l(t,0,1).getBoundingClientRect();if(!r||r.left==r.right)return!1;var n=_l(t,1,2).getBoundingClientRect();return Gl=n.right-r.right<3}function Zi(e){if(null!=Ql)return Ql;var t=qi(e,Bi("span","x")),r=t.getBoundingClientRect(),n=_l(t,0,1).getBoundingClientRect();return Ql=Math.abs(r.left-n.left)>1}function Qi(e,t,r,n){if(!e)return n(t,r,"ltr");for(var i=!1,o=0;o<e.length;++o){var l=e[o];(l.from<r&&l.to>t||t==r&&l.to==t)&&(n(Math.max(l.from,t),Math.min(l.to,r),1==l.level?"rtl":"ltr"),i=!0)}i||n(t,r,"ltr")}function Ji(e){return e.level%2?e.to:e.from}function eo(e){return e.level%2?e.from:e.to}function to(e){var t=ni(e);return t?Ji(t[0]):0}function ro(e){var t=ni(e);return t?eo(Hi(t)):e.text.length}function no(e,t){var r=Yn(e.doc,t),n=vn(r);n!=r&&(t=ei(n));var i=ni(n),o=i?i[0].level%2?ro(n):to(n):0;return Eo(t,o)}function io(e,t){for(var r,n=Yn(e.doc,t);r=gn(n);)n=r.find(1,!0).line,t=null;var i=ni(n),o=i?i[0].level%2?to(n):ro(n):n.text.length;return Eo(null==t?ei(n):t,o)}function oo(e,t){var r=no(e,t.line),n=Yn(e.doc,r.line),i=ni(n);if(!i||0==i[0].level){var o=Math.max(0,n.text.search(/\S/)),l=t.line==r.line&&t.ch<=o&&t.ch;return Eo(r.line,l?0:o)}return r}function lo(e,t,r){var n=e[0].level;return t==n?!0:r==n?!1:r>t}function ao(e,t){ea=null;for(var r,n=0;n<e.length;++n){var i=e[n];if(i.from<t&&i.to>t)return n;if(i.from==t||i.to==t){if(null!=r)return lo(e,i.level,e[r].level)?(i.from!=i.to&&(ea=r),n):(i.from!=i.to&&(ea=n),r);r=n}}return r}function so(e,t,r,n){if(!n)return t+r;do t+=r;while(t>0&&zi(e.text.charAt(t)));return t}function uo(e,t,r,n){var i=ni(e);if(!i)return co(e,t,r,n);for(var o=ao(i,t),l=i[o],a=so(e,t,l.level%2?-r:r,n);;){if(a>l.from&&a<l.to)return a;if(a==l.from||a==l.to)return ao(i,a)==o?a:(l=i[o+=r],r>0==l.level%2?l.to:l.from);if(l=i[o+=r],!l)return null;a=r>0==l.level%2?so(e,l.to,-1,n):so(e,l.from,1,n)}}function co(e,t,r,n){var i=t+r;if(n)for(;i>0&&zi(e.text.charAt(i));)i+=r;return 0>i||i>e.text.length?null:i}var ho
}),t=Wi(r,t),t.name=r.name}else if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return e.resolveMode("application/xml");return"string"==typeof t?{name:t}:t||{name:"null"}},e.getMode=function(t,r){var r=e.resolveMode(r),n=Qo[r.name];if(!n)return e.getMode(t,"text/plain");var i=n(t,r);if(el.hasOwnProperty(r.name)){var o=el[r.name];for(var l in o)o.hasOwnProperty(l)&&(i.hasOwnProperty(l)&&(i["_"+l]=i[l]),i[l]=o[l])}if(i.name=r.name,r.helperType&&(i.helperType=r.helperType),r.modeProps)for(var l in r.modeProps)i[l]=r.modeProps[l];return i},e.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),e.defineMIME("text/plain","null");var el=e.modeExtensions={};e.extendMode=function(e,t){var r=el.hasOwnProperty(e)?el[e]:el[e]={};Ii(t,r)},e.defineExtension=function(t,r){e.prototype[t]=r},e.defineDocExtension=function(e,t){bl.prototype[e]=t},e.defineOption=Ur;var tl=[];e.defineInitHook=function(e){tl.push(e)};var rl=e.helpers={};e.registerHelper=function(t,r,n){rl.hasOwnProperty(t)||(rl[t]=e[t]={_global:[]}),rl[t][r]=n},e.registerGlobalHelper=function(t,r,n,i){e.registerHelper(t,r,i),rl[t]._global.push({pred:n,val:i})};var nl=e.copyState=function(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var r={};for(var n in t){var i=t[n];i instanceof Array&&(i=i.concat([])),r[n]=i}return r},il=e.startState=function(e,t,r){return e.startState?e.startState(t,r):!0};e.innerMode=function(e,t){for(;e.innerMode;){var r=e.innerMode(t);if(!r||r.mode==e)break;t=r.state,e=r.mode}return r||{mode:e,state:t}};var ol=e.commands={selectAll:function(e){e.setSelection(Eo(e.firstLine(),0),Eo(e.lastLine()),Dl)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Dl)},killLine:function(e){Br(e,function(t){if(t.empty()){var r=Yn(e.doc,t.head.line).text.length;return t.head.ch==r&&t.head.line<e.lastLine()?{from:t.head,to:Eo(t.head.line+1,0)}:{from:t.head,to:Eo(t.head.line,r)}}return{from:t.from(),to:t.to()}})},deleteLine:function(e){Br(e,function(t){return{from:Eo(t.from().line,0),to:me(e.doc,Eo(t.to().line+1,0))}})},delLineLeft:function(e){Br(e,function(e){return{from:Eo(e.from().line,0),to:e.from()}})},delWrappedLineLeft:function(e){Br(e,function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:0,top:r},"div");return{from:n,to:t.from()}})},delWrappedLineRight:function(e){Br(e,function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:r},"div");return{from:t.from(),to:n}})},undo:function(e){e.undo()},redo:function(e){e.redo()},undoSelection:function(e){e.undoSelection()},redoSelection:function(e){e.redoSelection()},goDocStart:function(e){e.extendSelection(Eo(e.firstLine(),0))},goDocEnd:function(e){e.extendSelection(Eo(e.lastLine()))},goLineStart:function(e){e.extendSelectionsBy(function(t){return no(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){e.extendSelectionsBy(function(t){return oo(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){e.extendSelectionsBy(function(t){return io(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:r},"div")},El)},goLineLeft:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:r},"div")},El)},goLineLeftSmart:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:0,top:r},"div");return n.ch<e.getLine(n.line).search(/\S/)?oo(e,t.head):n},El)},goLineUp:function(e){e.moveV(-1,"line")},goLineDown:function(e){e.moveV(1,"line")},goPageUp:function(e){e.moveV(-1,"page")},goPageDown:function(e){e.moveV(1,"page")},goCharLeft:function(e){e.moveH(-1,"char")},goCharRight:function(e){e.moveH(1,"char")},goColumnLeft:function(e){e.moveH(-1,"column")},goColumnRight:function(e){e.moveH(1,"column")},goWordLeft:function(e){e.moveH(-1,"word")},goGroupRight:function(e){e.moveH(1,"group")},goGroupLeft:function(e){e.moveH(-1,"gr
var n=h[d];"m"==n?h[d]=f:f=n}for(var d=0,p=u;c>d;++d){var n=h[d];"1"==n&&"r"==p?h[d]="n":l.test(n)&&(p=n,"r"==n&&(h[d]="R"))}for(var d=1,f=h[0];c-1>d;++d){var n=h[d];"+"==n&&"1"==f&&"1"==h[d+1]?h[d]="1":","!=n||f!=h[d+1]||"1"!=f&&"n"!=f||(h[d]=f),f=n}for(var d=0;c>d;++d){var n=h[d];if(","==n)h[d]="N";else if("%"==n){for(var g=d+1;c>g&&"%"==h[g];++g);for(var m=d&&"!"==h[d-1]||c>g&&"1"==h[g]?"1":"N",v=d;g>v;++v)h[v]=m;d=g-1}}for(var d=0,p=u;c>d;++d){var n=h[d];"L"==p&&"1"==n?h[d]="L":l.test(n)&&(p=n)}for(var d=0;c>d;++d)if(o.test(h[d])){for(var g=d+1;c>g&&o.test(h[g]);++g);for(var y="L"==(d?h[d-1]:u),b="L"==(c>g?h[g]:u),m=y||b?"L":"R",v=d;g>v;++v)h[v]=m;d=g-1}for(var x,w=[],d=0;c>d;)if(a.test(h[d])){var C=d;for(++d;c>d&&a.test(h[d]);++d);w.push(new t(0,C,d))}else{var S=d,k=w.length;for(++d;c>d&&"L"!=h[d];++d);for(var v=S;d>v;)if(s.test(h[v])){v>S&&w.splice(k,0,new t(1,S,v));var L=v;for(++v;d>v&&s.test(h[v]);++v);w.splice(k,0,new t(2,L,v)),S=v}else++v;d>S&&w.splice(k,0,new t(1,S,d))}return 1==w[0].level&&(x=r.match(/^\s+/))&&(w[0].from=x[0].length,w.unshift(new t(0,0,x[0].length))),1==Hi(w).level&&(x=r.match(/\s+$/))&&(Hi(w).to-=x[0].length,w.push(new t(0,c-x[0].length,c))),2==w[0].level&&w.unshift(new t(1,w[0].to,w[0].to)),w[0].level!=Hi(w).level&&w.push(new t(w[0].level,c,c)),w}}();return e.version="5.6.1",e}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";var t=/^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))(\s*)/,r=/^(\s*)(>[> ]*|[*+-]|(\d+)[.)])(\s*)$/,n=/[*+-]\s/;e.commands.newlineAndIndentContinueMarkdownList=function(i){if(i.getOption("disableInput"))return e.Pass;for(var o=i.listSelections(),l=[],a=0;a<o.length;a++){var s=o[a].head,u=i.getStateAfter(s.line),c=u.list!==!1,h=0!==u.quote,d=i.getLine(s.line),f=t.exec(d);if(!o[a].empty()||!c&&!h||!f)return void i.execCommand("newlineAndIndent");if(r.test(d))i.replaceRange("",{line:s.line,ch:0},{line:s.line,ch:s.ch+1}),l[a]="\n";else{var p=f[1],g=f[5],m=n.test(f[2])||f[2].indexOf(">")>=0?f[2]:parseInt(f[3],10)+1+f[4];l[a]="\n"+p+m+g}}i.replaceSelections(l)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.commands.tabAndIndentMarkdownList=function(e){var t=e.listSelections(),r=t[0].head,n=e.getStateAfter(r.line),i=n.list!==!1;if(i)return void e.execCommand("indentMore");if(e.options.indentWithTabs)e.execCommand("insertTab");else{var o=Array(e.options.tabSize+1).join(" ");e.replaceSelection(o)}},e.commands.shiftTabAndUnindentMarkdownList=function(e){var t=e.listSelections(),r=t[0].head,n=e.getStateAfter(r.line),i=n.list!==!1;if(i)return void e.execCommand("indentLess");if(e.options.indentWithTabs)e.execCommand("insertTab");else{var o=Array(e.options.tabSize+1).join(" ");e.replaceSelection(o)}}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e){var t=e.getWrapperElement();e.state.fullScreenRestore={scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,width:t.style.width,height:t.style.height},t.style.width="",t.style.height="auto",t.className+=" CodeMirror-fullscreen",document.documentElement.style.overflow="hidden",e.refresh()}function r(e){var t=e.getWrapperElement();t.className=t.className.replace(/\s*CodeMirror-fullscreen\b/,""),document.documentElement.style.overflow="";var r=e.state.fullScreenRestore;t.style.width=r.width,t.style.height=r.height,window.scrollTo(r.scrollLeft,r.scrollTop),e.refresh()}e.defineOption("fullScreen",!1,function(n,i,o){o==e.Init&&(o=!1),!o!=!i&&(i?t(n):r(n))})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../xml/xml"),require("../meta")):"function"==typeof define&&define.amd?define(["../../lib
}function r(e){this.options=e||{}}function n(e){this.tokens=[],this.token=null,this.options=e||u.defaults,this.options.renderer=this.options.renderer||new r,this.renderer=this.options.renderer,this.renderer.options=this.options}function i(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function o(e){return e.replace(/&([#\w]+);/g,function(e,t){return t=t.toLowerCase(),"colon"===t?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}function l(e,t){return e=e.source,t=t||"",function r(n,i){return n?(i=i.source||i,i=i.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(n,i),r):new RegExp(e,t)}}function a(){}function s(e){for(var t,r,n=1;n<arguments.length;n++){t=arguments[n];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}function u(t,r,o){if(o||"function"==typeof r){o||(o=r,r=null),r=s({},u.defaults,r||{});var l,a,c=r.highlight,h=0;try{l=e.lex(t,r)}catch(d){return o(d)}a=l.length;var f=function(e){if(e)return r.highlight=c,o(e);var t;try{t=n.parse(l,r)}catch(i){e=i}return r.highlight=c,e?o(e):o(null,t)};if(!c||c.length<3)return f();if(delete r.highlight,!a)return f();for(;h<l.length;h++)!function(e){return"code"!==e.type?--a||f():c(e.text,e.lang,function(t,r){return t?f(t):null==r||r===e.text?--a||f():(e.text=r,e.escaped=!0,void(--a||f()))})}(l[h])}else try{return r&&(r=s({},u.defaults,r)),n.parse(e.lex(t,r),r)}catch(d){if(d.message+="\nPlease report this to https://github.com/chjj/marked.",(r||u.defaults).silent)return"<p>An error occured:</p><pre>"+i(d.message+"",!0)+"</pre>";throw d}}var c={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:a,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:a,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:a,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};c.bullet=/(?:[*+-]|\d+\.)/,c.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,c.item=l(c.item,"gm")(/bull/g,c.bullet)(),c.list=l(c.list)(/bull/g,c.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+c.def.source+")")(),c.blockquote=l(c.blockquote)("def",c.def)(),c._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b",c.html=l(c.html)("comment",/<!--[\s\S]*?-->/)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g,c._tag)(),c.paragraph=l(c.paragraph)("hr",c.hr)("heading",c.heading)("lheading",c.lheading)("blockquote",c.blockquote)("tag","<"+c._tag)("def",c.def)(),c.normal=s({},c),c.gfm=s({},c.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),c.gfm.paragraph=l(c.paragraph)("(?!","(?!"+c.gfm.fences.source.replace("\\1","\\2")+"|"+c.list.source.replace("\\1","\\3")+"|")(),c.tables=s({},c.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),e.rules=c,e.lex=function(t,r){var n=new e(r);return n.lex(t)},e.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},e.prototype.token=function(e,t,r){for(var n,i,o,l,a,s,u,h,d,e=e.replace(/^ +$/gm,"");e;)if((o=this.rules.newline.exec(e))&&(e=e.substring(o[0].length),o[0].length>1&&this.tokens.push({type:"space"})),o=this.rules.code.exec(e))e=e.substring(o[0].length),o=o[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?o:o.replace(/\n+$/,"")});else if(o=this.rules.fences.exec(e))e=e.substring(o[0].leng