Browse Source

fix bugs & Releases v1.1.6

v1.1.9
Pandao 10 years ago
parent
commit
2c9ca0b418
  1. 16
      CHANGE.md
  2. 2
      bower.json
  3. 4
      dist/css/editormd.css
  4. 4
      dist/css/editormd.css.map
  5. 2
      dist/css/editormd.css.min.map
  6. 4
      dist/css/editormd.logo.css
  7. 4
      dist/css/editormd.logo.css.map
  8. 2
      dist/css/editormd.logo.css.min.map
  9. 2
      dist/css/editormd.logo.min.css
  10. 2
      dist/css/editormd.min.css
  11. 4
      dist/css/editormd.preview.css
  12. 4
      dist/css/editormd.preview.css.map
  13. 2
      dist/css/editormd.preview.css.min.map
  14. 2
      dist/css/editormd.preview.min.css
  15. 183
      dist/js/editormd.js
  16. 6
      dist/js/editormd.min.js
  17. 4
      dist/js/languages/en.js
  18. 2
      dist/js/languages/en.min.js
  19. 4
      dist/js/languages/zh-tw.js
  20. 2
      dist/js/languages/zh-tw.min.js
  21. 2
      docs/html/index.html
  22. 5
      examples/full.html
  23. 4
      examples/php/post.php
  24. 1
      examples/use-requirejs.html
  25. 1
      examples/use-seajs.html
  26. 7
      examples/use-zepto.html
  27. 2
      lib/codemirror/addons.min.js
  28. 2
      lib/codemirror/modes.min.js
  29. 2
      package.json
  30. 179
      src/js/editormd.js

16
CHANGE.md

