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/simplemde.min.js

13 lines
204 KiB
JavaScript

/*!
9 years ago
* SimpleMDE v1.5.0 (https://github.com/NextStepWebs/simplemde-markdown-editor)
* Copyright Next Step Webs, Inc.
* Licensed under the MIT license
*/
9 years ago
function fixShortcut(e){return e=isMac?e.replace("Ctrl","Cmd"):e.replace("Cmd","Ctrl")}function createIcon(e,t){e=e||{};var n=document.createElement("a");return t=void 0==t?!0:t,e.title&&t&&(n.title=e.title,isMac&&(n.title=n.title.replace("Ctrl","⌘"),n.title=n.title.replace("Alt","⌥"))),n.className=e.className,n}function createSep(){return el=document.createElement("i"),el.className="separator",el.innerHTML="|",el}function getState(e,t){t=t||e.getCursor("start");var n=e.getTokenAt(t);if(!n.type)return{};for(var r,i,o=n.type.split(" "),l={},s=0;s<o.length;s++)r=o[s],"strong"===r?l.bold=!0:"variable-2"===r?(i=e.getLine(t.line),/^\s*\d+\.\s/.test(i)?l["ordered-list"]=!0:l["unordered-list"]=!0):"atom"===r?l.quote=!0:"em"===r?l.italic=!0:"quote"===r&&(l.quote=!0);return l}function toggleFullScreen(e){var t=e.codemirror;t.setOption("fullScreen",!t.getOption("fullScreen"));var n=e.toolbarElements.fullscreen;/active/.test(n.className)?n.className=n.className.replace(/\s*active\s*/g,""):n.className+=" active"}function toggleBold(e){_toggleBlock(e,"bold","**")}function toggleItalic(e){_toggleBlock(e,"italic","*")}function toggleCodeBlock(e){_toggleBlock(e,"code","```\r\n","\r\n```")}function toggleBlockquote(e){var t=e.codemirror;_toggleLine(t,"quote")}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,n=getState(t);_replaceSelection(t,n.link,"[","](http://)")}function drawImage(e){var t=e.codemirror,n=getState(t);_replaceSelection(t,n.image,"![](http://",")")}function drawHorizontalRule(e){var t=e.codemirror,n=getState(t);_replaceSelection(t,n.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 togglePreview(e){var t=document.getElementsByClassName("editor-toolbar")[0],n=e.toolbarElements.preview,r=e.constructor.markdown,i=e.codemirror,o=i.getWrapperElement(),l=o.lastChild;/editor-preview/.test(l.className)||(l=document.createElement("div"),l.className="editor-preview",o.appendChild(l)),/editor-preview-active/.test(l.className)?(l.className=l.className.replace(/\s*editor-preview-active\s*/g,""),n.className=n.className.replace(/\s*active\s*/g,""),t.className=t.className.replace(/\s*disabled-for-preview*/g,"")):(setTimeout(function(){l.className+=" editor-preview-active"},1),n.className+=" active",t.className+=" disabled-for-preview");var s=i.getValue();l.innerHTML=r(s)}function _replaceSelection(e,t,n,r){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)){var i,o=e.getCursor("start"),l=e.getCursor("end");t?(i=e.getLine(o.line),n=i.slice(0,o.ch),r=i.slice(o.ch),e.replaceRange(n+r,{line:o.line,ch:0})):(i=e.getSelection(),e.replaceSelection(n+i+r),o.ch+=n.length,l.ch+=n.length),e.setSelection(o,l),e.focus()}}function _toggleLine(e,t){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)){for(var n=getState(e),r=e.getCursor("start"),i=e.getCursor("end"),o={quote:/^(\s*)\>\s+/,"unordered-list":/^(\s*)(\*|\-|\+)\s+/,"ordered-list":/^(\s*)\d+\.\s+/},l={quote:"> ","unordered-list":"* ","ordered-list":"1. "},s=r.line;s<=i.line;s++)!function(r){var i=e.getLine(r);i=n[t]?i.replace(o[t],"$1"):l[t]+i,e.replaceRange(i,{line:r,ch:0},{line:r,ch:99999999999999})}(s);e.focus()}}function _toggleBlock(e,t,n,r){if(!/editor-preview-active/.test(e.codemirror.getWrapperElement().lastChild.className)){r="undefined"==typeof r?n:r;var i,o=e.codemirror,l=getState(o),s=n,a=r,u=o.getCursor("start"),c=o.getCursor("end");l[t]?(i=o.getLine(u.line),s=i.slice(0,u.ch),a=i.slice(u.ch),"bold"==t?(s=s.replace(/(\*\*|__)(?![\s\S]*(\*\*|__))/,""),a=a.replace(/(\*\*|__)/,"")):"italic"==t&&(s=s.replace(/(\*|_)(?![\s\S]*(\*|_))/,""),a=a.replace(/(\*|_)/,"")),o.replaceRange(s+a,{line:u.line,ch:0},{line:u.line,ch:99999999999999}),"bold"==t?(u.ch-=2,c.ch-=2):"italic"==t&&(u.ch-=1,c.ch-=1)):(i=o.getSelection(),"bold"==t?(i=i.split("**").join(""),i=i.split("__").join("")):"italic"==t&&(i=
},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function zt(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,zo(Rt,e))}function Rt(e){var t=e.doc;if(t.frontier<t.first&&(t.frontier=t.first),!(t.frontier>=e.display.viewTo)){var n=+new Date+e.options.workTime,r=is(t.mode,_t(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,s=Wi(e,o,r,!0);o.styles=s.styles;var a=o.styleClasses,u=s.classes;u?o.styleClasses=u:a&&(o.styleClasses=null);for(var c=!l||l.length!=o.styles.length||a!=u&&(!a||!u||a.bgClass!=u.bgClass||a.textClass!=u.textClass),h=0;!c&&h<l.length;++h)c=l[h]!=o.styles[h];c&&i.push(t.frontier),o.stateAfter=is(t.mode,r)}else Ii(e,o.text,r),o.stateAfter=t.frontier%5==0?is(t.mode,r):null;return++t.frontier,+new Date>n?(zt(e,e.options.workDelay),!0):void 0}),i.length&&An(e,function(){for(var t=0;t<i.length;t++)Pn(e,i[t],"text")})}}function Bt(e,t,n){for(var r,i,o=e.doc,l=n?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;s>l;--s){if(s<=o.first)return o.first;var a=Yi(o,s-1);if(a.stateAfter&&(!n||s<=o.frontier))return s;var u=Is(a.text,null,e.options.tabSize);(null==i||r>u)&&(i=s-1,r=u)}return i}function _t(e,t,n){var r=e.doc,i=e.display;if(!r.mode.startState)return!0;var o=Bt(e,t,n),l=o>r.first&&Yi(r,o-1).stateAfter;return l=l?is(r.mode,l):os(r.mode),r.iter(o,t,function(n){Ii(e,n.text,l);var s=o==t-1||o%5==0||o>=i.viewFrom&&o<i.viewTo;n.stateAfter=s?is(r.mode,l):null,++o}),n&&(r.frontier=o),l}function qt(e){return e.lineSpace.offsetTop}function Ut(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Gt(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=Go(e.measure,qo("pre","x")),n=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(n.paddingLeft),right:parseInt(n.paddingRight)};return isNaN(r.left)||isNaN(r.right)||(e.cachedPaddingH=r),r}function $t(e){return Os-e.display.nativeBarWidth}function jt(e){return e.display.scroller.clientWidth-$t(e)-e.display.barWidth}function Vt(e){return e.display.scroller.clientHeight-$t(e)-e.display.barHeight}function Kt(e,t,n){var r=e.options.lineWrapping,i=r&&jt(e);if(!t.measure.heights||r&&t.measure.width!=i){var o=t.measure.heights=[];if(r){t.measure.width=i;for(var l=t.text.firstChild.getClientRects(),s=0;s<l.length-1;s++){var a=l[s],u=l[s+1];Math.abs(a.bottom-u.bottom)>2&&o.push((a.bottom+u.top)/2-n.top)}}o.push(n.bottom-n.top)}}function Xt(e,t,n){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;r<e.rest.length;r++)if(e.rest[r]==t)return{map:e.measure.maps[r],cache:e.measure.caches[r]};for(var r=0;r<e.rest.length;r++)if(eo(e.rest[r])>n)return{map:e.measure.maps[r],cache:e.measure.caches[r],before:!0}}function Yt(e,t){t=vi(t);var n=eo(t),r=e.display.externalMeasured=new Wn(e.doc,t,n);r.lineN=n;var i=r.built=Fi(e,r);return r.text=i.pre,Go(e.display.lineMeasure,i.pre),r}function Zt(e,t,n,r){return en(e,Jt(e,t),n,r)}function Qt(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[zn(e,t)];var n=e.display.externalMeasured;return n&&t>=n.lineN&&t<n.lineN+n.size?n:void 0}function Jt(e,t){var n=eo(t),r=Qt(e,n);r&&!r.text?r=null:r&&r.changes&&(I(e,r,n,W(e)),e.curOp.forceUpdate=!0),r||(r=Yt(e,t));var i=Xt(r,t,n);return{line:t,view:r,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function en(e,t,n,r,i){t.before&&(n=-1);var o,l=n+(r||"");return t.cache.hasOwnProperty(l)?o=t.cache[l]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Kt(e,t.view,t.rect),t.hasHeights=!0),o=nn(e,t,n,r),o.bogus||(t.cache[l]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}function tn(e,t,n){for(var r,i,o,l,s=0;s<e.length;s+=3){var a=e[s],u=e[s+1];if(a>t?(i=0,o=1,l="left"):u>t?(i=t-a,o=i+1):(s==e.length-3||t==u&&e[s+3]>t)&&(o=u-a,i=o-1,t>=u&&(l="right")),null!=i){if(r=e[s+2],a==u&&n==(r.insertLeft?"left":"right")&&(l=n),"left"==n&&0==i)for(;s&&e[s-2]==e[s-3]&&e[s-1].insertLeft;)r=e[(s-=3)+2],l="
}),e.sel.primIndex),e.cm)){In(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;r<n.viewTo;r++)Pn(e.cm,r,"gutter")}}function Ar(e,t,n,r){if(e.cm&&!e.cm.curOp)return On(e.cm,Ar)(e,t,n,r);if(t.to.line<e.first)return void Nr(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);Nr(e,i),t={from:Hl(e.first,0),to:Hl(t.to.line+i,t.to.ch),text:[Eo(t.text)],origin:t.origin}}var o=e.lastLine();t.to.line>o&&(t={from:t.from,to:Hl(o,Yi(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Zi(e,t.from,t.to),n||(n=wr(e,t)),e.cm?Or(e.cm,t,r):$i(e,t,r),Nt(e,n,Es)}}function Or(e,t,n){var r=e.doc,i=e.display,l=t.from,s=t.to,a=!1,u=l.line;e.options.lineWrapping||(u=eo(vi(Yi(r,l.line))),r.iter(u,s.line+1,function(e){return e==i.maxLine?(a=!0,!0):void 0})),r.sel.contains(t.from,t.to)>-1&&Mo(e),$i(r,t,n,o(e)),e.options.lineWrapping||(r.iter(u,l.line+t.text.length,function(e){var t=h(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,a=!1)}),a&&(e.curOp.updateMaxLine=!0)),r.frontier=Math.min(r.frontier,l.line),zt(e,400);var c=t.text.length-(s.line-l.line)-1;t.full?In(e):l.line!=s.line||1!=t.text.length||Gi(e.doc,t)?In(e,l.line,s.line+1,c):Pn(e,l.line,"text");var f=To(e,"changes"),d=To(e,"change");if(d||f){var p={from:l,to:s,text:t.text,removed:t.removed,origin:t.origin};d&&ko(e,"change",e,p),f&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(p)}e.display.selForContextMenu=null}function Dr(e,t,n,r,i){if(r||(r=n),Il(r,n)<0){var o=r;r=n,n=o}"string"==typeof t&&(t=e.splitLines(t)),Lr(e,{from:n,to:r,text:t,origin:i})}function Er(e,t){if(!Lo(e,"scrollCursorIntoView")){var n=e.display,r=n.sizer.getBoundingClientRect(),i=null;if(t.top+r.top<0?i=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!Sl){var o=qo("div","",null,"position: absolute; top: "+(t.top-n.viewOffset-qt(e.display))+"px; height: "+(t.bottom-t.top+$t(e)+n.barHeight)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}function Wr(e,t,n,r){null==r&&(r=0);for(var i=0;5>i;i++){var o=!1,l=dn(e,t),s=n&&n!=t?dn(e,n):l,a=Ir(e,Math.min(l.left,s.left),Math.min(l.top,s.top)-r,Math.max(l.left,s.left),Math.max(l.bottom,s.bottom)+r),u=e.doc.scrollTop,c=e.doc.scrollLeft;if(null!=a.scrollTop&&(rr(e,a.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(o=!0)),null!=a.scrollLeft&&(ir(e,a.scrollLeft),Math.abs(e.doc.scrollLeft-c)>1&&(o=!0)),!o)break}return l}function Hr(e,t,n,r,i){var o=Ir(e,t,n,r,i);null!=o.scrollTop&&rr(e,o.scrollTop),null!=o.scrollLeft&&ir(e,o.scrollLeft)}function Ir(e,t,n,r,i){var o=e.display,l=yn(e.display);0>n&&(n=0);var s=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,a=Vt(e),u={};i-n>a&&(i=n+a);var c=e.doc.height+Ut(o),h=l>n,f=i>c-l;if(s>n)u.scrollTop=h?0:n;else if(i>s+a){var d=Math.min(n,(f?c:i)-a);d!=s&&(u.scrollTop=d)}var p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,g=jt(e)-(e.options.fixedGutter?o.gutters.offsetWidth:0),m=r-t>g;return m&&(r=t+g),10>t?u.scrollLeft=0:p>t?u.scrollLeft=Math.max(0,t-(m?0:10)):r>g+p-3&&(u.scrollLeft=r+(m?0:10)-g),u}function Pr(e,t,n){(null!=t||null!=n)&&zr(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=n&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+n)}function Fr(e){zr(e);var t=e.getCursor(),n=t,r=t;e.options.lineWrapping||(n=t.ch?Hl(t.line,t.ch-1):t,r=Hl(t.line,t.ch+1)),e.curOp.scrollToPos={from:n,to:r,margin:e.options.cursorScrollMargin,isCursor:!0}}function zr(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var n=pn(e,t.from),r=pn(e,t.to),i=Ir(e,Math.min(n.left,r.left),Math.min(n.top,r.top)-t.margin,Math.max(n.right,r.right),Math.max(n.bottom,r.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function Rr(e,t,n,r){var i,o=e.doc;null==n&&(n="add"),"smart"==n&&(o.mode.indent?i=_t(e,t):n="prev");var l=e.options.tabSize,s=Yi(o,t),a=Is(s.t
if(!i||0==i[0].level){var o=Math.max(0,r.text.search(/\S/)),l=t.line==n.line&&t.ch<=o&&t.ch;return Hl(n.line,l?0:o)}return n}function al(e,t,n){var r=e[0].level;return t==r?!0:n==r?!1:n>t}function ul(e,t){ea=null;for(var n,r=0;r<e.length;++r){var i=e[r];if(i.from<t&&i.to>t)return r;if(i.from==t||i.to==t){if(null!=n)return al(e,i.level,e[n].level)?(i.from!=i.to&&(ea=n),r):(i.from!=i.to&&(ea=r),n);n=r}}return n}function cl(e,t,n,r){if(!r)return t+n;do t+=n;while(t>0&&_o(e.text.charAt(t)));return t}function hl(e,t,n,r){var i=ro(e);if(!i)return fl(e,t,n,r);for(var o=ul(i,t),l=i[o],s=cl(e,t,l.level%2?-n:n,r);;){if(s>l.from&&s<l.to)return s;if(s==l.from||s==l.to)return ul(i,s)==o?s:(l=i[o+=n],n>0==l.level%2?l.to:l.from);if(l=i[o+=n],!l)return null;s=n>0==l.level%2?cl(e,l.to,-1,r):cl(e,l.from,1,r)}}function fl(e,t,n,r){var i=t+n;if(r)for(;i>0&&_o(e.text.charAt(i));)i+=n;return 0>i||i>e.text.length?null:i}var dl=/gecko\/\d/i.test(navigator.userAgent),pl=/MSIE \d/.test(navigator.userAgent),gl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ml=pl||gl,vl=ml&&(pl?document.documentMode||6:gl[1]),yl=/WebKit\//.test(navigator.userAgent),bl=yl&&/Qt\/\d+\.\d+/.test(navigator.userAgent),xl=/Chrome\//.test(navigator.userAgent),wl=/Opera\//.test(navigator.userAgent),Cl=/Apple Computer/.test(navigator.vendor),kl=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),Sl=/PhantomJS/.test(navigator.userAgent),Ll=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),Ml=Ll||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),Tl=Ll||/Mac/.test(navigator.platform),Nl=/win/i.test(navigator.platform),Al=wl&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);Al&&(Al=Number(Al[1])),Al&&Al>=15&&(wl=!1,yl=!0);var Ol=Tl&&(bl||wl&&(null==Al||12.11>Al)),Dl=dl||ml&&vl>=9,El=!1,Wl=!1;g.prototype=Fo({update:function(e){var t=e.scrollWidth>e.clientWidth+1,n=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(n){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var i=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=n?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(n?r:0);this.horiz.firstChild.style.width=e.scrollWidth-e.clientWidth+o+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedOverlay&&e.clientHeight>0&&(0==r&&this.overlayHack(),this.checkedOverlay=!0),{right:n?r:0,bottom:t?r:0}},setScrollLeft:function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e)},setScrollTop:function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e)},overlayHack:function(){var e=Tl&&!kl?"12px":"18px";this.horiz.style.minHeight=this.vert.style.minWidth=e;var t=this,n=function(e){wo(e)!=t.vert&&wo(e)!=t.horiz&&On(t.cm,Vn)(e)};Ms(this.vert,"mousedown",n),Ms(this.horiz,"mousedown",n)},clear:function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)}},g.prototype),m.prototype=Fo({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},m.prototype),e.scrollbarModel={"native":g,"null":m},L.prototype.signal=function(e,t){To(e,t)&&this.events.push(arguments)},L.prototype.finish=function(){for(var e=0;e<this.events.length;e++)Ns.apply(null,this.events[e])};var Hl=e.Pos=function(e,t){return this instanceof Hl?(this.line=e,void(this.ch=t)):new Hl(e,t)},Il=e.cmpPos=function(e,t){return e.line-t.line||e.ch-t.ch},Pl=null;rt.prototype=Fo({init:function(e){function t(e){if(r.somethingSelected())Pl=r.getSelections(),n.inaccurateSelection&&(n.prevInput="",n.inaccurateSelection=!1,o.value=Pl.join("\n"),Fs(o));else{if(!r.options.lineWiseCopyCut)return;var t=tt(r);Pl=t.text,"cut"==e.type?r.setSelections(t.ranges,null,Es):(n.prevInput="",o.value=t.text.join("\n"),Fs(o))}"cut"==e.type&&(r.state.cutIncoming=!0)}var n=this,r=this.cm,i=this.wrapper=it(),o=this
},Hs)},goLineLeft:function(e){e.extendSelectionsBy(function(t){var n=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:n},"div")},Hs)},goLineLeftSmart:function(e){e.extendSelectionsBy(function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:n},"div");return r.ch<e.getLine(r.line).search(/\S/)?sl(e,t.head):r},Hs)},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,"group")},goWordRight:function(e){e.moveH(1,"word")},delCharBefore:function(e){e.deleteH(-1,"char")},delCharAfter:function(e){e.deleteH(1,"char")},delWordBefore:function(e){e.deleteH(-1,"word")},delWordAfter:function(e){e.deleteH(1,"word")},delGroupBefore:function(e){e.deleteH(-1,"group")},delGroupAfter:function(e){e.deleteH(1,"group")},indentAuto:function(e){e.indentSelection("smart")},indentMore:function(e){e.indentSelection("add")},indentLess:function(e){e.indentSelection("subtract")},insertTab:function(e){e.replaceSelection(" ")},insertSoftTab:function(e){for(var t=[],n=e.listSelections(),r=e.options.tabSize,i=0;i<n.length;i++){var o=n[i].from(),l=Is(e.getLine(o.line),o.ch,r);t.push(new Array(r-l%r+1).join(" "))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){An(e,function(){for(var t=e.listSelections(),n=[],r=0;r<t.length;r++){var i=t[r].head,o=Yi(e.doc,i.line).text;if(o)if(i.ch==o.length&&(i=new Hl(i.line,i.ch-1)),i.ch>0)i=new Hl(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),Hl(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var l=Yi(e.doc,i.line-1).text;l&&e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+l.charAt(l.length-1),Hl(i.line-1,l.length-1),Hl(i.line,1),"+transpose")}n.push(new ft(i,i))}e.setSelections(n)})},newlineAndIndent:function(e){An(e,function(){for(var t=e.listSelections().length,n=0;t>n;n++){var r=e.listSelections()[n];e.replaceRange(e.doc.lineSeparator(),r.anchor,r.head,"+input"),e.indentLine(r.from().line+1,null,!0),Fr(e)}})},toggleOverwrite:function(e){e.toggleOverwrite()}},ss=e.keyMap={};ss.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},ss.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},ss.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"},ss.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupL
var n=e.state.fullScreenRestore;t.style.width=n.width,t.style.height=n.height,window.scrollTo(n.scrollLeft,n.scrollTop),document.getElementsByClassName("editor-toolbar")[0].className=document.getElementsByClassName("editor-toolbar")[0].className.replace(/\s*fullscreen\b/,""),e.refresh()}e.defineOption("fullScreen",!1,function(r,i,o){o==e.Init&&(o=!1),!o!=!i&&(i?t(r):n(r))})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../xml/xml"),require("../meta")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../meta"],e):e(CodeMirror)}(function(e){"use strict";e.defineMode("markdown",function(t,n){function r(n){if(e.findModeByName){var r=e.findModeByName(n);r&&(n=r.mime||r.mimes[0])}var i=e.getMode(t,n);return"null"==i.name?null:i}function i(e,t,n){return t.f=t.inline=n,n(e,t)}function o(e,t,n){return t.f=t.block=n,n(e,t)}function l(e){return e.linkTitle=!1,e.em=!1,e.strong=!1,e.strikethrough=!1,e.quote=0,e.indentedCode=!1,w||e.f!=a||(e.f=d,e.block=s),e.trailingSpace=0,e.trailingSpaceNewLine=!1,e.thisLineHasContent=!1,null}function s(e,t){var o=e.sol(),l=t.list!==!1,s=t.indentedCode;t.indentedCode=!1,l&&(t.indentationDiff>=0?(t.indentationDiff<4&&(t.indentation-=t.indentationDiff),t.list=null):t.indentation>0?(t.list=null,t.listDepth=Math.floor(t.indentation/4)):(t.list=!1,t.listDepth=0));var a=null;if(t.indentationDiff>=4)return e.skipToEnd(),s||!t.prevLineHasContent?(t.indentation-=4,t.indentedCode=!0,L):null;if(e.eatSpace())return null;if((a=e.match(G))&&a[1].length<=6)return t.header=a[1].length,n.highlightFormatting&&(t.formatting="header"),t.f=t.inline,h(t);if(t.prevLineHasContent&&!t.quote&&!l&&!s&&(a=e.match($)))return t.header="="==a[0].charAt(0)?1:2,n.highlightFormatting&&(t.formatting="header"),t.f=t.inline,h(t);if(e.eat(">"))return t.quote=o?1:t.quote+1,n.highlightFormatting&&(t.formatting="quote"),e.eatSpace(),h(t);if("["===e.peek())return i(e,t,v);if(e.match(B,!0))return t.hr=!0,O;if((!t.prevLineHasContent||l)&&(e.match(_,!1)||e.match(q,!1))){var c=null;return e.match(_,!0)?c="ul":(e.match(q,!0),c="ol"),t.indentation+=4,t.list=!0,t.listDepth++,n.taskLists&&e.match(U,!1)&&(t.taskList=!0),t.f=t.inline,n.highlightFormatting&&(t.formatting=["list","list-"+c]),h(t)}return n.fencedCodeBlocks&&e.match(/^```[ \t]*([\w+#]*)/,!0)?(t.localMode=r(RegExp.$1),t.localMode&&(t.localState=t.localMode.startState()),t.f=t.block=u,n.highlightFormatting&&(t.formatting="code-block"),t.code=!0,h(t)):i(e,t,t.inline)}function a(e,t){var n=C.token(e,t.htmlState);return(w&&null===t.htmlState.tagStart&&!t.htmlState.context&&t.htmlState.tokenize.isInText||t.md_inside&&e.current().indexOf(">")>-1)&&(t.f=d,t.block=s,t.htmlState=null),n}function u(e,t){return e.sol()&&e.match("```",!1)?(t.localMode=t.localState=null,t.f=t.block=c,null):t.localMode?t.localMode.token(e,t.localState):(e.skipToEnd(),L)}function c(e,t){e.match("```"),t.block=s,t.f=d,n.highlightFormatting&&(t.formatting="code-block"),t.code=!0;var r=h(t);return t.code=!1,r}function h(e){var t=[];if(e.formatting){t.push(E),"string"==typeof e.formatting&&(e.formatting=[e.formatting]);for(var r=0;r<e.formatting.length;r++)t.push(E+"-"+e.formatting[r]),"header"===e.formatting[r]&&t.push(E+"-"+e.formatting[r]+"-"+e.header),"quote"===e.formatting[r]&&t.push(!n.maxBlockquoteDepth||n.maxBlockquoteDepth>=e.quote?E+"-"+e.formatting[r]+"-"+e.quote:"error")}if(e.taskOpen)return t.push("meta"),t.length?t.join(" "):null;if(e.taskClosed)return t.push("property"),t.length?t.join(" "):null;if(e.linkHref?t.push(P,"url"):(e.strong&&t.push(z),e.em&&t.push(F),e.strikethrough&&t.push(R),e.linkText&&t.push(I),e.code&&t.push(L)),e.header&&(t.push(S),t.push(S+"-"+e.header)),e.quote&&(t.push(M),t.push(!n.maxBlockquoteDepth||n.maxBlockquoteDepth>=e.quote?M+"-"+e.quote:M+"-"+n.maxBlockquoteDepth)),e.list!==!1){var i=(e.listDepth-1)%3;t.push(i?1===i?N:A:T)}return e.trailingSpaceNewLine?t.push("trailing-space-new-line"):e.trailingSpace&&t.push("trailing-space-"+(e.trailingSpace%2?"a":"b")),t.length?t.join(" "):null}functi
this.tokens.push({type:"list_end"})}else if(o=this.rules.html.exec(e))e=e.substring(o[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&("pre"===o[1]||"script"===o[1]||"style"===o[1]),text:o[0]});else if(!n&&t&&(o=this.rules.def.exec(e)))e=e.substring(o[0].length),this.tokens.links[o[1].toLowerCase()]={href:o[2],title:o[3]};else if(t&&(o=this.rules.table.exec(e))){for(e=e.substring(o[0].length),a={type:"table",header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:o[3].replace(/(?: *\| *)?\n$/,"").split("\n")},h=0;h<a.align.length;h++)a.align[h]=/^ *-+: *$/.test(a.align[h])?"right":/^ *:-+: *$/.test(a.align[h])?"center":/^ *:-+ *$/.test(a.align[h])?"left":null;for(h=0;h<a.cells.length;h++)a.cells[h]=a.cells[h].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */);this.tokens.push(a)}else if(t&&(o=this.rules.paragraph.exec(e)))e=e.substring(o[0].length),this.tokens.push({type:"paragraph",text:"\n"===o[1].charAt(o[1].length-1)?o[1].slice(0,-1):o[1]});else if(o=this.rules.text.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"text",text:o[0]});else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0));return this.tokens};var h={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:s,tag:/^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:s,text:/^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/};h._inside=/(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/,h._href=/\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/,h.link=l(h.link)("inside",h._inside)("href",h._href)(),h.reflink=l(h.reflink)("inside",h._inside)(),h.normal=a({},h),h.pedantic=a({},h.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),h.gfm=a({},h.normal,{escape:l(h.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:l(h.text)("]|","~]|")("|","|https?://|")()}),h.breaks=a({},h.gfm,{br:l(h.br)("{2,}","*")(),text:l(h.gfm.text)("{2,}","*")()}),t.rules=h,t.output=function(e,n,r){var i=new t(n,r);return i.output(e)},t.prototype.output=function(e){for(var t,n,r,o,l="";e;)if(o=this.rules.escape.exec(e))e=e.substring(o[0].length),l+=o[1];else if(o=this.rules.autolink.exec(e))e=e.substring(o[0].length),"@"===o[2]?(n=this.mangle(":"===o[1].charAt(6)?o[1].substring(7):o[1]),r=this.mangle("mailto:")+n):(n=i(o[1]),r=n),l+=this.renderer.link(r,null,n);else if(this.inLink||!(o=this.rules.url.exec(e))){if(o=this.rules.tag.exec(e))!this.inLink&&/^<a /i.test(o[0])?this.inLink=!0:this.inLink&&/^<\/a>/i.test(o[0])&&(this.inLink=!1),e=e.substring(o[0].length),l+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(o[0]):i(o[0]):o[0];else if(o=this.rules.link.exec(e))e=e.substring(o[0].length),this.inLink=!0,l+=this.outputLink(o,{href:o[2],title:o[3]}),this.inLink=!1;else if((o=this.rules.reflink.exec(e))||(o=this.rules.nolink.exec(e))){if(e=e.substring(o[0].length),t=(o[2]||o[1]).replace(/\s+/g," "),t=this.links[t.toLowerCase()],!t||!t.href){l+=o[0].charAt(0),e=o[0].substring(1)+e;continue}this.inLink=!0,l+=this.outputLink(o,t),this.inLink=!1}else if(o=this.rules.strong.exec(e))e=e.substring(o[0].length),l+=this.renderer.strong(this.output(o[2]||o[1]));else if(o=this.rules.em.exec(e))e=e.substring(o[0].length),l+=this.renderer.em(this.output(o[2]||o[1]));else if(o=this.rules.code.exec(e))e=e.substring(o[0].length),l+=this.renderer.codespan(i(o[2],!0));else if(o=this.rules.br.exec(e))e=e.substring(o[0].length),l+=this.renderer.br();else if(o=this.rules.del.exec(e))e=e.substring(o[0].length),l+=this.renderer.del(this.output(o[1]));else if(o=this.rules.text.exec(e))e=e.substring(o[0].length),l+=this.renderer.text(i(thi