|
|
@ -4,7 +4,7 @@ |
|
|
|
// CommonJS/Node.js
|
|
|
|
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") |
|
|
|
{ |
|
|
|
module.exports = factory; |
|
|
|
module.exports = factory(); |
|
|
|
} |
|
|
|
else if (typeof define === "function") // AMD/CMD/Sea.js
|
|
|
|
{ |
|
|
@ -28,7 +28,7 @@ |
|
|
|
|
|
|
|
"use strict"; |
|
|
|
|
|
|
|
var $ = (typeof (jQuery) !== "undefined") ? jQuery : Zepto; |
|
|
|
var $ = (typeof (window.jQuery) !== "undefined") ? window.jQuery : window.Zepto; |
|
|
|
|
|
|
|
if (typeof ($) === "undefined") { |
|
|
|
return ; |
|
|
@ -112,7 +112,7 @@ |
|
|
|
styleSelectedText : true, |
|
|
|
matchWordHighlight : true, // options: true, false, "onselected"
|
|
|
|
styleActiveLine : true, // Highlight the current line
|
|
|
|
dialogLockScreen : true, |
|
|
|
dialogLockScreen : false, |
|
|
|
dialogShowMask : true, |
|
|
|
dialogDraggable : true, |
|
|
|
dialogMaskBgColor : "#fff", |
|
|
@ -292,7 +292,8 @@ |
|
|
|
}, |
|
|
|
preformattedText : { |
|
|
|
title : "添加预格式文本或代码块", |
|
|
|
emptyAlert : "错误:请填写预格式文本或代码的内容。" |
|
|
|
emptyAlert : "错误:请填写预格式文本或代码的内容。", |
|
|
|
placeholder : "Coding now...." |
|
|
|
}, |
|
|
|
codeBlock : { |
|
|
|
title : "添加代码块", |
|
|
@ -300,7 +301,8 @@ |
|
|
|
selectDefaultText : "请选择代码语言", |
|
|
|
otherLanguage : "其他语言", |
|
|
|
unselectedLanguageAlert : "错误:请选择代码所属的语言类型。", |
|
|
|
codeEmptyAlert : "错误:请填写代码内容。" |
|
|
|
codeEmptyAlert : "错误:请填写代码内容。", |
|
|
|
placeholder : "Coding now...." |
|
|
|
}, |
|
|
|
htmlEntities : { |
|
|
|
title : "HTML 实体字符" |
|
|
@ -351,9 +353,8 @@ |
|
|
|
options = id; |
|
|
|
} |
|
|
|
|
|
|
|
var _this = this; |
|
|
|
var classPrefix = this.classPrefix = editormd.classPrefix; |
|
|
|
var settings = this.settings = $.extend(true, editormd.defaults, options); |
|
|
|
var settings = this.settings = $.extend(true, {}, editormd.defaults, options); |
|
|
|
|
|
|
|
id = (typeof id === "object") ? settings.id : id; |
|
|
|
|
|
|
@ -441,9 +442,9 @@ |
|
|
|
|
|
|
|
if (typeof define === "function" && define.amd) |
|
|
|
{ |
|
|
|
if (typeof katex !== "undefined") |
|
|
|
if (typeof window.katex !== "undefined") |
|
|
|
{ |
|
|
|
editormd.$katex = katex; |
|
|
|
editormd.$katex = window.katex; |
|
|
|
} |
|
|
|
|
|
|
|
if (settings.searchReplace && !settings.readOnly) |
|
|
@ -455,12 +456,12 @@ |
|
|
|
|
|
|
|
if ((typeof define === "function" && define.amd) || !settings.autoLoadModules) |
|
|
|
{ |
|
|
|
if (typeof CodeMirror !== "undefined") { |
|
|
|
editormd.$CodeMirror = CodeMirror; |
|
|
|
if (typeof window.CodeMirror !== "undefined") { |
|
|
|
editormd.$CodeMirror = window.CodeMirror; |
|
|
|
} |
|
|
|
|
|
|
|
if (typeof marked !== "undefined") { |
|
|
|
editormd.$marked = marked; |
|
|
|
if (typeof window.marked !== "undefined") { |
|
|
|
editormd.$marked = window.marked; |
|
|
|
} |
|
|
|
|
|
|
|
this.setCodeMirror().setToolbar().loadedDisplay(); |
|
|
@ -801,7 +802,6 @@ |
|
|
|
} |
|
|
|
|
|
|
|
var cm = this.cm; |
|
|
|
var editor = this.editor; |
|
|
|
var count = cm.lineCount(); |
|
|
|
var preview = this.preview; |
|
|
|
|
|
|
@ -1100,7 +1100,6 @@ |
|
|
|
} |
|
|
|
|
|
|
|
var editor = this.editor; |
|
|
|
var preview = this.preview; |
|
|
|
var classPrefix = this.classPrefix; |
|
|
|
|
|
|
|
var toolbar = this.toolbar = editor.children("." + classPrefix + "toolbar"); |
|
|
@ -1235,7 +1234,7 @@ |
|
|
|
var toolbarIcons = this.toolbarIcons = toolbar.find("." + classPrefix + "menu > li > a"); |
|
|
|
var toolbarIconHandlers = this.getToolbarHandles(); |
|
|
|
|
|
|
|
toolbarIcons.bind(editormd.mouseOrTouch("click", "touchend"), function(event) { |
|
|
|
toolbarIcons.bind("click", function() { |
|
|
|
|
|
|
|
var icon = $(this).children(".fa"); |
|
|
|
var name = icon.attr("name"); |
|
|
@ -1313,7 +1312,7 @@ |
|
|
|
|
|
|
|
var infoDialog = this.infoDialog = editor.children("." + classPrefix + "dialog-info"); |
|
|
|
|
|
|
|
infoDialog.find("." + classPrefix + "dialog-close").bind(editormd.mouseOrTouch("click", "touchend"), function() { |
|
|
|
infoDialog.find("." + classPrefix + "dialog-close").bind("click", function() { |
|
|
|
_this.hideInfoDialog(); |
|
|
|
}); |
|
|
|
|
|
|
@ -1359,7 +1358,6 @@ |
|
|
|
|
|
|
|
$("html,body").css("overflow-x", "hidden"); |
|
|
|
|
|
|
|
var _this = this; |
|
|
|
var editor = this.editor; |
|
|
|
var settings = this.settings; |
|
|
|
var infoDialog = this.infoDialog = editor.children("." + this.classPrefix + "dialog-info"); |
|
|
@ -1422,7 +1420,6 @@ |
|
|
|
*/ |
|
|
|
|
|
|
|
recreate : function() { |
|
|
|
var _this = this; |
|
|
|
var editor = this.editor; |
|
|
|
var settings = this.settings; |
|
|
|
|
|
|
@ -1617,17 +1614,17 @@ |
|
|
|
{ |
|
|
|
case 120: |
|
|
|
$.proxy(toolbarHandlers["watch"], _this)(); |
|
|
|
return false; |
|
|
|
event.stopPropagation(); |
|
|
|
break; |
|
|
|
|
|
|
|
case 121: |
|
|
|
$.proxy(toolbarHandlers["preview"], _this)(); |
|
|
|
return false; |
|
|
|
event.stopPropagation(); |
|
|
|
break; |
|
|
|
|
|
|
|
case 122: |
|
|
|
$.proxy(toolbarHandlers["fullscreen"], _this)(); |
|
|
|
return false; |
|
|
|
event.stopPropagation(); |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
@ -1755,8 +1752,7 @@ |
|
|
|
return this; |
|
|
|
} |
|
|
|
|
|
|
|
cm.on("change", function(_cm, changeObj) { |
|
|
|
|
|
|
|
cm.on("change", function() { |
|
|
|
if (settings.watch) |
|
|
|
{ |
|
|
|
_this.previewContainer.css("padding", settings.autoHeight ? "20px 20px 50px 40px" : "20px"); |
|
|
@ -1905,7 +1901,7 @@ |
|
|
|
|
|
|
|
if(settings.watch) |
|
|
|
{ |
|
|
|
codeMirror.width(editor.width() / 2); |
|
|
|
codeMirror.width((editor.width() / 2) - 1); |
|
|
|
preview.width((!state.preview) ? editor.width() / 2 : editor.width()); |
|
|
|
|
|
|
|
this.previewContainer.css("padding", settings.autoHeight ? "20px 20px 50px 40px" : "20px"); |
|
|
@ -2003,13 +1999,8 @@ |
|
|
|
marked.setOptions(markedOptions); |
|
|
|
|
|
|
|
var newMarkdownDoc = editormd.$marked(cmValue, markedOptions); |
|
|
|
|
|
|
|
//console.info("cmValue", cmValue, newMarkdownDoc);
|
|
|
|
|
|
|
|
newMarkdownDoc = editormd.filterHTMLTags(newMarkdownDoc, settings.htmlDecode); |
|
|
|
|
|
|
|
//console.error("cmValue", cmValue, newMarkdownDoc);
|
|
|
|
|
|
|
|
this.markdownTextarea.text(cmValue); |
|
|
|
|
|
|
|
cm.save(); |
|
|
@ -2215,7 +2206,6 @@ |
|
|
|
*/ |
|
|
|
|
|
|
|
appendMarkdown : function(md) { |
|
|
|
var settings = this.settings; |
|
|
|
var cm = this.cm; |
|
|
|
|
|
|
|
cm.setValue(cm.getValue() + md); |
|
|
@ -2451,6 +2441,19 @@ |
|
|
|
return this; |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 消毁并移除编辑器实例 |
|
|
|
* |
|
|
|
* destroy & remove editor |
|
|
|
* |
|
|
|
* @returns {void} void 无返回值 |
|
|
|
*/ |
|
|
|
|
|
|
|
destroy : function () { |
|
|
|
this.hide(); |
|
|
|
this.editor.remove(); |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 隐藏编辑器部分,只预览HTML |
|
|
|
* Enter preview html state |
|
|
@ -2472,6 +2475,8 @@ |
|
|
|
return this; |
|
|
|
} |
|
|
|
|
|
|
|
var editorHeight = this.editor.outerHeight(); |
|
|
|
|
|
|
|
if (settings.toolbar && toolbar) { |
|
|
|
toolbar.toggle(); |
|
|
|
toolbar.find(".fa[name=preview]").toggleClass("active"); |
|
|
@ -2489,11 +2494,15 @@ |
|
|
|
{ |
|
|
|
this.state.preview = true; |
|
|
|
|
|
|
|
if (this.settings.autoHeight) { |
|
|
|
this.editor.css("height", editorHeight); |
|
|
|
} |
|
|
|
|
|
|
|
if (this.state.fullscreen) { |
|
|
|
preview.css("background", "#fff"); |
|
|
|
} |
|
|
|
|
|
|
|
editor.find("." + this.classPrefix + "preview-close-btn").show().bind(editormd.mouseOrTouch("click", "touchend"), function(){ |
|
|
|
editor.find("." + this.classPrefix + "preview-close-btn").show().bind("click", function(){ |
|
|
|
_this.previewed(); |
|
|
|
}); |
|
|
|
|
|
|
@ -2555,7 +2564,7 @@ |
|
|
|
|
|
|
|
preview[(settings.watch) ? "show" : "hide"](); |
|
|
|
|
|
|
|
previewCloseBtn.hide().unbind(editormd.mouseOrTouch("click", "touchend")); |
|
|
|
previewCloseBtn.hide().unbind("click"); |
|
|
|
|
|
|
|
previewContainer.removeClass(this.classPrefix + "preview-active"); |
|
|
|
|
|
|
@ -2564,6 +2573,10 @@ |
|
|
|
previewContainer.css("padding", "20px"); |
|
|
|
} |
|
|
|
|
|
|
|
if (this.settings.autoHeight) { |
|
|
|
this.editor.css("height", "auto"); |
|
|
|
} |
|
|
|
|
|
|
|
preview.css({ |
|
|
|
background : null, |
|
|
|
position : "absolute", |
|
|
@ -2592,7 +2605,6 @@ |
|
|
|
var _this = this; |
|
|
|
var state = this.state; |
|
|
|
var editor = this.editor; |
|
|
|
var preview = this.preview; |
|
|
|
var toolbar = this.toolbar; |
|
|
|
var settings = this.settings; |
|
|
|
var fullscreenClass = this.classPrefix + "fullscreen"; |
|
|
@ -2890,7 +2902,6 @@ |
|
|
|
|
|
|
|
lowercase : function() { |
|
|
|
var cm = this.cm; |
|
|
|
var cursor = cm.getCursor(); |
|
|
|
var selection = cm.getSelection(); |
|
|
|
var selections = cm.listSelections(); |
|
|
|
|
|
|
@ -3002,7 +3013,6 @@ |
|
|
|
|
|
|
|
"list-ul" : function() { |
|
|
|
var cm = this.cm; |
|
|
|
var cursor = cm.getCursor(); |
|
|
|
var selection = cm.getSelection(); |
|
|
|
|
|
|
|
if (selection === "") |
|
|
@ -3024,7 +3034,6 @@ |
|
|
|
|
|
|
|
"list-ol" : function() { |
|
|
|
var cm = this.cm; |
|
|
|
var cursor = cm.getCursor(); |
|
|
|
var selection = cm.getSelection(); |
|
|
|
|
|
|
|
if(selection === "") |
|
|
@ -3047,7 +3056,6 @@ |
|
|
|
hr : function() { |
|
|
|
var cm = this.cm; |
|
|
|
var cursor = cm.getCursor(); |
|
|
|
var selection = cm.getSelection(); |
|
|
|
|
|
|
|
cm.replaceSelection(((cursor.ch !== 0) ? "\n\n" : "\n") + "------------\n\n"); |
|
|
|
}, |
|
|
@ -3086,7 +3094,6 @@ |
|
|
|
} |
|
|
|
|
|
|
|
var cm = this.cm; |
|
|
|
var selection = cm.getSelection(); |
|
|
|
|
|
|
|
cm.replaceSelection("\r\n[========]\r\n"); |
|
|
|
}, |
|
|
@ -3121,8 +3128,6 @@ |
|
|
|
|
|
|
|
datetime : function() { |
|
|
|
var cm = this.cm; |
|
|
|
var selection = cm.getSelection(); |
|
|
|
var date = new Date(); |
|
|
|
var langName = this.settings.lang.name; |
|
|
|
var datefmt = editormd.dateFormat() + " " + editormd.dateFormat((langName === "zh-cn" || langName === "zh-tw") ? "cn-week-day" : "week-day"); |
|
|
|
|
|
|
@ -3170,20 +3175,19 @@ |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
var isMac = navigator.platform.toUpperCase().indexOf('MAC')>=0; |
|
|
|
var key = isMac ? "Cmd" : "Ctrl"; |
|
|
|
// var isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0;
|
|
|
|
// var key = isMac ? "Cmd" : "Ctrl";
|
|
|
|
|
|
|
|
editormd.keyMaps = { |
|
|
|
[key + "-1"] : "h1", |
|
|
|
[key + "-2"] : "h2", |
|
|
|
[key + "-3"] : "h3", |
|
|
|
[key + "-4"] : "h4", |
|
|
|
[key + "-5"] : "h5", |
|
|
|
[key + "-6"] : "h6", |
|
|
|
[key + "-B"] : "bold", // if this is string == editormd.toolbarHandlers.xxxx
|
|
|
|
[key + "-D"] : "datetime", |
|
|
|
|
|
|
|
[key + "Ctrl-E"] : function() { // emoji
|
|
|
|
"Ctrl-1" : "h1", |
|
|
|
"Ctrl-2" : "h2", |
|
|
|
"Ctrl-3" : "h3", |
|
|
|
"Ctrl-4" : "h4", |
|
|
|
"Ctrl-5" : "h5", |
|
|
|
"Ctrl-6" : "h6", |
|
|
|
"Ctrl-B" : "bold", // if this is string == editormd.toolbarHandlers.xxxx
|
|
|
|
"Ctrl-D" : "datetime", |
|
|
|
"Ctrl-E" : function() { // emoji
|
|
|
|
var cm = this.cm; |
|
|
|
var cursor = cm.getCursor(); |
|
|
|
var selection = cm.getSelection(); |
|
|
@ -3200,11 +3204,10 @@ |
|
|
|
cm.setCursor(cursor.line, cursor.ch + 1); |
|
|
|
} |
|
|
|
}, |
|
|
|
[key + "-Alt-G"] : "goto-line", |
|
|
|
[key + "-H"] : "hr", |
|
|
|
[key + "-I"] : "italic", |
|
|
|
[key + "-K"] : "code", |
|
|
|
|
|
|
|
"Ctrl-Alt-G" : "goto-line", |
|
|
|
"Ctrl-H" : "hr", |
|
|
|
"Ctrl-I" : "italic", |
|
|
|
"Ctrl-K" : "code", |
|
|
|
"Ctrl-L" : function() { |
|
|
|
var cm = this.cm; |
|
|
|
var cursor = cm.getCursor(); |
|
|
@ -3218,8 +3221,7 @@ |
|
|
|
cm.setCursor(cursor.line, cursor.ch + 1); |
|
|
|
} |
|
|
|
}, |
|
|
|
[key + "-U"] : "list-ul", |
|
|
|
|
|
|
|
"Ctrl-U" : "list-ul", |
|
|
|
"Shift-Ctrl-A" : function() { |
|
|
|
var cm = this.cm; |
|
|
|
var cursor = cm.getCursor(); |
|
|
@ -3237,12 +3239,10 @@ |
|
|
|
cm.setCursor(cursor.line, cursor.ch + 1); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
["Shift" + key + "-C"] : "code", |
|
|
|
["Shift" + key + "Q"] : "quote", |
|
|
|
["Shift" + key + "S"] : "del", |
|
|
|
["Shift" + key + "K"] : "tex", // KaTeX
|
|
|
|
|
|
|
|
"Shift-Ctrl-C" : "code", |
|
|
|
"Shift-Ctrl-Q" : "quote", |
|
|
|
"Shift-Ctrl-S" : "del", |
|
|
|
"Shift-Ctrl-K" : "tex", // KaTeX
|
|
|
|
"Shift-Alt-C" : function() { |
|
|
|
var cm = this.cm; |
|
|
|
var cursor = cm.getCursor(); |
|
|
@ -3254,35 +3254,32 @@ |
|
|
|
cm.setCursor(cursor.line, cursor.ch + 3); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
["Shift-" + key + "-Alt-C"] : "code-block", |
|
|
|
["Shift-" + key + "-H"] : "html-entities", |
|
|
|
"Shift-Ctrl-Alt-C" : "code-block", |
|
|
|
"Shift-Ctrl-H" : "html-entities", |
|
|
|
"Shift-Alt-H" : "help", |
|
|
|
["Shift-" + key + "-E"] : "emoji", |
|
|
|
["Shift-" + key + "-U"] : "uppercase", |
|
|
|
"Shift-Ctrl-E" : "emoji", |
|
|
|
"Shift-Ctrl-U" : "uppercase", |
|
|
|
"Shift-Alt-U" : "ucwords", |
|
|
|
["Shift-" + key + "-Alt-U"] : "ucfirst", |
|
|
|
"Shift-Ctrl-Alt-U" : "ucfirst", |
|
|
|
"Shift-Alt-L" : "lowercase", |
|
|
|
|
|
|
|
["Shift-" + key + "-I"] : function() { |
|
|
|
"Shift-Ctrl-I" : function() { |
|
|
|
var cm = this.cm; |
|
|
|
var cursor = cm.getCursor(); |
|
|
|
var selection = cm.getSelection(); |
|
|
|
|
|
|
|
var title = (selection === "") ? "" : " \""+selection+"\""; |
|
|
|
var title = (selection === "") ? "" : " \"" + selection + "\""; |
|
|
|
|
|
|
|
cm.replaceSelection(""); |
|
|
|
cm.replaceSelection(""); |
|
|
|
|
|
|
|
if (selection === "") { |
|
|
|
cm.setCursor(cursor.line, cursor.ch + 4); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
["Shift-" + key + "-Alt-I"] : "image", |
|
|
|
["Shift-" + key + "-L"] : "link", |
|
|
|
["Shift-" + key + "-O"] : "list-ol", |
|
|
|
["Shift-" + key + "-P"] : "preformatted-text", |
|
|
|
["Shift-" + key + "-T"] : "table", |
|
|
|
"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", |
|
|
@ -3333,8 +3330,6 @@ |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
var ucfirst = firstUpperCase; |
|
|
|
|
|
|
|
editormd.firstUpperCase = editormd.ucfirst = firstUpperCase; |
|
|
|
|
|
|
|
editormd.urls = { |
|
|
@ -3355,7 +3350,7 @@ |
|
|
|
|
|
|
|
// Emoji graphics files url path
|
|
|
|
editormd.emoji = { |
|
|
|
path : "http://www.emoji-cheat-sheet.com/graphics/emojis/", |
|
|
|
path : "https://www.webpagefx.com/tools/emoji-cheat-sheet/graphics/emojis/", |
|
|
|
ext : ".png" |
|
|
|
}; |
|
|
|
|
|
|
@ -3421,7 +3416,7 @@ |
|
|
|
matchs[i] = ":\\+1:"; |
|
|
|
} |
|
|
|
|
|
|
|
text = text.replace(new RegExp(matchs[i]), function($1, $2){ |
|
|
|
text = text.replace(new RegExp(matchs[i]), function($1) { |
|
|
|
var faMatchs = $1.match(faIconReg); |
|
|
|
var name = $1.replace(/:/g, ""); |
|
|
|
|
|
|
@ -3502,14 +3497,14 @@ |
|
|
|
|
|
|
|
if (this.options.sanitize) { |
|
|
|
try { |
|
|
|
var prot = decodeURIComponent(unescape(href)).replace(/[^\w:]/g,"").toLowerCase(); |
|
|
|
} catch(e) { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
var prot = decodeURIComponent(unescape(href)).replace(/[^\w:]/g, "").toLowerCase(); |
|
|
|
|
|
|
|
if (prot.indexOf("javascript:") === 0) { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
} catch(e) { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var out = "<a href=\"" + href + "\""; |
|
|
@ -3533,11 +3528,11 @@ |
|
|
|
return out; |
|
|
|
}; |
|
|
|
|
|
|
|
markedRenderer.heading = function(text, level, raw) { |
|
|
|
markedRenderer.heading = function(text, level) { |
|
|
|
|
|
|
|
var linkText = text; |
|
|
|
var hasLinkReg = /\s*\<a\s*href\=\"(.*)\"\s*([^\>]*)\>(.*)\<\/a\>\s*/; |
|
|
|
var getLinkTextReg = /\s*\<a\s*([^\>]+)\>([^\>]*)\<\/a\>\s*/g; |
|
|
|
// var getLinkTextReg = /\s*\<a\s*([^\>]+)\>([^\>]*)\<\/a\>\s*/g;
|
|
|
|
|
|
|
|
if (hasLinkReg.test(text)) |
|
|
|
{ |
|
|
@ -3609,7 +3604,7 @@ |
|
|
|
: ( (pageBreakReg.test(text)) ? this.pageBreak(text) : "<p" + isTeXAddClass + ">" + this.atLink(this.emoji(text)) + "</p>\n" ); |
|
|
|
}; |
|
|
|
|
|
|
|
markedRenderer.code = function (code, lang, escaped) { |
|
|
|
markedRenderer.code = function (code, lang) { |
|
|
|
|
|
|
|
if (lang === "seq" || lang === "sequence") |
|
|
|
{ |
|
|
@ -3800,7 +3795,7 @@ |
|
|
|
editormd.filterHTMLTags = function(html, filters) { |
|
|
|
|
|
|
|
if (typeof html !== "string") { |
|
|
|
html = new String(html); |
|
|
|
html = html.toString(); |
|
|
|
} |
|
|
|
|
|
|
|
if (typeof filters !== "string") { |
|
|
@ -3838,7 +3833,9 @@ |
|
|
|
var $attrs = {}; |
|
|
|
|
|
|
|
$.each(_attrs, function(i, e) { |
|
|
|
if (e.nodeName !== '"') $attrs[e.nodeName] = e.nodeValue; |
|
|
|
if (e.nodeName !== "\"") { |
|
|
|
$attrs[e.nodeName] = e.nodeValue; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
$.each($attrs, function(i) { |
|
|
@ -3909,7 +3906,7 @@ |
|
|
|
editormd.$marked = marked; |
|
|
|
|
|
|
|
var div = $("#" + id); |
|
|
|
var settings = div.settings = $.extend(true, defaults, options || {}); |
|
|
|
var settings = div.settings = $.extend(true, {}, defaults, options || {}); |
|
|
|
var saveTo = div.find("textarea"); |
|
|
|
|
|
|
|
if (saveTo.length < 1) |
|
|
@ -3947,7 +3944,7 @@ |
|
|
|
smartypants : true |
|
|
|
}; |
|
|
|
|
|
|
|
markdownDoc = new String(markdownDoc); |
|
|
|
markdownDoc = markdownDoc.toString(); |
|
|
|
|
|
|
|
var markdownParsed = marked(markdownDoc, markedOptions); |
|
|
|
|
|
|
@ -4114,8 +4111,8 @@ |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
editormd.isIE = (navigator.appName == "Microsoft Internet Explorer"); |
|
|
|
editormd.isIE8 = (editormd.isIE && navigator.appVersion.match(/8./i) == "8."); |
|
|
|
editormd.isIE = (navigator.appName === "Microsoft Internet Explorer"); |
|
|
|
editormd.isIE8 = (editormd.isIE && navigator.appVersion.match(/8./i) === "8."); |
|
|
|
|
|
|
|
/** |
|
|
|
* 动态加载JS文件的方法 |
|
|
@ -4169,8 +4166,8 @@ |
|
|
|
// 使用国外的CDN,加载速度有时会很慢,或者自定义URL
|
|
|
|
// You can custom KaTeX load url.
|
|
|
|
editormd.katexURL = { |
|
|
|
css : "//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min", |
|
|
|
js : "//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min" |
|
|
|
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" |
|
|
|
}; |
|
|
|
|
|
|
|
editormd.kaTeXLoaded = false; |
|
|
@ -4216,6 +4213,7 @@ |
|
|
|
title : "", |
|
|
|
drag : true, |
|
|
|
closed : true, |
|
|
|
cached : false, |
|
|
|
content : "", |
|
|
|
mask : true, |
|
|
|
maskStyle : { |
|
|
@ -4234,8 +4232,6 @@ |
|
|
|
var classPrefix = editormd.classPrefix; |
|
|
|
var guid = (new Date()).getTime(); |
|
|
|
var dialogName = ( (options.name === "") ? classPrefix + "dialog-" + guid : options.name); |
|
|
|
var mouseOrTouch = editormd.mouseOrTouch; |
|
|
|
|
|
|
|
var html = "<div class=\"" + classPrefix + "dialog " + dialogName + "\">"; |
|
|
|
|
|
|
|
if (options.title !== "") |
|
|
@ -4258,7 +4254,6 @@ |
|
|
|
} |
|
|
|
|
|
|
|
html += "</div>"; |
|
|
|
|
|
|
|
html += "<div class=\"" + classPrefix + "dialog-mask " + classPrefix + "dialog-mask-bg\"></div>"; |
|
|
|
html += "<div class=\"" + classPrefix + "dialog-mask " + classPrefix + "dialog-mask-con\"></div>"; |
|
|
|
html += "</div>"; |
|
|
@ -4321,8 +4316,12 @@ |
|
|
|
|
|
|
|
$(window).resize(dialogPosition); |
|
|
|
|
|
|
|
dialog.children("." + classPrefix + "dialog-close").bind(mouseOrTouch("click", "touchend"), function() { |
|
|
|
dialog.children("." + classPrefix + "dialog-close").bind("click", function() { |
|
|
|
dialog.hide().lockScreen(false).hideMask(); |
|
|
|
|
|
|
|
if (!options.cached) { |
|
|
|
dialog.remove(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
if (typeof options.buttons === "object") |
|
|
@ -4336,7 +4335,7 @@ |
|
|
|
|
|
|
|
footer.append("<button class=\"" + classPrefix + "btn " + btnClassName + "\">" + btn[0] + "</button>"); |
|
|
|
btn[1] = $.proxy(btn[1], dialog); |
|
|
|
footer.children("." + btnClassName).bind(mouseOrTouch("click", "touchend"), btn[1]); |
|
|
|
footer.children("." + btnClassName).bind("click", btn[1]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -4346,26 +4345,18 @@ |
|
|
|
var dialogHeader = dialog.children("." + classPrefix + "dialog-header"); |
|
|
|
|
|
|
|
if (!options.mask) { |
|
|
|
dialogHeader.bind(mouseOrTouch("click", "touchend"), function(){ |
|
|
|
dialogHeader.bind("click", function(){ |
|
|
|
editormd.dialogZindex += 2; |
|
|
|
dialog.css("z-index", editormd.dialogZindex); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
dialogHeader.mousedown(function(e) { |
|
|
|
e = e || window.event; //IE
|
|
|
|
posX = e.clientX - parseInt(dialog[0].style.left); |
|
|
|
posY = e.clientY - parseInt(dialog[0].style.top); |
|
|
|
|
|
|
|
document.onmousemove = moveAction; |
|
|
|
}); |
|
|
|
|
|
|
|
var userCanSelect = function (obj) { |
|
|
|
obj.removeClass(classPrefix + "user-unselect").off("selectstart"); |
|
|
|
}; |
|
|
|
|
|
|
|
var userUnselect = function (obj) { |
|
|
|
obj.addClass(classPrefix + "user-unselect").on("selectstart", function(event) { // selectstart for IE
|
|
|
|
obj.addClass(classPrefix + "user-unselect").on("selectstart", function() { // selectstart for IE
|
|
|
|
return false; |
|
|
|
}); |
|
|
|
}; |
|
|
@ -4405,6 +4396,14 @@ |
|
|
|
dialog[0].style.top = top + "px"; |
|
|
|
}; |
|
|
|
|
|
|
|
dialogHeader.mousedown(function(e) { |
|
|
|
e = e || window.event; //IE
|
|
|
|
posX = e.clientX - parseInt(dialog[0].style.left); |
|
|
|
posY = e.clientY - parseInt(dialog[0].style.top); |
|
|
|
|
|
|
|
document.onmousemove = moveAction; |
|
|
|
}); |
|
|
|
|
|
|
|
document.onmouseup = function() { |
|
|
|
userCanSelect($("body")); |
|
|
|
userCanSelect(dialog); |
|
|
|