From 7b2cec6c359f122b1cefad93c74ec0d09c8d730f Mon Sep 17 00:00:00 2001 From: pandao <272383090@qq.com> Date: Sat, 11 May 2019 14:47:58 +0800 Subject: [PATCH] Fixed Task list rendeing --- editormd.amd.js | 22 +++++++++++++--------- editormd.amd.min.js | 2 +- editormd.js | 22 +++++++++++++--------- editormd.min.js | 2 +- examples/task-lists.html | 5 +++-- examples/use-zepto.html | 2 +- lib/codemirror/addons.min.js | 2 +- src/editormd.js | 22 +++++++++++++--------- 8 files changed, 46 insertions(+), 33 deletions(-) diff --git a/editormd.amd.js b/editormd.amd.js index 0014dd8..5158639 100644 --- a/editormd.amd.js +++ b/editormd.amd.js @@ -2105,6 +2105,10 @@ { previewContainer.html(newMarkdownDoc); + previewContainer.find(".task-list-item").each(function () { + $(this).parent().addClass("task-list"); + }); + this.previewCodeHighlight(); if (settings.toc) @@ -3723,16 +3727,12 @@ return tag + this.atLink(this.emoji(content)) + "\n"; }; - markedRenderer.listitem = function(text) { - if (settings.taskList && /^\s*\[[x\s]\]\s*/.test(text)) - { - text = text.replace(/^\s*\[\s\]\s*/, " ") - .replace(/^\s*\[x\]\s*/, " "); + markedRenderer.listitem = function(text, task) { + if (settings.taskList && task) { + text = text.replace("" + this.atLink(this.emoji(text)) + ""; - } - else - { + return "
  • " + this.atLink(this.emoji(text)) + "
  • "; + } else { return "
  • " + this.atLink(this.emoji(text)) + "
  • "; } }; @@ -4048,6 +4048,10 @@ } div.addClass("markdown-body " + this.classPrefix + "html-preview").append(markdownParsed); + + div.find(".task-list-item").each(function () { + $(this).parent().addClass("task-list"); + }); var tocContainer = (settings.tocContainer !== "") ? $(settings.tocContainer) : div; diff --git a/editormd.amd.min.js b/editormd.amd.min.js index 50be1d2..e104dfb 100644 --- a/editormd.amd.min.js +++ b/editormd.amd.min.js @@ -1,2 +1,2 @@ /*! Editor.md v1.5.1 | editormd.amd.min.js | Open source online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2019-05-11 */ -!function(e){"use strict";if("function"==typeof require&&"object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define)if(define.amd){var t="codemirror/mode/",i="codemirror/addon/",o=["jquery","marked","prettify","katex","raphael","underscore","flowchart","jqueryflowchart","sequenceDiagram","codemirror/lib/codemirror",t+"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",i+"edit/trailingspace",i+"dialog/dialog",i+"search/searchcursor",i+"search/search",i+"scroll/annotatescrollbar",i+"search/matchesonscrollbar",i+"display/placeholder",i+"edit/closetag",i+"fold/foldcode",i+"fold/foldgutter",i+"fold/indent-fold",i+"fold/brace-fold",i+"fold/xml-fold",i+"fold/markdown-fold",i+"fold/comment-fold",i+"mode/overlay",i+"selection/active-line",i+"edit/closebrackets",i+"display/fullscreen",i+"search/match-highlighter"];define(o,e)}else define(["jquery"],e);else window.editormd=e()}(function(){"function"==typeof define&&define.amd&&(e=arguments[0],marked=arguments[1],prettify=arguments[2],katex=arguments[3],Raphael=arguments[4],_=arguments[5],flowchart=arguments[6],CodeMirror=arguments[9]);var e=void 0!==window.jQuery?window.jQuery:window.Zepto;if(void 0!==e){var t=function(e,i){return new t.fn.init(e,i)};t.title=t.$name="Editor.md",t.version="1.5.1",t.homePage="https://pandao.github.io/editor.md/",t.classPrefix="editormd-",t.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","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","info"],mini:["undo","redo","|","watch","preview","|","help","info"]},t.defaults={mode:"gfm",name:"",value:"",theme:"",editorTheme:"default",previewTheme:"",markdown:"",appendMarkdown:"",width:"100%",height:"100%",path:"./lib/",pluginPath:"",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:!1,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(){},onpreviewed:function(){},onfullscreen:function(){},onfullscreenExit:function(){},onscroll:function(){},onpreviewscroll:function(){},imageUpload:!1,imageFormats:["jpg","jpeg","gif","png","bmp","webp"],imageUploadURL:"",imageUploadFields:"",imageUploadCallback:function(){},imageUploadCallbackName:"__Editor_md_ImageUploadCallback",crossDomainUpload:!1,uploadCallbackURL:"",toc:!0,tocm:!1,tocTitle:"",tocDropdown:!1,tocContainer:"",tocStartLevel:1,htmlDecode:!1,pageBreak:!0,atLink:!0,emailLink:!0,taskList:!1,emoji:!1,tex:!1,flowChart:!1,sequenceDiagram:!1,previewCodeHighlight:!0,toolbar:!0,toolbarAutoFixed:!0,toolbarIcons:"full",toolbarTitles:{},toolbarHandlers:{ucwords:function(){return t.toolbarHandlers.ucwords},lowercase:function(){return t.toolbarHandlers.lowercase}},toolbarCustomIcons:{lowercase:'a',ucwords:'Aa'},toolbarIconsClass:{undo:"fa-undo",redo:"fa-repeat",bold:"fa-bold",del:"fa-strikethrough",italic:"fa-italic",quote:"fa-quote-left",uppercase:"fa-font",h1:t.classPrefix+"bold",h2:t.classPrefix+"bold",h3:t.classPrefix+"bold",h4:t.classPrefix+"bold",h5:t.classPrefix+"bold",h6:t.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",info:"fa-info-circle"},toolbarIconTexts:{},lang:{name:"zh-cn",description:"开源在线 Markdown 编辑器
    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:"使用帮助",info:"关于"+t.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:"错误:请填写预格式文本或代码的内容。",placeholder:"Coding now...."},codeBlock:{title:"添加代码块",selectLabel:"代码语言:",selectDefaultText:"请选择代码语言",otherLanguage:"其他语言",unselectedLanguageAlert:"错误:请选择代码所属的语言类型。",codeEmptyAlert:"错误:请填写代码内容。",placeholder:"Coding now...."},htmlEntities:{title:"HTML 实体字符"},help:{title:"使用帮助"}}}},t.classNames={tex:t.classPrefix+"tex"},t.dialogZindex=99999,t.$katex=null,t.$marked=null,t.$CodeMirror=null,t.$prettyPrint=null;var i,o;t.prototype=t.fn={state:{watching:!1,loaded:!1,preview:!1,fullscreen:!1},init:function(i,o){o=o||{},"object"==typeof i&&(o=i);var r=this.classPrefix=t.classPrefix,a=e.extend(!0,{},t.defaults,o);o.imageFormats&&(a.imageFormats=o.imageFormats),this.settings=a,i="object"==typeof i?a.id:i;var n=this.editor=e("#"+i);this.id=i,this.lang=a.lang;var s=this.classNames={textarea:{html:r+"html-textarea",markdown:r+"markdown-textarea"}};a.pluginPath=""===a.pluginPath?a.path+"../plugins/":a.pluginPath,this.state.watching=!!a.watch,n.hasClass("editormd")||n.addClass("editormd"),n.css({width:"number"==typeof a.width?a.width+"px":a.width,height:"number"==typeof a.height?a.height+"px":a.height}),a.autoHeight&&n.css("height","auto");var l=this.markdownTextarea=n.children("textarea");l.length<1&&(n.append(""),l=this.markdownTextarea=n.children("textarea")),l.addClass(s.textarea.markdown).attr("placeholder",a.placeholder),void 0!==l.attr("name")&&""!==l.attr("name")||l.attr("name",""!==a.name?a.name:i+"-markdown-doc");var c=[a.readOnly?"":'',a.saveHTMLToTextarea?'':"",'
    ','
    ','
    '].join("\n");return n.append(c).addClass(r+"vertical"),""!==a.theme&&n.addClass(r+"theme-"+a.theme),this.mask=n.children("."+r+"mask"),this.containerMask=n.children("."+r+"container-mask"),""!==a.markdown&&l.val(a.markdown),""!==a.appendMarkdown&&l.val(l.val()+a.appendMarkdown),this.htmlTextarea=n.children("."+s.textarea.html),this.preview=n.children("."+r+"preview"),this.previewContainer=this.preview.children("."+r+"preview-container"),""!==a.previewTheme&&this.preview.addClass(r+"preview-theme-"+a.previewTheme),"function"==typeof define&&define.amd&&(void 0!==window.katex&&(t.$katex=window.katex),a.searchReplace&&!a.readOnly&&(t.loadCSS(a.path+"codemirror/addon/dialog/dialog"),t.loadCSS(a.path+"codemirror/addon/search/matchesonscrollbar"))),"function"==typeof define&&define.amd||!a.autoLoadModules?(void 0!==window.CodeMirror&&(t.$CodeMirror=window.CodeMirror),void 0!==window.marked&&(t.$marked=window.marked),this.setCodeMirror().setToolbar().loadedDisplay()):this.loadQueues(),this},loadQueues:function(){var e=this,i=this.settings,o=i.path,r=function(){if(t.isIE8)return void e.loadedDisplay();i.flowChart||i.sequenceDiagram?t.loadScript(o+"raphael.min",function(){t.loadScript(o+"underscore.min",function(){!i.flowChart&&i.sequenceDiagram?t.loadScript(o+"sequence-diagram.min",function(){e.loadedDisplay()}):i.flowChart&&!i.sequenceDiagram?t.loadScript(o+"flowchart.min",function(){t.loadScript(o+"jquery.flowchart.min",function(){e.loadedDisplay()})}):i.flowChart&&i.sequenceDiagram&&t.loadScript(o+"flowchart.min",function(){t.loadScript(o+"jquery.flowchart.min",function(){t.loadScript(o+"sequence-diagram.min",function(){e.loadedDisplay()})})})})}):e.loadedDisplay()};return t.loadCSS(o+"codemirror/codemirror.min"),i.searchReplace&&!i.readOnly&&(t.loadCSS(o+"codemirror/addon/dialog/dialog"),t.loadCSS(o+"codemirror/addon/search/matchesonscrollbar")),i.codeFold&&t.loadCSS(o+"codemirror/addon/fold/foldgutter"),t.loadScript(o+"codemirror/codemirror.min",function(){t.$CodeMirror=CodeMirror,t.loadScript(o+"codemirror/modes.min",function(){t.loadScript(o+"codemirror/addons.min",function(){if(e.setCodeMirror(),"gfm"!==i.mode&&"markdown"!==i.mode)return e.loadedDisplay(),!1;e.setToolbar(),t.loadScript(o+"marked.min",function(){t.$marked=marked,i.previewCodeHighlight?t.loadScript(o+"prettify.min",function(){r()}):r()})})})}),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 i=this.settings;return i.editorTheme=e,"default"!==e&&t.loadCSS(i.path+"codemirror/theme/"+i.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,i=this.editor;"default"!==e.editorTheme&&t.loadCSS(e.path+"codemirror/theme/"+e.editorTheme);var o={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=t.$CodeMirror.fromTextArea(this.markdownTextarea[0],o),this.codeMirror=this.cmElement=i.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(t){var i=this.settings;if(!i.gotoLine)return this;var o=this.cm,r=o.lineCount(),a=this.preview;if("string"==typeof t&&("last"===t&&(t=r),"first"===t&&(t=1)),"number"!=typeof t)return alert("Error: The line number must be an integer."),this;if((t=parseInt(t)-1)>r)return alert("Error: The line number range 1-"+r),this;o.setCursor({line:t,ch:0});var n=o.getScrollInfo(),s=n.clientHeight,l=o.charCoords({line:t,ch:0},"local");if(o.scrollTo(null,(l.top+l.bottom-s)/2),i.watch){var c=this.codeMirror.find(".CodeMirror-scroll")[0],h=e(c).height(),d=c.scrollTop,u=d/c.scrollHeight;0===d?a.scrollTop(0):d+h>=c.scrollHeight-16?a.scrollTop(a[0].scrollHeight):a.scrollTop(a[0].scrollHeight*u)}return o.focus(),this},extend:function(){return void 0!==arguments[1]&&("function"==typeof arguments[1]&&(arguments[1]=e.proxy(arguments[1],this)),this[arguments[0]]=arguments[1]),"object"==typeof arguments[0]&&void 0===arguments[0].length&&e.extend(!0,this,arguments[0]),this},set:function(t,i){return void 0!==i&&"function"==typeof i&&(i=e.proxy(i,this)),this[t]=i,this},config:function(t,i){var o=this.settings;return"object"==typeof t&&(o=e.extend(!0,o,t)),"string"==typeof t&&(o[t]=i),this.settings=o,this.recreate(),this},on:function(t,i){var o=this.settings;return void 0!==o["on"+t]&&(o["on"+t]=e.proxy(i,this)),this},off:function(e){var t=this.settings;return void 0!==t["on"+e]&&(t["on"+e]=function(){}),this},showToolbar:function(t){var i=this.settings;return i.readOnly?this:(i.toolbar&&(this.toolbar.length<1||""===this.toolbar.find("."+this.classPrefix+"menu").html())&&this.setToolbar(),i.toolbar=!0,this.toolbar.show(),this.resize(),e.proxy(t||function(){},this)(),this)},hideToolbar:function(t){return this.settings.toolbar=!1,this.toolbar.hide(),this.resize(),e.proxy(t||function(){},this)(),this},setToolbarAutoFixed:function(t){var i=this.state,o=this.editor,r=this.toolbar,a=this.settings;void 0!==t&&(a.toolbarAutoFixed=t);var n=function(){var t=e(window),i=t.scrollTop();if(!a.toolbarAutoFixed)return!1;i-o.offset().top>10&&i
    ';i.append(a),r=this.toolbar=i.children("."+o+"toolbar")}if(!e.toolbar)return r.hide(),this;r.show();for(var n="function"==typeof e.toolbarIcons?e.toolbarIcons():"string"==typeof e.toolbarIcons?t.toolbarModes[e.toolbarIcons]:e.toolbarIcons,s=r.find("."+this.classPrefix+"menu"),l="",c=!1,h=0,d=n.length;h|';else{var f=/h(\d)/.test(u),g=u;"watch"!==u||e.watch||(g="unwatch");var p=e.lang.toolbar[g],m=e.toolbarIconTexts[g],w=e.toolbarIconsClass[g];p=void 0===p?"":p,m=void 0===m?"":m,w=void 0===w?"":w;var v=c?'
  • ':"
  • ";void 0!==e.toolbarCustomIcons[u]&&"function"!=typeof e.toolbarCustomIcons[u]?v+=e.toolbarCustomIcons[u]:(v+='',v+=''+(f?u.toUpperCase():""===w?m:"")+"",v+=""),v+="
  • ",l=c?v+l:l+v}}return s.html(l),s.find('[title="Lowercase"]').attr("title",e.lang.toolbar.lowercase),s.find('[title="ucwords"]').attr("title",e.lang.toolbar.ucwords),this.setToolbarHandler(),this.setToolbarAutoFixed(),this},dialogLockScreen:function(){return e.proxy(t.dialogLockScreen,this)(),this},dialogShowMask:function(i){return e.proxy(t.dialogShowMask,this)(i),this},getToolbarHandles:function(e){var i=this.toolbarHandlers=t.toolbarHandlers;return e&&void 0!==toolbarIconHandlers[e]?i[e]:i},setToolbarHandler:function(){var t=this,i=this.settings;if(!i.toolbar||i.readOnly)return this;var o=this.toolbar,r=this.cm,a=this.classPrefix,n=this.toolbarIcons=o.find("."+a+"menu > li > a"),s=this.getToolbarHandles();return n.bind("click",function(){var o=e(this).children(".fa"),a=o.attr("name"),n=r.getCursor(),l=r.getSelection();if(""!==a)return t.activeIcon=o,void 0!==s[a]?e.proxy(s[a],t)(r):void 0!==i.toolbarHandlers[a]&&e.proxy(i.toolbarHandlers[a],t)(r,o,n,l),"link"!==a&&"reference-link"!==a&&"image"!==a&&"code-block"!==a&&"preformatted-text"!==a&&"watch"!==a&&"preview"!==a&&"search"!==a&&"fullscreen"!==a&&"info"!==a&&r.focus(),!1}),this},createDialog:function(i){return e.proxy(t.createDialog,this)(i)},createInfoDialog:function(){var e=this,i=this.editor,o=this.classPrefix,r=['
    ','
    ','

    '+t.title+"v"+t.version+"

    ","

    "+this.lang.description+"

    ",'

    '+t.homePage+'

    ','

    Copyright © 2015-'+t.dateFormat("yyyy")+' Pandao, The MIT License.

    ',"
    ",'',"
    "].join("\n");i.append(r);var a=this.infoDialog=i.children("."+o+"dialog-info");return a.find("."+o+"dialog-close").bind("click",function(){e.hideInfoDialog()}),a.css("border",t.isIE8?"1px solid #ddd":"").css("z-index",t.dialogZindex).show(),this.infoDialogPosition(),this},infoDialogPosition:function(){var t=this.infoDialog,i=function(){t.css({top:(e(window).height()-t.height())/2+"px",left:(e(window).width()-t.width())/2+"px"})};return i(),e(window).resize(i),this},showInfoDialog:function(){e("html,body").css("overflow-x","hidden");var i=this.editor,o=this.settings,r=this.infoDialog=i.children("."+this.classPrefix+"dialog-info");return r.length<1&&this.createInfoDialog(),this.lockScreen(!0),this.mask.css({opacity:o.dialogMaskOpacity,backgroundColor:o.dialogMaskBgColor}).show(),r.css("z-index",t.dialogZindex).show(),this.infoDialogPosition(),this},hideInfoDialog:function(){return e("html,body").css("overflow-x",""),this.infoDialog.hide(),this.mask.hide(),this.lockScreen(!1),this},lockScreen:function(e){return t.lockScreen(e),this.resize(),this},recreate:function(){var e=this.editor,t=this.settings;return this.codeMirror.remove(),this.setCodeMirror(),t.readOnly||(e.find(".editormd-dialog").length>0&&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"),void 0!==window.prettyPrint&&window.prettyPrint()),this},katexRender:function(){return null===i?this:(this.previewContainer.find("."+t.classNames.tex).each(function(){var i=e(this);t.$katex.render(i.text(),i[0]),i.find(".katex").css("font-size","1.6em")}),this)},flowChartAndSequenceDiagramRender:function(){var i=this,r=this.settings,a=this.previewContainer;if(t.isIE8)return this;if(r.flowChart){if(null===o)return this;a.find(".flowchart").flowChart()}r.sequenceDiagram&&a.find(".sequence-diagram").sequenceDiagram({theme:"simple"});var n=i.preview,s=i.codeMirror,l=s.find(".CodeMirror-scroll"),c=l.height(),h=l.scrollTop(),d=h/l[0].scrollHeight,u=0;n.find(".markdown-toc-list").each(function(){u+=e(this).height()});var f=n.find(".editormd-toc-menu").height();return f=f||0,0===h?n.scrollTop(0):h+c>=l[0].scrollHeight-16?n.scrollTop(n[0].scrollHeight):n.scrollTop((n[0].scrollHeight+u+f)*d),this},registerKeyMaps:function(i){var o=this,r=this.cm,a=this.settings,n=t.toolbarHandlers,s=a.disabledKeyMaps;if(i=i||null){for(var l in i)if(e.inArray(l,s)<0){var c={};c[l]=i[l],r.addKeyMap(i)}}else{for(var h in t.keyMaps){var d=t.keyMaps[h],u="string"==typeof d?e.proxy(n[d],o):e.proxy(d,o);if(e.inArray(h,["F9","F10","F11"])<0&&e.inArray(h,s)<0){var f={};f[h]=u,r.addKeyMap(f)}}e(window).keydown(function(t){var i={120:"F9",121:"F10",122:"F11"};if(e.inArray(i[t.keyCode],s)<0)switch(t.keyCode){case 120:e.proxy(n.watch,o)(),t.stopPropagation();break;case 121:e.proxy(n.preview,o)(),t.stopPropagation();break;case 122:e.proxy(n.fullscreen,o)(),t.stopPropagation()}})}return this},bindScrollEvent:function(){var i=this,o=this.preview,r=this.settings,a=this.codeMirror,n=t.mouseOrTouch;if(!r.syncScrolling)return this;var s=function(){a.find(".CodeMirror-scroll").bind(n("scroll","touchmove"),function(t){var a=e(this).height(),n=e(this).scrollTop(),s=n/e(this)[0].scrollHeight,l=0;o.find(".markdown-toc-list").each(function(){l+=e(this).height()});var c=o.find(".editormd-toc-menu").height();c=c||0,0===n?o.scrollTop(0):n+a>=e(this)[0].scrollHeight-16?o.scrollTop(o[0].scrollHeight):o.scrollTop((o[0].scrollHeight+l+c)*s),e.proxy(r.onscroll,i)(t)})},l=function(){a.find(".CodeMirror-scroll").unbind(n("scroll","touchmove"))},c=function(){o.bind(n("scroll","touchmove"),function(t){var o=e(this).height(),n=e(this).scrollTop(),s=n/e(this)[0].scrollHeight,l=a.find(".CodeMirror-scroll");0===n?l.scrollTop(0):n+o>=e(this)[0].scrollHeight?l.scrollTop(l[0].scrollHeight):l.scrollTop(l[0].scrollHeight*s),e.proxy(r.onpreviewscroll,i)(t)})},h=function(){o.unbind(n("scroll","touchmove"))};return a.bind({mouseover:s,mouseout:l,touchstart:s,touchend:l}),"single"===r.syncScrolling?this:(o.bind({mouseover:c,mouseout:h,touchstart:c,touchend:h}),this)},bindChangeEvent:function(){var e=this,t=this.cm,o=this.settings;return o.syncScrolling?(t.on("change",function(){o.watch&&e.previewContainer.css("padding",o.autoHeight?"20px 20px 50px 40px":"20px"),i=setTimeout(function(){clearTimeout(i),e.save(),i=null},o.delay)}),this):this},loadedDisplay:function(t){t=t||!1;var i=this,o=this.editor,r=this.preview,a=this.settings;return this.containerMask.hide(),this.save(),a.watch&&r.show(),o.data("oldWidth",o.width()).data("oldHeight",o.height()),this.resize(),this.registerKeyMaps(),e(window).resize(function(){i.resize()}),this.bindScrollEvent().bindChangeEvent(),t||e.proxy(a.onload,this)(),this.state.loaded=!0,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(t,i){t=t||null,i=i||null;var o=this.state,r=this.editor,a=this.preview,n=this.toolbar,s=this.settings,l=this.codeMirror;if(t&&r.css("width","number"==typeof t?t+"px":t),!s.autoHeight||o.fullscreen||o.preview?(i&&r.css("height","number"==typeof i?i+"px":i),o.fullscreen&&r.height(e(window).height()),s.toolbar&&!s.readOnly?l.css("margin-top",n.height()+1).height(r.height()-n.height()):l.css("margin-top",0).height(r.height())):(r.css("height","auto"),l.css("height","auto")),s.watch)if(l.width(r.width()/2-1),a.width(o.preview?r.width():r.width()/2),this.previewContainer.css("padding",s.autoHeight?"20px 20px 50px 40px":"20px"),s.toolbar&&!s.readOnly?a.css("top",n.height()+1):a.css("top",0),!s.autoHeight||o.fullscreen||o.preview){var c=s.toolbar&&!s.readOnly?r.height()-n.height():r.height();a.height(c)}else a.height("");else l.width(r.width()),a.hide();return o.loaded&&e.proxy(s.onresize,this)(),this},save:function(){if(null===i)return this;var r=this,a=this.state,n=this.settings,s=this.cm,l=s.getValue(),c=this.previewContainer;if("gfm"!==n.mode&&"markdown"!==n.mode)return this.markdownTextarea.val(l),this;var h=t.$marked,d=this.markdownToC=[],u=this.markedRendererOptions={toc:n.toc,tocm:n.tocm,tocStartLevel:n.tocStartLevel,pageBreak:n.pageBreak,taskList:n.taskList,emoji:n.emoji,tex:n.tex,atLink:n.atLink,emailLink:n.emailLink,flowChart:n.flowChart,sequenceDiagram:n.sequenceDiagram,previewCodeHighlight:n.previewCodeHighlight},f=this.markedOptions={renderer:t.markedRenderer(d,u),gfm:!0,tables:!0,breaks:!0,pedantic:!1,sanitize:!n.htmlDecode,smartLists:!0,smartypants:!0};h.setOptions(f);var g=t.$marked(l,f);if(g=t.filterHTMLTags(g,n.htmlDecode),this.markdownTextarea.text(l),s.save(),n.saveHTMLToTextarea&&this.htmlTextarea.text(g),n.watch||!n.watch&&a.preview){if(c.html(g),this.previewCodeHighlight(),n.toc){var p=""===n.tocContainer?c:e(n.tocContainer),m=p.find("."+this.classPrefix+"toc-menu");p.attr("previewContainer",""===n.tocContainer?"true":"false"),""!==n.tocContainer&&m.length>0&&m.remove(),t.markdownToCRenderer(d,p,n.tocDropdown,n.tocStartLevel),(n.tocDropdown||p.find("."+this.classPrefix+"toc-menu").length>0)&&t.tocDropdownMenu(p,""!==n.tocTitle?n.tocTitle:this.lang.tocTitle),""!==n.tocContainer&&c.find(".markdown-toc").css("border","none")}n.tex&&(!t.kaTeXLoaded&&n.autoLoadModules?t.loadKaTeX(function(){t.$katex=katex,t.kaTeXLoaded=!0,r.katexRender()}):(t.$katex=katex,this.katexRender())),(n.flowChart||n.sequenceDiagram)&&(o=setTimeout(function(){clearTimeout(o),r.flowChartAndSequenceDiagramRender(),o=null},10)),a.loaded&&e.proxy(n.onchange,this)()}return 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){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(t){var o=this.settings;if(e.inArray(o.mode,["gfm","markdown"])<0)return this;if(this.state.watching=o.watch=!0,this.preview.show(),this.toolbar){var r=o.toolbarIconsClass.watch,a=o.toolbarIconsClass.unwatch,n=this.toolbar.find(".fa[name=watch]");n.parent().attr("title",o.lang.toolbar.watch),n.removeClass(a).addClass(r)}return this.codeMirror.css("border-right","1px solid #ddd").width(this.editor.width()/2),i=0,this.save().resize(),o.onwatch||(o.onwatch=t||function(){}),e.proxy(o.onwatch,this)(),this},unwatch:function(t){var i=this.settings;if(this.state.watching=i.watch=!1,this.preview.hide(),this.toolbar){var o=i.toolbarIconsClass.watch,r=i.toolbarIconsClass.unwatch,a=this.toolbar.find(".fa[name=watch]");a.parent().attr("title",i.lang.toolbar.unwatch),a.removeClass(o).addClass(r)}return this.codeMirror.css("border-right","none").width(this.editor.width()),this.resize(),i.onunwatch||(i.onunwatch=t||function(){}),e.proxy(i.onunwatch,this)(),this},show:function(t){t=t||function(){};var i=this;return this.editor.show(0,function(){e.proxy(t,i)()}),this},hide:function(t){t=t||function(){};var i=this;return this.editor.hide(0,function(){e.proxy(t,i)()}),this},destroy:function(){this.hide(),this.editor.remove()},previewing:function(){var t=this,i=this.editor,o=this.preview,r=this.toolbar,a=this.settings,n=this.codeMirror,s=this.previewContainer;if(e.inArray(a.mode,["gfm","markdown"])<0)return this;var l=this.editor.outerHeight();a.toolbar&&r&&(r.toggle(),r.find(".fa[name=preview]").toggleClass("active")),n.toggle();var c=function(e){e.shiftKey&&27===e.keyCode&&t.previewed()};"none"===n.css("display")?(this.state.preview=!0,this.settings.autoHeight&&this.editor.css("height",l),this.state.fullscreen&&o.css("background","#fff"),i.find("."+this.classPrefix+"preview-close-btn").show().bind("click",function(){t.previewed()}),a.watch?s.css("padding",""):this.save(),s.addClass(this.classPrefix+"preview-active"),o.show().css({position:"",top:0,width:i.width(),height:a.autoHeight&&!this.state.fullscreen?"auto":i.height()}),this.state.loaded&&e.proxy(a.onpreviewing,this)(),e(window).bind("keyup",c)):(e(window).unbind("keyup",c),this.previewed())},previewed:function(){var t=this.editor,i=this.preview,o=this.toolbar,r=this.settings,a=this.previewContainer,n=t.find("."+this.classPrefix+"preview-close-btn");return this.state.preview=!1,this.codeMirror.show(),r.toolbar&&o.show(),i[r.watch?"show":"hide"](),n.hide().unbind("click"),a.removeClass(this.classPrefix+"preview-active"),r.watch&&a.css("padding","20px"),this.settings.autoHeight&&this.editor.css("height","auto"),i.css({background:null,position:"absolute",width:t.width()/2,height:r.autoHeight&&!this.state.fullscreen?"auto":t.height()-o.height(),top:r.toolbar?o.height():0}),this.state.loaded&&e.proxy(r.onpreviewed,this)(),this},fullscreen:function(){var t=this,i=this.state,o=this.editor,r=this.toolbar,a=this.settings,n=this.classPrefix+"fullscreen";r&&r.find(".fa[name=fullscreen]").parent().toggleClass("active");var s=function(e){e.shiftKey||27!==e.keyCode||i.fullscreen&&t.fullscreenExit()};return o.hasClass(n)?(e(window).unbind("keyup",s),this.fullscreenExit()):(i.fullscreen=!0,e("html,body").css("overflow","hidden"),o.css({width:e(window).width(),height:e(window).height()}).addClass(n),this.resize(),e.proxy(a.onfullscreen,this)(),e(window).bind("keyup",s)),this},fullscreenExit:function(){var t=this.editor,i=this.settings,o=this.toolbar,r=this.classPrefix+"fullscreen";return this.state.fullscreen=!1,o&&o.find(".fa[name=fullscreen]").parent().removeClass("active"),e("html,body").css("overflow",""),t.css({width:t.data("oldWidth"),height:t.data("oldHeight")}).removeClass(r),this.resize(),e.proxy(i.onfullscreenExit,this)(),this},executePlugin:function(i,o){var r=this,a=this.cm;return o=this.settings.pluginPath+o,"function"==typeof define?void 0===this[i]?(alert("Error: "+i+" plugin is not found, you are not load this plugin."),this):(this[i](a),this):(e.inArray(o,t.loadFiles.plugin)<0?t.loadPlugin(o,function(){t.loadPlugins[i]=r[i],r[i](a)}):e.proxy(t.loadPlugins[i],this)(a),this)},search:function(e){var t=this.settings;return t.searchReplace?(t.readOnly||this.cm.execCommand(e||"find"),this):(alert("Error: settings.searchReplace == false"),this)},searchReplace:function(){return this.search("replace"),this},searchReplaceAll:function(){return this.search("replaceAll"),this}},t.fn.init.prototype=t.fn,t.dialogLockScreen=function(){(this.settings||{dialogLockScreen:!0}).dialogLockScreen&&(e("html,body").css("overflow","hidden"),this.resize())},t.dialogShowMask=function(t){var i=this.editor,o=this.settings||{dialogShowMask:!0};t.css({top:(e(window).height()-t.height())/2+"px",left:(e(window).width()-t.width())/2+"px"}),o.dialogShowMask&&i.children("."+this.classPrefix+"mask").css("z-index",parseInt(t.css("z-index"))-1).show()},t.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,i=e.getSelection(),o=e.listSelections();e.replaceSelection(t.firstUpperCase(i)),e.setSelections(o)},ucwords:function(){var e=this.cm,i=e.getSelection(),o=e.listSelections();e.replaceSelection(t.wordsFirstUpperCase(i)),e.setSelections(o)},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.getSelection(),i=e.listSelections();e.replaceSelection(t.toLowerCase()),e.setSelections(i)},h1: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)},h2: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+3)):e.replaceSelection("## "+i)},h3: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+4)):e.replaceSelection("### "+i)},h4: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+5)):e.replaceSelection("#### "+i)},h5: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+6)):e.replaceSelection("##### "+i)},h6: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+7)):e.replaceSelection("###### "+i)},"list-ul":function(){var e=this.cm,t=e.getSelection();if(""===t)e.replaceSelection("- "+t);else{for(var i=t.split("\n"),o=0,r=i.length;o'}else{var s=e.match(m),l=e.match(g);if(s)for(var c=0,h=s.length;c'}else{if(!l){var u="+1"===o?"plus1":o;return u="black_large_square"===u?"black_square":u,u="moon"===u?"waxing_gibbous_moon":u,':'+o+':'}for(var f=0,w=l.length;f'}}}});return e},l.atLink=function(i){return h.test(i)?(n.atLink&&(i=i.replace(u,function(e,t,i,o){return e.replace(/@/g,"_#_@_#_")}),i=i.replace(h,function(e,i){return''+e+""}).replace(/_#_@_#_/g,"@")),n.emailLink&&(i=i.replace(f,function(t,i,o,r,a){return!i&&e.inArray(a,"jpg|jpeg|png|gif|webp|ico|icon|pdf".split("|"))<0?''+t+"":t})),i):i},l.link=function(e,t,i){if(this.options.sanitize)try{if(0===decodeURIComponent(unescape(e)).replace(/[^\w:]/g,"").toLowerCase().indexOf("javascript:"))return""}catch(e){return""}var o=''+i.replace(/@/g,"@")+""):(t&&(o+=' title="'+t+'"'),o+=">"+i+"")},l.heading=function(e,t){var o=e,a=/\s*\]*)\>(.*)\<\/a\>\s*/;if(a.test(e)){var n=[];e=e.split(/\]+)\>([^\>]*)\<\/a\>/);for(var s=0,l=e.length;s';return f+='',f+='',f+=a?this.atLink(this.emoji(o)):this.atLink(this.emoji(e)),f+=""},l.pageBreak=function(e){return w.test(e)&&n.pageBreak&&(e='
    '),e},l.paragraph=function(e){var i=/\$\$(.*)\$\$/g.test(e),o=/^\$\$(.*)\$\$$/.test(e),r=o?' class="'+t.classNames.tex+'"':"",a=n.tocm?/^(\[TOC\]|\[TOCM\])$/.test(e):/^\[TOC\]$/.test(e),s=/^\[TOCM\]$/.test(e);e=!o&&i?e.replace(/(\$\$([^\$]*)\$\$)+/g,function(e,i){return''+i.replace(/\$/g,"")+""}):o?e.replace(/\$/g,""):e;var l='
    '+e+"
    ";return a?s?'
    '+l+"

    ":l:w.test(e)?this.pageBreak(e):""+this.atLink(this.emoji(e))+"

    \n"},l.code=function(e,i){return"seq"===i||"sequence"===i?'
    '+e+"
    ":"flow"===i?'
    '+e+"
    ":"math"===i||"latex"===i||"katex"===i?'

    '+e+"

    ":s.Renderer.prototype.code.apply(this,arguments)},l.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))+"\n"},l.listitem=function(e){return n.taskList&&/^\s*\[[x\s]\]\s*/.test(e)?(e=e.replace(/^\s*\[\s\]\s*/,' ').replace(/^\s*\[x\]\s*/,' '),'
  • '+this.atLink(this.emoji(e))+"
  • "):"
  • "+this.atLink(this.emoji(e))+"
  • "},l},t.markdownToCRenderer=function(e,t,i,o){var r="",a=0,n=this.classPrefix;o=o||1;for(var s=0,l=e.length;sa?"":h"):"",r+='
  • '+c+"
      ",a=h)}var d=t.find(".markdown-toc");if(d.length<1&&"false"===t.attr("previewContainer")){var u='
      ';u=i?'
      '+u+"
      ":u,t.html(u),d=t.find(".markdown-toc")}return i&&d.wrap('

      '),d.html('
        ').children(".markdown-toc-list").html(r.replace(/\r?\n?\\<\/ul\>/g,"")),d},t.tocDropdownMenu=function(t,i){i=i||"Table of Contents";var o=400,r=t.find("."+this.classPrefix+"toc-menu");return r.each(function(){var t=e(this),r=t.children(".markdown-toc"),a='',n=''+a+i+"",s=r.children("ul"),l=s.find("li");r.append(n),l.first().before("
      • "+i+" "+a+"

      • "),t.mouseover(function(){s.show(),l.each(function(){var t=e(this),i=t.children("ul");if(""===i.html()&&i.remove(),i.length>0&&""!==i.html()){var r=t.children("a").first();r.children(".fa").length<1&&r.append(e(a).css({float:"right",paddingTop:"4px"}))}t.mouseover(function(){i.css("z-index",o).show(),o+=1}).mouseleave(function(){i.hide()})})}).mouseleave(function(){s.hide()})}),r},t.filterHTMLTags=function(t,i){if("string"!=typeof t&&(t=t.toString()),"string"!=typeof i)return t;for(var o=i.split("|"),r=o[0].split(","),a=o[1],n=0,s=r.length;n]*)>([^>]*)","igm"),"")}if(void 0!==a){var c=/\<(\w+)\s*([^\>]*)\>([^\>]*)\<\/(\w+)\>/gi;t="*"===a?t.replace(c,function(e,t,i,o,r){return"<"+t+">"+o+""}):"on*"===a?t.replace(c,function(t,i,o,r,a){var n=e("<"+i+">"+r+""),s=e(t)[0].attributes,l={};e.each(s,function(e,t){'"'!==t.nodeName&&(l[t.nodeName]=t.nodeValue)}),e.each(l,function(e){0===e.indexOf("on")&&delete l[e]}),n.attr(l);var c=void 0!==n[1]?e(n[1]).text():"";return n[0].outerHTML+c}):t.replace(c,function(t,i,o,r){var n=a.split(","),s=e(t);return s.html(r),e.each(n,function(e){s.attr(n[e],null)}),s[0].outerHTML})}return t},t.markdownToHTML=function(i,o){var r={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};t.$marked=marked;var a=e("#"+i),n=a.settings=e.extend(!0,{},r,o||{}),s=a.find("textarea");s.length<1&&(a.append(""),s=a.find("textarea"));var l=""===n.markdown?s.val():n.markdown,c=[],h={toc:n.toc,tocm:n.tocm,tocStartLevel:n.tocStartLevel,taskList:n.taskList,emoji:n.emoji,tex:n.tex,pageBreak:n.pageBreak,atLink:n.atLink,emailLink:n.emailLink,flowChart:n.flowChart,sequenceDiagram:n.sequenceDiagram,previewCodeHighlight:n.previewCodeHighlight},d={renderer:t.markedRenderer(c,h),gfm:n.gfm,tables:!0,breaks:!0,pedantic:!1,sanitize:!n.htmlDecode,smartLists:!0,smartypants:!0};l=l.toString();var u=marked(l,d);u=t.filterHTMLTags(u,n.htmlDecode),n.markdownSourceCode?s.text(l):s.remove(),a.addClass("markdown-body "+this.classPrefix+"html-preview").append(u);var f=""!==n.tocContainer?e(n.tocContainer):a;if(""!==n.tocContainer&&f.attr("previewContainer",!1),n.toc&&(a.tocContainer=this.markdownToCRenderer(c,f,n.tocDropdown,n.tocStartLevel),(n.tocDropdown||a.find("."+this.classPrefix+"toc-menu").length>0)&&this.tocDropdownMenu(a,n.tocTitle),""!==n.tocContainer&&a.find(".editormd-toc-menu, .editormd-markdown-toc").remove()),n.previewCodeHighlight&&(a.find("pre").addClass("prettyprint linenums"),window.prettyPrint()),t.isIE8||(n.flowChart&&a.find(".flowchart").flowChart(),n.sequenceDiagram&&a.find(".sequence-diagram").sequenceDiagram({theme:"simple"})),n.tex){var g=function(){a.find("."+t.classNames.tex).each(function(){var t=e(this);katex.render(t.html().replace(/</g,"<").replace(/>/g,">"),t[0]),t.find(".katex").css("font-size","1.6em")})};!n.autoLoadKaTeX||t.$katex||t.kaTeXLoaded?g():this.loadKaTeX(function(){t.$katex=katex,t.kaTeXLoaded=!0,g()})}return a.getMarkdown=function(){return s.val()},a},t.themes=["default","dark"],t.previewThemes=["default","dark"],t.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"],t.loadPlugins={},t.loadFiles={js:[],css:[],plugin:[]},t.loadPlugin=function(e,i,o){i=i||function(){},this.loadScript(e,function(){t.loadFiles.plugin.push(e),i()},o)},t.loadCSS=function(e,i,o){o=o||"head",i=i||function(){};var r=document.createElement("link");r.type="text/css",r.rel="stylesheet",r.onload=r.onreadystatechange=function(){t.loadFiles.css.push(e),i()},r.href=e+".css","head"===o?document.getElementsByTagName("head")[0].appendChild(r):document.body.appendChild(r)},t.isIE="Microsoft Internet Explorer"===navigator.appName,t.isIE8=t.isIE&&"8."===navigator.appVersion.match(/8./i),t.loadScript=function(e,i,o){o=o||"head",i=i||function(){};var r=null;r=document.createElement("script"),r.id=e.replace(/[\.\/]+/g,"-"),r.type="text/javascript",r.src=e+".js",t.isIE8?r.onreadystatechange=function(){r.readyState&&("loaded"!==r.readyState&&"complete"!==r.readyState||(r.onreadystatechange=null,t.loadFiles.js.push(e),i()))}:r.onload=function(){t.loadFiles.js.push(e),i()},"head"===o?document.getElementsByTagName("head")[0].appendChild(r):document.body.appendChild(r)},t.katexURL={css:"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.1/katex.min",js:"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.1/katex.min"},t.kaTeXLoaded=!1,t.loadKaTeX=function(e){t.loadCSS(t.katexURL.css,function(){t.loadScript(t.katexURL.js,e||function(){})})},t.lockScreen=function(t){e("html,body").css("overflow",t?"hidden":"")},t.createDialog=function(i){var o={name:"",width:420,height:240,title:"",drag:!0,closed:!0,cached:!1,content:"",mask:!0,maskStyle:{backgroundColor:"#fff",opacity:.1},lockScreen:!0,footer:!0,buttons:!1};i=e.extend(!0,o,i);var r=this,a=this.editor,n=t.classPrefix,s=(new Date).getTime(),l=""===i.name?n+"dialog-"+s:i.name,c='
        ';""!==i.title&&(c+='
        ",c+=''+i.title+"",c+="
        "),i.closed&&(c+=''),c+='
        '+i.content,(i.footer||"string"==typeof i.footer)&&(c+='"),c+="
        ",c+='
        ',c+='
        ',c+="
        ",a.append(c);var h=a.find("."+l);h.lockScreen=function(t){return i.lockScreen&&(e("html,body").css("overflow",t?"hidden":""),r.resize()),h},h.showMask=function(){return i.mask&&a.find("."+n+"mask").css(i.maskStyle).css("z-index",t.dialogZindex-1).show(),h},h.hideMask=function(){return i.mask&&a.find("."+n+"mask").hide(),h},h.loading=function(e){return h.find("."+n+"dialog-mask")[e?"show":"hide"](),h},h.lockScreen(!0).showMask(),h.show().css({zIndex:t.dialogZindex,border:t.isIE8?"1px solid #ddd":"",width:"number"==typeof i.width?i.width+"px":i.width,height:"number"==typeof i.height?i.height+"px":i.height});var d=function(){h.css({top:(e(window).height()-h.height())/2+"px",left:(e(window).width()-h.width())/2+"px"})};if(d(),e(window).resize(d),h.children("."+n+"dialog-close").bind("click",function(){h.hide().lockScreen(!1).hideMask(),i.cached||h.remove()}),"object"==typeof i.buttons){var u=h.footer=h.find("."+n+"dialog-footer");for(var f in i.buttons){var g=i.buttons[f],p=n+f+"-btn";u.append('"),g[1]=e.proxy(g[1],h),u.children("."+p).bind("click",g[1])}}if(""!==i.title&&i.drag){var m,w,v=h.children("."+n+"dialog-header");i.mask||v.bind("click",function(){t.dialogZindex+=2,h.css("z-index",t.dialogZindex)});var k=function(e){e.removeClass(n+"user-unselect").off("selectstart")},b=function(e){e.addClass(n+"user-unselect").on("selectstart",function(){return!1})},x=function(t){t=t||window.event;var i,o,r=parseInt(h[0].style.left),a=parseInt(h[0].style.top);r>=0?r+h.width()<=e(window).width()?i=t.clientX-m:(i=e(window).width()-h.width(),document.onmousemove=null):(i=0,document.onmousemove=null),a>=0?o=t.clientY-w:(o=0,document.onmousemove=null),document.onselectstart=function(){return!1},b(e("body")),b(h),h[0].style.left=i+"px",h[0].style.top=o+"px"};v.mousedown(function(e){e=e||window.event,m=e.clientX-parseInt(h[0].style.left),w=e.clientY-parseInt(h[0].style.top),document.onmousemove=x}),document.onmouseup=function(){k(e("body")),k(h),document.onselectstart=null,document.onmousemove=null},v.touchDraggable=function(){var t=null,i=function(i){var o=i.originalEvent,r=e(this).parent().position();t={x:o.changedTouches[0].pageX-r.left,y:o.changedTouches[0].pageY-r.top}},o=function(i){i.preventDefault();var o=i.originalEvent;e(this).parent().css({top:o.changedTouches[0].pageY-t.y,left:o.changedTouches[0].pageX-t.x})};this.bind("touchstart",i).bind("touchmove",o)},v.touchDraggable()}return t.dialogZindex+=2,h},t.mouseOrTouch=function(e,t){e=e||"click",t=t||"touchend";var i=e;try{document.createEvent("TouchEvent"),i=t}catch(e){}return i},t.dateFormat=function(e){e=e||"";var t=function(e){return e<10?"0"+e:e},i=new Date,o=i.getFullYear(),r=o.toString().slice(2,4),a=t(i.getMonth()+1),n=t(i.getDate()),s=i.getDay(),l=t(i.getHours()),c=t(i.getMinutes()),h=t(i.getSeconds()),d=t(i.getMilliseconds()),u="",f=r+"-"+a+"-"+n,g=o+"-"+a+"-"+n,p=l+":"+c+":"+h;switch(e){case"UNIX Time":u=i.getTime();break;case"UTC":u=i.toUTCString();break;case"yy":u=r;break;case"year":case"yyyy":u=o;break;case"month":case"mm":u=a;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=n;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=g;break;case"yyyy-mm-dd h:i:s ms":case"full + ms":u=g+" "+p+" "+d;break;case"full":case"yyyy-mm-dd h:i:s":default:u=g+" "+p}return u},t}}); \ No newline at end of file +!function(e){"use strict";if("function"==typeof require&&"object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define)if(define.amd){var t="codemirror/mode/",i="codemirror/addon/",o=["jquery","marked","prettify","katex","raphael","underscore","flowchart","jqueryflowchart","sequenceDiagram","codemirror/lib/codemirror",t+"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",i+"edit/trailingspace",i+"dialog/dialog",i+"search/searchcursor",i+"search/search",i+"scroll/annotatescrollbar",i+"search/matchesonscrollbar",i+"display/placeholder",i+"edit/closetag",i+"fold/foldcode",i+"fold/foldgutter",i+"fold/indent-fold",i+"fold/brace-fold",i+"fold/xml-fold",i+"fold/markdown-fold",i+"fold/comment-fold",i+"mode/overlay",i+"selection/active-line",i+"edit/closebrackets",i+"display/fullscreen",i+"search/match-highlighter"];define(o,e)}else define(["jquery"],e);else window.editormd=e()}(function(){"function"==typeof define&&define.amd&&(e=arguments[0],marked=arguments[1],prettify=arguments[2],katex=arguments[3],Raphael=arguments[4],_=arguments[5],flowchart=arguments[6],CodeMirror=arguments[9]);var e=void 0!==window.jQuery?window.jQuery:window.Zepto;if(void 0!==e){var t=function(e,i){return new t.fn.init(e,i)};t.title=t.$name="Editor.md",t.version="1.5.1",t.homePage="https://pandao.github.io/editor.md/",t.classPrefix="editormd-",t.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","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","info"],mini:["undo","redo","|","watch","preview","|","help","info"]},t.defaults={mode:"gfm",name:"",value:"",theme:"",editorTheme:"default",previewTheme:"",markdown:"",appendMarkdown:"",width:"100%",height:"100%",path:"./lib/",pluginPath:"",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:!1,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(){},onpreviewed:function(){},onfullscreen:function(){},onfullscreenExit:function(){},onscroll:function(){},onpreviewscroll:function(){},imageUpload:!1,imageFormats:["jpg","jpeg","gif","png","bmp","webp"],imageUploadURL:"",imageUploadFields:"",imageUploadCallback:function(){},imageUploadCallbackName:"__Editor_md_ImageUploadCallback",crossDomainUpload:!1,uploadCallbackURL:"",toc:!0,tocm:!1,tocTitle:"",tocDropdown:!1,tocContainer:"",tocStartLevel:1,htmlDecode:!1,pageBreak:!0,atLink:!0,emailLink:!0,taskList:!1,emoji:!1,tex:!1,flowChart:!1,sequenceDiagram:!1,previewCodeHighlight:!0,toolbar:!0,toolbarAutoFixed:!0,toolbarIcons:"full",toolbarTitles:{},toolbarHandlers:{ucwords:function(){return t.toolbarHandlers.ucwords},lowercase:function(){return t.toolbarHandlers.lowercase}},toolbarCustomIcons:{lowercase:'a',ucwords:'Aa'},toolbarIconsClass:{undo:"fa-undo",redo:"fa-repeat",bold:"fa-bold",del:"fa-strikethrough",italic:"fa-italic",quote:"fa-quote-left",uppercase:"fa-font",h1:t.classPrefix+"bold",h2:t.classPrefix+"bold",h3:t.classPrefix+"bold",h4:t.classPrefix+"bold",h5:t.classPrefix+"bold",h6:t.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",info:"fa-info-circle"},toolbarIconTexts:{},lang:{name:"zh-cn",description:"开源在线 Markdown 编辑器
        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:"使用帮助",info:"关于"+t.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:"错误:请填写预格式文本或代码的内容。",placeholder:"Coding now...."},codeBlock:{title:"添加代码块",selectLabel:"代码语言:",selectDefaultText:"请选择代码语言",otherLanguage:"其他语言",unselectedLanguageAlert:"错误:请选择代码所属的语言类型。",codeEmptyAlert:"错误:请填写代码内容。",placeholder:"Coding now...."},htmlEntities:{title:"HTML 实体字符"},help:{title:"使用帮助"}}}},t.classNames={tex:t.classPrefix+"tex"},t.dialogZindex=99999,t.$katex=null,t.$marked=null,t.$CodeMirror=null,t.$prettyPrint=null;var i,o;t.prototype=t.fn={state:{watching:!1,loaded:!1,preview:!1,fullscreen:!1},init:function(i,o){o=o||{},"object"==typeof i&&(o=i);var r=this.classPrefix=t.classPrefix,a=e.extend(!0,{},t.defaults,o);o.imageFormats&&(a.imageFormats=o.imageFormats),this.settings=a,i="object"==typeof i?a.id:i;var n=this.editor=e("#"+i);this.id=i,this.lang=a.lang;var s=this.classNames={textarea:{html:r+"html-textarea",markdown:r+"markdown-textarea"}};a.pluginPath=""===a.pluginPath?a.path+"../plugins/":a.pluginPath,this.state.watching=!!a.watch,n.hasClass("editormd")||n.addClass("editormd"),n.css({width:"number"==typeof a.width?a.width+"px":a.width,height:"number"==typeof a.height?a.height+"px":a.height}),a.autoHeight&&n.css("height","auto");var l=this.markdownTextarea=n.children("textarea");l.length<1&&(n.append(""),l=this.markdownTextarea=n.children("textarea")),l.addClass(s.textarea.markdown).attr("placeholder",a.placeholder),void 0!==l.attr("name")&&""!==l.attr("name")||l.attr("name",""!==a.name?a.name:i+"-markdown-doc");var c=[a.readOnly?"":'',a.saveHTMLToTextarea?'':"",'
        ','
        ','
        '].join("\n");return n.append(c).addClass(r+"vertical"),""!==a.theme&&n.addClass(r+"theme-"+a.theme),this.mask=n.children("."+r+"mask"),this.containerMask=n.children("."+r+"container-mask"),""!==a.markdown&&l.val(a.markdown),""!==a.appendMarkdown&&l.val(l.val()+a.appendMarkdown),this.htmlTextarea=n.children("."+s.textarea.html),this.preview=n.children("."+r+"preview"),this.previewContainer=this.preview.children("."+r+"preview-container"),""!==a.previewTheme&&this.preview.addClass(r+"preview-theme-"+a.previewTheme),"function"==typeof define&&define.amd&&(void 0!==window.katex&&(t.$katex=window.katex),a.searchReplace&&!a.readOnly&&(t.loadCSS(a.path+"codemirror/addon/dialog/dialog"),t.loadCSS(a.path+"codemirror/addon/search/matchesonscrollbar"))),"function"==typeof define&&define.amd||!a.autoLoadModules?(void 0!==window.CodeMirror&&(t.$CodeMirror=window.CodeMirror),void 0!==window.marked&&(t.$marked=window.marked),this.setCodeMirror().setToolbar().loadedDisplay()):this.loadQueues(),this},loadQueues:function(){var e=this,i=this.settings,o=i.path,r=function(){if(t.isIE8)return void e.loadedDisplay();i.flowChart||i.sequenceDiagram?t.loadScript(o+"raphael.min",function(){t.loadScript(o+"underscore.min",function(){!i.flowChart&&i.sequenceDiagram?t.loadScript(o+"sequence-diagram.min",function(){e.loadedDisplay()}):i.flowChart&&!i.sequenceDiagram?t.loadScript(o+"flowchart.min",function(){t.loadScript(o+"jquery.flowchart.min",function(){e.loadedDisplay()})}):i.flowChart&&i.sequenceDiagram&&t.loadScript(o+"flowchart.min",function(){t.loadScript(o+"jquery.flowchart.min",function(){t.loadScript(o+"sequence-diagram.min",function(){e.loadedDisplay()})})})})}):e.loadedDisplay()};return t.loadCSS(o+"codemirror/codemirror.min"),i.searchReplace&&!i.readOnly&&(t.loadCSS(o+"codemirror/addon/dialog/dialog"),t.loadCSS(o+"codemirror/addon/search/matchesonscrollbar")),i.codeFold&&t.loadCSS(o+"codemirror/addon/fold/foldgutter"),t.loadScript(o+"codemirror/codemirror.min",function(){t.$CodeMirror=CodeMirror,t.loadScript(o+"codemirror/modes.min",function(){t.loadScript(o+"codemirror/addons.min",function(){if(e.setCodeMirror(),"gfm"!==i.mode&&"markdown"!==i.mode)return e.loadedDisplay(),!1;e.setToolbar(),t.loadScript(o+"marked.min",function(){t.$marked=marked,i.previewCodeHighlight?t.loadScript(o+"prettify.min",function(){r()}):r()})})})}),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 i=this.settings;return i.editorTheme=e,"default"!==e&&t.loadCSS(i.path+"codemirror/theme/"+i.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,i=this.editor;"default"!==e.editorTheme&&t.loadCSS(e.path+"codemirror/theme/"+e.editorTheme);var o={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=t.$CodeMirror.fromTextArea(this.markdownTextarea[0],o),this.codeMirror=this.cmElement=i.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(t){var i=this.settings;if(!i.gotoLine)return this;var o=this.cm,r=o.lineCount(),a=this.preview;if("string"==typeof t&&("last"===t&&(t=r),"first"===t&&(t=1)),"number"!=typeof t)return alert("Error: The line number must be an integer."),this;if((t=parseInt(t)-1)>r)return alert("Error: The line number range 1-"+r),this;o.setCursor({line:t,ch:0});var n=o.getScrollInfo(),s=n.clientHeight,l=o.charCoords({line:t,ch:0},"local");if(o.scrollTo(null,(l.top+l.bottom-s)/2),i.watch){var c=this.codeMirror.find(".CodeMirror-scroll")[0],h=e(c).height(),d=c.scrollTop,u=d/c.scrollHeight;0===d?a.scrollTop(0):d+h>=c.scrollHeight-16?a.scrollTop(a[0].scrollHeight):a.scrollTop(a[0].scrollHeight*u)}return o.focus(),this},extend:function(){return void 0!==arguments[1]&&("function"==typeof arguments[1]&&(arguments[1]=e.proxy(arguments[1],this)),this[arguments[0]]=arguments[1]),"object"==typeof arguments[0]&&void 0===arguments[0].length&&e.extend(!0,this,arguments[0]),this},set:function(t,i){return void 0!==i&&"function"==typeof i&&(i=e.proxy(i,this)),this[t]=i,this},config:function(t,i){var o=this.settings;return"object"==typeof t&&(o=e.extend(!0,o,t)),"string"==typeof t&&(o[t]=i),this.settings=o,this.recreate(),this},on:function(t,i){var o=this.settings;return void 0!==o["on"+t]&&(o["on"+t]=e.proxy(i,this)),this},off:function(e){var t=this.settings;return void 0!==t["on"+e]&&(t["on"+e]=function(){}),this},showToolbar:function(t){var i=this.settings;return i.readOnly?this:(i.toolbar&&(this.toolbar.length<1||""===this.toolbar.find("."+this.classPrefix+"menu").html())&&this.setToolbar(),i.toolbar=!0,this.toolbar.show(),this.resize(),e.proxy(t||function(){},this)(),this)},hideToolbar:function(t){return this.settings.toolbar=!1,this.toolbar.hide(),this.resize(),e.proxy(t||function(){},this)(),this},setToolbarAutoFixed:function(t){var i=this.state,o=this.editor,r=this.toolbar,a=this.settings;void 0!==t&&(a.toolbarAutoFixed=t);var n=function(){var t=e(window),i=t.scrollTop();if(!a.toolbarAutoFixed)return!1;i-o.offset().top>10&&i
          ';i.append(a),r=this.toolbar=i.children("."+o+"toolbar")}if(!e.toolbar)return r.hide(),this;r.show();for(var n="function"==typeof e.toolbarIcons?e.toolbarIcons():"string"==typeof e.toolbarIcons?t.toolbarModes[e.toolbarIcons]:e.toolbarIcons,s=r.find("."+this.classPrefix+"menu"),l="",c=!1,h=0,d=n.length;h|';else{var f=/h(\d)/.test(u),g=u;"watch"!==u||e.watch||(g="unwatch");var p=e.lang.toolbar[g],m=e.toolbarIconTexts[g],w=e.toolbarIconsClass[g];p=void 0===p?"":p,m=void 0===m?"":m,w=void 0===w?"":w;var v=c?'
        • ':"
        • ";void 0!==e.toolbarCustomIcons[u]&&"function"!=typeof e.toolbarCustomIcons[u]?v+=e.toolbarCustomIcons[u]:(v+='',v+=''+(f?u.toUpperCase():""===w?m:"")+"",v+=""),v+="
        • ",l=c?v+l:l+v}}return s.html(l),s.find('[title="Lowercase"]').attr("title",e.lang.toolbar.lowercase),s.find('[title="ucwords"]').attr("title",e.lang.toolbar.ucwords),this.setToolbarHandler(),this.setToolbarAutoFixed(),this},dialogLockScreen:function(){return e.proxy(t.dialogLockScreen,this)(),this},dialogShowMask:function(i){return e.proxy(t.dialogShowMask,this)(i),this},getToolbarHandles:function(e){var i=this.toolbarHandlers=t.toolbarHandlers;return e&&void 0!==toolbarIconHandlers[e]?i[e]:i},setToolbarHandler:function(){var t=this,i=this.settings;if(!i.toolbar||i.readOnly)return this;var o=this.toolbar,r=this.cm,a=this.classPrefix,n=this.toolbarIcons=o.find("."+a+"menu > li > a"),s=this.getToolbarHandles();return n.bind("click",function(){var o=e(this).children(".fa"),a=o.attr("name"),n=r.getCursor(),l=r.getSelection();if(""!==a)return t.activeIcon=o,void 0!==s[a]?e.proxy(s[a],t)(r):void 0!==i.toolbarHandlers[a]&&e.proxy(i.toolbarHandlers[a],t)(r,o,n,l),"link"!==a&&"reference-link"!==a&&"image"!==a&&"code-block"!==a&&"preformatted-text"!==a&&"watch"!==a&&"preview"!==a&&"search"!==a&&"fullscreen"!==a&&"info"!==a&&r.focus(),!1}),this},createDialog:function(i){return e.proxy(t.createDialog,this)(i)},createInfoDialog:function(){var e=this,i=this.editor,o=this.classPrefix,r=['
          ','
          ','

          '+t.title+"v"+t.version+"

          ","

          "+this.lang.description+"

          ",'

          '+t.homePage+'

          ','

          Copyright © 2015-'+t.dateFormat("yyyy")+' Pandao, The MIT License.

          ',"
          ",'',"
          "].join("\n");i.append(r);var a=this.infoDialog=i.children("."+o+"dialog-info");return a.find("."+o+"dialog-close").bind("click",function(){e.hideInfoDialog()}),a.css("border",t.isIE8?"1px solid #ddd":"").css("z-index",t.dialogZindex).show(),this.infoDialogPosition(),this},infoDialogPosition:function(){var t=this.infoDialog,i=function(){t.css({top:(e(window).height()-t.height())/2+"px",left:(e(window).width()-t.width())/2+"px"})};return i(),e(window).resize(i),this},showInfoDialog:function(){e("html,body").css("overflow-x","hidden");var i=this.editor,o=this.settings,r=this.infoDialog=i.children("."+this.classPrefix+"dialog-info");return r.length<1&&this.createInfoDialog(),this.lockScreen(!0),this.mask.css({opacity:o.dialogMaskOpacity,backgroundColor:o.dialogMaskBgColor}).show(),r.css("z-index",t.dialogZindex).show(),this.infoDialogPosition(),this},hideInfoDialog:function(){return e("html,body").css("overflow-x",""),this.infoDialog.hide(),this.mask.hide(),this.lockScreen(!1),this},lockScreen:function(e){return t.lockScreen(e),this.resize(),this},recreate:function(){var e=this.editor,t=this.settings;return this.codeMirror.remove(),this.setCodeMirror(),t.readOnly||(e.find(".editormd-dialog").length>0&&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"),void 0!==window.prettyPrint&&window.prettyPrint()),this},katexRender:function(){return null===i?this:(this.previewContainer.find("."+t.classNames.tex).each(function(){var i=e(this);t.$katex.render(i.text(),i[0]),i.find(".katex").css("font-size","1.6em")}),this)},flowChartAndSequenceDiagramRender:function(){var i=this,r=this.settings,a=this.previewContainer;if(t.isIE8)return this;if(r.flowChart){if(null===o)return this;a.find(".flowchart").flowChart()}r.sequenceDiagram&&a.find(".sequence-diagram").sequenceDiagram({theme:"simple"});var n=i.preview,s=i.codeMirror,l=s.find(".CodeMirror-scroll"),c=l.height(),h=l.scrollTop(),d=h/l[0].scrollHeight,u=0;n.find(".markdown-toc-list").each(function(){u+=e(this).height()});var f=n.find(".editormd-toc-menu").height();return f=f||0,0===h?n.scrollTop(0):h+c>=l[0].scrollHeight-16?n.scrollTop(n[0].scrollHeight):n.scrollTop((n[0].scrollHeight+u+f)*d),this},registerKeyMaps:function(i){var o=this,r=this.cm,a=this.settings,n=t.toolbarHandlers,s=a.disabledKeyMaps;if(i=i||null){for(var l in i)if(e.inArray(l,s)<0){var c={};c[l]=i[l],r.addKeyMap(i)}}else{for(var h in t.keyMaps){var d=t.keyMaps[h],u="string"==typeof d?e.proxy(n[d],o):e.proxy(d,o);if(e.inArray(h,["F9","F10","F11"])<0&&e.inArray(h,s)<0){var f={};f[h]=u,r.addKeyMap(f)}}e(window).keydown(function(t){var i={120:"F9",121:"F10",122:"F11"};if(e.inArray(i[t.keyCode],s)<0)switch(t.keyCode){case 120:e.proxy(n.watch,o)(),t.stopPropagation();break;case 121:e.proxy(n.preview,o)(),t.stopPropagation();break;case 122:e.proxy(n.fullscreen,o)(),t.stopPropagation()}})}return this},bindScrollEvent:function(){var i=this,o=this.preview,r=this.settings,a=this.codeMirror,n=t.mouseOrTouch;if(!r.syncScrolling)return this;var s=function(){a.find(".CodeMirror-scroll").bind(n("scroll","touchmove"),function(t){var a=e(this).height(),n=e(this).scrollTop(),s=n/e(this)[0].scrollHeight,l=0;o.find(".markdown-toc-list").each(function(){l+=e(this).height()});var c=o.find(".editormd-toc-menu").height();c=c||0,0===n?o.scrollTop(0):n+a>=e(this)[0].scrollHeight-16?o.scrollTop(o[0].scrollHeight):o.scrollTop((o[0].scrollHeight+l+c)*s),e.proxy(r.onscroll,i)(t)})},l=function(){a.find(".CodeMirror-scroll").unbind(n("scroll","touchmove"))},c=function(){o.bind(n("scroll","touchmove"),function(t){var o=e(this).height(),n=e(this).scrollTop(),s=n/e(this)[0].scrollHeight,l=a.find(".CodeMirror-scroll");0===n?l.scrollTop(0):n+o>=e(this)[0].scrollHeight?l.scrollTop(l[0].scrollHeight):l.scrollTop(l[0].scrollHeight*s),e.proxy(r.onpreviewscroll,i)(t)})},h=function(){o.unbind(n("scroll","touchmove"))};return a.bind({mouseover:s,mouseout:l,touchstart:s,touchend:l}),"single"===r.syncScrolling?this:(o.bind({mouseover:c,mouseout:h,touchstart:c,touchend:h}),this)},bindChangeEvent:function(){var e=this,t=this.cm,o=this.settings;return o.syncScrolling?(t.on("change",function(){o.watch&&e.previewContainer.css("padding",o.autoHeight?"20px 20px 50px 40px":"20px"),i=setTimeout(function(){clearTimeout(i),e.save(),i=null},o.delay)}),this):this},loadedDisplay:function(t){t=t||!1;var i=this,o=this.editor,r=this.preview,a=this.settings;return this.containerMask.hide(),this.save(),a.watch&&r.show(),o.data("oldWidth",o.width()).data("oldHeight",o.height()),this.resize(),this.registerKeyMaps(),e(window).resize(function(){i.resize()}),this.bindScrollEvent().bindChangeEvent(),t||e.proxy(a.onload,this)(),this.state.loaded=!0,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(t,i){t=t||null,i=i||null;var o=this.state,r=this.editor,a=this.preview,n=this.toolbar,s=this.settings,l=this.codeMirror;if(t&&r.css("width","number"==typeof t?t+"px":t),!s.autoHeight||o.fullscreen||o.preview?(i&&r.css("height","number"==typeof i?i+"px":i),o.fullscreen&&r.height(e(window).height()),s.toolbar&&!s.readOnly?l.css("margin-top",n.height()+1).height(r.height()-n.height()):l.css("margin-top",0).height(r.height())):(r.css("height","auto"),l.css("height","auto")),s.watch)if(l.width(r.width()/2-1),a.width(o.preview?r.width():r.width()/2),this.previewContainer.css("padding",s.autoHeight?"20px 20px 50px 40px":"20px"),s.toolbar&&!s.readOnly?a.css("top",n.height()+1):a.css("top",0),!s.autoHeight||o.fullscreen||o.preview){var c=s.toolbar&&!s.readOnly?r.height()-n.height():r.height();a.height(c)}else a.height("");else l.width(r.width()),a.hide();return o.loaded&&e.proxy(s.onresize,this)(),this},save:function(){if(null===i)return this;var r=this,a=this.state,n=this.settings,s=this.cm,l=s.getValue(),c=this.previewContainer;if("gfm"!==n.mode&&"markdown"!==n.mode)return this.markdownTextarea.val(l),this;var h=t.$marked,d=this.markdownToC=[],u=this.markedRendererOptions={toc:n.toc,tocm:n.tocm,tocStartLevel:n.tocStartLevel,pageBreak:n.pageBreak,taskList:n.taskList,emoji:n.emoji,tex:n.tex,atLink:n.atLink,emailLink:n.emailLink,flowChart:n.flowChart,sequenceDiagram:n.sequenceDiagram,previewCodeHighlight:n.previewCodeHighlight},f=this.markedOptions={renderer:t.markedRenderer(d,u),gfm:!0,tables:!0,breaks:!0,pedantic:!1,sanitize:!n.htmlDecode,smartLists:!0,smartypants:!0};h.setOptions(f);var g=t.$marked(l,f);if(g=t.filterHTMLTags(g,n.htmlDecode),this.markdownTextarea.text(l),s.save(),n.saveHTMLToTextarea&&this.htmlTextarea.text(g),n.watch||!n.watch&&a.preview){if(c.html(g),c.find(".task-list-item").each(function(){e(this).parent().addClass("task-list")}),this.previewCodeHighlight(),n.toc){var p=""===n.tocContainer?c:e(n.tocContainer),m=p.find("."+this.classPrefix+"toc-menu");p.attr("previewContainer",""===n.tocContainer?"true":"false"),""!==n.tocContainer&&m.length>0&&m.remove(),t.markdownToCRenderer(d,p,n.tocDropdown,n.tocStartLevel),(n.tocDropdown||p.find("."+this.classPrefix+"toc-menu").length>0)&&t.tocDropdownMenu(p,""!==n.tocTitle?n.tocTitle:this.lang.tocTitle),""!==n.tocContainer&&c.find(".markdown-toc").css("border","none")}n.tex&&(!t.kaTeXLoaded&&n.autoLoadModules?t.loadKaTeX(function(){t.$katex=katex,t.kaTeXLoaded=!0,r.katexRender()}):(t.$katex=katex,this.katexRender())),(n.flowChart||n.sequenceDiagram)&&(o=setTimeout(function(){clearTimeout(o),r.flowChartAndSequenceDiagramRender(),o=null},10)),a.loaded&&e.proxy(n.onchange,this)()}return 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){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(t){var o=this.settings;if(e.inArray(o.mode,["gfm","markdown"])<0)return this;if(this.state.watching=o.watch=!0,this.preview.show(),this.toolbar){var r=o.toolbarIconsClass.watch,a=o.toolbarIconsClass.unwatch,n=this.toolbar.find(".fa[name=watch]");n.parent().attr("title",o.lang.toolbar.watch),n.removeClass(a).addClass(r)}return this.codeMirror.css("border-right","1px solid #ddd").width(this.editor.width()/2),i=0,this.save().resize(),o.onwatch||(o.onwatch=t||function(){}),e.proxy(o.onwatch,this)(),this},unwatch:function(t){var i=this.settings;if(this.state.watching=i.watch=!1,this.preview.hide(),this.toolbar){var o=i.toolbarIconsClass.watch,r=i.toolbarIconsClass.unwatch,a=this.toolbar.find(".fa[name=watch]");a.parent().attr("title",i.lang.toolbar.unwatch),a.removeClass(o).addClass(r)}return this.codeMirror.css("border-right","none").width(this.editor.width()),this.resize(),i.onunwatch||(i.onunwatch=t||function(){}),e.proxy(i.onunwatch,this)(),this},show:function(t){t=t||function(){};var i=this;return this.editor.show(0,function(){e.proxy(t,i)()}),this},hide:function(t){t=t||function(){};var i=this;return this.editor.hide(0,function(){e.proxy(t,i)()}),this},destroy:function(){this.hide(),this.editor.remove()},previewing:function(){var t=this,i=this.editor,o=this.preview,r=this.toolbar,a=this.settings,n=this.codeMirror,s=this.previewContainer;if(e.inArray(a.mode,["gfm","markdown"])<0)return this;var l=this.editor.outerHeight();a.toolbar&&r&&(r.toggle(),r.find(".fa[name=preview]").toggleClass("active")),n.toggle();var c=function(e){e.shiftKey&&27===e.keyCode&&t.previewed()};"none"===n.css("display")?(this.state.preview=!0,this.settings.autoHeight&&this.editor.css("height",l),this.state.fullscreen&&o.css("background","#fff"),i.find("."+this.classPrefix+"preview-close-btn").show().bind("click",function(){t.previewed()}),a.watch?s.css("padding",""):this.save(),s.addClass(this.classPrefix+"preview-active"),o.show().css({position:"",top:0,width:i.width(),height:a.autoHeight&&!this.state.fullscreen?"auto":i.height()}),this.state.loaded&&e.proxy(a.onpreviewing,this)(),e(window).bind("keyup",c)):(e(window).unbind("keyup",c),this.previewed())},previewed:function(){var t=this.editor,i=this.preview,o=this.toolbar,r=this.settings,a=this.previewContainer,n=t.find("."+this.classPrefix+"preview-close-btn");return this.state.preview=!1,this.codeMirror.show(),r.toolbar&&o.show(),i[r.watch?"show":"hide"](),n.hide().unbind("click"),a.removeClass(this.classPrefix+"preview-active"),r.watch&&a.css("padding","20px"),this.settings.autoHeight&&this.editor.css("height","auto"),i.css({background:null,position:"absolute",width:t.width()/2,height:r.autoHeight&&!this.state.fullscreen?"auto":t.height()-o.height(),top:r.toolbar?o.height():0}),this.state.loaded&&e.proxy(r.onpreviewed,this)(),this},fullscreen:function(){var t=this,i=this.state,o=this.editor,r=this.toolbar,a=this.settings,n=this.classPrefix+"fullscreen";r&&r.find(".fa[name=fullscreen]").parent().toggleClass("active");var s=function(e){e.shiftKey||27!==e.keyCode||i.fullscreen&&t.fullscreenExit()};return o.hasClass(n)?(e(window).unbind("keyup",s),this.fullscreenExit()):(i.fullscreen=!0,e("html,body").css("overflow","hidden"),o.css({width:e(window).width(),height:e(window).height()}).addClass(n),this.resize(),e.proxy(a.onfullscreen,this)(),e(window).bind("keyup",s)),this},fullscreenExit:function(){var t=this.editor,i=this.settings,o=this.toolbar,r=this.classPrefix+"fullscreen";return this.state.fullscreen=!1,o&&o.find(".fa[name=fullscreen]").parent().removeClass("active"),e("html,body").css("overflow",""),t.css({width:t.data("oldWidth"),height:t.data("oldHeight")}).removeClass(r),this.resize(),e.proxy(i.onfullscreenExit,this)(),this},executePlugin:function(i,o){var r=this,a=this.cm;return o=this.settings.pluginPath+o,"function"==typeof define?void 0===this[i]?(alert("Error: "+i+" plugin is not found, you are not load this plugin."),this):(this[i](a),this):(e.inArray(o,t.loadFiles.plugin)<0?t.loadPlugin(o,function(){t.loadPlugins[i]=r[i],r[i](a)}):e.proxy(t.loadPlugins[i],this)(a),this)},search:function(e){var t=this.settings;return t.searchReplace?(t.readOnly||this.cm.execCommand(e||"find"),this):(alert("Error: settings.searchReplace == false"),this)},searchReplace:function(){return this.search("replace"),this},searchReplaceAll:function(){return this.search("replaceAll"),this}},t.fn.init.prototype=t.fn,t.dialogLockScreen=function(){(this.settings||{dialogLockScreen:!0}).dialogLockScreen&&(e("html,body").css("overflow","hidden"),this.resize())},t.dialogShowMask=function(t){var i=this.editor,o=this.settings||{dialogShowMask:!0};t.css({top:(e(window).height()-t.height())/2+"px",left:(e(window).width()-t.width())/2+"px"}),o.dialogShowMask&&i.children("."+this.classPrefix+"mask").css("z-index",parseInt(t.css("z-index"))-1).show()},t.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,i=e.getSelection(),o=e.listSelections();e.replaceSelection(t.firstUpperCase(i)),e.setSelections(o)},ucwords:function(){var e=this.cm,i=e.getSelection(),o=e.listSelections();e.replaceSelection(t.wordsFirstUpperCase(i)),e.setSelections(o)},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.getSelection(),i=e.listSelections();e.replaceSelection(t.toLowerCase()),e.setSelections(i)},h1: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)},h2: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+3)):e.replaceSelection("## "+i)},h3: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+4)):e.replaceSelection("### "+i)},h4: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+5)):e.replaceSelection("#### "+i)},h5: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+6)):e.replaceSelection("##### "+i)},h6: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+7)):e.replaceSelection("###### "+i)},"list-ul":function(){var e=this.cm,t=e.getSelection();if(""===t)e.replaceSelection("- "+t);else{for(var i=t.split("\n"),o=0,r=i.length;o'}else{var s=e.match(m),l=e.match(g);if(s)for(var c=0,h=s.length;c'}else{if(!l){var u="+1"===o?"plus1":o;return u="black_large_square"===u?"black_square":u,u="moon"===u?"waxing_gibbous_moon":u,':'+o+':'}for(var f=0,w=l.length;f'}}}});return e},l.atLink=function(i){return h.test(i)?(n.atLink&&(i=i.replace(u,function(e,t,i,o){return e.replace(/@/g,"_#_@_#_")}),i=i.replace(h,function(e,i){return''+e+""}).replace(/_#_@_#_/g,"@")),n.emailLink&&(i=i.replace(f,function(t,i,o,r,a){return!i&&e.inArray(a,"jpg|jpeg|png|gif|webp|ico|icon|pdf".split("|"))<0?''+t+"":t})),i):i},l.link=function(e,t,i){if(this.options.sanitize)try{if(0===decodeURIComponent(unescape(e)).replace(/[^\w:]/g,"").toLowerCase().indexOf("javascript:"))return""}catch(e){return""}var o=''+i.replace(/@/g,"@")+""):(t&&(o+=' title="'+t+'"'),o+=">"+i+"")},l.heading=function(e,t){var o=e,a=/\s*\]*)\>(.*)\<\/a\>\s*/;if(a.test(e)){var n=[];e=e.split(/\]+)\>([^\>]*)\<\/a\>/);for(var s=0,l=e.length;s';return f+='',f+='',f+=a?this.atLink(this.emoji(o)):this.atLink(this.emoji(e)),f+=""},l.pageBreak=function(e){return w.test(e)&&n.pageBreak&&(e='
          '),e},l.paragraph=function(e){var i=/\$\$(.*)\$\$/g.test(e),o=/^\$\$(.*)\$\$$/.test(e),r=o?' class="'+t.classNames.tex+'"':"",a=n.tocm?/^(\[TOC\]|\[TOCM\])$/.test(e):/^\[TOC\]$/.test(e),s=/^\[TOCM\]$/.test(e);e=!o&&i?e.replace(/(\$\$([^\$]*)\$\$)+/g,function(e,i){return''+i.replace(/\$/g,"")+""}):o?e.replace(/\$/g,""):e;var l='
          '+e+"
          ";return a?s?'
          '+l+"

          ":l:w.test(e)?this.pageBreak(e):""+this.atLink(this.emoji(e))+"

          \n"},l.code=function(e,i){return"seq"===i||"sequence"===i?'
          '+e+"
          ":"flow"===i?'
          '+e+"
          ":"math"===i||"latex"===i||"katex"===i?'

          '+e+"

          ":s.Renderer.prototype.code.apply(this,arguments)},l.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))+"\n"},l.listitem=function(e,t){return n.taskList&&t?(e=e.replace("'+this.atLink(this.emoji(e))+""):"
        • "+this.atLink(this.emoji(e))+"
        • "},l},t.markdownToCRenderer=function(e,t,i,o){var r="",a=0,n=this.classPrefix;o=o||1;for(var s=0,l=e.length;sa?"":h"):"
      • ",r+='
      • '+c+"
          ",a=h)}var d=t.find(".markdown-toc");if(d.length<1&&"false"===t.attr("previewContainer")){var u='
          ';u=i?'
          '+u+"
          ":u,t.html(u),d=t.find(".markdown-toc")}return i&&d.wrap('

          '),d.html('
            ').children(".markdown-toc-list").html(r.replace(/\r?\n?\\<\/ul\>/g,"")),d},t.tocDropdownMenu=function(t,i){i=i||"Table of Contents";var o=400,r=t.find("."+this.classPrefix+"toc-menu");return r.each(function(){var t=e(this),r=t.children(".markdown-toc"),a='',n=''+a+i+"",s=r.children("ul"),l=s.find("li");r.append(n),l.first().before("
          • "+i+" "+a+"

          • "),t.mouseover(function(){s.show(),l.each(function(){var t=e(this),i=t.children("ul");if(""===i.html()&&i.remove(),i.length>0&&""!==i.html()){var r=t.children("a").first();r.children(".fa").length<1&&r.append(e(a).css({float:"right",paddingTop:"4px"}))}t.mouseover(function(){i.css("z-index",o).show(),o+=1}).mouseleave(function(){i.hide()})})}).mouseleave(function(){s.hide()})}),r},t.filterHTMLTags=function(t,i){if("string"!=typeof t&&(t=t.toString()),"string"!=typeof i)return t;for(var o=i.split("|"),r=o[0].split(","),a=o[1],n=0,s=r.length;n]*)>([^>]*)","igm"),"")}if(void 0!==a){var c=/\<(\w+)\s*([^\>]*)\>([^\>]*)\<\/(\w+)\>/gi;t="*"===a?t.replace(c,function(e,t,i,o,r){return"<"+t+">"+o+""}):"on*"===a?t.replace(c,function(t,i,o,r,a){var n=e("<"+i+">"+r+""),s=e(t)[0].attributes,l={};e.each(s,function(e,t){'"'!==t.nodeName&&(l[t.nodeName]=t.nodeValue)}),e.each(l,function(e){0===e.indexOf("on")&&delete l[e]}),n.attr(l);var c=void 0!==n[1]?e(n[1]).text():"";return n[0].outerHTML+c}):t.replace(c,function(t,i,o,r){var n=a.split(","),s=e(t);return s.html(r),e.each(n,function(e){s.attr(n[e],null)}),s[0].outerHTML})}return t},t.markdownToHTML=function(i,o){var r={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};t.$marked=marked;var a=e("#"+i),n=a.settings=e.extend(!0,{},r,o||{}),s=a.find("textarea");s.length<1&&(a.append(""),s=a.find("textarea"));var l=""===n.markdown?s.val():n.markdown,c=[],h={toc:n.toc,tocm:n.tocm,tocStartLevel:n.tocStartLevel,taskList:n.taskList,emoji:n.emoji,tex:n.tex,pageBreak:n.pageBreak,atLink:n.atLink,emailLink:n.emailLink,flowChart:n.flowChart,sequenceDiagram:n.sequenceDiagram,previewCodeHighlight:n.previewCodeHighlight},d={renderer:t.markedRenderer(c,h),gfm:n.gfm,tables:!0,breaks:!0,pedantic:!1,sanitize:!n.htmlDecode,smartLists:!0,smartypants:!0};l=l.toString();var u=marked(l,d);u=t.filterHTMLTags(u,n.htmlDecode),n.markdownSourceCode?s.text(l):s.remove(),a.addClass("markdown-body "+this.classPrefix+"html-preview").append(u),a.find(".task-list-item").each(function(){e(this).parent().addClass("task-list")});var f=""!==n.tocContainer?e(n.tocContainer):a;if(""!==n.tocContainer&&f.attr("previewContainer",!1),n.toc&&(a.tocContainer=this.markdownToCRenderer(c,f,n.tocDropdown,n.tocStartLevel),(n.tocDropdown||a.find("."+this.classPrefix+"toc-menu").length>0)&&this.tocDropdownMenu(a,n.tocTitle),""!==n.tocContainer&&a.find(".editormd-toc-menu, .editormd-markdown-toc").remove()),n.previewCodeHighlight&&(a.find("pre").addClass("prettyprint linenums"),window.prettyPrint()),t.isIE8||(n.flowChart&&a.find(".flowchart").flowChart(),n.sequenceDiagram&&a.find(".sequence-diagram").sequenceDiagram({theme:"simple"})),n.tex){var g=function(){a.find("."+t.classNames.tex).each(function(){var t=e(this);katex.render(t.html().replace(/</g,"<").replace(/>/g,">"),t[0]),t.find(".katex").css("font-size","1.6em")})};!n.autoLoadKaTeX||t.$katex||t.kaTeXLoaded?g():this.loadKaTeX(function(){t.$katex=katex,t.kaTeXLoaded=!0,g()})}return a.getMarkdown=function(){return s.val()},a},t.themes=["default","dark"],t.previewThemes=["default","dark"],t.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"],t.loadPlugins={},t.loadFiles={js:[],css:[],plugin:[]},t.loadPlugin=function(e,i,o){i=i||function(){},this.loadScript(e,function(){t.loadFiles.plugin.push(e),i()},o)},t.loadCSS=function(e,i,o){o=o||"head",i=i||function(){};var r=document.createElement("link");r.type="text/css",r.rel="stylesheet",r.onload=r.onreadystatechange=function(){t.loadFiles.css.push(e),i()},r.href=e+".css","head"===o?document.getElementsByTagName("head")[0].appendChild(r):document.body.appendChild(r)},t.isIE="Microsoft Internet Explorer"===navigator.appName,t.isIE8=t.isIE&&"8."===navigator.appVersion.match(/8./i),t.loadScript=function(e,i,o){o=o||"head",i=i||function(){};var r=null;r=document.createElement("script"),r.id=e.replace(/[\.\/]+/g,"-"),r.type="text/javascript",r.src=e+".js",t.isIE8?r.onreadystatechange=function(){r.readyState&&("loaded"!==r.readyState&&"complete"!==r.readyState||(r.onreadystatechange=null,t.loadFiles.js.push(e),i()))}:r.onload=function(){t.loadFiles.js.push(e),i()},"head"===o?document.getElementsByTagName("head")[0].appendChild(r):document.body.appendChild(r)},t.katexURL={css:"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.1/katex.min",js:"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.1/katex.min"},t.kaTeXLoaded=!1,t.loadKaTeX=function(e){t.loadCSS(t.katexURL.css,function(){t.loadScript(t.katexURL.js,e||function(){})})},t.lockScreen=function(t){e("html,body").css("overflow",t?"hidden":"")},t.createDialog=function(i){var o={name:"",width:420,height:240,title:"",drag:!0,closed:!0,cached:!1,content:"",mask:!0,maskStyle:{backgroundColor:"#fff",opacity:.1},lockScreen:!0,footer:!0,buttons:!1};i=e.extend(!0,o,i);var r=this,a=this.editor,n=t.classPrefix,s=(new Date).getTime(),l=""===i.name?n+"dialog-"+s:i.name,c='
            ';""!==i.title&&(c+='
            ",c+=''+i.title+"",c+="
            "),i.closed&&(c+=''),c+='
            '+i.content,(i.footer||"string"==typeof i.footer)&&(c+='"),c+="
            ",c+='
            ',c+='
            ',c+="
            ",a.append(c);var h=a.find("."+l);h.lockScreen=function(t){return i.lockScreen&&(e("html,body").css("overflow",t?"hidden":""),r.resize()),h},h.showMask=function(){return i.mask&&a.find("."+n+"mask").css(i.maskStyle).css("z-index",t.dialogZindex-1).show(),h},h.hideMask=function(){return i.mask&&a.find("."+n+"mask").hide(),h},h.loading=function(e){return h.find("."+n+"dialog-mask")[e?"show":"hide"](),h},h.lockScreen(!0).showMask(),h.show().css({zIndex:t.dialogZindex,border:t.isIE8?"1px solid #ddd":"",width:"number"==typeof i.width?i.width+"px":i.width,height:"number"==typeof i.height?i.height+"px":i.height});var d=function(){h.css({top:(e(window).height()-h.height())/2+"px",left:(e(window).width()-h.width())/2+"px"})};if(d(),e(window).resize(d),h.children("."+n+"dialog-close").bind("click",function(){h.hide().lockScreen(!1).hideMask(),i.cached||h.remove()}),"object"==typeof i.buttons){var u=h.footer=h.find("."+n+"dialog-footer");for(var f in i.buttons){var g=i.buttons[f],p=n+f+"-btn";u.append('"),g[1]=e.proxy(g[1],h),u.children("."+p).bind("click",g[1])}}if(""!==i.title&&i.drag){var m,w,v=h.children("."+n+"dialog-header");i.mask||v.bind("click",function(){t.dialogZindex+=2,h.css("z-index",t.dialogZindex)});var k=function(e){e.removeClass(n+"user-unselect").off("selectstart")},b=function(e){e.addClass(n+"user-unselect").on("selectstart",function(){return!1})},x=function(t){t=t||window.event;var i,o,r=parseInt(h[0].style.left),a=parseInt(h[0].style.top);r>=0?r+h.width()<=e(window).width()?i=t.clientX-m:(i=e(window).width()-h.width(),document.onmousemove=null):(i=0,document.onmousemove=null),a>=0?o=t.clientY-w:(o=0,document.onmousemove=null),document.onselectstart=function(){return!1},b(e("body")),b(h),h[0].style.left=i+"px",h[0].style.top=o+"px"};v.mousedown(function(e){e=e||window.event,m=e.clientX-parseInt(h[0].style.left),w=e.clientY-parseInt(h[0].style.top),document.onmousemove=x}),document.onmouseup=function(){k(e("body")),k(h),document.onselectstart=null,document.onmousemove=null},v.touchDraggable=function(){var t=null,i=function(i){var o=i.originalEvent,r=e(this).parent().position();t={x:o.changedTouches[0].pageX-r.left,y:o.changedTouches[0].pageY-r.top}},o=function(i){i.preventDefault();var o=i.originalEvent;e(this).parent().css({top:o.changedTouches[0].pageY-t.y,left:o.changedTouches[0].pageX-t.x})};this.bind("touchstart",i).bind("touchmove",o)},v.touchDraggable()}return t.dialogZindex+=2,h},t.mouseOrTouch=function(e,t){e=e||"click",t=t||"touchend";var i=e;try{document.createEvent("TouchEvent"),i=t}catch(e){}return i},t.dateFormat=function(e){e=e||"";var t=function(e){return e<10?"0"+e:e},i=new Date,o=i.getFullYear(),r=o.toString().slice(2,4),a=t(i.getMonth()+1),n=t(i.getDate()),s=i.getDay(),l=t(i.getHours()),c=t(i.getMinutes()),h=t(i.getSeconds()),d=t(i.getMilliseconds()),u="",f=r+"-"+a+"-"+n,g=o+"-"+a+"-"+n,p=l+":"+c+":"+h;switch(e){case"UNIX Time":u=i.getTime();break;case"UTC":u=i.toUTCString();break;case"yy":u=r;break;case"year":case"yyyy":u=o;break;case"month":case"mm":u=a;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=n;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=g;break;case"yyyy-mm-dd h:i:s ms":case"full + ms":u=g+" "+p+" "+d;break;case"full":case"yyyy-mm-dd h:i:s":default:u=g+" "+p}return u},t}}); \ No newline at end of file diff --git a/editormd.js b/editormd.js index 6905134..8e5e289 100644 --- a/editormd.js +++ b/editormd.js @@ -2035,6 +2035,10 @@ { previewContainer.html(newMarkdownDoc); + previewContainer.find(".task-list-item").each(function () { + $(this).parent().addClass("task-list"); + }); + this.previewCodeHighlight(); if (settings.toc) @@ -3653,16 +3657,12 @@ return tag + this.atLink(this.emoji(content)) + "\n"; }; - markedRenderer.listitem = function(text) { - if (settings.taskList && /^\s*\[[x\s]\]\s*/.test(text)) - { - text = text.replace(/^\s*\[\s\]\s*/, " ") - .replace(/^\s*\[x\]\s*/, " "); + markedRenderer.listitem = function(text, task) { + if (settings.taskList && task) { + text = text.replace("" + this.atLink(this.emoji(text)) + ""; - } - else - { + return "
          • " + this.atLink(this.emoji(text)) + "
          • "; + } else { return "
          • " + this.atLink(this.emoji(text)) + "
          • "; } }; @@ -3978,6 +3978,10 @@ } div.addClass("markdown-body " + this.classPrefix + "html-preview").append(markdownParsed); + + div.find(".task-list-item").each(function () { + $(this).parent().addClass("task-list"); + }); var tocContainer = (settings.tocContainer !== "") ? $(settings.tocContainer) : div; diff --git a/editormd.min.js b/editormd.min.js index 064e656..ee07595 100644 --- a/editormd.min.js +++ b/editormd.min.js @@ -1,2 +1,2 @@ /*! Editor.md v1.5.1 | editormd.min.js | Open source online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2019-05-11 */ -!function(e){"use strict";"function"==typeof require&&"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define?define.amd||define(["jquery"],e):window.editormd=e()}(function(){"use strict";var e=void 0!==window.jQuery?window.jQuery:window.Zepto;if(void 0!==e){var t=function(e,i){return new t.fn.init(e,i)};t.title=t.$name="Editor.md",t.version="1.5.1",t.homePage="https://pandao.github.io/editor.md/",t.classPrefix="editormd-",t.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","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","info"],mini:["undo","redo","|","watch","preview","|","help","info"]},t.defaults={mode:"gfm",name:"",value:"",theme:"",editorTheme:"default",previewTheme:"",markdown:"",appendMarkdown:"",width:"100%",height:"100%",path:"./lib/",pluginPath:"",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:!1,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(){},onpreviewed:function(){},onfullscreen:function(){},onfullscreenExit:function(){},onscroll:function(){},onpreviewscroll:function(){},imageUpload:!1,imageFormats:["jpg","jpeg","gif","png","bmp","webp"],imageUploadURL:"",imageUploadFields:"",imageUploadCallback:function(){},imageUploadCallbackName:"__Editor_md_ImageUploadCallback",crossDomainUpload:!1,uploadCallbackURL:"",toc:!0,tocm:!1,tocTitle:"",tocDropdown:!1,tocContainer:"",tocStartLevel:1,htmlDecode:!1,pageBreak:!0,atLink:!0,emailLink:!0,taskList:!1,emoji:!1,tex:!1,flowChart:!1,sequenceDiagram:!1,previewCodeHighlight:!0,toolbar:!0,toolbarAutoFixed:!0,toolbarIcons:"full",toolbarTitles:{},toolbarHandlers:{ucwords:function(){return t.toolbarHandlers.ucwords},lowercase:function(){return t.toolbarHandlers.lowercase}},toolbarCustomIcons:{lowercase:'a',ucwords:'Aa'},toolbarIconsClass:{undo:"fa-undo",redo:"fa-repeat",bold:"fa-bold",del:"fa-strikethrough",italic:"fa-italic",quote:"fa-quote-left",uppercase:"fa-font",h1:t.classPrefix+"bold",h2:t.classPrefix+"bold",h3:t.classPrefix+"bold",h4:t.classPrefix+"bold",h5:t.classPrefix+"bold",h6:t.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",info:"fa-info-circle"},toolbarIconTexts:{},lang:{name:"zh-cn",description:"开源在线 Markdown 编辑器
            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:"使用帮助",info:"关于"+t.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:"错误:请填写预格式文本或代码的内容。",placeholder:"Coding now...."},codeBlock:{title:"添加代码块",selectLabel:"代码语言:",selectDefaultText:"请选择代码语言",otherLanguage:"其他语言",unselectedLanguageAlert:"错误:请选择代码所属的语言类型。",codeEmptyAlert:"错误:请填写代码内容。",placeholder:"Coding now...."},htmlEntities:{title:"HTML 实体字符"},help:{title:"使用帮助"}}}},t.classNames={tex:t.classPrefix+"tex"},t.dialogZindex=99999,t.$katex=null,t.$marked=null,t.$CodeMirror=null,t.$prettyPrint=null;var i,o;t.prototype=t.fn={state:{watching:!1,loaded:!1,preview:!1,fullscreen:!1},init:function(i,o){o=o||{},"object"==typeof i&&(o=i);var r=this.classPrefix=t.classPrefix,a=e.extend(!0,{},t.defaults,o);o.imageFormats&&(a.imageFormats=o.imageFormats),this.settings=a,i="object"==typeof i?a.id:i;var n=this.editor=e("#"+i);this.id=i,this.lang=a.lang;var s=this.classNames={textarea:{html:r+"html-textarea",markdown:r+"markdown-textarea"}};a.pluginPath=""===a.pluginPath?a.path+"../plugins/":a.pluginPath,this.state.watching=!!a.watch,n.hasClass("editormd")||n.addClass("editormd"),n.css({width:"number"==typeof a.width?a.width+"px":a.width,height:"number"==typeof a.height?a.height+"px":a.height}),a.autoHeight&&n.css("height","auto");var l=this.markdownTextarea=n.children("textarea");l.length<1&&(n.append(""),l=this.markdownTextarea=n.children("textarea")),l.addClass(s.textarea.markdown).attr("placeholder",a.placeholder),void 0!==l.attr("name")&&""!==l.attr("name")||l.attr("name",""!==a.name?a.name:i+"-markdown-doc");var c=[a.readOnly?"":'',a.saveHTMLToTextarea?'':"",'
            ','
            ','
            '].join("\n");return n.append(c).addClass(r+"vertical"),""!==a.theme&&n.addClass(r+"theme-"+a.theme),this.mask=n.children("."+r+"mask"),this.containerMask=n.children("."+r+"container-mask"),""!==a.markdown&&l.val(a.markdown),""!==a.appendMarkdown&&l.val(l.val()+a.appendMarkdown),this.htmlTextarea=n.children("."+s.textarea.html),this.preview=n.children("."+r+"preview"),this.previewContainer=this.preview.children("."+r+"preview-container"),""!==a.previewTheme&&this.preview.addClass(r+"preview-theme-"+a.previewTheme),"function"==typeof define&&define.amd&&(void 0!==window.katex&&(t.$katex=window.katex),a.searchReplace&&!a.readOnly&&(t.loadCSS(a.path+"codemirror/addon/dialog/dialog"),t.loadCSS(a.path+"codemirror/addon/search/matchesonscrollbar"))),"function"==typeof define&&define.amd||!a.autoLoadModules?(void 0!==window.CodeMirror&&(t.$CodeMirror=window.CodeMirror),void 0!==window.marked&&(t.$marked=window.marked),this.setCodeMirror().setToolbar().loadedDisplay()):this.loadQueues(),this},loadQueues:function(){var e=this,i=this.settings,o=i.path,r=function(){if(t.isIE8)return void e.loadedDisplay();i.flowChart||i.sequenceDiagram?t.loadScript(o+"raphael.min",function(){t.loadScript(o+"underscore.min",function(){!i.flowChart&&i.sequenceDiagram?t.loadScript(o+"sequence-diagram.min",function(){e.loadedDisplay()}):i.flowChart&&!i.sequenceDiagram?t.loadScript(o+"flowchart.min",function(){t.loadScript(o+"jquery.flowchart.min",function(){e.loadedDisplay()})}):i.flowChart&&i.sequenceDiagram&&t.loadScript(o+"flowchart.min",function(){t.loadScript(o+"jquery.flowchart.min",function(){t.loadScript(o+"sequence-diagram.min",function(){e.loadedDisplay()})})})})}):e.loadedDisplay()};return t.loadCSS(o+"codemirror/codemirror.min"),i.searchReplace&&!i.readOnly&&(t.loadCSS(o+"codemirror/addon/dialog/dialog"),t.loadCSS(o+"codemirror/addon/search/matchesonscrollbar")),i.codeFold&&t.loadCSS(o+"codemirror/addon/fold/foldgutter"),t.loadScript(o+"codemirror/codemirror.min",function(){t.$CodeMirror=CodeMirror,t.loadScript(o+"codemirror/modes.min",function(){t.loadScript(o+"codemirror/addons.min",function(){if(e.setCodeMirror(),"gfm"!==i.mode&&"markdown"!==i.mode)return e.loadedDisplay(),!1;e.setToolbar(),t.loadScript(o+"marked.min",function(){t.$marked=marked,i.previewCodeHighlight?t.loadScript(o+"prettify.min",function(){r()}):r()})})})}),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 i=this.settings;return i.editorTheme=e,"default"!==e&&t.loadCSS(i.path+"codemirror/theme/"+i.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,i=this.editor;"default"!==e.editorTheme&&t.loadCSS(e.path+"codemirror/theme/"+e.editorTheme);var o={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=t.$CodeMirror.fromTextArea(this.markdownTextarea[0],o),this.codeMirror=this.cmElement=i.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(t){var i=this.settings;if(!i.gotoLine)return this;var o=this.cm,r=o.lineCount(),a=this.preview;if("string"==typeof t&&("last"===t&&(t=r),"first"===t&&(t=1)),"number"!=typeof t)return alert("Error: The line number must be an integer."),this;if((t=parseInt(t)-1)>r)return alert("Error: The line number range 1-"+r),this;o.setCursor({line:t,ch:0});var n=o.getScrollInfo(),s=n.clientHeight,l=o.charCoords({line:t,ch:0},"local");if(o.scrollTo(null,(l.top+l.bottom-s)/2),i.watch){var c=this.codeMirror.find(".CodeMirror-scroll")[0],h=e(c).height(),d=c.scrollTop,u=d/c.scrollHeight;0===d?a.scrollTop(0):d+h>=c.scrollHeight-16?a.scrollTop(a[0].scrollHeight):a.scrollTop(a[0].scrollHeight*u)}return o.focus(),this},extend:function(){return void 0!==arguments[1]&&("function"==typeof arguments[1]&&(arguments[1]=e.proxy(arguments[1],this)),this[arguments[0]]=arguments[1]),"object"==typeof arguments[0]&&void 0===arguments[0].length&&e.extend(!0,this,arguments[0]),this},set:function(t,i){return void 0!==i&&"function"==typeof i&&(i=e.proxy(i,this)),this[t]=i,this},config:function(t,i){var o=this.settings;return"object"==typeof t&&(o=e.extend(!0,o,t)),"string"==typeof t&&(o[t]=i),this.settings=o,this.recreate(),this},on:function(t,i){var o=this.settings;return void 0!==o["on"+t]&&(o["on"+t]=e.proxy(i,this)),this},off:function(e){var t=this.settings;return void 0!==t["on"+e]&&(t["on"+e]=function(){}),this},showToolbar:function(t){var i=this.settings;return i.readOnly?this:(i.toolbar&&(this.toolbar.length<1||""===this.toolbar.find("."+this.classPrefix+"menu").html())&&this.setToolbar(),i.toolbar=!0,this.toolbar.show(),this.resize(),e.proxy(t||function(){},this)(),this)},hideToolbar:function(t){return this.settings.toolbar=!1,this.toolbar.hide(),this.resize(),e.proxy(t||function(){},this)(),this},setToolbarAutoFixed:function(t){var i=this.state,o=this.editor,r=this.toolbar,a=this.settings;void 0!==t&&(a.toolbarAutoFixed=t);var n=function(){var t=e(window),i=t.scrollTop();if(!a.toolbarAutoFixed)return!1;i-o.offset().top>10&&i
              ';i.append(a),r=this.toolbar=i.children("."+o+"toolbar")}if(!e.toolbar)return r.hide(),this;r.show();for(var n="function"==typeof e.toolbarIcons?e.toolbarIcons():"string"==typeof e.toolbarIcons?t.toolbarModes[e.toolbarIcons]:e.toolbarIcons,s=r.find("."+this.classPrefix+"menu"),l="",c=!1,h=0,d=n.length;h|';else{var f=/h(\d)/.test(u),g=u;"watch"!==u||e.watch||(g="unwatch");var p=e.lang.toolbar[g],m=e.toolbarIconTexts[g],w=e.toolbarIconsClass[g];p=void 0===p?"":p,m=void 0===m?"":m,w=void 0===w?"":w;var v=c?'
            • ':"
            • ";void 0!==e.toolbarCustomIcons[u]&&"function"!=typeof e.toolbarCustomIcons[u]?v+=e.toolbarCustomIcons[u]:(v+='',v+=''+(f?u.toUpperCase():""===w?m:"")+"",v+=""),v+="
            • ",l=c?v+l:l+v}}return s.html(l),s.find('[title="Lowercase"]').attr("title",e.lang.toolbar.lowercase),s.find('[title="ucwords"]').attr("title",e.lang.toolbar.ucwords),this.setToolbarHandler(),this.setToolbarAutoFixed(),this},dialogLockScreen:function(){return e.proxy(t.dialogLockScreen,this)(),this},dialogShowMask:function(i){return e.proxy(t.dialogShowMask,this)(i),this},getToolbarHandles:function(e){var i=this.toolbarHandlers=t.toolbarHandlers;return e&&void 0!==toolbarIconHandlers[e]?i[e]:i},setToolbarHandler:function(){var t=this,i=this.settings;if(!i.toolbar||i.readOnly)return this;var o=this.toolbar,r=this.cm,a=this.classPrefix,n=this.toolbarIcons=o.find("."+a+"menu > li > a"),s=this.getToolbarHandles();return n.bind("click",function(){var o=e(this).children(".fa"),a=o.attr("name"),n=r.getCursor(),l=r.getSelection();if(""!==a)return t.activeIcon=o,void 0!==s[a]?e.proxy(s[a],t)(r):void 0!==i.toolbarHandlers[a]&&e.proxy(i.toolbarHandlers[a],t)(r,o,n,l),"link"!==a&&"reference-link"!==a&&"image"!==a&&"code-block"!==a&&"preformatted-text"!==a&&"watch"!==a&&"preview"!==a&&"search"!==a&&"fullscreen"!==a&&"info"!==a&&r.focus(),!1}),this},createDialog:function(i){return e.proxy(t.createDialog,this)(i)},createInfoDialog:function(){var e=this,i=this.editor,o=this.classPrefix,r=['
              ','
              ','

              '+t.title+"v"+t.version+"

              ","

              "+this.lang.description+"

              ",'

              '+t.homePage+'

              ','

              Copyright © 2015-'+t.dateFormat("yyyy")+' Pandao, The MIT License.

              ',"
              ",'',"
              "].join("\n");i.append(r);var a=this.infoDialog=i.children("."+o+"dialog-info");return a.find("."+o+"dialog-close").bind("click",function(){e.hideInfoDialog()}),a.css("border",t.isIE8?"1px solid #ddd":"").css("z-index",t.dialogZindex).show(),this.infoDialogPosition(),this},infoDialogPosition:function(){var t=this.infoDialog,i=function(){t.css({top:(e(window).height()-t.height())/2+"px",left:(e(window).width()-t.width())/2+"px"})};return i(),e(window).resize(i),this},showInfoDialog:function(){e("html,body").css("overflow-x","hidden");var i=this.editor,o=this.settings,r=this.infoDialog=i.children("."+this.classPrefix+"dialog-info");return r.length<1&&this.createInfoDialog(),this.lockScreen(!0),this.mask.css({opacity:o.dialogMaskOpacity,backgroundColor:o.dialogMaskBgColor}).show(),r.css("z-index",t.dialogZindex).show(),this.infoDialogPosition(),this},hideInfoDialog:function(){return e("html,body").css("overflow-x",""),this.infoDialog.hide(),this.mask.hide(),this.lockScreen(!1),this},lockScreen:function(e){return t.lockScreen(e),this.resize(),this},recreate:function(){var e=this.editor,t=this.settings;return this.codeMirror.remove(),this.setCodeMirror(),t.readOnly||(e.find(".editormd-dialog").length>0&&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"),void 0!==window.prettyPrint&&window.prettyPrint()),this},katexRender:function(){return null===i?this:(this.previewContainer.find("."+t.classNames.tex).each(function(){var i=e(this);t.$katex.render(i.text(),i[0]),i.find(".katex").css("font-size","1.6em")}),this)},flowChartAndSequenceDiagramRender:function(){var i=this,r=this.settings,a=this.previewContainer;if(t.isIE8)return this;if(r.flowChart){if(null===o)return this;a.find(".flowchart").flowChart()}r.sequenceDiagram&&a.find(".sequence-diagram").sequenceDiagram({theme:"simple"});var n=i.preview,s=i.codeMirror,l=s.find(".CodeMirror-scroll"),c=l.height(),h=l.scrollTop(),d=h/l[0].scrollHeight,u=0;n.find(".markdown-toc-list").each(function(){u+=e(this).height()});var f=n.find(".editormd-toc-menu").height();return f=f||0,0===h?n.scrollTop(0):h+c>=l[0].scrollHeight-16?n.scrollTop(n[0].scrollHeight):n.scrollTop((n[0].scrollHeight+u+f)*d),this},registerKeyMaps:function(i){var o=this,r=this.cm,a=this.settings,n=t.toolbarHandlers,s=a.disabledKeyMaps;if(i=i||null){for(var l in i)if(e.inArray(l,s)<0){var c={};c[l]=i[l],r.addKeyMap(i)}}else{for(var h in t.keyMaps){var d=t.keyMaps[h],u="string"==typeof d?e.proxy(n[d],o):e.proxy(d,o);if(e.inArray(h,["F9","F10","F11"])<0&&e.inArray(h,s)<0){var f={};f[h]=u,r.addKeyMap(f)}}e(window).keydown(function(t){var i={120:"F9",121:"F10",122:"F11"};if(e.inArray(i[t.keyCode],s)<0)switch(t.keyCode){case 120:e.proxy(n.watch,o)(),t.stopPropagation();break;case 121:e.proxy(n.preview,o)(),t.stopPropagation();break;case 122:e.proxy(n.fullscreen,o)(),t.stopPropagation()}})}return this},bindScrollEvent:function(){var i=this,o=this.preview,r=this.settings,a=this.codeMirror,n=t.mouseOrTouch;if(!r.syncScrolling)return this;var s=function(){a.find(".CodeMirror-scroll").bind(n("scroll","touchmove"),function(t){var a=e(this).height(),n=e(this).scrollTop(),s=n/e(this)[0].scrollHeight,l=0;o.find(".markdown-toc-list").each(function(){l+=e(this).height()});var c=o.find(".editormd-toc-menu").height();c=c||0,0===n?o.scrollTop(0):n+a>=e(this)[0].scrollHeight-16?o.scrollTop(o[0].scrollHeight):o.scrollTop((o[0].scrollHeight+l+c)*s),e.proxy(r.onscroll,i)(t)})},l=function(){a.find(".CodeMirror-scroll").unbind(n("scroll","touchmove"))},c=function(){o.bind(n("scroll","touchmove"),function(t){var o=e(this).height(),n=e(this).scrollTop(),s=n/e(this)[0].scrollHeight,l=a.find(".CodeMirror-scroll");0===n?l.scrollTop(0):n+o>=e(this)[0].scrollHeight?l.scrollTop(l[0].scrollHeight):l.scrollTop(l[0].scrollHeight*s),e.proxy(r.onpreviewscroll,i)(t)})},h=function(){o.unbind(n("scroll","touchmove"))};return a.bind({mouseover:s,mouseout:l,touchstart:s,touchend:l}),"single"===r.syncScrolling?this:(o.bind({mouseover:c,mouseout:h,touchstart:c,touchend:h}),this)},bindChangeEvent:function(){var e=this,t=this.cm,o=this.settings;return o.syncScrolling?(t.on("change",function(){o.watch&&e.previewContainer.css("padding",o.autoHeight?"20px 20px 50px 40px":"20px"),i=setTimeout(function(){clearTimeout(i),e.save(),i=null},o.delay)}),this):this},loadedDisplay:function(t){t=t||!1;var i=this,o=this.editor,r=this.preview,a=this.settings;return this.containerMask.hide(),this.save(),a.watch&&r.show(),o.data("oldWidth",o.width()).data("oldHeight",o.height()),this.resize(),this.registerKeyMaps(),e(window).resize(function(){i.resize()}),this.bindScrollEvent().bindChangeEvent(),t||e.proxy(a.onload,this)(),this.state.loaded=!0,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(t,i){t=t||null,i=i||null;var o=this.state,r=this.editor,a=this.preview,n=this.toolbar,s=this.settings,l=this.codeMirror;if(t&&r.css("width","number"==typeof t?t+"px":t),!s.autoHeight||o.fullscreen||o.preview?(i&&r.css("height","number"==typeof i?i+"px":i),o.fullscreen&&r.height(e(window).height()),s.toolbar&&!s.readOnly?l.css("margin-top",n.height()+1).height(r.height()-n.height()):l.css("margin-top",0).height(r.height())):(r.css("height","auto"),l.css("height","auto")),s.watch)if(l.width(r.width()/2-1),a.width(o.preview?r.width():r.width()/2),this.previewContainer.css("padding",s.autoHeight?"20px 20px 50px 40px":"20px"),s.toolbar&&!s.readOnly?a.css("top",n.height()+1):a.css("top",0),!s.autoHeight||o.fullscreen||o.preview){var c=s.toolbar&&!s.readOnly?r.height()-n.height():r.height();a.height(c)}else a.height("");else l.width(r.width()),a.hide();return o.loaded&&e.proxy(s.onresize,this)(),this},save:function(){if(null===i)return this;var r=this,a=this.state,n=this.settings,s=this.cm,l=s.getValue(),c=this.previewContainer;if("gfm"!==n.mode&&"markdown"!==n.mode)return this.markdownTextarea.val(l),this;var h=t.$marked,d=this.markdownToC=[],u=this.markedRendererOptions={toc:n.toc,tocm:n.tocm,tocStartLevel:n.tocStartLevel,pageBreak:n.pageBreak,taskList:n.taskList,emoji:n.emoji,tex:n.tex,atLink:n.atLink,emailLink:n.emailLink,flowChart:n.flowChart,sequenceDiagram:n.sequenceDiagram,previewCodeHighlight:n.previewCodeHighlight},f=this.markedOptions={renderer:t.markedRenderer(d,u),gfm:!0,tables:!0,breaks:!0,pedantic:!1,sanitize:!n.htmlDecode,smartLists:!0,smartypants:!0};h.setOptions(f);var g=t.$marked(l,f);if(g=t.filterHTMLTags(g,n.htmlDecode),this.markdownTextarea.text(l),s.save(),n.saveHTMLToTextarea&&this.htmlTextarea.text(g),n.watch||!n.watch&&a.preview){if(c.html(g),this.previewCodeHighlight(),n.toc){var p=""===n.tocContainer?c:e(n.tocContainer),m=p.find("."+this.classPrefix+"toc-menu");p.attr("previewContainer",""===n.tocContainer?"true":"false"),""!==n.tocContainer&&m.length>0&&m.remove(),t.markdownToCRenderer(d,p,n.tocDropdown,n.tocStartLevel),(n.tocDropdown||p.find("."+this.classPrefix+"toc-menu").length>0)&&t.tocDropdownMenu(p,""!==n.tocTitle?n.tocTitle:this.lang.tocTitle),""!==n.tocContainer&&c.find(".markdown-toc").css("border","none")}n.tex&&(!t.kaTeXLoaded&&n.autoLoadModules?t.loadKaTeX(function(){t.$katex=katex,t.kaTeXLoaded=!0,r.katexRender()}):(t.$katex=katex,this.katexRender())),(n.flowChart||n.sequenceDiagram)&&(o=setTimeout(function(){clearTimeout(o),r.flowChartAndSequenceDiagramRender(),o=null},10)),a.loaded&&e.proxy(n.onchange,this)()}return 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){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(t){var o=this.settings;if(e.inArray(o.mode,["gfm","markdown"])<0)return this;if(this.state.watching=o.watch=!0,this.preview.show(),this.toolbar){var r=o.toolbarIconsClass.watch,a=o.toolbarIconsClass.unwatch,n=this.toolbar.find(".fa[name=watch]");n.parent().attr("title",o.lang.toolbar.watch),n.removeClass(a).addClass(r)}return this.codeMirror.css("border-right","1px solid #ddd").width(this.editor.width()/2),i=0,this.save().resize(),o.onwatch||(o.onwatch=t||function(){}),e.proxy(o.onwatch,this)(),this},unwatch:function(t){var i=this.settings;if(this.state.watching=i.watch=!1,this.preview.hide(),this.toolbar){var o=i.toolbarIconsClass.watch,r=i.toolbarIconsClass.unwatch,a=this.toolbar.find(".fa[name=watch]");a.parent().attr("title",i.lang.toolbar.unwatch),a.removeClass(o).addClass(r)}return this.codeMirror.css("border-right","none").width(this.editor.width()),this.resize(),i.onunwatch||(i.onunwatch=t||function(){}),e.proxy(i.onunwatch,this)(),this},show:function(t){t=t||function(){};var i=this;return this.editor.show(0,function(){e.proxy(t,i)()}),this},hide:function(t){t=t||function(){};var i=this;return this.editor.hide(0,function(){e.proxy(t,i)()}),this},destroy:function(){this.hide(),this.editor.remove()},previewing:function(){var t=this,i=this.editor,o=this.preview,r=this.toolbar,a=this.settings,n=this.codeMirror,s=this.previewContainer;if(e.inArray(a.mode,["gfm","markdown"])<0)return this;var l=this.editor.outerHeight();a.toolbar&&r&&(r.toggle(),r.find(".fa[name=preview]").toggleClass("active")),n.toggle();var c=function(e){e.shiftKey&&27===e.keyCode&&t.previewed()};"none"===n.css("display")?(this.state.preview=!0,this.settings.autoHeight&&this.editor.css("height",l),this.state.fullscreen&&o.css("background","#fff"),i.find("."+this.classPrefix+"preview-close-btn").show().bind("click",function(){t.previewed()}),a.watch?s.css("padding",""):this.save(),s.addClass(this.classPrefix+"preview-active"),o.show().css({position:"",top:0,width:i.width(),height:a.autoHeight&&!this.state.fullscreen?"auto":i.height()}),this.state.loaded&&e.proxy(a.onpreviewing,this)(),e(window).bind("keyup",c)):(e(window).unbind("keyup",c),this.previewed())},previewed:function(){var t=this.editor,i=this.preview,o=this.toolbar,r=this.settings,a=this.previewContainer,n=t.find("."+this.classPrefix+"preview-close-btn");return this.state.preview=!1,this.codeMirror.show(),r.toolbar&&o.show(),i[r.watch?"show":"hide"](),n.hide().unbind("click"),a.removeClass(this.classPrefix+"preview-active"),r.watch&&a.css("padding","20px"),this.settings.autoHeight&&this.editor.css("height","auto"),i.css({background:null,position:"absolute",width:t.width()/2,height:r.autoHeight&&!this.state.fullscreen?"auto":t.height()-o.height(),top:r.toolbar?o.height():0}),this.state.loaded&&e.proxy(r.onpreviewed,this)(),this},fullscreen:function(){var t=this,i=this.state,o=this.editor,r=this.toolbar,a=this.settings,n=this.classPrefix+"fullscreen";r&&r.find(".fa[name=fullscreen]").parent().toggleClass("active");var s=function(e){e.shiftKey||27!==e.keyCode||i.fullscreen&&t.fullscreenExit()};return o.hasClass(n)?(e(window).unbind("keyup",s),this.fullscreenExit()):(i.fullscreen=!0,e("html,body").css("overflow","hidden"),o.css({width:e(window).width(),height:e(window).height()}).addClass(n),this.resize(),e.proxy(a.onfullscreen,this)(),e(window).bind("keyup",s)),this},fullscreenExit:function(){var t=this.editor,i=this.settings,o=this.toolbar,r=this.classPrefix+"fullscreen";return this.state.fullscreen=!1,o&&o.find(".fa[name=fullscreen]").parent().removeClass("active"),e("html,body").css("overflow",""),t.css({width:t.data("oldWidth"),height:t.data("oldHeight")}).removeClass(r),this.resize(),e.proxy(i.onfullscreenExit,this)(),this},executePlugin:function(i,o){var r=this,a=this.cm;return o=this.settings.pluginPath+o,"function"==typeof define?void 0===this[i]?(alert("Error: "+i+" plugin is not found, you are not load this plugin."),this):(this[i](a),this):(e.inArray(o,t.loadFiles.plugin)<0?t.loadPlugin(o,function(){t.loadPlugins[i]=r[i],r[i](a)}):e.proxy(t.loadPlugins[i],this)(a),this)},search:function(e){var t=this.settings;return t.searchReplace?(t.readOnly||this.cm.execCommand(e||"find"),this):(alert("Error: settings.searchReplace == false"),this)},searchReplace:function(){return this.search("replace"),this},searchReplaceAll:function(){return this.search("replaceAll"),this}},t.fn.init.prototype=t.fn,t.dialogLockScreen=function(){(this.settings||{dialogLockScreen:!0}).dialogLockScreen&&(e("html,body").css("overflow","hidden"),this.resize())},t.dialogShowMask=function(t){var i=this.editor,o=this.settings||{dialogShowMask:!0};t.css({top:(e(window).height()-t.height())/2+"px",left:(e(window).width()-t.width())/2+"px"}),o.dialogShowMask&&i.children("."+this.classPrefix+"mask").css("z-index",parseInt(t.css("z-index"))-1).show()},t.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,i=e.getSelection(),o=e.listSelections();e.replaceSelection(t.firstUpperCase(i)),e.setSelections(o)},ucwords:function(){var e=this.cm,i=e.getSelection(),o=e.listSelections();e.replaceSelection(t.wordsFirstUpperCase(i)),e.setSelections(o)},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.getSelection(),i=e.listSelections();e.replaceSelection(t.toLowerCase()),e.setSelections(i)},h1: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)},h2: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+3)):e.replaceSelection("## "+i)},h3: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+4)):e.replaceSelection("### "+i)},h4: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+5)):e.replaceSelection("#### "+i)},h5: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+6)):e.replaceSelection("##### "+i)},h6: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+7)):e.replaceSelection("###### "+i)},"list-ul":function(){var e=this.cm,t=e.getSelection();if(""===t)e.replaceSelection("- "+t);else{for(var i=t.split("\n"),o=0,r=i.length;o'}else{var s=e.match(m),l=e.match(g);if(s)for(var c=0,h=s.length;c'}else{if(!l){var u="+1"===o?"plus1":o;return u="black_large_square"===u?"black_square":u,u="moon"===u?"waxing_gibbous_moon":u,':'+o+':'}for(var f=0,w=l.length;f'}}}});return e},l.atLink=function(i){return h.test(i)?(n.atLink&&(i=i.replace(u,function(e,t,i,o){return e.replace(/@/g,"_#_@_#_")}),i=i.replace(h,function(e,i){return''+e+""}).replace(/_#_@_#_/g,"@")),n.emailLink&&(i=i.replace(f,function(t,i,o,r,a){return!i&&e.inArray(a,"jpg|jpeg|png|gif|webp|ico|icon|pdf".split("|"))<0?''+t+"":t})),i):i},l.link=function(e,t,i){if(this.options.sanitize)try{if(0===decodeURIComponent(unescape(e)).replace(/[^\w:]/g,"").toLowerCase().indexOf("javascript:"))return""}catch(e){return""}var o=''+i.replace(/@/g,"@")+""):(t&&(o+=' title="'+t+'"'),o+=">"+i+"")},l.heading=function(e,t){var o=e,a=/\s*\]*)\>(.*)\<\/a\>\s*/;if(a.test(e)){var n=[];e=e.split(/\]+)\>([^\>]*)\<\/a\>/);for(var s=0,l=e.length;s';return f+='',f+='',f+=a?this.atLink(this.emoji(o)):this.atLink(this.emoji(e)),f+=""},l.pageBreak=function(e){return w.test(e)&&n.pageBreak&&(e='
              '),e},l.paragraph=function(e){var i=/\$\$(.*)\$\$/g.test(e),o=/^\$\$(.*)\$\$$/.test(e),r=o?' class="'+t.classNames.tex+'"':"",a=n.tocm?/^(\[TOC\]|\[TOCM\])$/.test(e):/^\[TOC\]$/.test(e),s=/^\[TOCM\]$/.test(e);e=!o&&i?e.replace(/(\$\$([^\$]*)\$\$)+/g,function(e,i){return''+i.replace(/\$/g,"")+""}):o?e.replace(/\$/g,""):e;var l='
              '+e+"
              ";return a?s?'
              '+l+"

              ":l:w.test(e)?this.pageBreak(e):""+this.atLink(this.emoji(e))+"

              \n"},l.code=function(e,i){return"seq"===i||"sequence"===i?'
              '+e+"
              ":"flow"===i?'
              '+e+"
              ":"math"===i||"latex"===i||"katex"===i?'

              '+e+"

              ":s.Renderer.prototype.code.apply(this,arguments)},l.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))+"\n"},l.listitem=function(e){return n.taskList&&/^\s*\[[x\s]\]\s*/.test(e)?(e=e.replace(/^\s*\[\s\]\s*/,' ').replace(/^\s*\[x\]\s*/,' '),'
            • '+this.atLink(this.emoji(e))+"
            • "):"
            • "+this.atLink(this.emoji(e))+"
            • "},l},t.markdownToCRenderer=function(e,t,i,o){var r="",a=0,n=this.classPrefix;o=o||1;for(var s=0,l=e.length;sa?"":h"):"
          • ",r+='
          • '+c+"
              ",a=h)}var d=t.find(".markdown-toc");if(d.length<1&&"false"===t.attr("previewContainer")){var u='
              ';u=i?'
              '+u+"
              ":u,t.html(u),d=t.find(".markdown-toc")}return i&&d.wrap('

              '),d.html('
                ').children(".markdown-toc-list").html(r.replace(/\r?\n?\\<\/ul\>/g,"")),d},t.tocDropdownMenu=function(t,i){i=i||"Table of Contents";var o=400,r=t.find("."+this.classPrefix+"toc-menu");return r.each(function(){var t=e(this),r=t.children(".markdown-toc"),a='',n=''+a+i+"",s=r.children("ul"),l=s.find("li");r.append(n),l.first().before("
              • "+i+" "+a+"

              • "),t.mouseover(function(){s.show(),l.each(function(){var t=e(this),i=t.children("ul");if(""===i.html()&&i.remove(),i.length>0&&""!==i.html()){var r=t.children("a").first();r.children(".fa").length<1&&r.append(e(a).css({float:"right",paddingTop:"4px"}))}t.mouseover(function(){i.css("z-index",o).show(),o+=1}).mouseleave(function(){i.hide()})})}).mouseleave(function(){s.hide()})}),r},t.filterHTMLTags=function(t,i){if("string"!=typeof t&&(t=t.toString()),"string"!=typeof i)return t;for(var o=i.split("|"),r=o[0].split(","),a=o[1],n=0,s=r.length;n]*)>([^>]*)","igm"),"")}if(void 0!==a){var c=/\<(\w+)\s*([^\>]*)\>([^\>]*)\<\/(\w+)\>/gi;t="*"===a?t.replace(c,function(e,t,i,o,r){return"<"+t+">"+o+""}):"on*"===a?t.replace(c,function(t,i,o,r,a){var n=e("<"+i+">"+r+""),s=e(t)[0].attributes,l={};e.each(s,function(e,t){'"'!==t.nodeName&&(l[t.nodeName]=t.nodeValue)}),e.each(l,function(e){0===e.indexOf("on")&&delete l[e]}),n.attr(l);var c=void 0!==n[1]?e(n[1]).text():"";return n[0].outerHTML+c}):t.replace(c,function(t,i,o,r){var n=a.split(","),s=e(t);return s.html(r),e.each(n,function(e){s.attr(n[e],null)}),s[0].outerHTML})}return t},t.markdownToHTML=function(i,o){var r={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};t.$marked=marked;var a=e("#"+i),n=a.settings=e.extend(!0,{},r,o||{}),s=a.find("textarea");s.length<1&&(a.append(""),s=a.find("textarea"));var l=""===n.markdown?s.val():n.markdown,c=[],h={toc:n.toc,tocm:n.tocm,tocStartLevel:n.tocStartLevel,taskList:n.taskList,emoji:n.emoji,tex:n.tex,pageBreak:n.pageBreak,atLink:n.atLink,emailLink:n.emailLink,flowChart:n.flowChart,sequenceDiagram:n.sequenceDiagram,previewCodeHighlight:n.previewCodeHighlight},d={renderer:t.markedRenderer(c,h),gfm:n.gfm,tables:!0,breaks:!0,pedantic:!1,sanitize:!n.htmlDecode,smartLists:!0,smartypants:!0};l=l.toString();var u=marked(l,d);u=t.filterHTMLTags(u,n.htmlDecode),n.markdownSourceCode?s.text(l):s.remove(),a.addClass("markdown-body "+this.classPrefix+"html-preview").append(u);var f=""!==n.tocContainer?e(n.tocContainer):a;if(""!==n.tocContainer&&f.attr("previewContainer",!1),n.toc&&(a.tocContainer=this.markdownToCRenderer(c,f,n.tocDropdown,n.tocStartLevel),(n.tocDropdown||a.find("."+this.classPrefix+"toc-menu").length>0)&&this.tocDropdownMenu(a,n.tocTitle),""!==n.tocContainer&&a.find(".editormd-toc-menu, .editormd-markdown-toc").remove()),n.previewCodeHighlight&&(a.find("pre").addClass("prettyprint linenums"),window.prettyPrint()),t.isIE8||(n.flowChart&&a.find(".flowchart").flowChart(),n.sequenceDiagram&&a.find(".sequence-diagram").sequenceDiagram({theme:"simple"})),n.tex){var g=function(){a.find("."+t.classNames.tex).each(function(){var t=e(this);katex.render(t.html().replace(/</g,"<").replace(/>/g,">"),t[0]),t.find(".katex").css("font-size","1.6em")})};!n.autoLoadKaTeX||t.$katex||t.kaTeXLoaded?g():this.loadKaTeX(function(){t.$katex=katex,t.kaTeXLoaded=!0,g()})}return a.getMarkdown=function(){return s.val()},a},t.themes=["default","dark"],t.previewThemes=["default","dark"],t.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"],t.loadPlugins={},t.loadFiles={js:[],css:[],plugin:[]},t.loadPlugin=function(e,i,o){i=i||function(){},this.loadScript(e,function(){t.loadFiles.plugin.push(e),i()},o)},t.loadCSS=function(e,i,o){o=o||"head",i=i||function(){};var r=document.createElement("link");r.type="text/css",r.rel="stylesheet",r.onload=r.onreadystatechange=function(){t.loadFiles.css.push(e),i()},r.href=e+".css","head"===o?document.getElementsByTagName("head")[0].appendChild(r):document.body.appendChild(r)},t.isIE="Microsoft Internet Explorer"===navigator.appName,t.isIE8=t.isIE&&"8."===navigator.appVersion.match(/8./i),t.loadScript=function(e,i,o){o=o||"head",i=i||function(){};var r=null;r=document.createElement("script"),r.id=e.replace(/[\.\/]+/g,"-"),r.type="text/javascript",r.src=e+".js",t.isIE8?r.onreadystatechange=function(){r.readyState&&("loaded"!==r.readyState&&"complete"!==r.readyState||(r.onreadystatechange=null,t.loadFiles.js.push(e),i()))}:r.onload=function(){t.loadFiles.js.push(e),i()},"head"===o?document.getElementsByTagName("head")[0].appendChild(r):document.body.appendChild(r)},t.katexURL={css:"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.1/katex.min",js:"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.1/katex.min"},t.kaTeXLoaded=!1,t.loadKaTeX=function(e){t.loadCSS(t.katexURL.css,function(){t.loadScript(t.katexURL.js,e||function(){})})},t.lockScreen=function(t){e("html,body").css("overflow",t?"hidden":"")},t.createDialog=function(i){var o={name:"",width:420,height:240,title:"",drag:!0,closed:!0,cached:!1,content:"",mask:!0,maskStyle:{backgroundColor:"#fff",opacity:.1},lockScreen:!0,footer:!0,buttons:!1};i=e.extend(!0,o,i);var r=this,a=this.editor,n=t.classPrefix,s=(new Date).getTime(),l=""===i.name?n+"dialog-"+s:i.name,c='
                ';""!==i.title&&(c+='
                ",c+=''+i.title+"",c+="
                "),i.closed&&(c+=''),c+='
                '+i.content,(i.footer||"string"==typeof i.footer)&&(c+='"),c+="
                ",c+='
                ',c+='
                ',c+="
                ",a.append(c);var h=a.find("."+l);h.lockScreen=function(t){return i.lockScreen&&(e("html,body").css("overflow",t?"hidden":""),r.resize()),h},h.showMask=function(){return i.mask&&a.find("."+n+"mask").css(i.maskStyle).css("z-index",t.dialogZindex-1).show(),h},h.hideMask=function(){return i.mask&&a.find("."+n+"mask").hide(),h},h.loading=function(e){return h.find("."+n+"dialog-mask")[e?"show":"hide"](),h},h.lockScreen(!0).showMask(),h.show().css({zIndex:t.dialogZindex,border:t.isIE8?"1px solid #ddd":"",width:"number"==typeof i.width?i.width+"px":i.width,height:"number"==typeof i.height?i.height+"px":i.height});var d=function(){h.css({top:(e(window).height()-h.height())/2+"px",left:(e(window).width()-h.width())/2+"px"})};if(d(),e(window).resize(d),h.children("."+n+"dialog-close").bind("click",function(){h.hide().lockScreen(!1).hideMask(),i.cached||h.remove()}),"object"==typeof i.buttons){var u=h.footer=h.find("."+n+"dialog-footer");for(var f in i.buttons){var g=i.buttons[f],p=n+f+"-btn";u.append('"),g[1]=e.proxy(g[1],h),u.children("."+p).bind("click",g[1])}}if(""!==i.title&&i.drag){var m,w,v=h.children("."+n+"dialog-header");i.mask||v.bind("click",function(){t.dialogZindex+=2,h.css("z-index",t.dialogZindex)});var k=function(e){e.removeClass(n+"user-unselect").off("selectstart")},b=function(e){e.addClass(n+"user-unselect").on("selectstart",function(){return!1})},x=function(t){t=t||window.event;var i,o,r=parseInt(h[0].style.left),a=parseInt(h[0].style.top);r>=0?r+h.width()<=e(window).width()?i=t.clientX-m:(i=e(window).width()-h.width(),document.onmousemove=null):(i=0,document.onmousemove=null),a>=0?o=t.clientY-w:(o=0,document.onmousemove=null),document.onselectstart=function(){return!1},b(e("body")),b(h),h[0].style.left=i+"px",h[0].style.top=o+"px"};v.mousedown(function(e){e=e||window.event,m=e.clientX-parseInt(h[0].style.left),w=e.clientY-parseInt(h[0].style.top),document.onmousemove=x}),document.onmouseup=function(){k(e("body")),k(h),document.onselectstart=null,document.onmousemove=null},v.touchDraggable=function(){var t=null,i=function(i){var o=i.originalEvent,r=e(this).parent().position();t={x:o.changedTouches[0].pageX-r.left,y:o.changedTouches[0].pageY-r.top}},o=function(i){i.preventDefault();var o=i.originalEvent;e(this).parent().css({top:o.changedTouches[0].pageY-t.y,left:o.changedTouches[0].pageX-t.x})};this.bind("touchstart",i).bind("touchmove",o)},v.touchDraggable()}return t.dialogZindex+=2,h},t.mouseOrTouch=function(e,t){e=e||"click",t=t||"touchend";var i=e;try{document.createEvent("TouchEvent"),i=t}catch(e){}return i},t.dateFormat=function(e){e=e||"";var t=function(e){return e<10?"0"+e:e},i=new Date,o=i.getFullYear(),r=o.toString().slice(2,4),a=t(i.getMonth()+1),n=t(i.getDate()),s=i.getDay(),l=t(i.getHours()),c=t(i.getMinutes()),h=t(i.getSeconds()),d=t(i.getMilliseconds()),u="",f=r+"-"+a+"-"+n,g=o+"-"+a+"-"+n,p=l+":"+c+":"+h;switch(e){case"UNIX Time":u=i.getTime();break;case"UTC":u=i.toUTCString();break;case"yy":u=r;break;case"year":case"yyyy":u=o;break;case"month":case"mm":u=a;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=n;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=g;break;case"yyyy-mm-dd h:i:s ms":case"full + ms":u=g+" "+p+" "+d;break;case"full":case"yyyy-mm-dd h:i:s":default:u=g+" "+p}return u},t}}); \ No newline at end of file +!function(e){"use strict";"function"==typeof require&&"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define?define.amd||define(["jquery"],e):window.editormd=e()}(function(){"use strict";var e=void 0!==window.jQuery?window.jQuery:window.Zepto;if(void 0!==e){var t=function(e,i){return new t.fn.init(e,i)};t.title=t.$name="Editor.md",t.version="1.5.1",t.homePage="https://pandao.github.io/editor.md/",t.classPrefix="editormd-",t.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","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","info"],mini:["undo","redo","|","watch","preview","|","help","info"]},t.defaults={mode:"gfm",name:"",value:"",theme:"",editorTheme:"default",previewTheme:"",markdown:"",appendMarkdown:"",width:"100%",height:"100%",path:"./lib/",pluginPath:"",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:!1,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(){},onpreviewed:function(){},onfullscreen:function(){},onfullscreenExit:function(){},onscroll:function(){},onpreviewscroll:function(){},imageUpload:!1,imageFormats:["jpg","jpeg","gif","png","bmp","webp"],imageUploadURL:"",imageUploadFields:"",imageUploadCallback:function(){},imageUploadCallbackName:"__Editor_md_ImageUploadCallback",crossDomainUpload:!1,uploadCallbackURL:"",toc:!0,tocm:!1,tocTitle:"",tocDropdown:!1,tocContainer:"",tocStartLevel:1,htmlDecode:!1,pageBreak:!0,atLink:!0,emailLink:!0,taskList:!1,emoji:!1,tex:!1,flowChart:!1,sequenceDiagram:!1,previewCodeHighlight:!0,toolbar:!0,toolbarAutoFixed:!0,toolbarIcons:"full",toolbarTitles:{},toolbarHandlers:{ucwords:function(){return t.toolbarHandlers.ucwords},lowercase:function(){return t.toolbarHandlers.lowercase}},toolbarCustomIcons:{lowercase:'a',ucwords:'Aa'},toolbarIconsClass:{undo:"fa-undo",redo:"fa-repeat",bold:"fa-bold",del:"fa-strikethrough",italic:"fa-italic",quote:"fa-quote-left",uppercase:"fa-font",h1:t.classPrefix+"bold",h2:t.classPrefix+"bold",h3:t.classPrefix+"bold",h4:t.classPrefix+"bold",h5:t.classPrefix+"bold",h6:t.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",info:"fa-info-circle"},toolbarIconTexts:{},lang:{name:"zh-cn",description:"开源在线 Markdown 编辑器
                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:"使用帮助",info:"关于"+t.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:"错误:请填写预格式文本或代码的内容。",placeholder:"Coding now...."},codeBlock:{title:"添加代码块",selectLabel:"代码语言:",selectDefaultText:"请选择代码语言",otherLanguage:"其他语言",unselectedLanguageAlert:"错误:请选择代码所属的语言类型。",codeEmptyAlert:"错误:请填写代码内容。",placeholder:"Coding now...."},htmlEntities:{title:"HTML 实体字符"},help:{title:"使用帮助"}}}},t.classNames={tex:t.classPrefix+"tex"},t.dialogZindex=99999,t.$katex=null,t.$marked=null,t.$CodeMirror=null,t.$prettyPrint=null;var i,o;t.prototype=t.fn={state:{watching:!1,loaded:!1,preview:!1,fullscreen:!1},init:function(i,o){o=o||{},"object"==typeof i&&(o=i);var r=this.classPrefix=t.classPrefix,a=e.extend(!0,{},t.defaults,o);o.imageFormats&&(a.imageFormats=o.imageFormats),this.settings=a,i="object"==typeof i?a.id:i;var n=this.editor=e("#"+i);this.id=i,this.lang=a.lang;var s=this.classNames={textarea:{html:r+"html-textarea",markdown:r+"markdown-textarea"}};a.pluginPath=""===a.pluginPath?a.path+"../plugins/":a.pluginPath,this.state.watching=!!a.watch,n.hasClass("editormd")||n.addClass("editormd"),n.css({width:"number"==typeof a.width?a.width+"px":a.width,height:"number"==typeof a.height?a.height+"px":a.height}),a.autoHeight&&n.css("height","auto");var l=this.markdownTextarea=n.children("textarea");l.length<1&&(n.append(""),l=this.markdownTextarea=n.children("textarea")),l.addClass(s.textarea.markdown).attr("placeholder",a.placeholder),void 0!==l.attr("name")&&""!==l.attr("name")||l.attr("name",""!==a.name?a.name:i+"-markdown-doc");var c=[a.readOnly?"":'',a.saveHTMLToTextarea?'':"",'
                ','
                ','
                '].join("\n");return n.append(c).addClass(r+"vertical"),""!==a.theme&&n.addClass(r+"theme-"+a.theme),this.mask=n.children("."+r+"mask"),this.containerMask=n.children("."+r+"container-mask"),""!==a.markdown&&l.val(a.markdown),""!==a.appendMarkdown&&l.val(l.val()+a.appendMarkdown),this.htmlTextarea=n.children("."+s.textarea.html),this.preview=n.children("."+r+"preview"),this.previewContainer=this.preview.children("."+r+"preview-container"),""!==a.previewTheme&&this.preview.addClass(r+"preview-theme-"+a.previewTheme),"function"==typeof define&&define.amd&&(void 0!==window.katex&&(t.$katex=window.katex),a.searchReplace&&!a.readOnly&&(t.loadCSS(a.path+"codemirror/addon/dialog/dialog"),t.loadCSS(a.path+"codemirror/addon/search/matchesonscrollbar"))),"function"==typeof define&&define.amd||!a.autoLoadModules?(void 0!==window.CodeMirror&&(t.$CodeMirror=window.CodeMirror),void 0!==window.marked&&(t.$marked=window.marked),this.setCodeMirror().setToolbar().loadedDisplay()):this.loadQueues(),this},loadQueues:function(){var e=this,i=this.settings,o=i.path,r=function(){if(t.isIE8)return void e.loadedDisplay();i.flowChart||i.sequenceDiagram?t.loadScript(o+"raphael.min",function(){t.loadScript(o+"underscore.min",function(){!i.flowChart&&i.sequenceDiagram?t.loadScript(o+"sequence-diagram.min",function(){e.loadedDisplay()}):i.flowChart&&!i.sequenceDiagram?t.loadScript(o+"flowchart.min",function(){t.loadScript(o+"jquery.flowchart.min",function(){e.loadedDisplay()})}):i.flowChart&&i.sequenceDiagram&&t.loadScript(o+"flowchart.min",function(){t.loadScript(o+"jquery.flowchart.min",function(){t.loadScript(o+"sequence-diagram.min",function(){e.loadedDisplay()})})})})}):e.loadedDisplay()};return t.loadCSS(o+"codemirror/codemirror.min"),i.searchReplace&&!i.readOnly&&(t.loadCSS(o+"codemirror/addon/dialog/dialog"),t.loadCSS(o+"codemirror/addon/search/matchesonscrollbar")),i.codeFold&&t.loadCSS(o+"codemirror/addon/fold/foldgutter"),t.loadScript(o+"codemirror/codemirror.min",function(){t.$CodeMirror=CodeMirror,t.loadScript(o+"codemirror/modes.min",function(){t.loadScript(o+"codemirror/addons.min",function(){if(e.setCodeMirror(),"gfm"!==i.mode&&"markdown"!==i.mode)return e.loadedDisplay(),!1;e.setToolbar(),t.loadScript(o+"marked.min",function(){t.$marked=marked,i.previewCodeHighlight?t.loadScript(o+"prettify.min",function(){r()}):r()})})})}),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 i=this.settings;return i.editorTheme=e,"default"!==e&&t.loadCSS(i.path+"codemirror/theme/"+i.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,i=this.editor;"default"!==e.editorTheme&&t.loadCSS(e.path+"codemirror/theme/"+e.editorTheme);var o={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=t.$CodeMirror.fromTextArea(this.markdownTextarea[0],o),this.codeMirror=this.cmElement=i.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(t){var i=this.settings;if(!i.gotoLine)return this;var o=this.cm,r=o.lineCount(),a=this.preview;if("string"==typeof t&&("last"===t&&(t=r),"first"===t&&(t=1)),"number"!=typeof t)return alert("Error: The line number must be an integer."),this;if((t=parseInt(t)-1)>r)return alert("Error: The line number range 1-"+r),this;o.setCursor({line:t,ch:0});var n=o.getScrollInfo(),s=n.clientHeight,l=o.charCoords({line:t,ch:0},"local");if(o.scrollTo(null,(l.top+l.bottom-s)/2),i.watch){var c=this.codeMirror.find(".CodeMirror-scroll")[0],h=e(c).height(),d=c.scrollTop,u=d/c.scrollHeight;0===d?a.scrollTop(0):d+h>=c.scrollHeight-16?a.scrollTop(a[0].scrollHeight):a.scrollTop(a[0].scrollHeight*u)}return o.focus(),this},extend:function(){return void 0!==arguments[1]&&("function"==typeof arguments[1]&&(arguments[1]=e.proxy(arguments[1],this)),this[arguments[0]]=arguments[1]),"object"==typeof arguments[0]&&void 0===arguments[0].length&&e.extend(!0,this,arguments[0]),this},set:function(t,i){return void 0!==i&&"function"==typeof i&&(i=e.proxy(i,this)),this[t]=i,this},config:function(t,i){var o=this.settings;return"object"==typeof t&&(o=e.extend(!0,o,t)),"string"==typeof t&&(o[t]=i),this.settings=o,this.recreate(),this},on:function(t,i){var o=this.settings;return void 0!==o["on"+t]&&(o["on"+t]=e.proxy(i,this)),this},off:function(e){var t=this.settings;return void 0!==t["on"+e]&&(t["on"+e]=function(){}),this},showToolbar:function(t){var i=this.settings;return i.readOnly?this:(i.toolbar&&(this.toolbar.length<1||""===this.toolbar.find("."+this.classPrefix+"menu").html())&&this.setToolbar(),i.toolbar=!0,this.toolbar.show(),this.resize(),e.proxy(t||function(){},this)(),this)},hideToolbar:function(t){return this.settings.toolbar=!1,this.toolbar.hide(),this.resize(),e.proxy(t||function(){},this)(),this},setToolbarAutoFixed:function(t){var i=this.state,o=this.editor,r=this.toolbar,a=this.settings;void 0!==t&&(a.toolbarAutoFixed=t);var n=function(){var t=e(window),i=t.scrollTop();if(!a.toolbarAutoFixed)return!1;i-o.offset().top>10&&i
                  ';i.append(a),r=this.toolbar=i.children("."+o+"toolbar")}if(!e.toolbar)return r.hide(),this;r.show();for(var n="function"==typeof e.toolbarIcons?e.toolbarIcons():"string"==typeof e.toolbarIcons?t.toolbarModes[e.toolbarIcons]:e.toolbarIcons,s=r.find("."+this.classPrefix+"menu"),l="",c=!1,h=0,d=n.length;h|';else{var f=/h(\d)/.test(u),g=u;"watch"!==u||e.watch||(g="unwatch");var p=e.lang.toolbar[g],m=e.toolbarIconTexts[g],w=e.toolbarIconsClass[g];p=void 0===p?"":p,m=void 0===m?"":m,w=void 0===w?"":w;var v=c?'
                • ':"
                • ";void 0!==e.toolbarCustomIcons[u]&&"function"!=typeof e.toolbarCustomIcons[u]?v+=e.toolbarCustomIcons[u]:(v+='',v+=''+(f?u.toUpperCase():""===w?m:"")+"",v+=""),v+="
                • ",l=c?v+l:l+v}}return s.html(l),s.find('[title="Lowercase"]').attr("title",e.lang.toolbar.lowercase),s.find('[title="ucwords"]').attr("title",e.lang.toolbar.ucwords),this.setToolbarHandler(),this.setToolbarAutoFixed(),this},dialogLockScreen:function(){return e.proxy(t.dialogLockScreen,this)(),this},dialogShowMask:function(i){return e.proxy(t.dialogShowMask,this)(i),this},getToolbarHandles:function(e){var i=this.toolbarHandlers=t.toolbarHandlers;return e&&void 0!==toolbarIconHandlers[e]?i[e]:i},setToolbarHandler:function(){var t=this,i=this.settings;if(!i.toolbar||i.readOnly)return this;var o=this.toolbar,r=this.cm,a=this.classPrefix,n=this.toolbarIcons=o.find("."+a+"menu > li > a"),s=this.getToolbarHandles();return n.bind("click",function(){var o=e(this).children(".fa"),a=o.attr("name"),n=r.getCursor(),l=r.getSelection();if(""!==a)return t.activeIcon=o,void 0!==s[a]?e.proxy(s[a],t)(r):void 0!==i.toolbarHandlers[a]&&e.proxy(i.toolbarHandlers[a],t)(r,o,n,l),"link"!==a&&"reference-link"!==a&&"image"!==a&&"code-block"!==a&&"preformatted-text"!==a&&"watch"!==a&&"preview"!==a&&"search"!==a&&"fullscreen"!==a&&"info"!==a&&r.focus(),!1}),this},createDialog:function(i){return e.proxy(t.createDialog,this)(i)},createInfoDialog:function(){var e=this,i=this.editor,o=this.classPrefix,r=['
                  ','
                  ','

                  '+t.title+"v"+t.version+"

                  ","

                  "+this.lang.description+"

                  ",'

                  '+t.homePage+'

                  ','

                  Copyright © 2015-'+t.dateFormat("yyyy")+' Pandao, The MIT License.

                  ',"
                  ",'',"
                  "].join("\n");i.append(r);var a=this.infoDialog=i.children("."+o+"dialog-info");return a.find("."+o+"dialog-close").bind("click",function(){e.hideInfoDialog()}),a.css("border",t.isIE8?"1px solid #ddd":"").css("z-index",t.dialogZindex).show(),this.infoDialogPosition(),this},infoDialogPosition:function(){var t=this.infoDialog,i=function(){t.css({top:(e(window).height()-t.height())/2+"px",left:(e(window).width()-t.width())/2+"px"})};return i(),e(window).resize(i),this},showInfoDialog:function(){e("html,body").css("overflow-x","hidden");var i=this.editor,o=this.settings,r=this.infoDialog=i.children("."+this.classPrefix+"dialog-info");return r.length<1&&this.createInfoDialog(),this.lockScreen(!0),this.mask.css({opacity:o.dialogMaskOpacity,backgroundColor:o.dialogMaskBgColor}).show(),r.css("z-index",t.dialogZindex).show(),this.infoDialogPosition(),this},hideInfoDialog:function(){return e("html,body").css("overflow-x",""),this.infoDialog.hide(),this.mask.hide(),this.lockScreen(!1),this},lockScreen:function(e){return t.lockScreen(e),this.resize(),this},recreate:function(){var e=this.editor,t=this.settings;return this.codeMirror.remove(),this.setCodeMirror(),t.readOnly||(e.find(".editormd-dialog").length>0&&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"),void 0!==window.prettyPrint&&window.prettyPrint()),this},katexRender:function(){return null===i?this:(this.previewContainer.find("."+t.classNames.tex).each(function(){var i=e(this);t.$katex.render(i.text(),i[0]),i.find(".katex").css("font-size","1.6em")}),this)},flowChartAndSequenceDiagramRender:function(){var i=this,r=this.settings,a=this.previewContainer;if(t.isIE8)return this;if(r.flowChart){if(null===o)return this;a.find(".flowchart").flowChart()}r.sequenceDiagram&&a.find(".sequence-diagram").sequenceDiagram({theme:"simple"});var n=i.preview,s=i.codeMirror,l=s.find(".CodeMirror-scroll"),c=l.height(),h=l.scrollTop(),d=h/l[0].scrollHeight,u=0;n.find(".markdown-toc-list").each(function(){u+=e(this).height()});var f=n.find(".editormd-toc-menu").height();return f=f||0,0===h?n.scrollTop(0):h+c>=l[0].scrollHeight-16?n.scrollTop(n[0].scrollHeight):n.scrollTop((n[0].scrollHeight+u+f)*d),this},registerKeyMaps:function(i){var o=this,r=this.cm,a=this.settings,n=t.toolbarHandlers,s=a.disabledKeyMaps;if(i=i||null){for(var l in i)if(e.inArray(l,s)<0){var c={};c[l]=i[l],r.addKeyMap(i)}}else{for(var h in t.keyMaps){var d=t.keyMaps[h],u="string"==typeof d?e.proxy(n[d],o):e.proxy(d,o);if(e.inArray(h,["F9","F10","F11"])<0&&e.inArray(h,s)<0){var f={};f[h]=u,r.addKeyMap(f)}}e(window).keydown(function(t){var i={120:"F9",121:"F10",122:"F11"};if(e.inArray(i[t.keyCode],s)<0)switch(t.keyCode){case 120:e.proxy(n.watch,o)(),t.stopPropagation();break;case 121:e.proxy(n.preview,o)(),t.stopPropagation();break;case 122:e.proxy(n.fullscreen,o)(),t.stopPropagation()}})}return this},bindScrollEvent:function(){var i=this,o=this.preview,r=this.settings,a=this.codeMirror,n=t.mouseOrTouch;if(!r.syncScrolling)return this;var s=function(){a.find(".CodeMirror-scroll").bind(n("scroll","touchmove"),function(t){var a=e(this).height(),n=e(this).scrollTop(),s=n/e(this)[0].scrollHeight,l=0;o.find(".markdown-toc-list").each(function(){l+=e(this).height()});var c=o.find(".editormd-toc-menu").height();c=c||0,0===n?o.scrollTop(0):n+a>=e(this)[0].scrollHeight-16?o.scrollTop(o[0].scrollHeight):o.scrollTop((o[0].scrollHeight+l+c)*s),e.proxy(r.onscroll,i)(t)})},l=function(){a.find(".CodeMirror-scroll").unbind(n("scroll","touchmove"))},c=function(){o.bind(n("scroll","touchmove"),function(t){var o=e(this).height(),n=e(this).scrollTop(),s=n/e(this)[0].scrollHeight,l=a.find(".CodeMirror-scroll");0===n?l.scrollTop(0):n+o>=e(this)[0].scrollHeight?l.scrollTop(l[0].scrollHeight):l.scrollTop(l[0].scrollHeight*s),e.proxy(r.onpreviewscroll,i)(t)})},h=function(){o.unbind(n("scroll","touchmove"))};return a.bind({mouseover:s,mouseout:l,touchstart:s,touchend:l}),"single"===r.syncScrolling?this:(o.bind({mouseover:c,mouseout:h,touchstart:c,touchend:h}),this)},bindChangeEvent:function(){var e=this,t=this.cm,o=this.settings;return o.syncScrolling?(t.on("change",function(){o.watch&&e.previewContainer.css("padding",o.autoHeight?"20px 20px 50px 40px":"20px"),i=setTimeout(function(){clearTimeout(i),e.save(),i=null},o.delay)}),this):this},loadedDisplay:function(t){t=t||!1;var i=this,o=this.editor,r=this.preview,a=this.settings;return this.containerMask.hide(),this.save(),a.watch&&r.show(),o.data("oldWidth",o.width()).data("oldHeight",o.height()),this.resize(),this.registerKeyMaps(),e(window).resize(function(){i.resize()}),this.bindScrollEvent().bindChangeEvent(),t||e.proxy(a.onload,this)(),this.state.loaded=!0,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(t,i){t=t||null,i=i||null;var o=this.state,r=this.editor,a=this.preview,n=this.toolbar,s=this.settings,l=this.codeMirror;if(t&&r.css("width","number"==typeof t?t+"px":t),!s.autoHeight||o.fullscreen||o.preview?(i&&r.css("height","number"==typeof i?i+"px":i),o.fullscreen&&r.height(e(window).height()),s.toolbar&&!s.readOnly?l.css("margin-top",n.height()+1).height(r.height()-n.height()):l.css("margin-top",0).height(r.height())):(r.css("height","auto"),l.css("height","auto")),s.watch)if(l.width(r.width()/2-1),a.width(o.preview?r.width():r.width()/2),this.previewContainer.css("padding",s.autoHeight?"20px 20px 50px 40px":"20px"),s.toolbar&&!s.readOnly?a.css("top",n.height()+1):a.css("top",0),!s.autoHeight||o.fullscreen||o.preview){var c=s.toolbar&&!s.readOnly?r.height()-n.height():r.height();a.height(c)}else a.height("");else l.width(r.width()),a.hide();return o.loaded&&e.proxy(s.onresize,this)(),this},save:function(){if(null===i)return this;var r=this,a=this.state,n=this.settings,s=this.cm,l=s.getValue(),c=this.previewContainer;if("gfm"!==n.mode&&"markdown"!==n.mode)return this.markdownTextarea.val(l),this;var h=t.$marked,d=this.markdownToC=[],u=this.markedRendererOptions={toc:n.toc,tocm:n.tocm,tocStartLevel:n.tocStartLevel,pageBreak:n.pageBreak,taskList:n.taskList,emoji:n.emoji,tex:n.tex,atLink:n.atLink,emailLink:n.emailLink,flowChart:n.flowChart,sequenceDiagram:n.sequenceDiagram,previewCodeHighlight:n.previewCodeHighlight},f=this.markedOptions={renderer:t.markedRenderer(d,u),gfm:!0,tables:!0,breaks:!0,pedantic:!1,sanitize:!n.htmlDecode,smartLists:!0,smartypants:!0};h.setOptions(f);var g=t.$marked(l,f);if(g=t.filterHTMLTags(g,n.htmlDecode),this.markdownTextarea.text(l),s.save(),n.saveHTMLToTextarea&&this.htmlTextarea.text(g),n.watch||!n.watch&&a.preview){if(c.html(g),c.find(".task-list-item").each(function(){e(this).parent().addClass("task-list")}),this.previewCodeHighlight(),n.toc){var p=""===n.tocContainer?c:e(n.tocContainer),m=p.find("."+this.classPrefix+"toc-menu");p.attr("previewContainer",""===n.tocContainer?"true":"false"),""!==n.tocContainer&&m.length>0&&m.remove(),t.markdownToCRenderer(d,p,n.tocDropdown,n.tocStartLevel),(n.tocDropdown||p.find("."+this.classPrefix+"toc-menu").length>0)&&t.tocDropdownMenu(p,""!==n.tocTitle?n.tocTitle:this.lang.tocTitle),""!==n.tocContainer&&c.find(".markdown-toc").css("border","none")}n.tex&&(!t.kaTeXLoaded&&n.autoLoadModules?t.loadKaTeX(function(){t.$katex=katex,t.kaTeXLoaded=!0,r.katexRender()}):(t.$katex=katex,this.katexRender())),(n.flowChart||n.sequenceDiagram)&&(o=setTimeout(function(){clearTimeout(o),r.flowChartAndSequenceDiagramRender(),o=null},10)),a.loaded&&e.proxy(n.onchange,this)()}return 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){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(t){var o=this.settings;if(e.inArray(o.mode,["gfm","markdown"])<0)return this;if(this.state.watching=o.watch=!0,this.preview.show(),this.toolbar){var r=o.toolbarIconsClass.watch,a=o.toolbarIconsClass.unwatch,n=this.toolbar.find(".fa[name=watch]");n.parent().attr("title",o.lang.toolbar.watch),n.removeClass(a).addClass(r)}return this.codeMirror.css("border-right","1px solid #ddd").width(this.editor.width()/2),i=0,this.save().resize(),o.onwatch||(o.onwatch=t||function(){}),e.proxy(o.onwatch,this)(),this},unwatch:function(t){var i=this.settings;if(this.state.watching=i.watch=!1,this.preview.hide(),this.toolbar){var o=i.toolbarIconsClass.watch,r=i.toolbarIconsClass.unwatch,a=this.toolbar.find(".fa[name=watch]");a.parent().attr("title",i.lang.toolbar.unwatch),a.removeClass(o).addClass(r)}return this.codeMirror.css("border-right","none").width(this.editor.width()),this.resize(),i.onunwatch||(i.onunwatch=t||function(){}),e.proxy(i.onunwatch,this)(),this},show:function(t){t=t||function(){};var i=this;return this.editor.show(0,function(){e.proxy(t,i)()}),this},hide:function(t){t=t||function(){};var i=this;return this.editor.hide(0,function(){e.proxy(t,i)()}),this},destroy:function(){this.hide(),this.editor.remove()},previewing:function(){var t=this,i=this.editor,o=this.preview,r=this.toolbar,a=this.settings,n=this.codeMirror,s=this.previewContainer;if(e.inArray(a.mode,["gfm","markdown"])<0)return this;var l=this.editor.outerHeight();a.toolbar&&r&&(r.toggle(),r.find(".fa[name=preview]").toggleClass("active")),n.toggle();var c=function(e){e.shiftKey&&27===e.keyCode&&t.previewed()};"none"===n.css("display")?(this.state.preview=!0,this.settings.autoHeight&&this.editor.css("height",l),this.state.fullscreen&&o.css("background","#fff"),i.find("."+this.classPrefix+"preview-close-btn").show().bind("click",function(){t.previewed()}),a.watch?s.css("padding",""):this.save(),s.addClass(this.classPrefix+"preview-active"),o.show().css({position:"",top:0,width:i.width(),height:a.autoHeight&&!this.state.fullscreen?"auto":i.height()}),this.state.loaded&&e.proxy(a.onpreviewing,this)(),e(window).bind("keyup",c)):(e(window).unbind("keyup",c),this.previewed())},previewed:function(){var t=this.editor,i=this.preview,o=this.toolbar,r=this.settings,a=this.previewContainer,n=t.find("."+this.classPrefix+"preview-close-btn");return this.state.preview=!1,this.codeMirror.show(),r.toolbar&&o.show(),i[r.watch?"show":"hide"](),n.hide().unbind("click"),a.removeClass(this.classPrefix+"preview-active"),r.watch&&a.css("padding","20px"),this.settings.autoHeight&&this.editor.css("height","auto"),i.css({background:null,position:"absolute",width:t.width()/2,height:r.autoHeight&&!this.state.fullscreen?"auto":t.height()-o.height(),top:r.toolbar?o.height():0}),this.state.loaded&&e.proxy(r.onpreviewed,this)(),this},fullscreen:function(){var t=this,i=this.state,o=this.editor,r=this.toolbar,a=this.settings,n=this.classPrefix+"fullscreen";r&&r.find(".fa[name=fullscreen]").parent().toggleClass("active");var s=function(e){e.shiftKey||27!==e.keyCode||i.fullscreen&&t.fullscreenExit()};return o.hasClass(n)?(e(window).unbind("keyup",s),this.fullscreenExit()):(i.fullscreen=!0,e("html,body").css("overflow","hidden"),o.css({width:e(window).width(),height:e(window).height()}).addClass(n),this.resize(),e.proxy(a.onfullscreen,this)(),e(window).bind("keyup",s)),this},fullscreenExit:function(){var t=this.editor,i=this.settings,o=this.toolbar,r=this.classPrefix+"fullscreen";return this.state.fullscreen=!1,o&&o.find(".fa[name=fullscreen]").parent().removeClass("active"),e("html,body").css("overflow",""),t.css({width:t.data("oldWidth"),height:t.data("oldHeight")}).removeClass(r),this.resize(),e.proxy(i.onfullscreenExit,this)(),this},executePlugin:function(i,o){var r=this,a=this.cm;return o=this.settings.pluginPath+o,"function"==typeof define?void 0===this[i]?(alert("Error: "+i+" plugin is not found, you are not load this plugin."),this):(this[i](a),this):(e.inArray(o,t.loadFiles.plugin)<0?t.loadPlugin(o,function(){t.loadPlugins[i]=r[i],r[i](a)}):e.proxy(t.loadPlugins[i],this)(a),this)},search:function(e){var t=this.settings;return t.searchReplace?(t.readOnly||this.cm.execCommand(e||"find"),this):(alert("Error: settings.searchReplace == false"),this)},searchReplace:function(){return this.search("replace"),this},searchReplaceAll:function(){return this.search("replaceAll"),this}},t.fn.init.prototype=t.fn,t.dialogLockScreen=function(){(this.settings||{dialogLockScreen:!0}).dialogLockScreen&&(e("html,body").css("overflow","hidden"),this.resize())},t.dialogShowMask=function(t){var i=this.editor,o=this.settings||{dialogShowMask:!0};t.css({top:(e(window).height()-t.height())/2+"px",left:(e(window).width()-t.width())/2+"px"}),o.dialogShowMask&&i.children("."+this.classPrefix+"mask").css("z-index",parseInt(t.css("z-index"))-1).show()},t.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,i=e.getSelection(),o=e.listSelections();e.replaceSelection(t.firstUpperCase(i)),e.setSelections(o)},ucwords:function(){var e=this.cm,i=e.getSelection(),o=e.listSelections();e.replaceSelection(t.wordsFirstUpperCase(i)),e.setSelections(o)},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.getSelection(),i=e.listSelections();e.replaceSelection(t.toLowerCase()),e.setSelections(i)},h1: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)},h2: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+3)):e.replaceSelection("## "+i)},h3: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+4)):e.replaceSelection("### "+i)},h4: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+5)):e.replaceSelection("#### "+i)},h5: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+6)):e.replaceSelection("##### "+i)},h6: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+7)):e.replaceSelection("###### "+i)},"list-ul":function(){var e=this.cm,t=e.getSelection();if(""===t)e.replaceSelection("- "+t);else{for(var i=t.split("\n"),o=0,r=i.length;o'}else{var s=e.match(m),l=e.match(g);if(s)for(var c=0,h=s.length;c'}else{if(!l){var u="+1"===o?"plus1":o;return u="black_large_square"===u?"black_square":u,u="moon"===u?"waxing_gibbous_moon":u,':'+o+':'}for(var f=0,w=l.length;f'}}}});return e},l.atLink=function(i){return h.test(i)?(n.atLink&&(i=i.replace(u,function(e,t,i,o){return e.replace(/@/g,"_#_@_#_")}),i=i.replace(h,function(e,i){return''+e+""}).replace(/_#_@_#_/g,"@")),n.emailLink&&(i=i.replace(f,function(t,i,o,r,a){return!i&&e.inArray(a,"jpg|jpeg|png|gif|webp|ico|icon|pdf".split("|"))<0?''+t+"":t})),i):i},l.link=function(e,t,i){if(this.options.sanitize)try{if(0===decodeURIComponent(unescape(e)).replace(/[^\w:]/g,"").toLowerCase().indexOf("javascript:"))return""}catch(e){return""}var o=''+i.replace(/@/g,"@")+""):(t&&(o+=' title="'+t+'"'),o+=">"+i+"")},l.heading=function(e,t){var o=e,a=/\s*\]*)\>(.*)\<\/a\>\s*/;if(a.test(e)){var n=[];e=e.split(/\]+)\>([^\>]*)\<\/a\>/);for(var s=0,l=e.length;s';return f+='',f+='',f+=a?this.atLink(this.emoji(o)):this.atLink(this.emoji(e)),f+=""},l.pageBreak=function(e){return w.test(e)&&n.pageBreak&&(e='
                  '),e},l.paragraph=function(e){var i=/\$\$(.*)\$\$/g.test(e),o=/^\$\$(.*)\$\$$/.test(e),r=o?' class="'+t.classNames.tex+'"':"",a=n.tocm?/^(\[TOC\]|\[TOCM\])$/.test(e):/^\[TOC\]$/.test(e),s=/^\[TOCM\]$/.test(e);e=!o&&i?e.replace(/(\$\$([^\$]*)\$\$)+/g,function(e,i){return''+i.replace(/\$/g,"")+""}):o?e.replace(/\$/g,""):e;var l='
                  '+e+"
                  ";return a?s?'
                  '+l+"

                  ":l:w.test(e)?this.pageBreak(e):""+this.atLink(this.emoji(e))+"

                  \n"},l.code=function(e,i){return"seq"===i||"sequence"===i?'
                  '+e+"
                  ":"flow"===i?'
                  '+e+"
                  ":"math"===i||"latex"===i||"katex"===i?'

                  '+e+"

                  ":s.Renderer.prototype.code.apply(this,arguments)},l.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))+"\n"},l.listitem=function(e,t){return n.taskList&&t?(e=e.replace("'+this.atLink(this.emoji(e))+""):"
                • "+this.atLink(this.emoji(e))+"
                • "},l},t.markdownToCRenderer=function(e,t,i,o){var r="",a=0,n=this.classPrefix;o=o||1;for(var s=0,l=e.length;sa?"":h"):"
              • ",r+='
              • '+c+"
                  ",a=h)}var d=t.find(".markdown-toc");if(d.length<1&&"false"===t.attr("previewContainer")){var u='
                  ';u=i?'
                  '+u+"
                  ":u,t.html(u),d=t.find(".markdown-toc")}return i&&d.wrap('

                  '),d.html('
                    ').children(".markdown-toc-list").html(r.replace(/\r?\n?\\<\/ul\>/g,"")),d},t.tocDropdownMenu=function(t,i){i=i||"Table of Contents";var o=400,r=t.find("."+this.classPrefix+"toc-menu");return r.each(function(){var t=e(this),r=t.children(".markdown-toc"),a='',n=''+a+i+"",s=r.children("ul"),l=s.find("li");r.append(n),l.first().before("
                  • "+i+" "+a+"

                  • "),t.mouseover(function(){s.show(),l.each(function(){var t=e(this),i=t.children("ul");if(""===i.html()&&i.remove(),i.length>0&&""!==i.html()){var r=t.children("a").first();r.children(".fa").length<1&&r.append(e(a).css({float:"right",paddingTop:"4px"}))}t.mouseover(function(){i.css("z-index",o).show(),o+=1}).mouseleave(function(){i.hide()})})}).mouseleave(function(){s.hide()})}),r},t.filterHTMLTags=function(t,i){if("string"!=typeof t&&(t=t.toString()),"string"!=typeof i)return t;for(var o=i.split("|"),r=o[0].split(","),a=o[1],n=0,s=r.length;n]*)>([^>]*)","igm"),"")}if(void 0!==a){var c=/\<(\w+)\s*([^\>]*)\>([^\>]*)\<\/(\w+)\>/gi;t="*"===a?t.replace(c,function(e,t,i,o,r){return"<"+t+">"+o+""}):"on*"===a?t.replace(c,function(t,i,o,r,a){var n=e("<"+i+">"+r+""),s=e(t)[0].attributes,l={};e.each(s,function(e,t){'"'!==t.nodeName&&(l[t.nodeName]=t.nodeValue)}),e.each(l,function(e){0===e.indexOf("on")&&delete l[e]}),n.attr(l);var c=void 0!==n[1]?e(n[1]).text():"";return n[0].outerHTML+c}):t.replace(c,function(t,i,o,r){var n=a.split(","),s=e(t);return s.html(r),e.each(n,function(e){s.attr(n[e],null)}),s[0].outerHTML})}return t},t.markdownToHTML=function(i,o){var r={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};t.$marked=marked;var a=e("#"+i),n=a.settings=e.extend(!0,{},r,o||{}),s=a.find("textarea");s.length<1&&(a.append(""),s=a.find("textarea"));var l=""===n.markdown?s.val():n.markdown,c=[],h={toc:n.toc,tocm:n.tocm,tocStartLevel:n.tocStartLevel,taskList:n.taskList,emoji:n.emoji,tex:n.tex,pageBreak:n.pageBreak,atLink:n.atLink,emailLink:n.emailLink,flowChart:n.flowChart,sequenceDiagram:n.sequenceDiagram,previewCodeHighlight:n.previewCodeHighlight},d={renderer:t.markedRenderer(c,h),gfm:n.gfm,tables:!0,breaks:!0,pedantic:!1,sanitize:!n.htmlDecode,smartLists:!0,smartypants:!0};l=l.toString();var u=marked(l,d);u=t.filterHTMLTags(u,n.htmlDecode),n.markdownSourceCode?s.text(l):s.remove(),a.addClass("markdown-body "+this.classPrefix+"html-preview").append(u),a.find(".task-list-item").each(function(){e(this).parent().addClass("task-list")});var f=""!==n.tocContainer?e(n.tocContainer):a;if(""!==n.tocContainer&&f.attr("previewContainer",!1),n.toc&&(a.tocContainer=this.markdownToCRenderer(c,f,n.tocDropdown,n.tocStartLevel),(n.tocDropdown||a.find("."+this.classPrefix+"toc-menu").length>0)&&this.tocDropdownMenu(a,n.tocTitle),""!==n.tocContainer&&a.find(".editormd-toc-menu, .editormd-markdown-toc").remove()),n.previewCodeHighlight&&(a.find("pre").addClass("prettyprint linenums"),window.prettyPrint()),t.isIE8||(n.flowChart&&a.find(".flowchart").flowChart(),n.sequenceDiagram&&a.find(".sequence-diagram").sequenceDiagram({theme:"simple"})),n.tex){var g=function(){a.find("."+t.classNames.tex).each(function(){var t=e(this);katex.render(t.html().replace(/</g,"<").replace(/>/g,">"),t[0]),t.find(".katex").css("font-size","1.6em")})};!n.autoLoadKaTeX||t.$katex||t.kaTeXLoaded?g():this.loadKaTeX(function(){t.$katex=katex,t.kaTeXLoaded=!0,g()})}return a.getMarkdown=function(){return s.val()},a},t.themes=["default","dark"],t.previewThemes=["default","dark"],t.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"],t.loadPlugins={},t.loadFiles={js:[],css:[],plugin:[]},t.loadPlugin=function(e,i,o){i=i||function(){},this.loadScript(e,function(){t.loadFiles.plugin.push(e),i()},o)},t.loadCSS=function(e,i,o){o=o||"head",i=i||function(){};var r=document.createElement("link");r.type="text/css",r.rel="stylesheet",r.onload=r.onreadystatechange=function(){t.loadFiles.css.push(e),i()},r.href=e+".css","head"===o?document.getElementsByTagName("head")[0].appendChild(r):document.body.appendChild(r)},t.isIE="Microsoft Internet Explorer"===navigator.appName,t.isIE8=t.isIE&&"8."===navigator.appVersion.match(/8./i),t.loadScript=function(e,i,o){o=o||"head",i=i||function(){};var r=null;r=document.createElement("script"),r.id=e.replace(/[\.\/]+/g,"-"),r.type="text/javascript",r.src=e+".js",t.isIE8?r.onreadystatechange=function(){r.readyState&&("loaded"!==r.readyState&&"complete"!==r.readyState||(r.onreadystatechange=null,t.loadFiles.js.push(e),i()))}:r.onload=function(){t.loadFiles.js.push(e),i()},"head"===o?document.getElementsByTagName("head")[0].appendChild(r):document.body.appendChild(r)},t.katexURL={css:"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.1/katex.min",js:"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.1/katex.min"},t.kaTeXLoaded=!1,t.loadKaTeX=function(e){t.loadCSS(t.katexURL.css,function(){t.loadScript(t.katexURL.js,e||function(){})})},t.lockScreen=function(t){e("html,body").css("overflow",t?"hidden":"")},t.createDialog=function(i){var o={name:"",width:420,height:240,title:"",drag:!0,closed:!0,cached:!1,content:"",mask:!0,maskStyle:{backgroundColor:"#fff",opacity:.1},lockScreen:!0,footer:!0,buttons:!1};i=e.extend(!0,o,i);var r=this,a=this.editor,n=t.classPrefix,s=(new Date).getTime(),l=""===i.name?n+"dialog-"+s:i.name,c='
                    ';""!==i.title&&(c+='
                    ",c+=''+i.title+"",c+="
                    "),i.closed&&(c+=''),c+='
                    '+i.content,(i.footer||"string"==typeof i.footer)&&(c+='"),c+="
                    ",c+='
                    ',c+='
                    ',c+="
                    ",a.append(c);var h=a.find("."+l);h.lockScreen=function(t){return i.lockScreen&&(e("html,body").css("overflow",t?"hidden":""),r.resize()),h},h.showMask=function(){return i.mask&&a.find("."+n+"mask").css(i.maskStyle).css("z-index",t.dialogZindex-1).show(),h},h.hideMask=function(){return i.mask&&a.find("."+n+"mask").hide(),h},h.loading=function(e){return h.find("."+n+"dialog-mask")[e?"show":"hide"](),h},h.lockScreen(!0).showMask(),h.show().css({zIndex:t.dialogZindex,border:t.isIE8?"1px solid #ddd":"",width:"number"==typeof i.width?i.width+"px":i.width,height:"number"==typeof i.height?i.height+"px":i.height});var d=function(){h.css({top:(e(window).height()-h.height())/2+"px",left:(e(window).width()-h.width())/2+"px"})};if(d(),e(window).resize(d),h.children("."+n+"dialog-close").bind("click",function(){h.hide().lockScreen(!1).hideMask(),i.cached||h.remove()}),"object"==typeof i.buttons){var u=h.footer=h.find("."+n+"dialog-footer");for(var f in i.buttons){var g=i.buttons[f],p=n+f+"-btn";u.append('"),g[1]=e.proxy(g[1],h),u.children("."+p).bind("click",g[1])}}if(""!==i.title&&i.drag){var m,w,v=h.children("."+n+"dialog-header");i.mask||v.bind("click",function(){t.dialogZindex+=2,h.css("z-index",t.dialogZindex)});var k=function(e){e.removeClass(n+"user-unselect").off("selectstart")},b=function(e){e.addClass(n+"user-unselect").on("selectstart",function(){return!1})},x=function(t){t=t||window.event;var i,o,r=parseInt(h[0].style.left),a=parseInt(h[0].style.top);r>=0?r+h.width()<=e(window).width()?i=t.clientX-m:(i=e(window).width()-h.width(),document.onmousemove=null):(i=0,document.onmousemove=null),a>=0?o=t.clientY-w:(o=0,document.onmousemove=null),document.onselectstart=function(){return!1},b(e("body")),b(h),h[0].style.left=i+"px",h[0].style.top=o+"px"};v.mousedown(function(e){e=e||window.event,m=e.clientX-parseInt(h[0].style.left),w=e.clientY-parseInt(h[0].style.top),document.onmousemove=x}),document.onmouseup=function(){k(e("body")),k(h),document.onselectstart=null,document.onmousemove=null},v.touchDraggable=function(){var t=null,i=function(i){var o=i.originalEvent,r=e(this).parent().position();t={x:o.changedTouches[0].pageX-r.left,y:o.changedTouches[0].pageY-r.top}},o=function(i){i.preventDefault();var o=i.originalEvent;e(this).parent().css({top:o.changedTouches[0].pageY-t.y,left:o.changedTouches[0].pageX-t.x})};this.bind("touchstart",i).bind("touchmove",o)},v.touchDraggable()}return t.dialogZindex+=2,h},t.mouseOrTouch=function(e,t){e=e||"click",t=t||"touchend";var i=e;try{document.createEvent("TouchEvent"),i=t}catch(e){}return i},t.dateFormat=function(e){e=e||"";var t=function(e){return e<10?"0"+e:e},i=new Date,o=i.getFullYear(),r=o.toString().slice(2,4),a=t(i.getMonth()+1),n=t(i.getDate()),s=i.getDay(),l=t(i.getHours()),c=t(i.getMinutes()),h=t(i.getSeconds()),d=t(i.getMilliseconds()),u="",f=r+"-"+a+"-"+n,g=o+"-"+a+"-"+n,p=l+":"+c+":"+h;switch(e){case"UNIX Time":u=i.getTime();break;case"UTC":u=i.toUTCString();break;case"yy":u=r;break;case"year":case"yyyy":u=o;break;case"month":case"mm":u=a;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=n;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=g;break;case"yyyy-mm-dd h:i:s ms":case"full + ms":u=g+" "+p+" "+d;break;case"full":case"yyyy-mm-dd h:i:s":default:u=g+" "+p}return u},t}}); \ No newline at end of file diff --git a/examples/task-lists.html b/examples/task-lists.html index 644f9be..197f2c3 100644 --- a/examples/task-lists.html +++ b/examples/task-lists.html @@ -22,13 +22,13 @@ ### Examples - [x] @mentions, #refs, [links](), **formatting**, and tags supported; -- [x] list syntax required (any unordered or ordered list supported); +- [x] list syntax required (any unordered or ordered list supported); :heart: :blush: - [x] this is a complete item; - [ ] this is an incomplete item [test link](#); - [ ] this is an incomplete item; - [ ] this is an incomplete item [test link](#); - [ ] this is an incomplete item [test link](#); -- [x] list syntax required (any unordered or ordered list supported); +- [x] list syntax required (any unordered or ordered list supported); :smile: - [x] this is a complete item; - [ ] this is an incomplete item [test link](#); - [ ] this is an incomplete item; @@ -53,6 +53,7 @@ testEditor = editormd("test-editormd", { width : "90%", height : 720, + emoji : true, // enable for test taskList : true, path : '../lib/', htmlDebode : true, diff --git a/examples/use-zepto.html b/examples/use-zepto.html index ab434b0..7d1303b 100644 --- a/examples/use-zepto.html +++ b/examples/use-zepto.html @@ -59,7 +59,7 @@ htmlDecode : "style,script,iframe|on*", // 开启 HTML 标签解析,为了安全性,默认不开启 emoji : true, taskList : true, - tocm : true, // Using [TOCM] + tocm : true, // Using [TOCM] tex : true, // 开启科学公式 TeX 语言支持,默认关闭 //previewCodeHighlight : false, // 关闭预览窗口的代码高亮,默认开启 flowChart : true, diff --git a/lib/codemirror/addons.min.js b/lib/codemirror/addons.min.js index 7b10c5b..56764a4 100644 --- a/lib/codemirror/addons.min.js +++ b/lib/codemirror/addons.min.js @@ -1,2 +1,2 @@ /*! Editor.md v1.5.1 | /Applications/XAMPP/xamppfiles/htdocs/editor.md/lib/codemirror/addons.min.js | Open source online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2019-05-11 */ -!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){e.defineOption("showTrailingSpace",!1,function(t,i,o){o==e.Init&&(o=!1),o&&!i?t.removeOverlay("trailingspace"):!o&&i&&t.addOverlay({token:function(e){for(var t=e.string.length,i=t;i&&/\s/.test(e.string.charAt(i-1));--i);return i>e.pos?(e.pos=i,null):(e.pos=t,"trailingspace")},name:"trailingspace"})})}),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){function t(e,t,i){var o,r=e.getWrapperElement();return o=r.appendChild(document.createElement("div")),o.className=i?"CodeMirror-dialog CodeMirror-dialog-bottom":"CodeMirror-dialog CodeMirror-dialog-top","string"==typeof t?o.innerHTML=t:o.appendChild(t),o}function i(e,t){e.state.currentNotificationClose&&e.state.currentNotificationClose(),e.state.currentNotificationClose=t}e.defineExtension("openDialog",function(o,r,n){function a(e){if("string"==typeof e)d.value=e;else{if(c)return;c=!0,l.parentNode.removeChild(l),h.focus(),n.onClose&&n.onClose(l)}}n||(n={}),i(this,null);var s,l=t(this,o,n.bottom),c=!1,h=this,d=l.getElementsByTagName("input")[0];return d?(n.value&&(d.value=n.value,d.select()),n.onInput&&e.on(d,"input",function(e){n.onInput(e,d.value,a)}),n.onKeyUp&&e.on(d,"keyup",function(e){n.onKeyUp(e,d.value,a)}),e.on(d,"keydown",function(t){n&&n.onKeyDown&&n.onKeyDown(t,d.value,a)||((27==t.keyCode||!1!==n.closeOnEnter&&13==t.keyCode)&&(d.blur(),e.e_stop(t),a()),13==t.keyCode&&r(d.value,t))}),!1!==n.closeOnBlur&&e.on(d,"blur",a),d.focus()):(s=l.getElementsByTagName("button")[0])&&(e.on(s,"click",function(){a(),h.focus()}),!1!==n.closeOnBlur&&e.on(s,"blur",a),s.focus()),a}),e.defineExtension("openConfirm",function(o,r,n){function a(){c||(c=!0,s.parentNode.removeChild(s),h.focus())}i(this,null);var s=t(this,o,n&&n.bottom),l=s.getElementsByTagName("button"),c=!1,h=this,d=1;l[0].focus();for(var u=0;u-1)return h=i(l,c,h),{from:o(n.line,h),to:o(n.line,h+a.length)}}else{var l=e.getLine(n.line).slice(n.ch),c=s(l),h=c.indexOf(t);if(h>-1)return h=i(l,c,h)+n.ch,{from:o(n.line,h),to:o(n.line,h+a.length)}}}:this.matches=function(){};else{var c=a.split("\n");this.matches=function(t,i){var r=l.length-1;if(t){if(i.line-(l.length-1)=1;--h,--a)if(l[h]!=s(e.getLine(a)))return;var d=e.getLine(a),u=d.length-c[0].length;if(s(d.slice(u))!=l[0])return;return{from:o(a,u),to:n}}if(!(i.line+(l.length-1)>e.lastLine())){var d=e.getLine(i.line),u=d.length-c[0].length;if(s(d.slice(u))==l[0]){for(var f=o(i.line,u),a=i.line+1,h=1;hi))return o;--o}}}var o=e.Pos;t.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(e){function t(e){var t=o(e,0);return i.pos={from:t,to:t},i.atOccurrence=!1,!1}for(var i=this,r=this.doc.clipPos(e?this.pos.from:this.pos.to);;){if(this.pos=this.matches(e,r))return this.atOccurrence=!0,this.pos.match||!0;if(e){if(!r.line)return t(0);r=o(r.line-1,this.doc.getLine(r.line-1).length)}else{var n=this.doc.lineCount();if(r.line==n-1)return t(n);r=o(r.line+1,0)}}},from:function(){if(this.atOccurrence)return this.pos.from},to:function(){if(this.atOccurrence)return this.pos.to},replace:function(t){if(this.atOccurrence){var i=e.splitLines(t);this.doc.replaceRange(i,this.pos.from,this.pos.to),this.pos.to=o(this.pos.from.line+i.length-1,i[i.length-1].length+(1==i.length?this.pos.from.ch:0))}}},e.defineExtension("getSearchCursor",function(e,i,o){return new t(this.doc,e,i,o)}),e.defineDocExtension("getSearchCursor",function(e,i,o){return new t(this,e,i,o)}),e.defineExtension("selectMatches",function(t,i){for(var o=[],r=this.getSearchCursor(t,this.getCursor("from"),i);r.findNext()&&!(e.cmpPos(r.to(),this.getCursor("to"))>0);)o.push({anchor:r.from(),head:r.to()});o.length&&this.setSelections(o,0)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./searchcursor"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../dialog/dialog"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t){return"string"==typeof e?e=new RegExp(e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),t?"gi":"g"):e.global||(e=new RegExp(e.source,e.ignoreCase?"gi":"g")),{token:function(t){e.lastIndex=t.pos;var i=e.exec(t.string);if(i&&i.index==t.pos)return t.pos+=i[0].length,"searching";i?t.pos=i.index:t.skipToEnd()}}}function i(){this.posFrom=this.posTo=this.query=null,this.overlay=null}function o(e){return e.state.search||(e.state.search=new i)}function r(e){return"string"==typeof e&&e==e.toLowerCase()}function n(e,t,i){return e.getSearchCursor(t,i,r(t))}function a(e,t,i,o,r){e.openDialog?e.openDialog(t,r,{value:o}):r(prompt(i,o))}function s(e,t,i,o){e.openConfirm?e.openConfirm(t,o):confirm(i)&&o[0]()}function l(e){var t=e.match(/^\/(.*)\/([a-z]*)$/);if(t)try{e=new RegExp(t[1],-1==t[2].indexOf("i")?"":"i")}catch(e){}return("string"==typeof e?""==e:e.test(""))&&(e=/x^/),e}function c(e,i){var n=o(e);if(n.query)return h(e,i);a(e,f,"Search for:",e.getSelection(),function(o){e.operation(function(){o&&!n.query&&(n.query=l(o),e.removeOverlay(n.overlay,r(n.query)),n.overlay=t(n.query,r(n.query)),e.addOverlay(n.overlay),e.showMatchesOnScrollbar&&(n.annotate&&(n.annotate.clear(),n.annotate=null),n.annotate=e.showMatchesOnScrollbar(n.query,r(n.query))),n.posFrom=n.posTo=e.getCursor(),h(e,i))})})}function h(t,i){t.operation(function(){var r=o(t),a=n(t,r.query,i?r.posFrom:r.posTo);(a.find(i)||(a=n(t,r.query,i?e.Pos(t.lastLine()):e.Pos(t.firstLine(),0)),a.find(i)))&&(t.setSelection(a.from(),a.to()),t.scrollIntoView({from:a.from(),to:a.to()}),r.posFrom=a.from(),r.posTo=a.to())})}function d(e){e.operation(function(){var t=o(e);t.query&&(t.query=null,e.removeOverlay(t.overlay),t.annotate&&(t.annotate.clear(),t.annotate=null))})}function u(e,t){e.getOption("readOnly")||a(e,g,"Replace:",e.getSelection(),function(i){i&&(i=l(i),a(e,p,"Replace with:","",function(o){if(t)e.operation(function(){for(var t=n(e,i);t.findNext();)if("string"!=typeof i){var r=e.getRange(t.from(),t.to()).match(i);t.replace(o.replace(/\$(\d)/g,function(e,t){return r[t]}))}else t.replace(o)});else{d(e);var r=n(e,i,e.getCursor()),a=function(){var t,o=r.from();!(t=r.findNext())&&(r=n(e,i),!(t=r.findNext())||o&&r.from().line==o.line&&r.from().ch==o.ch)||(e.setSelection(r.from(),r.to()),e.scrollIntoView({from:r.from(),to:r.to()}),s(e,m,"Replace?",[function(){l(t)},a]))},l=function(e){r.replace("string"==typeof i?o:o.replace(/\$(\d)/g,function(t,i){return e[i]})),a()};a()}}))})}var f='Search: (Use /re/ syntax for regexp search)',g='Replace: (Use /re/ syntax for regexp search)',p='With: ',m="Replace? ";e.commands.find=function(e){d(e),c(e)},e.commands.findNext=c,e.commands.findPrev=function(e){c(e,!0)},e.commands.clearSearch=d,e.commands.replace=u,e.commands.replaceAll=function(e){u(e,!0)}}),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,t){function i(e){clearTimeout(o.doRedraw),o.doRedraw=setTimeout(function(){o.redraw()},e)}this.cm=e,this.options=t,this.buttonHeight=t.scrollButtonHeight||e.getOption("scrollButtonHeight"),this.annotations=[],this.doRedraw=this.doUpdate=null,this.div=e.getWrapperElement().appendChild(document.createElement("div")),this.div.style.cssText="position: absolute; right: 0; top: 0; z-index: 7; pointer-events: none",this.computeScale();var o=this;e.on("refresh",this.resizeHandler=function(){clearTimeout(o.doUpdate),o.doUpdate=setTimeout(function(){o.computeScale()&&i(20)},100)}),e.on("markerAdded",this.resizeHandler),e.on("markerCleared",this.resizeHandler),!1!==t.listenForChanges&&e.on("change",this.changeHandler=function(){i(250)})}e.defineExtension("annotateScrollbar",function(e){return"string"==typeof e&&(e={className:e}),new t(this,e)}),e.defineOption("scrollButtonHeight",0),t.prototype.computeScale=function(){var e=this.cm,t=(e.getWrapperElement().clientHeight-e.display.barHeight-2*this.buttonHeight)/e.heightAtLine(e.lastLine()+1,"local");if(t!=this.hScale)return this.hScale=t,!0},t.prototype.update=function(e){this.annotations=e,this.redraw()},t.prototype.redraw=function(e){!1!==e&&this.computeScale();var t=this.cm,i=this.hScale,o=document.createDocumentFragment(),r=this.annotations;if(t.display.barWidth)for(var n,a=0;ac+.9);)s=r[++a],c=t.charCoords(s.to,"local").bottom*i;if(c!=l){var h=Math.max(c-l,3),d=o.appendChild(document.createElement("div"));d.style.cssText="position: absolute; right: 0px; width: "+Math.max(t.display.barWidth-1,2)+"px; top: "+(l+this.buttonHeight)+"px; height: "+h+"px",d.className=this.options.className}}this.div.textContent="",this.div.appendChild(o)},t.prototype.clear=function(){this.cm.off("refresh",this.resizeHandler),this.cm.off("markerAdded",this.resizeHandler),this.cm.off("markerCleared",this.resizeHandler),this.changeHandler&&this.cm.off("change",this.changeHandler),this.div.parentNode.removeChild(this.div)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./searchcursor"),require("../scroll/annotatescrollbar")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../scroll/annotatescrollbar"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t,i,o){this.cm=e;var r={listenForChanges:!1};for(var n in o)r[n]=o[n];r.className||(r.className="CodeMirror-search-match"),this.annotation=e.annotateScrollbar(r),this.query=t,this.caseFold=i,this.gap={from:e.firstLine(),to:e.lastLine()+1},this.matches=[],this.update=null,this.findMatches(),this.annotation.update(this.matches);var a=this;e.on("change",this.changeHandler=function(e,t){a.onChange(t)})}function i(e,t,i){return e<=t?e:Math.max(t,e+i)}e.defineExtension("showMatchesOnScrollbar",function(e,i,o){return"string"==typeof o&&(o={className:o}),o||(o={}),new t(this,e,i,o)}),t.prototype.findMatches=function(){if(this.gap){for(var t=0;t=this.gap.to)break;i.to.line>=this.gap.from&&this.matches.splice(t--,1)}for(var o=this.cm.getSearchCursor(this.query,e.Pos(this.gap.from,0),this.caseFold);o.findNext();){var i={from:o.from(),to:o.to()};if(i.from.line>=this.gap.to)break;if(this.matches.splice(t++,0,i),this.matches.length>1e3)break}this.gap=null}},t.prototype.onChange=function(t){var o=t.from.line,r=e.changeEnd(t).line,n=r-t.to.line;if(this.gap?(this.gap.from=Math.min(i(this.gap.from,o,n),t.from.line),this.gap.to=Math.max(i(this.gap.to,o,n),t.from.line)):this.gap={from:t.from.line,to:r+1},n)for(var a=0;ac.ch&&(v=v.slice(0,v.length-h.end+c.ch));var w=v.toLowerCase();if(!v||"string"==h.type&&(h.end!=c.ch||!/[\"\']/.test(h.string.charAt(h.string.length-1))||1==h.string.length)||"tag"==h.type&&"closeTag"==u.type||h.string.indexOf("/")==h.string.length-1||p&&r(p,w)>-1||n(t,v,c,u,!0))return e.Pass;var b=m&&r(m,w)>-1;o[l]={indent:b,text:">"+(b?"\n\n":"")+"",newPos:b?e.Pos(c.line+1,0):e.Pos(c.line,c.ch+1)}}for(var l=i.length-1;l>=0;l--){var y=o[l];t.replaceRange(y.text,i[l].head,i[l].anchor,"+insert");var k=t.listSelections().slice(0);k[l]={head:y.newPos,anchor:y.newPos},t.setSelections(k),y.indent&&(t.indentLine(y.newPos.line,null,!0),t.indentLine(y.newPos.line+1,null,!0))}}function i(t,i){for(var o=t.listSelections(),r=[],a=i?"/":"";else{if("htmlmixed"!=t.getMode().name||"css"!=h.mode.name)return e.Pass;r[s]=a+"style>"}else{if(!d.context||!d.context.tagName||n(t,d.context.tagName,l,d))return e.Pass;r[s]=a+d.context.tagName+">"}}t.replaceSelections(r),o=t.listSelections();for(var s=0;s'"]=function(e){return t(e)}),i.addKeyMap(a)}});var a=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],s=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];e.commands.closeTag=function(e){return i(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";function t(t,r,n,a){function s(e){var i=l(t,r);if(!i||i.to.line-i.from.linet.firstLine();)r=e.Pos(r.line-1,0),h=s(!1);if(h&&!h.cleared&&"unfold"!==a){var d=i(t,n);e.on(d,"mousedown",function(t){u.clear(),e.e_preventDefault(t)});var u=t.markText(h.from,h.to,{replacedWith:d,clearOnEnter:!0,__isFold:!0});u.on("clear",function(i,o){e.signal(t,"unfold",t,i,o)}),e.signal(t,"fold",t,h.from,h.to)}}function i(e,t){var i=o(e,t,"widget");if("string"==typeof i){var r=document.createTextNode(i);i=document.createElement("span"),i.appendChild(r),i.className="CodeMirror-foldmarker"}return i}function o(e,t,i){if(t&&void 0!==t[i])return t[i];var o=e.options.foldOptions;return o&&void 0!==o[i]?o[i]:r[i]}e.newFoldFunction=function(e,i){return function(o,r){t(o,r,{rangeFinder:e,widget:i})}},e.defineExtension("foldCode",function(e,i,o){t(this,e,i,o)}),e.defineExtension("isFolded",function(e){for(var t=this.findMarksAt(e),i=0;i=s&&(i=r(n.indicatorOpen))}e.setGutterMarker(t,n.gutter,i),++a})}function a(e){var t=e.getViewport(),i=e.state.foldGutter;i&&(e.operation(function(){n(e,t.from,t.to)}),i.from=t.from,i.to=t.to)}function s(e,t,i){var o=e.state.foldGutter;if(o){var r=o.options;i==r.gutter&&e.foldCode(d(t,0),r.rangeFinder)}}function l(e){var t=e.state.foldGutter;if(t){var i=t.options;t.from=t.to=0,clearTimeout(t.changeUpdate),t.changeUpdate=setTimeout(function(){a(e)},i.foldOnChangeTimeSpan||600)}}function c(e){var t=e.state.foldGutter;if(t){var i=t.options;clearTimeout(t.changeUpdate),t.changeUpdate=setTimeout(function(){var i=e.getViewport();t.from==t.to||i.from-t.to>20||t.from-i.to>20?a(e):e.operation(function(){i.fromt.to&&(n(e,t.to,i.to),t.to=i.to)})},i.updateViewportTimeSpan||400)}}function h(e,t){var i=e.state.foldGutter;if(i){var o=t.line;o>=i.from&&oa)s=l;else if(/\S/.test(h))break}return s?{from:e.Pos(i.line,r.length),to:e.Pos(s,t.getLine(s).length)}:void 0}})}),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.registerHelper("fold","brace",function(t,i){function o(o){for(var r=i.ch,l=0;;){var c=r<=0?-1:s.lastIndexOf(o,r-1);if(-1!=c){if(1==l&&ct.lastLine())return null;var o=t.getTokenAt(e.Pos(i,1));if(/\S/.test(o.string)||(o=t.getTokenAt(e.Pos(i,o.end+1))),"keyword"!=o.type||"import"!=o.string)return null;for(var r=i,n=Math.min(t.lastLine(),i+10);r<=n;++r){var a=t.getLine(r),s=a.indexOf(";");if(-1!=s)return{startCh:o.end,end:e.Pos(r,s)}}}var r,i=i.line,n=o(i);if(!n||o(i-1)||(r=o(i-2))&&r.end.line==i-1)return null;for(var a=n.end;;){var s=o(a.line+1);if(null==s)break;a=s.end}return{from:t.clipPos(e.Pos(i,n.startCh+1)),to:a}}),e.registerHelper("fold","include",function(t,i){function o(i){if(it.lastLine())return null;var o=t.getTokenAt(e.Pos(i,1));return/\S/.test(o.string)||(o=t.getTokenAt(e.Pos(i,o.end+1))),"meta"==o.type&&"#include"==o.string.slice(0,8)?o.start+8:void 0}var i=i.line,r=o(i);if(null==r||null!=o(i-1))return null;for(var n=i;;){if(null==o(n+1))break;++n}return{from:e.Pos(i,r+1),to:t.clipPos(e.Pos(n))}})}),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,t){return e.line-t.line||e.ch-t.ch}function i(e,t,i,o){this.line=t,this.ch=i,this.cm=e,this.text=e.getLine(t),this.min=o?o.from:e.firstLine(),this.max=o?o.to-1:e.lastLine()}function o(e,t){var i=e.cm.getTokenTypeAt(u(e.line,t));return i&&/\btag\b/.test(i)}function r(e){if(!(e.line>=e.max))return e.ch=0,e.text=e.cm.getLine(++e.line),!0}function n(e){if(!(e.line<=e.min))return e.text=e.cm.getLine(--e.line),e.ch=e.text.length,!0}function a(e){for(;;){var t=e.text.indexOf(">",e.ch);if(-1==t){if(r(e))continue;return}{if(o(e,t+1)){var i=e.text.lastIndexOf("/",t),n=i>-1&&!/\S/.test(e.text.slice(i+1,t));return e.ch=t+1,n?"selfClose":"regular"}e.ch=t+1}}}function s(e){for(;;){var t=e.ch?e.text.lastIndexOf("<",e.ch-1):-1;if(-1==t){if(n(e))continue;return}if(o(e,t+1)){p.lastIndex=t,e.ch=t;var i=p.exec(e.text);if(i&&i.index==t)return i}else e.ch=t}}function l(e){for(;;){p.lastIndex=e.ch;var t=p.exec(e.text);if(!t){if(r(e))continue;return}{if(o(e,t.index+1))return e.ch=t.index+t[0].length,t;e.ch=t.index+1}}}function c(e){for(;;){var t=e.ch?e.text.lastIndexOf(">",e.ch-1):-1;if(-1==t){if(n(e))continue;return}{if(o(e,t+1)){var i=e.text.lastIndexOf("/",t),r=i>-1&&!/\S/.test(e.text.slice(i+1,t));return e.ch=t+1,r?"selfClose":"regular"}e.ch=t}}}function h(e,t){for(var i=[];;){var o,r=l(e),n=e.line,s=e.ch-(r?r[0].length:0);if(!r||!(o=a(e)))return;if("selfClose"!=o)if(r[1]){for(var c=i.length-1;c>=0;--c)if(i[c]==r[2]){i.length=c;break}if(c<0&&(!t||t==r[2]))return{tag:r[2],from:u(n,s),to:u(e.line,e.ch)}}else i.push(r[2])}}function d(e,t){for(var i=[];;){var o=c(e);if(!o)return;if("selfClose"!=o){var r=e.line,n=e.ch,a=s(e);if(!a)return;if(a[1])i.push(a[2]);else{for(var l=i.length-1;l>=0;--l)if(i[l]==a[2]){i.length=l;break}if(l<0&&(!t||t==a[2]))return{tag:a[2],from:u(e.line,e.ch),to:u(r,n)}}}else s(e)}}var u=e.Pos,f="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",g=f+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",p=new RegExp("<(/?)(["+f+"]["+g+"]*)","g");e.registerHelper("fold","xml",function(e,t){for(var o=new i(e,t.line,0);;){var r,n=l(o);if(!n||o.line!=t.line||!(r=a(o)))return;if(!n[1]&&"selfClose"!=r){var t=u(o.line,o.ch),s=h(o,n[2]);return s&&{from:t,to:s.from}}}}),e.findMatchingTag=function(e,o,r){var n=new i(e,o.line,o.ch,r);if(-1!=n.text.indexOf(">")||-1!=n.text.indexOf("<")){var l=a(n),c=l&&u(n.line,n.ch),f=l&&s(n);if(l&&f&&!(t(n,o)>0)){var g={from:u(n.line,n.ch),to:c,tag:f[2]};return"selfClose"==l?{open:g,close:null,at:"open"}:f[1]?{open:d(n,f[2]),close:g,at:"close"}:(n=new i(e,c.line,c.ch,r),{open:g,close:h(n,f[2]),at:"open"})}}},e.findEnclosingTag=function(e,t,o){for(var r=new i(e,t.line,t.ch,o);;){var n=d(r);if(!n)break;var a=new i(e,t.line,t.ch,o),s=h(a,n.tag);if(s)return{open:n,close:s}}},e.scanForClosingTag=function(e,t,o,r){return h(new i(e,t.line,t.ch,r?{from:0,to:r}:null),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";e.registerHelper("fold","markdown",function(t,i){function o(i){var o=t.getTokenTypeAt(e.Pos(i,0));return o&&/\bheader\b/.test(o)}function r(e,t,i){var r=t&&t.match(/^#+/);return r&&o(e)?r[0].length:(r=i&&i.match(/^[=\-]+\s*$/),r&&o(e+1)?"="==i[0]?1:2:n)}var n=100,a=t.getLine(i.line),s=t.getLine(i.line+1),l=r(i.line,a,s);if(l!==n){for(var c=t.lastLine(),h=i.line,d=t.getLine(h+2);h=i.ch+1)return/\bstring2?\b/.test(s);a.start=a.pos}}function o(o,r){for(var s={name:"autoCloseBrackets",Backspace:function(i){if(i.getOption("disableInput"))return e.Pass;for(var r=i.listSelections(),n=0;n=0;n--){var l=r[n].head;i.replaceRange("",a(l.line,l.ch-1),a(l.line,l.ch+1))}}},l="",c=0;c1&&r.indexOf(t)>=0&&s.getRange(a(p.line,p.ch-2),p)==t+t&&(p.ch<=2||s.getRange(a(p.line,p.ch-3),a(p.line,p.ch-2))!=t))f="addFour";else if('"'==t||"'"==t){if(e.isWordChar(h)||!i(s,p,t))return e.Pass;f="both"}else{if(!(s.getLine(p.line).length==p.ch||l.indexOf(h)>=0||n.test(h)))return e.Pass;f="both"}else f="surround";if(c){if(c!=f)return e.Pass}else c=f}s.operation(function(){if("skip"==c)s.execCommand("goCharRight");else if("skipThree"==c)for(var e=0;e<3;e++)s.execCommand("goCharRight");else if("surround"==c){for(var i=s.getSelections(),e=0;e=t.minChars&&e.addOverlay(t.overlay=a(d,!1,t.style))}})}function r(e,t,i){if(null!==e.getRange(t,i).match(/^\w+$/)){if(t.ch>0){var o={line:t.line,ch:t.ch-1},r=e.getRange(o,t);if(null===r.match(/\W/))return!1}if(i.che.pos?(e.pos=i,null):(e.pos=t,"trailingspace")},name:"trailingspace"})})}),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){function t(e,t,i){var o,r=e.getWrapperElement();return o=r.appendChild(document.createElement("div")),o.className=i?"CodeMirror-dialog CodeMirror-dialog-bottom":"CodeMirror-dialog CodeMirror-dialog-top","string"==typeof t?o.innerHTML=t:o.appendChild(t),o}function i(e,t){e.state.currentNotificationClose&&e.state.currentNotificationClose(),e.state.currentNotificationClose=t}e.defineExtension("openDialog",function(o,r,n){function a(e){if("string"==typeof e)d.value=e;else{if(c)return;c=!0,l.parentNode.removeChild(l),h.focus(),n.onClose&&n.onClose(l)}}n||(n={}),i(this,null);var s,l=t(this,o,n.bottom),c=!1,h=this,d=l.getElementsByTagName("input")[0];return d?(n.value&&(d.value=n.value,d.select()),n.onInput&&e.on(d,"input",function(e){n.onInput(e,d.value,a)}),n.onKeyUp&&e.on(d,"keyup",function(e){n.onKeyUp(e,d.value,a)}),e.on(d,"keydown",function(t){n&&n.onKeyDown&&n.onKeyDown(t,d.value,a)||((27==t.keyCode||!1!==n.closeOnEnter&&13==t.keyCode)&&(d.blur(),e.e_stop(t),a()),13==t.keyCode&&r(d.value,t))}),!1!==n.closeOnBlur&&e.on(d,"blur",a),d.focus()):(s=l.getElementsByTagName("button")[0])&&(e.on(s,"click",function(){a(),h.focus()}),!1!==n.closeOnBlur&&e.on(s,"blur",a),s.focus()),a}),e.defineExtension("openConfirm",function(o,r,n){function a(){c||(c=!0,s.parentNode.removeChild(s),h.focus())}i(this,null);var s=t(this,o,n&&n.bottom),l=s.getElementsByTagName("button"),c=!1,h=this,d=1;l[0].focus();for(var u=0;u-1)return h=i(l,c,h),{from:o(n.line,h),to:o(n.line,h+a.length)}}else{var l=e.getLine(n.line).slice(n.ch),c=s(l),h=c.indexOf(t);if(h>-1)return h=i(l,c,h)+n.ch,{from:o(n.line,h),to:o(n.line,h+a.length)}}}:this.matches=function(){};else{var c=a.split("\n");this.matches=function(t,i){var r=l.length-1;if(t){if(i.line-(l.length-1)=1;--h,--a)if(l[h]!=s(e.getLine(a)))return;var d=e.getLine(a),u=d.length-c[0].length;if(s(d.slice(u))!=l[0])return;return{from:o(a,u),to:n}}if(!(i.line+(l.length-1)>e.lastLine())){var d=e.getLine(i.line),u=d.length-c[0].length;if(s(d.slice(u))==l[0]){for(var f=o(i.line,u),a=i.line+1,h=1;hi))return o;--o}}}var o=e.Pos;t.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(e){function t(e){var t=o(e,0);return i.pos={from:t,to:t},i.atOccurrence=!1,!1}for(var i=this,r=this.doc.clipPos(e?this.pos.from:this.pos.to);;){if(this.pos=this.matches(e,r))return this.atOccurrence=!0,this.pos.match||!0;if(e){if(!r.line)return t(0);r=o(r.line-1,this.doc.getLine(r.line-1).length)}else{var n=this.doc.lineCount();if(r.line==n-1)return t(n);r=o(r.line+1,0)}}},from:function(){if(this.atOccurrence)return this.pos.from},to:function(){if(this.atOccurrence)return this.pos.to},replace:function(t){if(this.atOccurrence){var i=e.splitLines(t);this.doc.replaceRange(i,this.pos.from,this.pos.to),this.pos.to=o(this.pos.from.line+i.length-1,i[i.length-1].length+(1==i.length?this.pos.from.ch:0))}}},e.defineExtension("getSearchCursor",function(e,i,o){return new t(this.doc,e,i,o)}),e.defineDocExtension("getSearchCursor",function(e,i,o){return new t(this,e,i,o)}),e.defineExtension("selectMatches",function(t,i){for(var o=[],r=this.getSearchCursor(t,this.getCursor("from"),i);r.findNext()&&!(e.cmpPos(r.to(),this.getCursor("to"))>0);)o.push({anchor:r.from(),head:r.to()});o.length&&this.setSelections(o,0)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./searchcursor"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../dialog/dialog"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t){return"string"==typeof e?e=new RegExp(e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),t?"gi":"g"):e.global||(e=new RegExp(e.source,e.ignoreCase?"gi":"g")),{token:function(t){e.lastIndex=t.pos;var i=e.exec(t.string);if(i&&i.index==t.pos)return t.pos+=i[0].length,"searching";i?t.pos=i.index:t.skipToEnd()}}}function i(){this.posFrom=this.posTo=this.query=null,this.overlay=null}function o(e){return e.state.search||(e.state.search=new i)}function r(e){return"string"==typeof e&&e==e.toLowerCase()}function n(e,t,i){return e.getSearchCursor(t,i,r(t))}function a(e,t,i,o,r){e.openDialog?e.openDialog(t,r,{value:o}):r(prompt(i,o))}function s(e,t,i,o){e.openConfirm?e.openConfirm(t,o):confirm(i)&&o[0]()}function l(e){var t=e.match(/^\/(.*)\/([a-z]*)$/);if(t)try{e=new RegExp(t[1],-1==t[2].indexOf("i")?"":"i")}catch(e){}return("string"==typeof e?""==e:e.test(""))&&(e=/x^/),e}function c(e,i){var n=o(e);if(n.query)return h(e,i);a(e,f,"Search for:",e.getSelection(),function(o){e.operation(function(){o&&!n.query&&(n.query=l(o),e.removeOverlay(n.overlay,r(n.query)),n.overlay=t(n.query,r(n.query)),e.addOverlay(n.overlay),e.showMatchesOnScrollbar&&(n.annotate&&(n.annotate.clear(),n.annotate=null),n.annotate=e.showMatchesOnScrollbar(n.query,r(n.query))),n.posFrom=n.posTo=e.getCursor(),h(e,i))})})}function h(t,i){t.operation(function(){var r=o(t),a=n(t,r.query,i?r.posFrom:r.posTo);(a.find(i)||(a=n(t,r.query,i?e.Pos(t.lastLine()):e.Pos(t.firstLine(),0)),a.find(i)))&&(t.setSelection(a.from(),a.to()),t.scrollIntoView({from:a.from(),to:a.to()}),r.posFrom=a.from(),r.posTo=a.to())})}function d(e){e.operation(function(){var t=o(e);t.query&&(t.query=null,e.removeOverlay(t.overlay),t.annotate&&(t.annotate.clear(),t.annotate=null))})}function u(e,t){e.getOption("readOnly")||a(e,g,"Replace:",e.getSelection(),function(i){i&&(i=l(i),a(e,p,"Replace with:","",function(o){if(t)e.operation(function(){for(var t=n(e,i);t.findNext();)if("string"!=typeof i){var r=e.getRange(t.from(),t.to()).match(i);t.replace(o.replace(/\$(\d)/g,function(e,t){return r[t]}))}else t.replace(o)});else{d(e);var r=n(e,i,e.getCursor()),a=function(){var t,o=r.from();!(t=r.findNext())&&(r=n(e,i),!(t=r.findNext())||o&&r.from().line==o.line&&r.from().ch==o.ch)||(e.setSelection(r.from(),r.to()),e.scrollIntoView({from:r.from(),to:r.to()}),s(e,m,"Replace?",[function(){l(t)},a]))},l=function(e){r.replace("string"==typeof i?o:o.replace(/\$(\d)/g,function(t,i){return e[i]})),a()};a()}}))})}var f='Search: (Use /re/ syntax for regexp search)',g='Replace: (Use /re/ syntax for regexp search)',p='With: ',m="Replace? ";e.commands.find=function(e){d(e),c(e)},e.commands.findNext=c,e.commands.findPrev=function(e){c(e,!0)},e.commands.clearSearch=d,e.commands.replace=u,e.commands.replaceAll=function(e){u(e,!0)}}),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,t){function i(e){clearTimeout(o.doRedraw),o.doRedraw=setTimeout(function(){o.redraw()},e)}this.cm=e,this.options=t,this.buttonHeight=t.scrollButtonHeight||e.getOption("scrollButtonHeight"),this.annotations=[],this.doRedraw=this.doUpdate=null,this.div=e.getWrapperElement().appendChild(document.createElement("div")),this.div.style.cssText="position: absolute; right: 0; top: 0; z-index: 7; pointer-events: none",this.computeScale();var o=this;e.on("refresh",this.resizeHandler=function(){clearTimeout(o.doUpdate),o.doUpdate=setTimeout(function(){o.computeScale()&&i(20)},100)}),e.on("markerAdded",this.resizeHandler),e.on("markerCleared",this.resizeHandler),!1!==t.listenForChanges&&e.on("change",this.changeHandler=function(){i(250)})}e.defineExtension("annotateScrollbar",function(e){return"string"==typeof e&&(e={className:e}),new t(this,e)}),e.defineOption("scrollButtonHeight",0),t.prototype.computeScale=function(){var e=this.cm,t=(e.getWrapperElement().clientHeight-e.display.barHeight-2*this.buttonHeight)/e.heightAtLine(e.lastLine()+1,"local");if(t!=this.hScale)return this.hScale=t,!0},t.prototype.update=function(e){this.annotations=e,this.redraw()},t.prototype.redraw=function(e){!1!==e&&this.computeScale();var t=this.cm,i=this.hScale,o=document.createDocumentFragment(),r=this.annotations;if(t.display.barWidth)for(var n,a=0;ac+.9);)s=r[++a],c=t.charCoords(s.to,"local").bottom*i;if(c!=l){var h=Math.max(c-l,3),d=o.appendChild(document.createElement("div"));d.style.cssText="position: absolute; right: 0px; width: "+Math.max(t.display.barWidth-1,2)+"px; top: "+(l+this.buttonHeight)+"px; height: "+h+"px",d.className=this.options.className}}this.div.textContent="",this.div.appendChild(o)},t.prototype.clear=function(){this.cm.off("refresh",this.resizeHandler),this.cm.off("markerAdded",this.resizeHandler),this.cm.off("markerCleared",this.resizeHandler),this.changeHandler&&this.cm.off("change",this.changeHandler),this.div.parentNode.removeChild(this.div)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./searchcursor"),require("../scroll/annotatescrollbar")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../scroll/annotatescrollbar"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t,i,o){this.cm=e;var r={listenForChanges:!1};for(var n in o)r[n]=o[n];r.className||(r.className="CodeMirror-search-match"),this.annotation=e.annotateScrollbar(r),this.query=t,this.caseFold=i,this.gap={from:e.firstLine(),to:e.lastLine()+1},this.matches=[],this.update=null,this.findMatches(),this.annotation.update(this.matches);var a=this;e.on("change",this.changeHandler=function(e,t){a.onChange(t)})}function i(e,t,i){return e<=t?e:Math.max(t,e+i)}e.defineExtension("showMatchesOnScrollbar",function(e,i,o){return"string"==typeof o&&(o={className:o}),o||(o={}),new t(this,e,i,o)}),t.prototype.findMatches=function(){if(this.gap){for(var t=0;t=this.gap.to)break;i.to.line>=this.gap.from&&this.matches.splice(t--,1)}for(var o=this.cm.getSearchCursor(this.query,e.Pos(this.gap.from,0),this.caseFold);o.findNext();){var i={from:o.from(),to:o.to()};if(i.from.line>=this.gap.to)break;if(this.matches.splice(t++,0,i),this.matches.length>1e3)break}this.gap=null}},t.prototype.onChange=function(t){var o=t.from.line,r=e.changeEnd(t).line,n=r-t.to.line;if(this.gap?(this.gap.from=Math.min(i(this.gap.from,o,n),t.from.line),this.gap.to=Math.max(i(this.gap.to,o,n),t.from.line)):this.gap={from:t.from.line,to:r+1},n)for(var a=0;ac.ch&&(v=v.slice(0,v.length-h.end+c.ch));var w=v.toLowerCase();if(!v||"string"==h.type&&(h.end!=c.ch||!/[\"\']/.test(h.string.charAt(h.string.length-1))||1==h.string.length)||"tag"==h.type&&"closeTag"==u.type||h.string.indexOf("/")==h.string.length-1||p&&r(p,w)>-1||n(t,v,c,u,!0))return e.Pass;var b=m&&r(m,w)>-1;o[l]={indent:b,text:">"+(b?"\n\n":"")+"",newPos:b?e.Pos(c.line+1,0):e.Pos(c.line,c.ch+1)}}for(var l=i.length-1;l>=0;l--){var k=o[l];t.replaceRange(k.text,i[l].head,i[l].anchor,"+insert");var y=t.listSelections().slice(0);y[l]={head:k.newPos,anchor:k.newPos},t.setSelections(y),k.indent&&(t.indentLine(k.newPos.line,null,!0),t.indentLine(k.newPos.line+1,null,!0))}}function i(t,i){for(var o=t.listSelections(),r=[],a=i?"/":"";else{if("htmlmixed"!=t.getMode().name||"css"!=h.mode.name)return e.Pass;r[s]=a+"style>"}else{if(!d.context||!d.context.tagName||n(t,d.context.tagName,l,d))return e.Pass;r[s]=a+d.context.tagName+">"}}t.replaceSelections(r),o=t.listSelections();for(var s=0;s'"]=function(e){return t(e)}),i.addKeyMap(a)}});var a=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],s=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];e.commands.closeTag=function(e){return i(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";function t(t,r,n,a){function s(e){var i=l(t,r);if(!i||i.to.line-i.from.linet.firstLine();)r=e.Pos(r.line-1,0),h=s(!1);if(h&&!h.cleared&&"unfold"!==a){var d=i(t,n);e.on(d,"mousedown",function(t){u.clear(),e.e_preventDefault(t)});var u=t.markText(h.from,h.to,{replacedWith:d,clearOnEnter:!0,__isFold:!0});u.on("clear",function(i,o){e.signal(t,"unfold",t,i,o)}),e.signal(t,"fold",t,h.from,h.to)}}function i(e,t){var i=o(e,t,"widget");if("string"==typeof i){var r=document.createTextNode(i);i=document.createElement("span"),i.appendChild(r),i.className="CodeMirror-foldmarker"}return i}function o(e,t,i){if(t&&void 0!==t[i])return t[i];var o=e.options.foldOptions;return o&&void 0!==o[i]?o[i]:r[i]}e.newFoldFunction=function(e,i){return function(o,r){t(o,r,{rangeFinder:e,widget:i})}},e.defineExtension("foldCode",function(e,i,o){t(this,e,i,o)}),e.defineExtension("isFolded",function(e){for(var t=this.findMarksAt(e),i=0;i=s&&(i=r(n.indicatorOpen))}e.setGutterMarker(t,n.gutter,i),++a})}function a(e){var t=e.getViewport(),i=e.state.foldGutter;i&&(e.operation(function(){n(e,t.from,t.to)}),i.from=t.from,i.to=t.to)}function s(e,t,i){var o=e.state.foldGutter;if(o){var r=o.options;i==r.gutter&&e.foldCode(d(t,0),r.rangeFinder)}}function l(e){var t=e.state.foldGutter;if(t){var i=t.options;t.from=t.to=0,clearTimeout(t.changeUpdate),t.changeUpdate=setTimeout(function(){a(e)},i.foldOnChangeTimeSpan||600)}}function c(e){var t=e.state.foldGutter;if(t){var i=t.options;clearTimeout(t.changeUpdate),t.changeUpdate=setTimeout(function(){var i=e.getViewport();t.from==t.to||i.from-t.to>20||t.from-i.to>20?a(e):e.operation(function(){i.fromt.to&&(n(e,t.to,i.to),t.to=i.to)})},i.updateViewportTimeSpan||400)}}function h(e,t){var i=e.state.foldGutter;if(i){var o=t.line;o>=i.from&&oa)s=l;else if(/\S/.test(h))break}return s?{from:e.Pos(i.line,r.length),to:e.Pos(s,t.getLine(s).length)}:void 0}})}),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.registerHelper("fold","brace",function(t,i){function o(o){for(var r=i.ch,l=0;;){var c=r<=0?-1:s.lastIndexOf(o,r-1);if(-1!=c){if(1==l&&ct.lastLine())return null;var o=t.getTokenAt(e.Pos(i,1));if(/\S/.test(o.string)||(o=t.getTokenAt(e.Pos(i,o.end+1))),"keyword"!=o.type||"import"!=o.string)return null;for(var r=i,n=Math.min(t.lastLine(),i+10);r<=n;++r){var a=t.getLine(r),s=a.indexOf(";");if(-1!=s)return{startCh:o.end,end:e.Pos(r,s)}}}var r,i=i.line,n=o(i);if(!n||o(i-1)||(r=o(i-2))&&r.end.line==i-1)return null;for(var a=n.end;;){var s=o(a.line+1);if(null==s)break;a=s.end}return{from:t.clipPos(e.Pos(i,n.startCh+1)),to:a}}),e.registerHelper("fold","include",function(t,i){function o(i){if(it.lastLine())return null;var o=t.getTokenAt(e.Pos(i,1));return/\S/.test(o.string)||(o=t.getTokenAt(e.Pos(i,o.end+1))),"meta"==o.type&&"#include"==o.string.slice(0,8)?o.start+8:void 0}var i=i.line,r=o(i);if(null==r||null!=o(i-1))return null;for(var n=i;;){if(null==o(n+1))break;++n}return{from:e.Pos(i,r+1),to:t.clipPos(e.Pos(n))}})}),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,t){return e.line-t.line||e.ch-t.ch}function i(e,t,i,o){this.line=t,this.ch=i,this.cm=e,this.text=e.getLine(t),this.min=o?o.from:e.firstLine(),this.max=o?o.to-1:e.lastLine()}function o(e,t){var i=e.cm.getTokenTypeAt(u(e.line,t));return i&&/\btag\b/.test(i)}function r(e){if(!(e.line>=e.max))return e.ch=0,e.text=e.cm.getLine(++e.line),!0}function n(e){if(!(e.line<=e.min))return e.text=e.cm.getLine(--e.line),e.ch=e.text.length,!0}function a(e){for(;;){var t=e.text.indexOf(">",e.ch);if(-1==t){if(r(e))continue;return}{if(o(e,t+1)){var i=e.text.lastIndexOf("/",t),n=i>-1&&!/\S/.test(e.text.slice(i+1,t));return e.ch=t+1,n?"selfClose":"regular"}e.ch=t+1}}}function s(e){for(;;){var t=e.ch?e.text.lastIndexOf("<",e.ch-1):-1;if(-1==t){if(n(e))continue;return}if(o(e,t+1)){p.lastIndex=t,e.ch=t;var i=p.exec(e.text);if(i&&i.index==t)return i}else e.ch=t}}function l(e){for(;;){p.lastIndex=e.ch;var t=p.exec(e.text);if(!t){if(r(e))continue;return}{if(o(e,t.index+1))return e.ch=t.index+t[0].length,t;e.ch=t.index+1}}}function c(e){for(;;){var t=e.ch?e.text.lastIndexOf(">",e.ch-1):-1;if(-1==t){if(n(e))continue;return}{if(o(e,t+1)){var i=e.text.lastIndexOf("/",t),r=i>-1&&!/\S/.test(e.text.slice(i+1,t));return e.ch=t+1,r?"selfClose":"regular"}e.ch=t}}}function h(e,t){for(var i=[];;){var o,r=l(e),n=e.line,s=e.ch-(r?r[0].length:0);if(!r||!(o=a(e)))return;if("selfClose"!=o)if(r[1]){for(var c=i.length-1;c>=0;--c)if(i[c]==r[2]){i.length=c;break}if(c<0&&(!t||t==r[2]))return{tag:r[2],from:u(n,s),to:u(e.line,e.ch)}}else i.push(r[2])}}function d(e,t){for(var i=[];;){var o=c(e);if(!o)return;if("selfClose"!=o){var r=e.line,n=e.ch,a=s(e);if(!a)return;if(a[1])i.push(a[2]);else{for(var l=i.length-1;l>=0;--l)if(i[l]==a[2]){i.length=l;break}if(l<0&&(!t||t==a[2]))return{tag:a[2],from:u(e.line,e.ch),to:u(r,n)}}}else s(e)}}var u=e.Pos,f="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",g=f+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",p=new RegExp("<(/?)(["+f+"]["+g+"]*)","g");e.registerHelper("fold","xml",function(e,t){for(var o=new i(e,t.line,0);;){var r,n=l(o);if(!n||o.line!=t.line||!(r=a(o)))return;if(!n[1]&&"selfClose"!=r){var t=u(o.line,o.ch),s=h(o,n[2]);return s&&{from:t,to:s.from}}}}),e.findMatchingTag=function(e,o,r){var n=new i(e,o.line,o.ch,r);if(-1!=n.text.indexOf(">")||-1!=n.text.indexOf("<")){var l=a(n),c=l&&u(n.line,n.ch),f=l&&s(n);if(l&&f&&!(t(n,o)>0)){var g={from:u(n.line,n.ch),to:c,tag:f[2]};return"selfClose"==l?{open:g,close:null,at:"open"}:f[1]?{open:d(n,f[2]),close:g,at:"close"}:(n=new i(e,c.line,c.ch,r),{open:g,close:h(n,f[2]),at:"open"})}}},e.findEnclosingTag=function(e,t,o){for(var r=new i(e,t.line,t.ch,o);;){var n=d(r);if(!n)break;var a=new i(e,t.line,t.ch,o),s=h(a,n.tag);if(s)return{open:n,close:s}}},e.scanForClosingTag=function(e,t,o,r){return h(new i(e,t.line,t.ch,r?{from:0,to:r}:null),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";e.registerHelper("fold","markdown",function(t,i){function o(i){var o=t.getTokenTypeAt(e.Pos(i,0));return o&&/\bheader\b/.test(o)}function r(e,t,i){var r=t&&t.match(/^#+/);return r&&o(e)?r[0].length:(r=i&&i.match(/^[=\-]+\s*$/),r&&o(e+1)?"="==i[0]?1:2:n)}var n=100,a=t.getLine(i.line),s=t.getLine(i.line+1),l=r(i.line,a,s);if(l!==n){for(var c=t.lastLine(),h=i.line,d=t.getLine(h+2);h=i.ch+1)return/\bstring2?\b/.test(s);a.start=a.pos}}function o(o,r){for(var s={name:"autoCloseBrackets",Backspace:function(i){if(i.getOption("disableInput"))return e.Pass;for(var r=i.listSelections(),n=0;n=0;n--){var l=r[n].head;i.replaceRange("",a(l.line,l.ch-1),a(l.line,l.ch+1))}}},l="",c=0;c1&&r.indexOf(t)>=0&&s.getRange(a(p.line,p.ch-2),p)==t+t&&(p.ch<=2||s.getRange(a(p.line,p.ch-3),a(p.line,p.ch-2))!=t))f="addFour";else if('"'==t||"'"==t){if(e.isWordChar(h)||!i(s,p,t))return e.Pass;f="both"}else{if(!(s.getLine(p.line).length==p.ch||l.indexOf(h)>=0||n.test(h)))return e.Pass;f="both"}else f="surround";if(c){if(c!=f)return e.Pass}else c=f}s.operation(function(){if("skip"==c)s.execCommand("goCharRight");else if("skipThree"==c)for(var e=0;e<3;e++)s.execCommand("goCharRight");else if("surround"==c){for(var i=s.getSelections(),e=0;e=t.minChars&&e.addOverlay(t.overlay=a(d,!1,t.style))}})}function r(e,t,i){if(null!==e.getRange(t,i).match(/^\w+$/)){if(t.ch>0){var o={line:t.line,ch:t.ch-1},r=e.getRange(o,t);if(null===r.match(/\W/))return!1}if(i.ch\n"; }; - markedRenderer.listitem = function(text) { - if (settings.taskList && /^\s*\[[x\s]\]\s*/.test(text)) - { - text = text.replace(/^\s*\[\s\]\s*/, " ") - .replace(/^\s*\[x\]\s*/, " "); + markedRenderer.listitem = function(text, task) { + if (settings.taskList && task) { + text = text.replace("" + this.atLink(this.emoji(text)) + ""; - } - else - { + return "
                  • " + this.atLink(this.emoji(text)) + "
                  • "; + } else { return "
                  • " + this.atLink(this.emoji(text)) + "
                  • "; } }; @@ -3966,6 +3966,10 @@ } div.addClass("markdown-body " + this.classPrefix + "html-preview").append(markdownParsed); + + div.find(".task-list-item").each(function () { + $(this).parent().addClass("task-list"); + }); var tocContainer = (settings.tocContainer !== "") ? $(settings.tocContainer) : div;