Browse Source

Releases v1.4.5

master
pandao 10 years ago
parent
commit
4c0a4ab469
  1. 19
      CHANGE.md
  2. 2
      README.md
  3. 2
      bower.json
  4. 4
      css/editormd.css
  5. 4
      css/editormd.logo.css
  6. 2
      css/editormd.logo.min.css
  7. 2
      css/editormd.min.css
  8. 4
      css/editormd.preview.css
  9. 2
      css/editormd.preview.min.css
  10. 28
      editormd.amd.js
  11. 7
      editormd.amd.min.js
  12. 30
      editormd.js
  13. 7
      editormd.min.js
  14. 6
      examples/code-fold.html
  15. 2
      examples/define-plugin.html
  16. 2
      examples/emoji.html
  17. 12
      examples/extends.html
  18. 3
      examples/form-get-value.html
  19. 4
      examples/full.html
  20. 8
      examples/html-preview-markdown-to-html.html
  21. 2
      examples/html-tags-decode.html
  22. 2
      examples/image-cross-domain-upload.html
  23. 4
      examples/index.html
  24. 5
      examples/katex.html
  25. 5
      examples/manually-load-modules.html
  26. 15
      examples/multi-editormd.html
  27. 12
      examples/php/cross-domain-upload.php
  28. 18
      examples/php/editormd.uploader.class.php
  29. 7
      examples/php/upload.php
  30. 3
      examples/php/upload_callback.html
  31. 4
      examples/sequence-diagram.html
  32. 4
      examples/set-get-replace-selection.html
  33. 14
      examples/task-lists.html
  34. 2
      examples/test.md
  35. 2
      examples/themes.html
  36. 1
      examples/toc.html
  37. 2
      examples/toolbar-auto-fixed.html
  38. 6
      examples/use-requirejs.html
  39. 6
      examples/use-seajs.html
  40. 6
      examples/use-zepto.html
  41. 2
      lib/codemirror/addons.min.js
  42. 10779
      lib/codemirror/modes.min.js
  43. 2
      package.json
  44. 28
      plugins/image-dialog/image-dialog.js
  45. 24
      src/editormd.js

19
CHANGE.md

