代码功能更新
This commit is contained in:
@@ -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=\":" + emoji + ":\" alt=\":" + emoji + ":\" />";
|
||||
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 + " <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 :emoji: |
|
||||
| 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 @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 ![]() |
|
||||
| Ctrl + Shift + K | 插入TeX(KaTeX)公式符号 | Insert TeX(KaTeX) symbol $$TeX$$ |
|
||||
| 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("&", "&");
|
||||
|
||||
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": "&#64;",
|
||||
"description": "at symbol"
|
||||
},
|
||||
{
|
||||
"name": "&copy;",
|
||||
"description": "copyright symbol"
|
||||
},
|
||||
{
|
||||
"name": "&reg;",
|
||||
"description": "registered symbol"
|
||||
},
|
||||
{
|
||||
"name": "&trade;",
|
||||
"description": "trademark symbol"
|
||||
},
|
||||
{
|
||||
"name": "&hearts;",
|
||||
"description": "heart"
|
||||
},
|
||||
{
|
||||
"name": "&nbsp;",
|
||||
"description": "Inserts a non-breaking blank space"
|
||||
},
|
||||
{
|
||||
"name": "&amp;",
|
||||
"description": "Ampersand"
|
||||
},
|
||||
{
|
||||
"name": "&#36;",
|
||||
"description": "dollar symbol"
|
||||
},
|
||||
{
|
||||
"name": "&cent;",
|
||||
"description": "Cent symbol"
|
||||
},
|
||||
{
|
||||
"name": "&pound;",
|
||||
"description": "Pound"
|
||||
},
|
||||
{
|
||||
"name": "&yen;",
|
||||
"description": "Yen"
|
||||
},
|
||||
{
|
||||
"name": "&euro;",
|
||||
"description": "Euro symbol"
|
||||
},
|
||||
{
|
||||
"name": "&quot;",
|
||||
"description": "quotation mark"
|
||||
},
|
||||
{
|
||||
"name": "&ldquo;",
|
||||
"description": "Opening Double Quotes "
|
||||
},
|
||||
{
|
||||
"name": "&rdquo;",
|
||||
"description": "Closing Double Quotes "
|
||||
},
|
||||
{
|
||||
"name": "&lsquo;",
|
||||
"description": "Opening Single Quote Mark "
|
||||
},
|
||||
{
|
||||
"name": "&rsquo;",
|
||||
"description": "Closing Single Quote Mark "
|
||||
},
|
||||
{
|
||||
"name": "&laquo;",
|
||||
"description": "angle quotation mark (left)"
|
||||
},
|
||||
{
|
||||
"name": "&raquo;",
|
||||
"description": "angle quotation mark (right)"
|
||||
},
|
||||
{
|
||||
"name": "&lsaquo;",
|
||||
"description": "single left angle quotation"
|
||||
},
|
||||
{
|
||||
"name": "&rsaquo;",
|
||||
"description": "single right angle quotation"
|
||||
},
|
||||
{
|
||||
"name": "&sect;",
|
||||
"description": "Section Symbol"
|
||||
},
|
||||
{
|
||||
"name": "&micro;",
|
||||
"description": "micro sign"
|
||||
},
|
||||
{
|
||||
"name": "&para;",
|
||||
"description": "Paragraph symbol"
|
||||
},
|
||||
{
|
||||
"name": "&bull;",
|
||||
"description": "Big List Dot"
|
||||
},
|
||||
{
|
||||
"name": "&middot;",
|
||||
"description": "Medium List Dot"
|
||||
},
|
||||
{
|
||||
"name": "&hellip;",
|
||||
"description": "horizontal ellipsis"
|
||||
},
|
||||
{
|
||||
"name": "&#124;",
|
||||
"description": "vertical bar"
|
||||
},
|
||||
{
|
||||
"name": "&brvbar;",
|
||||
"description": "broken vertical bar"
|
||||
},
|
||||
{
|
||||
"name": "&ndash;",
|
||||
"description": "en-dash"
|
||||
},
|
||||
{
|
||||
"name": "&mdash;",
|
||||
"description": "em-dash"
|
||||
},
|
||||
{
|
||||
"name": "&curren;",
|
||||
"description": "Generic currency symbol"
|
||||
},
|
||||
{
|
||||
"name": "&#33;",
|
||||
"description": "exclamation point"
|
||||
},
|
||||
{
|
||||
"name": "&#35;",
|
||||
"description": "number sign"
|
||||
},
|
||||
{
|
||||
"name": "&#39;",
|
||||
"description": "single quote"
|
||||
},
|
||||
{
|
||||
"name": "&#40;",
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"name": "&#41;",
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"name": "&#42;",
|
||||
"description": "asterisk"
|
||||
},
|
||||
{
|
||||
"name": "&#43;",
|
||||
"description": "plus sign"
|
||||
},
|
||||
{
|
||||
"name": "&#44;",
|
||||
"description": "comma"
|
||||
},
|
||||
{
|
||||
"name": "&#45;",
|
||||
"description": "minus sign - hyphen"
|
||||
},
|
||||
{
|
||||
"name": "&#46;",
|
||||
"description": "period"
|
||||
},
|
||||
{
|
||||
"name": "&#47;",
|
||||
"description": "slash"
|
||||
},
|
||||
{
|
||||
"name": "&#48;",
|
||||
"description": "0"
|
||||
},
|
||||
{
|
||||
"name": "&#49;",
|
||||
"description": "1"
|
||||
},
|
||||
{
|
||||
"name": "&#50;",
|
||||
"description": "2"
|
||||
},
|
||||
{
|
||||
"name": "&#51;",
|
||||
"description": "3"
|
||||
},
|
||||
{
|
||||
"name": "&#52;",
|
||||
"description": "4"
|
||||
},
|
||||
{
|
||||
"name": "&#53;",
|
||||
"description": "5"
|
||||
},
|
||||
{
|
||||
"name": "&#54;",
|
||||
"description": "6"
|
||||
},
|
||||
{
|
||||
"name": "&#55;",
|
||||
"description": "7"
|
||||
},
|
||||
{
|
||||
"name": "&#56;",
|
||||
"description": "8"
|
||||
},
|
||||
{
|
||||
"name": "&#57;",
|
||||
"description": "9"
|
||||
},
|
||||
{
|
||||
"name": "&#58;",
|
||||
"description": "colon"
|
||||
},
|
||||
{
|
||||
"name": "&#59;",
|
||||
"description": "semicolon"
|
||||
},
|
||||
{
|
||||
"name": "&#61;",
|
||||
"description": "equal sign"
|
||||
},
|
||||
{
|
||||
"name": "&#63;",
|
||||
"description": "question mark"
|
||||
},
|
||||
{
|
||||
"name": "&lt;",
|
||||
"description": "Less than"
|
||||
},
|
||||
{
|
||||
"name": "&gt;",
|
||||
"description": "Greater than"
|
||||
},
|
||||
{
|
||||
"name": "&le;",
|
||||
"description": "Less than or Equal to"
|
||||
},
|
||||
{
|
||||
"name": "&ge;",
|
||||
"description": "Greater than or Equal to"
|
||||
},
|
||||
{
|
||||
"name": "&times;",
|
||||
"description": "Multiplication symbol"
|
||||
},
|
||||
{
|
||||
"name": "&divide;",
|
||||
"description": "Division symbol"
|
||||
},
|
||||
{
|
||||
"name": "&minus;",
|
||||
"description": "Minus symbol"
|
||||
},
|
||||
{
|
||||
"name": "&plusmn;",
|
||||
"description": "Plus/minus symbol"
|
||||
},
|
||||
{
|
||||
"name": "&ne;",
|
||||
"description": "Not Equal"
|
||||
},
|
||||
{
|
||||
"name": "&sup1;",
|
||||
"description": "Superscript 1"
|
||||
},
|
||||
{
|
||||
"name": "&sup2;",
|
||||
"description": "Superscript 2"
|
||||
},
|
||||
{
|
||||
"name": "&sup3;",
|
||||
"description": "Superscript 3"
|
||||
},
|
||||
{
|
||||
"name": "&frac12;",
|
||||
"description": "Fraction ½"
|
||||
},
|
||||
{
|
||||
"name": "&frac14;",
|
||||
"description": "Fraction ¼"
|
||||
},
|
||||
{
|
||||
"name": "&frac34;",
|
||||
"description": "Fraction ¾"
|
||||
},
|
||||
{
|
||||
"name": "&permil;",
|
||||
"description": "per mille"
|
||||
},
|
||||
{
|
||||
"name": "&deg;",
|
||||
"description": "Degree symbol"
|
||||
},
|
||||
{
|
||||
"name": "&radic;",
|
||||
"description": "square root"
|
||||
},
|
||||
{
|
||||
"name": "&infin;",
|
||||
"description": "Infinity"
|
||||
},
|
||||
{
|
||||
"name": "&larr;",
|
||||
"description": "left arrow"
|
||||
},
|
||||
{
|
||||
"name": "&uarr;",
|
||||
"description": "up arrow"
|
||||
},
|
||||
{
|
||||
"name": "&rarr;",
|
||||
"description": "right arrow"
|
||||
},
|
||||
{
|
||||
"name": "&darr;",
|
||||
"description": "down arrow"
|
||||
},
|
||||
{
|
||||
"name": "&harr;",
|
||||
"description": "left right arrow"
|
||||
},
|
||||
{
|
||||
"name": "&crarr;",
|
||||
"description": "carriage return arrow"
|
||||
},
|
||||
{
|
||||
"name": "&lceil;",
|
||||
"description": "left ceiling"
|
||||
},
|
||||
{
|
||||
"name": "&rceil;",
|
||||
"description": "right ceiling"
|
||||
},
|
||||
{
|
||||
"name": "&lfloor;",
|
||||
"description": "left floor"
|
||||
},
|
||||
{
|
||||
"name": "&rfloor;",
|
||||
"description": "right floor"
|
||||
},
|
||||
{
|
||||
"name": "&spades;",
|
||||
"description": "spade"
|
||||
},
|
||||
{
|
||||
"name": "&clubs;",
|
||||
"description": "club"
|
||||
},
|
||||
{
|
||||
"name": "&hearts;",
|
||||
"description": "heart"
|
||||
},
|
||||
{
|
||||
"name": "&diams;",
|
||||
"description": "diamond"
|
||||
},
|
||||
{
|
||||
"name": "&loz;",
|
||||
"description": "lozenge"
|
||||
},
|
||||
{
|
||||
"name": "&dagger;",
|
||||
"description": "dagger"
|
||||
},
|
||||
{
|
||||
"name": "&Dagger;",
|
||||
"description": "double dagger"
|
||||
},
|
||||
{
|
||||
"name": "&iexcl;",
|
||||
"description": "inverted exclamation mark"
|
||||
},
|
||||
{
|
||||
"name": "&iquest;",
|
||||
"description": "inverted question mark"
|
||||
},
|
||||
{
|
||||
"name": "&#338;",
|
||||
"description": "latin capital letter OE"
|
||||
},
|
||||
{
|
||||
"name": "&#339;",
|
||||
"description": "latin small letter oe"
|
||||
},
|
||||
{
|
||||
"name": "&#352;",
|
||||
"description": "latin capital letter S with caron"
|
||||
},
|
||||
{
|
||||
"name": "&#353;",
|
||||
"description": "latin small letter s with caron"
|
||||
},
|
||||
{
|
||||
"name": "&#376;",
|
||||
"description": "latin capital letter Y with diaeresis"
|
||||
},
|
||||
{
|
||||
"name": "&#402;",
|
||||
"description": "latin small f with hook - function"
|
||||
},
|
||||
{
|
||||
"name": "&not;",
|
||||
"description": "not sign"
|
||||
},
|
||||
{
|
||||
"name": "&ordf;",
|
||||
"description": "feminine ordinal indicator"
|
||||
},
|
||||
{
|
||||
"name": "&uml;",
|
||||
"description": "spacing diaeresis - umlaut"
|
||||
},
|
||||
{
|
||||
"name": "&macr;",
|
||||
"description": "spacing macron - overline"
|
||||
},
|
||||
{
|
||||
"name": "&acute;",
|
||||
"description": "acute accent - spacing acute"
|
||||
},
|
||||
{
|
||||
"name": "&Agrave;",
|
||||
"description": "latin capital letter A with grave"
|
||||
},
|
||||
{
|
||||
"name": "&Aacute;",
|
||||
"description": "latin capital letter A with acute"
|
||||
},
|
||||
{
|
||||
"name": "&Acirc;",
|
||||
"description": "latin capital letter A with circumflex"
|
||||
},
|
||||
{
|
||||
"name": "&Atilde;",
|
||||
"description": "latin capital letter A with tilde"
|
||||
},
|
||||
{
|
||||
"name": "&Auml;",
|
||||
"description": "latin capital letter A with diaeresis"
|
||||
},
|
||||
{
|
||||
"name": "&Aring;",
|
||||
"description": "latin capital letter A with ring above"
|
||||
},
|
||||
{
|
||||
"name": "&AElig;",
|
||||
"description": "latin capital letter AE"
|
||||
},
|
||||
{
|
||||
"name": "&Ccedil;",
|
||||
"description": "latin capital letter C with cedilla"
|
||||
},
|
||||
{
|
||||
"name": "&Egrave;",
|
||||
"description": "latin capital letter E with grave"
|
||||
},
|
||||
{
|
||||
"name": "&Eacute;",
|
||||
"description": "latin capital letter E with acute"
|
||||
},
|
||||
{
|
||||
"name": "&Ecirc;",
|
||||
"description": "latin capital letter E with circumflex"
|
||||
},
|
||||
{
|
||||
"name": "&Euml;",
|
||||
"description": "latin capital letter E with diaeresis"
|
||||
},
|
||||
{
|
||||
"name": "&Igrave;",
|
||||
"description": "latin capital letter I with grave"
|
||||
},
|
||||
{
|
||||
"name": "&Iacute;",
|
||||
"description": "latin capital letter I with acute"
|
||||
},
|
||||
{
|
||||
"name": "&Icirc;",
|
||||
"description": "latin capital letter I with circumflex"
|
||||
},
|
||||
{
|
||||
"name": "&Iuml;",
|
||||
"description": "latin capital letter I with diaeresis"
|
||||
},
|
||||
{
|
||||
"name": "&ETH;",
|
||||
"description": "latin capital letter ETH"
|
||||
},
|
||||
{
|
||||
"name": "&Ntilde;",
|
||||
"description": "latin capital letter N with tilde"
|
||||
},
|
||||
{
|
||||
"name": "&Ograve;",
|
||||
"description": "latin capital letter O with grave"
|
||||
},
|
||||
{
|
||||
"name": "&Oacute;",
|
||||
"description": "latin capital letter O with acute"
|
||||
},
|
||||
{
|
||||
"name": "&Ocirc;",
|
||||
"description": "latin capital letter O with circumflex"
|
||||
},
|
||||
{
|
||||
"name": "&Otilde;",
|
||||
"description": "latin capital letter O with tilde"
|
||||
},
|
||||
{
|
||||
"name": "&Ouml;",
|
||||
"description": "latin capital letter O with diaeresis"
|
||||
},
|
||||
{
|
||||
"name": "&times;",
|
||||
"description": "multiplication sign"
|
||||
},
|
||||
{
|
||||
"name": "&Oslash;",
|
||||
"description": "latin capital letter O with slash"
|
||||
},
|
||||
{
|
||||
"name": "&Ugrave;",
|
||||
"description": "latin capital letter U with grave"
|
||||
},
|
||||
{
|
||||
"name": "&Uacute;",
|
||||
"description": "latin capital letter U with acute"
|
||||
},
|
||||
{
|
||||
"name": "&Ucirc;",
|
||||
"description": "latin capital letter U with circumflex"
|
||||
},
|
||||
{
|
||||
"name": "&Uuml;",
|
||||
"description": "latin capital letter U with diaeresis"
|
||||
},
|
||||
{
|
||||
"name": "&Yacute;",
|
||||
"description": "latin capital letter Y with acute"
|
||||
},
|
||||
{
|
||||
"name": "&THORN;",
|
||||
"description": "latin capital letter THORN"
|
||||
},
|
||||
{
|
||||
"name": "&szlig;",
|
||||
"description": "latin small letter sharp s - ess-zed"
|
||||
},
|
||||
{
|
||||
"name": "&eth;",
|
||||
"description": "latin capital letter eth"
|
||||
},
|
||||
{
|
||||
"name": "&ntilde;",
|
||||
"description": "latin capital letter n with tilde"
|
||||
},
|
||||
{
|
||||
"name": "&ograve;",
|
||||
"description": "latin capital letter o with grave"
|
||||
},
|
||||
{
|
||||
"name": "&oacute;",
|
||||
"description": "latin capital letter o with acute"
|
||||
},
|
||||
{
|
||||
"name": "&ocirc;",
|
||||
"description": "latin capital letter o with circumflex"
|
||||
},
|
||||
{
|
||||
"name": "&otilde;",
|
||||
"description": "latin capital letter o with tilde"
|
||||
},
|
||||
{
|
||||
"name": "&ouml;",
|
||||
"description": "latin capital letter o with diaeresis"
|
||||
},
|
||||
{
|
||||
"name": "&times;",
|
||||
"description": "multiplication sign"
|
||||
},
|
||||
{
|
||||
"name": "&oslash;",
|
||||
"description": "latin capital letter o with slash"
|
||||
},
|
||||
{
|
||||
"name": "&ugrave;",
|
||||
"description": "latin capital letter u with grave"
|
||||
},
|
||||
{
|
||||
"name": "&uacute;",
|
||||
"description": "latin capital letter u with acute"
|
||||
},
|
||||
{
|
||||
"name": "&ucirc;",
|
||||
"description": "latin capital letter u with circumflex"
|
||||
},
|
||||
{
|
||||
"name": "&uuml;",
|
||||
"description": "latin capital letter u with diaeresis"
|
||||
},
|
||||
{
|
||||
"name": "&yacute;",
|
||||
"description": "latin capital letter y with acute"
|
||||
},
|
||||
{
|
||||
"name": "&thorn;",
|
||||
"description": "latin capital letter thorn"
|
||||
},
|
||||
{
|
||||
"name": "&yuml;",
|
||||
"description": "latin small letter y with diaeresis"
|
||||
},
|
||||
{
|
||||
"name": "&agrave;",
|
||||
"description": "latin capital letter a with grave"
|
||||
},
|
||||
{
|
||||
"name": "&aacute;",
|
||||
"description": "latin capital letter a with acute"
|
||||
},
|
||||
{
|
||||
"name": "&acirc;",
|
||||
"description": "latin capital letter a with circumflex"
|
||||
},
|
||||
{
|
||||
"name": "&atilde;",
|
||||
"description": "latin capital letter a with tilde"
|
||||
},
|
||||
{
|
||||
"name": "&auml;",
|
||||
"description": "latin capital letter a with diaeresis"
|
||||
},
|
||||
{
|
||||
"name": "&aring;",
|
||||
"description": "latin capital letter a with ring above"
|
||||
},
|
||||
{
|
||||
"name": "&aelig;",
|
||||
"description": "latin capital letter ae"
|
||||
},
|
||||
{
|
||||
"name": "&ccedil;",
|
||||
"description": "latin capital letter c with cedilla"
|
||||
},
|
||||
{
|
||||
"name": "&egrave;",
|
||||
"description": "latin capital letter e with grave"
|
||||
},
|
||||
{
|
||||
"name": "&eacute;",
|
||||
"description": "latin capital letter e with acute"
|
||||
},
|
||||
{
|
||||
"name": "&ecirc;",
|
||||
"description": "latin capital letter e with circumflex"
|
||||
},
|
||||
{
|
||||
"name": "&euml;",
|
||||
"description": "latin capital letter e with diaeresis"
|
||||
},
|
||||
{
|
||||
"name": "&igrave;",
|
||||
"description": "latin capital letter i with grave"
|
||||
},
|
||||
{
|
||||
"name": "&Iacute;",
|
||||
"description": "latin capital letter i with acute"
|
||||
},
|
||||
{
|
||||
"name": "&icirc;",
|
||||
"description": "latin capital letter i with circumflex"
|
||||
},
|
||||
{
|
||||
"name": "&iuml;",
|
||||
"description": "latin capital letter i with diaeresis"
|
||||
},
|
||||
{
|
||||
"name": "&#65;",
|
||||
"description": "A"
|
||||
},
|
||||
{
|
||||
"name": "&#66;",
|
||||
"description": "B"
|
||||
},
|
||||
{
|
||||
"name": "&#67;",
|
||||
"description": "C"
|
||||
},
|
||||
{
|
||||
"name": "&#68;",
|
||||
"description": "D"
|
||||
},
|
||||
{
|
||||
"name": "&#69;",
|
||||
"description": "E"
|
||||
},
|
||||
{
|
||||
"name": "&#70;",
|
||||
"description": "F"
|
||||
},
|
||||
{
|
||||
"name": "&#71;",
|
||||
"description": "G"
|
||||
},
|
||||
{
|
||||
"name": "&#72;",
|
||||
"description": "H"
|
||||
},
|
||||
{
|
||||
"name": "&#73;",
|
||||
"description": "I"
|
||||
},
|
||||
{
|
||||
"name": "&#74;",
|
||||
"description": "J"
|
||||
},
|
||||
{
|
||||
"name": "&#75;",
|
||||
"description": "K"
|
||||
},
|
||||
{
|
||||
"name": "&#76;",
|
||||
"description": "L"
|
||||
},
|
||||
{
|
||||
"name": "&#77;",
|
||||
"description": "M"
|
||||
},
|
||||
{
|
||||
"name": "&#78;",
|
||||
"description": "N"
|
||||
},
|
||||
{
|
||||
"name": "&#79;",
|
||||
"description": "O"
|
||||
},
|
||||
{
|
||||
"name": "&#80;",
|
||||
"description": "P"
|
||||
},
|
||||
{
|
||||
"name": "&#81;",
|
||||
"description": "Q"
|
||||
},
|
||||
{
|
||||
"name": "&#82;",
|
||||
"description": "R"
|
||||
},
|
||||
{
|
||||
"name": "&#83;",
|
||||
"description": "S"
|
||||
},
|
||||
{
|
||||
"name": "&#84;",
|
||||
"description": "T"
|
||||
},
|
||||
{
|
||||
"name": "&#85;",
|
||||
"description": "U"
|
||||
},
|
||||
{
|
||||
"name": "&#86;",
|
||||
"description": "V"
|
||||
},
|
||||
{
|
||||
"name": "&#87;",
|
||||
"description": "W"
|
||||
},
|
||||
{
|
||||
"name": "&#88;",
|
||||
"description": "X"
|
||||
},
|
||||
{
|
||||
"name": "&#89;",
|
||||
"description": "Y"
|
||||
},
|
||||
{
|
||||
"name": "&#90;",
|
||||
"description": "Z"
|
||||
},
|
||||
{
|
||||
"name": "&#91;",
|
||||
"description": "opening bracket"
|
||||
},
|
||||
{
|
||||
"name": "&#92;",
|
||||
"description": "backslash"
|
||||
},
|
||||
{
|
||||
"name": "&#93;",
|
||||
"description": "closing bracket"
|
||||
},
|
||||
{
|
||||
"name": "&#94;",
|
||||
"description": "caret - circumflex"
|
||||
},
|
||||
{
|
||||
"name": "&#95;",
|
||||
"description": "underscore"
|
||||
},
|
||||
{
|
||||
"name": "&#96;",
|
||||
"description": "grave accent"
|
||||
},
|
||||
{
|
||||
"name": "&#97;",
|
||||
"description": "a"
|
||||
},
|
||||
{
|
||||
"name": "&#98;",
|
||||
"description": "b"
|
||||
},
|
||||
{
|
||||
"name": "&#99;",
|
||||
"description": "c"
|
||||
},
|
||||
{
|
||||
"name": "&#100;",
|
||||
"description": "d"
|
||||
},
|
||||
{
|
||||
"name": "&#101;",
|
||||
"description": "e"
|
||||
},
|
||||
{
|
||||
"name": "&#102;",
|
||||
"description": "f"
|
||||
},
|
||||
{
|
||||
"name": "&#103;",
|
||||
"description": "g"
|
||||
},
|
||||
{
|
||||
"name": "&#104;",
|
||||
"description": "h"
|
||||
},
|
||||
{
|
||||
"name": "&#105;",
|
||||
"description": "i"
|
||||
},
|
||||
{
|
||||
"name": "&#106;",
|
||||
"description": "j"
|
||||
},
|
||||
{
|
||||
"name": "&#107;",
|
||||
"description": "k"
|
||||
},
|
||||
{
|
||||
"name": "&#108;",
|
||||
"description": "l"
|
||||
},
|
||||
{
|
||||
"name": "&#109;",
|
||||
"description": "m"
|
||||
},
|
||||
{
|
||||
"name": "&#110;",
|
||||
"description": "n"
|
||||
},
|
||||
{
|
||||
"name": "&#111;",
|
||||
"description": "o"
|
||||
},
|
||||
{
|
||||
"name": "&#112;",
|
||||
"description": "p"
|
||||
},
|
||||
{
|
||||
"name": "&#113;",
|
||||
"description": "q"
|
||||
},
|
||||
{
|
||||
"name": "&#114;",
|
||||
"description": "r"
|
||||
},
|
||||
{
|
||||
"name": "&#115;",
|
||||
"description": "s"
|
||||
},
|
||||
{
|
||||
"name": "&#116;",
|
||||
"description": "t"
|
||||
},
|
||||
{
|
||||
"name": "&#117;",
|
||||
"description": "u"
|
||||
},
|
||||
{
|
||||
"name": "&#118;",
|
||||
"description": "v"
|
||||
},
|
||||
{
|
||||
"name": "&#119;",
|
||||
"description": "w"
|
||||
},
|
||||
{
|
||||
"name": "&#120;",
|
||||
"description": "x"
|
||||
},
|
||||
{
|
||||
"name": "&#121;",
|
||||
"description": "y"
|
||||
},
|
||||
{
|
||||
"name": "&#122;",
|
||||
"description": "z"
|
||||
},
|
||||
{
|
||||
"name": "&#123;",
|
||||
"description": "opening brace"
|
||||
},
|
||||
{
|
||||
"name": "&#124;",
|
||||
"description": "vertical bar"
|
||||
},
|
||||
{
|
||||
"name": "&#125;",
|
||||
"description": "closing brace"
|
||||
},
|
||||
{
|
||||
"name": "&#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("");
|
||||
} else {
|
||||
cm.replaceSelection("[](" + 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);
|
||||
}
|
||||
|
||||
})();
|
||||
+164
@@ -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 /> ",
|
||||
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 + " /> ";
|
||||
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);
|
||||
}
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user