Browse Source

Releases v1.1.0

v1.1.9
Pandao 10 years ago
parent
commit
a13b7e72ac
  1. 13
      BUGS.md
  2. 100
      CHANGE.md
  3. 2
      Gulpfile.js
  4. 20
      README.md
  5. 2
      bower.json
  6. 423
      dist/css/editormd.css
  7. 8
      dist/css/editormd.css.map
  8. 4
      dist/css/editormd.css.min.map
  9. 6
      dist/css/editormd.min.css
  10. 28
      dist/css/editormd.preview.css
  11. 8
      dist/css/editormd.preview.css.map
  12. 4
      dist/css/editormd.preview.css.min.map
  13. 4
      dist/css/editormd.preview.min.css
  14. BIN
      dist/fonts/editormd-logo.eot
  15. 11
      dist/fonts/editormd-logo.svg
  16. BIN
      dist/fonts/editormd-logo.ttf
  17. BIN
      dist/fonts/editormd-logo.woff
  18. BIN
      dist/images/logos/editormd-logo-114x114.png
  19. BIN
      dist/images/logos/editormd-logo-120x120.png
  20. BIN
      dist/images/logos/editormd-logo-144x144.png
  21. BIN
      dist/images/logos/editormd-logo-16x16.png
  22. BIN
      dist/images/logos/editormd-logo-180x180.png
  23. BIN
      dist/images/logos/editormd-logo-240x240.png
  24. BIN
      dist/images/logos/editormd-logo-24x24.png
  25. BIN
      dist/images/logos/editormd-logo-320x320.png
  26. BIN
      dist/images/logos/editormd-logo-32x32.png
  27. BIN
      dist/images/logos/editormd-logo-48x48.png
  28. BIN
      dist/images/logos/editormd-logo-57x57.png
  29. BIN
      dist/images/logos/editormd-logo-64x64.png
  30. BIN
      dist/images/logos/editormd-logo-72x72.png
  31. BIN
      dist/images/logos/editormd-logo-96x96.png
  32. BIN
      dist/images/logos/vi.png
  33. 1900
      dist/js/editormd.js
  34. 5
      dist/js/editormd.min.js
  35. 121
      dist/js/languages/en.js
  36. 2
      dist/js/languages/en.min.js
  37. 121
      dist/js/languages/zh-tw.js
  38. 2
      dist/js/languages/zh-tw.min.js
  39. 2
      examples/127.0.0.1-8888.url
  40. 15
      examples/css/style.css
  41. 140
      examples/custom-toolbar.html
  42. 46
      examples/dynamic-create-editormd.html
  43. 19
      examples/flowchart.html
  44. 85
      examples/form-get-value.html
  45. 159
      examples/full.html
  46. 24
      examples/html-preview-markdown-to-html.html
  47. 57
      examples/html-tags-decode.html
  48. 94
      examples/image-cross-domain-upload.html
  49. 45
      examples/image-upload.html
  50. BIN
      examples/images/1.jpg
  51. BIN
      examples/images/10.jpg
  52. BIN
      examples/images/2.jpg
  53. BIN
      examples/images/3.jpg
  54. BIN
      examples/images/4.jpg
  55. BIN
      examples/images/5.jpg
  56. BIN
      examples/images/6.jpg
  57. BIN
      examples/images/7.jpg
  58. BIN
      examples/images/8.jpg
  59. BIN
      examples/images/9.jpg
  60. 121
      examples/index.html
  61. 74
      examples/js/seajs-main.js
  62. 2
      examples/js/zepto.min.js
  63. 48
      examples/katex.html
  64. 54
      examples/multi-editormd.html
  65. 89
      examples/multi-languages.html
  66. 6
      examples/onchange.html
  67. 6
      examples/onfullscreen.html
  68. 6
      examples/onload.html
  69. 54
      examples/php/cross-domain-upload.php
  70. 327
      examples/php/editormd.uploader.class.php
  71. 13
      examples/php/post.php
  72. 46
      examples/php/upload.php
  73. 39
      examples/php/upload_callback.php
  74. 54
      examples/readonly.html
  75. 22
      examples/sequence-diagram.html
  76. 107
      examples/set-get-replace-selection.html
  77. 99
      examples/simple.html
  78. 118
      examples/test.md
  79. 9
      examples/toc.html
  80. 24
      examples/use-requirejs.html
  81. 24
      examples/use-seajs.html
  82. 96
      examples/use-zepto.html
  83. 4
      package.json
  84. 1914
      src/js/editormd.js
  85. 110
      src/js/languages/en.js
  86. 110
      src/js/languages/zh-tw.js
  87. 10
      src/scss/editormd.codemirror.scss
  88. 144
      src/scss/editormd.dialog.scss
  89. 97
      src/scss/editormd.form.scss
  90. 23
      src/scss/editormd.menu.scss
  91. 81
      src/scss/editormd.preview.scss
  92. 159
      src/scss/editormd.scss
  93. 12
      src/scss/lib/functions.scss
  94. 9
      src/scss/lib/variables.scss

13
BUGS.md

@ -4,14 +4,19 @@
####IE8
- ~~不能加载~~
- flowChart(流程图)、sequenceDiagram(序列图)不支持IE8
- ~~不能加载;~~
- flowChart(流程图)、sequenceDiagram(序列图)不支持IE8;
- ~~不支持Markdown转HTML页面解析预览;~~
####IE8 & IE9 & IE10
- KaTeX会出现解析错误,但不影响程序运行;
####Sea.js
- Raphael.js无法加载
- ~~Raphael.js无法加载;~~
####Require.js
- CodeMirror编辑器的代码无法高亮
- CodeMirror编辑器的代码无法高亮

100
CHANGE.md

