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

13 lines
214 KiB
JavaScript

/**
* simplemde v1.7.5
* 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 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={},a=0;a<o.length;a++)r=o[a],"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:"strikethrough"===r?l.strikethrough=!0:"comment"===r&&(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 n=t.getWrapperElement();/fullscreen/.test(n.previousSibling.className)?n.previousSibling.className=n.previousSibling.className.replace(/\s*fullscreen\b/,""):n.previousSibling.className+=" fullscreen";var r=e.toolbarElements.fullscreen;/active/.test(r.className)?r.className=r.className.replace(/\s*active\s*/g,""):r.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,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 toggleSideBySide(e){var t=e.codemirror,n=t.getWrapperElement(),r=(n.firstChild,n.nextSibling),i=e.toolbarElements["side-by-side"];/editor-preview-active-side/.test(r.className)?(r.className=r.className.replace(/\s*editor-preview-active-side\s*/g,""),i.className=i.className.replace(/\s*active\s*/g,""),n.className=n.className.replace(/\s*CodeMirror-sided\s*/g," ")):(setTimeout(function(){t.getOption("fullScreen")||toggleFullScreen(e),r.className+=" editor-preview-active-side"},1),i.className+=" active",n.className+=" CodeMirror-sided");var o=n.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=n.previousSibling;l.className=l.className.replace(/\s*active\s*/g,""),a.className=a.className.replace(/\s*disabled-for-preview*/g,"")}r.innerHTML=e.options.previewRender(e.value(),r),t.on("update",function(){r.innerHTML=e.options.previewRender(e.value(),r)})}function togglePreview(e){var t=e.codemirror,n=t.getWrapperElement(),r=n.previousSibling,i=e.toolbarElements.preview,o=n.lastChild;o&&/editor-preview/.test(o.className)||(o=document.createElement("div"),o.className="editor-preview",n.appendChild(o)),/editor-preview-active/.test(o.className)?(o.
Ae(e,He(e,t,r,!0)),n&&n.scroll===!1||!e.cm||Pn(e.cm)}function Ae(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,Mi(e.cm)),Si(e,"cursorActivity",e))}function De(e){Ae(e,He(e,e.sel,null,!1),El)}function He(e,t,n,r){for(var i,o=0;o<t.ranges.length;o++){var l=t.ranges[o],a=Oe(e,l.anchor,n,r),s=Oe(e,l.head,n,r);(i||a!=l.anchor||s!=l.head)&&(i||(i=t.ranges.slice(0,o)),i[o]=new de(a,s))}return i?fe(i,t.primIndex):t}function Oe(e,t,n,r){var i=!1,o=t,l=n||1;e.cantEdit=!1;e:for(;;){var a=Yr(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(r&&(Al(c,"beforeCursorEnter"),c.explicitlyCleared)){if(a.markedSpans){--s;continue}break}if(!c.atomic)continue;var h=c.find(0>l?-1:1);if(0==Io(h,o)&&(h.ch+=l,h.ch<0?h=h.line>e.first?me(e,Wo(h.line-1)):null:h.ch>a.text.length&&(h=h.line<e.first+e.size-1?Wo(h.line+1,0):null),!h)){if(i)return r?(e.cantEdit=!0,Wo(e.first,0)):Oe(e,t,n,!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 n=e.doc,r={},i=r.cursors=document.createDocumentFragment(),o=r.selection=document.createDocumentFragment(),l=0;l<n.sel.ranges.length;l++)if(t!==!1||l!=n.sel.primIndex){var a=n.sel.ranges[l],s=a.empty();(s||e.options.showCursorWhenSelecting)&&Ie(e,a.head,i),s||Fe(e,a,o)}return r}function Ie(e,t,n){var r=dt(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),i=n.appendChild(Ri("div"," ","CodeMirror-cursor"));if(i.style.left=r.left+"px",i.style.top=r.top+"px",i.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px",r.other){var o=n.appendChild(Ri("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));o.style.display="",o.style.left=r.other.left+"px",o.style.top=r.other.top+"px",o.style.height=.85*(r.other.bottom-r.other.top)+"px"}}function Fe(e,t,n){function r(e,t,n,r){0>t&&(t=0),t=Math.round(t),r=Math.round(r),a.appendChild(Ri("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(null==n?c-e:n)+"px; height: "+(r-t)+"px"))}function i(t,n,i){function o(n,r){return ht(e,Wo(t,n),"div",h,r)}var a,s,h=Yr(l,t),d=h.text.length;return Ji(ri(h),n||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==n&&0==e&&(f=u),h.top-g.top>3&&(r(f,g.top,null,g.bottom),f=u,g.bottom<h.top&&r(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),r(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,$e(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=Yr(l,h.line),p=Yr(l,d.line),g=vr(f)==vr(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?(r(m.right,m.top,null,m.bottom),r(u,v.top,v.left,v.bottom)):r(m.right,m.top,v.left-m.right,m.bottom)),m.bottom<v.top&&r(u,m.bottom,null,v.top)}n.appendChild(a)}function Pe(e){if(e.state.focused){var t=e.display;clearInterval(t.blinker);var n=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(n=!n)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function Be(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 n=+new Date+e.options.workTime,r=il(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=Er(e
var t=this;if(!(Gt(t.display,e)||Li(t,e)||e.ctrlKey&&!e.altKey||To&&e.metaKey)){var n=e.keyCode,r=e.charCode;if(wo&&n==Ko)return Ko=null,void Sl(e);if(!wo||e.which&&!(e.which<10)||!un(t,e)){var i=String.fromCharCode(null==r?n:r);cn(t,e,i)||t.display.input.onKeyPress(e)}}}function gn(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,vn(e))},100)}function mn(e){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(Al(e,"focus",e),e.state.focused=!0,Kl(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),yo&&setTimeout(function(){e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Pe(e))}function vn(e){e.state.delayingBlurEvent||(e.state.focused&&(Al(e,"blur",e),e.state.focused=!1,Vl(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function yn(e,t){Gt(e.display,t)||bn(e,t)||Li(e,t,"contextmenu")||e.display.input.onContextMenu(t)}function bn(e,t){return Ti(e,"gutterContextMenu")?Yt(e,t,"gutterContextMenu",!1,Al):!1}function xn(e,t){if(Io(e,t.from)<0)return e;if(Io(e,t.to)<=0)return Xo(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Xo(t).ch-t.to.ch),Wo(n,r)}function wn(e,t){for(var n=[],r=0;r<e.sel.ranges.length;r++){var i=e.sel.ranges[r];n.push(new de(xn(i.anchor,t),xn(i.head,t)))}return fe(n,e.sel.primIndex)}function Cn(e,t,n){return e.line==t.line?Wo(n.line,e.ch-t.ch+n.ch):Wo(n.line+(e.line-t.line),e.ch)}function Sn(e,t,n){for(var r=[],i=Wo(e.first,0),o=i,l=0;l<t.length;l++){var a=t[l],s=Cn(a.from,i,o),u=Cn(Xo(a),i,o);if(i=a.to,o=u,"around"==n){var c=e.sel.ranges[l],h=Io(c.head,c.anchor)<0;r[l]=new de(h?u:s,h?s:u)}else r[l]=new de(s,s)}return new he(r,e.sel.primIndex)}function kn(e,t,n){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return n&&(r.update=function(t,n,r,i){t&&(this.from=me(e,t)),n&&(this.to=me(e,n)),r&&(this.text=r),void 0!==i&&(this.origin=i)}),Al(e,"beforeChange",e,r),e.cm&&Al(e.cm,"beforeChange",e.cm,r),r.canceled?null:{from:r.from,to:r.to,text:r.text,origin:r.origin}}function Ln(e,t,n){if(e.cm){if(!e.cm.curOp)return At(e.cm,Ln)(e,t,n);if(e.cm.state.suppressEdits)return}if(!(Ti(e,"beforeChange")||e.cm&&Ti(e.cm,"beforeChange"))||(t=kn(e,t,!0))){var r=Oo&&!n&&ar(e,t.from,t.to);if(r)for(var i=r.length-1;i>=0;--i)Mn(e,{from:r[i].from,to:r[i].to,text:i?[""]:t.text});else Mn(e,t)}}function Mn(e,t){if(1!=t.text.length||""!=t.text[0]||0!=Io(t.from,t.to)){var n=wn(e,t);si(e,t,n,e.cm?e.cm.curOp.id:NaN),An(e,t,n,ir(e,t));var r=[];Kr(e,function(e,n){n||-1!=Oi(r,e.history)||(yi(e.history,t),r.push(e.history)),An(e,t,null,ir(e,t))})}}function Tn(e,t,n){if(!e.cm||!e.cm.state.suppressEdits){for(var r,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&&(r=l[s],n?!r.ranges||r.equals(e.sel):r.ranges);s++);if(s!=l.length){for(i.lastOrigin=i.lastSelOrigin=null;r=l.pop(),r.ranges;){if(hi(r,a),n&&!r.equals(e.sel))return void Te(e,r,{clearRedo:!1});o=r}var u=[];hi(o,a),a.push({changes:u,generation:i.generation}),i.generation=r.generation||++i.maxGeneration;for(var c=Ti(e,"beforeChange")||e.cm&&Ti(e.cm,"beforeChange"),s=r.changes.length-1;s>=0;--s){var h=r.changes[s];if(h.origin=t,c&&!kn(e,h,!1))return void(l.length=0);u.push(oi(e,h));var d=s?wn(e,h):Hi(l);An(e,h,d,lr(e,h)),!s&&e.cm&&e.cm.scrollIntoView({from:h.from,to:Xo(h)});var f=[];Kr(e,function(e,t){t||-1!=Oi(f,e.history)||(yi(e.history,h),f.push(e.history)),An(e,h,null,lr(e,h))})}}}}function Nn(e,t){if(0!=t&&(e.first+=t,e.sel=new he(Ei(e.sel.ranges,function(e){return new de(Wo(e.anchor.line+t,e.anchor.ch),Wo(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){Wt(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;r<n.viewTo;r++)It(e.cm,r,"gutter")}}function An(e,t,n,r){if(e.cm&&!e.cm.curOp)return At(e.cm,An)(e,t,n,r);if(t.to.line<e.first)return vo
}}function ki(){var e=Dl;Dl=null;for(var t=0;t<e.length;++t)e[t]()}function Li(e,t,n){return"string"==typeof t&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Al(e,n||t.type,e,t),bi(t)||t.codemirrorIgnore}function Mi(e){var t=e._handlers&&e._handlers.cursorActivity;if(t)for(var n=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),r=0;r<t.length;++r)-1==Oi(n,t[r])&&n.push(t[r])}function Ti(e,t){return Ci(e,t).length>0}function Ni(e){e.prototype.on=function(e,t){Ml(this,e,t)},e.prototype.off=function(e,t){Nl(this,e,t)}}function Ai(){this.id=null}function Di(e){for(;Bl.length<=e;)Bl.push(Hi(Bl)+" ");return Bl[e]}function Hi(e){return e[e.length-1]}function Oi(e,t){for(var n=0;n<e.length;++n)if(e[n]==t)return n;return-1}function Ei(e,t){for(var n=[],r=0;r<e.length;r++)n[r]=t(e[r],r);return n}function Wi(){}function Ii(e,t){var n;return Object.create?n=Object.create(e):(Wi.prototype=e,n=new Wi),t&&Fi(t,n),n}function Fi(e,t,n){t||(t={});for(var r in e)!e.hasOwnProperty(r)||n===!1&&t.hasOwnProperty(r)||(t[r]=e[r]);return t}function Pi(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function Bi(e,t){return t?t.source.indexOf("\\w")>-1&&ql(e)?!0:t.test(e):ql(e)}function zi(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function _i(e){return e.charCodeAt(0)>=768&&Ul.test(e)}function Ri(e,t,n,r){var i=document.createElement(e);if(n&&(i.className=n),r&&(i.style.cssText=r),"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 qi(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function Ui(e,t){return qi(e).appendChild(t)}function Gi(){for(var e=document.activeElement;e&&e.root&&e.root.activeElement;)e=e.root.activeElement;return e}function ji(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function $i(e,t){for(var n=e.split(" "),r=0;r<n.length;r++)n[r]&&!ji(n[r]).test(t)&&(t+=" "+n[r]);return t}function Vi(e){if(document.body.getElementsByClassName)for(var t=document.body.getElementsByClassName("CodeMirror"),n=0;n<t.length;n++){var r=t[n].CodeMirror;r&&e(r)}}function Ki(){Xl||(Xi(),Xl=!0)}function Xi(){var e;Ml(window,"resize",function(){null==e&&(e=setTimeout(function(){e=null,Vi(Ut)},100))}),Ml(window,"blur",function(){Vi(vn)})}function Yi(e){if(null==jl){var t=Ri("span","");Ui(e,Ri("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(jl=t.offsetWidth<=1&&t.offsetHeight>2&&!(mo&&8>vo))}var n=jl?Ri("span",""):Ri("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}function Zi(e){if(null!=$l)return $l;var t=Ui(e,document.createTextNode("AخA")),n=_l(t,0,1).getBoundingClientRect();if(!n||n.left==n.right)return!1;var r=_l(t,1,2).getBoundingClientRect();return $l=r.right-n.right<3}function Qi(e){if(null!=ea)return ea;var t=Ui(e,Ri("span","x")),n=t.getBoundingClientRect(),r=_l(t,0,1).getBoundingClientRect();return ea=Math.abs(n.left-r.left)>1}function Ji(e,t,n,r){if(!e)return r(t,n,"ltr");for(var i=!1,o=0;o<e.length;++o){var l=e[o];(l.from<n&&l.to>t||t==n&&l.to==t)&&(r(Math.max(l.from,t),Math.min(l.to,n),1==l.level?"rtl":"ltr"),i=!0)}i||r(t,n,"ltr")}function eo(e){return e.level%2?e.to:e.from}function to(e){return e.level%2?e.from:e.to}function no(e){var t=ri(e);return t?eo(t[0]):0}function ro(e){var t=ri(e);return t?to(Hi(t)):e.text.length}function io(e,t){var n=Yr(e.doc,t),r=vr(n);r!=n&&(t=ei(r));var i=ri(r),o=i?i[0].level%2?ro(r):no(r):0;return Wo(t,o)}function oo(e,t){for(var n,r=Yr(e.doc,t);n=gr(r);)r=n.find(1,!0).line,t=null;var i=ri(r),o=i?i[0].level%2?no(r):ro(r):r.text.length;return Wo(null==t?ei(r):t,o)}function lo(e,t){var n=io(e,t.line),r=Yr(e.doc,n.line),i=ri(r);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 Wo(n.line,l?0:o)}return n}function ao(e,t,n){var r=e[0].level;return t==r?!0:n==r?!1:n>t}function so(e,t){na=null;for(var n,r=0;r<e.length;++r){var i=e[r];if(i.from<t&&i.to>t)retu
Gn("pollInterval",100),Gn("undoDepth",200,function(e,t){e.doc.history.undoDepth=t}),Gn("historyEventDelay",1250),Gn("viewportMargin",10,function(e){e.refresh()},!0),Gn("maxHighlightLength",1e4,r,!0),Gn("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),Gn("tabindex",null,function(e,t){e.display.input.getField().tabIndex=t||""}),Gn("autofocus",null);var Jo=e.modes={},el=e.mimeModes={};e.defineMode=function(t,n){e.defaults.mode||"null"==t||(e.defaults.mode=t),arguments.length>2&&(n.dependencies=Array.prototype.slice.call(arguments,2)),Jo[t]=n},e.defineMIME=function(e,t){el[e]=t},e.resolveMode=function(t){if("string"==typeof t&&el.hasOwnProperty(t))t=el[t];else if(t&&"string"==typeof t.name&&el.hasOwnProperty(t.name)){var n=el[t.name];"string"==typeof n&&(n={name:n}),t=Ii(n,t),t.name=n.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,n){var n=e.resolveMode(n),r=Jo[n.name];if(!r)return e.getMode(t,"text/plain");var i=r(t,n);if(tl.hasOwnProperty(n.name)){var o=tl[n.name];for(var l in o)o.hasOwnProperty(l)&&(i.hasOwnProperty(l)&&(i["_"+l]=i[l]),i[l]=o[l])}if(i.name=n.name,n.helperType&&(i.helperType=n.helperType),n.modeProps)for(var l in n.modeProps)i[l]=n.modeProps[l];return i},e.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),e.defineMIME("text/plain","null");var tl=e.modeExtensions={};e.extendMode=function(e,t){var n=tl.hasOwnProperty(e)?tl[e]:tl[e]={};Fi(t,n)},e.defineExtension=function(t,n){e.prototype[t]=n},e.defineDocExtension=function(e,t){xl.prototype[e]=t},e.defineOption=Gn;var nl=[];e.defineInitHook=function(e){nl.push(e)};var rl=e.helpers={};e.registerHelper=function(t,n,r){rl.hasOwnProperty(t)||(rl[t]=e[t]={_global:[]}),rl[t][n]=r},e.registerGlobalHelper=function(t,n,r,i){e.registerHelper(t,n,i),rl[t]._global.push({pred:r,val:i})};var il=e.copyState=function(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var n={};for(var r in t){var i=t[r];i instanceof Array&&(i=i.concat([])),n[r]=i}return n},ol=e.startState=function(e,t,n){return e.startState?e.startState(t,n):!0};e.innerMode=function(e,t){for(;e.innerMode;){var n=e.innerMode(t);if(!n||n.mode==e)break;t=n.state,e=n.mode}return n||{mode:e,state:t}};var ll=e.commands={selectAll:function(e){e.setSelection(Wo(e.firstLine(),0),Wo(e.lastLine()),El)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),El)},killLine:function(e){Rn(e,function(t){if(t.empty()){var n=Yr(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line<e.lastLine()?{from:t.head,to:Wo(t.head.line+1,0)}:{from:t.head,to:Wo(t.head.line,n)}}return{from:t.from(),to:t.to()}})},deleteLine:function(e){Rn(e,function(t){return{from:Wo(t.from().line,0),to:me(e.doc,Wo(t.to().line+1,0))}})},delLineLeft:function(e){Rn(e,function(e){return{from:Wo(e.from().line,0),to:e.from()}})},delWrappedLineLeft:function(e){Rn(e,function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:n},"div");return{from:r,to:t.from()}})},delWrappedLineRight:function(e){Rn(e,function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div");return{from:t.from(),to:r}})},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(Wo(e.firstLine(),0))},goDocEnd:function(e){e.extendSelection(Wo(e.lastLine()))},goLineStart:function(e){e.extendSelectionsBy(function(t){return io(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){e.extendSelectionsBy(function(t){return lo(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){e.extendSelectionsBy(function(t){return oo(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){e.extendSelectionsBy(function(t){var n=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div")},Il)},goLineLeft:function
this.level=e,this.from=t,this.to=n}var n="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",r="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",i=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,l=/[LRr]/,a=/[Lb1n]/,s=/[1n]/,u="L";return function(n){if(!i.test(n))return!1;for(var r,c=n.length,h=[],d=0;c>d;++d)h.push(r=e(n.charCodeAt(d)));for(var d=0,f=u;c>d;++d){var r=h[d];"m"==r?h[d]=f:f=r}for(var d=0,p=u;c>d;++d){var r=h[d];"1"==r&&"r"==p?h[d]="n":l.test(r)&&(p=r,"r"==r&&(h[d]="R"))}for(var d=1,f=h[0];c-1>d;++d){var r=h[d];"+"==r&&"1"==f&&"1"==h[d+1]?h[d]="1":","!=r||f!=h[d+1]||"1"!=f&&"n"!=f||(h[d]=f),f=r}for(var d=0;c>d;++d){var r=h[d];if(","==r)h[d]="N";else if("%"==r){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 r=h[d];"L"==p&&"1"==r?h[d]="L":l.test(r)&&(p=r)}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=n.match(/^\s+/))&&(w[0].from=x[0].length,w.unshift(new t(0,0,x[0].length))),1==Hi(w).level&&(x=n.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.7.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*)/,n=/^(\s*)(>[> ]*|[*+-]|(\d+)[.)])(\s*)$/,r=/[*+-]\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(n.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=r.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(),n=t[0].head,r=e.getStateAfter(n.line),i=r.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(),n=t[0].head,r=e.getStateAfter(n.line),i=r.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:windo
return typo&&!typo.check(r)?"spell-error":null}},l=CodeMirror.getMode(e,e.backdrop||"text/plain");return CodeMirror.overlayMode(l,o,!0)}),String.prototype.includes||(String.prototype.includes=function(){"use strict";return-1!==String.prototype.indexOf.apply(this,arguments)}),function(){function e(e){this.tokens=[],this.tokens.links={},this.options=e||u.defaults,this.rules=c.normal,this.options.gfm&&(this.options.tables?this.rules=c.tables:this.rules=c.gfm)}function t(e,t){if(this.options=t||u.defaults,this.links=e,this.rules=h.normal,this.renderer=this.options.renderer||new n,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.options.breaks?this.rules=h.breaks:this.rules=h.gfm:this.options.pedantic&&(this.rules=h.pedantic)}function n(e){this.options=e||{}}function r(e){this.tokens=[],this.token=null,this.options=e||u.defaults,this.options.renderer=this.options.renderer||new n,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 n(r,i){return r?(i=i.source||i,i=i.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,i),n):new RegExp(e,t)}}function a(){}function s(e){for(var t,n,r=1;r<arguments.length;r++){t=arguments[r];for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}function u(t,n,o){if(o||"function"==typeof n){o||(o=n,n=null),n=s({},u.defaults,n||{});var l,a,c=n.highlight,h=0;try{l=e.lex(t,n)}catch(d){return o(d)}a=l.length;var f=function(e){if(e)return n.highlight=c,o(e);var t;try{t=r.parse(l,n)}catch(i){e=i}return n.highlight=c,e?o(e):o(null,t)};if(!c||c.length<3)return f();if(delete n.highlight,!a)return f();for(;h<l.length;h++)!function(e){return"code"!==e.type?--a||f():c(e.text,e.lang,function(t,n){return t?f(t):null==n||n===e.text?--a||f():(e.text=n,e.escaped=!0,void(--a||f()))})}(l[h])}else try{return n&&(n=s({},u.defaults,n)),r.parse(e.lex(t,n),n)}catch(d){if(d.message+="\nPlease report this to https://github.com/chjj/marked.",(n||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",