代码功能更新

This commit is contained in:
root
2025-05-18 07:42:27 +00:00
parent 7fc1d422a1
commit 4a90c41da2
2083 changed files with 695218 additions and 3 deletions
@@ -0,0 +1,227 @@
/*!
* Code block dialog plugin for Editor.md
*
* @file code-block-dialog.js
* @author pandao
* @version 1.2.0
* @updateTime 2015-03-07
* {@link https://github.com/pandao/editor.md}
* @license MIT
*/
(function () {
var factory = function (exports) {
var cmEditor;
var pluginName = "code-block-dialog";
// for CodeBlock dialog select
var codeLanguages = exports.codeLanguages = {
asp: ["ASP", "vbscript"],
actionscript: ["ActionScript(3.0)/Flash/Flex", "clike"],
bash: ["Bash/Bat", "shell"],
css: ["CSS", "css"],
c: ["C", "clike"],
cpp: ["C++", "clike"],
csharp: ["C#", "clike"],
coffeescript: ["CoffeeScript", "coffeescript"],
d: ["D", "d"],
dart: ["Dart", "dart"],
delphi: ["Delphi/Pascal", "pascal"],
erlang: ["Erlang", "erlang"],
go: ["Golang", "go"],
groovy: ["Groovy", "groovy"],
html: ["HTML", "text/html"],
java: ["Java", "clike"],
json: ["JSON", "text/json"],
javascript: ["Javascript", "javascript"],
lua: ["Lua", "lua"],
less: ["LESS", "css"],
markdown: ["Markdown", "gfm"],
"objective-c": ["Objective-C", "clike"],
php: ["PHP", "php"],
perl: ["Perl", "perl"],
python: ["Python", "python"],
r: ["R", "r"],
rst: ["reStructedText", "rst"],
ruby: ["Ruby", "ruby"],
sql: ["SQL", "sql"],
sass: ["SASS/SCSS", "sass"],
shell: ["Shell", "shell"],
scala: ["Scala", "clike"],
swift: ["Swift", "clike"],
vb: ["VB/VBScript", "vb"],
xml: ["XML", "text/xml"],
yaml: ["YAML", "yaml"]
};
exports.fn.codeBlockDialog = function () {
var _this = this;
var cm = this.cm;
var lang = this.lang;
var editor = this.editor;
var settings = this.settings;
var cursor = cm.getCursor();
var selection = cm.getSelection();
var classPrefix = this.classPrefix;
var dialogName = classPrefix + pluginName, dialog;
var dialogLang = lang.dialog.codeBlock;
cm.focus();
if (editor.find("." + dialogName).length > 0) {
dialog = editor.find("." + dialogName);
dialog.find("option:first").attr("selected", "selected");
dialog.find("textarea").val(selection);
this.dialogShowMask(dialog);
this.dialogLockScreen();
dialog.show();
} else {
var dialogHTML = "<div class=\"" + classPrefix + "code-toolbar\">" +
dialogLang.selectLabel + "<select><option selected=\"selected\" value=\"\">" + dialogLang.selectDefaultText + "</option></select>" +
"</div>" +
"<textarea placeholder=\"" + dialogLang.placeholder + "\" style=\"display:none;\">" + selection + "</textarea>";
dialog = this.createDialog({
name: dialogName,
title: dialogLang.title,
width: 780,
height: 565,
mask: settings.dialogShowMask,
drag: settings.dialogDraggable,
content: dialogHTML,
lockScreen: settings.dialogLockScreen,
maskStyle: {
opacity: settings.dialogMaskOpacity,
backgroundColor: settings.dialogMaskBgColor
},
buttons: {
enter: [lang.buttons.enter, function () {
var codeTexts = this.find("textarea").val();
var langName = this.find("select").val();
if (langName === "") {
alert(lang.dialog.codeBlock.unselectedLanguageAlert);
return false;
}
if (codeTexts === "") {
alert(lang.dialog.codeBlock.codeEmptyAlert);
return false;
}
langName = (langName === "other") ? "" : langName;
cm.replaceSelection(["```" + langName, codeTexts, "```"].join("\n"));
if (langName === "") {
cm.setCursor(cursor.line, cursor.ch + 3);
}
this.hide().lockScreen(false).hideMask();
return false;
}],
cancel: [lang.buttons.cancel, function () {
this.hide().lockScreen(false).hideMask();
return false;
}]
}
});
}
var langSelect = dialog.find("select");
if (langSelect.find("option").length === 1) {
for (var key in codeLanguages) {
var codeLang = codeLanguages[key];
langSelect.append("<option value=\"" + key + "\" mode=\"" + codeLang[1] + "\">" + codeLang[0] + "</option>");
}
langSelect.append("<option value=\"other\">" + dialogLang.otherLanguage + "</option>");
}
var mode = langSelect.find("option:selected").attr("mode");
var cmConfig = {
mode: (mode) ? mode : "text/html",
theme: settings.theme,
tabSize: 4,
autofocus: true,
autoCloseTags: true,
indentUnit: 4,
lineNumbers: true,
lineWrapping: true,
extraKeys: {
"Ctrl-Q": function (cm) {
cm.foldCode(cm.getCursor());
}
},
foldGutter: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
matchBrackets: true,
indentWithTabs: true,
styleActiveLine: true,
styleSelectedText: true,
autoCloseBrackets: true,
showTrailingSpace: true,
highlightSelectionMatches: true
};
var textarea = dialog.find("textarea");
var cmObj = dialog.find(".CodeMirror");
if (dialog.find(".CodeMirror").length < 1) {
cmEditor = exports.$CodeMirror.fromTextArea(textarea[0], cmConfig);
cmObj = dialog.find(".CodeMirror");
cmObj.css({
"float": "none",
margin: "8px 0",
border: "1px solid #ddd",
fontSize: settings.fontSize,
width: "100%",
height: "390px"
});
cmEditor.on("change", function (cm) {
textarea.val(cm.getValue());
});
} else {
cmEditor.setValue(cm.getSelection());
}
langSelect.change(function () {
var _mode = $(this).find("option:selected").attr("mode");
cmEditor.setOption("mode", _mode);
});
};
};
// CommonJS/Node.js
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
module.exports = factory;
} else if (typeof define === "function") // AMD/CMD/Sea.js
{
if (define.amd) { // for Require.js
define(["editormd"], function (editormd) {
factory(editormd);
});
} else { // for Sea.js
define(function (require) {
var editormd = require("./../../editormd");
factory(editormd);
});
}
} else {
factory(window.editormd);
}
})();
@@ -0,0 +1,297 @@
/*!
* Emoji dialog plugin for Editor.md
*
* @file emoji-dialog.js
* @author pandao
* @version 1.2.0
* @updateTime 2015-03-08
* {@link https://github.com/pandao/editor.md}
* @license MIT
*/
(function () {
var factory = function (exports) {
var $ = jQuery;
var pluginName = "emoji-dialog";
var emojiTabIndex = 0;
var emojiData = [];
var selecteds = [];
var logoPrefix = "editormd-logo";
var logos = [
logoPrefix,
logoPrefix + "-1x",
logoPrefix + "-2x",
logoPrefix + "-3x",
logoPrefix + "-4x",
logoPrefix + "-5x",
logoPrefix + "-6x",
logoPrefix + "-7x",
logoPrefix + "-8x"
];
var langs = {
"zh-cn": {
toolbar: {
emoji: "Emoji 表情"
},
dialog: {
emoji: {
title: "Emoji 表情"
}
}
},
"zh-tw": {
toolbar: {
emoji: "Emoji 表情"
},
dialog: {
emoji: {
title: "Emoji 表情"
}
}
},
"en": {
toolbar: {
emoji: "Emoji"
},
dialog: {
emoji: {
title: "Emoji"
}
}
}
};
exports.fn.emojiDialog = function () {
var _this = this;
var cm = this.cm;
var settings = _this.settings;
if (!settings.emoji) {
alert("settings.emoji == false");
return;
}
var path = settings.pluginPath + pluginName + "/";
var editor = this.editor;
var cursor = cm.getCursor();
var selection = cm.getSelection();
var classPrefix = this.classPrefix;
$.extend(true, this.lang, langs[this.lang.name]);
this.setToolbar();
var lang = this.lang;
var dialogName = classPrefix + pluginName, dialog;
var dialogLang = lang.dialog.emoji;
var dialogContent = [
"<div class=\"" + classPrefix + "emoji-dialog-box\" style=\"width: 760px;height: 334px;margin-bottom: 8px;overflow: hidden;\">",
"<div class=\"" + classPrefix + "tab\"></div>",
"</div>",
].join("\n");
cm.focus();
if (editor.find("." + dialogName).length > 0) {
dialog = editor.find("." + dialogName);
selecteds = [];
dialog.find("a").removeClass("selected");
this.dialogShowMask(dialog);
this.dialogLockScreen();
dialog.show();
} else {
dialog = this.createDialog({
name: dialogName,
title: dialogLang.title,
width: 800,
height: 475,
mask: settings.dialogShowMask,
drag: settings.dialogDraggable,
content: dialogContent,
lockScreen: settings.dialogLockScreen,
maskStyle: {
opacity: settings.dialogMaskOpacity,
backgroundColor: settings.dialogMaskBgColor
},
buttons: {
enter: [lang.buttons.enter, function () {
cm.replaceSelection(selecteds.join(" "));
this.hide().lockScreen(false).hideMask();
return false;
}],
cancel: [lang.buttons.cancel, function () {
this.hide().lockScreen(false).hideMask();
return false;
}]
}
});
}
var category = ["Github emoji", "Twemoji", "Font awesome", "Editor.md logo"];
var tab = dialog.find("." + classPrefix + "tab");
if (tab.html() === "") {
var head = "<ul class=\"" + classPrefix + "tab-head\">";
for (var i = 0; i < 4; i++) {
var active = (i === 0) ? " class=\"active\"" : "";
head += "<li" + active + "><a href=\"javascript:;\">" + category[i] + "</a></li>";
}
head += "</ul>";
tab.append(head);
var container = "<div class=\"" + classPrefix + "tab-container\">";
for (var x = 0; x < 4; x++) {
var display = (x === 0) ? "" : "display:none;";
container += "<div class=\"" + classPrefix + "tab-box\" style=\"height: 260px;overflow: hidden;overflow-y: auto;" + display + "\"></div>";
}
container += "</div>";
tab.append(container);
}
var tabBoxs = tab.find("." + classPrefix + "tab-box");
var emojiCategories = ["github-emoji", "twemoji", "font-awesome", logoPrefix];
var drawTable = function () {
var cname = emojiCategories[emojiTabIndex];
var $data = emojiData[cname];
var $tab = tabBoxs.eq(emojiTabIndex);
if ($tab.html() !== "") {
//console.log("break =>", cname);
return;
}
var pagination = function (data, type) {
var rowNumber = (type === "editormd-logo") ? "5" : 20;
var pageTotal = Math.ceil(data.length / rowNumber);
var table = "<div class=\"" + classPrefix + "grid-table\">";
for (var i = 0; i < pageTotal; i++) {
var row = "<div class=\"" + classPrefix + "grid-table-row\">";
for (var x = 0; x < rowNumber; x++) {
var emoji = $.trim(data[(i * rowNumber) + x]);
if (typeof emoji !== "undefined" && emoji !== "") {
var img = "", icon = "";
if (type === "github-emoji") {
var src = (emoji === "+1") ? "plus1" : emoji;
src = (src === "black_large_square") ? "black_square" : src;
src = (src === "moon") ? "waxing_gibbous_moon" : src;
src = exports.emoji.path + src + exports.emoji.ext;
img = "<img src=\"" + src + "\" width=\"24\" class=\"emoji\" title=\"&#58;" + emoji + "&#58;\" alt=\"&#58;" + emoji + "&#58;\" />";
row += "<a href=\"javascript:;\" value=\":" + emoji + ":\" title=\":" + emoji + ":\" class=\"" + classPrefix + "emoji-btn\">" + img + "</a>";
} else if (type === "twemoji") {
var twemojiSrc = exports.twemoji.path + emoji + exports.twemoji.ext;
img = "<img src=\"" + twemojiSrc + "\" width=\"24\" title=\"twemoji-" + emoji + "\" alt=\"twemoji-" + emoji + "\" class=\"emoji twemoji\" />";
row += "<a href=\"javascript:;\" value=\":tw-" + emoji + ":\" title=\":tw-" + emoji + ":\" class=\"" + classPrefix + "emoji-btn\">" + img + "</a>";
} else if (type === "font-awesome") {
icon = "<i class=\"fa fa-" + emoji + " fa-emoji\" title=\"" + emoji + "\"></i>";
row += "<a href=\"javascript:;\" value=\":fa-" + emoji + ":\" title=\":fa-" + emoji + ":\" class=\"" + classPrefix + "emoji-btn\">" + icon + "</a>";
} else if (type === "editormd-logo") {
icon = "<i class=\"" + emoji + "\" title=\"Editor.md logo (" + emoji + ")\"></i>";
row += "<a href=\"javascript:;\" value=\":" + emoji + ":\" title=\":" + emoji + ":\" style=\"width:20%;\" class=\"" + classPrefix + "emoji-btn\">" + icon + "</a>";
}
} else {
row += "<a href=\"javascript:;\" value=\"\"></a>";
}
}
row += "</div>";
table += row;
}
table += "</div>";
return table;
};
if (emojiTabIndex === 0) {
for (var i = 0, len = $data.length; i < len; i++) {
var h4Style = (i === 0) ? " style=\"margin: 0 0 10px;\"" : " style=\"margin: 10px 0;\"";
$tab.append("<h4" + h4Style + ">" + $data[i].category + "</h4>");
$tab.append(pagination($data[i].list, cname));
}
} else {
$tab.append(pagination($data, cname));
}
$tab.find("." + classPrefix + "emoji-btn").bind(exports.mouseOrTouch("click", "touchend"), function () {
$(this).toggleClass("selected");
if ($(this).hasClass("selected")) {
selecteds.push($(this).attr("value"));
}
});
};
if (emojiData.length < 1) {
if (typeof dialog.loading === "function") {
dialog.loading(true);
}
$.getJSON(path + "emoji.json?temp=" + Math.random(), function (json) {
if (typeof dialog.loading === "function") {
dialog.loading(false);
}
emojiData = json;
emojiData[logoPrefix] = logos;
drawTable();
});
} else {
drawTable();
}
tab.find("li").bind(exports.mouseOrTouch("click", "touchend"), function () {
var $this = $(this);
emojiTabIndex = $this.index();
$this.addClass("active").siblings().removeClass("active");
tabBoxs.eq(emojiTabIndex).show().siblings().hide();
drawTable();
});
};
};
// CommonJS/Node.js
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
module.exports = factory;
} else if (typeof define === "function") // AMD/CMD/Sea.js
{
if (define.amd) { // for Require.js
define(["editormd"], function (editormd) {
factory(editormd);
});
} else { // for Sea.js
define(function (require) {
var editormd = require("./../../editormd");
factory(editormd);
});
}
} else {
factory(window.editormd);
}
})();
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,152 @@
/*!
* Goto line dialog plugin for Editor.md
*
* @file goto-line-dialog.js
* @author pandao
* @version 1.2.1
* @updateTime 2015-06-09
* {@link https://github.com/pandao/editor.md}
* @license MIT
*/
(function () {
var factory = function (exports) {
var $ = jQuery;
var pluginName = "goto-line-dialog";
var langs = {
"zh-cn": {
toolbar: {
"goto-line": "跳转到行"
},
dialog: {
"goto-line": {
title: "跳转到行",
label: "请输入行号",
error: "错误:"
}
}
},
"zh-tw": {
toolbar: {
"goto-line": "跳轉到行"
},
dialog: {
"goto-line": {
title: "跳轉到行",
label: "請輸入行號",
error: "錯誤:"
}
}
},
"en": {
toolbar: {
"goto-line": "Goto line"
},
dialog: {
"goto-line": {
title: "Goto line",
label: "Enter a line number, range ",
error: "Error: "
}
}
}
};
exports.fn.gotoLineDialog = function () {
var _this = this;
var cm = this.cm;
var editor = this.editor;
var settings = this.settings;
var path = settings.pluginPath + pluginName + "/";
var classPrefix = this.classPrefix;
var dialogName = classPrefix + pluginName, dialog;
$.extend(true, this.lang, langs[this.lang.name]);
this.setToolbar();
var lang = this.lang;
var dialogLang = lang.dialog["goto-line"];
var lineCount = cm.lineCount();
dialogLang.error += dialogLang.label + " 1-" + lineCount;
if (editor.find("." + dialogName).length < 1) {
var dialogContent = [
"<div class=\"editormd-form\" style=\"padding: 10px 0;\">",
"<p style=\"margin: 0;\">" + dialogLang.label + " 1-" + lineCount + "&nbsp;&nbsp;&nbsp;<input type=\"number\" class=\"number-input\" style=\"width: 60px;\" value=\"1\" max=\"" + lineCount + "\" min=\"1\" data-line-number /></p>",
"</div>"
].join("\n");
dialog = this.createDialog({
name: dialogName,
title: dialogLang.title,
width: 400,
height: 180,
mask: settings.dialogShowMask,
drag: settings.dialogDraggable,
content: dialogContent,
lockScreen: settings.dialogLockScreen,
maskStyle: {
opacity: settings.dialogMaskOpacity,
backgroundColor: settings.dialogMaskBgColor
},
buttons: {
enter: [lang.buttons.enter, function () {
var line = parseInt(this.find("[data-line-number]").val());
if (line < 1 || line > lineCount) {
alert(dialogLang.error);
return false;
}
_this.gotoLine(line);
this.hide().lockScreen(false).hideMask();
return false;
}],
cancel: [lang.buttons.cancel, function () {
this.hide().lockScreen(false).hideMask();
return false;
}]
}
});
}
dialog = editor.find("." + dialogName);
this.dialogShowMask(dialog);
this.dialogLockScreen();
dialog.show();
};
};
// CommonJS/Node.js
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
module.exports = factory;
} else if (typeof define === "function") // AMD/CMD/Sea.js
{
if (define.amd) { // for Require.js
define(["editormd"], function (editormd) {
factory(editormd);
});
} else { // for Sea.js
define(function (require) {
var editormd = require("./../../editormd");
factory(editormd);
});
}
} else {
factory(window.editormd);
}
})();
@@ -0,0 +1,96 @@
/*!
* Help dialog plugin for Editor.md
*
* @file help-dialog.js
* @author pandao
* @version 1.2.0
* @updateTime 2015-03-08
* {@link https://github.com/pandao/editor.md}
* @license MIT
*/
(function () {
var factory = function (exports) {
var $ = jQuery;
var pluginName = "help-dialog";
exports.fn.helpDialog = function () {
var _this = this;
var lang = this.lang;
var editor = this.editor;
var settings = this.settings;
var path = settings.pluginPath + pluginName + "/";
var classPrefix = this.classPrefix;
var dialogName = classPrefix + pluginName, dialog;
var dialogLang = lang.dialog.help;
if (editor.find("." + dialogName).length < 1) {
var dialogContent = "<div class=\"markdown-body\" style=\"font-family:微软雅黑, Helvetica, Tahoma, STXihei,Arial;height:390px;overflow:auto;font-size:14px;border-bottom:1px solid #ddd;padding:0 20px 20px 0;\"></div>";
dialog = this.createDialog({
name: dialogName,
title: dialogLang.title,
width: 840,
height: 540,
mask: settings.dialogShowMask,
drag: settings.dialogDraggable,
content: dialogContent,
lockScreen: settings.dialogLockScreen,
maskStyle: {
opacity: settings.dialogMaskOpacity,
backgroundColor: settings.dialogMaskBgColor
},
buttons: {
close: [lang.buttons.close, function () {
this.hide().lockScreen(false).hideMask();
return false;
}]
}
});
}
dialog = editor.find("." + dialogName);
this.dialogShowMask(dialog);
this.dialogLockScreen();
dialog.show();
var helpContent = dialog.find(".markdown-body");
if (helpContent.html() === "") {
$.get(path + "help.md", function (text) {
var md = exports.$marked(text);
helpContent.html(md);
helpContent.find("a").attr("target", "_blank");
});
}
};
};
// CommonJS/Node.js
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
module.exports = factory;
} else if (typeof define === "function") // AMD/CMD/Sea.js
{
if (define.amd) { // for Require.js
define(["editormd"], function (editormd) {
factory(editormd);
});
} else { // for Sea.js
define(function (require) {
var editormd = require("./../../editormd");
factory(editormd);
});
}
} else {
factory(window.editormd);
}
})();
@@ -0,0 +1,77 @@
##### Markdown语法教程 (Markdown syntax tutorial)
- [Markdown Syntax](http://daringfireball.net/projects/markdown/syntax/ "Markdown Syntax")
- [Mastering Markdown](https://guides.github.com/features/mastering-markdown/ "Mastering Markdown")
- [Markdown Basics](https://help.github.com/articles/markdown-basics/ "Markdown Basics")
- [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown/ "GitHub Flavored Markdown")
- [Markdown 语法说明(简体中文)](http://www.markdown.cn/ "Markdown 语法说明(简体中文)")
- [Markdown 語法說明(繁體中文)](http://markdown.tw/ "Markdown 語法說明(繁體中文)")
##### 键盘快捷键 (Keyboard shortcuts)
> If Editor.md code editor is on focus, you can use keyboard shortcuts.
| Keyboard shortcuts (键盘快捷键) | 说明 | Description |
| :---------------------------------------------- |:--------------------------------- | :------------------------------------------------- |
| F9 | 切换实时预览 | Switch watch/unwatch |
| F10 | 全屏HTML预览(按 Shift + ESC 退出) | Full preview HTML (Press Shift + ESC exit) |
| F11 | 切换全屏状态 | Switch fullscreen (Press ESC exit) |
| Ctrl + 1~6 / Command + 1~6 | 插入标题1~6 | Insert heading 1~6 |
| Ctrl + A / Command + A | 全选 | Select all |
| Ctrl + B / Command + B | 插入粗体 | Insert bold |
| Ctrl + D / Command + D | 插入日期时间 | Insert datetime |
| Ctrl + E / Command + E | 插入Emoji符号 | Insert &#58;emoji&#58; |
| Ctrl + F / Command + F | 查找/搜索 | Start searching |
| Ctrl + G / Command + G | 切换到下一个搜索结果项 | Find next search results |
| Ctrl + H / Command + H | 插入水平线 | Insert horizontal rule |
| Ctrl + I / Command + I | 插入斜体 | Insert italic |
| Ctrl + K / Command + K | 插入行内代码 | Insert inline code |
| Ctrl + L / Command + L | 插入链接 | Insert link |
| Ctrl + U / Command + U | 插入无序列表 | Insert unordered list |
| Ctrl + Q | 代码折叠切换 | Switch code fold |
| Ctrl + Z / Command + Z | 撤销 | Undo |
| Ctrl + Y / Command + Y | 重做 | Redo |
| Ctrl + Shift + A | 插入@链接 | Insert &#64;link |
| Ctrl + Shift + C | 插入行内代码 | Insert inline code |
| Ctrl + Shift + E | 打开插入Emoji表情对话框 | Open emoji dialog |
| Ctrl + Shift + F / Command + Option + F | 替换 | Replace |
| Ctrl + Shift + G / Shift + Command + G | 切换到上一个搜索结果项 | Find previous search results |
| Ctrl + Shift + H | 打开HTML实体字符对话框 | Open HTML Entities dialog |
| Ctrl + Shift + I | 插入图片 | Insert image &#33;[]&#40;&#41; |
| Ctrl + Shift + K | 插入TeX(KaTeX)公式符号 | Insert TeX(KaTeX) symbol &#36;&#36;TeX&#36;&#36; |
| Ctrl + Shift + L | 打开插入链接对话框 | Open link dialog |
| Ctrl + Shift + O | 插入有序列表 | Insert ordered list |
| Ctrl + Shift + P | 打开插入PRE对话框 | Open Preformatted text dialog |
| Ctrl + Shift + Q | 插入引用 | Insert blockquotes |
| Ctrl + Shift + R / Shift + Command + Option + F | 全部替换 | Replace all |
| Ctrl + Shift + S | 插入删除线 | Insert strikethrough |
| Ctrl + Shift + T | 打开插入表格对话框 | Open table dialog |
| Ctrl + Shift + U | 将所选文字转成大写 | Selection text convert to uppercase |
| Shift + Alt + C | 插入```代码 | Insert code blocks (```) |
| Shift + Alt + H | 打开使用帮助对话框 | Open help dialog |
| Shift + Alt + L | 将所选文本转成小写 | Selection text convert to lowercase |
| Shift + Alt + P | 插入分页符 | Insert page break |
| Alt + L | 将所选文本转成小写 | Selection text convert to lowercase |
| Shift + Alt + U | 将所选的每个单词的首字母转成大写 | Selection words first letter convert to Uppercase |
| Ctrl + Shift + Alt + C | 打开插入代码块对话框层 | Open code blocks dialog |
| Ctrl + Shift + Alt + I | 打开插入图片对话框层 | Open image dialog |
| Ctrl + Shift + Alt + U | 将所选文本的第一个首字母转成大写 | Selection text first letter convert to uppercase |
| Ctrl + Alt + G | 跳转到指定的行 | Goto line |
##### Emoji表情参考 (Emoji reference)
- [Github emoji](http://www.emoji-cheat-sheet.com/ "Github emoji")
- [Twitter Emoji \(Twemoji\)](http://twitter.github.io/twemoji/preview.html "Twitter Emoji \(Twemoji\)")
- [FontAwesome icons emoji](http://fortawesome.github.io/Font-Awesome/icons/ "FontAwesome icons emoji")
##### 流程图参考 (Flowchart reference)
[http://adrai.github.io/flowchart.js/](http://adrai.github.io/flowchart.js/)
##### 时序图参考 (SequenceDiagram reference)
[http://bramp.github.io/js-sequence-diagrams/](http://bramp.github.io/js-sequence-diagrams/)
##### TeX/LaTeX reference
[http://meta.wikimedia.org/wiki/Help:Formula](http://meta.wikimedia.org/wiki/Help:Formula)
@@ -0,0 +1,159 @@
/*!
* HTML entities dialog plugin for Editor.md
*
* @file html-entities-dialog.js
* @author pandao
* @version 1.2.0
* @updateTime 2015-03-08
* {@link https://github.com/pandao/editor.md}
* @license MIT
*/
(function () {
var factory = function (exports) {
var $ = jQuery;
var pluginName = "html-entities-dialog";
var selecteds = [];
var entitiesData = [];
exports.fn.htmlEntitiesDialog = function () {
var _this = this;
var cm = this.cm;
var lang = _this.lang;
var settings = _this.settings;
var path = settings.pluginPath + pluginName + "/";
var editor = this.editor;
var cursor = cm.getCursor();
var selection = cm.getSelection();
var classPrefix = _this.classPrefix;
var dialogName = classPrefix + "dialog-" + pluginName, dialog;
var dialogLang = lang.dialog.htmlEntities;
var dialogContent = [
'<div class="' + classPrefix + 'html-entities-box" style=\"width: 760px;height: 334px;margin-bottom: 8px;overflow: hidden;overflow-y: auto;\">',
'<div class="' + classPrefix + 'grid-table">',
'</div>',
'</div>',
].join("\r\n");
cm.focus();
if (editor.find("." + dialogName).length > 0) {
dialog = editor.find("." + dialogName);
selecteds = [];
dialog.find("a").removeClass("selected");
this.dialogShowMask(dialog);
this.dialogLockScreen();
dialog.show();
} else {
dialog = this.createDialog({
name: dialogName,
title: dialogLang.title,
width: 800,
height: 475,
mask: settings.dialogShowMask,
drag: settings.dialogDraggable,
content: dialogContent,
lockScreen: settings.dialogLockScreen,
maskStyle: {
opacity: settings.dialogMaskOpacity,
backgroundColor: settings.dialogMaskBgColor
},
buttons: {
enter: [lang.buttons.enter, function () {
cm.replaceSelection(selecteds.join(" "));
this.hide().lockScreen(false).hideMask();
return false;
}],
cancel: [lang.buttons.cancel, function () {
this.hide().lockScreen(false).hideMask();
return false;
}]
}
});
}
var table = dialog.find("." + classPrefix + "grid-table");
var drawTable = function () {
if (entitiesData.length < 1) return;
var rowNumber = 20;
var pageTotal = Math.ceil(entitiesData.length / rowNumber);
table.html("");
for (var i = 0; i < pageTotal; i++) {
var row = "<div class=\"" + classPrefix + "grid-table-row\">";
for (var x = 0; x < rowNumber; x++) {
var entity = entitiesData[(i * rowNumber) + x];
if (typeof entity !== "undefined") {
var name = entity.name.replace("&amp;", "&");
row += "<a href=\"javascript:;\" value=\"" + entity.name + "\" title=\"" + name + "\" class=\"" + classPrefix + "html-entity-btn\">" + name + "</a>";
}
}
row += "</div>";
table.append(row);
}
dialog.find("." + classPrefix + "html-entity-btn").bind(exports.mouseOrTouch("click", "touchend"), function () {
$(this).toggleClass("selected");
if ($(this).hasClass("selected")) {
selecteds.push($(this).attr("value"));
}
});
};
if (entitiesData.length < 1) {
if (typeof (dialog.loading) == "function") dialog.loading(true);
$.getJSON(path + pluginName.replace("-dialog", "") + ".json", function (json) {
if (typeof (dialog.loading) == "function") dialog.loading(false);
entitiesData = json;
drawTable();
});
} else {
drawTable();
}
};
};
// CommonJS/Node.js
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
module.exports = factory;
} else if (typeof define === "function") // AMD/CMD/Sea.js
{
if (define.amd) { // for Require.js
define(["editormd"], function (editormd) {
factory(editormd);
});
} else { // for Sea.js
define(function (require) {
var editormd = require("./../../editormd");
factory(editormd);
});
}
} else {
factory(window.editormd);
}
})();
@@ -0,0 +1,930 @@
[
{
"name": "&amp;#64;",
"description": "at symbol"
},
{
"name": "&amp;copy;",
"description": "copyright symbol"
},
{
"name": "&amp;reg;",
"description": "registered symbol"
},
{
"name": "&amp;trade;",
"description": "trademark symbol"
},
{
"name": "&amp;hearts;",
"description": "heart"
},
{
"name": "&amp;nbsp;",
"description": "Inserts a non-breaking blank space"
},
{
"name": "&amp;amp;",
"description": "Ampersand"
},
{
"name": "&amp;#36;",
"description": "dollar symbol"
},
{
"name": "&amp;cent;",
"description": "Cent symbol"
},
{
"name": "&amp;pound;",
"description": "Pound"
},
{
"name": "&amp;yen;",
"description": "Yen"
},
{
"name": "&amp;euro;",
"description": "Euro symbol"
},
{
"name": "&amp;quot;",
"description": "quotation mark"
},
{
"name": "&amp;ldquo;",
"description": "Opening Double Quotes "
},
{
"name": "&amp;rdquo;",
"description": "Closing Double Quotes "
},
{
"name": "&amp;lsquo;",
"description": "Opening Single Quote Mark "
},
{
"name": "&amp;rsquo;",
"description": "Closing Single Quote Mark "
},
{
"name": "&amp;laquo;",
"description": "angle quotation mark (left)"
},
{
"name": "&amp;raquo;",
"description": "angle quotation mark (right)"
},
{
"name": "&amp;lsaquo;",
"description": "single left angle quotation"
},
{
"name": "&amp;rsaquo;",
"description": "single right angle quotation"
},
{
"name": "&amp;sect;",
"description": "Section Symbol"
},
{
"name": "&amp;micro;",
"description": "micro sign"
},
{
"name": "&amp;para;",
"description": "Paragraph symbol"
},
{
"name": "&amp;bull;",
"description": "Big List Dot"
},
{
"name": "&amp;middot;",
"description": "Medium List Dot"
},
{
"name": "&amp;hellip;",
"description": "horizontal ellipsis"
},
{
"name": "&amp;#124;",
"description": "vertical bar"
},
{
"name": "&amp;brvbar;",
"description": "broken vertical bar"
},
{
"name": "&amp;ndash;",
"description": "en-dash"
},
{
"name": "&amp;mdash;",
"description": "em-dash"
},
{
"name": "&amp;curren;",
"description": "Generic currency symbol"
},
{
"name": "&amp;#33;",
"description": "exclamation point"
},
{
"name": "&amp;#35;",
"description": "number sign"
},
{
"name": "&amp;#39;",
"description": "single quote"
},
{
"name": "&amp;#40;",
"description": ""
},
{
"name": "&amp;#41;",
"description": ""
},
{
"name": "&amp;#42;",
"description": "asterisk"
},
{
"name": "&amp;#43;",
"description": "plus sign"
},
{
"name": "&amp;#44;",
"description": "comma"
},
{
"name": "&amp;#45;",
"description": "minus sign - hyphen"
},
{
"name": "&amp;#46;",
"description": "period"
},
{
"name": "&amp;#47;",
"description": "slash"
},
{
"name": "&amp;#48;",
"description": "0"
},
{
"name": "&amp;#49;",
"description": "1"
},
{
"name": "&amp;#50;",
"description": "2"
},
{
"name": "&amp;#51;",
"description": "3"
},
{
"name": "&amp;#52;",
"description": "4"
},
{
"name": "&amp;#53;",
"description": "5"
},
{
"name": "&amp;#54;",
"description": "6"
},
{
"name": "&amp;#55;",
"description": "7"
},
{
"name": "&amp;#56;",
"description": "8"
},
{
"name": "&amp;#57;",
"description": "9"
},
{
"name": "&amp;#58;",
"description": "colon"
},
{
"name": "&amp;#59;",
"description": "semicolon"
},
{
"name": "&amp;#61;",
"description": "equal sign"
},
{
"name": "&amp;#63;",
"description": "question mark"
},
{
"name": "&amp;lt;",
"description": "Less than"
},
{
"name": "&amp;gt;",
"description": "Greater than"
},
{
"name": "&amp;le;",
"description": "Less than or Equal to"
},
{
"name": "&amp;ge;",
"description": "Greater than or Equal to"
},
{
"name": "&amp;times;",
"description": "Multiplication symbol"
},
{
"name": "&amp;divide;",
"description": "Division symbol"
},
{
"name": "&amp;minus;",
"description": "Minus symbol"
},
{
"name": "&amp;plusmn;",
"description": "Plus/minus symbol"
},
{
"name": "&amp;ne;",
"description": "Not Equal"
},
{
"name": "&amp;sup1;",
"description": "Superscript 1"
},
{
"name": "&amp;sup2;",
"description": "Superscript 2"
},
{
"name": "&amp;sup3;",
"description": "Superscript 3"
},
{
"name": "&amp;frac12;",
"description": "Fraction ½"
},
{
"name": "&amp;frac14;",
"description": "Fraction ¼"
},
{
"name": "&amp;frac34;",
"description": "Fraction ¾"
},
{
"name": "&amp;permil;",
"description": "per mille"
},
{
"name": "&amp;deg;",
"description": "Degree symbol"
},
{
"name": "&amp;radic;",
"description": "square root"
},
{
"name": "&amp;infin;",
"description": "Infinity"
},
{
"name": "&amp;larr;",
"description": "left arrow"
},
{
"name": "&amp;uarr;",
"description": "up arrow"
},
{
"name": "&amp;rarr;",
"description": "right arrow"
},
{
"name": "&amp;darr;",
"description": "down arrow"
},
{
"name": "&amp;harr;",
"description": "left right arrow"
},
{
"name": "&amp;crarr;",
"description": "carriage return arrow"
},
{
"name": "&amp;lceil;",
"description": "left ceiling"
},
{
"name": "&amp;rceil;",
"description": "right ceiling"
},
{
"name": "&amp;lfloor;",
"description": "left floor"
},
{
"name": "&amp;rfloor;",
"description": "right floor"
},
{
"name": "&amp;spades;",
"description": "spade"
},
{
"name": "&amp;clubs;",
"description": "club"
},
{
"name": "&amp;hearts;",
"description": "heart"
},
{
"name": "&amp;diams;",
"description": "diamond"
},
{
"name": "&amp;loz;",
"description": "lozenge"
},
{
"name": "&amp;dagger;",
"description": "dagger"
},
{
"name": "&amp;Dagger;",
"description": "double dagger"
},
{
"name": "&amp;iexcl;",
"description": "inverted exclamation mark"
},
{
"name": "&amp;iquest;",
"description": "inverted question mark"
},
{
"name": "&amp;#338;",
"description": "latin capital letter OE"
},
{
"name": "&amp;#339;",
"description": "latin small letter oe"
},
{
"name": "&amp;#352;",
"description": "latin capital letter S with caron"
},
{
"name": "&amp;#353;",
"description": "latin small letter s with caron"
},
{
"name": "&amp;#376;",
"description": "latin capital letter Y with diaeresis"
},
{
"name": "&amp;#402;",
"description": "latin small f with hook - function"
},
{
"name": "&amp;not;",
"description": "not sign"
},
{
"name": "&amp;ordf;",
"description": "feminine ordinal indicator"
},
{
"name": "&amp;uml;",
"description": "spacing diaeresis - umlaut"
},
{
"name": "&amp;macr;",
"description": "spacing macron - overline"
},
{
"name": "&amp;acute;",
"description": "acute accent - spacing acute"
},
{
"name": "&amp;Agrave;",
"description": "latin capital letter A with grave"
},
{
"name": "&amp;Aacute;",
"description": "latin capital letter A with acute"
},
{
"name": "&amp;Acirc;",
"description": "latin capital letter A with circumflex"
},
{
"name": "&amp;Atilde;",
"description": "latin capital letter A with tilde"
},
{
"name": "&amp;Auml;",
"description": "latin capital letter A with diaeresis"
},
{
"name": "&amp;Aring;",
"description": "latin capital letter A with ring above"
},
{
"name": "&amp;AElig;",
"description": "latin capital letter AE"
},
{
"name": "&amp;Ccedil;",
"description": "latin capital letter C with cedilla"
},
{
"name": "&amp;Egrave;",
"description": "latin capital letter E with grave"
},
{
"name": "&amp;Eacute;",
"description": "latin capital letter E with acute"
},
{
"name": "&amp;Ecirc;",
"description": "latin capital letter E with circumflex"
},
{
"name": "&amp;Euml;",
"description": "latin capital letter E with diaeresis"
},
{
"name": "&amp;Igrave;",
"description": "latin capital letter I with grave"
},
{
"name": "&amp;Iacute;",
"description": "latin capital letter I with acute"
},
{
"name": "&amp;Icirc;",
"description": "latin capital letter I with circumflex"
},
{
"name": "&amp;Iuml;",
"description": "latin capital letter I with diaeresis"
},
{
"name": "&amp;ETH;",
"description": "latin capital letter ETH"
},
{
"name": "&amp;Ntilde;",
"description": "latin capital letter N with tilde"
},
{
"name": "&amp;Ograve;",
"description": "latin capital letter O with grave"
},
{
"name": "&amp;Oacute;",
"description": "latin capital letter O with acute"
},
{
"name": "&amp;Ocirc;",
"description": "latin capital letter O with circumflex"
},
{
"name": "&amp;Otilde;",
"description": "latin capital letter O with tilde"
},
{
"name": "&amp;Ouml;",
"description": "latin capital letter O with diaeresis"
},
{
"name": "&amp;times;",
"description": "multiplication sign"
},
{
"name": "&amp;Oslash;",
"description": "latin capital letter O with slash"
},
{
"name": "&amp;Ugrave;",
"description": "latin capital letter U with grave"
},
{
"name": "&amp;Uacute;",
"description": "latin capital letter U with acute"
},
{
"name": "&amp;Ucirc;",
"description": "latin capital letter U with circumflex"
},
{
"name": "&amp;Uuml;",
"description": "latin capital letter U with diaeresis"
},
{
"name": "&amp;Yacute;",
"description": "latin capital letter Y with acute"
},
{
"name": "&amp;THORN;",
"description": "latin capital letter THORN"
},
{
"name": "&amp;szlig;",
"description": "latin small letter sharp s - ess-zed"
},
{
"name": "&amp;eth;",
"description": "latin capital letter eth"
},
{
"name": "&amp;ntilde;",
"description": "latin capital letter n with tilde"
},
{
"name": "&amp;ograve;",
"description": "latin capital letter o with grave"
},
{
"name": "&amp;oacute;",
"description": "latin capital letter o with acute"
},
{
"name": "&amp;ocirc;",
"description": "latin capital letter o with circumflex"
},
{
"name": "&amp;otilde;",
"description": "latin capital letter o with tilde"
},
{
"name": "&amp;ouml;",
"description": "latin capital letter o with diaeresis"
},
{
"name": "&amp;times;",
"description": "multiplication sign"
},
{
"name": "&amp;oslash;",
"description": "latin capital letter o with slash"
},
{
"name": "&amp;ugrave;",
"description": "latin capital letter u with grave"
},
{
"name": "&amp;uacute;",
"description": "latin capital letter u with acute"
},
{
"name": "&amp;ucirc;",
"description": "latin capital letter u with circumflex"
},
{
"name": "&amp;uuml;",
"description": "latin capital letter u with diaeresis"
},
{
"name": "&amp;yacute;",
"description": "latin capital letter y with acute"
},
{
"name": "&amp;thorn;",
"description": "latin capital letter thorn"
},
{
"name": "&amp;yuml;",
"description": "latin small letter y with diaeresis"
},
{
"name": "&amp;agrave;",
"description": "latin capital letter a with grave"
},
{
"name": "&amp;aacute;",
"description": "latin capital letter a with acute"
},
{
"name": "&amp;acirc;",
"description": "latin capital letter a with circumflex"
},
{
"name": "&amp;atilde;",
"description": "latin capital letter a with tilde"
},
{
"name": "&amp;auml;",
"description": "latin capital letter a with diaeresis"
},
{
"name": "&amp;aring;",
"description": "latin capital letter a with ring above"
},
{
"name": "&amp;aelig;",
"description": "latin capital letter ae"
},
{
"name": "&amp;ccedil;",
"description": "latin capital letter c with cedilla"
},
{
"name": "&amp;egrave;",
"description": "latin capital letter e with grave"
},
{
"name": "&amp;eacute;",
"description": "latin capital letter e with acute"
},
{
"name": "&amp;ecirc;",
"description": "latin capital letter e with circumflex"
},
{
"name": "&amp;euml;",
"description": "latin capital letter e with diaeresis"
},
{
"name": "&amp;igrave;",
"description": "latin capital letter i with grave"
},
{
"name": "&amp;Iacute;",
"description": "latin capital letter i with acute"
},
{
"name": "&amp;icirc;",
"description": "latin capital letter i with circumflex"
},
{
"name": "&amp;iuml;",
"description": "latin capital letter i with diaeresis"
},
{
"name": "&amp;#65;",
"description": "A"
},
{
"name": "&amp;#66;",
"description": "B"
},
{
"name": "&amp;#67;",
"description": "C"
},
{
"name": "&amp;#68;",
"description": "D"
},
{
"name": "&amp;#69;",
"description": "E"
},
{
"name": "&amp;#70;",
"description": "F"
},
{
"name": "&amp;#71;",
"description": "G"
},
{
"name": "&amp;#72;",
"description": "H"
},
{
"name": "&amp;#73;",
"description": "I"
},
{
"name": "&amp;#74;",
"description": "J"
},
{
"name": "&amp;#75;",
"description": "K"
},
{
"name": "&amp;#76;",
"description": "L"
},
{
"name": "&amp;#77;",
"description": "M"
},
{
"name": "&amp;#78;",
"description": "N"
},
{
"name": "&amp;#79;",
"description": "O"
},
{
"name": "&amp;#80;",
"description": "P"
},
{
"name": "&amp;#81;",
"description": "Q"
},
{
"name": "&amp;#82;",
"description": "R"
},
{
"name": "&amp;#83;",
"description": "S"
},
{
"name": "&amp;#84;",
"description": "T"
},
{
"name": "&amp;#85;",
"description": "U"
},
{
"name": "&amp;#86;",
"description": "V"
},
{
"name": "&amp;#87;",
"description": "W"
},
{
"name": "&amp;#88;",
"description": "X"
},
{
"name": "&amp;#89;",
"description": "Y"
},
{
"name": "&amp;#90;",
"description": "Z"
},
{
"name": "&amp;#91;",
"description": "opening bracket"
},
{
"name": "&amp;#92;",
"description": "backslash"
},
{
"name": "&amp;#93;",
"description": "closing bracket"
},
{
"name": "&amp;#94;",
"description": "caret - circumflex"
},
{
"name": "&amp;#95;",
"description": "underscore"
},
{
"name": "&amp;#96;",
"description": "grave accent"
},
{
"name": "&amp;#97;",
"description": "a"
},
{
"name": "&amp;#98;",
"description": "b"
},
{
"name": "&amp;#99;",
"description": "c"
},
{
"name": "&amp;#100;",
"description": "d"
},
{
"name": "&amp;#101;",
"description": "e"
},
{
"name": "&amp;#102;",
"description": "f"
},
{
"name": "&amp;#103;",
"description": "g"
},
{
"name": "&amp;#104;",
"description": "h"
},
{
"name": "&amp;#105;",
"description": "i"
},
{
"name": "&amp;#106;",
"description": "j"
},
{
"name": "&amp;#107;",
"description": "k"
},
{
"name": "&amp;#108;",
"description": "l"
},
{
"name": "&amp;#109;",
"description": "m"
},
{
"name": "&amp;#110;",
"description": "n"
},
{
"name": "&amp;#111;",
"description": "o"
},
{
"name": "&amp;#112;",
"description": "p"
},
{
"name": "&amp;#113;",
"description": "q"
},
{
"name": "&amp;#114;",
"description": "r"
},
{
"name": "&amp;#115;",
"description": "s"
},
{
"name": "&amp;#116;",
"description": "t"
},
{
"name": "&amp;#117;",
"description": "u"
},
{
"name": "&amp;#118;",
"description": "v"
},
{
"name": "&amp;#119;",
"description": "w"
},
{
"name": "&amp;#120;",
"description": "x"
},
{
"name": "&amp;#121;",
"description": "y"
},
{
"name": "&amp;#122;",
"description": "z"
},
{
"name": "&amp;#123;",
"description": "opening brace"
},
{
"name": "&amp;#124;",
"description": "vertical bar"
},
{
"name": "&amp;#125;",
"description": "closing brace"
},
{
"name": "&amp;#126;",
"description": "equivalency sign - tilde"
}
]
@@ -0,0 +1,211 @@
/*!
* Image (upload) dialog plugin for Editor.md
*
* @file image-dialog.js
* @author pandao
* @version 1.3.4
* @updateTime 2015-06-09
* {@link https://github.com/pandao/editor.md}
* @license MIT
*/
(function () {
var factory = function (exports) {
var pluginName = "image-dialog";
exports.fn.imageDialog = function () {
var _this = this;
var cm = this.cm;
var lang = this.lang;
var editor = this.editor;
var settings = this.settings;
var cursor = cm.getCursor();
var selection = cm.getSelection();
var imageLang = lang.dialog.image;
var classPrefix = this.classPrefix;
var iframeName = classPrefix + "image-iframe";
var dialogName = classPrefix + pluginName, dialog;
cm.focus();
var loading = function (show) {
var _loading = dialog.find("." + classPrefix + "dialog-mask");
_loading[(show) ? "show" : "hide"]();
};
if (editor.find("." + dialogName).length < 1) {
var guid = (new Date).getTime();
var action = settings.imageUploadURL + (settings.imageUploadURL.indexOf("?") >= 0 ? "&" : "?") + "guid=" + guid;
if (settings.crossDomainUpload) {
action += "&callback=" + settings.uploadCallbackURL + "&dialog_id=editormd-image-dialog-" + guid;
}
var dialogContent = ((settings.imageUpload) ? "<form action=\"" + action + "\" target=\"" + iframeName + "\" method=\"post\" enctype=\"multipart/form-data\" class=\"" + classPrefix + "form\">" : "<div class=\"" + classPrefix + "form\">") +
((settings.imageUpload) ? "<iframe name=\"" + iframeName + "\" id=\"" + iframeName + "\" guid=\"" + guid + "\"></iframe>" : "") +
"<label>" + imageLang.url + "</label>" +
"<input type=\"text\" data-url />" + (function () {
return (settings.imageUpload) ? "<div class=\"" + classPrefix + "file-input\">" +
"<input type=\"file\" name=\"" + classPrefix + "image-file\" accept=\"image/*\" />" +
"<input type=\"submit\" value=\"" + imageLang.uploadButton + "\" />" +
"</div>" : "";
})() +
"<br/>" +
"<label>" + imageLang.alt + "</label>" +
"<input type=\"text\" value=\"" + selection + "\" data-alt />" +
"<br/>" +
"<label>" + imageLang.link + "</label>" +
"<input type=\"text\" value=\"http://\" data-link />" +
"<br/>" +
((settings.imageUpload) ? "</form>" : "</div>");
//var imageFooterHTML = "<button class=\"" + classPrefix + "btn " + classPrefix + "image-manager-btn\" style=\"float:left;\">" + imageLang.managerButton + "</button>";
dialog = this.createDialog({
title: imageLang.title,
width: (settings.imageUpload) ? 465 : 380,
height: 254,
name: dialogName,
content: dialogContent,
mask: settings.dialogShowMask,
drag: settings.dialogDraggable,
lockScreen: settings.dialogLockScreen,
maskStyle: {
opacity: settings.dialogMaskOpacity,
backgroundColor: settings.dialogMaskBgColor
},
buttons: {
enter: [lang.buttons.enter, function () {
var url = this.find("[data-url]").val();
var alt = this.find("[data-alt]").val();
var link = this.find("[data-link]").val();
if (url === "") {
alert(imageLang.imageURLEmpty);
return false;
}
var altAttr = (alt !== "") ? " \"" + alt + "\"" : "";
if (link === "" || link === "http://") {
cm.replaceSelection("![" + alt + "](" + url + altAttr + ")");
} else {
cm.replaceSelection("[![" + alt + "](" + url + altAttr + ")](" + link + altAttr + ")");
}
if (alt === "") {
cm.setCursor(cursor.line, cursor.ch + 2);
}
this.hide().lockScreen(false).hideMask();
//删除对话框
this.remove();
return false;
}],
cancel: [lang.buttons.cancel, function () {
this.hide().lockScreen(false).hideMask();
//删除对话框
this.remove();
return false;
}]
}
});
dialog.attr("id", classPrefix + "image-dialog-" + guid);
if (!settings.imageUpload) {
return;
}
var fileInput = dialog.find("[name=\"" + classPrefix + "image-file\"]");
fileInput.bind("change", function () {
var fileName = fileInput.val();
var isImage = new RegExp("(\\.(" + settings.imageFormats.join("|") + "))$", "i"); // /(\.(webp|jpg|jpeg|gif|bmp|png))$/
if (fileName === "") {
alert(imageLang.uploadFileEmpty);
return false;
}
if (!isImage.test(fileName)) {
alert(imageLang.formatNotAllowed + settings.imageFormats.join(", "));
return false;
}
loading(true);
var submitHandler = function () {
var uploadIframe = document.getElementById(iframeName);
uploadIframe.onload = function () {
loading(false);
var body = (uploadIframe.contentWindow ? uploadIframe.contentWindow : uploadIframe.contentDocument).document.body;
var json = (body.innerText) ? body.innerText : ((body.textContent) ? body.textContent : null);
json = (typeof JSON.parse !== "undefined") ? JSON.parse(json) : eval("(" + json + ")");
if (!settings.crossDomainUpload) {
if (json.success === 1) {
dialog.find("[data-url]").val(json.url);
} else {
alert(json.message);
}
}
return false;
};
};
dialog.find("[type=\"submit\"]").bind("click", submitHandler).trigger("click");
});
}
dialog = editor.find("." + dialogName);
dialog.find("[type=\"text\"]").val("");
dialog.find("[type=\"file\"]").val("");
dialog.find("[data-link]").val("http://");
this.dialogShowMask(dialog);
this.dialogLockScreen();
dialog.show();
};
};
// CommonJS/Node.js
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
module.exports = factory;
} else if (typeof define === "function") // AMD/CMD/Sea.js
{
if (define.amd) { // for Require.js
define(["editormd"], function (editormd) {
factory(editormd);
});
} else { // for Sea.js
define(function (require) {
var editormd = require("./../../editormd");
factory(editormd);
});
}
} else {
factory(window.editormd);
}
})();
@@ -0,0 +1,124 @@
/*!
* Link dialog plugin for Editor.md
*
* @file link-dialog.js
* @author pandao
* @version 1.2.1
* @updateTime 2015-06-09
* {@link https://github.com/pandao/editor.md}
* @license MIT
*/
(function () {
var factory = function (exports) {
var pluginName = "link-dialog";
exports.fn.linkDialog = function () {
var _this = this;
var cm = this.cm;
var editor = this.editor;
var settings = this.settings;
var selection = cm.getSelection();
var lang = this.lang;
var linkLang = lang.dialog.link;
var classPrefix = this.classPrefix;
var dialogName = classPrefix + pluginName, dialog;
cm.focus();
if (editor.find("." + dialogName).length > 0) {
dialog = editor.find("." + dialogName);
dialog.find("[data-url]").val("http://");
dialog.find("[data-title]").val(selection);
this.dialogShowMask(dialog);
this.dialogLockScreen();
dialog.show();
} else {
var dialogHTML = "<div class=\"" + classPrefix + "form\">" +
"<label>" + linkLang.url + "</label>" +
"<input type=\"text\" value=\"http://\" data-url />" +
"<br/>" +
"<label>" + linkLang.urlTitle + "</label>" +
"<input type=\"text\" value=\"" + selection + "\" data-title />" +
"<br/>" +
"</div>";
dialog = this.createDialog({
title: linkLang.title,
width: 380,
height: 211,
content: dialogHTML,
mask: settings.dialogShowMask,
drag: settings.dialogDraggable,
lockScreen: settings.dialogLockScreen,
maskStyle: {
opacity: settings.dialogMaskOpacity,
backgroundColor: settings.dialogMaskBgColor
},
buttons: {
enter: [lang.buttons.enter, function () {
var url = this.find("[data-url]").val();
var title = this.find("[data-title]").val();
if (url === "http://" || url === "") {
alert(linkLang.urlEmpty);
return false;
}
/*if (title === "")
{
alert(linkLang.titleEmpty);
return false;
}*/
var str = "[" + title + "](" + url + " \"" + title + "\")";
if (title == "") {
str = "[" + url + "](" + url + ")";
}
cm.replaceSelection(str);
this.hide().lockScreen(false).hideMask();
return false;
}],
cancel: [lang.buttons.cancel, function () {
this.hide().lockScreen(false).hideMask();
return false;
}]
}
});
}
};
};
// CommonJS/Node.js
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
module.exports = factory;
} else if (typeof define === "function") // AMD/CMD/Sea.js
{
if (define.amd) { // for Require.js
define(["editormd"], function (editormd) {
factory(editormd);
});
} else { // for Sea.js
define(function (require) {
var editormd = require("./../../editormd");
factory(editormd);
});
}
} else {
factory(window.editormd);
}
})();
@@ -0,0 +1,107 @@
/*!
* Link dialog plugin for Editor.md
*
* @file link-dialog.js
* @author pandao
* @version 1.2.0
* @updateTime 2015-03-07
* {@link https://github.com/pandao/editor.md}
* @license MIT
*/
(function () {
var factory = function (exports) {
var $ = jQuery; // if using module loader(Require.js/Sea.js).
var langs = {
"zh-cn": {
toolbar: {
table: "表格"
},
dialog: {
table: {
title: "添加表格",
cellsLabel: "单元格数",
alignLabel: "对齐方式",
rows: "行数",
cols: "列数",
aligns: ["默认", "左对齐", "居中对齐", "右对齐"]
}
}
},
"zh-tw": {
toolbar: {
table: "添加表格"
},
dialog: {
table: {
title: "添加表格",
cellsLabel: "單元格數",
alignLabel: "對齊方式",
rows: "行數",
cols: "列數",
aligns: ["默認", "左對齊", "居中對齊", "右對齊"]
}
}
},
"en": {
toolbar: {
table: "Tables"
},
dialog: {
table: {
title: "Tables",
cellsLabel: "Cells",
alignLabel: "Align",
rows: "Rows",
cols: "Cols",
aligns: ["Default", "Left align", "Center align", "Right align"]
}
}
}
};
exports.fn.htmlEntities = function () {
/*
var _this = this; // this == the current instance object of Editor.md
var lang = _this.lang;
var settings = _this.settings;
var editor = this.editor;
var cursor = cm.getCursor();
var selection = cm.getSelection();
var classPrefix = this.classPrefix;
$.extend(true, this.lang, langs[this.lang.name]); // l18n
this.setToolbar();
cm.focus();
*/
//....
};
};
// CommonJS/Node.js
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
module.exports = factory;
} else if (typeof define === "function") // AMD/CMD/Sea.js
{
if (define.amd) { // for Require.js
define(["editormd"], function (editormd) {
factory(editormd);
});
} else { // for Sea.js
define(function (require) {
var editormd = require("./../../editormd");
factory(editormd);
});
}
} else {
factory(window.editormd);
}
})();
@@ -0,0 +1,164 @@
/*!
* Preformatted text dialog plugin for Editor.md
*
* @file preformatted-text-dialog.js
* @author pandao
* @version 1.2.0
* @updateTime 2015-03-07
* {@link https://github.com/pandao/editor.md}
* @license MIT
*/
(function () {
var factory = function (exports) {
var cmEditor;
var pluginName = "preformatted-text-dialog";
exports.fn.preformattedTextDialog = function () {
var _this = this;
var cm = this.cm;
var lang = this.lang;
var editor = this.editor;
var settings = this.settings;
var cursor = cm.getCursor();
var selection = cm.getSelection();
var classPrefix = this.classPrefix;
var dialogLang = lang.dialog.preformattedText;
var dialogName = classPrefix + pluginName, dialog;
cm.focus();
if (editor.find("." + dialogName).length > 0) {
dialog = editor.find("." + dialogName);
dialog.find("textarea").val(selection);
this.dialogShowMask(dialog);
this.dialogLockScreen();
dialog.show();
} else {
var dialogContent = "<textarea placeholder=\"" + dialogLang.placeholder + "\" style=\"display:none;\">" + selection + "</textarea>";
dialog = this.createDialog({
name: dialogName,
title: dialogLang.title,
width: 780,
height: 540,
mask: settings.dialogShowMask,
drag: settings.dialogDraggable,
content: dialogContent,
lockScreen: settings.dialogLockScreen,
maskStyle: {
opacity: settings.dialogMaskOpacity,
backgroundColor: settings.dialogMaskBgColor
},
buttons: {
enter: [lang.buttons.enter, function () {
var codeTexts = this.find("textarea").val();
if (codeTexts === "") {
alert(dialogLang.emptyAlert);
return false;
}
codeTexts = codeTexts.split("\n");
for (var i in codeTexts) {
codeTexts[i] = " " + codeTexts[i];
}
codeTexts = codeTexts.join("\n");
if (cursor.ch !== 0) {
codeTexts = "\r\n\r\n" + codeTexts;
}
cm.replaceSelection(codeTexts);
this.hide().lockScreen(false).hideMask();
return false;
}],
cancel: [lang.buttons.cancel, function () {
this.hide().lockScreen(false).hideMask();
return false;
}]
}
});
}
var cmConfig = {
mode: "text/html",
theme: settings.theme,
tabSize: 4,
autofocus: true,
autoCloseTags: true,
indentUnit: 4,
lineNumbers: true,
lineWrapping: true,
extraKeys: {
"Ctrl-Q": function (cm) {
cm.foldCode(cm.getCursor());
}
},
foldGutter: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
matchBrackets: true,
indentWithTabs: true,
styleActiveLine: true,
styleSelectedText: true,
autoCloseBrackets: true,
showTrailingSpace: true,
highlightSelectionMatches: true
};
var textarea = dialog.find("textarea");
var cmObj = dialog.find(".CodeMirror");
if (dialog.find(".CodeMirror").length < 1) {
cmEditor = exports.$CodeMirror.fromTextArea(textarea[0], cmConfig);
cmObj = dialog.find(".CodeMirror");
cmObj.css({
"float": "none",
margin: "0 0 5px",
border: "1px solid #ddd",
fontSize: settings.fontSize,
width: "100%",
height: "410px"
});
cmEditor.on("change", function (cm) {
textarea.val(cm.getValue());
});
} else {
cmEditor.setValue(cm.getSelection());
}
};
};
// CommonJS/Node.js
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
module.exports = factory;
} else if (typeof define === "function") // AMD/CMD/Sea.js
{
if (define.amd) { // for Require.js
define(["editormd"], function (editormd) {
factory(editormd);
});
} else { // for Sea.js
define(function (require) {
var editormd = require("./../../editormd");
factory(editormd);
});
}
} else {
factory(window.editormd);
}
})();
@@ -0,0 +1,145 @@
/*!
* Reference link dialog plugin for Editor.md
*
* @file reference-link-dialog.js
* @author pandao
* @version 1.2.1
* @updateTime 2015-06-09
* {@link https://github.com/pandao/editor.md}
* @license MIT
*/
(function () {
var factory = function (exports) {
var pluginName = "reference-link-dialog";
var ReLinkId = 1;
exports.fn.referenceLinkDialog = function () {
var _this = this;
var cm = this.cm;
var lang = this.lang;
var editor = this.editor;
var settings = this.settings;
var cursor = cm.getCursor();
var selection = cm.getSelection();
var dialogLang = lang.dialog.referenceLink;
var classPrefix = this.classPrefix;
var dialogName = classPrefix + pluginName, dialog;
cm.focus();
if (editor.find("." + dialogName).length < 1) {
var dialogHTML = "<div class=\"" + classPrefix + "form\">" +
"<label>" + dialogLang.name + "</label>" +
"<input type=\"text\" value=\"[" + ReLinkId + "]\" data-name />" +
"<br/>" +
"<label>" + dialogLang.urlId + "</label>" +
"<input type=\"text\" data-url-id />" +
"<br/>" +
"<label>" + dialogLang.url + "</label>" +
"<input type=\"text\" value=\"http://\" data-url />" +
"<br/>" +
"<label>" + dialogLang.urlTitle + "</label>" +
"<input type=\"text\" value=\"" + selection + "\" data-title />" +
"<br/>" +
"</div>";
dialog = this.createDialog({
name: dialogName,
title: dialogLang.title,
width: 380,
height: 296,
content: dialogHTML,
mask: settings.dialogShowMask,
drag: settings.dialogDraggable,
lockScreen: settings.dialogLockScreen,
maskStyle: {
opacity: settings.dialogMaskOpacity,
backgroundColor: settings.dialogMaskBgColor
},
buttons: {
enter: [lang.buttons.enter, function () {
var name = this.find("[data-name]").val();
var url = this.find("[data-url]").val();
var rid = this.find("[data-url-id]").val();
var title = this.find("[data-title]").val();
if (name === "") {
alert(dialogLang.nameEmpty);
return false;
}
if (rid === "") {
alert(dialogLang.idEmpty);
return false;
}
if (url === "http://" || url === "") {
alert(dialogLang.urlEmpty);
return false;
}
//cm.replaceSelection("[" + title + "][" + name + "]\n[" + name + "]: " + url + "");
cm.replaceSelection("[" + name + "][" + rid + "]");
if (selection === "") {
cm.setCursor(cursor.line, cursor.ch + 1);
}
title = (title === "") ? "" : " \"" + title + "\"";
cm.setValue(cm.getValue() + "\n[" + rid + "]: " + url + title + "");
this.hide().lockScreen(false).hideMask();
return false;
}],
cancel: [lang.buttons.cancel, function () {
this.hide().lockScreen(false).hideMask();
return false;
}]
}
});
}
dialog = editor.find("." + dialogName);
dialog.find("[data-name]").val("[" + ReLinkId + "]");
dialog.find("[data-url-id]").val("");
dialog.find("[data-url]").val("http://");
dialog.find("[data-title]").val(selection);
this.dialogShowMask(dialog);
this.dialogLockScreen();
dialog.show();
ReLinkId++;
};
};
// CommonJS/Node.js
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
module.exports = factory;
} else if (typeof define === "function") // AMD/CMD/Sea.js
{
if (define.amd) { // for Require.js
define(["editormd"], function (editormd) {
factory(editormd);
});
} else { // for Sea.js
define(function (require) {
var editormd = require("./../../editormd");
factory(editormd);
});
}
} else {
factory(window.editormd);
}
})();
@@ -0,0 +1,206 @@
/*!
* Table dialog plugin for Editor.md
*
* @file table-dialog.js
* @author pandao
* @version 1.2.1
* @updateTime 2015-06-09
* {@link https://github.com/pandao/editor.md}
* @license MIT
*/
(function () {
var factory = function (exports) {
var $ = jQuery;
var pluginName = "table-dialog";
var langs = {
"zh-cn": {
toolbar: {
table: "表格"
},
dialog: {
table: {
title: "添加表格",
cellsLabel: "单元格数",
alignLabel: "对齐方式",
rows: "行数",
cols: "列数",
aligns: ["默认", "左对齐", "居中对齐", "右对齐"]
}
}
},
"zh-tw": {
toolbar: {
table: "添加表格"
},
dialog: {
table: {
title: "添加表格",
cellsLabel: "單元格數",
alignLabel: "對齊方式",
rows: "行數",
cols: "列數",
aligns: ["默認", "左對齊", "居中對齊", "右對齊"]
}
}
},
"en": {
toolbar: {
table: "Tables"
},
dialog: {
table: {
title: "Tables",
cellsLabel: "Cells",
alignLabel: "Align",
rows: "Rows",
cols: "Cols",
aligns: ["Default", "Left align", "Center align", "Right align"]
}
}
}
};
exports.fn.tableDialog = function () {
var _this = this;
var cm = this.cm;
var editor = this.editor;
var settings = this.settings;
var path = settings.path + "../plugins/" + pluginName + "/";
var classPrefix = this.classPrefix;
var dialogName = classPrefix + pluginName, dialog;
$.extend(true, this.lang, langs[this.lang.name]);
this.setToolbar();
var lang = this.lang;
var dialogLang = lang.dialog.table;
var dialogContent = [
"<div class=\"editormd-form\" style=\"padding: 13px 0;\">",
"<label>" + dialogLang.cellsLabel + "</label>",
dialogLang.rows + " <input type=\"number\" value=\"3\" class=\"number-input\" style=\"width:40px;\" max=\"100\" min=\"2\" data-rows />&nbsp;&nbsp;",
dialogLang.cols + " <input type=\"number\" value=\"2\" class=\"number-input\" style=\"width:40px;\" max=\"100\" min=\"1\" data-cols /><br/>",
"<label>" + dialogLang.alignLabel + "</label>",
"<div class=\"fa-btns\"></div>",
"</div>"
].join("\n");
if (editor.find("." + dialogName).length > 0) {
dialog = editor.find("." + dialogName);
this.dialogShowMask(dialog);
this.dialogLockScreen();
dialog.show();
} else {
dialog = this.createDialog({
name: dialogName,
title: dialogLang.title,
width: 360,
height: 226,
mask: settings.dialogShowMask,
drag: settings.dialogDraggable,
content: dialogContent,
lockScreen: settings.dialogLockScreen,
maskStyle: {
opacity: settings.dialogMaskOpacity,
backgroundColor: settings.dialogMaskBgColor
},
buttons: {
enter: [lang.buttons.enter, function () {
var rows = parseInt(this.find("[data-rows]").val());
var cols = parseInt(this.find("[data-cols]").val());
var align = this.find("[name=\"table-align\"]:checked").val();
var table = "";
var hrLine = "------------";
var alignSign = {
_default: hrLine,
left: ":" + hrLine,
center: ":" + hrLine + ":",
right: hrLine + ":"
};
if (rows > 1 && cols > 0) {
for (var r = 0, len = rows; r < len; r++) {
var row = [];
var head = [];
for (var c = 0, len2 = cols; c < len2; c++) {
if (r === 1) {
head.push(alignSign[align]);
}
row.push(" ");
}
if (r === 1) {
table += "| " + head.join(" | ") + " |" + "\n";
}
table += "| " + row.join((cols === 1) ? "" : " | ") + " |" + "\n";
}
}
cm.replaceSelection(table);
this.hide().lockScreen(false).hideMask();
return false;
}],
cancel: [lang.buttons.cancel, function () {
this.hide().lockScreen(false).hideMask();
return false;
}]
}
});
}
var faBtns = dialog.find(".fa-btns");
if (faBtns.html() === "") {
var icons = ["align-justify", "align-left", "align-center", "align-right"];
var _lang = dialogLang.aligns;
var values = ["_default", "left", "center", "right"];
for (var i = 0, len = icons.length; i < len; i++) {
var checked = (i === 0) ? " checked=\"checked\"" : "";
var btn = "<a href=\"javascript:;\"><label for=\"editormd-table-dialog-radio" + i + "\" title=\"" + _lang[i] + "\">";
btn += "<input type=\"radio\" name=\"table-align\" id=\"editormd-table-dialog-radio" + i + "\" value=\"" + values[i] + "\"" + checked + " />&nbsp;";
btn += "<i class=\"fa fa-" + icons[i] + "\"></i>";
btn += "</label></a>";
faBtns.append(btn);
}
}
};
};
// CommonJS/Node.js
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
module.exports = factory;
} else if (typeof define === "function") // AMD/CMD/Sea.js
{
if (define.amd) { // for Require.js
define(["editormd"], function (editormd) {
factory(editormd);
});
} else { // for Sea.js
define(function (require) {
var editormd = require("./../../editormd");
factory(editormd);
});
}
} else {
factory(window.editormd);
}
})();
@@ -0,0 +1,62 @@
/*!
* Test plugin for Editor.md
*
* @file test-plugin.js
* @author pandao
* @version 1.2.0
* @updateTime 2015-03-07
* {@link https://github.com/pandao/editor.md}
* @license MIT
*/
(function () {
var factory = function (exports) {
var $ = jQuery; // if using module loader(Require.js/Sea.js).
exports.testPlugin = function () {
alert("testPlugin");
};
exports.fn.testPluginMethodA = function () {
/*
var _this = this; // this == the current instance object of Editor.md
var lang = _this.lang;
var settings = _this.settings;
var editor = this.editor;
var cursor = cm.getCursor();
var selection = cm.getSelection();
var classPrefix = this.classPrefix;
cm.focus();
*/
//....
alert("testPluginMethodA");
};
};
// CommonJS/Node.js
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
module.exports = factory;
} else if (typeof define === "function") // AMD/CMD/Sea.js
{
if (define.amd) { // for Require.js
define(["editormd"], function (editormd) {
factory(editormd);
});
} else { // for Sea.js
define(function (require) {
var editormd = require("./../../editormd");
factory(editormd);
});
}
} else {
factory(window.editormd);
}
})();