-
Notifications
You must be signed in to change notification settings - Fork 0
/
editormd.amd.min.js
2 lines (2 loc) · 55.8 KB
/
editormd.amd.min.js
1
2
/*! Editor.md v2.0.1 | editormd.amd.min.js | Open source online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2018-03-29 */
"use strict";function _defineProperty(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(e){if("function"==typeof require&&"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"object"===("undefined"==typeof module?"undefined":_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(){var e;"function"==typeof define&&define.amd&&(t=arguments[0],marked=arguments[1],prettify=arguments[2],katex=arguments[3],Raphael=arguments[4],_=arguments[5],flowchart=arguments[6],CodeMirror=arguments[9]);var t="undefined"!=typeof jQuery?jQuery:Zepto;if(void 0!==t){var i=function e(t,i){return new e.fn.init(t,i)};i.title=i.$name="Editor.md",i.version="1.5.0",i.homePage="https://pandao.github.io/editor.md/",i.classPrefix="editormd-",i.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"]},i.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,minHeight:"150px",maxHeight:"none",autoFocus:!0,autoCloseTags:!0,searchReplace:!0,syncScrolling:!0,readOnly:!1,tabSize:4,indentUnit:4,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,showTrailingSpace:!0,matchBrackets:!0,indentWithTabs:!0,styleSelectedText:!0,matchWordHighlight:!0,styleActiveLine:!0,dialogLockScreen:!0,dialogShowMask:!0,dialogDraggable:!0,dialogMaskBgColor:"#fff",dialogMaskOpacity:.1,fontSize:"13px",saveHTMLToTextarea:!1,disabledKeyMaps:[],onload:function(){},onresize:function(){},onchange:function(){},onwatch:null,onunwatch:null,onpreviewing:function(){},onpreviewed:function(){},onfullscreen:function(){},onfullscreenExit:function(){},onscroll:function(){},onpreviewscroll:function(){},imageUpload:!1,imageFormats:["jpg","jpeg","gif","png","bmp","webp"],imageUploadURL:"",crossDomainUpload:!1,uploadCallbackURL:"",toc:!0,tocm:!1,tocTitle:"",tocDropdown:!1,tocContainer:"",tocStartLevel:1,htmlDecode:!1,pageBreak:!0,atLink:!0,emailLink:!0,taskList:!1,emoji:!1,tex:!1,flowChart:!1,sequenceDiagram:!1,previewCodeHighlight:!0,toolbar:!0,toolbarAutoFixed:!0,toolbarIcons:"full",toolbarTitles:{},toolbarHandlers:{ucwords:function(){return i.toolbarHandlers.ucwords},lowercase:function(){return i.toolbarHandlers.lowercase}},toolbarCustomIcons:{lowercase:'<a href="javascript:;" title="Lowercase" unselectable="on"><i class="fa" name="lowercase" style="font-size:24px;margin-top: -10px;">a</i></a>',ucwords:'<a href="javascript:;" title="ucwords" unselectable="on"><i class="fa" name="ucwords" style="font-size:20px;margin-top: -3px;">Aa</i></a>'},toolbarIconsClass:{undo:"fa-undo",redo:"fa-repeat",bold:"fa-bold",del:"fa-strikethrough",italic:"fa-italic",quote:"fa-quote-left",uppercase:"fa-font",h1:i.classPrefix+"bold",h2:i.classPrefix+"bold",h3:i.classPrefix+"bold",h4:i.classPrefix+"bold",h5:i.classPrefix+"bold",h6:i.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编辑器<br/>Open source online Markdown editor.",tocTitle:"目录",toolbar:{undo:"撤销(Ctrl+Z)",redo:"重做(Ctrl+Y)",bold:"粗体",del:"删除线",italic:"斜体",quote:"引用",ucwords:"将每个单词首字母转成大写",uppercase:"将所选转换成大写",lowercase:"将所选转换成小写",h1:"标题1",h2:"标题2",h3:"标题3",h4:"标题4",h5:"标题5",h6:"标题6","list-ul":"无序列表","list-ol":"有序列表",hr:"横线",link:"链接","reference-link":"引用链接",image:"添加图片",code:"行内代码","preformatted-text":"预格式文本 / 代码块(缩进风格)","code-block":"代码块(多语言风格)",table:"添加表格",datetime:"日期时间",emoji:"Emoji表情","html-entities":"HTML实体字符",pagebreak:"插入分页符","goto-line":"跳转到行",watch:"关闭实时预览",unwatch:"开启实时预览",preview:"全窗口预览HTML(按 Shift + ESC还原)",fullscreen:"全屏(按ESC还原)",clear:"清空",search:"搜索",help:"使用帮助",info:"关于"+i.title},buttons:{enter:"确定",cancel:"取消",close:"关闭"},dialog:{link:{title:"添加链接",url:"链接地址",urlTitle:"链接标题",urlEmpty:"错误:请填写链接地址。"},referenceLink:{title:"添加引用链接",name:"引用名称",url:"链接地址",urlId:"链接ID",urlTitle:"链接标题",nameEmpty:"错误:引用链接的名称不能为空。",idEmpty:"错误:请填写引用链接的ID。",urlEmpty:"错误:请填写引用链接的URL地址。"},image:{title:"添加图片",url:"图片地址",link:"图片链接",alt:"图片描述",uploadButton:"本地上传",imageURLEmpty:"错误:图片地址不能为空。",uploadFileEmpty:"错误:上传的图片不能为空。",formatNotAllowed:"错误:只允许上传图片文件,允许上传的图片文件格式有:"},preformattedText:{title:"添加预格式文本或代码块",emptyAlert:"错误:请填写预格式文本或代码的内容。"},codeBlock:{title:"添加代码块",selectLabel:"代码语言:",selectDefaultText:"请选择代码语言",otherLanguage:"其他语言",unselectedLanguageAlert:"错误:请选择代码所属的语言类型。",codeEmptyAlert:"错误:请填写代码内容。"},htmlEntities:{title:"HTML 实体字符"},help:{title:"使用帮助"}}}},i.classNames={tex:i.classPrefix+"tex"},i.dialogZindex=99999,i.$katex=null,i.$marked=null,i.$CodeMirror=null,i.$prettyPrint=null;var o,r;i.prototype=i.fn={state:{watching:!1,loaded:!1,preview:!1,fullscreen:!1},init:function(e,o){o=o||{},"object"===_typeof(e)&&(o=e);var r=this.classPrefix=i.classPrefix,n=this.settings=t.extend(!0,i.defaults,o);e="object"===_typeof(e)?n.id:e;var a=this.editor=t("#"+e);this.id=e,this.lang=n.lang;var s=this.classNames={textarea:{html:r+"html-textarea",markdown:r+"markdown-textarea"}};n.pluginPath=""===n.pluginPath?n.path+"../plugins/":n.pluginPath,this.state.watching=!!n.watch,a.hasClass("editormd")||a.addClass("editormd"),a.css({width:"number"==typeof n.width?n.width+"px":n.width,height:"number"==typeof n.height?n.height+"px":n.height}),n.autoHeight&&a.css({height:"auto",minHeight:n.minHeight});var l=this.markdownTextarea=a.children("textarea");l.length<1&&(a.append("<textarea></textarea>"),l=this.markdownTextarea=a.children("textarea")),l.addClass(s.textarea.markdown).attr("placeholder",n.placeholder),void 0!==l.attr("name")&&""!==l.attr("name")||l.attr("name",""!==n.name?n.name:e+"-markdown-doc");var c=[n.readOnly?"":'<a href="javascript:;" class="fa fa-close '+r+'preview-close-btn"></a>',n.saveHTMLToTextarea?'<textarea class="'+s.textarea.html+'" name="'+e+'-html-code"></textarea>':"",'<div class="'+r+'preview"><div class="markdown-body '+r+'preview-container"></div></div>','<div class="'+r+'container-mask" style="display:block;"></div>','<div class="'+r+'mask"></div>'].join("\n");return a.append(c).addClass(r+"vertical"),""!==n.theme&&a.addClass(r+"theme-"+n.theme),this.mask=a.children("."+r+"mask"),this.containerMask=a.children("."+r+"container-mask"),""!==n.markdown&&l.val(n.markdown),""!==n.appendMarkdown&&l.val(l.val()+n.appendMarkdown),this.htmlTextarea=a.children("."+s.textarea.html),this.preview=a.children("."+r+"preview"),this.previewContainer=this.preview.children("."+r+"preview-container"),""!==n.previewTheme&&this.preview.addClass(r+"preview-theme-"+n.previewTheme),"function"==typeof define&&define.amd&&("undefined"!=typeof katex&&(i.$katex=katex),n.searchReplace&&!n.readOnly&&(i.loadCSS(n.path+"codemirror/addon/dialog/dialog"),i.loadCSS(n.path+"codemirror/addon/search/matchesonscrollbar"))),"function"==typeof define&&define.amd||!n.autoLoadModules?("undefined"!=typeof CodeMirror&&(i.$CodeMirror=CodeMirror),"undefined"!=typeof marked&&(i.$marked=marked),this.setCodeMirror().setToolbar().loadedDisplay()):this.loadQueues(),this},loadQueues:function(){var e=this,t=this.settings,o=t.path,r=function(){if(i.isIE8)return void e.loadedDisplay();t.flowChart||t.sequenceDiagram?i.loadScript(o+"raphael.min",function(){i.loadScript(o+"underscore.min",function(){!t.flowChart&&t.sequenceDiagram?i.loadScript(o+"sequence-diagram.min",function(){e.loadedDisplay()}):t.flowChart&&!t.sequenceDiagram?i.loadScript(o+"flowchart.min",function(){i.loadScript(o+"jquery.flowchart.min",function(){e.loadedDisplay()})}):t.flowChart&&t.sequenceDiagram&&i.loadScript(o+"flowchart.min",function(){i.loadScript(o+"jquery.flowchart.min",function(){i.loadScript(o+"sequence-diagram.min",function(){e.loadedDisplay()})})})})}):e.loadedDisplay()};return i.loadCSS(o+"codemirror/codemirror.min"),t.searchReplace&&!t.readOnly&&(i.loadCSS(o+"codemirror/addon/dialog/dialog"),i.loadCSS(o+"codemirror/addon/search/matchesonscrollbar")),t.codeFold&&i.loadCSS(o+"codemirror/addon/fold/foldgutter"),i.loadScript(o+"codemirror/codemirror.min",function(){i.$CodeMirror=CodeMirror,i.loadScript(o+"codemirror/modes.min",function(){i.loadScript(o+"codemirror/addons.min",function(){if(e.setCodeMirror(),"gfm"!==t.mode&&"markdown"!==t.mode)return e.loadedDisplay(),!1;e.setToolbar(),i.loadScript(o+"marked.min",function(){i.$marked=marked,t.previewCodeHighlight?i.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 t=this.settings;return t.editorTheme=e,"default"!==e&&i.loadCSS(t.path+"codemirror/theme/"+t.editorTheme),this.cm.setOption("theme",e),this},setCodeMirrorTheme:function(e){return this.setEditorTheme(e),this},setPreviewTheme:function(e){var t=this.preview,i=this.settings.previewTheme,o=this.classPrefix+"preview-theme-";return t.removeClass(o+i).addClass(o+e),this.settings.previewTheme=e,this},setCodeMirror:function(){var e=this.settings,t=this.editor;"default"!==e.editorTheme&&i.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=i.$CodeMirror.fromTextArea(this.markdownTextarea[0],o),this.codeMirror=this.cmElement=t.children(".CodeMirror"),""!==e.value&&this.cm.setValue(e.value),this.codeMirror.css({fontSize:e.fontSize,width:e.watch?"50%":"100%"}),e.autoHeight&&(this.codeMirror.css({height:"auto",minHeight:e.minHeight,maxHeight:e.maxHeight}),this.codeMirror.find(".CodeMirror-gutters").css({minHeight:e.minHeight}),this.codeMirror.find(".CodeMirror-scroll").css({minHeight:e.minHeight,maxHeight:e.maxHeight}),this.cm.setOption("viewportMargin",1/0)),e.lineNumbers||this.codeMirror.find(".CodeMirror-gutters").css("border-right","none"),this},getCodeMirrorOption:function(e){return this.cm.getOption(e)},setCodeMirrorOption:function(e,t){return this.cm.setOption(e,t),this},addKeyMap:function(e,t){return this.cm.addKeyMap(e,t),this},removeKeyMap:function(e){return this.cm.removeKeyMap(e),this},gotoLine:function(e){var i=this.settings;if(!i.gotoLine)return this;var o=this.cm,r=(this.editor,o.lineCount()),n=this.preview;if("string"==typeof e&&("last"===e&&(e=r),"first"===e&&(e=1)),"number"!=typeof e)return alert("Error: The line number must be an integer."),this;if((e=parseInt(e)-1)>r)return alert("Error: The line number range 1-"+r),this;o.setCursor({line:e,ch:0});var a=o.getScrollInfo(),s=a.clientHeight,l=o.charCoords({line:e,ch:0},"local");if(o.scrollTo(null,(l.top+l.bottom-s)/2),i.watch){var c=this.codeMirror.find(".CodeMirror-scroll")[0],h=t(c).height(),d=c.scrollTop,u=d/c.scrollHeight;0===d?n.scrollTop(0):d+h>=c.scrollHeight-16?n.scrollTop(n[0].scrollHeight):n.scrollTop(n[0].scrollHeight*u)}return o.focus(),this},extend:function(){return void 0!==arguments[1]&&("function"==typeof arguments[1]&&(arguments[1]=t.proxy(arguments[1],this)),this[arguments[0]]=arguments[1]),"object"===_typeof(arguments[0])&&void 0===arguments[0].length&&t.extend(!0,this,arguments[0]),this},set:function(e,i){return void 0!==i&&"function"==typeof i&&(i=t.proxy(i,this)),this[e]=i,this},config:function(e,i){var o=this.settings;return"object"===_typeof(e)&&(o=t.extend(!0,o,e)),"string"==typeof e&&(o[e]=i),this.settings=o,this.recreate(),this},on:function(e,i){var o=this.settings;return void 0!==o["on"+e]&&(o["on"+e]=t.proxy(i,this)),this},off:function(e){var t=this.settings;return void 0!==t["on"+e]&&(t["on"+e]=function(){}),this},showToolbar:function(e){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(),t.proxy(e||function(){},this)(),this)},hideToolbar:function(e){return this.settings.toolbar=!1,this.toolbar.hide(),this.resize(),t.proxy(e||function(){},this)(),this},setToolbarAutoFixed:function(e){var i=this.state,o=this.editor,r=this.toolbar,n=this.settings;void 0!==e&&(n.toolbarAutoFixed=e);var a=function(){var e=t(window),i=e.scrollTop();if(!n.toolbarAutoFixed)return!1;i-o.offset().top>10&&i<o.height()?r.css({position:"fixed",width:o.width()+"px",left:(e.width()-o.width())/2+"px"}):r.css({position:"absolute",width:"100%",left:0})};return!i.fullscreen&&!i.preview&&n.toolbar&&n.toolbarAutoFixed&&t(window).bind("scroll",a),this},setToolbar:function(){var e=this.settings;if(e.readOnly)return this;var t=this.editor,o=(this.preview,this.classPrefix),r=this.toolbar=t.children("."+o+"toolbar");if(e.toolbar&&r.length<1){var n='<div class="'+o+'toolbar"><div class="'+o+'toolbar-container"><ul class="'+o+'menu"></ul></div></div>';t.append(n),r=this.toolbar=t.children("."+o+"toolbar")}if(!e.toolbar)return r.hide(),this;r.show();for(var a="function"==typeof e.toolbarIcons?e.toolbarIcons():"string"==typeof e.toolbarIcons?i.toolbarModes[e.toolbarIcons]:e.toolbarIcons,s=r.find("."+this.classPrefix+"menu"),l="",c=!1,h=0,d=a.length;h<d;h++){var u=a[h];if("||"===u)c=!0;else if("|"===u)l+='<li class="divider" unselectable="on">|</li>';else{var f=/h(\d)/.test(u),p=u;"watch"!==u||e.watch||(p="unwatch");var g=e.lang.toolbar[p],m=e.toolbarIconTexts[p],w=e.toolbarIconsClass[p];g=void 0===g?"":g,m=void 0===m?"":m,w=void 0===w?"":w;var v=c?'<li class="pull-right">':"<li>";void 0!==e.toolbarCustomIcons[u]&&"function"!=typeof e.toolbarCustomIcons[u]?v+=e.toolbarCustomIcons[u]:(v+='<a href="javascript:;" title="'+g+'" unselectable="on">',v+='<i class="fa '+w+'" name="'+u+'" unselectable="on">'+(f?u.toUpperCase():""===w?m:"")+"</i>",v+="</a>"),v+="</li>",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 t.proxy(i.dialogLockScreen,this)(),this},dialogShowMask:function(e){return t.proxy(i.dialogShowMask,this)(e),this},getToolbarHandles:function(e){var t=this.toolbarHandlers=i.toolbarHandlers;return e&&void 0!==toolbarIconHandlers[e]?t[e]:t},setToolbarHandler:function(){var e=this,o=this.settings;if(!o.toolbar||o.readOnly)return this;var r=this.toolbar,n=this.cm,a=this.classPrefix,s=this.toolbarIcons=r.find("."+a+"menu > li > a"),l=this.getToolbarHandles();return s.bind(i.mouseOrTouch("click","touchend"),function(i){var r=t(this).children(".fa"),a=r.attr("name"),s=n.getCursor(),c=n.getSelection();if(""!==a)return e.activeIcon=r,void 0!==l[a]?t.proxy(l[a],e)(n):void 0!==o.toolbarHandlers[a]&&t.proxy(o.toolbarHandlers[a],e)(n,r,s,c),"link"!==a&&"reference-link"!==a&&"image"!==a&&"code-block"!==a&&"preformatted-text"!==a&&"watch"!==a&&"preview"!==a&&"search"!==a&&"fullscreen"!==a&&"info"!==a&&n.focus(),!1}),this},createDialog:function(e){return t.proxy(i.createDialog,this)(e)},createInfoDialog:function(){var e=this,t=this.editor,o=this.classPrefix,r=['<div class="'+o+"dialog "+o+'dialog-info" style="">','<div class="'+o+'dialog-container">','<h1><i class="editormd-logo editormd-logo-lg editormd-logo-color"></i> '+i.title+"<small>v"+i.version+"</small></h1>","<p>"+this.lang.description+"</p>",'<p style="margin: 10px 0 20px 0;"><a href="'+i.homePage+'" target="_blank">'+i.homePage+' <i class="fa fa-external-link"></i></a></p>','<p style="font-size: 0.85em;">Copyright © 2015 <a href="https://github.com/pandao" target="_blank" class="hover-link">Pandao</a>, The <a href="https://github.com/pandao/editor.md/blob/master/LICENSE" target="_blank" class="hover-link">MIT</a> License.</p>',"</div>",'<a href="javascript:;" class="fa fa-close '+o+'dialog-close"></a>',"</div>"].join("\n");t.append(r);var n=this.infoDialog=t.children("."+o+"dialog-info");return n.find("."+o+"dialog-close").bind(i.mouseOrTouch("click","touchend"),function(){e.hideInfoDialog()}),n.css("border",i.isIE8?"1px solid #ddd":"").css("z-index",i.dialogZindex).show(),this.infoDialogPosition(),this},infoDialogPosition:function(){var e=this.infoDialog,i=function(){e.css({top:(t(window).height()-e.height())/2+"px",left:(t(window).width()-e.width())/2+"px"})};return i(),t(window).resize(i),this},showInfoDialog:function(){t("html,body").css("overflow-x","hidden");var e=this.editor,o=this.settings,r=this.infoDialog=e.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",i.dialogZindex).show(),this.infoDialogPosition(),this},hideInfoDialog:function(){return t("html,body").css("overflow-x",""),this.infoDialog.hide(),this.mask.hide(),this.lockScreen(!1),this},lockScreen:function(e){return i.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"),"undefined"!=typeof prettyPrint&&prettyPrint()),this},katexRender:function(){return null===o?this:(this.previewContainer.find("."+i.classNames.tex).each(function(){var e=t(this);i.$katex.render(e.text(),e[0]),e.find(".katex").css("font-size","1.6em")}),this)},flowChartAndSequenceDiagramRender:function(){var e=this,o=this.settings,n=this.previewContainer;if(i.isIE8)return this;if(o.flowChart){if(null===r)return this;n.find(".flowchart").flowChart()}o.sequenceDiagram&&n.find(".sequence-diagram").sequenceDiagram({theme:"simple"});var a=e.preview,s=e.codeMirror,l=s.find(".CodeMirror-scroll"),c=l.height(),h=l.scrollTop(),d=h/l[0].scrollHeight,u=0;a.find(".markdown-toc-list").each(function(){u+=t(this).height()});var f=a.find(".editormd-toc-menu").height();return f=f||0,o.syncScrolling&&(0===h?a.scrollTop(0):h+c>=l[0].scrollHeight-16?a.scrollTop(a[0].scrollHeight):a.scrollTop((a[0].scrollHeight+u+f)*d)),this},registerKeyMaps:function(e){var o=this,r=this.cm,n=this.settings,a=i.toolbarHandlers,s=n.disabledKeyMaps;if(e=e||null){for(var l in e)if(t.inArray(l,s)<0){var c={};c[l]=e[l],r.addKeyMap(e)}}else{for(var h in i.keyMaps){var d=i.keyMaps[h],u="string"==typeof d?t.proxy(a[d],o):t.proxy(d,o);if(t.inArray(h,["F9","F10","F11"])<0&&t.inArray(h,s)<0){var f={};f[h]=u,r.addKeyMap(f)}}t(window).keydown(function(e){var i={120:"F9",121:"F10",122:"F11"};if(t.inArray(i[e.keyCode],s)<0)switch(e.keyCode){case 120:return t.proxy(a.watch,o)(),!1;case 121:return t.proxy(a.preview,o)(),!1;case 122:return t.proxy(a.fullscreen,o)(),!1}})}return this},bindScrollEvent:function(){var e=this,o=this.preview,r=this.settings,n=this.codeMirror,a=i.mouseOrTouch;if(!r.syncScrolling)return this;var s=function(){n.find(".CodeMirror-scroll").bind(a("scroll","touchmove"),function(i){var n=t(this).height(),a=t(this).scrollTop(),s=a/t(this)[0].scrollHeight,l=0;o.find(".markdown-toc-list").each(function(){l+=t(this).height()});var c=o.find(".editormd-toc-menu").height();c=c||0,0===a?o.scrollTop(0):a+n>=t(this)[0].scrollHeight-16?o.scrollTop(o[0].scrollHeight):o.scrollTop((o[0].scrollHeight+l+c)*s),t.proxy(r.onscroll,e)(i)})},l=function(){n.find(".CodeMirror-scroll").unbind(a("scroll","touchmove"))},c=function(){o.bind(a("scroll","touchmove"),function(i){var o=t(this).height(),a=t(this).scrollTop(),s=a/t(this)[0].scrollHeight,l=n.find(".CodeMirror-scroll");0===a?l.scrollTop(0):a+o>=t(this)[0].scrollHeight?l.scrollTop(l[0].scrollHeight):l.scrollTop(l[0].scrollHeight*s),t.proxy(r.onpreviewscroll,e)(i)})},h=function(){o.unbind(a("scroll","touchmove"))};return n.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,i=this.settings;return t.on("change",function(t,r){i.watch&&e.previewContainer.css("padding",i.autoHeight?"20px 20px 50px 40px":"20px"),o=setTimeout(function(){clearTimeout(o),e.save(),o=null},i.delay)}),this},loadedDisplay:function(e){e=e||!1;var i=this,o=this.editor,r=this.preview,n=this.settings;return this.containerMask.hide(),this.save(),n.watch&&r.show(),o.data("oldWidth",o.width()).data("oldHeight",o.height()),this.resize(),this.registerKeyMaps(),t(window).resize(function(){i.resize()}),this.bindScrollEvent().bindChangeEvent(),e||t.proxy(n.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(e,i){e=e||null,i=i||null;var o=this.state,r=this.editor,n=this.preview,a=this.toolbar,s=this.settings,l=this.codeMirror;if(e&&r.css("width","number"==typeof e?e+"px":e),!s.autoHeight||o.fullscreen||o.preview?(i&&r.css("height","number"==typeof i?i+"px":i),o.fullscreen&&r.height(t(window).height()),s.toolbar&&!s.readOnly?l.css("margin-top",a.height()+1).height(r.height()-a.height()):l.css("margin-top",0).height(r.height())):(r.css({height:"auto",minHeight:s.minHeight}),l.css({height:"auto",minHeight:s.minHeight,maxHeight:s.maxHeight})),s.watch)if(l.width(r.width()/2),n.width(o.preview?r.width():r.width()/2),this.previewContainer.css("padding",s.autoHeight?"20px 20px 50px 40px":"20px"),s.toolbar&&!s.readOnly?n.css("top",a.height()+1):n.css("top",0),!s.autoHeight||o.fullscreen||o.preview){var c=s.toolbar&&!s.readOnly?r.height()-a.height():r.height();n.height(c)}else n.height("");else l.width(r.width()),n.hide();return o.loaded&&t.proxy(s.onresize,this)(),this},save:function(){if(null===o)return this;var e=this,n=this.state,a=this.settings,s=this.cm,l=s.getValue(),c=this.previewContainer;if("gfm"!==a.mode&&"markdown"!==a.mode)return this.markdownTextarea.val(l),this;var h=i.$marked,d=this.markdownToC=[],u=this.markedRendererOptions={toc:a.toc,tocm:a.tocm,tocStartLevel:a.tocStartLevel,pageBreak:a.pageBreak,taskList:a.taskList,emoji:a.emoji,tex:a.tex,atLink:a.atLink,emailLink:a.emailLink,flowChart:a.flowChart,sequenceDiagram:a.sequenceDiagram,previewCodeHighlight:a.previewCodeHighlight},f=this.markedOptions={renderer:i.markedRenderer(d,u),gfm:!0,tables:!0,breaks:!0,pedantic:!1,sanitize:!a.htmlDecode,smartLists:!0,smartypants:!0};h.setOptions(f);var p=i.$marked(l,f);if(p=i.filterHTMLTags(p,a.htmlDecode),this.markdownTextarea.text(l),s.save(),a.saveHTMLToTextarea&&this.htmlTextarea.text(p),a.watch||!a.watch&&n.preview){if(c.html(p),this.previewCodeHighlight(),a.toc){var g=""===a.tocContainer?c:t(a.tocContainer),m=g.find("."+this.classPrefix+"toc-menu");g.attr("previewContainer",""===a.tocContainer?"true":"false"),""!==a.tocContainer&&m.length>0&&m.remove(),i.markdownToCRenderer(d,g,a.tocDropdown,a.tocStartLevel),(a.tocDropdown||g.find("."+this.classPrefix+"toc-menu").length>0)&&i.tocDropdownMenu(g,""!==a.tocTitle?a.tocTitle:this.lang.tocTitle),""!==a.tocContainer&&c.find(".markdown-toc").css("border","none")}a.tex&&(!i.kaTeXLoaded&&a.autoLoadModules?i.loadKaTeX(function(){i.$katex=katex,i.kaTeXLoaded=!0,e.katexRender()}):(i.$katex=katex,this.katexRender())),(a.flowChart||a.sequenceDiagram)&&(r=setTimeout(function(){clearTimeout(r),e.flowChartAndSequenceDiagramRender(),r=null},10)),n.loaded&&t.proxy(a.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.settings,this.cm);return t.setValue(t.getValue()+e),this},setMarkdown:function(e){return this.cm.setValue(e||this.settings.markdown),this},getMarkdown:function(){return this.cm.getValue()},getValue:function(){return this.cm.getValue()},setValue:function(e){return this.cm.setValue(e),this},clear:function(){return this.cm.setValue(""),this},getHTML:function(){return this.settings.saveHTMLToTextarea?this.htmlTextarea.val():(alert("Error: settings.saveHTMLToTextarea == false"),!1)},getTextareaSavedHTML:function(){return this.getHTML()},getPreviewedHTML:function(){return this.settings.watch?this.previewContainer.html():(alert("Error: settings.watch == false"),!1)},watch:function(e){var i=this.settings;if(t.inArray(i.mode,["gfm","markdown"])<0)return this;if(this.state.watching=i.watch=!0,this.preview.show(),this.toolbar){var r=i.toolbarIconsClass.watch,n=i.toolbarIconsClass.unwatch,a=this.toolbar.find(".fa[name=watch]");a.parent().attr("title",i.lang.toolbar.watch),a.removeClass(n).addClass(r)}return this.codeMirror.css("border-right","1px solid #ddd").width(this.editor.width()/2),o=0,this.save().resize(),i.onwatch||(i.onwatch=e||function(){}),t.proxy(i.onwatch,this)(),this},unwatch:function(e){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,n=this.toolbar.find(".fa[name=watch]");n.parent().attr("title",i.lang.toolbar.unwatch),n.removeClass(o).addClass(r)}return this.codeMirror.css("border-right","none").width(this.editor.width()),this.resize(),i.onunwatch||(i.onunwatch=e||function(){}),t.proxy(i.onunwatch,this)(),this},show:function(e){e=e||function(){};var i=this;return this.editor.show(0,function(){t.proxy(e,i)()}),this},hide:function(e){e=e||function(){};var i=this;return this.editor.hide(0,function(){t.proxy(e,i)()}),this},previewing:function(){var e=this,o=this.editor,r=this.preview,n=this.toolbar,a=this.settings,s=this.codeMirror,l=this.previewContainer;if(t.inArray(a.mode,["gfm","markdown"])<0)return this;a.toolbar&&n&&(n.toggle(),n.find(".fa[name=preview]").toggleClass("active")),s.toggle();var c=function(t){t.shiftKey&&27===t.keyCode&&e.previewed()};"none"===s.css("display")?(this.state.preview=!0,this.state.fullscreen&&r.css("background","#fff"),o.find("."+this.classPrefix+"preview-close-btn").show().bind(i.mouseOrTouch("click","touchend"),function(){e.previewed()}),a.watch?l.css("padding",""):this.save(),l.addClass(this.classPrefix+"preview-active"),r.show().css({position:"",top:0,width:o.width(),height:a.autoHeight&&!this.state.fullscreen?"auto":o.height()}),this.state.loaded&&t.proxy(a.onpreviewing,this)(),t(window).bind("keyup",c)):(t(window).unbind("keyup",c),this.previewed())},previewed:function(){var e=this.editor,o=this.preview,r=this.toolbar,n=this.settings,a=this.previewContainer,s=e.find("."+this.classPrefix+"preview-close-btn");return this.state.preview=!1,this.codeMirror.show(),n.toolbar&&r.show(),o[n.watch?"show":"hide"](),s.hide().unbind(i.mouseOrTouch("click","touchend")),a.removeClass(this.classPrefix+"preview-active"),n.watch&&a.css("padding","20px"),o.css({background:null,position:"absolute",width:e.width()/2,height:n.autoHeight&&!this.state.fullscreen?"auto":e.height()-r.height(),top:n.toolbar?r.height():0}),this.state.loaded&&t.proxy(n.onpreviewed,this)(),this},fullscreen:function(){var e=this,i=this.state,o=this.editor,r=(this.preview,this.toolbar),n=this.settings,a=this.classPrefix+"fullscreen";r&&r.find(".fa[name=fullscreen]").parent().toggleClass("active");var s=function(t){t.shiftKey||27!==t.keyCode||i.fullscreen&&e.fullscreenExit()};return o.hasClass(a)?(t(window).unbind("keyup",s),this.fullscreenExit()):(i.fullscreen=!0,t("html,body").css("overflow","hidden"),o.css({width:t(window).width(),height:t(window).height()}).addClass(a),this.resize(),t.proxy(n.onfullscreen,this)(),t(window).bind("keyup",s)),this},fullscreenExit:function(){var e=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"),t("html,body").css("overflow",""),e.css({width:e.data("oldWidth"),height:e.data("oldHeight")}).removeClass(r),this.resize(),t.proxy(i.onfullscreenExit,this)(),this},executePlugin:function(e,o){var r=this,n=this.cm;return o=this.settings.pluginPath+o,"function"==typeof define?void 0===this[e]?(alert("Error: "+e+" plugin is not found, you are not load this plugin."),this):(this[e](n),this):(t.inArray(o,i.loadFiles.plugin)<0?i.loadPlugin(o,function(){i.loadPlugins[e]=r[e],r[e](n)}):t.proxy(i.loadPlugins[e],this)(n),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}},i.fn.init.prototype=i.fn,i.dialogLockScreen=function(){(this.settings||{dialogLockScreen:!0}).dialogLockScreen&&(t("html,body").css("overflow","hidden"),this.resize())},i.dialogShowMask=function(e){var i=this.editor,o=this.settings||{dialogShowMask:!0};e.css({top:(t(window).height()-e.height())/2+"px",left:(t(window).width()-e.width())/2+"px"}),o.dialogShowMask&&i.children("."+this.classPrefix+"mask").css("z-index",parseInt(e.css("z-index"))-1).show()},i.toolbarHandlers={undo:function(){this.cm.undo()},redo:function(){this.cm.redo()},bold:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("**"+i+"**"),""===i&&e.setCursor(t.line,t.ch+2)},del:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("~~"+i+"~~"),""===i&&e.setCursor(t.line,t.ch+2)},italic:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("*"+i+"*"),""===i&&e.setCursor(t.line,t.ch+1)},quote:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("> "+i),e.setCursor(t.line,t.ch+2)):e.replaceSelection("> "+i)},ucfirst:function(){var e=this.cm,t=e.getSelection(),o=e.listSelections();e.replaceSelection(i.firstUpperCase(t)),e.setSelections(o)},ucwords:function(){var e=this.cm,t=e.getSelection(),o=e.listSelections();e.replaceSelection(i.wordsFirstUpperCase(t)),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.getCursor(),e.getSelection()),i=e.listSelections();e.replaceSelection(t.toLowerCase()),e.setSelections(i)},h1:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();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.getCursor(),e.getSelection());if(""===t)e.replaceSelection("- "+t);else{for(var i=t.split("\n"),o=0,r=i.length;o<r;o++)i[o]=""===i[o]?"":"- "+i[o];e.replaceSelection(i.join("\n"))}},"list-ol":function(){var e=this.cm,t=(e.getCursor(),e.getSelection());if(""===t)e.replaceSelection("1. "+t);else{for(var i=t.split("\n"),o=0,r=i.length;o<r;o++)i[o]=""===i[o]?"":o+1+". "+i[o];e.replaceSelection(i.join("\n"))}},hr:function(){var e=this.cm,t=e.getCursor();e.getSelection();e.replaceSelection((0!==t.ch?"\n\n":"\n")+"------------\n\n")},tex:function(){if(!this.settings.tex)return alert("settings.tex === false"),this;var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("$$"+i+"$$"),""===i&&e.setCursor(t.line,t.ch+2)},link:function(){this.executePlugin("linkDialog","link-dialog/link-dialog")},"reference-link":function(){this.executePlugin("referenceLinkDialog","reference-link-dialog/reference-link-dialog")},pagebreak:function(){if(!this.settings.pageBreak)return alert("settings.pageBreak === false"),this;var e=this.cm;e.getSelection();e.replaceSelection("\r\n[========]\r\n")},image:function(){this.executePlugin("imageDialog","image-dialog/image-dialog")},code:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("`"+i+"`"),""===i&&e.setCursor(t.line,t.ch+1)},"code-block":function(){this.executePlugin("codeBlockDialog","code-block-dialog/code-block-dialog")},"preformatted-text":function(){this.executePlugin("preformattedTextDialog","preformatted-text-dialog/preformatted-text-dialog")},table:function(){this.executePlugin("tableDialog","table-dialog/table-dialog")},datetime:function(){var e=this.cm,t=(e.getSelection(),new Date,this.settings.lang.name),o=i.dateFormat()+" "+i.dateFormat("zh-cn"===t||"zh-tw"===t?"cn-week-day":"week-day");e.replaceSelection(o)},emoji:function(){this.executePlugin("emojiDialog","emoji-dialog/emoji-dialog")},"html-entities":function(){this.executePlugin("htmlEntitiesDialog","html-entities-dialog/html-entities-dialog")},"goto-line":function(){this.executePlugin("gotoLineDialog","goto-line-dialog/goto-line-dialog")},watch:function(){this[this.settings.watch?"unwatch":"watch"]()},preview:function(){this.previewing()},fullscreen:function(){this.fullscreen()},clear:function(){this.clear()},search:function(){this.search()},help:function(){this.executePlugin("helpDialog","help-dialog/help-dialog")},info:function(){this.showInfoDialog()}};var n=navigator.platform.toUpperCase().indexOf("MAC")>=0,a=n?"Cmd":"Ctrl";i.keyMaps=(e={},_defineProperty(e,a+"-1","h1"),_defineProperty(e,a+"-2","h2"),_defineProperty(e,a+"-3","h3"),_defineProperty(e,a+"-4","h4"),_defineProperty(e,a+"-5","h5"),_defineProperty(e,a+"-6","h6"),_defineProperty(e,a+"-B","bold"),_defineProperty(e,a+"-D","datetime"),_defineProperty(e,a+"Ctrl-E",function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();if(!this.settings.emoji)return void alert("Error: settings.emoji == false");e.replaceSelection(":"+i+":"),""===i&&e.setCursor(t.line,t.ch+1)}),_defineProperty(e,a+"-Alt-G","goto-line"),_defineProperty(e,a+"-H","hr"),_defineProperty(e,a+"-I","italic"),_defineProperty(e,a+"-K","code"),_defineProperty(e,"Ctrl-L",function(){var e=this.cm,t=e.getCursor(),i=e.getSelection(),o=""===i?"":' "'+i+'"';e.replaceSelection("["+i+"]("+o+")"),""===i&&e.setCursor(t.line,t.ch+1)}),_defineProperty(e,a+"-U","list-ul"),_defineProperty(e,"Shift-Ctrl-A",function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();if(!this.settings.atLink)return void alert("Error: settings.atLink == false");e.replaceSelection("@"+i),""===i&&e.setCursor(t.line,t.ch+1)}),_defineProperty(e,"Shift"+a+"-C","code"),_defineProperty(e,"Shift"+a+"Q","quote"),_defineProperty(e,"Shift"+a+"S","del"),_defineProperty(e,"Shift"+a+"K","tex"),_defineProperty(e,"Shift-Alt-C",function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection(["```",i,"```"].join("\n")),""===i&&e.setCursor(t.line,t.ch+3)}),_defineProperty(e,"Shift-"+a+"-Alt-C","code-block"),_defineProperty(e,"Shift-"+a+"-H","html-entities"),_defineProperty(e,"Shift-Alt-H","help"),_defineProperty(e,"Shift-"+a+"-E","emoji"),_defineProperty(e,"Shift-"+a+"-U","uppercase"),_defineProperty(e,"Shift-Alt-U","ucwords"),_defineProperty(e,"Shift-"+a+"-Alt-U","ucfirst"),_defineProperty(e,"Shift-Alt-L","lowercase"),_defineProperty(e,"Shift-"+a+"-I",function(){var e=this.cm,t=e.getCursor(),i=e.getSelection(),o=""===i?"":' "'+i+'"';e.replaceSelection("!["+i+"]("+o+")"),""===i&&e.setCursor(t.line,t.ch+4)}),_defineProperty(e,"Shift-"+a+"-Alt-I","image"),_defineProperty(e,"Shift-"+a+"-L","link"),_defineProperty(e,"Shift-"+a+"-O","list-ol"),_defineProperty(e,"Shift-"+a+"-P","preformatted-text"),_defineProperty(e,"Shift-"+a+"-T","table"),_defineProperty(e,"Shift-Alt-P","pagebreak"),_defineProperty(e,"F9","watch"),_defineProperty(e,"F10","preview"),_defineProperty(e,"F11","fullscreen"),e);var s=function(e){return String.prototype.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};i.trim=s;var l=function(e){return e.toLowerCase().replace(/\b(\w)|\s(\w)/g,function(e){return e.toUpperCase()})};i.ucwords=i.wordsFirstUpperCase=l;var c=function(e){return e.toLowerCase().replace(/\b(\w)/,function(e){return e.toUpperCase()})};return i.firstUpperCase=i.ucfirst=c,i.urls={atLinkBase:"https://github.com/"},i.regexs={atLink:/@(\w+)/g,email:/(\w+)@(\w+)\.(\w+)\.?(\w+)?/g,emailLink:/(mailto:)?([\w\.\_]+)@(\w+)\.(\w+)\.?(\w+)?/g,emoji:/:([\w\+-]+):/g,emojiDatetime:/(\d{1,2}:\d{1,2}:\d{1,2})/g,twemoji:/:(tw-([\w]+)-?(\w+)?):/g,fontAwesome:/:(fa-([\w]+)(-(\w+)){0,}):/g,editormdLogo:/:(editormd-logo-?(\w+)?):/g,pageBreak:/^\[[=]{8,}\]$/},i.emoji={path:"http://www.emoji-cheat-sheet.com/graphics/emojis/",ext:".png"},i.twemoji={path:"http://twemoji.maxcdn.com/36x36/",ext:".png"},i.markedRenderer=function(e,o){var r={toc:!0,tocm:!1,tocStartLevel:1,pageBreak:!0,atLink:!0,emailLink:!0,taskList:!1,emoji:!1,tex:!1,flowChart:!1,sequenceDiagram:!1},n=t.extend(r,o||{}),a=i.$marked,l=new a.Renderer;e=e||[];var c=i.regexs,h=c.atLink,d=c.emoji,u=c.email,f=c.emailLink,p=c.twemoji,g=c.fontAwesome,m=c.editormdLogo,w=c.pageBreak;return l.emoji=function(e){e=e.replace(i.regexs.emojiDatetime,function(e){return e.replace(/:/g,":")});var t=e.match(d);if(!t||!n.emoji)return e;for(var o=0,r=t.length;o<r;o++)":+1:"===t[o]&&(t[o]=":\\+1:"),e=e.replace(new RegExp(t[o]),function(e,t){var o=e.match(g),r=e.replace(/:/g,"");if(o)for(var n=0,a=o.length;n<a;n++){var s=o[n].replace(/:/g,"");return'<i class="fa '+s+' fa-emoji" title="'+s.replace("fa-","")+'"></i>'}else{var l=e.match(m),c=e.match(p);if(l)for(var h=0,d=l.length;h<d;h++){var u=l[h].replace(/:/g,"");return'<i class="'+u+'" title="Editor.md logo ('+u+')"></i>'}else{if(!c){var f="+1"===r?"plus1":r;return f="black_large_square"===f?"black_square":f,f="moon"===f?"waxing_gibbous_moon":f,'<img src="'+i.emoji.path+f+i.emoji.ext+'" class="emoji" title=":'+r+':" alt=":'+r+':" />'}for(var w=0,v=c.length;w<v;w++){var k=c[w].replace(/:/g,"").replace("tw-","");return'<img src="'+i.twemoji.path+k+i.twemoji.ext+'" title="twemoji-'+k+'" alt="twemoji-'+k+'" class="emoji twemoji" />'}}}});return e},l.atLink=function(e){return h.test(e)?(n.atLink&&(e=e.replace(u,function(e,t,i,o){return e.replace(/@/g,"_#_@_#_")}),e=e.replace(h,function(e,t){return'<a href="'+i.urls.atLinkBase+t+'" title="@'+t+'" class="at-link">'+e+"</a>"}).replace(/_#_@_#_/g,"@")),n.emailLink&&(e=e.replace(f,function(e,i,o,r,n){return!i&&t.inArray(n,"jpg|jpeg|png|gif|webp|ico|icon|pdf".split("|"))<0?'<a href="mailto:'+e+'">'+e+"</a>":e})),e):e},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='<a href="'+e+'"';return h.test(t)||h.test(i)?(t&&(o+=' title="'+t.replace(/@/g,"@")),o+'">'+i.replace(/@/g,"@")+"</a>"):(t&&(o+=' title="'+t+'"'),o+=">"+i+"</a>")},l.heading=function(t,i,o){var r=t,n=/\s*<a\s*href\=\"(.*)\"\s*([^\>]*)\>(.*)<\/a\>\s*/;if(n.test(t)){var a=[];t=t.split(/<a\s*([^\>]+)\>([^\>]*)<\/a\>/);for(var l=0,c=t.length;l<c;l++)a.push(t[l].replace(/\s*href\=\"(.*)\"\s*/g,""));t=a.join(" ")}t=s(t);var h=t.toLowerCase().replace(/[^\w]+/g,"-"),d={text:t,level:i,slug:h},u=/^[\u4e00-\u9fa5]+$/.test(t),f=u?escape(t).replace(/\%/g,""):t.toLowerCase().replace(/[^\w]+/g,"-");e.push(d);var p="<h"+i+' id="h'+i+"-"+this.options.headerPrefix+f+'">';return p+='<a name="'+t+'" class="reference-link"></a>',p+='<span class="header-link octicon octicon-link"></span>',p+=n?this.atLink(this.emoji(r)):this.atLink(this.emoji(t)),p+="</h"+i+">"},l.pageBreak=function(e){return w.test(e)&&n.pageBreak&&(e='<hr style="page-break-after:always;" class="page-break editormd-page-break" />'),e},l.paragraph=function(e){var t=/\$\$(.*)\$\$/g.test(e),o=/^\$\$(.*)\$\$$/.test(e),r=o?' class="'+i.classNames.tex+'"':"",a=n.tocm?/^(\[TOC\]|\[TOCM\])$/.test(e):/^\[TOC\]$/.test(e),s=/^\[TOCM\]$/.test(e);e=!o&&t?e.replace(/(\$\$([^\$]*)\$\$)+/g,function(e,t){return'<span class="'+i.classNames.tex+'">'+t.replace(/\$/g,"")+"</span>"}):o?e.replace(/\$/g,""):e;var l='<div class="markdown-toc editormd-markdown-toc">'+e+"</div>";return a?s?'<div class="editormd-toc-menu">'+l+"</div><br/>":l:w.test(e)?this.pageBreak(e):"<p"+r+">"+this.atLink(this.emoji(e))+"</p>\n"},l.code=function(e,t,o){return"seq"===t||"sequence"===t?'<div class="sequence-diagram">'+e+"</div>":"flow"===t?'<div class="flowchart">'+e+"</div>":"math"===t||"latex"===t||"katex"===t?'<p class="'+i.classNames.tex+'">'+e+"</p>":a.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))+"</"+i+">\n"},l.listitem=function(e){return n.taskList&&/^\s*\[[x\s]\]\s*/.test(e)?(e=e.replace(/^\s*\[\s\]\s*/,'<input type="checkbox" class="task-list-item-checkbox" /> ').replace(/^\s*\[x\]\s*/,'<input type="checkbox" class="task-list-item-checkbox" checked disabled /> '),'<li style="list-style: none;">'+this.atLink(this.emoji(e))+"</li>"):"<li>"+this.atLink(this.emoji(e))+"</li>"},l},i.markdownToCRenderer=function(e,t,i,o){var r="",n=[0],a=this.classPrefix;o=o||1;for(var s=0,l=e.length;s<l;s++){var c=e[s].text,h=e[s].level,d=n.length,u=n[d-1],f=0;if(!(h<o)){if(h>u)r+="",n.push(h);else if(h<u){for(var p=d-1;p>=0;p--){if(!(h<=n[p])){n.push(h);break}f++,n.pop()}r+=new Array(f+1).join("</ul></li>")}else r+="</ul></li>";r+='<li><a class="toc-level-'+h+'" href="#'+c+'" level="'+h+'">'+c+"</a><ul>"}}var g=t.find(".markdown-toc");if(g.length<1&&"false"===t.attr("previewContainer")){var m='<div class="markdown-toc '+a+'markdown-toc"></div>';m=i?'<div class="'+a+'toc-menu">'+m+"</div>":m,t.html(m),g=t.find(".markdown-toc")}return i&&g.wrap('<div class="'+a+'toc-menu"></div><br/>'),g.html('<ul class="markdown-toc-list"></ul>').children(".markdown-toc-list").html(r.replace(/\r?\n?<ul\><\/ul\>/g,"")),g},i.tocDropdownMenu=function(e,i){i=i||"Table of Contents";var o=400,r=e.find("."+this.classPrefix+"toc-menu");return r.each(function(){var e=t(this),r=e.children(".markdown-toc"),n='<i class="fa fa-angle-down"></i>',a='<a href="javascript:;" class="toc-menu-btn">'+n+i+"</a>",s=r.children("ul"),l=s.find("li");r.append(a),l.first().before("<li><h1>"+i+" "+n+"</h1></li>"),e.mouseover(function(){s.show(),l.each(function(){var e=t(this),i=e.children("ul");if(""===i.html()&&i.remove(),i.length>0&&""!==i.html()){var r=e.children("a").first();r.children(".fa").length<1&&r.append(t(n).css({float:"right",paddingTop:"4px"}))}e.mouseover(function(){i.css("z-index",o).show(),o+=1}).mouseleave(function(){i.hide()})})}).mouseleave(function(){s.hide()})}),r},i.filterHTMLTags=function(e,i){if("string"!=typeof e&&(e=new String(e)),"string"!=typeof i)return e;for(var o=i.split("|"),r=o[0].split(","),n=o[1],a=0,s=r.length;a<s;a++){var l=r[a];e=e.replace(new RegExp("<s*"+l+"s*([^>]*)>([^>]*)<s*/"+l+"s*>","igm"),"")}if(void 0!==n){var c=/<(\w+)\s*([^\>]*)\>([^\>]*)<\/(\w+)\>/gi;e="*"===n?e.replace(c,function(e,t,i,o,r){return"<"+t+">"+o+"</"+r+">"}):"on*"===n?e.replace(c,function(e,i,o,r,n){var a=t("<"+i+">"+r+"</"+n+">"),s=t(e)[0].attributes,l={};t.each(s,function(e,t){'"'!==t.nodeName&&(l[t.nodeName]=t.nodeValue,"href"===t.nodeName&&t.nodeValue.toLowerCase().indexOf("javascript:")>=0&&(l[t.nodeName]="javascript:;"))}),t.each(l,function(e){0===e.indexOf("on")&&delete l[e]}),a.attr(l);var c=void 0!==a[1]?t(a[1]).text():"";if(!i||isNaN(i)||i===n)return i&&isNaN(i)&&i!==n?(c+="</"+n+">",a[0].outerHTML+c):a[0].outerHTML+c;c+="<"+i+">"+r+"</"+n+">"}):e.replace(c,function(e,i,o,r){var a=n.split(","),s=t(e);return s.html(r),t.each(a,function(e){s.attr(a[e],null)}),s[0].outerHTML})}return e},i.markdownToHTML=function(e,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};i.$marked=marked;var n=t("#"+e),a=n.settings=t.extend(!0,r,o||{}),s=n.find("textarea");s.length<1&&(n.append("<textarea></textarea>"),s=n.find("textarea"));var l=""===a.markdown?s.val():a.markdown,c=[],h={toc:a.toc,tocm:a.tocm,tocStartLevel:a.tocStartLevel,taskList:a.taskList,emoji:a.emoji,tex:a.tex,pageBreak:a.pageBreak,atLink:a.atLink,emailLink:a.emailLink,flowChart:a.flowChart,sequenceDiagram:a.sequenceDiagram,previewCodeHighlight:a.previewCodeHighlight},d={renderer:i.markedRenderer(c,h),gfm:a.gfm,tables:!0,breaks:!0,pedantic:!1,sanitize:!a.htmlDecode,smartLists:!0,smartypants:!0};l=new String(l);var u=marked(l,d);u=i.filterHTMLTags(u,a.htmlDecode),a.markdownSourceCode?s.text(l):s.remove(),n.addClass("markdown-body "+this.classPrefix+"html-preview").append(u);var f=""!==a.tocContainer?t(a.tocContainer):n;if(""!==a.tocContainer&&f.attr("previewContainer",!1),a.toc&&(n.tocContainer=this.markdownToCRenderer(c,f,a.tocDropdown,a.tocStartLevel),(a.tocDropdown||n.find("."+this.classPrefix+"toc-menu").length>0)&&this.tocDropdownMenu(n,a.tocTitle),""!==a.tocContainer&&n.find(".editormd-toc-menu, .editormd-markdown-toc").remove()),a.previewCodeHighlight&&(n.find("pre").addClass("prettyprint linenums"),prettyPrint()),i.isIE8||(a.flowChart&&n.find(".flowchart").flowChart(),a.sequenceDiagram&&n.find(".sequence-diagram").sequenceDiagram({theme:"simple"})),a.tex){var p=function(){n.find("."+i.classNames.tex).each(function(){var e=t(this);katex.render(e.html().replace(/</g,"<").replace(/>/g,">"),e[0]),e.find(".katex").css("font-size","1.6em")})};!a.autoLoadKaTeX||i.$katex||i.kaTeXLoaded?p():this.loadKaTeX(function(){i.$katex=katex,i.kaTeXLoaded=!0,p()})}return n.getMarkdown=function(){return s.val()},n},i.themes=["default","dark"],i.previewThemes=["default","dark"],i.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"],i.loadPlugins={},i.loadFiles={js:[],css:[],plugin:[]},i.loadPlugin=function(e,t,o){t=t||function(){},this.loadScript(e,function(){i.loadFiles.plugin.push(e),t()},o)},i.loadCSS=function(e,t,o){o=o||"head",t=t||function(){};var r=document.createElement("link");r.type="text/css",r.rel="stylesheet",r.onload=r.onreadystatechange=function(){i.loadFiles.css.push(e),t()},r.href=e+".css","head"===o?document.getElementsByTagName("head")[0].appendChild(r):document.body.appendChild(r)},i.isIE="Microsoft Internet Explorer"===navigator.appName,i.isIE8=i.isIE&&"8."===navigator.appVersion.match(/8./i),i.loadScript=function(e,t,o){o=o||"head",t=t||function(){};var r=null;r=document.createElement("script"),r.id=e.replace(/[\.\/]+/g,"-"),r.type="text/javascript",r.src=e+".js",i.isIE8?r.onreadystatechange=function(){r.readyState&&("loaded"!==r.readyState&&"complete"!==r.readyState||(r.onreadystatechange=null,i.loadFiles.js.push(e),t()))}:r.onload=function(){i.loadFiles.js.push(e),t()},"head"===o?document.getElementsByTagName("head")[0].appendChild(r):document.body.appendChild(r)},i.katexURL={css:"//cdn.staticfile.org/KaTeX/0.3.0/katex.min",js:"//cdn.staticfile.org/KaTeX/0.3.0/katex.min"},i.kaTeXLoaded=!1,i.loadKaTeX=function(e){i.loadCSS(i.katexURL.css,function(){i.loadScript(i.katexURL.js,e||function(){})})},i.lockScreen=function(e){t("html,body").css("overflow",e?"hidden":"")},i.createDialog=function(e){var o={name:"",width:420,height:240,title:"",drag:!0,closed:!0,content:"",mask:!0,maskStyle:{backgroundColor:"#fff",opacity:.1},lockScreen:!0,footer:!0,buttons:!1};e=t.extend(!0,o,e);var r=this,n=this.editor,a=i.classPrefix,s=(new Date).getTime(),l=""===e.name?a+"dialog-"+s:e.name,c=i.mouseOrTouch,h='<div class="'+a+"dialog "+l+'">';""!==e.title&&(h+='<div class="'+a+'dialog-header"'+(e.drag?' style="cursor: move;"':"")+">",h+='<strong class="'+a+'dialog-title">'+e.title+"</strong>",h+="</div>"),e.closed&&(h+='<a href="javascript:;" class="fa fa-close '+a+'dialog-close"></a>'),h+='<div class="'+a+'dialog-container">'+e.content,(e.footer||"string"==typeof e.footer)&&(h+='<div class="'+a+'dialog-footer">'+("boolean"==typeof e.footer?"":e.footer)+"</div>"),h+="</div>",h+='<div class="'+a+"dialog-mask "+a+'dialog-mask-bg"></div>',h+='<div class="'+a+"dialog-mask "+a+'dialog-mask-con"></div>',h+="</div>",n.append(h);var d=n.find("."+l);d.lockScreen=function(i){return e.lockScreen&&(t("html,body").css("overflow",i?"hidden":""),r.resize()),d},d.showMask=function(){return e.mask&&n.find("."+a+"mask").css(e.maskStyle).css("z-index",i.dialogZindex-1).show(),d},d.hideMask=function(){return e.mask&&n.find("."+a+"mask").hide(),d},d.loading=function(e){return d.find("."+a+"dialog-mask")[e?"show":"hide"](),d},d.lockScreen(!0).showMask(),d.show().css({zIndex:i.dialogZindex,border:i.isIE8?"1px solid #ddd":"",width:"number"==typeof e.width?e.width+"px":e.width,height:"number"==typeof e.height?e.height+"px":e.height});var u=function(){d.css({top:(t(window).height()-d.height())/2+"px",left:(t(window).width()-d.width())/2+"px"})};if(u(),t(window).resize(u),d.children("."+a+"dialog-close").bind(c("click","touchend"),function(){d.hide().lockScreen(!1).hideMask()}),"object"===_typeof(e.buttons)){var f=d.footer=d.find("."+a+"dialog-footer");for(var p in e.buttons){var g=e.buttons[p],m=a+p+"-btn";f.append('<button class="'+a+"btn "+m+'">'+g[0]+"</button>"),g[1]=t.proxy(g[1],d),f.children("."+m).bind(c("click","touchend"),g[1])}}if(""!==e.title&&e.drag){var w,v,k=d.children("."+a+"dialog-header");e.mask||k.bind(c("click","touchend"),function(){i.dialogZindex+=2,d.css("z-index",i.dialogZindex)});var y=function(e){e.removeClass(a+"user-unselect").off("selectstart")},b=function(e){e.addClass(a+"user-unselect").on("selectstart",function(e){return!1})},x=function(e){e=e||window.event;var i,o,r=parseInt(d[0].style.left),n=parseInt(d[0].style.top);r>=0?r+d.width()<=t(window).width()?i=e.clientX-w:(i=t(window).width()-d.width(),document.onmousemove=null):(i=0,document.onmousemove=null),n>=0?o=e.clientY-v:(o=0,document.onmousemove=null),document.onselectstart=function(){return!1},b(t("body")),b(d),d[0].style.left=i+"px",d[0].style.top=o+"px"};k.mousedown(function(e){e=e||window.event,w=e.clientX-parseInt(d[0].style.left),v=e.clientY-parseInt(d[0].style.top),document.onmousemove=x}),document.onmouseup=function(){y(t("body")),y(d),document.onselectstart=null,document.onmousemove=null},k.touchDraggable=function(){var e=null,i=function(i){var o=i.originalEvent,r=t(this).parent().position();e={x:o.changedTouches[0].pageX-r.left,y:o.changedTouches[0].pageY-r.top}},o=function(i){i.preventDefault();var o=i.originalEvent;t(this).parent().css({top:o.changedTouches[0].pageY-e.y,left:o.changedTouches[0].pageX-e.x})};this.bind("touchstart",i).bind("touchmove",o)},k.touchDraggable()}return i.dialogZindex+=2,d},i.mouseOrTouch=function(e,t){e=e||"click",t=t||"touchend";var i=e;try{document.createEvent("TouchEvent"),i=t}catch(e){}return i},i.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),n=t(i.getMonth()+1),a=t(i.getDate()),s=i.getDay(),l=t(i.getHours()),c=t(i.getMinutes()),h=t(i.getSeconds()),d=t(i.getMilliseconds()),u="",f=r+"-"+n+"-"+a,p=o+"-"+n+"-"+a,g=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=n;break;case"cn-week-day":case"cn-wd":u="星期"+["日","一","二","三","四","五","六"][s];break;case"week-day":case"wd":u=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][s];break;case"day":case"dd":u=a;break;case"hour":case"hh":u=l;break;case"min":case"ii":u=c;break;case"second":case"ss":u=h;break;case"ms":u=d;break;case"yy-mm-dd":u=f;break;case"yyyy-mm-dd":u=p;break;case"yyyy-mm-dd h:i:s ms":case"full + ms":u=p+" "+g+" "+d;break;case"full":case"yyyy-mm-dd h:i:s":break;default:u=p+" "+g}return u},i}});