玛氪宕·梦魔(Markdown Memo),使用Markdown的云端备忘录,百度IFE的RIA启航班的不合格的作业,才……才没有什么阴谋呢!
源gitee链接https://gitee.com/arathi/MarkdownMemo?_from=gitee_search
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
55 KiB
2 lines
55 KiB
/*! 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,emojiCategories:["github-emoji","twemoji","font-awesome","editormd-logo"],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 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: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 编辑器<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:"关于"+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=9999,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),o.emojiCategories&&(a.emojiCategories=o.emojiCategories),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("<textarea></textarea>"),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 href="javascript:;" class="fa fa-close '+r+'preview-close-btn"></a>',a.saveHTMLToTextarea?'<textarea class="'+s.textarea.html+'" name="'+i+'-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 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-o.offset().top<o.height()-r.height()?r.css({position:"fixed",width:o.width()+"px",left:o.offset().left+1+"px"}):r.css({position:"absolute",width:"100%",left:0})};return!i.fullscreen&&!i.preview&&a.toolbar&&a.toolbarAutoFixed&&(e(window).bind("scroll",n),e(window).bind("resize",n)),this},setToolbar:function(){var e=this.settings;if(e.readOnly)return this;var i=this.editor,o=this.classPrefix,r=this.toolbar=i.children("."+o+"toolbar");if(e.toolbar&&r.length<1){var a='<div class="'+o+'toolbar"><div class="'+o+'toolbar-container"><ul class="'+o+'menu"></ul></div></div>';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<d;h++){var u=n[h];if("||"===u)c=!0;else if("|"===u)l+='<li class="divider" unselectable="on">|</li>';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?'<li class="pull-right">':"<li>";void 0!==e.toolbarCustomIcons[u]&&"function"!=typeof e.toolbarCustomIcons[u]?v+=e.toolbarCustomIcons[u]:(v+='<a href="javascript:;" title="'+p+'" 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 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=['<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> '+t.title+"<small>v"+t.version+"</small></h1>","<p>"+this.lang.description+"</p>",'<p style="margin: 10px 0 20px 0;"><a href="'+t.homePage+'" target="_blank">'+t.homePage+' <i class="fa fa-external-link"></i></a></p>','<p style="font-size: 0.85em;">Copyright © 2015-'+t.dateFormat("yyyy")+' <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");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;var n=a.find(".flowchart");n.length>0&&n.flowChart()}if(r.sequenceDiagram){var s=a.find(".sequence-diagram");s.length>0&&s.sequenceDiagram({theme:"simple"})}var l=i.preview,c=i.codeMirror,h=c.find(".CodeMirror-scroll"),d=h.height(),u=h.scrollTop(),f=u/h[0].scrollHeight,g=0;l.find(".markdown-toc-list").each(function(){g+=e(this).height()});var p=l.find(".editormd-toc-menu").height();return p=p||0,0===u?l.scrollTop(0):u+d>=h[0].scrollHeight-16?l.scrollTop(l[0].scrollHeight):l.scrollTop((l[0].scrollHeight+g+p)*f),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);var c=s.toolbar&&!s.readOnly,h=c&&n?n.height():0,d=l.find(".CodeMirror-gutters");o.fullscreen?(r.height(e(window).height()),d.height(e(window).height()-h)):d.height(r.height()-h),c?l.css("margin-top",n.height()+1).height(r.height()-n.height()):l.css("margin-top",0).height(r.height())}else r.css("height","auto"),l.css("height","auto");if(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 u=s.toolbar&&!s.readOnly?r.height()-n.height():r.height();a.height(u)}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,f.renderer),(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 i=this,o=this.state,r=this.editor,a=this.toolbar,n=this.settings,s=this.classPrefix+"fullscreen";a&&a.find(".fa[name=fullscreen]").parent().toggleClass("active");var l=function(e){e.shiftKey||27!==e.keyCode||o.fullscreen&&i.fullscreenExit()};return r.hasClass(s)?(e(window).unbind("keyup",l),this.fullscreenExit()):(o.fullscreen=!0,e("html,body").css("overflow","hidden"),r.css({width:e(window).width(),height:e(window).height(),zIndex:t.dialogZindex}).addClass(s),this.resize(),e.proxy(n.onfullscreen,this)(),e(window).bind("keyup",l)),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"),zIndex:""}).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<r;o++)i[o]=""===i[o]?"":"- "+i[o];e.replaceSelection(i.join("\n"))}},"list-ol":function(){var e=this.cm,t=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.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;this.cm.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,i=this.settings.lang.name,o=t.dateFormat()+" "+t.dateFormat("zh-cn"===i||"zh-tw"===i?"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()}},t.keyMaps={"Ctrl-1":"h1","Ctrl-2":"h2","Ctrl-3":"h3","Ctrl-4":"h4","Ctrl-5":"h5","Ctrl-6":"h6","Ctrl-B":"bold","Ctrl-D":"datetime","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)},"Ctrl-Alt-G":"goto-line","Ctrl-H":"hr","Ctrl-I":"italic","Ctrl-K":"code","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)},"Ctrl-U":"list-ul","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)},"Shift-Ctrl-C":"code","Shift-Ctrl-Q":"quote","Shift-Ctrl-S":"del","Shift-Ctrl-K":"tex","Shift-Alt-C":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection(["```",i,"```"].join("\n")),""===i&&e.setCursor(t.line,t.ch+3)},"Shift-Ctrl-Alt-C":"code-block","Shift-Ctrl-H":"html-entities","Shift-Alt-H":"help","Shift-Ctrl-E":"emoji","Shift-Ctrl-U":"uppercase","Shift-Alt-U":"ucwords","Shift-Ctrl-Alt-U":"ucfirst","Shift-Alt-L":"lowercase","Shift-Ctrl-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)},"Shift-Ctrl-Alt-I":"image","Shift-Ctrl-L":"link","Shift-Ctrl-O":"list-ol","Shift-Ctrl-P":"preformatted-text","Shift-Ctrl-T":"table","Shift-Alt-P":"pagebreak",F9:"watch",F10:"preview",F11:"fullscreen"};var r=function(e){return String.prototype.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};t.trim=r;var a=function(e){return e.toLowerCase().replace(/\b(\w)|\s(\w)/g,function(e){return e.toUpperCase()})};t.ucwords=t.wordsFirstUpperCase=a;var n=function(e){return e.toLowerCase().replace(/\b(\w)/,function(e){return e.toUpperCase()})};return t.firstUpperCase=t.ucfirst=n,t.urls={atLinkBase:"https://github.com/"},t.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,}\]$/},t.emoji={path:"https://www.webpagefx.com/tools/emoji-cheat-sheet/graphics/emojis/",ext:".png"},t.twemoji={path:"http://twemoji.maxcdn.com/36x36/",ext:".png"},t.markedRenderer=function(i,o){var a={toc:!0,tocm:!1,tocStartLevel:1,pageBreak:!0,atLink:!0,emailLink:!0,taskList:!1,emoji:!1,tex:!1,flowChart:!1,sequenceDiagram:!1},n=[],s=e.extend(a,o||{}),l=t.$marked,c=new l.Renderer;i=i||[];var h=t.regexs,d=h.atLink,u=h.emoji,f=h.email,g=h.emailLink,p=h.twemoji,m=h.fontAwesome,w=h.editormdLogo,v=h.pageBreak;return c.emoji=function(e){e=e.replace(t.regexs.emojiDatetime,function(e){return e.replace(/:/g,":")});var i=e.match(u);if(!i||!s.emoji)return e;for(var o=0,r=i.length;o<r;o++)":+1:"===i[o]&&(i[o]=":\\+1:"),e=e.replace(new RegExp(i[o]),function(e){var i=e.match(m),o=e.replace(/:/g,"");if(i)for(var r=0,a=i.length;r<a;r++){var n=i[r].replace(/:/g,"");return'<i class="fa '+n+' fa-emoji" title="'+n.replace("fa-","")+'"></i>'}else{var s=e.match(w),l=e.match(p);if(s)for(var c=0,h=s.length;c<h;c++){var d=s[c].replace(/:/g,"");return'<i class="'+d+'" title="Editor.md logo ('+d+')"></i>'}else{if(!l){var u="+1"===o?"plus1":o;return u="black_large_square"===u?"black_square":u,u="moon"===u?"waxing_gibbous_moon":u,'<img src="'+t.emoji.path+u+t.emoji.ext+'" class="emoji" title=":'+o+':" alt=":'+o+':" />'}for(var f=0,g=l.length;f<g;f++){var v=l[f].replace(/:/g,"").replace("tw-","");return'<img src="'+t.twemoji.path+v+t.twemoji.ext+'" title="twemoji-'+v+'" alt="twemoji-'+v+'" class="emoji twemoji" />'}}}});return e},c.atLink=function(i){return d.test(i)?(s.atLink&&(i=i.replace(f,function(e,t,i,o){return e.replace(/@/g,"_#_@_#_")}),i=i.replace(d,function(e,i){return'<a href="'+t.urls.atLinkBase+i+'" title="@'+i+'" class="at-link">'+e+"</a>"}).replace(/_#_@_#_/g,"@")),s.emailLink&&(i=i.replace(g,function(t,i,o,r,a){return!i&&e.inArray(a,"jpg|jpeg|png|gif|webp|ico|icon|pdf".split("|"))<0?'<a href="mailto:'+t+'">'+t+"</a>":t})),i):i},c.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 d.test(t)||d.test(i)?(t&&(o+=' title="'+t.replace(/@/g,"@")),o+'">'+i.replace(/@/g,"@")+"</a>"):(t&&(o+=' title="'+t+'"'),o+=">"+i+"</a>")},c.heading=function(e,o){var a=e,s=/\s*\<a\s*href\=\"(.*)\"\s*([^\>]*)\>(.*)\<\/a\>\s*/;if(s.test(e)){var l=[];e=e.split(/\<a\s*([^\>]+)\>([^\>]*)\<\/a\>/);for(var c=0,h=e.length;c<h;c++)l.push(e[c].replace(/\s*href\=\"(.*)\"\s*/g,""));e=l.join(" ")}e=r(e);var d=e.toLowerCase().replace(/[^\w]+/g,"-"),u={text:e,level:o,slug:d},f=/^[\u4e00-\u9fa5]+$/.test(e),g=f?escape(e).replace(/\%/g,""):e.toLowerCase().replace(/[^\w]+/g,"-");n.indexOf(g)>=0&&(g+=t.rand(100,999999)),n.push(g),u.id=g,i.push(u);var p="<h"+o+' id="h'+o+"-"+this.options.headerPrefix+g+'">';return e=e.replace(/(<([^>]+)>)/gi,""),p+='<a name="'+e+'" class="reference-link"></a>',p+='<span class="header-link octicon octicon-link"></span>',p+=s?this.atLink(this.emoji(a)):this.atLink(this.emoji(e)),p+="</h"+o+">"},c.pageBreak=function(e){return v.test(e)&&s.pageBreak&&(e='<hr style="page-break-after:always;" class="page-break editormd-page-break" />'),e},c.paragraph=function(e){var i=/\$\$(.*)\$\$/g.test(e),o=/^\$\$(.*)\$\$$/.test(e),r=o?' class="'+t.classNames.tex+'"':"",a=s.tocm?/^(\[TOC\]|\[TOCM\])$/.test(e):/^\[TOC\]$/.test(e),n=/^\[TOCM\]$/.test(e);e=!o&&i?e.replace(/(\$\$([^\$]*)\$\$)+/g,function(e,i){return'<span class="'+t.classNames.tex+'">'+i.replace(/\$/g,"")+"</span>"}):o?e.replace(/\$/g,""):e;var l='<div class="markdown-toc editormd-markdown-toc">'+e+"</div>";return a?n?'<div class="editormd-toc-menu">'+l+"</div><br/>":l:v.test(e)?this.pageBreak(e):"<p"+r+">"+this.atLink(this.emoji(e))+"</p>\n"},c.code=function(e,i){return"seq"===i||"sequence"===i?'<div class="sequence-diagram">'+e+"</div>":"flow"===i?'<div class="flowchart">'+e+"</div>":"math"===i||"latex"===i||"katex"===i?'<p class="'+t.classNames.tex+'">'+e+"</p>":l.Renderer.prototype.code.apply(this,arguments)},c.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"},c.listitem=function(e,t){return s.taskList&&t?(e=e.replace("<input ","<input class='task-list-item-checkbox' "),'<li class="task-list-item">'+this.atLink(this.emoji(e))+"</li>"):"<li>"+this.atLink(this.emoji(e))+"</li>"},c},t.markdownToCRenderer=function(e,t,i,o,r){r=r||null;var a="",n=0,s=this.classPrefix;o=o||1;for(var l=0,c=e.length;l<c;l++){var h=e[l].text,d=e[l].level;if(!(d<o)){a+=d>n?"":d<n?new Array(n-d+2).join("</ul></li>"):"</ul></li>";var u=h.replace(/(<([^>]+)>)/gi,"");r&&(h=r.emoji(h)),a+='<li><a class="toc-level-'+d+'" href="#'+u+'" level="'+d+'">'+h+"</a><ul>",n=d}}var f=t.find(".markdown-toc");if(f.length<1&&"false"===t.attr("previewContainer")){var g='<div class="markdown-toc '+s+'markdown-toc"></div>';g=i?'<div class="'+s+'toc-menu">'+g+"</div>":g,t.html(g),f=t.find(".markdown-toc")}return i&&f.wrap('<div class="'+s+'toc-menu"></div><br/>'),f.html('<ul class="markdown-toc-list"></ul>').children(".markdown-toc-list").html(a.replace(/\r?\n?\<ul\>\<\/ul\>/g,"")),f},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='<i class="fa fa-angle-down"></i>',n='<a href="javascript:;" class="toc-menu-btn">'+a+i+"</a>",s=r.children("ul"),l=s.find("li");r.append(n),l.first().before("<li><h1>"+i+" "+a+"</h1></li>"),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<s;n++){var l=r[n];t=t.replace(new RegExp("<s*"+l+"s*([^>]*)>([^>]*)<s*/"+l+"s*>","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+"</"+r+">"}):"on*"===a?t.replace(c,function(t,i,o,r,a){var n=e("<"+i+">"+r+"</"+a+">"),s=e(t)[0].attributes,l={};e.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:;"))}),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("<textarea></textarea>"),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,d.renderer),(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){if(n.flowChart){var g=a.find(".flowchart");g.length>0&&g.flowChart()}if(n.sequenceDiagram){var p=a.find(".sequence-diagram");p.length>0&&p.sequenceDiagram({theme:"simple"})}}if(n.tex){var m=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?m():this.loadKaTeX(function(){t.$katex=katex,t.kaTeXLoaded=!0,m()})}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='<div class="'+n+"dialog "+l+'">';""!==i.title&&(c+='<div class="'+n+'dialog-header"'+(i.drag?' style="cursor: move;"':"")+">",c+='<strong class="'+n+'dialog-title">'+i.title+"</strong>",c+="</div>"),i.closed&&(c+='<a href="javascript:;" class="fa fa-close '+n+'dialog-close"></a>'),c+='<div class="'+n+'dialog-container">'+i.content,(i.footer||"string"==typeof i.footer)&&(c+='<div class="'+n+'dialog-footer">'+("boolean"==typeof i.footer?"":i.footer)+"</div>"),c+="</div>",c+='<div class="'+n+"dialog-mask "+n+'dialog-mask-bg"></div>',c+='<div class="'+n+"dialog-mask "+n+'dialog-mask-con"></div>',c+="</div>",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('<button class="'+n+"btn "+p+'">'+g[0]+"</button>"),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.rand=function(e,t){var i=t-e+1;return Math.floor(Math.random()*i+e)},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}});
|