|
|
|
!function(e){"use strict";"function"==typeof require&&"object"==typeof exports&&"object"==typeof module?module.exports=e:"function"==typeof define?define.amd||define(["jquery"],e):window.editormd=e()}(function(){"use strict";var e="undefined"!=typeof jQuery?jQuery:Zepto;if("undefined"!=typeof e){var t=function(e,i){return new t.fn.init(e,i)};t.title=t.$name="Editor.md",t.version="1.3.0",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","anchor","image","code","preformatted-text","code-block","table","datetime","emoji","htmlEntities","|","watch","preview","fullscreen","clear","|","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",theme:"default",value:"",markdown:"",width:"100%",height:"100%",path:"./lib/",pluginPath:"",autoLoadModules:!0,watch:!0,placeholder:"now coding markdown...",codeFold:!1,autoHeight:!1,autoCloseTags:!0,searchReplace:!1,readOnly:!1,lineNumbers:!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,tocStartLevel:1,htmlDecode:!1,atLink:!0,emailLink:!0,taskList:!1,emoji:!1,tex:!1,flowChart:!1,sequenceDiagram:!1,previewCodeHighlight:!0,toolbar:!0,toolbarAutoFixed:!0,toolbarIcons:function(){return t.toolbarModes.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",anchor:"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",htmlEntities:"fa-copyright",watch:"fa-eye-slash",unwatch:"fa-eye",preview:"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/>A simple markdown doucment online editor.",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:"链接",anchor:"锚点",image:"添加图片",code:"行内代码","preformatted-text":"预格式文本 / 代码块(缩进风格)","code-block":"代码块(多语言风格)",table:"添加表格",datetime:"日期时间",emoji:"Emoji表情",
|
|
|
|
ext:".png"},t.twemoji={path:"http://twemoji.maxcdn.com/36x36/",ext:".png"},t.markedRenderer=function(o,r){var a={toc:!0,tocStartLevel:1,atLink:!0,emailLink:!0,taskList:!1,emoji:!1,tex:!1,flowChart:!1,sequenceDiagram:!1},n=e.extend(a,r||{}),s=t.$marked,l=new s.Renderer;o=o||[];var c=t.regexs.atLink,d=t.regexs.emoji,h=t.regexs.email,u=t.regexs.emailLink,f=t.regexs.twemoji,g=t.regexs.fontAwesome,p=t.regexs.editormdLogo;return l.emoji=function(e){e=e.replace(t.regexs.emojiDatetime,function(e){return e.replace(/:/g,":")});var i=e.match(d);if(!i||!n.emoji)return e;for(var o=0,r=i.length;r>o;o++)e=e.replace(new RegExp(i[o]),function(e){var i=e.match(g),o=e.replace(/:/g,"");if(i)for(var r=0,a=i.length;a>r;r++){var n=i[r].replace(/:/g,"");return'<i class="fa '+n+' fa-emoji" title="'+n.replace("fa-","")+'"></i>'}else{var s=e.match(p),l=e.match(f);if(s)for(var c=0,d=s.length;d>c;c++){var h=s[c].replace(/:/g,"");return'<i class="'+h+'" title="Editor.md logo ('+h+')"></i>'}else{if(!l)return'<img src="'+t.emoji.path+o+t.emoji.ext+'" class="emoji" title=":'+o+':" alt=":'+o+':" />';for(var u=0,m=l.length;m>u;u++){var w=l[u].replace(/:/g,"").replace("tw-","");return'<img src="'+t.twemoji.path+w+t.twemoji.ext+'" title="twemoji-'+w+'" alt="twemoji-'+w+'" class="emoji twemoji" />'}}}});return e},l.atLink=function(e){return c.test(e)?(n.atLink&&(e=e.replace(h,function(e){return e.replace(/@/g,"_#_@_#_")}),e=e.replace(c,function(e,i){return'<a href="'+t.urls.atLinkBase+i+'" title="@'+i+'" class="at-link">'+e+"</a>"}).replace(/_#_@_#_/g,"@")),n.emailLink&&(e=e.replace(u,function(e,t){return t?e:'<a href="mailto:'+e+'">'+e+"</a>"})),e):e},l.link=function(e,t,i){if(this.options.sanitize){try{var o=decodeURIComponent(unescape(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(r){return""}if(0===o.indexOf("javascript:"))return""}var a='<a href="'+e+'"';return c.test(t)||c.test(i)?(t&&(a+=' title="'+t.replace(/@/g,"@")),a+'">'+i.replace(/@/g,"@")+"</a>"):(t&&(a+=' title="'+t+'"'),a+=">"+i+"</a>")},l.heading=function(e,t){var r=e,a=/\s*\<a\s*href\=\"(.*)\"\s*([^\>]*)\>(.*)\<\/a\>\s*/;if(a.test(e)){var n=[];e=e.split(/\<a\s*([^\>]+)\>([^\>]*)\<\/a\>/);for(var s=0,l=e.length;l>s;s++)n.push(e[s].replace(/\s*href\=\"(.*)\"\s*/g,""));e=n.join(" ")}e=i(e);var c=e.toLowerCase().replace(/[^\w]+/g,"-"),d={text:e,level:t,slug:c},h=/^[\u4e00-\u9fa5]+$/.test(e),u=h?escape(e).replace(/\%/g,""):e.toLowerCase().replace(/[^\w]+/g,"-");o.push(d);var f="<h"+t+' id="h'+t+"-"+this.options.headerPrefix+u+'">';return f+='<a name="'+e+'" class="anchor"></a>',f+='<span class="header-link octicon octicon-link"></span>',f+=this.atLink(a?this.emoji(r):this.emoji(e)),f+="</h"+t+">"},l.paragraph=function(e){var i=/\$\$(.*)\$\$/g.test(e),o=/^\$\$(.*)\$\$$/.test(e),r=o?' class="'+t.classNames.tex+'"':"",a=/^\[TOC\]$/.test(e);return e=!o&&i?e.replace(/(\$\$([^\$]*)\$\$)+/g,function(e,i){return'<span class="'+t.classNames.tex+'">'+i.replace(/\$/g,"")+"</span>"}):o?e.replace(/\$/g,""):e,a?'<div class="markdown-toc"><ul class="markdown-toc-list">'+e+"</ul></div>":"<p"+r+">"+this.atLink(this.emoji(e))+"</p>\n"},l.code=function(e,t){return"seq"===t||"sequence"===t?'<div class="sequence-diagram">'+e+"</div>":"flow"===t?'<div class="flowchart">'+e+"</div>":s.Renderer.prototype.code.apply(this,arguments)},l.tablecell=function(e,t){var i=t.header?"th":"td",o=t.align?"<"+i+' style="text-align:'+t.align+'">':"<"+i+">";return o+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},t.markdownToCRenderer=function(e,t,i){var o="",r=0;i=i||1;for(var a=0,n=e.length;n>a;a++){var s=e[a].text,l=e[a].level;i>l||(o+=l>r?"":r>l?new Array(r-l+2).join("</ul></li>"):"</ul></li>",o+='<li><a class="toc-level-'+l+'"
|