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.

1 line
53 KiB

4 years ago
  1. !function(a){"use strict";"function"==typeof require&&"object"==typeof exports&&"object"==typeof module?module.exports=a:"function"==typeof define?define.amd||define(["jquery"],a):window.editormd=a()}(function(){"use strict";var b,c,d,e,f,g,a="undefined"!=typeof jQuery?jQuery:Zepto;if("undefined"!=typeof a)return b=function(a,c){return new b.fn.init(a,c)},b.title=b.$name="Editor.md",b.version="1.5.0",b.homePage="https://pandao.github.io/editor.md/",b.classPrefix="editormd-",b.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"]},b.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:!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 b.toolbarHandlers.ucwords},lowercase:function(){return b.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:b.classPrefix+"bold",h2:b.classPrefix+"bold",h3:b.classPrefix+"bold",h4:b.classPrefix+"bold",h5:b.classPrefix+"bold",h6:b.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:"将所选转
  2. },h2:function(){var a=this.cm,b=a.getCursor(),c=a.getSelection();0!==b.ch?(a.setCursor(b.line,0),a.replaceSelection("## "+c),a.setCursor(b.line,b.ch+3)):a.replaceSelection("## "+c)},h3:function(){var a=this.cm,b=a.getCursor(),c=a.getSelection();0!==b.ch?(a.setCursor(b.line,0),a.replaceSelection("### "+c),a.setCursor(b.line,b.ch+4)):a.replaceSelection("### "+c)},h4:function(){var a=this.cm,b=a.getCursor(),c=a.getSelection();0!==b.ch?(a.setCursor(b.line,0),a.replaceSelection("#### "+c),a.setCursor(b.line,b.ch+5)):a.replaceSelection("#### "+c)},h5:function(){var a=this.cm,b=a.getCursor(),c=a.getSelection();0!==b.ch?(a.setCursor(b.line,0),a.replaceSelection("##### "+c),a.setCursor(b.line,b.ch+6)):a.replaceSelection("##### "+c)},h6:function(){var a=this.cm,b=a.getCursor(),c=a.getSelection();0!==b.ch?(a.setCursor(b.line,0),a.replaceSelection("###### "+c),a.setCursor(b.line,b.ch+7)):a.replaceSelection("###### "+c)},"list-ul":function(){var c,d,e,f,a=this.cm;if(a.getCursor(),c=a.getSelection(),""===c)a.replaceSelection("- "+c);else{for(d=c.split("\n"),e=0,f=d.length;f>e;e++)d[e]=""===d[e]?"":"- "+d[e];a.replaceSelection(d.join("\n"))}},"list-ol":function(){var c,d,e,f,a=this.cm;if(a.getCursor(),c=a.getSelection(),""===c)a.replaceSelection("1. "+c);else{for(d=c.split("\n"),e=0,f=d.length;f>e;e++)d[e]=""===d[e]?"":e+1+". "+d[e];a.replaceSelection(d.join("\n"))}},hr:function(){var a=this.cm,b=a.getCursor();a.getSelection(),a.replaceSelection((0!==b.ch?"\n\n":"\n")+"------------\n\n")},tex:function(){var a,b,c;return this.settings.tex?(a=this.cm,b=a.getCursor(),c=a.getSelection(),a.replaceSelection("$$"+c+"$$"),""===c&&a.setCursor(b.line,b.ch+2),void 0):(alert("settings.tex === false"),this)},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 a=this.cm;a.getSelection(),a.replaceSelection("\r\n[========]\r\n")},image:function(){this.executePlugin("imageDialog","image-dialog/image-dialog")},code:function(){var a=this.cm,b=a.getCursor(),c=a.getSelection();a.replaceSelection("`"+c+"`"),""===c&&a.setCursor(b.line,b.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,f,a=this.cm;a.getSelection(),new Date,e=this.settings.lang.name,f=b.dateFormat()+" "+b.dateFormat("zh-cn"===e||"zh-tw"===e?"cn-week-day":"week-day"),a.replaceSelection(f)},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()}},b.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 a=this.cm,b=a.getCursor(),c=a.getSelection();return this.settings.emoji?(a.replaceSelection(":"+c+":"),""===c&&a.setCursor(b.line,b.ch+1),void 0):(alert("Error: settings.emoji == false"),void 0)},"Ctrl-Alt-G":"goto-line","Ctrl-H":"hr","Ctrl-I":"italic","Ctrl-K":"code","Ctrl-L":function(){var a=this.cm,b=a.getCursor(),c=a.getSelection(),d=""===c?"":' "'+c+'"';a.replaceSelection("["+c+"]("+d+")"),""===c&&a.setCursor(b.line,b.ch+1)},"Ctrl-U":"list-ul","Shift-Ctrl-A":function(){var a=this.cm,b=a.getCursor(),c=a.getSelection();retur