@ -156,3 +156,19 @@
- 修复Bug[#20](https://github.com/pandao/editor.md/issues/20);
- 修改了引用的处理函数;
- 插入的headers的`#`号后面都加上了一个空格;
#####v1.1.6
修复多处Bug,具体如下:
- 修复Bug[#23](https://github.com/pandao/editor.md/issues/23),即Headers的id属性的重复及中文问题;
- 修改了`editormd.markedRenderer()`方法;
- 修复Bug[#24](https://github.com/pandao/editor.md/issues/24);
- 修改了`setMarkdown()`、`clear()`和`loadedDisplay()`方法的内部实现;
- 新增了`katexRender()`、`flowChartAndSequenceDiagramRender()`、`previewCodeHighlight()`方法;
- 修复有些情况下无法保存Markdown源文档到textarea的问题;
- 修改了`setCodeMirror()`、`recreateEditor()`等方法;
- 修改了以上Bug及部分相关示例文件;

2
bower.json

@ -1,6 +1,6 @@
{
"name": "editor.md",
"version": "1.1.5",
"version": "1.1.6",
"homepage": "https://github.com/pandao/editor.md",
"authors": [
"Pandao <pandao@vip.qq.com>"

4
dist/css/editormd.css

@ -1,12 +1,12 @@
/*
* Editor.md
* @file editormd.css
* @version v1.1.5
* @version v1.1.6
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-02-26
* @updateTime 2015-03-02
*/
@charset "UTF-8";

4
dist/css/editormd.css.map

@ -1,12 +1,12 @@
/*
* Editor.md
* @file editormd.css.map
* @version v1.1.5
* @version v1.1.6
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-02-26
* @updateTime 2015-03-02
*/
{

2
dist/css/editormd.css.min.map

File diff suppressed because one or more lines are too long

4
dist/css/editormd.logo.css

@ -1,12 +1,12 @@
/*
* Editor.md
* @file editormd.logo.css
* @version v1.1.5
* @version v1.1.6
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-02-26
* @updateTime 2015-03-02
*/
@font-face {

4
dist/css/editormd.logo.css.map

@ -1,12 +1,12 @@
/*
* Editor.md
* @file editormd.logo.css.map
* @version v1.1.5
* @version v1.1.6
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-02-26
* @updateTime 2015-03-02
*/
{

2
dist/css/editormd.logo.css.min.map

@ -1,2 +1,2 @@
/*! Editor.md v1.1.5 | editormd.logo.css.min.map | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-02-26 */
/*! Editor.md v1.1.6 | editormd.logo.css.min.map | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-03-02 */
{"version":3,"mappings":"AAKA,UASC;EARA,WAAW,EAAE,eAAe;EAC5B,GAAG,EAAC,yCAAyC;EAC7C,GAAG,EAAC,sQAA4E;EAIhF,WAAW,EAAE,MAAM;EACnB,UAAU,EAAE,MAAM;;AAGnB,cAAe;EACd,WAAW,EAAE,eAAe;EAC5B,KAAK,EAAE,IAAI;EACX,UAAU,EAAE,MAAM;EAClB,WAAW,EAAE,MAAM;EACnB,YAAY,EAAE,MAAM;EACpB,cAAc,EAAE,IAAI;EACjB,SAAS,EAAE,OAAO;EACrB,WAAW,EAAE,CAAC;EACX,OAAO,EAAE,YAAY;EACrB,cAAc,EAAE,IAAI;EACpB,cAAc,EAAE,OAAO;EAG1B,sBAAsB,EAAE,WAAW;EACnC,uBAAuB,EAAE,SAAS;;AAE/B,qBAAS;EACL,OAAO,EAAE,QAAQ;;;;;;;AAQzB,iBAAkB;EACd,SAAS,EAAE,GAAG;;;AAGlB,iBAAkB;EACd,SAAS,EAAE,KAAK;;;AAGpB,iBAAkB;EACd,SAAS,EAAE,GAAG;;;AAGlB,iBAAkB;EACd,SAAS,EAAE,GAAG;;;AAGlB,iBAAkB;EACd,SAAS,EAAE,GAAG;;;AAGlB,iBAAkB;EACd,SAAS,EAAE,GAAG;;;AAGlB,iBAAkB;EACd,SAAS,EAAE,GAAG;;;AAGlB,iBAAkB;EACd,SAAS,EAAE,GAAG;;;AAGlB,iBAAkB;EACd,SAAS,EAAE,GAAG;;;AAGlB,oBAAqB;EACjB,KAAK,ECxEO,OAAU","sources"["../editormd.logo.scss","file:///D:/APMServ/www/htdocs/editor.md/src/scss/lib/variables.scss"],"names"[],"file":"editormd.logo.css"}

2
dist/css/editormd.logo.min.css

@ -1,2 +1,2 @@
/*! Editor.md v1.1.5 | editormd.logo.min.css | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-02-26 */
/*! Editor.md v1.1.6 | editormd.logo.min.css | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-03-02 */
@font-face{font-family:editormd-logo;src:url(../fonts/editormd-logo.eot?-5y8q6h);src:url(.../fonts/editormd-logo.eot?#iefix-5y8q6h) format("embedded-opentype"),url(../fonts/editormd-logo.woff?-5y8q6h) format("woff"),url(../fonts/editormd-logo.ttf?-5y8q6h) format("truetype"),url(../fonts/editormd-logo.svg?-5y8q6h#icomoon) format("svg");font-weight:400;font-style:normal}.editormd-logo{font-family:editormd-logo;speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;font-size:inherit;line-height:1;display:inline-block;text-rendering:auto;vertical-align:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.editormd-logo:before{content:"\e1987"}.editormd-logo-1x{font-size:1em}.editormd-logo-lg{font-size:1.2em}.editormd-logo-2x{font-size:2em}.editormd-logo-3x{font-size:3em}.editormd-logo-4x{font-size:4em}.editormd-logo-5x{font-size:5em}.editormd-logo-6x{font-size:6em}.editormd-logo-7x{font-size:7em}.editormd-logo-8x{font-size:8em}.editormd-logo-color{color:#2196F3}

2
dist/css/editormd.min.css

@ -1,4 +1,4 @@
/*! Editor.md v1.1.5 | editormd.min.css | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-02-26 */
/*! Editor.md v1.1.6 | editormd.min.css | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-03-02 */
@charset "UTF-8";/*!
* Font Awesome 4.3.0 by @davegandy - http://fontawesome.io - @fontawesome
* License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License)

4
dist/css/editormd.preview.css

@ -1,12 +1,12 @@
/*
* Editor.md
* @file editormd.preview.css
* @version v1.1.5
* @version v1.1.6
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-02-26
* @updateTime 2015-03-02
*/
/*! github-markdown-css | The MIT License (MIT) | Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) | https://github.com/sindresorhus/github-markdown-css */

4
dist/css/editormd.preview.css.map

@ -1,12 +1,12 @@
/*
* Editor.md
* @file editormd.preview.css.map
* @version v1.1.5
* @version v1.1.6
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-02-26
* @updateTime 2015-03-02
*/
{

2
dist/css/editormd.preview.css.min.map

File diff suppressed because one or more lines are too long

2
dist/css/editormd.preview.min.css

File diff suppressed because one or more lines are too long

183
dist/js/editormd.js

@ -1,18 +1,18 @@
/*
* Editor.md
* @file editormd.js
* @version v1.1.5
* @version v1.1.6
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-02-26
* @updateTime 2015-03-02
*/
/**
* @fileOverview Editor.md
* @author pandao
* @version 1.1.5
* @version 1.1.6
*/
;(function(factory) {
@ -55,7 +55,7 @@
};
editormd.title = editormd.$name = "Editor.md";
editormd.version = "1.1.5";
editormd.version = "1.1.6";
editormd.homePage = "https://pandao.github.io/editor.md/";
editormd.classPrefix = "editormd-";
@ -293,7 +293,8 @@
editor.append(appendElements).addClass(classPrefix + "vertical");
if (settings.markdown !== "") {
if (settings.markdown !== "")
{
markdownTextarea.val(settings.markdown);
}
@ -420,6 +421,7 @@
setCodeMirror : function() {
var settings = this.settings;
var editor = this.editor;
var codeMirrorConfig = {
mode : settings.mode,
theme : "default",
@ -442,11 +444,10 @@
};
this.codeEditor = editormd.$CodeMirror.fromTextArea(this.markdownTextarea[0], codeMirrorConfig);
this.codeMirror = this.editor.find(".CodeMirror");
this.codeMirror = editor.find(".CodeMirror");
this.codeMirror.css({
fontSize : this.settings.fontSize,
fontSize : settings.fontSize,
width : (!settings.watch) ? "100%" : "50%"
});
@ -1642,7 +1643,6 @@
return this;
},
/**
* 编辑器界面重建用于动态语言包或模块加载等
* @returns {editormd} 返回editormd的实例对象
@ -1662,7 +1662,12 @@
createInfoDialog();
}
if (!settings.readOnly) {
if (!settings.readOnly)
{
if (editor.find(".editormd-dialog").length > 0) {
editor.find(".editormd-dialog").remove();
}
this.getToolbarHandles();
this.setToolbar();
}
@ -1673,40 +1678,49 @@
},
/**
* 加载队列完成之后的显示处理
* 高亮预览HTML的pre代码部分
* @returns {editormd} 返回editormd的实例对象
*/
loadedDisplay : function() {
this.state.loaded = true;
var _this = this;
var editor = this.editor;
var preview = this.preview;
previewCodeHighlight : function() {
var settings = this.settings;
var codeEditor = this.codeEditor;
var codeMirror = this.codeMirror;
var previewContainer = this.previewContainer;
var mouseOrTouch = editormd.mouseOrTouch;
editor.find("." + this.classPrefix + "container-mask").hide();
this.saveToTextareas();
if(settings.watch) {
preview.show();
}
var codeHighlight = function() {
if (settings.previewCodeHighlight)
{
previewContainer.find("pre").addClass("prettyprint linenums");
prettyPrint();
}
};
var flowChartAndSequenceDiagramHandle = function() {
return this;
},
/**
* 解析TeX(KaTeX)科学公式
* @returns {editormd} 返回editormd的实例对象
*/
katexRender : function() {
var previewContainer = this.previewContainer;
previewContainer.find("." + editormd.classNames.tex).each(function(){
var tex = $(this);
editormd.$katex.render(tex.html(), tex[0]);
});
return this;
},
/**
* 解析和渲染流程图及时序图
* @returns {editormd} 返回editormd的实例对象
*/
flowChartAndSequenceDiagramRender : function() {
var settings = this.settings;
var previewContainer = this.previewContainer;
if (editormd.isIE8) return ;
@ -1717,29 +1731,34 @@
if (settings.sequenceDiagram) {
previewContainer.find(".sequence-diagram").sequenceDiagram({theme: "simple"});
}
};
codeHighlight();
return this;
},
flowChartAndSequenceDiagramHandle();
/**
* 加载队列完成之后的显示处理
* @returns {editormd} 返回editormd的实例对象
*/
var katexHandle = function() {
previewContainer.find("." + editormd.classNames.tex).each(function(){
var tex = $(this);
editormd.$katex.render(tex.html(), tex[0]);
});
};
loadedDisplay : function() {
if (settings.tex)
{
if (!settings.inRequirejs) {
editormd.loadKaTeX(function(){
editormd.$katex = katex;
katexHandle();
});
} else {
katexHandle();
}
this.state.loaded = true;
var _this = this;
var editor = this.editor;
var preview = this.preview;
var settings = this.settings;
var codeEditor = this.codeEditor;
var codeMirror = this.codeMirror;
var previewContainer = this.previewContainer;
var mouseOrTouch = editormd.mouseOrTouch;
editor.find("." + this.classPrefix + "container-mask").hide();
this.saveToTextareas();
if(settings.watch) {
preview.show();
}
editor.data("oldWidth", editor.width()).data("oldHeight", editor.height()); // 为了兼容Zepto
@ -1818,22 +1837,7 @@
});
codeEditor.on("change", function(cm, changeObj) {
if (!settings.watch) {
return ;
}
_this.saveToTextareas();
codeHighlight();
flowChartAndSequenceDiagramHandle();
if (settings.tex) {
katexHandle();
}
$.proxy(settings.onchange, _this)();
});
return this;
@ -1928,28 +1932,49 @@
*/
saveToTextareas : function() {
var _this = this;
var settings = this.settings;
var codeEditor = this.codeEditor;
var previewContainer = this.previewContainer;
codeEditor.save();
var codeMirrorValue = codeEditor.getValue();
var markdownToC = this.markdownToC = [];
var newMarkdownDoc = editormd.$marked(codeEditor.getValue(), {renderer : editormd.markedRenderer(markdownToC)});
var newMarkdownDoc = editormd.$marked(codeMirrorValue, {renderer : editormd.markedRenderer(markdownToC)});
this.markdownTextarea[0].innerText = codeMirrorValue;
this.markdownTextarea.val(codeEditor.getValue());
codeEditor.save();
if (settings.saveHTMLToTextarea) {
this.htmlTextarea.html(newMarkdownDoc);
}
if(settings.watch)
if(settings.watch || (!settings.watch && this.state.preview))
{
previewContainer.html(newMarkdownDoc);
this.previewCodeHighlight();
if (settings.toc) {
editormd.markdownToCRenderer(markdownToC, previewContainer, settings.tocStartLevel);
}
if (!settings.inRequirejs && !editormd.kaTeXLoaded) {
editormd.loadKaTeX(function(){
editormd.$katex = katex;
editormd.kaTeXLoaded = true;
_this.katexRender();
});
} else {
this.katexRender();
}
var timer = setTimeout(function(){
clearTimeout(timer);
_this.flowChartAndSequenceDiagramRender();
}, 10);
$.proxy(settings.onchange, this)();
}
return this;
@ -2043,8 +2068,9 @@
*/
setMarkdown : function(md) {
var settings = this.settings;
this.codeEditor.setValue(md);
this.saveToTextareas();
return this;
},
@ -2065,7 +2091,6 @@
clear : function() {
this.codeEditor.setValue("");
this.saveToTextareas();
return this;
},
@ -2232,7 +2257,7 @@
if(!settings.watch)
{
var codeEditor = this.codeEditor;
/*var codeEditor = this.codeEditor;
var previewContainer = this.previewContainer;
codeEditor.save();
@ -2243,7 +2268,8 @@
if (settings.toc) {
editormd.markdownToCRenderer(markdownToC, previewContainer, settings.tocStartLevel);
}
}*/
this.saveToTextareas();
}
preview.show().css({
@ -2414,9 +2440,12 @@
slug : escapedText
};
var isChinese = /^[\u4e00-\u9fa5]+$/.test(text);
var id = (isChinese) ? escape(text).replace(/\%/g, "") : text.toLowerCase().replace(/[^\w]+/g, "-");
markdownToC.push(toc);
return "<h" + level + " id=\"" + this.options.headerPrefix + raw.toLowerCase().replace(/[^\w]+/g,"-")+"\">" +
return "<h" + level + " id=\"h"+ level + "-" + this.options.headerPrefix + id +"\">" +
"<a href=\"#" + text + "\" name=\"" + text + "\" class=\"anchor\"></a>" +
"<span class=\"header-link\"></span>" + text + "</h" + level + ">";
};
@ -2832,6 +2861,8 @@
js : "//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.1.1/katex.min"
};
editormd.kaTeXLoaded = false;
/**
* 加载KaTex文件
* @param {Function} [callback=function()] 加载成功后执行的回调函数

6
dist/js/editormd.min.js

File diff suppressed because one or more lines are too long

4
dist/js/languages/en.js

@ -1,12 +1,12 @@
/*
* Editor.md
* @file languages\en.js
* @version v1.1.5
* @version v1.1.6
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-02-26
* @updateTime 2015-03-02
*/
(function(){

2
dist/js/languages/en.min.js

@ -1,2 +1,2 @@
/*! Editor.md v1.1.5 | languages\en.min.js | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-02-26 */
/*! Editor.md v1.1.6 | languages\en.min.js | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-03-02 */
!function(){var e=function(e){var t={name:"en",description:"A simple markdown doucment online editor.",toolbar:{undo:"Undo(Ctrl+Z)",redo:"Redo(Ctrl+Y)",bold:"Bold",del:"Strikethrough",italic:"Italic",quote:"Block quote",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6","list-ul":"Unordered list","list-ol":"Ordered list",hr:"Horizontal line",link:"Link",anchor:"Anchor",image:"Image",code:"Code inline","code-block-tab":"Preformatted text / Code block (Tab indent)","code-block":"Code block (Multi-languages)",datetime:"Datetime",watch:"Unwatch",unwatch:"Watch",preview:"HTML Preview (Enter ESC exit)",fullscreen:"Fullscreen (Enter ESC exit)",clear:"Clear",info:"About "+e.title},buttons:{enter:"Enter",cancel:"Cancel"},dialog:{link:{title:"Link",url:"Address",urlTitle:"Title",urlEmpty:"Error: Please fill in the link address.",titleEmpty:"Error: Please fill in the link title."},anchor:{title:"Anchor link",name:"Name",url:"Address",urlTitle:"Title",nameEmpty:"Error: anchor name can't be empty.",titleEmpty:"Error: Please fill in anchor link title.",urlEmpty:"Error: Please fill in anchor link."},image:{title:"Image",url:"Address",link:"Link",alt:"Title",uploadButton:"Upload",imageURLEmpty:"Error: picture url address can't be empty.",uploadFileEmpty:"Error: upload pictures cannot be empty!",formatNotAllowed:"Error: only allows to upload pictures file, upload allowed image file format:"},tabCodeBlock:{title:"Preformatted text / Codes",codeEmptyAlert:"Error: Please fill in the Preformatted text or content of the codes."},codeBlock:{title:"Code block",selectLabel:"Languages: ",selectDefaultText:"select a code language...",otherLanguage:"Other languages",unselectedLanguageAlert:"Error: Please select the code language.",codeEmptyAlert:"Error: Please fill in the code content."}}};e.defaults.lang=t};"function"==typeof require&&"object"==typeof exports&&"object"==typeof module?module.exports=e:"function"==typeof define?define.amd?define(["editormd"],function(t){e(t)}):define(function(t){var l=t("../editormd");e(l)}):e(window.editormd)}();

4
dist/js/languages/zh-tw.js

@ -1,12 +1,12 @@
/*
* Editor.md
* @file languages\zh-tw.js
* @version v1.1.5
* @version v1.1.6
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-02-26
* @updateTime 2015-03-02
*/
(function(){

2
dist/js/languages/zh-tw.min.js

@ -1,2 +1,2 @@
/*! Editor.md v1.1.5 | languages\zh-tw.min.js | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-02-26 */
/*! Editor.md v1.1.6 | languages\zh-tw.min.js | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-03-02 */
!function(){var e=function(e){var t={name:"zh-tw",description:"開源在線Markdown編輯器<br/>A simple markdown doucment online editor.",toolbar:{undo:"撤銷(Ctrl+Z)",redo:"重做(Ctrl+Y)",bold:"粗體",del:"刪除線",italic:"斜體",quote:"引用",h1:"標題1",h2:"標題2",h3:"標題3",h4:"標題4",h5:"標題5",h6:"標題6","list-ul":"無序列表","list-ol":"有序列表",hr:"横线",link:"链接",anchor:"錨點",image:"圖片",code:"行內代碼","code-block-tab":"預格式文本 / 代碼塊(縮進風格)","code-block":"代碼塊(多語言風格)",datetime:"日期時間",watch:"關閉實時預覽",unwatch:"開啟實時預覽",preview:"全窗口預覽HTML(可按ESC還原)",fullscreen:"全屏(可按ESC還原)",clear:"清空",info:"關於"+e.title},buttons:{enter:"確定",cancel:"取消"},dialog:{link:{title:"添加鏈接",url:"鏈接地址",urlTitle:"鏈接標題",urlEmpty:"錯誤:請填寫鏈接地址。",titleEmpty:"錯誤:請填寫鏈接標題。"},anchor:{title:"添加錨點鏈接",name:"錨點名稱",url:"鏈接地址",urlTitle:"鏈接標題",nameEmpty:"錯誤:錨點名稱不能為空。",titleEmpty:"錯誤:請填寫錨點鏈接標題。",urlEmpty:"錯誤:請填寫錨點鏈接地址。"},image:{title:"添加圖片",url:"圖片地址",link:"圖片鏈接",alt:"圖片描述",uploadButton:"本地上傳",imageURLEmpty:"錯誤:圖片地址不能為空。",uploadFileEmpty:"錯誤:上傳的圖片不能為空!",formatNotAllowed:"錯誤:只允許上傳圖片文件,允許上傳的圖片文件格式有:"},tabCodeBlock:{title:"添加預格式文本或代碼塊",codeEmptyAlert:"錯誤:請填寫預格式文本或代碼的內容。"},codeBlock:{title:"添加代碼塊",selectLabel:"代碼語言:",selectDefaultText:"請語言代碼語言",otherLanguage:"其他語言",unselectedLanguageAlert:"錯誤:請選擇代碼所屬的語言類型。",codeEmptyAlert:"錯誤:請填寫代碼內容。"}}};e.defaults.lang=t};"function"==typeof require&&"object"==typeof exports&&"object"==typeof module?module.exports=e:"function"==typeof define?define.amd?define(["editormd"],function(t){e(t)}):define(function(t){var l=t("../editormd");e(l)}):e(window.editormd)}();

2
docs/html/index.html

@ -121,7 +121,7 @@
<br clear="both">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Thu Feb 26 2015 00:42:29 GMT+0800 (中国标准时间)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Mon Mar 02 2015 21:12:13 GMT+0800 (中国标准时间)
</footer>
<script> prettyPrint(); </script>

5
examples/full.html

@ -39,6 +39,7 @@
height: 740,
path : '../lib/',
markdown : md,
saveHTMLToTextarea : true, // 保存HTML到Textarea
//watch : false, // 关闭实时预览
htmlDecode : true, // 开启HTML标签解析,为了安全性,默认不开启
//toolbar : false, //关闭工具栏
@ -108,7 +109,7 @@
testEditor.hideToolbar();
});
});
/*
// IE不支持
editormd.printAreaCount = 0;
editormd.printArea = function($obj) {
@ -153,7 +154,7 @@
function preview() {
editormd.printArea(testEditor.previewContainer[0]);
}
}*/
</script>
</body>
</html>

4
examples/php/post.php

@ -4,8 +4,12 @@
if (isset($_POST['submit'])) {
echo "<pre>";
echo htmlspecialchars($_POST["test-editormd-markdown-doc"]);
if(isset($_POST["test-editormd-html-code"])) {
echo "<br/><br/>";
echo htmlspecialchars($_POST["test-editormd-html-code"]);
}
echo "</pre>";
}

1
examples/use-requirejs.html

@ -55,6 +55,7 @@
height: 640,
path : '../lib/',
markdown : md,
saveHTMLToTextarea : true, // 保存HTML到Textarea
htmlDecode : true, // 开启HTML标签解析,为了安全性,默认不开启
tex : true,
previewCodeHighlight : true,

1
examples/use-seajs.html

@ -61,6 +61,7 @@
path : '../lib/',
markdown : md,
//toolbar : false, //关闭工具栏
saveHTMLToTextarea : true, // 保存HTML到Textarea
htmlDecode : true, // 开启HTML标签解析,为了安全性,默认不开启
tex : true, // 开启科学公式TeX语言支持,默认关闭
//previewCodeHighlight : false, // 关闭预览窗口的代码高亮,默认开启

7
examples/use-zepto.html

@ -23,9 +23,12 @@
<button id="show-toolbar-btn">显示工具栏</button>
<button id="close-toolbar-btn">关闭工具栏</button>
</div>
<form action="php/post.php" method="post">
<div class="editormd" id="test-editormd">
<script type="text/markdown">###Hello world!</script>
<textarea>###Hello world!</textarea>
</div>
<br/><input type="submit" name="submit" value="Submit" class="btn" style="margin-left: 5%;" />
</form>
</div>
<script src="js/zepto.min.js"></script>
<script src="../src/js/editormd.js"></script>
@ -40,6 +43,8 @@
height : 720,
path : '../lib/',
markdown : md,
saveHTMLToTextarea : true, // 保存HTML到Textarea
//watch : false,
htmlDecode : true, // 开启HTML标签解析,为了安全性,默认不开启
tex : true, // 开启科学公式TeX语言支持,默认关闭
//previewCodeHighlight : false, // 关闭预览窗口的代码高亮,默认开启

2
lib/codemirror/addons.min.js

File diff suppressed because one or more lines are too long

2
lib/codemirror/modes.min.js

File diff suppressed because one or more lines are too long

2
package.json

@ -1,6 +1,6 @@
{
"name": "editor.md",
"version": "1.1.5",
"version": "1.1.6",
"description": "A simple online markdown editor.",
"directories": {
"doc": "docs",

179
src/js/editormd.js

@ -1,7 +1,7 @@
/**
* @fileOverview Editor.md
* @author pandao
* @version 1.1.5
* @version 1.1.6
*/
;(function(factory) {
@ -44,7 +44,7 @@
};
editormd.title = editormd.$name = "Editor.md";
editormd.version = "1.1.5";
editormd.version = "1.1.6";
editormd.homePage = "https://pandao.github.io/editor.md/";
editormd.classPrefix = "editormd-";
@ -282,7 +282,8 @@
editor.append(appendElements).addClass(classPrefix + "vertical");
if (settings.markdown !== "") {
if (settings.markdown !== "")
{
markdownTextarea.val(settings.markdown);
}
@ -409,6 +410,7 @@
setCodeMirror : function() {
var settings = this.settings;
var editor = this.editor;
var codeMirrorConfig = {
mode : settings.mode,
theme : "default",
@ -431,11 +433,10 @@
};
this.codeEditor = editormd.$CodeMirror.fromTextArea(this.markdownTextarea[0], codeMirrorConfig);
this.codeMirror = this.editor.find(".CodeMirror");
this.codeMirror = editor.find(".CodeMirror");
this.codeMirror.css({
fontSize : this.settings.fontSize,
fontSize : settings.fontSize,
width : (!settings.watch) ? "100%" : "50%"
});
@ -1631,7 +1632,6 @@
return this;
},
/**
* 编辑器界面重建用于动态语言包或模块加载等
* @returns {editormd} 返回editormd的实例对象
@ -1651,7 +1651,12 @@
createInfoDialog();
}
if (!settings.readOnly) {
if (!settings.readOnly)
{
if (editor.find(".editormd-dialog").length > 0) {
editor.find(".editormd-dialog").remove();
}
this.getToolbarHandles();
this.setToolbar();
}
@ -1662,40 +1667,49 @@
},
/**
* 加载队列完成之后的显示处理
* 高亮预览HTML的pre代码部分
* @returns {editormd} 返回editormd的实例对象
*/
loadedDisplay : function() {
this.state.loaded = true;
var _this = this;
var editor = this.editor;
var preview = this.preview;
previewCodeHighlight : function() {
var settings = this.settings;
var codeEditor = this.codeEditor;
var codeMirror = this.codeMirror;
var previewContainer = this.previewContainer;
var mouseOrTouch = editormd.mouseOrTouch;
editor.find("." + this.classPrefix + "container-mask").hide();
this.saveToTextareas();
if(settings.watch) {
preview.show();
}
var codeHighlight = function() {
if (settings.previewCodeHighlight)
{
previewContainer.find("pre").addClass("prettyprint linenums");
prettyPrint();
}
};
var flowChartAndSequenceDiagramHandle = function() {
return this;
},
/**
* 解析TeX(KaTeX)科学公式
* @returns {editormd} 返回editormd的实例对象
*/
katexRender : function() {
var previewContainer = this.previewContainer;
previewContainer.find("." + editormd.classNames.tex).each(function(){
var tex = $(this);
editormd.$katex.render(tex.html(), tex[0]);
});
return this;
},
/**
* 解析和渲染流程图及时序图
* @returns {editormd} 返回editormd的实例对象
*/
flowChartAndSequenceDiagramRender : function() {
var settings = this.settings;
var previewContainer = this.previewContainer;
if (editormd.isIE8) return ;
@ -1706,29 +1720,34 @@
if (settings.sequenceDiagram) {
previewContainer.find(".sequence-diagram").sequenceDiagram({theme: "simple"});
}
};
codeHighlight();
return this;
},
flowChartAndSequenceDiagramHandle();
/**
* 加载队列完成之后的显示处理
* @returns {editormd} 返回editormd的实例对象
*/
var katexHandle = function() {
previewContainer.find("." + editormd.classNames.tex).each(function(){
var tex = $(this);
editormd.$katex.render(tex.html(), tex[0]);
});
};
loadedDisplay : function() {
if (settings.tex)
{
if (!settings.inRequirejs) {
editormd.loadKaTeX(function(){
editormd.$katex = katex;
katexHandle();
});
} else {
katexHandle();
}
this.state.loaded = true;
var _this = this;
var editor = this.editor;
var preview = this.preview;
var settings = this.settings;
var codeEditor = this.codeEditor;
var codeMirror = this.codeMirror;
var previewContainer = this.previewContainer;
var mouseOrTouch = editormd.mouseOrTouch;
editor.find("." + this.classPrefix + "container-mask").hide();
this.saveToTextareas();
if(settings.watch) {
preview.show();
}
editor.data("oldWidth", editor.width()).data("oldHeight", editor.height()); // 为了兼容Zepto
@ -1807,22 +1826,7 @@
});
codeEditor.on("change", function(cm, changeObj) {
if (!settings.watch) {
return ;
}
_this.saveToTextareas();
codeHighlight();
flowChartAndSequenceDiagramHandle();
if (settings.tex) {
katexHandle();
}
$.proxy(settings.onchange, _this)();
});
return this;
@ -1917,28 +1921,49 @@
*/
saveToTextareas : function() {
var _this = this;
var settings = this.settings;
var codeEditor = this.codeEditor;
var previewContainer = this.previewContainer;
codeEditor.save();
var codeMirrorValue = codeEditor.getValue();
var markdownToC = this.markdownToC = [];
var newMarkdownDoc = editormd.$marked(codeEditor.getValue(), {renderer : editormd.markedRenderer(markdownToC)});
var newMarkdownDoc = editormd.$marked(codeMirrorValue, {renderer : editormd.markedRenderer(markdownToC)});
this.markdownTextarea[0].innerText = codeMirrorValue;
this.markdownTextarea.val(codeEditor.getValue());
codeEditor.save();
if (settings.saveHTMLToTextarea) {
this.htmlTextarea.html(newMarkdownDoc);
}
if(settings.watch)
if(settings.watch || (!settings.watch && this.state.preview))
{
previewContainer.html(newMarkdownDoc);
this.previewCodeHighlight();
if (settings.toc) {
editormd.markdownToCRenderer(markdownToC, previewContainer, settings.tocStartLevel);
}
if (!settings.inRequirejs && !editormd.kaTeXLoaded) {
editormd.loadKaTeX(function(){
editormd.$katex = katex;
editormd.kaTeXLoaded = true;
_this.katexRender();
});
} else {
this.katexRender();
}
var timer = setTimeout(function(){
clearTimeout(timer);
_this.flowChartAndSequenceDiagramRender();
}, 10);
$.proxy(settings.onchange, this)();
}
return this;
@ -2032,8 +2057,9 @@
*/
setMarkdown : function(md) {
var settings = this.settings;
this.codeEditor.setValue(md);
this.saveToTextareas();
return this;
},
@ -2054,7 +2080,6 @@
clear : function() {
this.codeEditor.setValue("");
this.saveToTextareas();
return this;
},
@ -2221,7 +2246,7 @@
if(!settings.watch)
{
var codeEditor = this.codeEditor;
/*var codeEditor = this.codeEditor;
var previewContainer = this.previewContainer;
codeEditor.save();
@ -2232,7 +2257,8 @@
if (settings.toc) {
editormd.markdownToCRenderer(markdownToC, previewContainer, settings.tocStartLevel);
}
}*/
this.saveToTextareas();
}
preview.show().css({
@ -2403,9 +2429,12 @@
slug : escapedText
};
var isChinese = /^[\u4e00-\u9fa5]+$/.test(text);
var id = (isChinese) ? escape(text).replace(/\%/g, "") : text.toLowerCase().replace(/[^\w]+/g, "-");
markdownToC.push(toc);
return "<h" + level + " id=\"" + this.options.headerPrefix + raw.toLowerCase().replace(/[^\w]+/g,"-")+"\">" +
return "<h" + level + " id=\"h"+ level + "-" + this.options.headerPrefix + id +"\">" +
"<a href=\"#" + text + "\" name=\"" + text + "\" class=\"anchor\"></a>" +
"<span class=\"header-link\"></span>" + text + "</h" + level + ">";
};
@ -2821,6 +2850,8 @@
js : "//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.1.1/katex.min"
};
editormd.kaTeXLoaded = false;
/**
* 加载KaTex文件
* @param {Function} [callback=function()] 加载成功后执行的回调函数

Loading…
Cancel
Save