@ -108,7 +108,7 @@
- 由于 IE8 不支持 FlowChart 和 SequenceDiagram,默认在 IE8 下不加载这两个组件,无论是否开启;
- 新增 Zepto.js 的支持;
- 为了兼容Zepto,某些元素在操作处理上不再使用`outerWidth()`、`outerHeight()`、`hover()`、`is()`等方法;
- 为了兼容 Zepto.js ,某些元素在操作处理上不再使用 `outerWidth()` `outerHeight()` 、`hover()` 、`is()` 等方法;
- 为了避免修改 flowChart.js 和 sequence-diagram.js 的源码,所以想支持 flowChart 或 sequenceDiagram 得加上这一句: `var jQuery = Zepto;`
- 新增 `editormd.$name` 属性,修改 `editormd.homePage` 属性的新地址;
@ -235,7 +235,7 @@ v1.2.0 主要更新:
- 新增代码折叠、自动闭合标签和搜索替换功能;
- 搜索快捷键 `Ctrl + F / Command + F`
- 替换快捷键 `Ctrl + Shift + F / Command + Option + F`
- 折叠快捷键`Ctrl + Q / Command + Q`
- 折叠快捷键 `Ctrl + Q / Command + Q`
- 新增自定义主题支持;
- 新增 3 个成员方法 `setTheme()``setCodeMirrorOption()``getCodeMirrorOption()`
@ -283,7 +283,7 @@ v1.2.0 主要更新:
- 新增两个方法: `setValue()` 、`getValue()`;
- 新增 `config()` 方法,用于加载后重新配置;
- 增加两个属性`cm`,是`codeEditor`的简写,`cmElement`,是`codeMirror`的别名;
- 增加两个属性 `cm` ,是 `codeEditor` 的简写, `cmElement``codeMirror` 的别名;
- 成员方法的改进:
@ -454,3 +454,16 @@ v1.2.0 主要更新:
- 修复 Bug [#81](https://github.com/pandao/editor.md/issues/81),即不支持 `:+1:` 的问题;
- 修复 Bug [#85](https://github.com/pandao/editor.md/issues/85),即图片上传返回结果不支持 `Content-Type=application/json` 的问题;
- 修复图片上传无法显示 loading 的问题;
#### v1.4.5
- 规范项目的中英文混排;
- 新增配置项 `name`,用于指定 Markdown textarea 的 `name="xxxx"` 属性;
- 修复 Bug,即无法正确解析公式的 `<``>` 的问题 [#87](https://github.com/pandao/editor.md/issues/87);
- 修复 Bug,即 `getHTML()` 无效的问题 [#95](https://github.com/pandao/editor.md/issues/95);
- 修复 Bug,即火狐上传图片后无法返回值的问题 [#96](https://github.com/pandao/editor.md/issues/96);
- 修改了图片上传插件;
- 修改 PHP 上传类及示例;
- 方法更名:`extends()` 更名为 `extend()`,与兼容 IE8;
- 修复 IE8 下 Emoji 正则表达式字符集越界的问题;
- 更新了 `README.md``CHANGE.md` 等相关文档文件;

2
README.md

@ -61,7 +61,7 @@ HTML:
```html
<link rel="stylesheet" href="editormd.min.css" />
<div id="editormd">
<textarea style="display:none;">### Hello world!</textarea>
<textarea style="display:none;">### Hello Editor.md !</textarea>
</div>
```

2
bower.json

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

4
css/editormd.css

@ -2,12 +2,12 @@
* Editor.md
*
* @file editormd.css
* @version v1.4.4
* @version v1.4.5
* @description Open source online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-05-09
* @updateTime 2015-06-02
*/
@charset "UTF-8";

4
css/editormd.logo.css

@ -2,12 +2,12 @@
* Editor.md
*
* @file editormd.logo.css
* @version v1.4.4
* @version v1.4.5
* @description Open source online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-05-09
* @updateTime 2015-06-02
*/
/*! prefixes.scss v0.1.0 | Author: Pandao | https://github.com/pandao/prefixes.scss | MIT license | Copyright (c) 2015 */

2
css/editormd.logo.min.css

@ -1,2 +1,2 @@
/*! Editor.md v1.4.4 | editormd.logo.min.css | Open source online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-05-09 */
/*! Editor.md v1.4.5 | editormd.logo.min.css | Open source online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-06-02 */
/*! prefixes.scss v0.1.0 | Author: Pandao | https://github.com/pandao/prefixes.scss | MIT license | Copyright (c) 2015 */@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,.editormd-logo-1x,.editormd-logo-2x,.editormd-logo-3x,.editormd-logo-4x,.editormd-logo-5x,.editormd-logo-6x,.editormd-logo-7x,.editormd-logo-8x{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-1x:before,.editormd-logo-2x:before,.editormd-logo-3x:before,.editormd-logo-4x:before,.editormd-logo-5x:before,.editormd-logo-6x:before,.editormd-logo-7x:before,.editormd-logo-8x:before,.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
css/editormd.min.css

File diff suppressed because one or more lines are too long

4
css/editormd.preview.css

@ -2,12 +2,12 @@
* Editor.md
*
* @file editormd.preview.css
* @version v1.4.4
* @version v1.4.5
* @description Open source online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-05-09
* @updateTime 2015-06-02
*/
@charset "UTF-8";

2
css/editormd.preview.min.css

@ -1,4 +1,4 @@
/*! Editor.md v1.4.4 | editormd.preview.min.css | Open source online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-05-09 */
/*! Editor.md v1.4.5 | editormd.preview.min.css | Open source online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-06-02 */
@charset "UTF-8";/*! prefixes.scss v0.1.0 | Author: Pandao | https://github.com/pandao/prefixes.scss | MIT license | Copyright (c) 2015 *//*!
* Font Awesome 4.3.0 by @davegandy - http://fontawesome.io - @fontawesome
* License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License)

28
editormd.amd.js

@ -2,12 +2,12 @@
* Editor.md
*
* @file editormd.amd.js
* @version v1.4.4
* @version v1.4.5
* @description Open source online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-05-09
* @updateTime 2015-06-02
*/
;(function(factory) {
@ -129,7 +129,7 @@
};
editormd.title = editormd.$name = "Editor.md";
editormd.version = "1.4.4";
editormd.version = "1.4.5";
editormd.homePage = "https://pandao.github.io/editor.md/";
editormd.classPrefix = "editormd-";
@ -161,6 +161,7 @@
editormd.defaults = {
mode : "gfm", //gfm or markdown
theme : "default",
name : "",
value : "", // value for CodeMirror, if mode not gfm/markdown
markdown : "",
appendMarkdown : "", // if in init textarea value not empty, append markdown to textarea
@ -474,7 +475,12 @@
markdownTextarea = this.markdownTextarea = editor.children("textarea");
}
markdownTextarea.addClass(classNames.textarea.markdown).attr("name", id + "-markdown-doc").attr("placeholder", settings.placeholder);
markdownTextarea.addClass(classNames.textarea.markdown).attr("placeholder", settings.placeholder);
if (typeof markdownTextarea.attr("name") === "undefined" || markdownTextarea.attr("name") === "")
{
markdownTextarea.attr("name", (settings.name !== "") ? settings.name : id + "-markdown-doc");
}
var appendElements = [
(!settings.readOnly) ? "<a href=\"javascript:;\" class=\"fa fa-close " + classPrefix + "preview-close-btn\"></a>" : "",
@ -882,7 +888,7 @@
* @returns {editormd} this(editormd instance object.)
*/
extends : function() {
extend : function() {
if (typeof arguments[1] !== "undefined")
{
if (typeof arguments[1] === "function")
@ -1961,13 +1967,15 @@
var newMarkdownDoc = editormd.$marked(cmValue, markedOptions);
this.markdownTextarea.val(cmValue);
//console.log("cmValue", cmValue, this.markdownTextarea, this.htmlTextarea);
this.markdownTextarea.text(cmValue);
cm.save();
if (settings.saveHTMLToTextarea)
{
this.htmlTextarea.val(newMarkdownDoc);
this.htmlTextarea.text(newMarkdownDoc);
}
if(settings.watch || (!settings.watch && state.preview))
@ -2252,7 +2260,7 @@
return false;
}
return this.htmlTextarea.html();
return this.htmlTextarea.val();
},
/**
@ -3216,7 +3224,7 @@
atLink : /@(\w+)/g,
email : /(\w+)@(\w+)\.(\w+)\.?(\w+)?/g,
emailLink : /(mailto:)?([\w\.\_]+)@(\w+)\.(\w+)\.?(\w+)?/g,
emoji : /:([\+-\w]+):/g,
emoji : /:([\w\+-]+):/g,
emojiDatetime : /(\d{2}:\d{2}:\d{2})/g,
twemoji : /:(tw-([\w]+)-?(\w+)?):/g,
fontAwesome : /:(fa-([\w]+)(-(\w+)){0,}):/g,
@ -3848,7 +3856,7 @@
var katexHandle = function() {
div.find("." + editormd.classNames.tex).each(function(){
var tex = $(this);
katex.render(tex.html(), tex[0]);
katex.render(tex.html().replace(/&lt;/g, "<").replace(/&gt;/g, ">"), tex[0]);
});
};

7
editormd.amd.min.js

File diff suppressed because one or more lines are too long

30
editormd.js

@ -2,12 +2,12 @@
* Editor.md
*
* @file editormd.js
* @version v1.4.4
* @version v1.4.5
* @description Open source online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-05-09
* @updateTime 2015-06-02
*/
;(function(factory) {
@ -59,7 +59,7 @@
};
editormd.title = editormd.$name = "Editor.md";
editormd.version = "1.4.4";
editormd.version = "1.4.5";
editormd.homePage = "https://pandao.github.io/editor.md/";
editormd.classPrefix = "editormd-";
@ -91,6 +91,7 @@
editormd.defaults = {
mode : "gfm", //gfm or markdown
theme : "default",
name : "",
value : "", // value for CodeMirror, if mode not gfm/markdown
markdown : "",
appendMarkdown : "", // if in init textarea value not empty, append markdown to textarea
@ -403,11 +404,14 @@
editor.append("<textarea></textarea>");
markdownTextarea = this.markdownTextarea = editor.children("textarea");
}
if(markdownTextarea.attr("name")=="undefined" || markdownTextarea.attr("name")==""){
markdownTextarea.attr("name", id + "-markdown-doc");
}
markdownTextarea.addClass(classNames.textarea.markdown).attr("placeholder", settings.placeholder);
if (typeof markdownTextarea.attr("name") === "undefined" || markdownTextarea.attr("name") === "")
{
markdownTextarea.attr("name", (settings.name !== "") ? settings.name : id + "-markdown-doc");
}
var appendElements = [
(!settings.readOnly) ? "<a href=\"javascript:;\" class=\"fa fa-close " + classPrefix + "preview-close-btn\"></a>" : "",
( (settings.saveHTMLToTextarea) ? "<textarea class=\"" + classNames.textarea.html + "\" name=\"" + id + "-html-code\"></textarea>" : "" ),
@ -814,7 +818,7 @@
* @returns {editormd} this(editormd instance object.)
*/
extends : function() {
extend : function() {
if (typeof arguments[1] !== "undefined")
{
if (typeof arguments[1] === "function")
@ -1893,13 +1897,15 @@
var newMarkdownDoc = editormd.$marked(cmValue, markedOptions);
this.markdownTextarea.val(cmValue);
//console.log("cmValue", cmValue, this.markdownTextarea, this.htmlTextarea);
this.markdownTextarea.text(cmValue);
cm.save();
if (settings.saveHTMLToTextarea)
{
this.htmlTextarea.val(newMarkdownDoc);
this.htmlTextarea.text(newMarkdownDoc);
}
if(settings.watch || (!settings.watch && state.preview))
@ -2184,7 +2190,7 @@
return false;
}
return this.htmlTextarea.html();
return this.htmlTextarea.val();
},
/**
@ -3148,7 +3154,7 @@
atLink : /@(\w+)/g,
email : /(\w+)@(\w+)\.(\w+)\.?(\w+)?/g,
emailLink : /(mailto:)?([\w\.\_]+)@(\w+)\.(\w+)\.?(\w+)?/g,
emoji : /:([\+-\w]+):/g,
emoji : /:([\w\+-]+):/g,
emojiDatetime : /(\d{2}:\d{2}:\d{2})/g,
twemoji : /:(tw-([\w]+)-?(\w+)?):/g,
fontAwesome : /:(fa-([\w]+)(-(\w+)){0,}):/g,
@ -3780,7 +3786,7 @@
var katexHandle = function() {
div.find("." + editormd.classNames.tex).each(function(){
var tex = $(this);
katex.render(tex.html(), tex[0]);
katex.render(tex.html().replace(/&lt;/g, "<").replace(/&gt;/g, ">"), tex[0]);
});
};

7
editormd.min.js

File diff suppressed because one or more lines are too long

6
examples/code-fold.html

@ -2,7 +2,7 @@
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>Code fold - Editor.md examples</title>
<title>Code folding - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../css/editormd.css" />
<link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon" />
@ -10,8 +10,8 @@
<body>
<div id="layout">
<header>
<h1>Code fold</h1>
<p>Switch code fold : Press Ctrl + Q / Command + Q</p>
<h1>Code folding</h1>
<p>Switch code folding : Press Ctrl + Q / Command + Q</p>
</header>
<div id="test-editormd">
<textarea style="display:none;"></textarea>

2
examples/define-plugin.html

@ -84,8 +84,6 @@
#### Usage plugin
The first method:
```html
&lt;script src="../plugins/you-plugin-name/you-plugin-name.js"&gt;&lt;/script&gt;
&lt;script&gt;

2
examples/emoji.html

@ -124,7 +124,7 @@ ___Emphasis :fa-gear: Italic:smiley:___ __Emphasis:smiley:__
2015-03-12 02:21:47
###Table
### In table
|:100: First Header | Second:smiley: Header:smiley: |
| ------------- | ------------- |

12
examples/extends.html

@ -21,12 +21,12 @@ var testEditor;
function EditormdExtend() {
this.extends("methodC", function() {
this.extend("methodC", function() {
console.log("methodC");
});
// or
testEditor.extends("methodA", function() {
testEditor.extend("methodA", function() {
console.log("methodA");
});
@ -37,7 +37,7 @@ function EditormdExtend() {
});
// mutil
this.extends({
this.extend({
propertyA : "propertyAAAA", // override, you can override other default method.
propertyB : "propertyB",
methodD : function() {
@ -90,12 +90,12 @@ $(function() {
function EditormdExtend() {
this.extends("methodC", function() {
this.extend("methodC", function() {
console.log("methodC");
});
// or
testEditor.extends("methodA", function() {
testEditor.extend("methodA", function() {
console.log("methodA");
});
@ -106,7 +106,7 @@ $(function() {
});
// mutil
this.extends({
this.extend({
propertyA : "propertyAAAA", // override, you can override other default method.
propertyB : "propertyB",
methodD : function() {

3
examples/form-get-value.html

@ -15,9 +15,10 @@
</header>
<form method="post" action="http://editormd.ipandao.com/php/post.php">
<div id="test-editormd">
<!-- Custom textarea name attribute <textarea style="display:none;" name="test-textarea-name"> -->
<textarea style="display:none;">#### Get value
每个Editor.md的ID元素下都包含两个Textarea,一个保存Markdown源码,一个保存HTML源码,可以按需要获取相应的值,如下:
每个 Editor.md 的 ID 元素下都有一个保存 Markdown 源码的 Textarea,你也可以通过设置开启另一个保存 HTML 源码的 Textarea,可以按需要获取相应的值,如下:
```html
&lt;div class="editormd" id="$id"&gt;

4
examples/full.html

@ -2,7 +2,7 @@
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>完整示例 Full example - Editor.md examples</title>
<title>Full example - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../css/editormd.css" />
<link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon" />
@ -54,7 +54,7 @@
saveHTMLToTextarea : true, // 保存 HTML 到 Textarea
searchReplace : true,
//watch : false, // 关闭实时预览
htmlDecode : "style,script,iframe", // 开启HTML标签解析,为了安全性,默认不开启
htmlDecode : "style,script,iframe|on*", // 开启 HTML 标签解析,为了安全性,默认不开启
//toolbar : false, //关闭工具栏
//previewCodeHighlight : false, // 关闭预览 HTML 的代码块高亮,默认开启
emoji : true,

8
examples/html-preview-markdown-to-html.html

@ -36,6 +36,8 @@ $$\(\sqrt{3x-1}+(1+x)^2\)$$
$$\sin(\alpha)^{\theta}=\sum_{i=0}^{n}(x^i + \cos(f))$$
$$X^2 > Y$$
#####上标和下标
上标:X&lt;sup&gt;2&lt;/sup&gt;
@ -79,12 +81,12 @@ alert("script");
<script src="../editormd.js"></script>
<script type="text/javascript">
$(function() {
var testEditormdView, testEditormdView2;
$(function() {
$.get("test.md", function(markdown) {
testEditormdView = editormd.markdownToHTML("test-editormd-view", {
markdown : markdown + "\r\n" + $("#append-test").val(),
markdown : markdown ,//+ "\r\n" + $("#append-test").text(),
//htmlDecode : true, // 开启 HTML 标签解析,为了安全性,默认不开启
htmlDecode : "style,script,iframe", // you can filter tags decode
//toc : false,
@ -101,7 +103,7 @@ alert("script");
//console.log("返回一个 jQuery 实例 =>", testEditormdView);
// 获取Markdown源码
console.log(testEditormdView.getMarkdown());
//console.log(testEditormdView.getMarkdown());
//alert(testEditormdView.getMarkdown());
});

2
examples/html-tags-decode.html

@ -13,7 +13,7 @@
<h1>识别和解析HTML标签</h1>
<p>HTML tags (filter) decode, You can increase safety by filtering the danger label.</p>
<p>注:虽然此功能能极大地扩展 Markdown 语法,但也面临着安全上的风险,所以默认是不开启的。</p>
<p>Update: 可以通过设置`settings.htmlDecode = "style,script,iframe"`来实现过滤指定标签的解析,提高安全性;</p>
<p>Update: 可以通过设置 `settings.htmlDecode = "style,script,iframe|on*"`来实现过滤指定标签及属性的解析,提高安全性;</p>
</header>
<div class="btns">
<button class="filter-btn" exp="true">Unfilter</button>

2
examples/image-cross-domain-upload.html

@ -46,6 +46,8 @@
```php
&lt;?php
header("Access-Control-Allow-Origin: *"); // Setting allow domian name
$file = 'uploads/' . $_FILES['file']['name'];
// 详细过程略
move_uploaded_file($_FILES['file']['tmp_name'], $file);

4
examples/index.html

@ -188,7 +188,7 @@
<a href="./multi-editormd.html">多个 Editor.md 并存 <span>Multi Editor.md</span></a>
</li>
<li>
<a href="./goto-line.html">跳转到指定的行 <span>Jump/goto line</span></a>
<a href="./goto-line.html">跳转到指定的行 <span>Goto line</span></a>
</li>
<li>
<a href="./readonly.html">只读模式 <span>Read only mode</span></a>
@ -254,7 +254,7 @@
<a href="./flowchart.html">流程图 <span>FlowChart example</span></a>
</li>
<li>
<a href="./sequence-diagram.html">时序/序列图 <span>Sequence Diagram example</span></a>
<a href="./sequence-diagram.html">时序/ 序列图 <span>Sequence Diagram example</span></a>
</li>
<li>
<a href="./page-break.html">分页符 <span>Page break</span></a>

5
examples/katex.html

@ -44,7 +44,7 @@ Inline 行内的公式$$E=mc^2$$行内的公式,行内的$$E=mc^2$$公式。
$$c = \\pm\\sqrt{a^2 + b^2}$$
$$x > y$$
$$x &gt; y$$
$$f(x) = x^2$$
@ -124,11 +124,10 @@ $$\int_C x^3\, dx + 4y^2\, dy$$
$${}_1^2\!\Omega_3^4$$
$$x', y'', f', f''$$
#### KaTeX vs MathJax
[https://jsperf.com/katex-vs-mathjax](https://jsperf.com/katex-vs-mathjax "KaTeX vs MathJax")
</textarea>
</div>
</div>

5
examples/manually-load-modules.html

@ -2,14 +2,15 @@
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>Manually load-modules - Editor.md examples</title>
<title>Manually load modules - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon" />
</head>
<body>
<div id="layout">
<header>
<h1>Manually load-modules</h1>
<h1>手动加载模式 Manually load modules</h1>
<p>在这种模式下,可以同步使用 Editor.md 实例的成员方法。</p>
</header>
<div id="test-editormd">
<textarea style="display:none;">#### Manually load modules exmaple

15
examples/multi-editormd.html

@ -2,7 +2,7 @@
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>多个Editor.md并存 - Editor.md examples</title>
<title>Multi Editor.md - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../css/editormd.css" />
<link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon" />
@ -20,14 +20,16 @@
<body>
<div id="layout">
<header>
<h1>多个Editor.md并存</h1>
<p>Multi Editor.md</p>
<h1>Multi Editor.md</h1>
<p>多个 Editor.md 并存</p>
<br/>
</header>
<h3>Editor.md A</h3>
<div id="test-editormd"></div>
<h3>Editor.md B</h3>
<div id="test-editormd2"></div>
<h3>Editor.md C</h3>
<div id="test-editormd3"></div>
</div>
<script src="js/jquery.min.js"></script>
@ -49,6 +51,13 @@
markdown : "#### Editor.md B",
path : '../lib/'
});
testEditormd3 = editormd("test-editormd3", {
width: "90%",
height: 480,
markdown : "#### Editor.md C",
path : '../lib/'
});
});
</script>
</body>

12
examples/php/cross-domain-upload.php

@ -23,16 +23,12 @@
$savePath = realpath($path . '../uploads/') . DIRECTORY_SEPARATOR;
$saveURL = '//'. $_SERVER['SERVER_NAME'] . $url . '../uploads/'; // 本例是演示跨域上传所以加上$_SERVER['SERVER_NAME']
/*echo "<pre>";
print_r($_SERVER);
echo $saveURL;
echo "</pre>";*/
$formats = array(
'image' => array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'webp')
);
$name = 'editormd-image-file'; // file input name
$callbackUrl = $_GET['callback'];
if (isset($_FILES[$name]))
{
@ -44,11 +40,15 @@
));
$imageUploader->redirect = true;
$imageUploader->redirectURL = $_GET['callback'] . '?dialog_id=' . $_GET['dialog_id'] . '&temp=' . date('ymdhis');
$imageUploader->redirectURL = $callbackUrl . (empty(parse_url($callbackUrl)['query']) ? '?' : '&') . 'dialog_id=' . $_GET['dialog_id'] . '&temp=' . date('ymdhis');
if ($imageUploader->upload($name))
{
$imageUploader->message('上传成功!', 1);
}
else
{
$imageUploader->message('上传失败!', 0);
}
}
?>

18
examples/php/editormd.uploader.class.php

@ -8,7 +8,7 @@
* @Auther: Pandao
* @E-mail: pandao@vip.qq.com
* @CreateTime: 2015-02-13 23:31:32
* @UpdateTime: 2015-02-15 20:49:52
* @UpdateTime: 2015-06-02 15:36:23
* Copyright@2015 Editor.md all right reserved.
*/
@ -91,6 +91,8 @@
if(empty($_FILES[$name]['name'])) //上传文件为空时
{
$this->message($this->errors['empty']);
return false;
}
$this->files = $_FILES[$name];
@ -98,11 +100,15 @@
if(!file_exists($this->savePath)) //目录不存在
{
$this->message($this->errors['not_exist']);
return false;
}
if(!is_writable($this->savePath)) //目录不可写
{
$this->message($this->errors['unwritable']);
return false;
}
$this->fileExt = $this->getFileExt($this->files["name"]); //取得扩展名
@ -128,12 +134,16 @@
$formats = implode(',', $this->formats);
$message = "您上传的文件" . $files["name"] . "是" . $this->fileExt . "格式的,系统不允许上传,您只能上传" . $formats . "格式的文件。";
$this->message($message);
return false;
}
if ($files["size"] / 1024 > $this->maxSize)
{
$message = "您上传的 " . $files["name"] . ",文件大小超出了系统限定值" . $this->maxSize . " KB,不能上传。";
$this->message($message);
return false;
}
if (!$this->cover) //当不能覆盖时
@ -141,6 +151,8 @@
if(file_exists($this->savePath.$this->saveName)) //有相同的文件存在
{
$this->message($this->saveName . $this->errors['same_file']);
return false;
}
}
@ -187,6 +199,8 @@
}
$this->message($message);
return false;
}
@unlink($files["tmp_name"]); //删除临时文件
@ -323,7 +337,5 @@
echo json_encode($array);
}
exit;
}
}

7
examples/php/upload.php

@ -11,7 +11,8 @@
* Copyright@2015 Editor.md all right reserved.
*/
header("Content-Type:application/json; charset=utf-8");
//header("Content-Type:application/json; charset=utf-8"); // Unsupport IE
header("Content-Type:text/html; charset=utf-8");
header("Access-Control-Allow-Origin: *");
require("editormd.uploader.class.php");
@ -42,5 +43,9 @@
{
$imageUploader->message('上传成功!', 1);
}
else
{
$imageUploader->message('上传失败!', 0);
}
}
?>

3
examples/php/upload_callback.html

@ -19,9 +19,8 @@
}
var imageDialog = window.parent.document.getElementById(query['dialog_id']);
//console.log(imageDialog, window.parent.document, window.parent, query);
if (query['success'] === '1')
if (parseInt(query['success']) === 1)
{
imageDialog.querySelector("[data-url]").value = query['url'];
}

