mirror of https://github.com/mindoc-org/mindoc.git
2 lines
63 KiB
Go
2 lines
63 KiB
Go
/*! Editor.md v1.7.17 | editormd.amd.min.js | Open source online markdown editor. | MIT License | By: IBM Skills Network | https://github.com/ibm-skills-network/editor.md | 2024-03-27 */
|
||
!function(e){"use strict";var t;"function"==typeof require&&"object"==typeof exports&&"object"==typeof module?module.exports=e:"function"==typeof define?define.amd?define(["jquery","marked","prettify","katex","raphael","underscore","flowchart","jqueryflowchart","sequenceDiagram","codemirror/lib/codemirror",(t="codemirror/mode/")+"css/css",t+"sass/sass",t+"shell/shell",t+"sql/sql",t+"clike/clike",t+"php/php",t+"xml/xml",t+"markdown/markdown",t+"javascript/javascript",t+"htmlmixed/htmlmixed",t+"gfm/gfm",t+"http/http",t+"go/go",t+"dart/dart",t+"coffeescript/coffeescript",t+"nginx/nginx",t+"python/python",t+"perl/perl",t+"lua/lua",t+"r/r",t+"ruby/ruby",t+"rst/rst",t+"smartymixed/smartymixed",t+"vb/vb",t+"vbscript/vbscript",t+"velocity/velocity",t+"xquery/xquery",t+"yaml/yaml",t+"erlang/erlang",t+"jade/jade",(t="codemirror/addon/")+"edit/trailingspace",t+"dialog/dialog",t+"search/searchcursor",t+"search/search",t+"scroll/annotatescrollbar",t+"search/matchesonscrollbar",t+"display/placeholder",t+"edit/closetag",t+"fold/foldcode",t+"fold/foldgutter",t+"fold/indent-fold",t+"fold/brace-fold",t+"fold/xml-fold",t+"fold/markdown-fold",t+"fold/comment-fold",t+"mode/overlay",t+"selection/active-line",t+"edit/closebrackets",t+"display/fullscreen",t+"search/match-highlighter"],e):define(["jquery"],e):window.editormd=e()}(function(){"function"==typeof define&&define.amd&&(v=arguments[0],marked=arguments[1],prettify=arguments[2],katex=arguments[3],Raphael=arguments[4],_=arguments[5],flowchart=arguments[6],CodeMirror=arguments[9]);var C,c,h,e,d,v="undefined"!=typeof jQuery?jQuery:Zepto;if(void 0!==v)return(C=function(e,t,i){return new C.fn.init(e,t,i)}).title=C.$name="Editor.md",C.version="1.7.17",C.homePage="https://pandao.github.io/editor.md/",C.classPrefix="editormd-",C.toolbarModes={full:["undo","redo","|","bold","del","italic","quote","ucwords","uppercase","lowercase","|","h1","h2","h3","h4","h5","h6","|","list-ul","list-ol","hr","|","link","reference-link","image","code","preformatted-text","code-block","table","datetime","emoji","html-entities","pagebreak","|","goto-line","watch","preview","fullscreen","clear","search","|","help","changetheme","info"],simple:["undo","redo","|","bold","del","italic","quote","uppercase","lowercase","|","h1","h2","h3","h4","h5","h6","|","list-ul","list-ol","hr","|","watch","preview","fullscreen","|","help","changetheme","info"],mini:["undo","redo","|","watch","preview","|","help","changetheme","info"]},C.defaults={debug:!1,mode:"gfm",name:"",value:"",theme:"",editorTheme:"default",previewTheme:"",markdown:void 0,appendMarkdown:"",width:"100%",height:"100%",path:"./lib/",pluginPath:"",customPluginPath:"",delay:300,autoLoadModules:!0,watch:!0,placeholder:"Enjoy Markdown! coding now...",gotoLine:!0,codeFold:!1,autoHeight:!1,autoFocus:!0,autoCloseTags:!0,searchReplace:!0,syncScrolling:!0,readOnly:!1,tabSize:4,indentUnit:4,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,showTrailingSpace:!0,matchBrackets:!0,indentWithTabs:!0,styleSelectedText:!0,matchWordHighlight:!0,styleActiveLine:!0,dialogLockScreen:!0,dialogShowMask:!0,dialogDraggable:!0,dialogMaskBgColor:"#fff",dialogMaskOpacity:.1,fontSize:"13px",saveHTMLToTextarea:!1,disabledKeyMaps:[],onload:function(){},onresize:function(){},onchange:function(){},onwatch:null,onunwatch:null,onpreviewing:function(){},onCmChange:null,fixCodeBlocks:function(){},onpreviewed:function(){},onfullscreen:function(){},onfullscreenExit:function(){},onscroll:function(){},onpreviewscroll:function(){},imageUpload:!1,imageFormats:["jpg","jpeg","gif","png","bmp","webp"],imageUploadURL:"",crossDomainUpload:!1,uploadCallbackURL:"",toc:!0,tocm:!1,tocTitle:"",tocDropdown:!1,tocContainer:"",tocStartLevel:1,htmlDecode:!1,pageBreak:!0,atLink:!0,emailLink:!0,taskList:!1,emoji:!0,tex:!1,flowChart:!1,sequenceDiagram:!1,mermaid:!0,mindMap:!0,previewCodeHighlight:!0,toolbar:!0,toolbarAutoFixed:!0,titlebar:{left:{},center:{},right:{}},toolbarIcons:"full",toolbarTitles:{},toolbarHandlers:{ucwords:function(){return C.toolbarHandlers.ucwords},lowercase:function(){return C.toolbarHandlers.lowercase}},toolbarCustomIcons:{lowercase:'<i class="fa" name="lowercase" style="font-size:24px;margin-top: -10px;">a</i>',ucwords:'<i class="fa" name="ucwords" style="font-size:20px;margin-top: -3px;">Aa</i>',fontcase:'<i class="fa" name="fontcase" unselectable="on"><span class="icon-text" style="font-size: 1rem;">Aa</span></i>'},toolbarIconsClass:{undo:"fa-undo",redo:"fa-repeat",bold:"fa-bold",del:"fa-strikethrough",italic:"fa-italic",quote:"fa-quote-left",uppercase:"fa-font",heading:"fa-header",h1:C.classPrefix+"bold",h2:C.classPrefix+"bold",h3:C.classPrefix+"bold",h4:C.classPrefix+"bold",h5:C.classPrefix+"bold",h6:C.classPrefix+"bold","list-ul":"fa-list-ul","list-ol":"fa-list-ol",hr:"fa-minus",link:"fa-link","reference-link":"fa-anchor",image:"fa-picture-o",code:"fa-code","preformatted-text":"fa-file-code-o","code-block":"fa-file-code-o",table:"fa-table",datetime:"fa-clock-o",emoji:"fa-smile-o","html-entities":"fa-copyright",pagebreak:"fa-newspaper-o","goto-line":"fa-terminal",watch:"fa-eye-slash",unwatch:"fa-eye",preview:"fa-desktop",search:"fa-search",fullscreen:"fa-arrows-alt",clear:"fa-eraser",help:"fa-question-circle",changetheme:"fa-info-circle",info:"fa-info-circle"},toolbarIconTexts:{ucwords:"Capitalize",uppercase:"Uppercase",lowercase:"Lowercase",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6"},lang:{name:"zh-cn",description:"开源在线Markdown编辑器<br/>Open source online Markdown editor.",tocTitle:"目录",toolbar:{undo:"撤销(Ctrl+Z)",redo:"重做(Ctrl+Y)",bold:"粗体",del:"删除线",italic:"斜体",quote:"引用",ucwords:"将每个单词首字母转成大写",uppercase:"将所选转换成大写",lowercase:"将所选转换成小写",h1:"标题1",h2:"标题2",h3:"标题3",h4:"标题4",h5:"标题5",h6:"标题6","list-ul":"无序列表","list-ol":"有序列表",hr:"横线",link:"链接","reference-link":"引用链接",image:"添加图片",code:"行内代码","preformatted-text":"预格式文本 / 代码块(缩进风格)","code-block":"代码块(多语言风格)",table:"添加表格",datetime:"日期时间",emoji:"Emoji表情","html-entities":"HTML实体字符",pagebreak:"插入分页符","goto-line":"跳转到行",watch:"关闭实时预览",unwatch:"开启实时预览",preview:"全窗口预览HTML(按 Shift + ESC还原)",fullscreen:"全屏(按ESC还原)",clear:"清空",search:"搜索",help:"使用帮助",changetheme:"切换编辑主题",info:"关于"+C.title},buttons:{enter:"确定",cancel:"取消",close:"关闭"},dialog:{link:{title:"添加链接",url:"链接地址",urlTitle:"链接标题",urlEmpty:"错误:请填写链接地址。"},referenceLink:{title:"添加引用链接",name:"引用名称",url:"链接地址",urlId:"链接ID",urlTitle:"链接标题",nameEmpty:"错误:引用链接的名称不能为空。",idEmpty:"错误:请填写引用链接的ID。",urlEmpty:"错误:请填写引用链接的URL地址。"},image:{title:"添加图片",url:"图片地址",link:"图片链接",alt:"图片描述",uploadButton:"本地上传",imageURLEmpty:"错误:图片地址不能为空。",uploadFileEmpty:"错误:上传的图片不能为空。",formatNotAllowed:"错误:只允许上传图片文件,允许上传的图片文件格式有:"},preformattedText:{title:"添加预格式文本或代码块",emptyAlert:"错误:请填写预格式文本或代码的内容。"},codeBlock:{title:"添加代码块",selectLabel:"代码语言:",selectDefaultText:"请选择代码语言",otherLanguage:"其他语言",unselectedLanguageAlert:"错误:请选择代码所属的语言类型。",codeEmptyAlert:"错误:请填写代码内容。"},htmlEntities:{title:"HTML 实体字符"},help:{title:"使用帮助"},changetheme:{title:"切换编辑主题"}}}},C.classNames={tex:C.classPrefix+"tex",texDisplay:C.classPrefix+"texDisaply"},C.dialogZindex=99999,C.$katex=null,C.$marked=null,C.$filterXSS=null,C.$CodeMirror=null,C.$prettyPrint=null,C.prototype=C.fn={state:{watching:!1,loaded:!1,preview:!1,fullscreen:!1},init:function(e,t,i){i="object"==typeof e?e:i||{};var o=this.classPrefix=C.classPrefix,i=this.settings=v.extend(!0,{},C.defaults,i),n=(e="object"==typeof e?i.id:e,this.editor=v("#"+e)),t=(this.id=e,this.author_ide_version=t||n.version,this.lang=i.lang,this.classNames={textarea:{html:o+"html-textarea",markdown:o+"markdown-textarea"}}),r=(i.pluginPath=""===i.pluginPath?i.path+"../plugins/":i.pluginPath,this.state.watching=!!i.watch,n.hasClass("editormd")||n.addClass("editormd"),n.css({width:"number"==typeof i.width?i.width+"px":i.width,height:"number"==typeof i.height?i.height+"px":i.height}),i.autoHeight&&n.css("height","auto"),this.markdownTextarea=n.children("textarea")),e=(r.length<1&&(n.append("<textarea></textarea>"),r=this.markdownTextarea=n.children("textarea")),r.addClass(t.textarea.markdown).attr("placeholder",i.placeholder),void 0!==r.attr("name")&&""!==r.attr("name")||r.attr("name",""!==i.name?i.name:e+"-markdown-doc"),[i.readOnly?"":'<a href="javascript:;" class="fa fa-close '+o+'preview-close-btn"></a>',i.saveHTMLToTextarea?'<textarea class="'+t.textarea.html+'" name="'+e+'-html-code"></textarea>':"",'<div class="'+o+'preview"><div class="markdown-body '+o+'preview-container"></div></div>','<div class="'+o+'container-mask" style="display:block;"></div>','<div class="'+o+'mask"></div>'].join("\n"));return n.append(e).addClass(o+"vertical"),""!==i.theme&&n.addClass(o+"theme-"+i.theme),this.mask=n.children("."+o+"mask"),this.containerMask=n.children("."+o+"container-mask"),void 0!==i.markdown&&r.val(i.markdown),""!==i.appendMarkdown&&r.val(r.val()+i.appendMarkdown),this.htmlTextarea=n.children("."+t.textarea.html),this.preview=n.children("."+o+"preview"),this.previewContainer=this.preview.children("."+o+"preview-container"),""!==i.previewTheme&&this.preview.addClass(o+"preview-theme-"+i.previewTheme),"function"==typeof define&&define.amd&&("undefined"!=typeof katex&&(C.$katex=katex),i.searchReplace)&&!i.readOnly&&(C.loadCSS(i.path+"codemirror/addon/dialog/dialog"),C.loadCSS(i.path+"codemirror/addon/search/matchesonscrollbar")),"function"==typeof define&&define.amd||!i.autoLoadModules?("undefined"!=typeof CodeMirror&&(C.$CodeMirror=CodeMirror),"undefined"!=typeof marked&&(C.$marked=marked),this.setCodeMirror().setToolbar().loadedDisplay()):this.loadQueues(),this},loadQueues:function(){function e(){!C.isIE8&&(i.flowChart||i.sequenceDiagram)?C.loadScript(o+"raphael.min",function(){C.loadScript(o+"underscore.min",function(){!i.flowChart&&i.sequenceDiagram?C.loadScript(o+"sequence-diagram.min",function(){t.loadedDisplay()}):i.flowChart&&!i.sequenceDiagram?C.loadScript(o+"flowchart.min",function(){C.loadScript(o+"jquery.flowchart.min",function(){t.loadedDisplay()})}):i.flowChart&&i.sequenceDiagram&&C.loadScript(o+"flowchart.min",function(){C.loadScript(o+"jquery.flowchart.min",function(){C.loadScript(o+"sequence-diagram.min",function(){t.loadedDisplay()})})})})}):t.loadedDisplay()}var t=this,i=this.settings,o=i.path;return C.loadScript(o+"xss",function(){C.$filterXSS=filterXSS}),C.loadCSS(o+"codemirror/codemirror.min"),i.searchReplace&&!i.readOnly&&(C.loadCSS(o+"codemirror/addon/dialog/dialog"),C.loadCSS(o+"codemirror/addon/search/matchesonscrollbar")),i.codeFold&&C.loadCSS(o+"codemirror/addon/fold/foldgutter"),C.loadScript(o+"codemirror/codemirror.min",function(){C.$CodeMirror=CodeMirror,C.loadScript(o+"codemirror/modes.min",function(){C.loadScript(o+"codemirror/addons.min",function(){if(t.setCodeMirror(),"gfm"!==i.mode&&"markdown"!==i.mode)return t.loadedDisplay(),!1;t.setToolbar(),C.loadScript(o+"marked.min",function(){C.$marked=marked,i.highlightStyle||(i.highlightStyle="github"),i.previewCodeHighlight?(C.loadCSS(o+"highlight/styles/"+i.highlightStyle),C.loadScript(o+"highlight/highlight",function(){e()})):e()})})})}),this},setTheme:function(e){var t=this.editor,i=this.settings.theme,o=this.classPrefix+"theme-";return t.removeClass(o+i).addClass(o+e),this.settings.theme=e,this},setEditorTheme:function(e){var t=this.settings;return"default"!==(t.editorTheme=e)&&C.loadCSS(t.path+"codemirror/theme/"+t.editorTheme),this.cm.setOption("theme",e),this},setCodeMirrorTheme:function(e){return this.setEditorTheme(e),this},setPreviewTheme:function(e){var t=this.preview,i=this.settings.previewTheme,o=this.classPrefix+"preview-theme-";return t.removeClass(o+i).addClass(o+e),this.settings.previewTheme=e,this},setCodeMirror:function(){var e=this.settings,t=this.editor,i=("default"!==e.editorTheme&&C.loadCSS(e.path+"codemirror/theme/"+e.editorTheme),{mode:e.mode,theme:e.editorTheme,tabSize:e.tabSize,dragDrop:!1,autofocus:e.autoFocus,autoCloseTags:e.autoCloseTags,readOnly:!!e.readOnly&&"nocursor",indentUnit:e.indentUnit,lineNumbers:e.lineNumbers,lineWrapping:e.lineWrapping,extraKeys:{"Ctrl-Q":function(e){e.foldCode(e.getCursor())}},foldGutter:e.codeFold,gutters:["CodeMirror-linenumbers","CodeMirror-foldgutter"],matchBrackets:e.matchBrackets,indentWithTabs:e.indentWithTabs,styleActiveLine:e.styleActiveLine,styleSelectedText:e.styleSelectedText,autoCloseBrackets:e.autoCloseBrackets,showTrailingSpace:e.showTrailingSpace,highlightSelectionMatches:!!e.matchWordHighlight&&{showToken:"onselected"!==e.matchWordHighlight&&/\w/}});return this.codeEditor=this.cm=C.$CodeMirror.fromTextArea(this.markdownTextarea[0],i),this.codeMirror=this.cmElement=t.children(".CodeMirror"),""!==e.value&&this.cm.setValue(e.value),this.codeMirror.css({fontSize:e.fontSize,width:e.watch?"50%":"100%"}),e.autoHeight&&(this.codeMirror.css("height","auto"),this.cm.setOption("viewportMargin",1/0)),e.lineNumbers||this.codeMirror.find(".CodeMirror-gutters").css("border-right","none"),this},getCodeMirrorOption:function(e){return this.cm.getOption(e)},setCodeMirrorOption:function(e,t){return this.cm.setOption(e,t),this},addKeyMap:function(e,t){return this.cm.addKeyMap(e,t),this},removeKeyMap:function(e){return this.cm.removeKeyMap(e),this},gotoLine:function(e){var t,i,o,n,r=this.settings;return r.gotoLine&&(t=this.cm,this.editor,o=t.lineCount(),i=this.preview,"number"!=typeof(e="string"==typeof e&&"first"===(e="last"===e?o:e)?1:e)?alert("Error: The line number must be an integer."):o<(e=parseInt(e)-1)?alert("Error: The line number range 1-"+o):(t.setCursor({line:e,ch:0}),o=t.getScrollInfo().clientHeight,e=t.charCoords({line:e,ch:0},"local"),t.scrollTo(null,(e.top+e.bottom-o)/2),r.watch&&(e=this.codeMirror.find(".CodeMirror-scroll")[0],o=v(e).height(),n=(r=e.scrollTop)/e.scrollHeight,0===r?i.scrollTop(0):r+o>=e.scrollHeight-16?i.scrollTop(i[0].scrollHeight):i.scrollTop(i[0].scrollHeight*n)),t.focus())),this},extend:function(){return void 0!==arguments[1]&&("function"==typeof arguments[1]&&(arguments[1]=v.proxy(arguments[1],this)),this[arguments[0]]=arguments[1]),"object"==typeof arguments[0]&&void 0===arguments[0].length&&v.extend(!0,this,arguments[0]),this},set:function(e,t){return void 0!==t&&"function"==typeof t&&(t=v.proxy(t,this)),this[e]=t,this},config:function(e,t){var i=this.settings;return"object"==typeof e&&(i=v.extend(!0,i,e)),"string"==typeof e&&(i[e]=t),this.settings=i,this.recreate(),this},on:function(e,t){var i=this.settings;return void 0!==i["on"+e]&&(i["on"+e]=v.proxy(t,this)),this},off:function(e){var t=this.settings;return void 0!==t["on"+e]&&(t["on"+e]=function(){}),this},showToolbar:function(e){var t=this.settings;return t.readOnly||(t.toolbar&&(this.toolbar.length<1||""===this.toolbar.find("."+this.classPrefix+"menu").html())&&this.setToolbar(),t.toolbar=!0,this.toolbar.show(),this.resize(),v.proxy(e||function(){},this)()),this},hideToolbar:function(e){return this.settings.toolbar=!1,this.toolbar.hide(),this.resize(),v.proxy(e||function(){},this)(),this},setToolbarAutoFixed:function(e){var t=this.state,i=this.editor,o=this.toolbar,n=this.settings;void 0!==e&&(n.toolbarAutoFixed=e);return!t.fullscreen&&!t.preview&&n.toolbar&&n.toolbarAutoFixed&&v(window).bind("scroll",function(){var e=v(window),t=e.scrollTop();if(!n.toolbarAutoFixed)return!1;10<t-i.offset().top&&t<i.height()?o.css({position:"fixed",width:i.width()+"px",left:(e.width()-i.width())/2+"px"}):o.css({position:"absolute",width:"100%",left:0})}),this},setToolbar:function(){var a=this.settings;if(!a.readOnly){var e=this.editor,s=(this.preview,this.classPrefix),t="function"==typeof a.titlebar?a.titlebar():a.titlebar,i=this.toolbar=e.children("."+s+"toolbar");if(a.toolbar&&i.length<1&&(e.append('<div class="'+s+'toolbar"> <div class="'+s+'titlebar-container"> </div> <div class="'+s+'toolbar-container"> <ul class="'+s+'menu"></ul> </div> </div>'),i=this.toolbar=e.children("."+s+"toolbar")),a.toolbar){for(var l="",o=(Object.entries(t).forEach(([e,t])=>{var i="";if("left"===e)i='<img class="sn-logo"><span class="home-title">Skills Network Author IDE</span>';else for(var o in t){var n=o.replace(/\s+/g,"-").toLowerCase(),r="string"==typeof a.lang.titlebar[o]?a.lang.titlebar[o]:"";switch(t[o]){case"dropdown":i+='<div class="'+s+'titlebar-dropdown"> <button class="'+s+"titlebar-button "+n+'" title="'+r+'"> <span class="dropdown-text">'+o+'</span> <span class="'+s+'titlebar-dropdown-chevron"></span> </button> <div class="toolbar-dropdown-content"></div> </div>';break;case"button":i+='<button class="'+s+"titlebar-button "+n+'" title="'+r+'">'+o+"</button>";break;default:i+='<span class="'+s+"titlebar "+n+'" title="'+r+'">'+o+"</span>"}}l+='<div class="'+s+"titlebar-section "+e+'">'+i+"</div>"}),i.find("div."+s+"titlebar-container").html(l),i.show(),"function"==typeof a.toolbarIcons?a.toolbarIcons():"string"==typeof a.toolbarIcons?C.toolbarModes[a.toolbarIcons]:a.toolbarIcons),e=i.find("."+this.classPrefix+"menu"),n="",r=!1,c=0,h=o.length;c<h;c++)if("||"===(u=o[c]))r=!0;else if("|"===u)n+='<li class="divider" unselectable="on"></li>';else{var d,u,f=u.includes("dropdown"),p=[],g=(r&&p.push("pull-right"),f&&p.push("dropdown"),0<p.length?'<li class="'+p.join(" ")+'">':"<li>"),m=[];f?(d=(p=u.split(":"))[0],u=p[1],p=p[2].split(","),m=[u].concat(p),p.length||(f=!1)):m.push(u);for(var w=0,h=m.length;w<h;w++){u=m[w].trim(),f&&1===w&&(g+='<div class="toolbar-dropdown-content">');var v=!(f&&"dropdownIcon"!==d&&g.includes("toolbar-dropdown-content")),b=/h(\d)/.test(u),x=u,k=("watch"!==u||a.watch||(x="unwatch"),a.lang.toolbar[x]),y=void 0===(y=a.toolbarIconTexts[x])?"":y,x=void 0!==(x=a.toolbarIconsClass[x])&&v?x:"";g+='<a href="javascript:;"title="'+(void 0===k||f?"":k)+'" unselectable="on">',v&&void 0!==a.toolbarCustomIcons[u]&&"function"!=typeof a.toolbarCustomIcons[u]?g+=a.toolbarCustomIcons[u]:(g+='<i class="fa '+x+'" name="'+u+'" unselectable="on">',"function"!=typeof a.toolbarIcons&&b?g+='<span class="icon-text">'+u.toUpperCase()+"</span>":d&&"dropdownIcon"===d&&g.includes("toolbar-dropdown-content")?g+='<span class="icon-text dropdown">'+(y||u)+"</span>":""!==x&&v||(g+='<span class="icon-text">'+(y||u)+"</span>"),g+="</i>"),g+="</a>",f&&w===h-1&&g.includes("toolbar-dropdown-content")&&(g+="</div>",d="")}g+="</li>",n=r?g+n:n+g}e.html(n),e.find('[title="Lowercase"]').attr("title",a.lang.toolbar.lowercase),e.find('[title="ucwords"]').attr("title",a.lang.toolbar.ucwords),this.setToolbarHandler(),this.setToolbarAutoFixed()}else i.hide()}return this},dialogLockScreen:function(){return v.proxy(C.dialogLockScreen,this)(),this},dialogShowMask:function(e){return v.proxy(C.dialogShowMask,this)(e),this},positionDialog:function(e,t){return v.proxy(C.positionDialog,this)(e,t),this},getToolbarHandles:function(e){var t=this.toolbarHandlers=C.toolbarHandlers;return e&&void 0!==toolbarIconHandlers[e]?t[e]:t},setToolbarHandler:function(){var n,e,t,r,a=this,s=this.settings;return s.toolbar&&!s.readOnly&&(t=this.toolbar,n=this.cm,e=this.classPrefix,t=this.toolbarIcons=t.find("."+e+"menu > li a"),r=this.getToolbarHandles(),t.bind(C.mouseOrTouch("click","touchend"),function(){var e=v(this).children(".fa"),t=e.attr("name"),i=n.getCursor(),o=n.getSelection();if(""!==t)return a.activeIcon=e,void 0!==r[t]?v.proxy(r[t],a)(n):void 0!==s.toolbarHandlers[t]&&v.proxy(s.toolbarHandlers[t],a)(n,e,i,o),"link"!==t&&"reference-link"!==t&&"image"!==t&&"code-block"!==t&&"preformatted-text"!==t&&"watch"!==t&&"preview"!==t&&"search"!==t&&"fullscreen"!==t&&"info"!==t&&n.focus(),!1})),this},createDialog:function(e){return v.proxy(C.createDialog,this)(e)},createInfoDialog:function(){var e=this,t=this.editor,i=this.classPrefix,o=['<div class="'+i+"dialog "+i+'dialog-info" style="">','<div class="'+i+'dialog-container">','<h1><i class="editormd-logo editormd-logo-lg editormd-logo-color"></i> '+C.title+"<small>v"+C.version+"</small></h1>","<p>"+this.lang.description+"</p>",'<p style="margin: 10px 0 20px 0;"><a href="'+C.homePage+'" target="_blank">'+C.homePage+' <i class="fa fa-external-link"></i></a></p>','<p style="font-size: 0.85em;">Copyright © 2015 <a href="https://github.com/pandao" target="_blank" class="hover-link">Pandao</a>, The <a href="https://github.com/pandao/editor.md/blob/master/LICENSE" target="_blank" class="hover-link">MIT</a> License.</p>',"</div>",'<a href="javascript:;" class="fa fa-close '+i+'dialog-close"></a>',"</div>"].join("\n"),o=(t.append(o),this.infoDialog=t.children("."+i+"dialog-info"));return o.find("."+i+"dialog-close").bind(C.mouseOrTouch("click","touchend"),function(){e.hideInfoDialog()}),o.css("border",C.isIE8?"1px solid #ddd":"").css("z-index",C.dialogZindex).show(),this.infoDialogPosition(),this},infoDialogPosition:function(){function e(){t.css({top:(v(window).height()-t.height())/2+"px",left:(v(window).width()-t.width())/2+"px"})}var t=this.infoDialog;return e(),v(window).resize(e),this},showInfoDialog:function(){v("html,body").css("overflow-x","hidden");var e=this.editor,t=this.settings,e=this.infoDialog=e.children("."+this.classPrefix+"dialog-info");return e.length<1&&this.createInfoDialog(),this.lockScreen(!0),this.mask.css({opacity:t.dialogMaskOpacity,backgroundColor:t.dialogMaskBgColor}).show(),e.css("z-index",C.dialogZindex).show(),this.infoDialogPosition(),this},hideInfoDialog:function(){return v("html,body").css("overflow-x",""),this.infoDialog.hide(),this.mask.hide(),this.lockScreen(!1),this},lockScreen:function(e){return C.lockScreen(e),this.resize(),this},recreate:function(){var e=this.editor,t=this.settings;return this.codeMirror.remove(),this.setCodeMirror(),t.readOnly||(0<e.find(".editormd-dialog").length&&e.find(".editormd-dialog").remove(),t.toolbar&&(this.getToolbarHandles(),this.setToolbar())),this.loadedDisplay(!0),this},previewCodeHighlight:function(){var e=this.settings,t=this.previewContainer;return e.previewCodeHighlight&&(t.find("pre").addClass("prettyprint linenums"),"undefined"!=typeof prettyPrint&&prettyPrint(v.proxy(e.fixCodeBlocks,this)),t.find("pre").each(function(e,t){hljs.highlightBlock(t)})),this},katexRender:function(){return null!==c&&(this.previewContainer.find("."+C.classNames.tex).each(function(){var e=v(this);C.$katex.render(e.text(),e[0],{throwOnError:!1}),e.find(".katex").css("font-size","1.6em")}),this.previewContainer.find("."+C.classNames.texDisplay).each(function(){var e=v(this);C.$katex.render(e.text(),e[0],{throwOnError:!1,displayMode:!0}),e.find(".katex").css("font-size","1.6em")})),this},mindmapRender:function(){return this.previewContainer.find(".mindmap").each(function(){var e=v(this),e=window.markmap.transform(e.text().trim());window.markmap.markmap("svg#"+this.id,e)}),this},flowChartAndSequenceDiagramRender:function(){var e=this.settings,t=this.previewContainer;if(!C.isIE8){if(e.mermaid){var i=t.find(".lang-mermaid");if(i)try{window.mermaid.init(void 0,i.removeClass("hide"))}catch(e){console.log(e)}}if(e.flowChart){if(null===h)return this;try{t.find(".flowchart").flowChart()}catch(e){console.log(e)}}if(e.sequenceDiagram)try{t.find(".sequence-diagram").sequenceDiagram({theme:"simple"})}catch(e){console.log(e)}var i=this.preview,e=this.codeMirror.find(".CodeMirror-scroll"),t=e.height(),o=e.scrollTop(),n=o/e[0].scrollHeight,r=0;i.find(".markdown-toc-list").each(function(){r+=v(this).height()});var a=i.find(".editormd-toc-menu").height()||0;0===o?i.scrollTop(0):o+t>=e[0].scrollHeight-16?i.scrollTop(i[0].scrollHeight):i.scrollTop((i[0].scrollHeight+r+a)*n)}return this},registerKeyMaps:function(e){var t=this,i=this.cm,o=this.settings,n=C.toolbarHandlers,r=o.disabledKeyMaps;if(e=e||null)for(var a in e)v.inArray(a,r)<0&&(e[a],i.addKeyMap(e));else{for(var s in C.keyMaps){var l,c=C.keyMaps[s],c="string"==typeof c?v.proxy(n[c],t):v.proxy(c,t);v.inArray(s,["F9","F10","F11"])<0&&v.inArray(s,r)<0&&((l={})[s]=c,i.addKeyMap(l))}v(window).keydown(function(e){if(v.inArray({120:"F9",121:"F10",122:"F11"}[e.keyCode],r)<0)switch(e.keyCode){case 120:return v.proxy(n.watch,t)(),!1;case 121:return v.proxy(n.preview,t)(),!1;case 122:return v.proxy(n.fullscreen,t)(),!1}})}return this},bindScrollEvent:function(){var e,t,i,o,a=this,s=this.previewContainer,l=this.settings,r=this.codeMirror,n=C.mouseOrTouch;return l.syncScrolling&&(i=function(){s.bind(n("scroll","touchmove"),function(e){var t,i,o,n;null==c&&(t=v(this).height(),o=(i=v(this).scrollTop())/v(this)[0].scrollHeight,n=r.find(".CodeMirror-scroll"),0===i?n.scrollTop(0):i+t>=v(this)[0].scrollHeight?n.scrollTop(n[0].scrollHeight):n.scrollTop(n[0].scrollHeight*o),v.proxy(l.onpreviewscroll,a)(e))})},o=function(){s.unbind(n("scroll","touchmove"))},r.bind({mouseover:e=function(){r.find(".CodeMirror-scroll").bind(n("scroll","touchmove"),function(e){var t,i,o,n,r;null==c&&(t=v(this).height(),o=(i=v(this).scrollTop())/v(this)[0].scrollHeight,n=0,s.find(".markdown-toc-list").each(function(){n+=v(this).height()}),r=(r=s.find(".editormd-toc-menu").height())||0,0===i?s.scrollTop(0):i+t>=v(this)[0].scrollHeight-16?s.scrollTop(s[0].scrollHeight):s.scrollTop((s[0].scrollHeight+n+r)*o),v.proxy(l.onscroll,a)(e))})},mouseout:t=function(){r.find(".CodeMirror-scroll").unbind(n("scroll","touchmove"))},touchstart:e,touchend:t}),"single"!==l.syncScrolling)&&s.bind({mouseover:i,mouseout:o,touchstart:i,touchend:o}),this},bindChangeEvent:function(){var i=this,e=this.cm,o=this.settings;return e.on("change",function(e,t){o.watch&&i.previewContainer.css("padding",o.autoHeight?"20px 20px 50px 40px":"20px"),c&&clearTimeout(c),o.onCmChange&&v.proxy(o.onCmChange,i)(),c=setTimeout(function(){i.save(),c=null},o.delay)}),this},loadedDisplay:function(e){e=e||!1;var t=this,i=this.editor,o=this.preview,n=this.settings;return this.containerMask.hide(),this.save(),n.watch&&o.show(),i.data("oldWidth",i.width()).data("oldHeight",i.height()),this.resize(),this.registerKeyMaps(),v(window).resize(function(){t.resize()}),this.bindScrollEvent().bindChangeEvent(),e||v.proxy(n.onload,this)(),this.state.loaded=!0,n.watch&&(this.save(),o.show()),this},width:function(e){return this.editor.css("width","number"==typeof e?e+"px":e),this.resize(),this},height:function(e){return this.editor.css("height","number"==typeof e?e+"px":e),this.resize(),this},resize:function(e,t){t=t||null;var i=this.state,o=this.editor,n=this.preview,r=this.toolbar,a=this.settings,s=this.codeMirror;return(e=e||null)&&o.css("width","number"==typeof e?e+"px":e),!a.autoHeight||i.fullscreen||i.preview?(t&&o.css("height","number"==typeof t?t+"px":t),i.fullscreen&&o.height(v(window).height()),a.toolbar&&!a.readOnly?s.css("margin-top",r.height()+1).height(o.height()-r.height()):s.css("margin-top",0).height(o.height())):(o.css("height","auto"),s.css("height","auto")),a.watch?(s.width(o.width()/2),n.width(i.preview?o.width():o.width()/2),this.previewContainer.css("padding",a.autoHeight?"20px 20px 50px 40px":"20px"),a.toolbar&&!a.readOnly?n.css("top",r.height()+1):n.css("top",0),!a.autoHeight||i.fullscreen||i.preview?(e=a.toolbar&&!a.readOnly?o.height()-r.height():o.height(),n.height(e)):n.height("")):(s.width(o.width()),n.hide()),i.loaded&&v.proxy(a.onresize,this)(),this},save:function(){var e,t,i,o=this,n=this.state,r=this.settings,a=this.cm,s=a.getValue(),l=this.previewContainer;return(null!==c||!r.watch&&n.preview)&&("gfm"!==r.mode&&"markdown"!==r.mode?this.markdownTextarea.val(s):(a.save(),(r.saveHTMLToTextarea||r.watch||!r.watch&&n.preview)&&(t=C.$marked,e=this.markdownToC=[],i=this.markedRendererOptions={toc:r.toc,tocm:r.tocm,tocStartLevel:r.tocStartLevel,pageBreak:r.pageBreak,taskList:r.taskList,emoji:r.emoji,tex:r.tex,atLink:r.atLink,emailLink:r.emailLink,flowChart:r.flowChart,sequenceDiagram:r.sequenceDiagram,previewCodeHighlight:r.previewCodeHighlight,mermaid:r.mermaid,mindMap:r.mindMap},i=this.markedOptions={renderer:C.markedRenderer(e,i),gfm:!0,tables:!0,breaks:!0,pedantic:!1,sanitize:!r.htmlDecode,smartLists:!0,smartypants:!0},t.setOptions(i),t=C.$marked.parse(s,i),r.debug&&console.info("cmValue",s,t),t=C.$filterXSS(t),this.markdownTextarea.text(s),a.save(),r.saveHTMLToTextarea&&this.htmlTextarea.text(t),r.watch||!r.watch&&n.preview)&&(l.html(t),this.previewCodeHighlight(),r.toc&&(s=(i=""===r.tocContainer?l:v(r.tocContainer)).find("."+this.classPrefix+"toc-menu"),i.attr("previewContainer",""===r.tocContainer?"true":"false"),""!==r.tocContainer&&0<s.length&&s.remove(),C.markdownToCRenderer(e,i,r.tocDropdown,r.tocStartLevel),(r.tocDropdown||0<i.find("."+this.classPrefix+"toc-menu").length)&&C.tocDropdownMenu(i,(""!==r.tocTitle?r:this.lang).tocTitle),""!==r.tocContainer)&&l.find(".markdown-toc").css("border","none"),r.tex&&(!C.kaTeXLoaded&&r.autoLoadModules?C.loadKaTeX(function(){C.$katex=katex,C.kaTeXLoaded=!0,o.katexRender()}):(C.$katex=katex,this.katexRender())),r.mindMap&&setTimeout(function(){o.mindmapRender()},10),(r.flowChart||r.sequenceDiagram||r.mermaid)&&(h=setTimeout(function(){clearTimeout(h),o.flowChartAndSequenceDiagramRender(),h=null},10)),n.loaded)&&v.proxy(r.onchange,this)())),this},focus:function(){return this.cm.focus(),this},setCursor:function(e){return this.cm.setCursor(e),this},getCursor:function(){return this.cm.getCursor()},setSelection:function(e,t){return this.cm.setSelection(e,t),this},getSelection:function(){return this.cm.getSelection()},setSelections:function(e){return this.cm.setSelections(e),this},getSelections:function(){return this.cm.getSelections()},replaceSelection:function(e){return this.cm.replaceSelection(e),this},insertValue:function(e){return this.replaceSelection(e),this},appendMarkdown:function(e){this.settings;var t=this.cm;return t.setValue(t.getValue()+e),this},setMarkdown:function(e){return this.cm.setValue(e||this.settings.markdown),this},getMarkdown:function(){return this.cm.getValue()},getValue:function(){return this.cm.getValue()},setValue:function(e){return this.cm.setValue(e),this},clear:function(){return this.cm.setValue(""),this},getHTML:function(){return this.settings.saveHTMLToTextarea?this.htmlTextarea.val():(alert("Error: settings.saveHTMLToTextarea == false"),!1)},getTextareaSavedHTML:function(){return this.getHTML()},getPreviewedHTML:function(){return this.settings.watch?this.previewContainer.html():(alert("Error: settings.watch == false"),!1)},watch:function(e){var t,i,o,n=this.settings;return v.inArray(n.mode,["gfm","markdown"])<0||(this.state.watching=n.watch=!0,this.preview.show(),this.toolbar&&(t=n.toolbarIconsClass.watch,i=n.toolbarIconsClass.unwatch,(o=this.toolbar.find(".fa[name=watch]")).parent().attr("title",n.lang.toolbar.watch),o.removeClass(i).addClass(t)),this.codeMirror.css("border-right","1px solid #ddd").width(this.editor.width()/2),c=0,this.save().resize(),n.onwatch||(n.onwatch=e||function(){}),v.proxy(n.onwatch,this)()),this},unwatch:function(e){var t,i,o,n=this.settings;return this.state.watching=n.watch=!1,this.preview.hide(),this.toolbar&&(t=n.toolbarIconsClass.watch,i=n.toolbarIconsClass.unwatch,(o=this.toolbar.find(".fa[name=watch]")).parent().attr("title",n.lang.toolbar.unwatch),o.removeClass(t).addClass(i)),this.codeMirror.css("border-right","none").width(this.editor.width()),this.resize(),n.onunwatch||(n.onunwatch=e||function(){}),v.proxy(n.onunwatch,this)(),this},show:function(e){e=e||function(){};var t=this;return this.editor.show(0,function(){v.proxy(e,t)()}),this},hide:function(e){e=e||function(){};var t=this;return this.editor.hide(0,function(){v.proxy(e,t)()}),this},previewing:function(){var t=this,e=this.editor,i=this.preview,o=this.toolbar,n=this.settings,r=this.codeMirror,a=this.previewContainer;if(v.inArray(n.mode,["gfm","markdown"])<0)return this;n.toolbar&&o&&(o.toggle(),o.find(".fa[name=preview]").toggleClass("active")),r.toggle();function s(e){e.shiftKey&&27===e.keyCode&&t.previewed()}"none"===r.css("display")?(this.state.preview=!0,this.state.fullscreen&&i.css("background","#fff"),e.find("."+this.classPrefix+"preview-close-btn").show().bind(C.mouseOrTouch("click","touchend"),function(){t.previewed()}),n.watch?a.css("padding",""):this.save(),a.addClass(this.classPrefix+"preview-active"),i.show().css({position:"",top:0,width:e.width(),height:n.autoHeight&&!this.state.fullscreen?"auto":e.height()}),this.state.loaded&&v.proxy(n.onpreviewing,this)(),v(window).bind("keyup",s)):(v(window).unbind("keyup",s),this.previewed())},previewed:function(){var e=this.editor,t=this.preview,i=this.toolbar,o=this.settings,n=this.previewContainer,r=e.find("."+this.classPrefix+"preview-close-btn"),r=(this.state.preview=!1,this.codeMirror.show(),o.toolbar&&i.show(),t[o.watch?"show":"hide"](),r.hide().unbind(C.mouseOrTouch("click","touchend")),n.removeClass(this.classPrefix+"preview-active"),o.watch&&n.css("padding","20px"),o.toolbar?i.height():0);return t.css({background:null,position:"absolute",width:e.width()/2,height:o.autoHeight&&!this.state.fullscreen?"auto":e.height()-r,top:o.toolbar?r:0}),this.state.loaded&&v.proxy(o.onpreviewed,this)(),this},fullscreen:function(){function e(e){e.shiftKey||27!==e.keyCode||i.fullscreen&&t.fullscreenExit()}var t=this,i=this.state,o=this.editor,n=(this.preview,this.toolbar),r=this.settings,a=this.classPrefix+"fullscreen";n&&n.find(".fa[name=fullscreen]").parent().toggleClass("active");return o.hasClass(a)?(v(window).unbind("keyup",e),this.fullscreenExit()):(i.fullscreen=!0,v("html,body").css("overflow","hidden"),o.css({width:v(window).width(),height:v(window).height()}).addClass(a),this.resize(),v.proxy(r.onfullscreen,this)(),v(window).bind("keyup",e)),this},fullscreenExit:function(){var e=this.editor,t=this.settings,i=this.toolbar,o=this.classPrefix+"fullscreen";return this.state.fullscreen=!1,i&&i.find(".fa[name=fullscreen]").parent().removeClass("active"),v("html,body").css("overflow",""),e.css({width:e.data("oldWidth"),height:e.data("oldHeight")}).removeClass(o),this.resize(),v.proxy(t.onfullscreenExit,this)(),this},executePlugin:function(t,i,o=!1,n={proxy:!1}){var r=this,a=this.cm,e=this.settings;if(i=(o?e.customPluginPath:e.pluginPath)+i,"function"==typeof define)return void 0===this[t]?(alert("Error: "+t+" plugin is not found, you are not load this plugin."),this):n.proxy?this[t](a):(this[t](a),this);if(v.inArray(i,C.loadFiles.plugin)<0){if(n.proxy)return new Promise(e=>{C.loadPlugin(i,function(){C.loadPlugins[t]=r[t],e(r[t](a,n))},"head",o?r.author_ide_version:C.version)});C.loadPlugin(i,function(){C.loadPlugins[t]=r[t],r[t](a,n)},"head",o?r.author_ide_version:C.version)}else{if(n.proxy)return v.proxy(C.loadPlugins[t],this)(a,n);v.proxy(C.loadPlugins[t],this)(a,n)}return this},search:function(e){var t=this.settings;return t.searchReplace?t.readOnly||this.cm.execCommand(e||"find"):alert("Error: settings.searchReplace == false"),this},searchReplace:function(){return this.search("replace"),this},searchReplaceAll:function(){return this.search("replaceAll"),this}},C.fn.init.prototype=C.fn,C.dialogLockScreen=function(){(this.settings||{dialogLockScreen:!0}).dialogLockScreen&&(v("html,body").css("overflow","hidden"),this.resize())},C.positionDialog=function(e,t="center"){var i,o;switch(t){case"center":i=(v(window).width()-e.width())/2+"px",o=(v(window).height()-e.height())/2+"px";break;case"center-left":i=v(window).width()/4-e.width()/2+"px",o=(v(window).height()-e.height())/2+"px";break;case"center-right":i=3*v(window).width()/4-e.width()/2+"px",o=(v(window).height()-e.height())/2+"px";break;default:console.warn("Unsupported dialog position: "+t),i=(v(window).width()-e.width())/2+"px",o=(v(window).height()-e.height())/2+"px"}e.css({top:o,left:i})},C.dialogShowMask=function(e){var t=this.editor,i=this.settings||{dialogShowMask:!0};e.css({top:(v(window).height()-e.height())/2+"px",left:(v(window).width()-e.width())/2+"px"}),i.dialogShowMask&&t.children("."+this.classPrefix+"mask").css("z-index",parseInt(e.css("z-index"))-1).show()},C.toolbarHandlers={undo:function(){this.cm.undo()},redo:function(){this.cm.redo()},bold:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("**"+i+"**"),""===i&&e.setCursor(t.line,t.ch+2)},del:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("~~"+i+"~~"),""===i&&e.setCursor(t.line,t.ch+2)},italic:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("*"+i+"*"),""===i&&e.setCursor(t.line,t.ch+1)},quote:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("> "+i),e.setCursor(t.line,t.ch+2)):e.replaceSelection("> "+i)},ucfirst:function(){var e=this.cm,t=e.getSelection(),i=e.listSelections();e.replaceSelection(C.firstUpperCase(t)),e.setSelections(i)},ucwords:function(){var e=this.cm,t=e.getSelection(),i=e.listSelections();e.replaceSelection(C.wordsFirstUpperCase(t)),e.setSelections(i)},uppercase:function(){var e=this.cm,t=e.getSelection(),i=e.listSelections();e.replaceSelection(t.toUpperCase()),e.setSelections(i)},lowercase:function(){var e=this.cm,t=(e.getCursor(),e.getSelection()),i=e.listSelections();e.replaceSelection(t.toLowerCase()),e.setSelections(i)},h1:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection(),o=new RegExp("^#{1}[ ]"),n=new RegExp("^#{1,6}[ ]");!0===o.test(i)?(i=i.replace(/^#{1}[ ]/,""),e.setSelection({line:t.line,ch:0},{line:t.line+1,ch:0}),e.replaceSelection(i+"\n"),e.setCursor(t.line,t.ch-2)):(!0===n.test(i)&&(i=i.replace(/^#{1,6}[ ]/,"")),e.setSelection({line:t.line,ch:0},{line:t.line+1,ch:0}),e.replaceSelection("# "+i+"\n"),e.setCursor(t.line,t.ch+2))},h2:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection(),o=new RegExp("^#{2}[ ]"),n=new RegExp("^#{1,6}[ ]");!0===o.test(i)?(i=i.replace(/^#{2}[ ]/,""),e.setSelection({line:t.line,ch:0},{line:t.line+1,ch:0}),e.replaceSelection(i+"\n"),e.setCursor(t.line,t.ch-3)):(!0===n.test(i)&&(i=i.replace(/^#{1,6}[ ]/,"")),e.setSelection({line:t.line,ch:0},{line:t.line+1,ch:0}),e.replaceSelection("## "+i+"\n"),e.setCursor(t.line,t.ch+3))},h3:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection(),o=new RegExp("^#{3}[ ]"),n=new RegExp("^#{1,6}[ ]");!0===o.test(i)?(i=i.replace(/^#{3}[ ]/,""),e.setSelection({line:t.line,ch:0},{line:t.line+1,ch:0}),e.replaceSelection(i+"\n"),e.setCursor(t.line,t.ch-4)):(!0===n.test(i)&&(i=i.replace(/^#{1,6}[ ]/,"")),e.setSelection({line:t.line,ch:0},{line:t.line+1,ch:0}),e.replaceSelection("### "+i+"\n"),e.setCursor(t.line,t.ch+4))},h4:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection(),o=new RegExp("^#{4}[ ]"),n=new RegExp("^#{1,6}[ ]");!0===o.test(i)?(i=i.replace(/^#{4}[ ]/,""),e.setSelection({line:t.line,ch:0},{line:t.line+1,ch:0}),e.replaceSelection(i+"\n"),e.setCursor(t.line,t.ch-5)):(!0===n.test(i)&&(i=i.replace(/^#{1,6}[ ]/,"")),e.setSelection({line:t.line,ch:0},{line:t.line+1,ch:0}),e.replaceSelection("#### "+i+"\n"),e.setCursor(t.line,t.ch+5))},h5:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection(),o=new RegExp("^#{5}[ ]"),n=new RegExp("^#{1,6}[ ]");!0===o.test(i)?(i=i.replace(/^#{5}[ ]/,""),e.setSelection({line:t.line,ch:0},{line:t.line+1,ch:0}),e.replaceSelection(i+"\n"),e.setCursor(t.line,t.ch-6)):(!0===n.test(i)&&(i=i.replace(/^#{1,6}[ ]/,"")),e.setSelection({line:t.line,ch:0},{line:t.line+1,ch:0}),e.replaceSelection("##### "+i+"\n"),e.setCursor(t.line,t.ch+6))},h6:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection(),o=new RegExp("^#{6}[ ]"),n=new RegExp("^#{1,6}[ ]");!0===o.test(i)?(i=i.replace(/^#{6}[ ]/,""),e.setSelection({line:t.line,ch:0},{line:t.line+1,ch:0}),e.replaceSelection(i+"\n"),e.setCursor(t.line,t.ch-7)):(!0===n.test(i)&&(i=i.replace(/^#{1,6}[ ]/,"")),e.setSelection({line:t.line,ch:0},{line:t.line+1,ch:0}),e.replaceSelection("###### "+i+"\n"),e.setCursor(t.line,t.ch+7))},"list-ul":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection(),o=new RegExp("^-{1}[ ]"),n=0;if(""===i)e.setCursor(t.line,0),e.replaceSelection("- "+i),e.setCursor(t.line,t.ch+2);else{for(var r=i.split("\n"),a=0,s=r.length;a<s;a++)!0===o.test(r[a])&&n++;if(n===r.length)for(a=0,s=r.length;a<s;a++)r[a]=""===r[a]?"":r[a].replace(o,"");else for(a=0,s=r.length;a<s;a++)r[a]=""===r[a]?"":"- "+r[a].replace(o,"");e.replaceSelection(r.join("\n"))}},"list-ol":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection(),o=new RegExp("^[0-9]+[.][ ]"),n=0;if(""===i)e.setCursor(t.line,0),e.replaceSelection("1. "+i),e.setCursor(t.line,t.ch+3);else{for(var r=i.split("\n"),a=0,s=r.length;a<s;a++)!0===o.test(r[a])&&n++;if(n===r.length)for(a=0,s=r.length;a<s;a++)r[a]=""===r[a]?"":r[a].replace(/^[0-9]+[\.][ ]/,"");else for(a=0,s=r.length;a<s;a++)r[a]=""===r[a]?"":a+1+". "+r[a].replace(o,"");e.replaceSelection(r.join("\n"))}},hr:function(){var e=this.cm,t=e.getCursor();e.getSelection();e.replaceSelection((0!==t.ch?"\n\n":"\n")+"------------\n\n")},tex:function(){if(!this.settings.tex)return alert("settings.tex === false"),this;var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("$$"+i+"$$"),""===i&&e.setCursor(t.line,t.ch+2)},link:function(){this.executePlugin("linkDialog","link-dialog/link-dialog")},"reference-link":function(){this.executePlugin("referenceLinkDialog","reference-link-dialog/reference-link-dialog")},pagebreak:function(){if(!this.settings.pageBreak)return alert("settings.pageBreak === false"),this;var e=this.cm;e.getSelection();e.replaceSelection("\r\n[========]\r\n")},image:function(){this.executePlugin("imageDialog","image-dialog/image-dialog")},code:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("`"+i+"`"),""===i&&e.setCursor(t.line,t.ch+1)},"code-block":function(){this.executePlugin("codeBlockDialog","code-block-dialog/code-block-dialog")},"preformatted-text":function(){this.executePlugin("preformattedTextDialog","preformatted-text-dialog/preformatted-text-dialog")},table:function(){this.executePlugin("tableDialog","table-dialog/table-dialog")},datetime:function(){var e=this.cm,t=(e.getSelection(),new Date,this.settings.lang.name),t=C.dateFormat()+" "+C.dateFormat("zh-cn"===t||"zh-tw"===t?"cn-week-day":"week-day");e.replaceSelection(t)},emoji:function(){this.executePlugin("emojiDialog","emoji-dialog/emoji-dialog")},"html-entities":function(){this.executePlugin("htmlEntitiesDialog","html-entities-dialog/html-entities-dialog")},"goto-line":function(){this.executePlugin("gotoLineDialog","goto-line-dialog/goto-line-dialog")},watch:function(){this[this.settings.watch?"unwatch":"watch"]()},preview:function(){this.previewing()},fullscreen:function(){this.fullscreen()},clear:function(){this.clear()},search:function(){this.search()},help:function(){this.executePlugin("helpDialog","help-dialog/help-dialog")},changetheme:function(){this.setEditorTheme("default"==this.settings.editorTheme?"pastel-on-dark":"default"),this.setPreviewTheme(""==this.settings.previewTheme?"dark":"")},info:function(){this.showInfoDialog()}},e=0<=navigator.platform.toUpperCase().indexOf("MAC")?"Cmd":"Ctrl",C.keyMaps={[e+"-1"]:"h1",[e+"-2"]:"h2",[e+"-3"]:"h3",[e+"-4"]:"h4",[e+"-5"]:"h5",[e+"-6"]:"h6",[e+"-B"]:"bold",[e+"-D"]:"datetime",[e+"-E"]:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();this.settings.emoji?(e.replaceSelection(":"+i+":"),""===i&&e.setCursor(t.line,t.ch+1)):alert("Error: settings.emoji == false")},[e+"-Alt-G"]:"goto-line",[e+"-H"]:"hr",[e+"-I"]:"italic",[e+"-K"]:"code",[e+"-L"]:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("["+i+"]("+(""===i?"":' "'+i+'"')+")"),""===i&&e.setCursor(t.line,t.ch+1)},[e+"-U"]:"list-ul",["Shift-"+e+"-A"]:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();this.settings.atLink?(e.replaceSelection("@"+i),""===i&&e.setCursor(t.line,t.ch+1)):alert("Error: settings.atLink == false")},["Shift"+e+"-C"]:"code",["Shift"+e+"Q"]:"quote",["Shift"+e+"S"]:"del",["Shift"+e+"K"]:"tex","Shift-Alt-C":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection(["```",i,"```"].join("\n")),""===i&&e.setCursor(t.line,t.ch+3)},["Shift-"+e+"-Alt-C"]:"code-block",["Shift-"+e+"-H"]:"html-entities","Shift-Alt-H":"help",["Shift-"+e+"-E"]:"emoji",["Shift-"+e+"-U"]:"uppercase","Shift-Alt-U":"ucwords",["Shift-"+e+"-Alt-U"]:"ucfirst","Shift-Alt-L":"lowercase",["Shift-"+e+"-I"]:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("!["+i+"]("+(""===i?"":' "'+i+'"')+")"),""===i&&e.setCursor(t.line,t.ch+4)},["Shift-"+e+"-Alt-I"]:"image",["Shift-"+e+"-L"]:"link",["Shift-"+e+"-O"]:"list-ol",["Shift-"+e+"-P"]:"preformatted-text",["Shift-"+e+"-T"]:"table","Shift-Alt-P":"pagebreak",F9:"watch",F10:"preview",F11:"fullscreen"},C.trim=d=function(e){return String.prototype.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},C.ucwords=C.wordsFirstUpperCase=function(e){return e.toLowerCase().replace(/\b(\w)|\s(\w)/g,function(e){return e.toUpperCase()})},C.firstUpperCase=C.ucfirst=function(e){return e.toLowerCase().replace(/\b(\w)/,function(e){return e.toUpperCase()})},C.urls={atLinkBase:"https://github.com/"},C.regexs={atLink:/@(\w+)/g,email:/(\w+)@(\w+)\.(\w+)\.?(\w+)?/g,emailLink:/(mailto:)?([\w\.\_]+)@(\w+)\.(\w+)\.?(\w+)?/g,emoji:/:([\w\+-]+):/g,emojiDatetime:/(\d{1,2}:\d{1,2}:\d{1,2})/g,twemoji:/:(tw-([\w]+)-?(\w+)?):/g,fontAwesome:/:(fa-([\w]+)(-(\w+)){0,}):/g,editormdLogo:/:(editormd-logo-?(\w+)?):/g,pageBreak:/^\[[=]{8,}\]$/},C.emoji={path:"https://www.webpagefx.com/tools/emoji-cheat-sheet/graphics/emojis/",ext:".png"},C.twemoji={path:"http://twemoji.maxcdn.com/36x36/",ext:".png"},C.markedRenderer=function(h,e){var a=v.extend({toc:!0,tocm:!1,tocStartLevel:1,pageBreak:!0,atLink:!0,emailLink:!0,taskList:!1,emoji:!1,tex:!1,flowChart:!1,sequenceDiagram:!1,mermaid:!0},e||{}),c=C.$marked,e=new c.Renderer,t=(h=h||[],C.regexs),n=t.atLink,r=t.emoji,i=t.email,o=t.emailLink,g=t.twemoji,m=t.fontAwesome,w=t.editormdLogo,s=t.pageBreak;return e.blockquote=function(e){var t="",i=e.match(/<p\s.*?>/i),i=(null!==i&&(t=i[0],e=e.substr(t.length)),"default");return 0===e.indexOf("[info]")?(i="info",e=e.substr(6)):0===e.indexOf("[warning]")?(i="warning",e=e.substr(9)):0===e.indexOf("[success]")?(i="success",e=e.substr(9)):0===e.indexOf("[danger]")&&(i="danger",e=e.substr(8)),'<blockquote class="'+i+'">\n'+t+e+"</blockquote>\n"},e.image=function(e,t,i){var o,n,r,a="",s="",l="";return e&&""!==e&&((o=document.createElement("a")).href=e,null!==(n=o.hash.match(/size=\d+x\d+/i))&&(o.hash=o.hash.replace(n[0],""),e=o.href,0<(n=n[0].replace("size=","").split("x"))[0]&&(a+=' width="'+n[0]+'"'),0<n[1])&&(a+=' height="'+n[1]+'"'),null!==(n=o.hash.match(/align=(center|left|right)/i)))&&(0===(r=o.hash.replace(n[0],"")).indexOf("#&")&&(r="#"+r.substr(2)),o.hash=r,e=o.href,l="</p>","center"===(n=n[0].replace("align=",""))?s='<p align="center">':"left"===n?s='<p align="left">':"right"===n&&(s='<p align="right">')),s+'<img src="'+e+'" title="'+t+'" alt="'+i+'" '+a+">"+l},e.emoji=function(e){var t=(e=e.replace(C.regexs.emojiDatetime,function(e){return e.replace(/:/g,":")})).match(r);if(t&&a.emoji)for(var i=0,o=t.length;i<o;i++)":+1:"===t[i]&&(t[i]=":\\+1:"),e=e.replace(new RegExp(t[i]),function(e,t){var i=e.match(m),o=e.replace(/:/g,"");if(i)for(var n=0,r=i.length;n<r;n++){var a=i[n].replace(/:/g,"");return'<i class="fa '+a+' fa-emoji" title="'+a.replace("fa-","")+'"></i>'}else{var s=e.match(w),l=e.match(g);if(s)for(var c=0,h=s.length;c<h;c++){var d=s[c].replace(/:/g,"");return'<i class="'+d+'" title="Editor.md logo ('+d+')"></i>'}else{if(!l)return'<img src="'+C.emoji.path+(e="moon"===(e="black_large_square"===(e="+1"===o?"plus1":o)?"black_square":e)?"waxing_gibbous_moon":e)+C.emoji.ext+'" class="emoji" title=":'+o+':" alt=":'+o+':" />';for(var u=0,f=l.length;u<f;u++){var p=l[u].replace(/:/g,"").replace("tw-","");return'<img src="'+C.twemoji.path+p+C.twemoji.ext+'" title="twemoji-'+p+'" alt="twemoji-'+p+'" class="emoji twemoji" />'}}}});return e},e.atLink=function(e){return n.test(e)&&(a.atLink&&(e=(e=e.replace(i,function(e,t,i,o){return e.replace(/@/g,"_#_@_#_")})).replace(n,function(e,t){return'<a href="'+C.urls.atLinkBase+t+'" title="@'+t+'" class="at-link" target=\'_blank\'>'+e+"</a>"}).replace(/_#_@_#_/g,"@")),a.emailLink)?e.replace(o,function(e,t,i,o,n){return!t&&v.inArray(n,"jpg|jpeg|png|gif|webp|ico|icon|pdf".split("|"))<0?'<a href="mailto:'+e+'">'+e+"</a>":e}):e},e.link=function(e,t,i){if(this.options.sanitize){try{var o=decodeURIComponent(unescape(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return""}if(0===o.indexOf("javascript:"))return""}return 0===e.indexOf("@")?'<a name="'+e.substr(1)+'"></a>':(o='<a href="'+e+'" target="_blank" rel="noopener noreferrer"',0!==e.indexOf("http://")&&0!==e.indexOf("https://")||(o+='target="_blank"'),n.test(t)||n.test(i)?(t&&(o+=' title="'+t.replace(/@/g,"@")),o+'">'+i.replace(/@/g,"@")+"</a>"):(t&&(o+=' title="'+t+'"'),o+">"+i+"</a>"))},e.heading=function(e,t,i){var o=e,n=/\s*\<a\s*href\=\"(.*)\"\s*([^\>]*)\>(.*)\<\/a\>\s*/;if(n.test(e)){for(var r=[],a=0,s=(e=e.split(/\<a\s*([^\>]+)\>([^\>]*)\<\/a\>/)).length;a<s;a++)r.push(e[a].replace(/\s*href\=\"(.*)\"\s*/g,""));e=r.join(" ")}var l=(e=d(e)).toLowerCase().replace(/[^\w]+/g,"-"),l={text:e,level:t,slug:l,id:void 0},c=/^[\u4e00-\u9fa5]+$/.test(e)?encodeURIComponent(e).replace(/\%/g,""):e.toLowerCase().replace(/[^\w]+/g,"-"),l=(h.push(l),"<h"+t+' id="h'+t+"-"+this.options.headerPrefix+c+'">');return(l+='<span class="header-link octicon octicon-link"></span>')+(n?this.atLink(this.emoji(o)):this.atLink(this.emoji(e)))+("</h"+t+">")},e.pageBreak=function(e){return e=s.test(e)&&a.pageBreak?'<hr style="page-break-after:always;" class="page-break editormd-page-break" />':e},e.paragraph=function(e){var t=/\$\$(.+?)\$\$/g.test(e),i=/^(?!\$\$.+?(?:\$\$).+?\$\$)(\$\$(.+?)\$\$)$/.test(e),o=i?' class="'+C.classNames.tex+'"':"",n=(a.tocm?/^(\[TOC\]|\[TOCM\])$/:/^\[TOC\]$/).test(e),r=/^\[TOCM\]$/.test(e),t='<div class="markdown-toc editormd-markdown-toc">'+(e=!i&&t?e.replaceAll(/(\$\$(.+?)\$\$)/g,function(e,t,i){return'<span class="'+C.classNames.tex+'">'+i.replaceAll(/\<br\>/g,"")+"</span>"}):i?e.replace(/^(?!\$\$.+?(?:\$\$).+?\$\$)(\$\$(.+?)\$\$)$/,(e,t,i)=>i):e)+"</div>";return n?r?'<div class="editormd-toc-menu">'+t+"</div><br/>":t:s.test(e)?this.pageBreak(e):"<p"+o+">"+this.atLink(this.emoji(e))+"</p>\n"},e.code=function(e,t,i){if("seq"===t||"sequence"===t)return'<div class="sequence-diagram">'+e+"</div>";if("mermaid"===t){for(var o=(a="ABCDEFGHJKLMNOPQRSTUVWXYZabcdefhijlkmnopqrstuvwxyz012345678").length,n="",r=0;r<4;r++)n+=a.charAt(Math.floor(Math.random()*o));return'<div class="lang-mermaid hide" data-anchor-id="'+n+'">'+e+"</div>"}if("flow"===t)return'<div class="flowchart">'+e+"</div>";if("math"===t||"latex"===t||"katex"===t)return'<p class="'+C.classNames.texDisplay+'">'+e+"</p>";if(/^mindmap/i.test(t)){for(var a,o=(a="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678").length,s="",l=t.split(">")[1],l=null!=l?l:150,r=0;r<9;r++)s+=a.charAt(Math.floor(Math.random()*o));return"<svg class='mindmap' style='width:100%;min-height=150px;height:"+l+"px;' id='mindmap-"+s+"'>"+e+"</svg>"}return"drawio"===t?'<div class="svg" style="overflow: auto; padding: 10px;">'+decodeURIComponent(escape(window.atob(e)))+"</div>":c.Renderer.prototype.code.apply(this,arguments)},e.tablecell=function(e,t){var i=t.header?"th":"td";return(t.align?"<"+i+' style="text-align:'+t.align+'">':"<"+i+">")+this.atLink(this.emoji(e))+"</"+i+">\n"},e.listitem=function(e){return a.taskList&&/^\s*\[[x\s]\]\s*/.test(e)?(e=e.replace(/^\s*\[\s\]\s*/,'<input type="checkbox" class="task-list-item-checkbox" /> ').replace(/^\s*\[x\]\s*/,'<input type="checkbox" class="task-list-item-checkbox" checked disabled /> '),'<li style="list-style: none;">'+this.atLink(this.emoji(e))+"</li>"):"<li>"+this.atLink(this.emoji(e))+"</li>"},e.checkbox=function(e){return e?'<i class="fa fa-check-square"></i> ':'<i class="fa fa-square-o"></i> '},e},C.markdownToCRenderer=function(e,t,i,o){var n="",r=0,a=this.classPrefix;o=o||1;for(var s=0,l=e.length;s<l;s++){var c=e[s].text,h=e[s].level,d=e[s].id;h<o||(n=n+(r<h?"":h<r?new Array(r-h+2).join("</ul></li>"):"</ul></li>")+'<li class="directory-item"><a class="directory-item-link directory-item-link-'+h+" toc-level-"+h+'" href="#'+d+'" level="'+h+'">'+c+"</a><ul>",r=h)}var u,f=t.find(".markdown-toc");return f.length<1&&"false"===t.attr("previewContainer")&&(u='<div class="markdown-toc '+a+'markdown-toc"></div>',t.html(u=i?'<div class="'+a+'toc-menu">'+u+"</div>":u),f=t.find(".markdown-toc")),i&&f.wrap('<div class="'+a+'toc-menu"></div><br/>'),f.html('<ul class="markdown-toc-list"></ul>').children(".markdown-toc-list").html(n.replace(/\r?\n?\<ul\>\<\/ul\>/g,"")),f},C.tocDropdownMenu=function(e,a){a=a||"Table of Contents";var s=400,e=e.find("."+this.classPrefix+"toc-menu");return e.each(function(){var e=v(this),t=e.children(".markdown-toc"),o='<i class="fa fa-angle-down"></i>',i='<a href="javascript:;" class="toc-menu-btn">'+o+a+"</a>",n=t.children("ul"),r=n.find("li");t.append(i),r.first().before("<li><h1>"+a+" "+o+"</h1></li>"),e.mouseover(function(){n.show(),r.each(function(){var e,t=v(this),i=t.children("ul");""===i.html()&&i.remove(),0<i.length&&""!==i.html()&&(e=t.children("a").first()).children(".fa").length<1&&e.append(v(o).css({float:"right",paddingTop:"4px"})),t.mouseover(function(){i.css("z-index",s).show(),s+=1}).mouseleave(function(){i.hide()})})}).mouseleave(function(){n.hide()})}),e},C.$filterXSS=C.filterHTMLTags=function(e,t){if("string"!=typeof e&&(e=new String(e)),"string"==typeof t){for(var t=t.split("|"),i=t[0].split(","),a=t[1],o=0,n=i.length;o<n;o++){var r=i[o];e=e.replace(new RegExp("<s*"+r+"s*([^>]*)>([^>]*)<s*/"+r+"s*>","igm"),"")}void 0!==a&&(t=/\<(\w+)\s*([^\>]*)\>([^\>]*)\<\/(\w+)\>/gi,e="*"===a?e.replace(t,function(e,t,i,o,n){return"<"+t+">"+o+"</"+n+">"}):"on*"===a?e.replace(t,function(e,t,i,o,n){var t=v("<"+t+">"+o+"</"+n+">"),o=v(e)[0].attributes,r={},n=(v.each(o,function(e,t){'"'!==t.nodeName&&(r[t.nodeName]=t.nodeValue)}),v.each(r,function(e){0===e.indexOf("on")&&delete r[e]}),t.attr(r),void 0!==t[1]?v(t[1]).text():"");return t[0].outerHTML+n}):e.replace(t,function(e,t,i,o){var n=a.split(","),r=v(e);return r.html(o),v.each(n,function(e){r.attr(n[e],null)}),r[0].outerHTML}))}return e},C.markdownToHTML=function(e,t){C.$marked=marked;var i,o=v("#"+e),e=o.settings=v.extend(!0,{gfm:!0,toc:!0,tocm:!1,tocStartLevel:1,tocTitle:"目录",tocDropdown:!1,tocContainer:"",markdown:"",markdownSourceCode:!1,htmlDecode:!1,autoLoadKaTeX:!0,pageBreak:!0,atLink:!0,emailLink:!0,tex:!1,taskList:!1,emoji:!1,flowChart:!1,sequenceDiagram:!1,previewCodeHighlight:!0,mermaid:!0,mindMap:!0},t||{}),n=o.find("textarea"),t=(n.length<1&&(o.append("<textarea></textarea>"),n=o.find("textarea")),void 0===e.markdown?n.val():e.markdown),r=[],a={toc:e.toc,tocm:e.tocm,tocStartLevel:e.tocStartLevel,taskList:e.taskList,emoji:e.emoji,tex:e.tex,pageBreak:e.pageBreak,atLink:e.atLink,emailLink:e.emailLink,flowChart:e.flowChart,sequenceDiagram:e.sequenceDiagram,mermaid:e.mermaid,mindMap:e.mindMap,previewCodeHighlight:e.previewCodeHighlight},a={renderer:C.markedRenderer(r,a),gfm:e.gfm,tables:!0,breaks:!0,pedantic:!1,sanitize:!e.htmlDecode,smartLists:!0,smartypants:!0},t=new String(t),a=marked.parse(t,a),a=C.$filterXSS(a),t=(e.markdownSourceCode?n.text(t):n.remove(),o.addClass("markdown-body "+this.classPrefix+"html-preview").append(a),""!==e.tocContainer?v(e.tocContainer):o);return""!==e.tocContainer&&t.attr("previewContainer",!1),e.toc&&(o.tocContainer=this.markdownToCRenderer(r,t,e.tocDropdown,e.tocStartLevel),(e.tocDropdown||0<o.find("."+this.classPrefix+"toc-menu").length)&&this.tocDropdownMenu(o,e.tocTitle),""!==e.tocContainer)&&o.find(".editormd-toc-menu, .editormd-markdown-toc").remove(),e.previewCodeHighlight&&(o.find("pre").addClass("prettyprint linenums"),prettyPrint()),C.isIE8||(e.flowChart&&o.find(".flowchart").flowChart(),e.sequenceDiagram&&o.find(".sequence-diagram").sequenceDiagram({theme:"simple"}),e.mermaid&&window.mermaid.init(void 0,o.find(".lang-mermaid"))),e.tex&&(i=function(){o.find("."+C.classNames.tex).each(function(){var e=v(this);katex.render(e.html().replace(/</g,"<").replace(/>/g,">"),e[0]),e.find(".katex").css("font-size","1.6em")})},!e.autoLoadKaTeX||C.$katex||C.kaTeXLoaded?i():this.loadKaTeX(function(){C.$katex=katex,C.kaTeXLoaded=!0,i()})),e.mindMap&&o.find(".mindmap").each(function(){var e=v(this),e=window.markmap.transform(e.text().trim());window.markmap.markmap("svg#"+this.id,e)}),o.getMarkdown=function(){return n.val()},o},C.themes=["default","dark"],C.previewThemes=["default","dark"],C.editorThemes=["default","3024-day","3024-night","ambiance","ambiance-mobile","base16-dark","base16-light","blackboard","cobalt","eclipse","elegant","erlang-dark","lesser-dark","mbo","mdn-like","midnight","monokai","neat","neo","night","paraiso-dark","paraiso-light","pastel-on-dark","rubyblue","solarized","the-matrix","tomorrow-night-eighties","twilight","vibrant-ink","xq-dark","xq-light"],C.loadPlugins={},C.loadFiles={js:[],css:[],plugin:[]},C.loadPlugin=function(e,t,i,o){t=t||function(){},this.loadScript(e,function(){C.loadFiles.plugin.push(e),t()},i,o)},C.loadCSS=function(e,t,i,o=C.version){i=i||"head",t=t||function(){},o=o||C.version;var n=document.createElement("link");n.type="text/css",n.rel="stylesheet",n.onload=n.onreadystatechange=function(){C.loadFiles.css.push(e),t()},n.href=e+".css?editormd_version="+o,("head"===i?document.getElementsByTagName("head")[0]:document.body).appendChild(n)},C.isIE="Microsoft Internet Explorer"==navigator.appName,C.isIE8=C.isIE&&"8."==navigator.appVersion.match(/8./i),C.loadScript=function(e,t,i,o){i=i||"head",o=o||C.version,t=t||function(){};var n=null;(n=document.createElement("script")).id=e.replace(/[\./]+/g,"-"),n.type="text/javascript",n.src=e+".js?editormd_version="+o,C.isIE8?n.onreadystatechange=function(){!n.readyState||"loaded"!==n.readyState&&"complete"!==n.readyState||(n.onreadystatechange=null,C.loadFiles.js.push(e),t())}:n.onload=function(){C.loadFiles.js.push(e),t()},("head"===i?document.getElementsByTagName("head")[0]:document.body).appendChild(n)},C.katexURL={css:"https://cdn.bootcdn.net/ajax/libs/KaTeX/0.16.8/katex.min",jsmain:"https://cdn.bootcdn.net/ajax/libs/KaTeX/0.16.8/katex.min",jsauto:"https://cdn.bootcdn.net/ajax/libs/KaTeX/0.16.8/contrib/auto-render.min"},C.kaTeXLoaded=!1,C.loadKaTeX=function(e){C.loadCSS(C.katexURL.css,function(){C.loadScript(C.katexURL.jsmain,function(){C.loadScript(C.katexURL.jsauto,e||function(){})})})},C.lockScreen=function(e){v("html,body").css("overflow",e?"hidden":"")},C.createDialog=function(t){function e(){f.css({top:(v(window).height()-f.height())/2+"px",left:(v(window).width()-f.width())/2+"px"})}t=v.extend(!0,{name:"",width:420,height:"auto",title:"",drag:!0,closed:!0,content:"",mask:!0,maskStyle:{backgroundColor:"#fff",opacity:.1},removeDialogOnClose:!1,resizeableX:!1,resizeableY:!1,minWidth:0,minHeight:0,maxWidth:"none",maxHeight:"none",lockScreen:!0,footer:!0,buttons:!1},t);var r,a,i,s,o,n=this,l=this.editor,c=C.classPrefix,h=(new Date).getTime(),h=""===t.name?c+"dialog-"+h:t.name,d=C.mouseOrTouch,u='<div class="'+c+"dialog "+h+'">',f=(""!==t.title&&(u=(u+='<div class="'+c+'dialog-header"'+(t.drag?' style="cursor: move;"':"")+">")+'<span class="'+c+'dialog-title">'+t.title+"</span>",t.closed&&(u+='<a href="javascript:;" class="'+c+'dialog-close"></a>'),u+="</div>"),u+='<div class="'+c+'dialog-container">'+t.content,!t.footer&&"string"!=typeof t.footer||(u+='<div class="'+c+'dialog-footer">'+("boolean"==typeof t.footer?"":t.footer)+"</div>"),l.append(u=(u=u+"</div>"+('<div class="'+c+"dialog-mask "+c+'dialog-mask-bg"></div>'))+('<div class="'+c+"dialog-mask "+c+'dialog-mask-con"></div>')+"</div>"),l.find("."+h));f.lockScreen=function(e){return t.lockScreen&&(v("html,body").css("overflow",e?"hidden":""),n.resize()),f},f.showMask=function(){return t.mask&&l.find("."+c+"mask").css(t.maskStyle).css("z-index",C.dialogZindex-1).show(),f},f.hideMask=function(){return t.mask&&l.find("."+c+"mask").hide(),f},f.loading=function(e){return f.find("."+c+"dialog-mask")[e?"show":"hide"](),f},f.lockScreen(!0).showMask(),f.show().css({zIndex:C.dialogZindex,border:C.isIE8?"1px solid #ddd":"",width:"number"==typeof t.width?t.width+"px":t.width,height:"number"==typeof t.height?t.height+"px":t.height,"min-width":"number"==typeof t.minWidth?t.minWidth+"px":t.minWidth,"min-height":"number"==typeof t.minHeight?t.minHeight+"px":t.minHeight,"max-width":"number"==typeof t.maxWidth?t.maxWidth+"px":t.maxWidth,"max-height":"number"==typeof t.maxHeight?t.maxHeight+"px":t.maxHeight,...t.resizeableX||t.resizeableY?{overflow:"hidden",resize:t.resizeableX&&t.resizeableY?"both":t.resizeableX?"horizontal":"vertical"}:{}});if(e(),v(window).resize(e),f.find("."+c+"dialog-close").bind(d("click","touchend"),function(){f.hide().lockScreen(!1).hideMask(),t.removeDialogOnClose&&f.remove()}),"object"==typeof t.buttons){var p,g=f.footer=f.find("."+c+"dialog-footer");for(p in t.buttons){var m=t.buttons[p],w=c+p+"-btn";g.append('<button class="'+c+"btn "+w+'">'+m[0]+"</button>"),m[1]=v.proxy(m[1],f),g.children("."+w).bind(d("click","touchend"),m[1])}}return""!==t.title&&t.drag&&(u=f.children("."+c+"dialog-header"),t.mask||u.bind(d("click","touchend"),function(){C.dialogZindex+=2,f.css("z-index",C.dialogZindex)}),u.mousedown(function(e){e=e||window.event,r=e.clientX-parseInt(f[0].style.left),a=e.clientY-parseInt(f[0].style.top),document.onmousemove=o}),i=function(e){e.removeClass(c+"user-unselect").off("selectstart")},s=function(e){e.addClass(c+"user-unselect").on("selectstart",function(e){return!1})},o=function(e){e=e||window.event;var t,i,o=parseInt(f[0].style.left),n=parseInt(f[0].style.top);0<=o?o+f.width()<=v(window).width()?t=e.clientX-r:(t=v(window).width()-f.width(),document.onmousemove=null):(t=0,document.onmousemove=null),0<=n?i=e.clientY-a:(i=0,document.onmousemove=null),document.onselectstart=function(){return!1},s(v("body")),s(f),f[0].style.left=t+"px",f[0].style.top=i+"px"},document.onmouseup=function(){i(v("body")),i(f),document.onselectstart=null,document.onmousemove=null},u.touchDraggable=function(){var i=null;this.bind("touchstart",function(e){var e=e.originalEvent,t=v(this).parent().position();i={x:e.changedTouches[0].pageX-t.left,y:e.changedTouches[0].pageY-t.top}}).bind("touchmove",function(e){e.preventDefault();e=e.originalEvent;v(this).parent().css({top:e.changedTouches[0].pageY-i.y,left:e.changedTouches[0].pageX-i.x})})},u.touchDraggable()),C.dialogZindex+=2,f},C.mouseOrTouch=function(e,t){t=t||"touchend";e=e||"click";try{document.createEvent("TouchEvent"),e=t}catch(e){}return e},C.dateFormat=function(e){e=e||"";function t(e){return e<10?"0"+e:e}var i=new Date,o=i.getFullYear(),n=o.toString().slice(2,4),r=t(i.getMonth()+1),a=t(i.getDate()),s=i.getDay(),l=t(i.getHours()),c=t(i.getMinutes()),h=t(i.getSeconds()),d=t(i.getMilliseconds()),u="",f=n+"-"+r+"-"+a,p=o+"-"+r+"-"+a,g=l+":"+c+":"+h;switch(e){case"UNIX Time":u=i.getTime();break;case"UTC":u=i.toUTCString();break;case"yy":u=n;break;case"year":case"yyyy":u=o;break;case"month":case"mm":u=r;break;case"cn-week-day":case"cn-wd":u="星期"+["日","一","二","三","四","五","六"][s];break;case"week-day":case"wd":u=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][s];break;case"day":case"dd":u=a;break;case"hour":case"hh":u=l;break;case"min":case"ii":u=c;break;case"second":case"ss":u=h;break;case"ms":u=d;break;case"yy-mm-dd":u=f;break;case"yyyy-mm-dd":u=p;break;case"yyyy-mm-dd h:i:s ms":case"full + ms":u=p+" "+g+" "+d;break;default:u=p+" "+g}return u},C.getLine=function(e){return this.cm.getLine(e)},C}); |