@ -2,7 +2,7 @@
#####v1.0.0 beta
基本功能完成;
预览版:基本功能完成;
#####v1.0.0 releases
@ -11,6 +11,7 @@
主要更新:
- 新建分支 `mathjax-version`,但不打算继续对此分支进行开发;
- 移除MathJax,改用KaTeX[#2](https://github.com/pandao/editor.md/issues/2),解析和预览响应速度大幅度提高[#3](https://github.com/pandao/editor.md/issues/3);
- 移除 `mathjax` 配置项;
- 移除 `mathjaxURL` 属性;
@ -21,10 +22,105 @@
- 新增 `katexURL` 属性;
- 新增 `loadKaTeX` 方法;
- 新增KaTeX的示例;
- `setCodeEditor()`方法更名为`setCodeMirror()`;
- 合并CodeMirror使用到的多个JS模块文件,大幅减少HTTP请求,加快下载速度;
- 新增合并后的两个模块文件:`./lib/codemirror/modes.min.js`、`./lib/codemirror/addons.min.js`;
- `Gulpfile.js` 新增合并CodeMirror模块文件的任务方法`codemirror-mode`和`codemirror-addon`;
- 另外在使用Require.js时,因为CodeMirror的严格模块依赖的限制,不能使用上述合并的模块文件,仍然采用动态加载多个模块文件;
- 更新 `README.md` 等相关文档和示例;
- 解决Sea.js环境下Raphael.js无法运行导致不支持流程图和时序图的问题,即必须先加载Raphael.js,后加载Sea.js;
- 解决Sea.js环境下Raphael.js无法运行导致不支持流程图和时序图的问题,即必须先加载Raphael.js,后加载Sea.js;
#####v1.1.0
主要更新:
- 设计并更换了Logo;
- 新增添加图片、链接、锚点链接、代码块、预格式文本等操作弹出对话框层及示例;
- 新增支持图片(跨域)上传;
- 改用`<textarea>`来存放Markdown源文档;
- 新增支持自定义工具栏;
- 新增支持多语言;
- 新增支持多个Editor.md并存和动态加载Editor.md及示例;
- 新增支持智能识别和解析HTML标签及示例;
- 新增多个外部操作方法接口及示例;
- 修复了一些大大小小的Bug;
具体更新如下:
- 更换Logo,建立基础VI;
- 创建了全系列WebFont字体`dist/fonts/editormd-logo.*`;
- 新增样式类`editormd-logo`等;
- 改用`<textarea>`来存放Markdown源文档;
- 原先使用`<script type="text/markdown"></script>`来存放Markdown源文档;
- 创建Editor.md只需要写一个`<div id="xxxx"></div>`,如果没有添加`class="editormd"`属性会自动添加,另外如果不存在`<textarea>`标签,则也会自动添加`<textarea>`;
- 新增支持智能识别和解析HTML标签,增强了Markdown语法的扩展性,几乎无限,例如:插入视频等等;
- 新增配置项`htmlDecode`,表示是否开启HTML标签识别和解析,但是为了安全性,默认不开启;
- 新增识别和解析HTML标签的示例;
- 新增插入链接、锚点链接、预格式文本和代码块的弹出对话框层;
- 弹出层改为使用固定定位;
- 新增动态创建对话框的方法 `createDialog()`
- 新增静态属性`editormd.codeLanguages`,用于存放代码语言列表;
- 开始支持图片上传;
- 新增添加图片(上传)弹出对话框层;
- 支持基于iframe的跨域上传,并添加相应的示例(PHP版);
- 开始支持自定义工具栏图标及操作处理;
- 配置项`toolbarIcons`类型由数组更改为函数,返回一个图标按钮列表数组;
- 新增配置项`toolbarHandlers` 和 `toolbarIconsTexts`,分别用于自定义按钮操作处理和按钮内容文本;
- 新增方法`getToolbarHandles()`,用于可在外部使用默认的操作方法;
- 新增成员属性`activeIcon`,可获取当前或上次点击的工具栏图标的jQuery实例对象;
- 新增表单取值、自定义工具栏、图片上传、多个Editor.md并存和动态加载Editor.md等多个示例;
- 新增插入锚点按钮和操作处理;
- 新增预览HTML内容窗口的关闭按钮,之前只能按ESC才能退出HTML全窗口预览;
- 新增多语言(l18n)及动态加载语言包支持;
- 新增英语`en`和繁体中文`zh-tw`语言包模块;
- 修改一些方法的内部实现以支持动态语言加载:
- `toolbarHandler()`更为`setToolbarHandler()`;
- `setToolbar()`方法包含`setToolbarHandler()`;
- 新建`createInfoDialog()`方法;
- 修改`showInfoDialog()`和`hideInfoDialog()`方法的内部实现等;
- 修改多次Bug,并优化触摸事件,改进对iPad的支持;
- 工具栏新增清空按钮和清空方法`clear()`,解决工具栏文本会被选中出现蓝底的问题;
- 配置项`tocStartLevel`的默认值由2改为1,表示默认从H1开始生成ToC;
- 解决IE8下加载出错的问题;
- 新增两个静态成员属性`isIE`和`isIE8`,用于判断IE8;
- 由于IE8不支持FlowChart和SequenceDiagram,默认在IE8下不加载这两个组件,无论是否开启;
- 新增Zepto.js的支持;
- 为了兼容Zepto,某些元素在操作处理上不再使用`outerWidth()`、`outerHeight()`、`hover()`、`is()`等方法;
- 为了避免修改flowChart.js和sequence-diagram.js的源码,所以想支持flowChart或sequenceDiagram得加上这一句:`var jQuery = Zepto;`;
- 新增`editormd.$name`属性,修改`editormd.homePage`属性的新地址;
- `editormd.markdownToHTML()`新增方法返回一个jQuery实例对象;
- 该实例对象定义了一个`getMarkdown()`方法,用于获取Markdown源代码;
- 该实例对象定义了一个`tocContainer`成员属性,即ToC列表的父层的jQuery实例对象;
- 新增只读模式;
- 新增配置项`readOnly`,默认值为`false`,即可编辑模式;
- 其他相关改动;
- 新增方法`focus()`、`setCursor()`、`getCursor()`、`setSelection()`、`getSelection()`、`replaceSelection()`和`insertValue()`方法,并增加对应的示例;
- 新增配置项`saveHTMLToTextarea`,用于将解析后的HTML保存到Textarea,以供提交到后台程序;
- `getHTML()`方法必须在`saveHTMLToTextarea == true`的情况下才能使用;
- 新增`getHTML()`方法的别名`getTextareaSavedHTML()`方法;
- 新增方法`getPreviewedHTML()`,用于获取预览窗口的HTML;
- 修复了一些大大小小的Bugs;

2
Gulpfile.js

@ -67,7 +67,7 @@ gulp.task('scss2', function() {
});
gulp.task('js', function() {
return gulp.src('src/js/editormd.js')
return gulp.src('src/js/**/*.js')
.pipe(jshint('./.jshintrc'))
.pipe(jshint.reporter('default'))
//.pipe(concat('all.js'))

20
README.md

@ -2,16 +2,17 @@
A simple online markdown editor.
**Editor.md** 是一个基于jQuery和CodeMirror构建的在线Markdown文档编辑器。
**Editor.md** 是一个基于jQuery和CodeMirror构建的在线Markdown编辑器。
![editormd-screenshot](https://pandao.github.io/editor.md/examples/images/editormd-screenshot.png "editormd-screenshot")
####主要特性
- 支持Markdown标准和Github风格;
- 支持实时预览和多语言语法高亮;
- 支持[ToC(Table of Contents)](https://pandao.github.io/editor.md/examples/toc.html);
- 支持实时预览、图片上传和多语言语法高亮;
- 兼容主流的浏览器(IE8+),且支持iPad等平板设备;
- 支持[ToC(Table of Contents)](https://pandao.github.io/editor.md/examples/toc.html);
- 支持识别和解析HTML标签,具有几乎无限的扩展性;
- 支持TeX科学公式(基于[KaTeX](https://pandao.github.io/editor.md/examples/katex.html));
- 支持流程图 `flowchart` 和时序图 `sequenceDiagram`;
- 支持AMD/CMD模块化加载(支持 [Require.js](https://pandao.github.io/editor.md/examples/use-requirejs.html) & [Sea.js](https://pandao.github.io/editor.md/examples/use-seajs.html));
@ -30,19 +31,24 @@ A simple online markdown editor.
HTML:
<div class="editormd" id="test-editormd">
<script type="text/markdown">###Hello world!</script>
<link rel="stylesheet" href="../dist/css/editormd.css" />
<div id="test-editormd">
<textarea>###Hello world!</texarea>
</div>
> 提示1:如果没有Markdown源内容或者通过Ajax异步加载Markdown源文档等,可以不添加`<textarea>`,会自动添加;
> 提示2:如果不想出现textarea闪现,则在textarea加上 style="display:none;";
javascript:
<link rel="stylesheet" href="../dist/css/editormd.css" />
<script src="../lib/jquery.min.js"></script>
<script src="../src/js/editormd.js"></script>
<script type="text/javascript">
$(function() {
var testEditor = editormd("test-editormd", {
path : '../lib/'
path : '../lib/' // codemirror、marked等依赖的库的路径
});
});
});

2
bower.json

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

423
dist/css/editormd.css

@ -1,14 +1,15 @@
/*
* Editor.md
* @file editormd.css
* @version v1.0.0
* @version v1.1.0
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-02-10
* @updateTime 2015-02-15
*/
@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)
@ -2362,32 +2363,118 @@
width: 90%;
height: 640px;
margin: 0 auto;
text-align: left;
overflow: hidden;
position: relative;
border: 1px solid #ddd;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
border: 1px solid #ddd;
text-align: left;
overflow: hidden;
background: #fff url("../images/loading.gif") no-repeat center center;
-webkit-background-size: 32px 32px;
background-size: 32px 32px;
font-family: "Microsoft YaHei", "微软雅黑", Helvetica, Tahoma, STXihei, "华文细黑", STHeiti, "Helvetica Neue", Helvetica, Tahoma, "Droid Sans", "wenquanyi micro hei", FreeSans, Arimo, Arial, SimSun, "宋体", Heiti, "黑体", sans-serif;
}
.editormd a {
text-decoration: none;
}
.editormd img {
border: none;
vertical-align: middle;
}
.editormd > textarea,
.editormd .editormd-html-textarea,
.editormd .editormd-markdown-textarea {
width: 0;
height: 0;
outline: 0;
resize: none;
}
.editormd input[type="text"],
.editormd input[type="button"],
.editormd input[type="submit"],
.editormd select, .editormd textarea, .editormd button {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2) {
.editormd {
background-image: url(../images/loading@2x.gif);
}
@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: normal;
font-style: normal;
}
@media only screen and (-webkit-min-device-pixel-ratio: 3), only screen and (min-device-pixel-ratio: 3) {
.editormd {
background-image: url(../images/loading@3x.gif);
}
.editormd-logo {
font-family: 'editormd-logo';
speak: none;
font-style: normal;
font-weight: normal;
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";
/*
HTML Entity &#xe1987;
example: <span class="editormd-logo">&#xe1987;</span>
*/
}
.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;
}
.editormd-user-unselect {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
.editormd-toolbar {
width: 100%;
min-height: 35px;
@ -2403,6 +2490,11 @@
.editormd-toolbar-container {
padding: 0 8px;
min-height: 35px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
.editormd-menu {
@ -2424,9 +2516,10 @@
border-right: 1px solid #ddd;
}
.editormd-menu > li > a {
outline: 0;
color: #666;
display: inline-block;
width: 24px;
min-width: 24px;
font-size: 14px;
text-decoration: none;
text-align: center;
@ -2521,21 +2614,11 @@
-ms-box-sizing: border-box;
box-sizing: border-box;
}
.editormd-container textarea {
display: none;
}
.editormd-html-textarea, .editormd-markdown-textarea {
display: none;
}
.editormd-dialog {
position: absolute;
top: 38%;
left: 33%;
z-index: 101;
width: 34%;
height: 24%;
color: #666;
position: fixed;
z-index: 99999;
display: none;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
@ -2548,17 +2631,13 @@
-o-box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
background: #fff;
}
.editormd-dialog-info {
width: 420px;
height: 160px;
font-size: 14px;
}
.editormd-dialog-container {
padding: 20px 25px 25px;
position: relative;
padding: 20px;
line-height: 1.6;
border: 1px solid #ddd\0;
}
.editormd-dialog-container h1 {
font-size: 24px;
@ -2574,18 +2653,220 @@
font-size: 12px;
color: #999;
}
.editormd-dialog-container select {
color: #999;
padding: 3px 8px;
border: 1px solid #ddd;
}
.editormd-dialog-close {
position: absolute;
top: 10px;
right: 10px;
top: 12px;
right: 15px;
font-size: 18px;
color: #ccc;
-webkit-transition: color 300ms ease-out;
transition: color 300ms ease-out;
}
.editormd-dialog-close:hover {
color: #999;
-webkit-transition: all 300ms ease-out;
transition: all 300ms ease-out;
}
.editormd-dialog-header {
padding: 11px 20px;
border-bottom: 1px solid #eee;
-webkit-transition: background 300ms ease-out;
transition: background 300ms ease-out;
}
.editormd-dialog-header:hover {
background: #f6f6f6;
}
.editormd-dialog-title {
font-size: 14px;
}
.editormd-dialog-footer {
padding: 10px 0 0 0;
text-align: right;
}
.editormd-dialog-info {
width: 420px;
}
.editormd-dialog-info h1 {
font-weight: normal;
}
.editormd-dialog-info .editormd-dialog-container {
padding: 20px 25px 25px;
}
.editormd-dialog-info .editormd-dialog-close {
top: 10px;
right: 10px;
}
.editormd-mask,
.editormd-container-mask,
.editormd-dialog-mask {
display: none;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.editormd-mask,
.editormd-container-mask,
.editormd-dialog-mask-bg {
background: #fff;
opacity: 0.5;
filter: alpha(opacity=50);
}
.editormd-mask {
position: fixed;
background: #000;
opacity: 0.2;
filter: alpha(opacity=20);
z-index: 99998;
}
.editormd-container-mask {
opacity: 0.1;
filter: alpha(opacity=10);
}
.editormd-container-mask,
.editormd-dialog-mask-con {
background: url(../images/loading.gif) no-repeat center center;
-webkit-background-size: 32px 32px;
background-size: 32px 32px;
}
@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2) {
.editormd-container-mask,
.editormd-dialog-mask-con {
background-image: url(../images/loading@2x.gif);
}
}
@media only screen and (-webkit-min-device-pixel-ratio: 3), only screen and (min-device-pixel-ratio: 3) {
.editormd-container-mask,
.editormd-dialog-mask-con {
background-image: url(../images/loading@3x.gif);
}
}
.editormd-dialog-code-block textarea,
.editormd-dialog-tab-code-block textarea {
width: 100%;
height: 400px;
margin-bottom: 6px;
overflow: auto;
border: 1px solid #eee;
background: #fff;
padding: 15px;
resize: none;
}
.editormd-code-toolbar {
color: #999;
font-size: 14px;
margin: -5px 0 12px;
}
.editormd-form {
color: #666;
}
.editormd-form label {
float: left;
display: block;
width: 75px;
text-align: left;
padding: 5px 0 15px 5px;
}
.editormd-form br {
clear: both;
}
.editormd-form iframe {
display: none;
}
.editormd-form input:focus {
outline: 0;
}
.editormd-form input[type="text"] {
color: #999;
padding: 7px 8px;
border: 1px solid #ddd;
}
.editormd-form input[type="text"] {
display: inline-block;
width: 242px;
}
.editormd-form input[type="submit"], .editormd-form .editormd-btn, .editormd-form button,
.editormd-dialog-container input[type="submit"],
.editormd-dialog-container .editormd-btn,
.editormd-dialog-container button,
.editormd-dialog-footer input[type="submit"],
.editormd-dialog-footer .editormd-btn,
.editormd-dialog-footer button {
color: #666;
min-width: 75px;
cursor: pointer;
background: #fff;
padding: 7px 10px;
border: 1px solid #ddd;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
-ms-border-radius: 3px;
-o-border-radius: 3px;
border-radius: 3px;
-webkit-transition: background 300ms ease-out;
transition: background 300ms ease-out;
}
.editormd-form input[type="submit"]:hover, .editormd-form .editormd-btn:hover, .editormd-form button:hover,
.editormd-dialog-container input[type="submit"]:hover,
.editormd-dialog-container .editormd-btn:hover,
.editormd-dialog-container button:hover,
.editormd-dialog-footer input[type="submit"]:hover,
.editormd-dialog-footer .editormd-btn:hover,
.editormd-dialog-footer button:hover {
background: #eee;
}
.editormd-form .editormd-btn,
.editormd-dialog-container .editormd-btn,
.editormd-dialog-footer .editormd-btn {
padding: 5px 8px 4px\0;
}
.editormd-form .editormd-btn + .editormd-btn,
.editormd-dialog-container .editormd-btn + .editormd-btn,
.editormd-dialog-footer .editormd-btn + .editormd-btn {
margin-left: 8px;
}
.editormd-file-input {
width: 75px;
height: 32px;
margin-left: 8px;
position: relative;
display: inline-block;
}
.editormd-file-input input[type="file"] {
width: 75px;
height: 32px;
opacity: 0;
cursor: pointer;
background: #000;
display: inline-block;
position: absolute;
top: 0;
right: 0;
}
.editormd-file-input input[type="file"]::-webkit-file-upload-button {
visibility: hidden;
}
.editormd-file-input:hover input[type="submit"] {
background: #eee;
}
.editormd .CodeMirror, .editormd-preview {
@ -2638,9 +2919,6 @@
background-position: bottom;
background-repeat: repeat-x;
}
.editormd .CodeMirror-empty {
outline: 1px solid #c22;
}
.editormd .CodeMirror-empty.CodeMirror-focused {
outline: none;
}
@ -3321,29 +3599,32 @@
}
.editormd-preview-container, .editormd-html-preview {
text-align: left;
font-size: 14px;
line-height: 1.6;
padding: 20px;
}
.editormd-preview-container blockquote, .editormd-html-preview blockquote {
color: #666;
border-left: 4px solid #ddd;
padding-left: 20px;
margin-left: 0;
color: #666;
font-size: 14px;
font-style: italic;
}
.editormd-preview-container p > code, .editormd-html-preview p > code {
margin-left: 5px;
}
.editormd-preview-container .markdown-body, .editormd-html-preview .markdown-body {
line-height: 1.6;
.editormd-preview-container abbr, .editormd-html-preview abbr {
background: #ffffdd;
}
.editormd-preview-container .markdown-body hr, .editormd-html-preview .markdown-body hr {
.editormd-preview-container hr, .editormd-html-preview hr {
height: 1px;
border: none;
border-top: 1px solid #ddd;
background: none;
}
.editormd-preview-container .markdown-body code, .editormd-html-preview .markdown-body code {
.editormd-preview-container code, .editormd-html-preview code {
border: 1px solid #ddd;
background: #f6f6f6;
padding: 3px;
@ -3351,7 +3632,7 @@
font-size: 13px;
font-family: Consolas, 'Monaco', courier, monospace;
}
.editormd-preview-container .markdown-body pre, .editormd-html-preview .markdown-body pre {
.editormd-preview-container pre, .editormd-html-preview pre {
border: 1px solid #ddd;
background: #f6f6f6;
padding: 10px;
@ -3361,9 +3642,12 @@
-o-border-radius: 3px;
border-radius: 3px;
}
.editormd-preview-container .markdown-body pre code, .editormd-html-preview .markdown-body pre code {
.editormd-preview-container pre code, .editormd-html-preview pre code {
padding: 0;
}
.editormd-preview-container table thead tr, .editormd-html-preview table thead tr {
background-color: #F8F8F8;
}
.editormd-preview-container p.editormd-tex, .editormd-html-preview p.editormd-tex {
text-align: center;
}
@ -3534,4 +3818,41 @@ li.L9 {
list-style-type: decimal;
}
.editormd-html-preview textarea {
display: none;
}
.editormd-preview-close-btn {
color: #fff;
padding: 4px 6px;
font-size: 18px;
-webkit-border-radius: 500px;
-moz-border-radius: 500px;
-ms-border-radius: 500px;
-o-border-radius: 500px;
border-radius: 500px;
display: none;
background-color: #ccc;
position: absolute;
top: 20px;
right: 20px;
z-index: 19;
-webkit-transition: background-color 300ms ease-out;
transition: background-color 300ms ease-out;
}
.editormd-preview-close-btn:hover {
background-color: #999;
}
.editormd-onlyread .editormd-toolbar {
display: none;
}
.editormd-onlyread .CodeMirror {
margin-top: 0;
}
.editormd-onlyread .editormd-preview {
top: 0;
}
/*# sourceMappingURL=editormd.css.map */

8
dist/css/editormd.css.map

File diff suppressed because one or more lines are too long

4
dist/css/editormd.css.min.map

File diff suppressed because one or more lines are too long

6
dist/css/editormd.min.css

File diff suppressed because one or more lines are too long

28
dist/css/editormd.preview.css

@ -1,12 +1,12 @@
/*
* Editor.md
* @file editormd.preview.css
* @version v1.0.0
* @version v1.1.0
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-02-10
* @updateTime 2015-02-15
*/
/*! github-markdown-css | The MIT License (MIT) | Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) | https://github.com/sindresorhus/github-markdown-css */
@ -672,29 +672,32 @@
}
.editormd-preview-container, .editormd-html-preview {
text-align: left;
font-size: 14px;
line-height: 1.6;
padding: 20px;
}
.editormd-preview-container blockquote, .editormd-html-preview blockquote {
color: #666;
border-left: 4px solid #ddd;
padding-left: 20px;
margin-left: 0;
color: #666;
font-size: 14px;
font-style: italic;
}
.editormd-preview-container p > code, .editormd-html-preview p > code {
margin-left: 5px;
}
.editormd-preview-container .markdown-body, .editormd-html-preview .markdown-body {
line-height: 1.6;
.editormd-preview-container abbr, .editormd-html-preview abbr {
background: #ffffdd;
}
.editormd-preview-container .markdown-body hr, .editormd-html-preview .markdown-body hr {
.editormd-preview-container hr, .editormd-html-preview hr {
height: 1px;
border: none;
border-top: 1px solid #ddd;
background: none;
}
.editormd-preview-container .markdown-body code, .editormd-html-preview .markdown-body code {
.editormd-preview-container code, .editormd-html-preview code {
border: 1px solid #ddd;
background: #f6f6f6;
padding: 3px;
@ -702,7 +705,7 @@
font-size: 13px;
font-family: Consolas, 'Monaco', courier, monospace;
}
.editormd-preview-container .markdown-body pre, .editormd-html-preview .markdown-body pre {
.editormd-preview-container pre, .editormd-html-preview pre {
border: 1px solid #ddd;
background: #f6f6f6;
padding: 10px;
@ -712,9 +715,12 @@
-o-border-radius: 3px;
border-radius: 3px;
}
.editormd-preview-container .markdown-body pre code, .editormd-html-preview .markdown-body pre code {
.editormd-preview-container pre code, .editormd-html-preview pre code {
padding: 0;
}
.editormd-preview-container table thead tr, .editormd-html-preview table thead tr {
background-color: #F8F8F8;
}
.editormd-preview-container p.editormd-tex, .editormd-html-preview p.editormd-tex {
text-align: center;
}
@ -885,4 +891,8 @@ li.L9 {
list-style-type: decimal;
}
.editormd-html-preview textarea {
display: none;
}
/*# sourceMappingURL=editormd.preview.css.map */

8
dist/css/editormd.preview.css.map

File diff suppressed because one or more lines are too long

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

File diff suppressed because one or more lines are too long

4
dist/css/editormd.preview.min.css

File diff suppressed because one or more lines are too long

BIN
dist/fonts/editormd-logo.eot

Binary file not shown.

11
dist/fonts/editormd-logo.svg

@ -0,0 +1,11 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>Generated by IcoMoon</metadata>
<defs>
<font id="icomoon" horiz-adv-x="1024">
<font-face units-per-em="1024" ascent="960" descent="-64" />
<missing-glyph horiz-adv-x="1024" />
<glyph unicode="&#x20;" d="" horiz-adv-x="512" />
<glyph unicode="&#xe1987;" d="M726.954 68.236l-91.855-56.319-21.517 106.748 113.371-50.43zM876.293 709.493l12.502 28.106c6.469 14.545 23.659 21.147 38.201 14.681l60.652-26.984c14.546-6.468 21.149-23.661 14.68-38.201l-12.502-28.106-113.536 50.505zM720.236 424.478l116.041 260.86-7.209 69.019h-130.248l-233.736-522.358-245.476 522.358h-133.528l-71.266-742.442h82.462l47.785 562.498 264.047-562.498h43.141l252.85 562.498 15.14-149.939zM761.891 11.915l-6.068 60.094 117.030 263.097 33.757-323.192-144.719 0.001zM621.638 137.007l113.54-50.503 246.486 554.111-113.536 50.506-246.489-554.114z" horiz-adv-x="1017" />
</font></defs></svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
dist/fonts/editormd-logo.ttf

Binary file not shown.

BIN
dist/fonts/editormd-logo.woff

Binary file not shown.

BIN
dist/images/logos/editormd-logo-114x114.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
dist/images/logos/editormd-logo-120x120.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

BIN
dist/images/logos/editormd-logo-144x144.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

BIN
dist/images/logos/editormd-logo-16x16.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
dist/images/logos/editormd-logo-180x180.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

BIN
dist/images/logos/editormd-logo-240x240.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
dist/images/logos/editormd-logo-24x24.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
dist/images/logos/editormd-logo-320x320.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
dist/images/logos/editormd-logo-32x32.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
dist/images/logos/editormd-logo-48x48.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
dist/images/logos/editormd-logo-57x57.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
dist/images/logos/editormd-logo-64x64.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
dist/images/logos/editormd-logo-72x72.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
dist/images/logos/editormd-logo-96x96.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
dist/images/logos/vi.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

1900
dist/js/editormd.js

File diff suppressed because it is too large

5
dist/js/editormd.min.js

File diff suppressed because one or more lines are too long

121
dist/js/languages/en.js

@ -0,0 +1,121 @@
/*
* Editor.md
* @file languagesen.js
* @version v1.1.0
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-02-15
*/
(function(){
var factory = function (exports) {
var lang = {
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 " + exports.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."
}
}
};
exports.defaults.lang = lang;
};
// 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);
}
})();

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

@ -0,0 +1,2 @@
/*! Editor.md v1.1.0 | languagesen.min.js | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-02-15 */
!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)}();

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

@ -0,0 +1,121 @@
/*
* Editor.md
* @file languageszh-tw.js
* @version v1.1.0
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-02-15
*/
(function(){
var factory = function (exports) {
var lang = {
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 : "關於" + exports.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 : "錯誤:請填寫代碼內容。"
}
}
};
exports.defaults.lang = lang;
};
// 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);
}
})();

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

@ -0,0 +1,2 @@
/*! Editor.md v1.1.0 | languageszh-tw.min.js | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-02-15 */
!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
examples/127.0.0.1-8888.url

@ -0,0 +1,2 @@
[InternetShortcut]
URL=http://127.0.0.1:8888/

15
examples/css/style.css

@ -70,4 +70,19 @@ body {
#layout > header > h1 {
font-size: 20px;
margin-bottom: 10px;
}
.btns button, .btn {
padding: 8px 10px;
background: #fff;
border: 1px solid #ddd;
-webkit-border-radius: 3px;
border-radius: 3px;
cursor: pointer;
-webkit-transition: background 300ms ease-out;
transition: background 300ms ease-out;
}
.btns button:hover, .btn:hover {
background: #f6f6f6;
}

140
examples/custom-toolbar.html

@ -0,0 +1,140 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>自定义工具栏 - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.css" />
</head>
<body>
<div id="layout">
<header>
<h1>自定义工具栏</h1>
<p>Custom toolbar (icons handler)</p>
</header>
<div id="test-editormd">
<textarea style="display:none;">###自定义工具栏
```javascript
$(function() {
var testEditor = editormd("test-editormd", {
width: "90%",
height: 640,
path : '../lib/',
toolbarIcons : function() {
return ["undo", "redo", "|", "bold", "hr", "|", "preview", "watch", "|", "fullscreen", "info", "testIcon", "testIcon2"]
},
toolbarIconsClass : {
testIcon : "fa-gears" // 指定一个FontAawsome的图标类
},
toolbarIconTexts : {
testIcon2 : "测试按钮" // 如果没有图标,则可以这样直接插入内容,可以是字符串或HTML标签
},
// 自定义工具栏按钮的事件处理
toolbarHandlers : {
/**
* @param {Object} cm CodeMirror对象
* @param {Object} icon 图标按钮jQuery元素对象
* @param {Object} cursor CodeMirror的光标对象,可获取光标所在行和位置
* @param {String} selection 编辑器选中的文本
*/
testIcon : function(cm, icon, cursor, selection) {
//var cursor = cm.getCursor(); //获取当前光标对象,同cursor参数
//var selection = cm.getSelection(); //获取当前选中的文本,同selection参数
// 替换选中文本,如果没有选中文本,则直接插入
cm.replaceSelection("[" + selection + ":testIcon]");
// 如果当前没有选中的文本,将光标移到要输入的位置
if(selection === "") {
cm.setCursor(cursor.line, cursor.ch + 1);
}
// this == 当前editormd实例
console.log("testIcon =>", this, cm, icon, cursor, selection);
},
testIcon2 : function(cm, icon, cursor, selection) {
cm.replaceSelection("[" + selection + ":testIcon2](" + icon.html() + ")");
console.log("testIcon2 =>", this, icon.html());
}
},
lang : {
toolbar : {
testIcon : "自定义按钮testIcon", // 自定义按钮的提示文本,即title属性
testIcon2 : "自定义按钮testIcon2",
undo : "撤销 (Ctrl+Z)"
}
}
});
});
```
</textarea>
</div>
</div>
<script src="../lib/jquery.min.js"></script>
<script src="../src/js/editormd.js"></script>
<!-- 多语言和自定义工具栏的整合测试 -->
<script src="../src/js/languages/en.js"></script>
<script type="text/javascript">
$(function() {
var testEditor = editormd("test-editormd", {
width: "90%",
height: 640,
path : '../lib/',
toolbarIcons : function() {
return ["undo", "redo", "|", "bold", "hr", "|", "preview", "watch", "|", "fullscreen", "info", "testIcon", "testIcon2"]
},
toolbarIconsClass : {
testIcon : "fa-gears" // 指定一个FontAawsome的图标类
},
toolbarIconTexts : {
testIcon2 : "测试按钮" // 如果没有图标,则可以这样直接插入内容,可以是字符串或HTML标签
},
// 自定义工具栏按钮的事件处理
toolbarHandlers : {
/**
* @param {Object} cm CodeMirror对象
* @param {Object} icon 图标按钮jQuery元素对象
* @param {Object} cursor CodeMirror的光标对象,可获取光标所在行和位置
* @param {String} selection 编辑器选中的文本
*/
testIcon : function(cm, icon, cursor, selection) {
//var cursor = cm.getCursor(); //获取当前光标对象,同cursor参数
//var selection = cm.getSelection(); //获取当前选中的文本,同selection参数
// 替换选中文本,如果没有选中文本,则直接插入
cm.replaceSelection("[" + selection + ":testIcon]");
// 如果当前没有选中的文本,将光标移到要输入的位置
if(selection === "") {
cm.setCursor(cursor.line, cursor.ch + 1);
}
// this == 当前editormd实例
console.log("testIcon =>", this, cm, icon, cursor, selection);
},
testIcon2 : function(cm, icon, cursor, selection) {
cm.replaceSelection("[" + selection + ":testIcon2](" + icon.html() + ")");
console.log("testIcon2 =>", this, icon.html());
}
},
lang : {
toolbar : {
testIcon : "自定义按钮testIcon", // 自定义按钮的提示文本,即title属性
testIcon2 : "自定义按钮testIcon2",
undo : "撤销 (Ctrl+Z)"
}
}
});
});
</script>
</body>
</html>

46
examples/dynamic-create-editormd.html

@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>动态创建Editor.md - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.css" />
</head>
<body>
<div id="layout">
<header>
<h1>动态创建Editor.md</h1>
<p>Dynamic create Editor.md</p>
<br/>
<div class="btns" style="margin:0;">
<button id="create-btn">动态创建一个Editor.md</button>
<button id="remove-btn">移除Editor.md</button>
</div>
</header>
</div>
<script src="../lib/jquery.min.js"></script>
<script type="text/javascript">
var testEditormd;
$(function() {
$("#create-btn").click(function(){
$.getScript("../src/js/editormd.js", function() {
$("#layout").append("<div id=\"test-editormd\"></div>");
testEditormd = editormd("test-editormd", {
width: "90%",
height: 240,
markdown : "###动态创建Editor.md\n\nDynamic create Editor.md",
path : '../lib/'
});
});
});
$("#remove-btn").click(function() {
testEditormd.editor.remove();
});
});
</script>
</body>
</html>

19
examples/flowchart.html

@ -4,6 +4,7 @@
<meta charset="utf-8" />
<title>FlowChart - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.css" />
</head>
<body>
<div id="layout">
@ -11,8 +12,17 @@
<h1>FlowChart 流程图</h1>
<p>基于flowchart.js:<a href="http://adrai.github.io/flowchart.js/" target="_blank">http://adrai.github.io/flowchart.js/</a></p>
</header>
<div class="editormd" id="test-editormd">
<script type="text/markdown">
<div id="test-editormd">
<textarea style="display:none;">####开启FlowChart 流程图支持
配置项:
{
flowChart : true
}
####示例
```flow
st=>start: 用户登陆
op=>operation: 登陆操作
@ -22,12 +32,11 @@ e=>end: 进入后台
st->op->cond
cond(yes)->e
cond(no)->op
```</script>
```</textarea>
</div>
</div>
<script src="../lib/jquery.min.js"></script>
<link rel="stylesheet" href="../dist/css/editormd.css" />
<script src="../src/js/editormd.js"></script>
<script type="text/javascript">
$(function() {
@ -35,7 +44,7 @@ cond(no)->op
width: "90%",
height: 640,
path : '../lib/',
flowChart : true,
flowChart : true
});
});
</script>

85
examples/form-get-value.html

@ -0,0 +1,85 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>Form get textarea value - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.css" />
</head>
<body>
<div id="layout">
<header>
<h1>表单取值</h1>
<p>Form get textarea value.</p>
</header>
<form method="post" action="./php/post.php">
<div id="test-editormd">
<textarea style="display:none;">####表单取值
每个Editor.md的ID元素下都包含两个Textarea,一个保存Markdown源码,一个保存HTML源码,可以按需要获取相应的值,如下:
```html
&lt;div class="editormd" id="$id"&gt;
&lt;textarea class="editormd-markdown-textarea" name="$id-markdown-doc"&gt;&lt;/textarea&gt;
&lt;!-- html textarea需要开启配置项 saveHTMLToTextarea == true --&gt;
&lt;textarea class="editormd-html-textarea" name="$id-html-code"&gt;&lt;/textarea&gt;
&lt;/div&gt;
```
####JS取值
```javascript
var testEditor = editormd("test-editormd", {
width : "90%",
height : 640,
saveHTMLToTextarea : true,
path : '../lib/'
});
testEditor.getMarkdown(); // 获取Markdown源码
testEditor.getHTML(); // 获取Textarea保存的HTML源码
testEditor.getPreviewedHTML(); // 获取预览窗口里的HTML,在开启watch且没有开启saveHTMLToTextarea时使用
```
####后台取值
假设编辑器ID为`test-editormd`,以PHP为例:
```php
<?php
header("Content-Type:text/html; charset=utf-8");
if (isset($_POST['submit'])) {
echo "<pre>";
echo htmlspecialchars($_POST["test-editormd-markdown-doc"]);
echo "<br/><br/>";
echo htmlspecialchars($_POST["test-editormd-html-code"]);
echo "</pre>";
}
?>
```</textarea>
</div>
<div style="width:90%;margin: 10px auto;">
<input type="submit" name="submit" value="提交表单 Submit" style="padding: 5px;" />
</div>
</form>
</div>
<script src="../lib/jquery.min.js"></script>
<script src="../src/js/editormd.js"></script>
<script type="text/javascript">
$(function() {
var testEditor = editormd("test-editormd", {
width : "90%",
height : 640,
saveHTMLToTextarea : true,
path : '../lib/'
});
//testEditor.getMarkdown(); // 获取Markdown源码
//testEditor.getHTML(); // 获取Textarea保存的HTML源码
//testEditor.getPreviewedHTML(); // 获取预览窗口里的HTML,在开启watch且没有开启saveHTMLToTextarea时使用
});
</script>
</body>
</html>

159
examples/full.html

@ -0,0 +1,159 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>完整示例 - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.css" />
</head>
<body>
<div id="layout">
<header>
<h1>完整示例</h1>
<p>开启HTML标签识别和解析、TeX(基于KaTeX)、流程图和时序/序列图支持;</p>
</header>
<div class="btns">
<button id="show-btn">显示编辑器</button>
<button id="hide-btn">隐藏编辑器</button>
<button id="get-md-btn">获取Markdown(源码)</button>
<button id="get-html-btn">获取HTML(源码)</button>
<button id="watch-btn">开启实时预览</button>
<button id="unwatch-btn">关闭实时预览</button>
<button id="preview-btn">预览HTML(按ESC取消)</button>
<button id="fullscreen-btn">全屏(按ESC取消)</button>
<button id="show-toolbar-btn">显示工具栏</button>
<button id="close-toolbar-btn">关闭工具栏</button>
</div>
<div id="test-editormd"></div>
</div>
<script src="../lib/jquery.min.js"></script>
<script src="../src/js/editormd.js"></script>
<script type="text/javascript">
var testEditor;
$(function() {
$.get('test.md', function(md){
testEditor = editormd("test-editormd", {
width: "90%",
height: 740,
path : '../lib/',
markdown : md,
//watch : false, // 关闭实时预览
htmlDecode : true, // 开启HTML标签解析,为了安全性,默认不开启
//toolbar : false, //关闭工具栏
//previewCodeHighlight : false, // 关闭预览HTML的代码块高亮,默认开启
tex : true, // 开启科学公式TeX语言支持,默认关闭
flowChart : true, // 开启流程图支持,默认关闭
sequenceDiagram : true, // 开启时序/序列图支持,默认关闭,
//dialogLockScreen : false, // 设置弹出层对话框不锁屏,全局通用,默认为true
//dialogShowMask : false, // 设置弹出层对话框显示透明遮罩层,全局通用,默认为true
//dialogDraggable : false, // 设置弹出层对话框不可拖动,全局通用,默认为true
//dialogMaskOpacity : 0.4, // 设置透明遮罩层的透明度,全局通用,默认值为0.1
//dialogMaskBgColor : "#000", // 设置透明遮罩层的背景颜色,全局通用,默认为#fff
imageUpload : true,
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
imageUploadURL : "./php/upload.php",
onload : function() {
console.log('onload', this);
//this.fullscreen();
//this.unwatch();
//this.watch().fullscreen();
//this.setMarkdown("#PHP");
//this.width("100%");
//this.height(480);
//this.resize("100%", 640);
}
});
});
$("#show-btn").bind('click', function(){
testEditor.show();
});
$("#hide-btn").bind('click', function(){
testEditor.hide();
});
$("#get-md-btn").bind('click', function(){
alert(testEditor.getMarkdown());
});
$("#get-html-btn").bind('click', function() {
alert(testEditor.getHTML());
});
$("#watch-btn").bind('click', function() {
testEditor.watch();
});
$("#unwatch-btn").bind('click', function() {
testEditor.unwatch();
});
$("#preview-btn").bind('click', function() {
testEditor.previewing();
});
$("#fullscreen-btn").bind('click', function() {
testEditor.fullscreen();
});
$("#show-toolbar-btn").bind('click', function() {
testEditor.showToolbar();
});
$("#close-toolbar-btn").bind('click', function() {
testEditor.hideToolbar();
});
});
// IE不支持
editormd.printAreaCount = 0;
editormd.printArea = function($obj) {
var prefix = "editormd-print-area-iframe";
var iframeId = prefix + editormd.printAreaCount;
if (editormd.printAreaCount > 0)
{
document.body.removeChild(document.getElementById(iframeId));
}
editormd.printAreaCount++;
var iframe = document.createElement("iframe");
iframe.id = prefix + editormd.printAreaCount;
iframe.style.cssText = "position:absolute;width:0px;height:0px;top:-999px;left:-999px;";
document.body.appendChild(iframe);
var iframeDocument = iframe.contentWindow.document;
var links = document.getElementsByTagName("link");
for (var i = 0, len = links.length; i < len; i++)
{
var rel = links[i].getAttribute("rel").toLowerCase();
if (rel === "stylesheet")
{
var css = "<link type=\"text/css\" rel=\"stylesheet\" href=\"" + links[i].getAttribute("href") + "\" >";
iframeDocument.write(css);
}
}
iframeDocument.write("<div class=\"" + $obj.className + "\">" + $obj.innerHTML + "</div>");
iframeDocument.close();
var iframeWindow = iframe.contentWindow;
iframeWindow.close();
iframeWindow.focus();
iframeWindow.print();
};
function preview() {
editormd.printArea(testEditor.previewContainer[0]);
}
</script>
</body>
</html>

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

@ -4,6 +4,7 @@
<meta charset="utf-8" />
<title>HTML Preview(markdown to html) - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.preview.css" />
<style>
.editormd-html-preview {
width: 90%;
@ -16,30 +17,43 @@
<header>
<h1>非编辑情况下的HTML预览</h1>
</header>
<div class="editormd-html-preview" id="test-editormd">
<script type="text/markdown">###Hello world!</script>
<div id="test-editormd-view">
<textarea style="display:none;">###Hello world!</textarea>
</div>
</div>
<!-- <script src="js/zepto.min.js"></script>
<script>
var jQuery = Zepto; // 为了避免修改flowChart.js和sequence-diagram.js的源码,所以想支持flowChart/sequenceDiagram就得加上这一句
</script> -->
<script src="../lib/jquery.min.js"></script>
<link rel="stylesheet" href="../dist/css/editormd.preview.css" />
<script src="../lib/marked.min.js"></script>
<script src="../lib/prettify.min.js"></script>
<script src="../lib/raphael.min.js"></script>
<script src="../lib/underscore.min.js"></script>
<script src="../lib/sequence-diagram.min.js"></script>
<script src="../lib/flowchart.min.js"></script>
<script src="../lib/jquery.flowchart.min.js"></script>
<script src="../src/js/editormd.js"></script>
<script src="../src/js/editormd.js"></script>
<script type="text/javascript">
var testEditormdView;
$(function() {
$.get("test.md", function(markdown) {
editormd.markdownToHTML("test-editormd", {
testEditormdView = editormd.markdownToHTML("test-editormd-view", {
markdown : markdown, // 不设置时,从<script type="text/markdown">markdown
htmlDecode : true, // 开启HTML标签解析,为了安全性,默认不开启
tex : true, // 默认不解析
flowChart: true, // 默认不解析
sequenceDiagram : true, // 默认不解析
});
console.log("返回一个jQuery实例 =>", testEditormdView);
// 获取Markdown源码
console.log(testEditormdView.getMarkdown());
});
});
</script>

57
examples/html-tags-decode.html

@ -0,0 +1,57 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>识别和解析HTML标签 - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.css" />
</head>
<body>
<div id="layout">
<header>
<h1>识别和解析HTML标签</h1>
<p>注:虽然此功能能极大地扩展Markdown语法,但也面临着安全上的风险,所以默认是不开启的。</p>
</header>
<div id="test-editormd">
<textarea style="display:none;">####开启识别和解析HTML标签
配置项:
{
htmlDecode : true
}
####示例
#####上标和下标
上标:X&lt;sup&gt;2&lt;/sup&gt;
下标:O&lt;sub&gt;2&lt;/sub&gt;
#####插入Flash
&lt;embed src="http://player.youku.com/player.php/sid/XMzA0MzIwMDgw/v.swf" allowFullScreen="true" quality="high" width="480" height="400" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;
#####插入视频
李健《最好不相见》
&lt;iframe height=498 width=510 src="http://player.youku.com/embed/XMzA0MzIwMDgw" frameborder=0 allowfullscreen&gt;&lt;/iframe&gt;</textarea>
</div>
</div>
<script src="../lib/jquery.min.js"></script>
<script src="../src/js/editormd.js"></script>
<script type="text/javascript">
$(function() {
var testEditor = editormd("test-editormd", {
width: "90%",
height: 720,
path : '../lib/',
htmlDecode : true
});
});
</script>
</body>
</html>

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

@ -0,0 +1,94 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>图片跨域上传示例 - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.css" />
</head>
<body>
<div id="layout" style="height: 2000px;background: #f6f6f6;">
<header>
<h1>图片跨域上传示例</h1>
<p>Image cross-domain upload example.</p>
</header>
<div id="test-editormd">
<textarea style="display:none;">####跨域上传原理
利用iframe来实现,A站POST到B站,B站处理上传后再跳转回到A站的callback页面,callback页面此时在iframe内(即同域下),再通过window.parent就可以操作父页面的任意元素了。
####跨域上传示例PHP版
当前域名:blog.xxx.com/post.php
```html
&lt;form method="post" target="upload-iframe" enctype="multipart/form-data" action="http://static.xxx.com/uploader.php?callback=http://blog.xxx.com/upload-callback.html"&gt;
&lt;input type="file" name="file" accept="image/*" /&gt;
&lt;input type="submit" id="submit" value="开始上传" /&gt;
&lt;/form&gt;
&lt;iframe name="upload-iframe" style="display:none;" frameborder="0"&gt;&lt;/iframe&gt;
```
图片服务器:static.xxx.com/uploader.php
```php
&lt;?php
$file = 'uploads/' . $_FILES['file']['name'];
// 详细过程略
move_uploaded_file($_FILES['file']['tmp_name'], $file);
$location = $_GET['callback'].'?success=1&message=xxxxxxx&url=http://static.xxx.com/2015/02/15'.$file.'&temp='.date('ymdhis');
header('location:' . $location);
exit;
?&gt;
```
当前域名:blog.xxx.com/upload-callback.html
```html
&lt;script type="text/javascript"&gt;
var query = {};
var urlParams = window.location.search.split('?')[1];
urlParams = urlParams.split("&");
for (var i = 0; i&lt; urlParams.length; i++) {
var param = urlParams[i].split("=");
query[param[0]] = param[1];
}
var imageDialog = window.parent.document.getElementById(query['dialog_id']);
//console.log(imageDialog, window.parent.document, window.parent, query);
&lt;/script&gt;
```</textarea>
</div>
</div>
<script src="../lib/jquery.min.js"></script>
<script src="../src/js/editormd.js"></script>
<script type="text/javascript">
$(function() {
var testEditor = editormd("test-editormd", {
width : "90%",
height : 640,
markdown : "",
path : '../lib/',
imageUpload : true,
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
imageUploadURL : "http://192.168.1.2/editor.md/examples/php/cross-domain-upload.php",
crossDomainUpload : true,
uploadCallbackURL : "http://localhost/editor.md/examples/php/upload_callback.php"
/*
跨域时,上传的图片服务器后台只需要返回一个跳转URL并跳转到原页面同域下的callback页面,结构如下:
{
success : 0 | 1, // 0表示上传失败,1表示上传成功
message : "提示的信息,上传成功或上传失败及错误信息等。",
dialog_id : $_GET['dialog_id'],
url : "远程图片地址" // 上传成功时才返回
}
*/
});
});
</script>
</body>
</html>

45
examples/image-upload.html

@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>图片上传示例 - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.css" />
</head>
<body>
<div id="layout" style="height: 2000px;background: #f6f6f6;">
<header>
<h1>图片上传示例</h1>
</header>
<div id="test-editormd"></div>
</div>
<script src="../lib/jquery.min.js"></script>
<script src="../src/js/editormd.js"></script>
<script type="text/javascript">
$(function() {
var testEditor = editormd("test-editormd", {
width: "90%",
height: 540,
markdown : "",
path : '../lib/',
//dialogLockScreen : false, // 设置弹出层对话框不锁屏,全局通用,默认为true
//dialogShowMask : false, // 设置弹出层对话框显示透明遮罩层,全局通用,默认为true
//dialogDraggable : false, // 设置弹出层对话框不可拖动,全局通用,默认为true
//dialogMaskOpacity : 0.4, // 设置透明遮罩层的透明度,全局通用,默认值为0.1
//dialogMaskBgColor : "#000", // 设置透明遮罩层的背景颜色,全局通用,默认为#fff
imageUpload : true,
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
imageUploadURL : "./php/upload.php",
/*
上传的后台只需要返回一个JSON数据,结构如下:
{
success : 0 | 1, // 0表示上传失败,1表示上传成功
message : "提示的信息,上传成功或上传失败及错误信息等。"
}
*/
});
});
</script>
</body>
</html>

BIN
examples/images/1.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
examples/images/10.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

BIN
examples/images/2.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
examples/images/3.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
examples/images/4.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

BIN
examples/images/5.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

BIN
examples/images/6.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

BIN
examples/images/7.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

BIN
examples/images/8.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
examples/images/9.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

121
examples/index.html

@ -4,55 +4,142 @@
<meta charset="utf-8" />
<title>Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.css" />
<style>
#header {
width: 100%;
color: #fff;
background: #2196F3;
padding: 80px 0;
text-align: center;
margin-bottom: 30px;
}
#header h1 {
font-size: 48px;
font-weight: normal;
}
ul {
width: 90%;
margin: 10px auto;
list-style: default;
line-height: 2;
padding-bottom: 50px;
margin: 0 auto;
list-style: none;
}
ul li {
width: 33%;
margin-bottom: 4px;
display: inline-block;
}
ul li a {
color: #2196F3;
display: block;
padding: 4px 15px;
font-size: 14px;
text-align: left;
text-decoration: none;
-webkit-transition: all 300ms ease-out;
transition: all 300ms ease-out;
}
ul li a span {
color: #999;
display: block;
padding-top: 3px;
font-size: 80%;
}
ul li a:hover {
color: #fff;
background: #2196F3;
border-radius: 8px;
}
ul li a:hover span {
color: #fff;
}
</style>
</head>
<body>
<div id="layout">
<header>
<h1>Editor.md examples</h1>
</header>
<div id="header">
<h1><i class="editormd-logo editormd-logo-4x"></i></h1>
<h1>Editor.md examples</h1>
</div>
<ul>
<li>
<a href="./simple.html">Full example</a>
<a href="./simple.html">简单示例 <span>Simple example</span></a>
</li>
<li>
<a href="./use-requirejs.html">Use Require.js example</a>
<a href="./full.html">完整示例 <span>Full example</span></a>
</li>
<li>
<a href="./use-seajs.html">Use Seajs example</a>
<a href="./use-requirejs.html">使用Require.js <span>Using Require.js example</span></a>
</li>
<li>
<a href="./toc.html">ToC (Table of Contents) example</a>
<a href="./use-seajs.html">使用Sea.js <span>Using Seajs example</span></a>
</li>
<li>
<a href="./katex.html">TeX (based on KaTeX) </a>
<a href="./use-zepto.html">使用Zepto.js <span>Using Zepto.js</span></a>
</li>
<li>
<a href="./onload.html">onload event handle example</a>
<a href="./toc.html">自动生成目录 ToC <span>Table of Contents example</span></a>
</li>
<li>
<a href="./onchange.html">onchange event handle example</a>
<a href="./form-get-value.html">表单取值 <span>Get textarea value in form</span></a>
</li>
<li>
<a href="./onfullscreen.html">onfullscreen / onfullscreenExit event handle example</a>
<a href="./html-tags-decode.html">识别和解析HTML标签 <span>HTML tags decode</span></a>
</li>
<li>
<a href="./flowchart.html">flowChart example</a>
<a href="./html-preview-markdown-to-html.html">Markdown转HTML的显示处理 <span>Markdown to HTML for preview</span></a>
</li>
<li>
<a href="./sequence-diagram.html">Sequence Diagram example</a>
<a href="./image-upload.html">图片上传 <span>Image upload</span></a>
</li>
<li>
<a href="./html-preview-markdown-to-html.html">Markdown to HTML for preview</a>
<a href="./image-cross-domain-upload.html">图片跨域上传 <span>Image cross-domain upload</span></a>
</li>
<li>
<a href="./custom-toolbar.html">自定义工具栏 <span>Custom toolbar</span></a>
</li>
<li>
<a href="./multi-languages.html">多语言支持 <span>Multi-languages for l18n</span></a>
</li>
<li>
<a href="./dynamic-create-editormd.html">动态创建Editor.md <span>Dynamic create Editor.md</span></a>
</li>
<li>
<a href="./multi-editormd.html">多个Editor.md并存 <span>Multi Editor.md</span></a>
</li>
<li>
<a href="./readonly.html">只读模式 <span>Editor.md read only</span></a>
</li>
<li>
<a href="./set-get-replace-selection.html">插入字符/设置和获取光标位置/设置、获取和替换选中的文本 <span>Insert value & Set/Get cursor & Set/Get/Replace selection</span></a>
</li>
<li>
<a href="./onload.html">加载完成事件处理 <span>Onload event handle example</span></a>
</li>
<li>
<a href="./onchange.html">变化监听处理 <span>Onchange event handle example</span></a>
</li>
<li>
<a href="./onfullscreen.html">全屏事件处理 <span>Onfullscreen / onfullscreenExit event handle example</span></a>
</li>
<li>
<a href="./katex.html">科学公式 TeX <span>Based on KaTeX</span> </a>
</li>
<li>
<a href="./flowchart.html">流程图 <span>FlowChart example</span></a>
</li>
<li>
<a href="./sequence-diagram.html">时序/序列图 <span>Sequence Diagram example</span></a>
</li>
</ul>
<div class="clear"></div>
</div>
</body>
</html>

74
examples/js/seajs-main.js

@ -0,0 +1,74 @@
define(function(require){
var $ = require("jquery");
var editormd = require("editormd");
require("../../src/js/languages/en"); // 加载英语语言包
console.log($, editormd);
$.get("./test.md", function(md){
testEditor = editormd("test-editormd", {
width: "90%",
height: 640,
path : '../lib/',
markdown : md,
//toolbar : false, //关闭工具栏
htmlDecode : true, // 开启HTML标签解析,为了安全性,默认不开启
tex : true, // 开启科学公式TeX语言支持,默认关闭
//previewCodeHighlight : false, // 关闭预览窗口的代码高亮,默认开启
flowChart : true, // 疑似Sea.js与Raphael.js有冲突,必须先加载Raphael.js,Editor.md才能在Sea.js下正常进行;
sequenceDiagram : true, // 同上
onload : function() {
console.log('onload', this);
//this.fullscreen();
//this.unwatch();
//this.watch().fullscreen();
//this.setMarkdown("#PHP");
//this.width("100%");
//this.height(480);
//this.resize("100%", 640);
}
});
});
$("#show-btn").bind('click', function(){
testEditor.show();
});
$("#hide-btn").bind('click', function(){
testEditor.hide();
});
$("#get-md-btn").bind('click', function(){
alert(testEditor.getMarkdown());
});
$("#get-html-btn").bind('click', function() {
alert(testEditor.getHTML());
});
$("#watch-btn").bind('click', function() {
testEditor.watch();
});
$("#unwatch-btn").bind('click', function() {
testEditor.unwatch();
});
$("#preview-btn").bind('click', function() {
testEditor.previewing();
});
$("#fullscreen-btn").bind('click', function() {
testEditor.fullscreen();
});
$("#show-toolbar-btn").bind('click', function() {
testEditor.showToolbar();
});
$("#close-toolbar-btn").bind('click', function() {
testEditor.hideToolbar();
});
});

2
examples/js/zepto.min.js

File diff suppressed because one or more lines are too long

48
examples/katex.html

@ -2,44 +2,54 @@
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>Tex科学公式 - Editor.md examples</title>
<title>Tex科学公式语言 - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.css" />
</head>
<body>
<div id="layout">
<header>
<h1>Tex科学公式</h1>
<h1>Tex科学公式语言</h1>
<p>基于KaTeX.js:<a href="http://khan.github.io/KaTeX/" target="_blank">http://khan.github.io/KaTeX/</a></p>
<p>注:默认使用cloudflare的CDN,有时加载速度会比较慢,可自定义加载地址。</p>
<p>注:默认使用CloudFlare的CDN,有时加载速度会比较慢,可自定义加载地址。</p>
</header>
<div class="editormd" id="test-editormd">
<script type="text/markdown">####
<div id="test-editormd">
<textarea style="display:none;">####开启科学公式支持
配置项:
{
tex : true
}
####示例
$$E=mc^2$$
行内的公式$$E=mc^2$$行内的公式,行内的$$E=mc^2$$公式。
$$\(\sqrt{3x-1}+(1+x)^2\)$$
$$\sin(\alpha)^{\theta}=\sum_{i=0}^{n}(x^i + \cos(f))$$</script>
$$\sin(\alpha)^{\theta}=\sum_{i=0}^{n}(x^i + \cos(f))$$
####自定义KaTeX的URL
```javascript
//默认使用CloudFlare的CDN,有时加载速度会比较慢
//或者直接修改源码
editormd.katexURL = {
js : "your url",
css : "your url"
};
```
</textarea>
</div>
</div>
<script src="../lib/jquery.min.js"></script>
<link rel="stylesheet" href="../dist/css/editormd.css" />
<script src="../src/js/editormd.js"></script>
<script type="text/javascript">
$(function() {
/*
默认使用cloudflare的CDN,有时加载速度会比较慢
自定义KaTex的URL或者直接修改源码
editormd.katexURL = {
js : ".....",
css : "......"
};
*/
var testEditor = editormd("test-editormd", {
width: "90%",
height: 640,

54
examples/multi-editormd.html

@ -0,0 +1,54 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>多个Editor.md并存 - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.css" />
<style>
h3 {
width : 90%;
margin: 0 auto 15px;
}
.editormd {
margin: 20px auto;
}
</style>
</head>
<body>
<div id="layout">
<header>
<h1>多个Editor.md并存</h1>
<p>Multi 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>
</div>
<script src="../lib/jquery.min.js"></script>
<script src="../src/js/editormd.js"></script>
<script type="text/javascript">
var testEditormd, testEditormd2;
$(function() {
testEditormd = editormd("test-editormd", {
width: "90%",
height: 480,
markdown : "####Editor.md A",
path : '../lib/'
});
testEditormd2 = editormd("test-editormd2", {
width: "90%",
height: 480,
markdown : "####Editor.md B",
path : '../lib/'
});
});
</script>
</body>
</html>

89
examples/multi-languages.html

@ -0,0 +1,89 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>多语言支持 - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.css" />
</head>
<body>
<div id="layout">
<header>
<h1>多语言支持(l18n)</h1>
<p>multi-languages for l18n.
<select id="lang-select">
<option selected="selected">Languages</option>
<option value="en">English (en)</option>
<option value="zh-tw">繁體中文 (zh-tw)</option>
<option value="zh-cn">简体中文 (zh-cn)</option>
</select>
</p>
</header>
<div id="test-editormd">
<textarea style="display:none;">###多语言支持(l18n)
目前支持三种语言:简体中文、繁體中文、English,默认为简体中文 (zh-cn default)。
```html
&lt;!-- English --&gt;
&lt;script src="../dist/js/languages/en.js"&gt;&lt;/script&gt;
&lt;!-- 繁體中文 --&gt;
&lt;script src="../dist/js/languages/zh-tw.js"&gt;&lt;/script&gt;
&lt;style&gt;
body{background:red;}
&lt;/style&gt;
```
</textarea>
</div>
</div>
<script src="../lib/jquery.min.js"></script>
<script src="../src/js/editormd.js"></script>
<!--<script src="../src/js/languages/en.js"></script>
<script src="../src/js/languages/zh-tw.js"></script> -->
<script type="text/javascript">
$(function() {
var testEditor = editormd("test-editormd", {
width: "90%",
height: 640,
path : '../lib/'
});
//console.log(editormd.defaults.lang);
var lang = "zh-cn";
// 动态加载语言包
// Dynamic load language package
$("#lang-select").change(function() {
var value = $(this).val();
var path = "../src/js/languages/";
if (value == "zh-cn")
{
location.reload();
}
else
{
editormd.loadScript(path + value, function() {
testEditor.lang = editormd.defaults.lang;
// 只重建涉及语言包的部分,如工具栏、弹出对话框等
testEditor.recreateEditor();
// 整个编辑器重建,预览HTML会重新生成,出现闪动
//testEditor = editormd("test-editormd", {
//width: "90%",
//height: 640,
//path : '../lib/'
//});
lang = value;
console.log(lang, value, editormd.defaults.lang);
});
}
});
});
</script>
</body>
</html>

6
examples/onchange.html

@ -4,6 +4,7 @@
<meta charset="utf-8" />
<title>Onchange - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.css" />
</head>
<body>
<div id="layout">
@ -11,12 +12,11 @@
<h1>Onchange event</h1>
<p>Enter F12 open the develop tools</p>
</header>
<div class="editormd" id="test-editormd">
<script type="text/markdown">###Hello world!</script>
<div id="test-editormd">
<textarea style="display:none;">###Hello world!</textarea>
</div>
</div>
<script src="../lib/jquery.min.js"></script>
<link rel="stylesheet" href="../dist/css/editormd.css" />
<script src="../src/js/editormd.js"></script>
<script type="text/javascript">
$(function() {

6
examples/onfullscreen.html

@ -4,6 +4,7 @@
<meta charset="utf-8" />
<title>Onfullscreen & onfullscreenExit - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.css" />
</head>
<body>
<div id="layout">
@ -11,12 +12,11 @@
<h1>Onfullscreen & onfullscreenExit event</h1>
<p>Enter F12 open the develop tools</p>
</header>
<div class="editormd" id="test-editormd">
<script type="text/markdown">###Hello world!</script>
<div id="test-editormd">
<textarea style="display:none;">###Hello world!</textarea>
</div>
</div>
<script src="../lib/jquery.min.js"></script>
<link rel="stylesheet" href="../dist/css/editormd.css" />
<script src="../src/js/editormd.js"></script>
<script type="text/javascript">
$(function() {

6
examples/onload.html

@ -4,6 +4,7 @@
<meta charset="utf-8" />
<title>Onload - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.css" />
</head>
<body>
<div id="layout">
@ -11,12 +12,11 @@
<h1>Onload event</h1>
<p>Enter F12 open the develop tools</p>
</header>
<div class="editormd" id="test-editormd">
<script type="text/markdown">###Hello world!</script>
<div id="test-editormd">
<textarea style="display:none;">###Hello world!</textarea>
</div>
</div>
<script src="../lib/jquery.min.js"></script>
<link rel="stylesheet" href="../dist/css/editormd.css" />
<script src="../src/js/editormd.js"></script>
<script type="text/javascript">
$(function() {

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

@ -0,0 +1,54 @@
<?php
/*
* PHP cross-domain upload demo for Editor.md
*
* @FileName: upload.php
* @Auther: Pandao
* @E-mail: pandao@vip.qq.com
* @CreateTime: 2015-02-15 19:12:11
* @UpdateTime: 2015-02-15 20:47:52
* Copyright@2015 Editor.md all right reserved.
*/
header("Content-Type:text/html; charset=utf-8");
header("Access-Control-Allow-Origin: *");
require("editormd.uploader.class.php");
error_reporting(E_ALL & ~E_NOTICE);
$path = __DIR__ . DIRECTORY_SEPARATOR;
$url = dirname($_SERVER['PHP_SELF']) . '/';
$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
if (isset($_FILES[$name]))
{
$imageUploader = new EditorMdUploader($savePath, $saveURL, $formats['image'], false); // Ymdhis表示按日期生成文件名,利用date()函数
$imageUploader->config(array(
'maxSize' => 1024, // 允许上传的最大文件大小,以KB为单位,默认值为1024
'cover' => true // 是否覆盖同名文件,默认为true
));
$imageUploader->redirect = true;
$imageUploader->redirectURL = $_GET['callback'] . '?dialog_id=' . $_GET['dialog_id'] . '&temp=' . date('ymdhis');
if ($imageUploader->upload($name))
{
$imageUploader->message('上传成功!', 1);
}
}
?>

327
examples/php/editormd.uploader.class.php

@ -0,0 +1,327 @@
<?php
/**
*
* Editor.md PHP简易上传类(仅供演示用,生产环境使用还需谨慎考虑)
*
* @FileName: editormd.uploader.class.php
* @Auther: Pandao
* @E-mail: pandao@vip.qq.com
* @CreateTime: 2015-02-13 23:31:32
* @UpdateTime: 2015-02-15 20:49:52
* Copyright@2015 Editor.md all right reserved.
*/
class EditorMdUploader
{
public $files; // $_FILES数组
public $fileExit; // 文件扩展名
public $saveName; // 最终保存的文件名
public $saveURL; // 最终保存URL地址
public $savePath; // 保存本地文件路径
public $randomLength = ''; // 生成随机文件名的长度,当为日期时为日期的格式
public $randomNameType = 1; // 生成随机的形式, NULL为保留原文件名, 1生成随机字符串, 2生成日期文件名
public $formats = array( // 允许上传的文件格式
'gif', 'jpg', 'jpeg', 'png', 'bmp'
);
public $maxSize = 1024; // 最大上传文件大小,单位KB
public $cover = true; // 是否覆盖同名文件, 1覆盖,0不覆盖
public $redirect = false; // 是否进行URL跳转
public $redirectURL = ""; // 上传成功或出错后要转到的URL
public $errors = array( // 错误信息
'empty' => '上传文件不能为空',
'format' =>'上传的文件格式不符合规定',
'maxsize' => '上传的文件太大',
'unwritable' => '保存目录不可写,请更改权限',
'not_exist' => '保存目录不存在',
'same_file' => '已经有相同的文件存在'
);
/**
* 构造函数,初始化对象
*
* @access public
* @param string $savePath 最终保存的本地路径
* @param string $saveURL 最终保存的URL地址
* @param string $formats 允许上传的文件格式
* @param Number $randomNameType 是否生成随机文件名及形式
* @param Intiger/string $randomLength 生成随机文件名字符的长度
* @param boolean $cover 是否覆盖相同文件
* @param Intiger $maxSize 允许最大的上传文件大小,以KB为单位
* @return viod
*/
public function __construct($savePath, $saveURL, $formats, $randomNameType = 1, $randomLength = '', $cover = true, $maxSize = 1024)
{
$this->savePath = $savePath;
$this->saveURL = $saveURL;
$this->formats = $formats;
$this->maxSize = $maxSize;
$this->cover = $cover;
$this->randomNameType = $randomNameType;
$this->randomLength = $randomLength;
}
/**
* 配置参数函数
*
* @access public
* @param array $configs 配置项数组
* @return void
*/
public function config($configs)
{
foreach($configs as $key => $value)
{
$this->$key = $value;
}
}
/**
* 执行文件上传
*
* @access public
* @param string $name fileInput's name
* @return boolean 返回是否上传成功的布尔值
*/
public function upload($name)
{
if(empty($_FILES[$name]['name'])) //上传文件为空时
{
$this->message($this->errors['empty']);
}
$this->files = $_FILES[$name];
if(!file_exists($this->savePath)) //目录不存在
{
$this->message($this->errors['not_exist']);
}
if(!is_writable($this->savePath)) //目录不可写
{
$this->message($this->errors['unwritable']);
}
$this->fileExt = $this->getFileExt($this->files["name"]); //取得扩展名
$this->setSeveName();
return $this->moveFile();
}
/**
* 检查并移动上传文件
*
* @access private
* @return boolean
*/
private function moveFile()
{
$files = $this->files;
if ($this->formats != "" && !in_array($this->fileExt, $this->formats))
{
$formats = implode(',', $this->formats);
$message = "您上传的文件" . $files["name"] . "是" . $this->fileExt . "格式的,系统不允许上传,您只能上传" . $formats . "格式的文件。";
$this->message($message);
}
if ($files["size"] / 1024 > $this->maxSize)
{
$message = "您上传的 " . $files["name"] . ",文件大小超出了系统限定值" . $this->maxSize . " KB,不能上传。";
$this->message($message);
}
if (!$this->cover) //当不能覆盖时
{
if(file_exists($this->savePath.$this->saveName)) //有相同的文件存在
{
$this->message($this->saveName . $this->errors['same_file']);
}
}
if (!@move_uploaded_file($files["tmp_name"], iconv("utf-8", "gbk", $this->savePath . $this->saveName)))
{
switch($files["errors"])
{
case '0':
$message = "文件上传成功";
break;
case '1':
$message = "上传的文件超过了 php.ini 中 upload_max_filesize 选项限制的值";
break;
case '2':
$message = "上传文件的大小超过了 HTML 表单中 MAX_FILE_SIZE 选项指定的值";
break;
case '3':
$message = "文件只有部分被上传";
break;
case '4':
$message = "没有文件被上传";
break;
case '6':
$message = "找不到临时目录";
break;
case '7':
$message = "写文件到硬盘时出错";
break;
case '8':
$message = "某个扩展停止了文件的上传";
break;
case '999':
default:
$message = "未知错误,请检查文件是否损坏、是否超大等原因。";
break;
}
$this->message($message);
}
@unlink($files["tmp_name"]); //删除临时文件
return true;
}
/**
* 生成随机文件名函数
*
* @access private
* @return string $fileName 返回生成的文件名字符串
*/
private function randomFileName()
{
if ($this->randomNameType == 1) // 生成时间格式文件名
{
date_default_timezone_set('PRC'); //设置时区
$date = date($this->randomLength);
$fileName = $date . "_" . mt_rand(10000, 99999);
}
elseif ($this->randomNameType == 2) // 生成随机字符文件名
{
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
$max = strlen($chars) - 1;
mt_srand((double)microtime() * 1000000);
for($i = 0; $i < $this->randomLength; $i++)
{
$fileName .= $chars[mt_rand(0, $max)];
}
}
else
{
$fileName = '';
}
return $fileName;
}
/**
* 组成最终保存的完整路径及文件名
*
* @access private
* @return void
*/
private function setSeveName()
{
$this->saveName = $this->randomFileName();
if($this->saveName == '') //如果没生成随机文件名,就保留原文件名
{
$this->saveName = $this->files['name'];
}
}
/**
* 取得保存的文件名,用于数据库存储
*
* @access public
* @return string
*/
public function getSeveName()
{
return $this->saveName;
}
/**
* 获取文件后缀名函数
*
* @access public
* @return string
*/
public function getFileExt($fileName)
{
return trim(strtolower(substr(strrchr($fileName, '.'), 1)));
}
/**
* 上传成功或出错后跳转
*
* @access public
* @param array $configs 配置项数组
* @return void
*/
public function redirect()
{
header('location: ' . $this->redirectURL);
}
/**
* 错误提示函数
*
* @access public
* @return void
*/
public function message($message, $success = 0)
{
$array = array(
'success' => $success
);
$url = $this->saveURL . $this->saveName;
// 适用于跨域上传时,跳转到中介页面等
if ($this->redirect)
{
$this->redirectURL .= "&success=" . $success . "&message=" . $message;
if ($success == 1)
{
$this->redirectURL .= '&url=' . $url;
}
$this->redirect();
}
else
{
if ($success == 1)
{
$array['url'] = $url;
}
else
{
$array['message'] = $message;
}
echo json_encode($array);
}
}
}

13
examples/php/post.php

@ -0,0 +1,13 @@
<?php
header("Content-Type:text/html; charset=utf-8");
if (isset($_POST['submit'])) {
echo "<pre>";
echo htmlspecialchars($_POST["test-editormd-markdown-doc"]);
echo "<br/><br/>";
echo htmlspecialchars($_POST["test-editormd-html-code"]);
echo "</pre>";
}
exit;
?>

46
examples/php/upload.php

@ -0,0 +1,46 @@
<?php
/*
* PHP upload demo for Editor.md
*
* @FileName: upload.php
* @Auther: Pandao
* @E-mail: pandao@vip.qq.com
* @CreateTime: 2015-02-13 23:20:04
* @UpdateTime: 2015-02-14 14:52:50
* Copyright@2015 Editor.md all right reserved.
*/
header("Content-Type:text/html; charset=utf-8");
header("Access-Control-Allow-Origin: *");
require("editormd.uploader.class.php");
error_reporting(E_ALL & ~E_NOTICE);
$path = __DIR__ . DIRECTORY_SEPARATOR;
$url = dirname($_SERVER['PHP_SELF']) . '/';
$savePath = realpath($path . '../uploads/') . DIRECTORY_SEPARATOR;
$saveURL = $url . '../uploads/';
$formats = array(
'image' => array('gif', 'jpg', 'jpeg', 'png', 'bmp')
);
$name = 'editormd-image-file';
if (isset($_FILES[$name]))
{
$imageUploader = new EditorMdUploader($savePath, $saveURL, $formats['image'], false); // Ymdhis表示按日期生成文件名,利用date()函数
$imageUploader->config(array(
'maxSize' => 1024, // 允许上传的最大文件大小,以KB为单位,默认值为1024
'cover' => true // 是否覆盖同名文件,默认为true
));
if ($imageUploader->upload($name))
{
$imageUploader->message('上传成功!', 1);
}
}
?>

39
examples/php/upload_callback.php

@ -0,0 +1,39 @@
<?php
header("Content-Type:text/html; charset=utf-8");
?>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
</head>
<body>
<!--
这是同域下的callback页面,本页面在iframe内,所以只要通过window.parent就能操作父窗口的元素
-->
<script type="text/javascript">
var query = {};
var urlParams = window.location.search.split('?')[1];
urlParams = urlParams.split("&");
for (var i = 0; i< urlParams.length; i++)
{
var param = urlParams[i].split("=");
query[param[0]] = param[1];
}
var imageDialog = window.parent.document.getElementById(query['dialog_id']);
//console.log(imageDialog, window.parent.document, window.parent, query);
if (query['success'] === '1')
{
imageDialog.querySelector("[data-url]").value = query['url'];
}
else
{
alert(query['message']);
}
location.href = "about:blank";
</script>
</body>
</html>

54
examples/readonly.html

@ -0,0 +1,54 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>只读模式 - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.css" />
</head>
<body>
<div id="layout">
<header>
<h1>只读模式</h1>
<p>Editor.md read only</p>
</header>
<div id="test-editormd" class="editormd-onlyread">
<textarea style="display:none;">###设置只读模式
```javascript
var testEditor;
$(function() {
testEditor = editormd("test-editormd", {
width: "90%",
height: 540,
path : '../lib/',
//watch : false, // 禁用实时预览
readOnly : true,
styleActiveLine : false, // 禁止高亮显示当前行
//lineNumbers : false // 隐藏行号
});
});
```
</textarea>
</div>
</div>
<script src="../lib/jquery.min.js"></script>
<script src="../src/js/editormd.js"></script>
<script type="text/javascript">
var testEditor;
$(function() {
testEditor = editormd("test-editormd", {
width: "90%",
height: 540,
path : '../lib/',
//watch : false, // 禁用实时预览
readOnly : true,
styleActiveLine : false, // 禁止高亮显示当前行
//lineNumbers : false // 隐藏行号
});
});
</script>
</body>
</html>

22
examples/sequence-diagram.html

@ -2,17 +2,28 @@
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>sequenceDiagram - Editor.md examples</title>
<title>SequenceDiagram - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.min.css" />
</head>
<body>
<div id="layout">
<header>
<h1>sequenceDiagram 时序图/序列图</h1>
<h1>SequenceDiagram 时序图/序列图</h1>
<p>基于SequenceDiagram.js:<a href="http://bramp.github.io/js-sequence-diagrams/" target="_blank">http://bramp.github.io/js-sequence-diagrams/</a></p>
</header>
<div class="editormd" id="test-editormd">
<script type="text/markdown">```seq
<div id="test-editormd">
<textarea style="display:none;">####开启 SequenceDiagram 时序图/序列图支持
配置项:
{
sequenceDiagram : true
}
####示例
```seq
A->B: Message
```
@ -21,12 +32,11 @@ Andrew->China: Says Hello
Note right of China: China thinks\nabout it
China-->Andrew: How are you?
Andrew->>China: I am good thanks!
```</script>
```</textarea>
</div>
</div>
<script src="../lib/jquery.min.js"></script>
<link rel="stylesheet" href="../dist/css/editormd.css" />
<script src="../src/js/editormd.js"></script>
<script type="text/javascript">
$(function() {

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

@ -0,0 +1,107 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>插入字符/设置和获取光标位置/设置、获取和替换选中的文本 - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.css" />
</head>
<body>
<div id="layout">
<header>
<h1>插入字符/设置和获取光标位置/设置、获取和替换选中的文本</h1>
<p>Insert value & Set/Get cursor & Set/Get/Replace selection</p>
<br/>
<div class="btns" style="margin:0">
<button id="btn1">设置光标位置(line:1, ch:2)</button>
<button id="btn2">获取光标位置</button>
<button id="btn3">设置选中文本({line:1, ch:0}, {line:5, ch:100})</button>
<button id="btn4">获取选中文本</button>
<button id="btn5">替换选中文本为"$$$$$$$$$"</button>
<button id="btn6">在光标处插入"????"</button>
</div>
</header>
<div id="test-editormd">
<textarea style="display:none;">```javascript
var testEditormd;
$(function() {
testEditormd = editormd("test-editormd", {
width: "90%",
height: 640,
path : '../lib/'
});
});
$("#btn1").click(function(){
testEditormd.setCursor({line:1, ch:2});
});
$("#btn2").click(function(){
console.log("getCursor =>", testEditormd.getCursor());
});
$("#btn3").click(function(){
testEditormd.setSelection({line:1, ch:0}, {line:5, ch:100});
});
$("#btn4").click(function(){
console.log("getSelection =>", testEditormd.getSelection());
});
$("#btn5").click(function(){
testEditormd.replaceSelection("$$$$$$$$$");
});
$("#btn6").click(function(){
testEditormd.insertValue("????");
});
```
</textarea>
</div>
</div>
<script src="../lib/jquery.min.js"></script>
<script src="../src/js/editormd.js"></script>
<script type="text/javascript">
var testEditormd;
$(function() {
testEditormd = editormd("test-editormd", {
width: "90%",
height: 640,
path : '../lib/'
});
$("#btn1").click(function(){
testEditormd.setCursor({line:1, ch:2});
testEditormd.focus();
});
$("#btn2").click(function(){
console.log("getCursor =>", testEditormd.getCursor());
testEditormd.focus();
});
$("#btn3").click(function(){
testEditormd.setSelection({line:1, ch:0}, {line:5, ch:100});
testEditormd.focus();
});
$("#btn4").click(function(){
console.log("getSelection =>", testEditormd.getSelection());
testEditormd.focus();
});
$("#btn5").click(function(){
testEditormd.replaceSelection("$$$$$$$$$");
testEditormd.focus();
});
$("#btn6").click(function(){
testEditormd.insertValue("????");
testEditormd.focus();
});
});
</script>
</body>
</html>

99
examples/simple.html

@ -4,99 +4,34 @@
<meta charset="utf-8" />
<title>Simple - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.css" />
</head>
<body>
<div id="layout">
<header>
<h1>完整示例</h1>
<p>开启TeX(基于KaTeX)、流程图和时序/序列图支持;</p>
<h1>简单示例</h1>
</header>
<div class="btns">
<button id="show-btn">显示编辑器</button>
<button id="hide-btn">隐藏编辑器</button>
<button id="get-md-btn">获取Markdown(源码)</button>
<button id="get-html-btn">获取HTML(源码)</button>
<button id="watch-btn">开启实时预览</button>
<button id="unwatch-btn">关闭实时预览</button>
<button id="preview-btn">预览HTML(按ESC取消)</button>
<button id="fullscreen-btn">全屏(按ESC取消)</button>
<button id="show-toolbar-btn">显示工具栏</button>
<button id="close-toolbar-btn">关闭工具栏</button>
</div>
<div class="editormd" id="test-editormd">
<script type="text/markdown">###Hello world!</script>
<div id="test-editormd">
<textarea style="display:none;">###Hello world!
本示例未开启:
- TeX(基于KaTeX);
- 智能识别和解析HTML标签;
- 流程图和时序/序列图支持;
</textarea>
</div>
</div>
<script src="../lib/jquery.min.js"></script>
<link rel="stylesheet" href="../dist/css/editormd.css" />
<script src="../src/js/editormd.js"></script>
<script type="text/javascript">
$(function() {
var testEditor;
$.get('test.md', function(md){
testEditor = editormd("test-editormd", {
width: "90%",
height: 720,
path : '../lib/',
markdown : md,
//toolbar : false, //关闭工具栏
//previewCodeHighlight : false, // 关闭预览HTML的代码块高亮,默认开启
tex : true, // 开启科学公式TeX语言支持,默认关闭
flowChart : true, // 开启流程图支持,默认关闭
sequenceDiagram : true, // 开启时序/序列图支持,默认关闭
onload : function() {
console.log('onload', this);
//this.fullscreen();
//this.unwatch();
//this.watch().fullscreen();
var testEditor;
//this.setMarkdown("#PHP");
//this.width("100%");
//this.height(480);
//this.resize("100%", 640);
}
});
});
$("#show-btn").bind('click', function(){
testEditor.show();
});
$("#hide-btn").bind('click', function(){
testEditor.hide();
});
$("#get-md-btn").bind('click', function(){
alert(testEditor.getMarkdown());
});
$("#get-html-btn").bind('click', function() {
alert(testEditor.getHTML());
});
$("#watch-btn").bind('click', function() {
testEditor.watch();
});
$("#unwatch-btn").bind('click', function() {
testEditor.unwatch();
});
$("#preview-btn").bind('click', function() {
testEditor.previewing();
});
$("#fullscreen-btn").bind('click', function() {
testEditor.fullscreen();
});
$("#show-toolbar-btn").bind('click', function() {
testEditor.showToolbar();
});
$("#close-toolbar-btn").bind('click', function() {
testEditor.hideToolbar();
$(function() {
testEditor = editormd("test-editormd", {
width: "90%",
height: 540,
path : '../lib/'
});
});
</script>

118
examples/test.md

@ -9,18 +9,64 @@
#####Hello world!
######Hello world!
###横线等基本语法
###字符效果和横线等
----
~~删除线~~
*斜体字*
**强调字体**
~~删除线~~ <s>删除线(开启识别HTML标签时)</s>
*斜体字* _斜体字_
**粗体** __粗体__
***粗斜体*** ___粗斜体___
> 引用文本 [示例链接](http://localhost/)
上标:X<sub>2</sub>,下标:O<sup>2</sup>
**缩写(同HTML的abbr标签)**
> 即更长的单词或短语的缩写形式,前提是开启识别HTML标签时,已默认开启
The <abbr title="Hyper Text Markup Language">HTML</abbr> specification is maintained by the <abbr title="World Wide Web Consortium">W3C</abbr>.
###引用
> 引用文本
引用的行内混合
> 引用:如果想要插入空白换行`即<br />标签`,在插入处先键入两个以上的空格然后回车即可,[普通链接](http://localhost/)。
###锚点与链接
[普通链接](http://localhost/)
[普通链接带标题](http://localhost/ "普通链接带标题")
直接链接:<https://github.com>
[锚点链接][anchor-id]
[anchor-id]: http://www.this-anchor-link.com/
###多语言代码高亮
####行内代码
执行命令:`npm install marked`
####缩进风格
即缩进四个空格,也做为实现类似`<pre>`预格式化文本(Preformatted Text)的功能。
<?php
echo "Hello world!";
?>
预格式化文本:
| First Header | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
####JS代码 
```javascript
@ -76,18 +122,20 @@ testBox.add("jQuery").remove("jQuery");
</body>
</html>
```
###图片
![ddd](./images/X7t2gyC.png)
> 引用:如果想要插入空白换行`即<br />标签`,在插入处先键入两个以上的空格然后回车即可。
图片加链接:
[![xxx](http://i.imgur.com/5MCMHPl.png)](http://i.imgur.com/5MCMHPl.png)
----
###列表
####无序列表(横线
####无序列表(减号
- 列表一
- 列表二
@ -95,9 +143,21 @@ testBox.add("jQuery").remove("jQuery");
####无序列表(星号)
* 一
* 二
* 三
* 列表一
* 列表二
* 列表三
####无序列表(加号和嵌套)
+ 列表一
+ 列表二
+ 列表二-1
+ 列表二-2
+ 列表二-3
+ 列表三
* 列表一
* 列表二
* 列表三
####有序列表
@ -107,7 +167,7 @@ testBox.add("jQuery").remove("jQuery");
----
### 绘制表格
###绘制表格
| 项目 | 价格 | 数量 |
| -------- | -----: | :----: |
@ -125,9 +185,39 @@ Content Cell | Content Cell
| Content Cell | Content Cell |
| Content Cell | Content Cell |
执行命令:`npm install marked`
| Function name | Description |
| ------------- | ------------------------------ |
| `help()` | Display the help window. |
| `destroy()` | **Destroy your computer!** |
| Item | Value |
| --------- | -----:|
| Computer | $1600 |
| Phone | $12 |
| Pipe | $1 |
----
####特殊符号
&copy; & &uml; &trade; &iexcl; &pound;
&amp; &lt; &gt; &yen; &euro; &reg; &plusmn; &para; &sect; &brvbar; &macr; &laquo; &middot;
X&sup2; Y&sup3; &frac34; &frac14; &times; &divide; &raquo;
18&ordm;C &quot; &apos;
####标题(用底线的形式)
This is an H1
=============
This is an H2
-------------
####反斜杠
\*literal asterisks\*
###科学公式

9
examples/toc.html

@ -4,14 +4,15 @@
<meta charset="utf-8" />
<title>TOC - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.css" />
</head>
<body>
<div id="layout">
<header>
<h1>TOC(Table of Contents)示例</h1>
</header>
<div class="editormd" id="test-editormd">
<script type="text/markdown"># 7
<div id="test-editormd">
<textarea style="display:none;">#支撑起整个互联网时代的 7 款开源软件
**目录:**
@ -94,12 +95,11 @@ WebKit 是一个开源的浏览器引擎,与之相应的引擎有Gecko(Mozil
很多人可能尚未意识到,我们使用的电脑中运行有开源软件,手机中运行有开源软件,家里的电视也运行有开源软件,甚至小小的数码产品中也运行有开源软件,尤其是互联网服务器端软件,几乎全部是开源软件。毫不夸张地说,开源软件已经渗透到了我们日常生活的方方面面。
稿源:[钛媒体](http://www.tmtpost.com/194306.html)
</script>
</textarea>
</div>
</div>
<script src="../lib/jquery.min.js"></script>
<link rel="stylesheet" href="../dist/css/editormd.css" />
<script src="../src/js/editormd.js"></script>
<script type="text/javascript">
$(function() {
@ -107,6 +107,7 @@ WebKit 是一个开源的浏览器引擎,与之相应的引擎有Gecko(Mozil
width : "90%",
height : 720,
//toc : false, // diable ToC
tocStartLevel : 2, // 表示从H2开始解析,默认值为1
path : '../lib/'
});
});

24
examples/use-requirejs.html

@ -24,13 +24,10 @@
<button id="show-toolbar-btn">显示工具栏</button>
<button id="close-toolbar-btn">关闭工具栏</button>
</div>
<div class="editormd" id="test-editormd">
<script type="text/markdown">###Hello world!</script>
</div>
<div id="test-editormd"></div>
</div>
<script src="js/require.min.js"></script>
<script type="text/javascript">
<script type="text/javascript">
requirejs.config({
baseUrl: "../lib/",
paths: {
@ -43,12 +40,12 @@
waitSeconds: 30
});
require(["jquery", "marked", "prettify", "editormd", "raphael", "underscore.min", "flowchart.min", "jquery.flowchart.min", "sequence-diagram.min"], function($, marked, prettify, editormd) {
require(["jquery", "marked", "prettify", "editormd", "../src/js/languages/en", "raphael", "underscore.min", "flowchart.min", "jquery.flowchart.min", "sequence-diagram.min"], function($, marked, prettify, editormd) {
var testEditor;
// editormd.katexURL.js + ".js"
require([editormd.katexURL.js + ".js"], function(katex) {
require([editormd.katexURL.js + ".js"], function(katex) {
require(editormd.requireModules(), function(CodeMirror) {
console.log(CodeMirror, marked, katex);
//console.log(CodeMirror, marked, katex);
editormd.requirejsInit(CodeMirror, marked, katex, prettyPrint);
@ -58,11 +55,20 @@
height: 640,
path : '../lib/',
markdown : md,
htmlDecode : true, // 开启HTML标签解析,为了安全性,默认不开启
tex : true,
previewCodeHighlight : true,
inRequirejs : true,
flowChart : true,
sequenceDiagram : true,
//dialogLockScreen : false, // 设置弹出层对话框不锁屏,全局通用,默认为true
//dialogShowMask : false, // 设置弹出层对话框显示透明遮罩层,全局通用,默认为true
//dialogDraggable : false, // 设置弹出层对话框不可拖动,全局通用,默认为true
//dialogMaskOpacity : 0.4, // 设置透明遮罩层的透明度,全局通用,默认值为0.1
//dialogMaskBgColor : "#000", // 设置透明遮罩层的背景颜色,全局通用,默认为#fff
imageUpload : true,
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
imageUploadURL : "./php/upload.php",
onload : function() {
console.log('onload', this);
//this.fullscreen();

24
examples/use-seajs.html

@ -4,6 +4,7 @@
<meta charset="utf-8" />
<title>Use sea.js - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.min.css" />
<style>
header p code {
padding: 3px;
@ -35,13 +36,10 @@
<button id="show-toolbar-btn">显示工具栏</button>
<button id="close-toolbar-btn">关闭工具栏</button>
</div>
<div class="editormd" id="test-editormd">
<script type="text/markdown">###Hello world!</script>
</div>
<div id="test-editormd"></div>
</div>
<script src="../lib/raphael.min.js"></script>
<script src="js/sea.js"></script>
<link rel="stylesheet" href="../dist/css/editormd.css" />
<script type="text/javascript">
seajs.config({
base : "../lib",
@ -51,10 +49,11 @@
}
});
var testEditor;
seajs.use(["jquery", "editormd"], function($, editormd) {
//seajs.use("./js/seajs-main"); //使用main.js时 editormd 路径要改为 "../../src/js/editormd"
seajs.use(["jquery", "editormd", "../src/js/languages/en"], function($, editormd) {
var testEditor;
$.get("./test.md", function(md){
testEditor = editormd("test-editormd", {
width: "90%",
@ -62,10 +61,19 @@
path : '../lib/',
markdown : md,
//toolbar : false, //关闭工具栏
htmlDecode : true, // 开启HTML标签解析,为了安全性,默认不开启
tex : true, // 开启科学公式TeX语言支持,默认关闭
//previewCodeHighlight : false, // 关闭预览窗口的代码高亮,默认开启
flowChart : true, // 疑似Sea.js与Raphael.js有冲突,必须先加载Raphael.js,Editor.md才能在Sea.js下正常进行;
sequenceDiagram : true, // 同上
//dialogLockScreen : false, // 设置弹出层对话框不锁屏,全局通用,默认为true
//dialogShowMask : false, // 设置弹出层对话框显示透明遮罩层,全局通用,默认为true
//dialogDraggable : false, // 设置弹出层对话框不可拖动,全局通用,默认为true
//dialogMaskOpacity : 0.4, // 设置透明遮罩层的透明度,全局通用,默认值为0.1
//dialogMaskBgColor : "#000", // 设置透明遮罩层的背景颜色,全局通用,默认为#fff
imageUpload : true,
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
imageUploadURL : "./php/upload.php",
onload : function() {
console.log('onload', this);
//this.fullscreen();

96
examples/use-zepto.html

@ -0,0 +1,96 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>Use Zepto.js - Editor.md examples</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="../dist/css/editormd.css" />
</head>
<body>
<div id="layout">
<header>
<h1>Use Zepto.js</h1>
</header>
<div class="btns">
<button id="show-btn">显示编辑器</button>
<button id="hide-btn">隐藏编辑器</button>
<button id="get-md-btn">获取Markdown(源码)</button>
<button id="get-html-btn">获取HTML(源码)</button>
<button id="watch-btn">开启实时预览</button>
<button id="unwatch-btn">关闭实时预览</button>
<button id="preview-btn">预览HTML(按ESC取消)</button>
<button id="fullscreen-btn">全屏(按ESC取消)</button>
<button id="show-toolbar-btn">显示工具栏</button>
<button id="close-toolbar-btn">关闭工具栏</button>
</div>
<div class="editormd" id="test-editormd">
<script type="text/markdown">###Hello world!</script>
</div>
</div>
<script src="js/zepto.min.js"></script>
<script src="../src/js/editormd.js"></script>
<script type="text/javascript">
var testEditor;
var jQuery = Zepto; // 为了避免修改flowChart.js和sequence-diagram.js的源码,所以想支持flowChart/sequenceDiagram就得加上这一句
$(function() {
$.get("./test.md", function(md){
testEditor = editormd("test-editormd", {
width : "90%",
height : 720,
path : '../lib/',
markdown : md,
htmlDecode : true, // 开启HTML标签解析,为了安全性,默认不开启
tex : true, // 开启科学公式TeX语言支持,默认关闭
//previewCodeHighlight : false, // 关闭预览窗口的代码高亮,默认开启
flowChart : true, // 疑似Sea.js与Raphael.js有冲突,必须先加载Raphael.js,Editor.md才能在Sea.js下正常进行;
sequenceDiagram : true, // 同上
onload : function() {
console.log("onload =>", this, this.id, this.settings);
}
});
});
$("#show-btn").bind('click', function(){
testEditor.show();
});
$("#hide-btn").bind('click', function(){
testEditor.hide();
});
$("#get-md-btn").bind('click', function(){
alert(testEditor.getMarkdown());
});
$("#get-html-btn").bind('click', function() {
alert(testEditor.getHTML());
});
$("#watch-btn").bind('click', function() {
testEditor.watch();
});
$("#unwatch-btn").bind('click', function() {
testEditor.unwatch();
});
$("#preview-btn").bind('click', function() {
testEditor.previewing();
});
$("#fullscreen-btn").bind('click', function() {
testEditor.fullscreen();
});
$("#show-toolbar-btn").bind('click', function() {
testEditor.showToolbar();
});
$("#close-toolbar-btn").bind('click', function() {
testEditor.hideToolbar();
});
});
</script>
</body>
</html>

4
package.json

@ -1,6 +1,6 @@
{
"name": "editor.md",
"version": "1.0.0",
"version": "1.1.0",
"description": "A simple online markdown editor.",
"directories": {
"doc": "docs",
@ -27,6 +27,8 @@
"homepage": "https://github.com/pandao/editor.md",
"devDependencies": {
"dateformatter": "^0.1.0",
"grunt": "^0.4.5",
"grunt-webfont": "^0.5.1",
"gulp": "^3.8.10",
"gulp-autoprefixer": "^2.1.0",
"gulp-concat": "^2.4.2",

1914
src/js/editormd.js

File diff suppressed because it is too large

110
src/js/languages/en.js

@ -0,0 +1,110 @@
(function(){
var factory = function (exports) {
var lang = {
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 " + exports.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."
}
}
};
exports.defaults.lang = lang;
};
// 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);
}
})();

110
src/js/languages/zh-tw.js

@ -0,0 +1,110 @@
(function(){
var factory = function (exports) {
var lang = {
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 : "關於" + exports.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 : "錯誤:請填寫代碼內容。"
}
}
};
exports.defaults.lang = lang;
};
// 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);
}
})();

10
src/scss/editormd.codemirror.scss

@ -1,6 +1,6 @@
@charset "UTF-8";
.editormd .CodeMirror, .editormd-preview {
.editormd .CodeMirror, #{$prefix}preview {
display: inline-block;
width: 50%;
height: 100%;
@ -9,7 +9,7 @@
margin: 0;
}
.editormd-preview {
#{$prefix}preview {
position: absolute;
top: 35px;
right: 0;
@ -26,7 +26,7 @@
.CodeMirror {
z-index: 10;
float: left;
border-right: 1px solid #ddd;
border-right: 1px solid $borderColor;
font-size: 13px;
font-family: Consolas, 'Monaco', courier, monospace;
line-height: 1.6;
@ -41,7 +41,7 @@
background: #70B7FF;
}
.CodeMirror, .CodeMirror-scroll, .editormd-preview {
.CodeMirror, .CodeMirror-scroll, #{$prefix}preview {
-webkit-overflow-scrolling : touch;
}
@ -56,7 +56,7 @@
}
.CodeMirror-empty {
outline: 1px solid #c22;
//outline: 1px solid #c22;
&.CodeMirror-focused {
outline: none;

144
src/scss/editormd.dialog.scss

@ -1,27 +1,21 @@
@charset "UTF-8";
.editormd-dialog {
position: absolute;
top: 38%;
left: 33%;
z-index: 101;
width: 34%;
height: 24%;
#{$prefix}dialog {
color: $color;
position: fixed;
z-index: 99999;
display: none;
@include border-radius(3px);
@include box-shadow(0 0 10px rgba(0, 0, 0, 0.3));
//@include user-select(none);
background: #fff;
font-size: 14px;
}
.editormd-dialog-info {
width: 420px;
height: 160px;
}
.editormd-dialog-container {
padding: 20px 25px 25px;
#{$prefix}dialog-container {
position: relative;
padding: 20px;
line-height: 1.6;
border: 1px solid #ddd\0;
h1 {
font-size: 24px;
@ -38,18 +32,130 @@
font-size: 12px;
color: #999;
}
}
select {
color: #999;
padding: 3px 8px;
border: 1px solid $borderColor;
}
}
.editormd-dialog-close {
#{$prefix}dialog-close {
position: absolute;
top: 10px;
right: 10px;
top: 12px;
right: 15px;
font-size: 18px;
color: #ccc;
@include transition(color 300ms ease-out);
&:hover {
color: #999;
@include transition(all 300ms ease-out);
}
}
#{$prefix}dialog-header {
padding: 11px 20px;
border-bottom: 1px solid #eee;
@include transition(background 300ms ease-out);
&:hover {
background: #f6f6f6;
}
}
#{$prefix}dialog-title {
font-size: 14px;
}
#{$prefix}dialog-footer {
padding: 10px 0 0 0;
text-align: right;
}
#{$prefix}dialog-info {
width: 420px;
h1 {
font-weight: normal;
}
#{$prefix}dialog-container {
padding: 20px 25px 25px;
}
#{$prefix}dialog-close {
top: 10px;
right: 10px;
}
}
#{$prefix}mask,
#{$prefix}container-mask,
#{$prefix}dialog-mask {
display: none;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
#{$prefix}mask,
#{$prefix}container-mask,
#{$prefix}dialog-mask-bg {
background: #fff;
opacity: 0.5;
filter: alpha(opacity=50);
}
#{$prefix}mask {
position: fixed;
background: #000;
@include opacity(0.2);
z-index: 99998;
}
#{$prefix}container-mask {
@include opacity(0.1);
}
#{$prefix}container-mask,
#{$prefix}dialog-mask-con {
background: url(../images/loading.gif) no-repeat center center;
@include background-size(32px 32px);
}
@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2) {
#{$prefix}container-mask,
#{$prefix}dialog-mask-con {
background-image: url(../images/loading@2x.gif);
}
}
@media only screen and (-webkit-min-device-pixel-ratio: 3), only screen and (min-device-pixel-ratio: 3) {
#{$prefix}container-mask,
#{$prefix}dialog-mask-con {
background-image: url(../images/loading@3x.gif);
}
}
#{$prefix}dialog-code-block,
#{$prefix}dialog-tab-code-block {
textarea {
width: 100%;
height: 400px;
margin-bottom: 6px;
overflow: auto;
border: 1px solid #eee;
background: #fff;
padding: 15px;
resize: none;
}
}
#{$prefix}code-toolbar {
color: #999;
font-size: 14px;
margin: -5px 0 12px;
}

97
src/scss/editormd.form.scss

@ -0,0 +1,97 @@
@charset "UTF-8";
// Form
#{$prefix}form {
color: $color;
label {
float: left;
display: block;
width: 75px;
text-align: left;
padding: 5px 0 15px 5px;
}
br {
clear: both;
}
iframe {
display: none;
}
input:focus {
outline: 0;
}
input[type="text"] {
color: #999;
padding: 7px 8px;
border: 1px solid $borderColor;
}
input[type="text"] {
display: inline-block;
width: 242px;
}
}
#{$prefix}form,
#{$prefix}dialog-container,
#{$prefix}dialog-footer {
input[type="submit"], #{$prefix}btn, button {
color: $color;
min-width: 75px;
cursor: pointer;
background: #fff;
padding: 7px 10px;
border: 1px solid #ddd;
@include border-radius(3px);
@include transition(background 300ms ease-out);
&:hover {
background: #eee;
}
}
#{$prefix}btn {
padding: 5px 8px 4px\0;
}
#{$prefix}btn + #{$prefix}btn {
margin-left: 8px;
}
}
#{$prefix}file-input {
width: 75px;
height: 32px;
margin-left: 8px;
position: relative;
display: inline-block;
input[type="file"] {
width: 75px;
height: 32px;
opacity: 0;
cursor: pointer;
background: #000;
display: inline-block;
position: absolute;
top: 0;
right: 0;
&::-webkit-file-upload-button {
visibility: hidden;
}
}
input[type="submit"] {
}
&:hover input[type="submit"] {
background: #eee;
}
}

23
src/scss/editormd.menu.scss

@ -1,6 +1,6 @@
@charset "UTF-8";
.editormd-menu {
#{$prefix}menu {
margin: 0;
padding: 0;
list-style: none;
@ -16,13 +16,14 @@
text-indent: -9999px;
margin: 0 5px;
height: 65%;
border-right: 1px solid #ddd;
border-right: 1px solid $borderColor;
}
> a {
color: #666;
outline: 0;
color: $color;
display: inline-block;
width: 24px;
min-width: 24px;
font-size: 14px;
text-decoration: none;
text-align: center;
@ -30,7 +31,7 @@
border: 1px solid #fff;
&:hover, &.active {
border: 1px solid #ddd;
border: 1px solid $borderColor;
background: #eee;
@include transition(all 300ms ease-out);
}
@ -41,14 +42,14 @@
padding: 5px;
}
> .editormd-bold {
> #{$prefix}bold {
padding: 5px 0;
display: inline-block;
font-weight: bold;
}
}
&:hover .editormd-dropdown-menu {
&:hover #{$prefix}dropdown-menu {
display: block;
}
}
@ -58,10 +59,10 @@
}
}
.editormd-dropdown-menu {
#{$prefix}dropdown-menu {
display: none;
background: #fff;
border: 1px solid #ddd;
border: 1px solid $borderColor;
width: 148px;
list-style: none;
position: absolute;
@ -94,7 +95,7 @@
> li {
> a {
color: #666;
color: $color;
display: block;
text-decoration: none;
padding: 8px 10px;
@ -107,6 +108,6 @@
}
> li + li {
border-top: 1px solid #ddd;
border-top: 1px solid $borderColor;
}
}

81
src/scss/editormd.preview.scss

@ -7,13 +7,16 @@
@import "github-markdown";
#{$prefix}preview-container, #{$prefix}html-preview {
text-align: left;
font-size: 14px;
line-height: 1.6;
padding: 20px;
blockquote {
border-left: 4px solid #ddd;
color: $color;
border-left: 4px solid $borderColor;
padding-left: 20px;
margin-left: 0;
color: #666;
font-size: 14px;
font-style: italic;
}
@ -21,43 +24,47 @@
p > code {
margin-left: 5px;
}
.markdown-body {
line-height: 1.6;
abbr {
background: #ffffdd;
}
hr {
height: 1px;
border: none;
border-top: 1px solid #ddd;
background: none;
}
hr {
height: 1px;
border: none;
border-top: 1px solid $borderColor;
background: none;
}
code {
border: 1px solid #ddd;
background: #f6f6f6;
padding: 3px;
border-radius: 3px;
font-size: 13px;
font-family: Consolas, 'Monaco', courier, monospace;
}
code {
border: 1px solid $borderColor;
background: #f6f6f6;
padding: 3px;
border-radius: 3px;
font-size: 13px;
font-family: Consolas, 'Monaco', courier, monospace;
}
pre {
border: 1px solid #ddd;
background: #f6f6f6;
padding: 10px;
@include border-radius(3px);
pre {
border: 1px solid $borderColor;
background: #f6f6f6;
padding: 10px;
@include border-radius(3px);
code {
padding: 0;
}
}
.markdown-toc {
code {
padding: 0;
}
}
.markdown-toc-list {
}
table thead tr {
background-color: #F8F8F8;
}
.markdown-toc {
}
.markdown-toc-list {
}
p#{$prefix}tex {
text-align: center;
@ -72,7 +79,7 @@
}
.sequence-diagram text, .flowchart text {
font-size: 15px !important;
font-size : 15px !important;
font-family: Arial !important;
}
}
@ -84,7 +91,7 @@
#{$prefix}preview-container, #{$prefix}html-preview {
pre.prettyprint {
padding: 10px;
border: 1px solid #ddd;
border: 1px solid $borderColor;
}
ol.linenums {
@ -101,4 +108,10 @@
li.L0, li.L1, li.L2, li.L3, li.L5, li.L6, li.L7, li.L8 {
list-style-type: decimal;
}
}
#{$prefix}html-preview {
textarea {
display : none;
}
}

159
src/scss/editormd.scss

@ -1,4 +1,4 @@
@charset "utf-8";
@charset "UTF-8";
@import "lib/variables";
@import "lib/functions";
@ -8,31 +8,120 @@
width: 90%;
height: 640px;
margin: 0 auto;
position: relative;
@include box-sizing(border-box);
border: 1px solid $borderColor;
text-align: left;
overflow: hidden;
background: #fff url("../images/loading.gif") no-repeat center center;
@include background-size(32px 32px);
overflow: hidden;
position: relative;
border: 1px solid $borderColor;
@include box-sizing(border-box);
font-family: "Microsoft YaHei", "微软雅黑", Helvetica, Tahoma, STXihei, "华文细黑", STHeiti, "Helvetica Neue", Helvetica, Tahoma, "Droid Sans", "wenquanyi micro hei", FreeSans, Arimo, Arial, SimSun, "宋体", Heiti, "黑体", sans-serif;
a {
text-decoration: none;
}
}
@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2) {
.editormd {
background-image: url(../images/loading@2x.gif);
img {
border: none;
vertical-align: middle;
}
> textarea,
#{$prefix}html-textarea,
#{$prefix}markdown-textarea {
width: 0;
height: 0;
outline: 0;
resize:none;
}
input[type="text"],
input[type="button"],
input[type="submit"],
select, textarea, button {
@include appearance(none);
}
}
@media only screen and (-webkit-min-device-pixel-ratio: 3), only screen and (min-device-pixel-ratio: 3) {
.editormd {
background-image: url(../images/loading@3x.gif);
@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: normal;
font-style: normal;
}
#{$prefix}logo {
font-family: 'editormd-logo';
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
font-size: inherit;
line-height: 1;
display: inline-block;
text-rendering: auto;
vertical-align: inherit;
//Better Font Rendering
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
&:before {
content: "\e1987";
/*
HTML Entity &#xe1987;
example: <span class="editormd-logo">&#xe1987;</span>
*/
}
}
#{$prefix}logo-1x {
font-size: 1em;
}
#{$prefix}logo-lg {
font-size: 1.2em;
}
#{$prefix}logo-2x {
font-size: 2em;
}
#{$prefix}logo-3x {
font-size: 3em;
}
#{$prefix}logo-4x {
font-size: 4em;
}
#{$prefix}logo-5x {
font-size: 5em;
}
#{$prefix}logo-6x {
font-size: 6em;
}
#{$prefix}logo-7x {
font-size: 7em;
}
#{$prefix}logo-8x {
font-size: 8em;
}
#{$prefix}logo-color {
color: $mainColor;
}
#{$prefix}user-unselect {
@include user-select(none);
}
#{$prefix}toolbar {
width: 100%;
min-height: 35px;
@ -48,6 +137,7 @@
#{$prefix}toolbar-container {
padding: 0 8px;
min-height: 35px;
@include user-select(none);
}
@import "editormd.menu";
@ -61,16 +151,41 @@
position: relative;
background: #fff;
@include box-sizing(border-box);
textarea {
display: none;
}
}
#{$prefix}html-textarea, #{$prefix}markdown-textarea {
@import "editormd.dialog";
@import "editormd.form";
@import "editormd.codemirror";
@import "editormd.preview";
#{$prefix}preview-close-btn {
color: #fff;
padding: 4px 6px;
font-size: 18px;
@include border-radius(500px);
display: none;
background-color: #ccc;
position: absolute;
top: 20px;
right: 20px;
z-index: 19;
@include transition(background-color 300ms ease-out);
}
@import "editormd.dialog";
@import "editormd.codemirror";
@import "editormd.preview";
#{$prefix}preview-close-btn:hover {
background-color: #999;
}
#{$prefix}onlyread {
#{$prefix}toolbar {
display: none;
}
.CodeMirror {
margin-top: 0;
}
#{$prefix}preview {
top: 0;
}
}

12
src/scss/lib/functions.scss

@ -1,5 +1,13 @@
@charset "UTF-8";
// appearance
@mixin appearance($value) {
-webkit-appearance: $value;
-moz-appearance: $value;
appearance: $value;
}
// clearfix
@mixin clearfix() {
@ -129,11 +137,11 @@
// user-select
@mixin user-select($type : none) {
@mixin user-select($type) {
-webkit-user-select: $type;
-moz-user-select: $type;
-ms-user-select: $type;
//-o-user-select: $type;
-o-user-select: $type;
user-select: $type;
}

9
src/scss/lib/variables.scss

@ -2,5 +2,10 @@
// Global Variables
$prefix : ".editormd-";
$borderColor: #ddd;
$prefix : ".editormd-";
$color : #666;
$mainColor : #2196F3;
$primaryColor : $mainColor;
$secondColor : #33CC66;
$thirdColor : #999999;
$borderColor : #ddd;
Loading…
Cancel
Save