4
examples/sequence-diagram.html

@ -14,9 +14,7 @@
<p>Based on SequenceDiagram.js:<a href="http://bramp.github.io/js-sequence-diagrams/" target="_blank">http://bramp.github.io/js-sequence-diagrams/</a></p>
</header>
<div id="test-editormd">
<textarea style="display:none;">####Using SequenceDiagram
setting:
<textarea style="display:none;">#### Setting
{
sequenceDiagram : true

4
examples/set-get-replace-selection.html

@ -23,7 +23,9 @@
</div>
</header>
<div id="test-editormd">
<textarea style="display:none;">```javascript
<textarea style="display:none;">### Examples
```javascript
var testEditormd;
$(function() {

14
examples/task-lists.html

@ -13,13 +13,19 @@
<h1>Github Flavored Markdown task lists</h1>
</header>
<div id="test-editormd">
<textarea style="display:none;">###GFM task lists
<textarea style="display:none;">### Setting
{
taskList : true
}
### Examples
- [x] @mentions, #refs, [links](), **formatting**, and <del>tags</del> supported;
- [x] list syntax required (any unordered or ordered list supported);
- [x] [ ] this is a complete item;
- [ ] []this is an incomplete item [test link](#);
- [ ] [ ]this is an incomplete item;
- [x] this is a complete item;
- [ ] this is an incomplete item [test link](#);
- [ ] this is an incomplete item;
- [ ] this is an incomplete item [test link](#);
- [ ] this is an incomplete item [test link](#);

2
examples/test.md

@ -291,6 +291,8 @@ $$E=mc^2$$
行内的公式$$E=mc^2$$行内的公式,行内的$$E=mc^2$$公式。
$$x > y$$
$$\(\sqrt{3x-1}+(1+x)^2\)$$
$$\sin(\alpha)^{\theta}=\sum_{i=0}^{n}(x^i + \cos(f))$$

2
examples/themes.html

@ -43,7 +43,7 @@ testEditor = editormd("test-editormd", {
- neat
- pastel-on-dark
####Optional
#### Optionals
- default
- 3024-day

1
examples/toc.html

@ -7,7 +7,6 @@
<link rel="stylesheet" href="../css/editormd.css" />
<link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon" />
<style>
#custom-toc-container {
border: 1px solid #ddd;
width: 87%;

2
examples/toolbar-auto-fixed.html

@ -2,7 +2,7 @@
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>Simple - Editor.md examples</title>
<title>Toolbar auto fixed - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../css/editormd.css" />
<link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon" />

6
examples/use-requirejs.html

@ -2,7 +2,7 @@
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>Use require.js - Editor.md examples</title>
<title>Using require.js - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../lib/codemirror/codemirror.min.css" />
<!-- <link rel="stylesheet" href="../lib/codemirror/addon/fold/foldgutter.css" /> -->
@ -12,7 +12,7 @@
<body>
<div id="layout">
<header>
<h1>Use require.js</h1>
<h1>Using require.js</h1>
<ul style="margin: 10px 0 0 18px;">
<li>Enable HTML tags decode</li>
<li>Enable TeX, Flowchart, Sequence Diagram, Emoji, FontAwesome, Task lists</li>
@ -87,7 +87,7 @@
codeFold : true,
searchReplace : true,
saveHTMLToTextarea : true, // 保存HTML到Textarea
htmlDecode : "style,script,iframe", // 开启HTML标签解析,为了安全性,默认不开启
htmlDecode : "style,script,iframe|on*", // 开启HTML标签解析,为了安全性,默认不开启
emoji : true,
taskList : true,
tex : true,

6
examples/use-seajs.html

@ -2,7 +2,7 @@
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>Use sea.js - Editor.md examples</title>
<title>Using sea.js - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../css/editormd.min.css" />
<link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon" />
@ -20,7 +20,7 @@
<body>
<div id="layout">
<header>
<h1>Use sea.js</h1>
<h1>Using sea.js</h1>
<p>说明:</p>
<p>1、由于Editor.md是依赖jQuery的,所以在使用Sea.js加载Editor.md时,要在jQuery.js文件尾部加上 <code>if(typeof define === "function") { define(function () { return $.noConflict(); }); }</code>,使jQuery支持Sea.js;</p>
<p>2、flowChart(流程图)和sequenceDiagram(时序图)基于Raphael.js,由于疑似Sea.js与Raphael.js有冲突,所以必须先加载Raphael.js再加载Sea.js,Editor.md才能在Sea.js下正常进行;</p>
@ -90,7 +90,7 @@
codeFold : true,
searchReplace : true,
saveHTMLToTextarea : true, // 保存 HTML 到 Textarea
htmlDecode : "style,script,iframe", // 开启HTML标签解析,为了安全性,默认不开启
htmlDecode : "style,script,iframe|on*", // 开启 HTML 标签解析,为了安全性,默认不开启
emoji : true,
taskList : true,
tocm : true, // Using [TOCM]

6
examples/use-zepto.html

@ -2,7 +2,7 @@
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>Use Zepto.js - Editor.md examples</title>
<title>Using Zepto.js - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../css/editormd.css" />
<link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon" />
@ -10,7 +10,7 @@
<body>
<div id="layout">
<header>
<h1>Use Zepto.js</h1>
<h1>Using Zepto.js</h1>
<ul style="margin: 10px 0 0 18px;">
<li>Enable HTML tags decode</li>
<li>Enable TeX, Flowchart, Sequence Diagram, Emoji, FontAwesome, Task lists</li>
@ -56,7 +56,7 @@
searchReplace : true,
saveHTMLToTextarea : true, // 保存 HTML 到 Textarea
//watch : false,
htmlDecode : "style,script,iframe", // 开启HTML标签解析,为了安全性,默认不开启
htmlDecode : "style,script,iframe|on*", // 开启 HTML 标签解析,为了安全性,默认不开启
emoji : true,
taskList : true,
tocm : true, // Using [TOCM]

2
lib/codemirror/addons.min.js

File diff suppressed because one or more lines are too long

10779
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.4.4",
"version": "1.4.5",
"description": "Open source online markdown editor.",
"directories": {
"doc": "docs",

28
plugins/image-dialog/image-dialog.js

@ -3,8 +3,8 @@
*
* @file image-dialog.js
* @author pandao
* @version 1.3.2
* @updateTime 2015-05-09
* @version 1.3.3
* @updateTime 2015-06-02
* {@link https://github.com/pandao/editor.md}
* @license MIT
*/
@ -134,13 +134,17 @@
if (fileName === "")
{
alert(imageLang.uploadFileEmpty);
return false;
}
else if (!isImage.test(fileName))
if (!isImage.test(fileName))
{
alert(imageLang.formatNotAllowed + settings.imageFormats.join(", "));
return false;
}
else
{
loading(true);
var submitHandler = function() {
@ -148,14 +152,12 @@
var uploadIframe = document.getElementById(iframeName);
uploadIframe.onload = function() {
loading(false);
var json = "";
if (uploadIframe.contentWindow) {
json = uploadIframe.contentWindow.document.body ? uploadIframe.contentWindow.document.body.innerHTML : null;
} else if (uploadIframe.contentDocument) {
json = uploadIframe.contentDocument.document.body ? uploadIframe.contentDocument.document.body.innerHTML : null;
}
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 (json.success === 1)
@ -172,10 +174,6 @@
};
dialog.find("[type=\"submit\"]").bind("click", submitHandler).trigger("click");
}
return false;
});
}

24
src/editormd.js

@ -47,7 +47,7 @@
};
editormd.title = editormd.$name = "Editor.md";
editormd.version = "1.4.4";
editormd.version = "1.4.5";
editormd.homePage = "https://pandao.github.io/editor.md/";
editormd.classPrefix = "editormd-";
@ -79,6 +79,7 @@
editormd.defaults = {
mode : "gfm", //gfm or markdown
theme : "default",
name : "",
value : "", // value for CodeMirror, if mode not gfm/markdown
markdown : "",
appendMarkdown : "", // if in init textarea value not empty, append markdown to textarea
@ -392,7 +393,12 @@
markdownTextarea = this.markdownTextarea = editor.children("textarea");
}
markdownTextarea.addClass(classNames.textarea.markdown).attr("name", id + "-markdown-doc").attr("placeholder", settings.placeholder);
markdownTextarea.addClass(classNames.textarea.markdown).attr("placeholder", settings.placeholder);
if (typeof markdownTextarea.attr("name") === "undefined" || markdownTextarea.attr("name") === "")
{
markdownTextarea.attr("name", (settings.name !== "") ? settings.name : id + "-markdown-doc");
}
var appendElements = [
(!settings.readOnly) ? "<a href=\"javascript:;\" class=\"fa fa-close " + classPrefix + "preview-close-btn\"></a>" : "",
@ -800,7 +806,7 @@
* @returns {editormd} this(editormd instance object.)
*/
extends : function() {
extend : function() {
if (typeof arguments[1] !== "undefined")
{
if (typeof arguments[1] === "function")
@ -1879,13 +1885,15 @@
var newMarkdownDoc = editormd.$marked(cmValue, markedOptions);
this.markdownTextarea.val(cmValue);
//console.log("cmValue", cmValue, this.markdownTextarea, this.htmlTextarea);
this.markdownTextarea.text(cmValue);
cm.save();
if (settings.saveHTMLToTextarea)
{
this.htmlTextarea.val(newMarkdownDoc);
this.htmlTextarea.text(newMarkdownDoc);
}
if(settings.watch || (!settings.watch && state.preview))
@ -2170,7 +2178,7 @@
return false;
}
return this.htmlTextarea.html();
return this.htmlTextarea.val();
},
/**
@ -3134,7 +3142,7 @@
atLink : /@(\w+)/g,
email : /(\w+)@(\w+)\.(\w+)\.?(\w+)?/g,
emailLink : /(mailto:)?([\w\.\_]+)@(\w+)\.(\w+)\.?(\w+)?/g,
emoji : /:([\+-\w]+):/g,
emoji : /:([\w\+-]+):/g,
emojiDatetime : /(\d{2}:\d{2}:\d{2})/g,
twemoji : /:(tw-([\w]+)-?(\w+)?):/g,
fontAwesome : /:(fa-([\w]+)(-(\w+)){0,}):/g,
@ -3766,7 +3774,7 @@
var katexHandle = function() {
div.find("." + editormd.classNames.tex).each(function(){
var tex = $(this);
katex.render(tex.html(), tex[0]);
katex.render(tex.html().replace(/&lt;/g, "<").replace(/&gt;/g, ">"), tex[0]);
});
};

Loading…
Cancel
Save