Browse Source

Releases v1.1.4

v1.1.9 v1.1.4
Pandao 10 years ago
parent
commit
33a144fc1f
  1. 7
      CHANGE.md
  2. 139
      Gulpfile.js
  3. 2
      bower.json
  4. 4
      dist/css/editormd.css
  5. 8
      dist/css/editormd.css.map
  6. 4
      dist/css/editormd.css.min.map
  7. 82
      dist/css/editormd.logo.css
  8. 18
      dist/css/editormd.logo.css.map
  9. 2
      dist/css/editormd.logo.css.min.map
  10. 2
      dist/css/editormd.logo.min.css
  11. 2
      dist/css/editormd.min.css
  12. 4
      dist/css/editormd.preview.css
  13. 4
      dist/css/editormd.preview.css.map
  14. 2
      dist/css/editormd.preview.css.min.map
  15. 2
      dist/css/editormd.preview.min.css
  16. 211
      dist/js/editormd.js
  17. 6
      dist/js/editormd.min.js
  18. 4
      dist/js/languages/en.js
  19. 2
      dist/js/languages/en.min.js
  20. 4
      dist/js/languages/zh-tw.js
  21. 2
      dist/js/languages/zh-tw.min.js
  22. 2
      docs/html/index.html
  23. 2
      lib/codemirror/addons.min.js
  24. 2
      lib/codemirror/modes.min.js
  25. 2
      package.json
  26. 207
      src/js/editormd.js
  27. 81
      src/scss/editormd.logo.scss
  28. 77
      src/scss/editormd.scss

7
CHANGE.md

@ -139,3 +139,10 @@
- 修复Bug[#14](https://github.com/pandao/editor.md/issues/14);
- 修复Bug[#15](https://github.com/pandao/editor.md/issues/15);
#####v1.1.4
- 修复Bug[#17](https://github.com/pandao/editor.md/issues/17);
- 修改了`getToolbarHandles()`和`setToolbarHandler()`方法;
- 从`editormd.scss`中分离出`editormd.logo.scss`,并生成`editormd.logo.css`,以便单独使用;
- 同时修改了`Gulpfile.js`的相应任务;

139
Gulpfile.js

@ -39,23 +39,23 @@ var scssTask = function(fileName, path) {
path = path || 'src/scss/';
return gulp.src(path + fileName + ".scss")
.pipe(sass({ style: 'expanded' })) //nested,compact,expanded,compressed
.pipe(gulp.dest('dist/css'))
.pipe(header(headerComment, {pkg : pkg, fileName : function(file) {
var name = file.path.split(file.base);
return name[1].replace('\\', '');
}}))
.pipe(gulp.dest('dist/css'))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist/css'))
.pipe(minifycss())
.pipe(gulp.dest('dist/css'))
.pipe(header(headerMiniComment, {pkg : pkg, fileName : function(file) {
var name = file.path.split(file.base);
return name[1].replace('\\', '');
}}))
.pipe(gulp.dest('dist/css'))
.pipe(notify({ message: fileName + '.scss task completed!' }));
.pipe(sass({ style: 'expanded' })) //nested,compact,expanded,compressed
.pipe(gulp.dest('dist/css'))
.pipe(header(headerComment, {pkg : pkg, fileName : function(file) {
var name = file.path.split(file.base);
return name[1].replace('\\', '');
}}))
.pipe(gulp.dest('dist/css'))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist/css'))
.pipe(minifycss())
.pipe(gulp.dest('dist/css'))
.pipe(header(headerMiniComment, {pkg : pkg, fileName : function(file) {
var name = file.path.split(file.base);
return name[1].replace('\\', '');
}}))
.pipe(gulp.dest('dist/css'))
.pipe(notify({ message: fileName + '.scss task completed!' }));
};
gulp.task('scss', function() {
@ -66,24 +66,28 @@ gulp.task('scss2', function() {
return scssTask('editormd.preview');
});
gulp.task('scss3', function() {
return scssTask('editormd.logo');
});
gulp.task('js', function() {
return gulp.src('src/js/**/*.js')
.pipe(jshint('./.jshintrc'))
.pipe(jshint.reporter('default'))
.pipe(header(headerComment, {pkg : pkg, fileName : function(file) {
var name = file.path.split(file.base);
return name[1].replace(/[\\\/]?/, '');
}}))
.pipe(gulp.dest('dist/js'))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(gulp.dest('dist/js'))
.pipe(header(headerMiniComment, {pkg : pkg, fileName : function(file) {
var name = file.path.split(file.base + ( (os.platform() === "win32") ? "\\" : "/") );
return name[1].replace(/[\\\/]?/, '');
}}))
.pipe(gulp.dest('dist/js'))
.pipe(notify({ message: 'js task complete' }));
.pipe(jshint('./.jshintrc'))
.pipe(jshint.reporter('default'))
.pipe(header(headerComment, {pkg : pkg, fileName : function(file) {
var name = file.path.split(file.base);
return name[1].replace(/[\\\/]?/, '');
}}))
.pipe(gulp.dest('dist/js'))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(gulp.dest('dist/js'))
.pipe(header(headerMiniComment, {pkg : pkg, fileName : function(file) {
var name = file.path.split(file.base + ( (os.platform() === "win32") ? "\\" : "/") );
return name[1].replace(/[\\\/]?/, '');
}}))
.pipe(gulp.dest('dist/js'))
.pipe(notify({ message: 'js task complete' }));
});
var codeMirror = {
@ -157,19 +161,17 @@ gulp.task('codemirror-mode', function() {
modes.push(codeMirror.path.src.mode + "/" + mode + "/" + mode + ".js");
}
//console.log("modes =>", modes);
return gulp.src(modes)
.pipe(concat('modes.min.js'))
.pipe(gulp.dest(codeMirror.path.dist))
.pipe(uglify())
.pipe(gulp.dest(codeMirror.path.dist))
.pipe(header(headerMiniComment, {pkg : pkg, fileName : function(file) {
var name = file.path.split(file.base + "\\");
return name[1].replace('\\', '');
}}))
.pipe(gulp.dest(codeMirror.path.dist))
.pipe(notify({ message: 'codemirror-mode task complete' }));
return gulp.src(modes)
.pipe(concat('modes.min.js'))
.pipe(gulp.dest(codeMirror.path.dist))
.pipe(uglify())
.pipe(gulp.dest(codeMirror.path.dist))
.pipe(header(headerMiniComment, {pkg : pkg, fileName : function(file) {
var name = file.path.split(file.base + "\\");
return name[1].replace('\\', '');
}}))
.pipe(gulp.dest(codeMirror.path.dist))
.pipe(notify({ message: 'codemirror-mode task complete' }));
});
gulp.task('codemirror-addon', function() {
@ -181,17 +183,17 @@ gulp.task('codemirror-addon', function() {
addons.push(codeMirror.path.src.addon + "/" + addon + ".js");
}
return gulp.src(addons)
.pipe(concat('addons.min.js'))
.pipe(gulp.dest(codeMirror.path.dist))
.pipe(uglify())
.pipe(gulp.dest(codeMirror.path.dist))
.pipe(header(headerMiniComment, {pkg : pkg, fileName : function(file) {
var name = file.path.split(file.base + "\\");
return name[1].replace('\\', '');
}}))
.pipe(gulp.dest(codeMirror.path.dist))
.pipe(notify({ message: 'codemirror-addon task complete' }));
return gulp.src(addons)
.pipe(concat('addons.min.js'))
.pipe(gulp.dest(codeMirror.path.dist))
.pipe(uglify())
.pipe(gulp.dest(codeMirror.path.dist))
.pipe(header(headerMiniComment, {pkg : pkg, fileName : function(file) {
var name = file.path.split(file.base + "\\");
return name[1].replace('\\', '');
}}))
.pipe(gulp.dest(codeMirror.path.dist))
.pipe(notify({ message: 'codemirror-addon task complete' }));
});
gulp.task("jsdoc", function(){
@ -202,24 +204,29 @@ gulp.task("jsdoc", function(){
gulp.task("jsdoc2md", function() {
return gulp.src("src/js/editormd.js")
.pipe(jsdoc2md())
.on("error", function(err){
gutil.log(gutil.colors.red("jsdoc2md failed"), err.message)
})
.pipe(rename(function(path) {
path.extname = ".md";
}))
.pipe(gulp.dest("docs/markdown"));
.pipe(jsdoc2md())
.on("error", function(err){
gutil.log(gutil.colors.red("jsdoc2md failed"), err.message)
})
.pipe(rename(function(path) {
path.extname = ".md";
}))
.pipe(gulp.dest("docs/markdown"));
});
gulp.task('watch', function() {
gulp.watch('src/scss/editormd.scss', ['scss']);
gulp.watch('src/scss/editormd.preview.scss', ['scss2']);
gulp.watch('src/js/editormd.js', ['js']);
gulp.watch('src/scss/editormd.logo.scss', ['scss3']);
gulp.watch('src/js/**/*.js', ['js']);
});
gulp.task('default', function() {
gulp.run('scss');
gulp.run('scss2');
gulp.run('scss3');
gulp.run('js');
gulp.run("codemirror-addon");
gulp.run("codemirror-mode");
gulp.run('jsdoc');
});

2
bower.json

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

4
dist/css/editormd.css

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

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

82
dist/css/editormd.logo.css

@ -0,0 +1,82 @@
/*
* Editor.md
* @file editormd.logo.css
* @version v1.1.4
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-02-24
*/
@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;
}
.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;
}
/*# sourceMappingURL=editormd.logo.css.map */

18
dist/css/editormd.logo.css.map

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

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

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

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

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

2
dist/css/editormd.min.css

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

4
dist/css/editormd.preview.css

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

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

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

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

File diff suppressed because one or more lines are too long

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

File diff suppressed because one or more lines are too long

211
dist/js/editormd.js

@ -1,18 +1,18 @@
/*
* Editor.md
* @file editormd.js
* @version v1.1.3
* @version v1.1.4
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-02-23
* @updateTime 2015-02-24
*/
/**
* @fileOverview Editor.md
* @author pandao
* @version 1.1.3
* @version 1.1.4
*/
;(function(factory) {
@ -55,7 +55,7 @@
};
editormd.title = editormd.$name = "Editor.md";
editormd.version = "1.1.3";
editormd.version = "1.1.4";
editormd.homePage = "https://pandao.github.io/editor.md/";
editormd.classPrefix = "editormd-";
@ -555,18 +555,16 @@
/**
* 工具栏图标事件处理对象序列
* @param {Object} cm CodeMirror的实例对象
* @param {String} name 要获取的事件处理器名称
* @returns {Object} 返回处理对象序列
*/
getToolbarHandles : function(name) {
getToolbarHandles : function(name) {
var _this = this;
var settings = this.settings;
var lang = settings.lang;
var editor = this.editor;
var codeEditor = this.codeEditor;
var cursor = codeEditor.getCursor();
var selection = codeEditor.getSelection();
var classPrefix = this.classPrefix;
var dialogLockScreen = function() {
@ -587,71 +585,95 @@
};
var toolbarHandlers = this.toolbarHandlers = {
undo : function() {
codeEditor.undo();
undo : function(cm) {
cm.undo();
},
redo : function() {
codeEditor.redo();
redo : function(cm) {
cm.redo();
},
bold : function() {
codeEditor.replaceSelection("**" + selection + "**");
bold : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
cm.replaceSelection("**" + selection + "**");
if(selection === "") {
codeEditor.setCursor(cursor.line, cursor.ch + 2);
cm.setCursor(cursor.line, cursor.ch + 2);
}
},
del : function() {
codeEditor.replaceSelection("~~" + selection + "~~");
del : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
cm.replaceSelection("~~" + selection + "~~");
if(selection === "") {
codeEditor.setCursor(cursor.line, cursor.ch + 2);
cm.setCursor(cursor.line, cursor.ch + 2);
}
},
italic : function() {
codeEditor.replaceSelection("*" + selection + "*");
italic : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
cm.replaceSelection("*" + selection + "*");
if(selection === "") {
codeEditor.setCursor(cursor.line, cursor.ch + 1);
cm.setCursor(cursor.line, cursor.ch + 1);
}
},
quote : function() {
codeEditor.replaceSelection((selection === "") ? ["> " + selection, ""].join("\n") : "> " + selection);
codeEditor.setCursor(cursor.line, (selection === "") ? cursor.ch + 2 : cursor.ch + selection.length + 2);
quote : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
cm.replaceSelection((selection === "") ? ["> " + selection, ""].join("\n") : "> " + selection);
cm.setCursor(cursor.line, (selection === "") ? cursor.ch + 2 : cursor.ch + selection.length + 2);
},
h1 : function() {
codeEditor.replaceSelection("#" + selection);
h1 : function(cm) {
var selection = cm.getSelection();
cm.replaceSelection("#" + selection);
},
h2 : function() {
codeEditor.replaceSelection("##" + selection);
h2 : function(cm) {
var selection = cm.getSelection();
cm.replaceSelection("##" + selection);
},
h3 : function() {
codeEditor.replaceSelection("###" + selection);
h3 : function(cm) {
var selection = cm.getSelection();
cm.replaceSelection("###" + selection);
},
h4 : function() {
codeEditor.replaceSelection("####" + selection);
h4 : function(cm) {
var selection = cm.getSelection();
cm.replaceSelection("####" + selection);
},
h5 : function() {
codeEditor.replaceSelection("#####" + selection);
h5 : function(cm) {
var selection = cm.getSelection();
cm.replaceSelection("#####" + selection);
},
h6 : function() {
codeEditor.replaceSelection("######" + selection);
h6 : function(cm) {
var selection = cm.getSelection();
cm.replaceSelection("######" + selection);
},
"list-ul" : function() {
"list-ul" : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
if (selection === "")
{
codeEditor.replaceSelection("- " + selection);
cm.replaceSelection("- " + selection);
}
else
{
@ -662,15 +684,17 @@
selectionText[i] = (selectionText[i] === "") ? "" : "- " + selectionText[i];
}
codeEditor.replaceSelection(selectionText.join("\n"));
cm.replaceSelection(selectionText.join("\n"));
}
},
"list-ol" : function() {
"list-ol" : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
if(selection === "")
{
codeEditor.replaceSelection("1. " + selection);
cm.replaceSelection("1. " + selection);
}
else
{
@ -681,15 +705,19 @@
selectionText[i] = (selectionText[i] === "") ? "" : (i+1) + ". " + selectionText[i];
}
codeEditor.replaceSelection(selectionText.join("\n"));
cm.replaceSelection(selectionText.join("\n"));
}
},
hr : function() {
codeEditor.replaceSelection("------------");
hr : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
cm.replaceSelection("------------");
},
link : function() {
link : function(cm) {
var selection = cm.getSelection();
var linkLang = lang.dialog.link;
var linkDialogName = classPrefix + "link-dialog", linkDialog;
@ -743,7 +771,7 @@
return false;
}
codeEditor.replaceSelection("[" + title + "](" + url + " \""+title+"\")");
cm.replaceSelection("[" + title + "](" + url + " \""+title+"\")");
this.hide().lockScreen(false).hideMask();
@ -759,9 +787,10 @@
}
},
anchor : function() {
var anchorLang = lang.dialog.anchor;
anchor : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
var anchorLang = lang.dialog.anchor;
var anchorDialogName = classPrefix + "anchor-dialog", anchorDialog;
if (editor.find("." + anchorDialogName).length > 0)
@ -826,10 +855,10 @@
return false;
}
codeEditor.replaceSelection("[" + title + "][" + name + "]\n[" + name + "]: " + url + "");
cm.replaceSelection("[" + title + "][" + name + "]\n[" + name + "]: " + url + "");
if (selection === "") {
codeEditor.setCursor(cursor.line, cursor.ch + 1);
cm.setCursor(cursor.line, cursor.ch + 1);
}
this.hide().lockScreen(false).hideMask();
@ -846,7 +875,9 @@
}
},
image : function() {
image : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
var imageLang = lang.dialog.image;
var iframeName = classPrefix + "image-iframe";
var imageDialogName = classPrefix + "image-dialog", imageDialog;
@ -919,15 +950,15 @@
if (link === "" || link === "http://")
{
codeEditor.replaceSelection("![" + alt + "](" + url + " \"" + alt + "\")");
cm.replaceSelection("![" + alt + "](" + url + " \"" + alt + "\")");
}
else
{
codeEditor.replaceSelection("[![" + alt + "](" + url + " \"" + alt + "\")](" + link + " \"" + alt + "\")");
cm.replaceSelection("[![" + alt + "](" + url + " \"" + alt + "\")](" + link + " \"" + alt + "\")");
}
if (alt === "") {
codeEditor.setCursor(cursor.line, cursor.ch + 2);
cm.setCursor(cursor.line, cursor.ch + 2);
}
this.hide().lockScreen(false).hideMask();
@ -994,23 +1025,27 @@
});
},
code : function() {
code : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
codeEditor.replaceSelection("`" + selection + "`");
cm.replaceSelection("`" + selection + "`");
if (selection === "") {
codeEditor.setCursor(cursor.line, cursor.ch + 1);
cm.setCursor(cursor.line, cursor.ch + 1);
}
},
"code-block-tab" : function() {
"code-block-tab" : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
var tabCodeBlockDialogName = classPrefix + "dialog-tab-code-block", tabCodeBlockDialog;
if (editor.find("." + tabCodeBlockDialogName).length > 0)
{
tabCodeBlockDialog = editor.find("." + tabCodeBlockDialogName);
tabCodeBlockDialog.find("textarea").val("");
tabCodeBlockDialog.find("textarea").val(selection);
dialogShowMask(tabCodeBlockDialog);
dialogLockScreen();
@ -1018,7 +1053,7 @@
}
else
{
var tabCodeBlockDialogHTML = "<textarea placeholder=\"coding now....\" style=\"width: 680px;height: 300px;\"></textarea>";
var tabCodeBlockDialogHTML = "<textarea placeholder=\"coding now....\" style=\"width: 680px;height: 300px;\">" + selection + "</textarea>";
tabCodeBlockDialog = _this.createDialog({
name : tabCodeBlockDialogName,
@ -1050,7 +1085,7 @@
codeTexts[i] = " " + codeTexts[i];
}
codeEditor.replaceSelection(codeTexts.join("\n"));
cm.replaceSelection(codeTexts.join("\n"));
this.hide().lockScreen(false).hideMask();
@ -1066,15 +1101,16 @@
}
},
"code-block" : function() {
"code-block" : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
var codeBlockDialogName = classPrefix + "dialog-code-block", codeBlockDialog;
if (editor.find("." + codeBlockDialogName).length > 0)
{
codeBlockDialog = editor.find("." + codeBlockDialogName);
codeBlockDialog.find("option:first").attr("selected", "selected");
codeBlockDialog.find("textarea").val("");
codeBlockDialog.find("textarea").val(selection);
dialogShowMask(codeBlockDialog);
dialogLockScreen();
@ -1085,7 +1121,7 @@
var codeBlockDialogHTML = "<div class=\"" + classPrefix + "code-toolbar\">" +
lang.dialog.codeBlock.selectLabel + "<select><option selected=\"selected\" value=\"\">" + lang.dialog.codeBlock.selectDefaultText + "</option></select>" +
"</div>" +
"<textarea placeholder=\"coding now....\" style=\"width: 680px;height: 360px;\"></textarea>";
"<textarea placeholder=\"coding now....\" style=\"width: 680px;height: 360px;\">" + selection + "</textarea>";
codeBlockDialog = _this.createDialog({
name : codeBlockDialogName,
@ -1119,10 +1155,10 @@
langName = (langName === "other") ? "" : langName;
codeEditor.replaceSelection(["```" + langName, codeTexts, "```"].join("\n"));
cm.replaceSelection(["```" + langName, codeTexts, "```"].join("\n"));
if (langName === "") {
codeEditor.setCursor(cursor.line, cursor.ch + 3);
cm.setCursor(cursor.line, cursor.ch + 3);
}
this.hide().lockScreen(false).hideMask();
@ -1149,31 +1185,34 @@
}
},
datetime : function() {
var date = new Date();
var langName = settings.lang.name;
codeEditor.replaceSelection(editormd.dateFormat() + " " + editormd.dateFormat((langName === "zh-cn" || langName === "zh-tw") ? "cn-week-day" : "week-day"));
datetime : function(cm) {
var selection = cm.getSelection();
var date = new Date();
var langName = settings.lang.name;
var datefmt = editormd.dateFormat() + " " + editormd.dateFormat((langName === "zh-cn" || langName === "zh-tw") ? "cn-week-day" : "week-day");
cm.replaceSelection(datefmt);
},
watch : function() {
watch : function(cm) {
_this[_this.settings.watch ? "unwatch" : "watch"]();
},
preview : function() {
preview : function(cm) {
_this.previewing();
},
fullscreen : function() {
fullscreen : function(cm) {
_this.fullscreen();
},
clear : function() {
clear : function(cm) {
_this.clear();
},
info : function() {
info : function(cm) {
_this.showInfoDialog();
}
};
@ -1201,15 +1240,15 @@
var codeMirror = this.codeMirror;
var classPrefix = this.classPrefix;
var previewContainer = this.previewContainer;
var toolbarIcons = this.toolbarIcons = toolbar.find("." + classPrefix + "menu a");
var toolbarIconHandlers = _this.getToolbarHandles();
var toolbarIcons = this.toolbarIcons = toolbar.find("." + classPrefix + "menu a");
toolbarIcons.bind(editormd.mouseOrTouch("click", "touchend"), function(event) {
var icon = $(this).children(".fa");
var name = icon.attr("name");
var cursor = codeEditor.getCursor();
var selection = codeEditor.getSelection();
var icon = $(this).children(".fa");
var name = icon.attr("name");
var cursor = codeEditor.getCursor();
var selection = codeEditor.getSelection();
var toolbarIconHandlers = _this.getToolbarHandles();
if (name === "") {
return ;
@ -1219,7 +1258,7 @@
if (typeof toolbarIconHandlers[name] !== "undefined")
{
toolbarIconHandlers[name]();
toolbarIconHandlers[name](codeEditor);
}
else
{

6
dist/js/editormd.min.js

File diff suppressed because one or more lines are too long

4
dist/js/languages/en.js

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

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

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

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

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

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

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

2
docs/html/index.html

@ -121,7 +121,7 @@
<br clear="both">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Mon Feb 23 2015 13:48:47 GMT+0800 (中国标准时间)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Tue Feb 24 2015 09:24:29 GMT+0800 (中国标准时间)
</footer>
<script> prettyPrint(); </script>

2
lib/codemirror/addons.min.js

File diff suppressed because one or more lines are too long

2
lib/codemirror/modes.min.js

File diff suppressed because one or more lines are too long

2
package.json

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

207
src/js/editormd.js

@ -1,7 +1,7 @@
/**
* @fileOverview Editor.md
* @author pandao
* @version 1.1.3
* @version 1.1.4
*/
;(function(factory) {
@ -44,7 +44,7 @@
};
editormd.title = editormd.$name = "Editor.md";
editormd.version = "1.1.3";
editormd.version = "1.1.4";
editormd.homePage = "https://pandao.github.io/editor.md/";
editormd.classPrefix = "editormd-";
@ -544,18 +544,16 @@
/**
* 工具栏图标事件处理对象序列
* @param {Object} cm CodeMirror的实例对象
* @param {String} name 要获取的事件处理器名称
* @returns {Object} 返回处理对象序列
*/
getToolbarHandles : function(name) {
getToolbarHandles : function(name) {
var _this = this;
var settings = this.settings;
var lang = settings.lang;
var editor = this.editor;
var codeEditor = this.codeEditor;
var cursor = codeEditor.getCursor();
var selection = codeEditor.getSelection();
var classPrefix = this.classPrefix;
var dialogLockScreen = function() {
@ -576,71 +574,95 @@
};
var toolbarHandlers = this.toolbarHandlers = {
undo : function() {
codeEditor.undo();
undo : function(cm) {
cm.undo();
},
redo : function() {
codeEditor.redo();
redo : function(cm) {
cm.redo();
},
bold : function() {
codeEditor.replaceSelection("**" + selection + "**");
bold : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
cm.replaceSelection("**" + selection + "**");
if(selection === "") {
codeEditor.setCursor(cursor.line, cursor.ch + 2);
cm.setCursor(cursor.line, cursor.ch + 2);
}
},
del : function() {
codeEditor.replaceSelection("~~" + selection + "~~");
del : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
cm.replaceSelection("~~" + selection + "~~");
if(selection === "") {
codeEditor.setCursor(cursor.line, cursor.ch + 2);
cm.setCursor(cursor.line, cursor.ch + 2);
}
},
italic : function() {
codeEditor.replaceSelection("*" + selection + "*");
italic : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
cm.replaceSelection("*" + selection + "*");
if(selection === "") {
codeEditor.setCursor(cursor.line, cursor.ch + 1);
cm.setCursor(cursor.line, cursor.ch + 1);
}
},
quote : function() {
codeEditor.replaceSelection((selection === "") ? ["> " + selection, ""].join("\n") : "> " + selection);
codeEditor.setCursor(cursor.line, (selection === "") ? cursor.ch + 2 : cursor.ch + selection.length + 2);
quote : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
cm.replaceSelection((selection === "") ? ["> " + selection, ""].join("\n") : "> " + selection);
cm.setCursor(cursor.line, (selection === "") ? cursor.ch + 2 : cursor.ch + selection.length + 2);
},
h1 : function() {
codeEditor.replaceSelection("#" + selection);
h1 : function(cm) {
var selection = cm.getSelection();
cm.replaceSelection("#" + selection);
},
h2 : function() {
codeEditor.replaceSelection("##" + selection);
h2 : function(cm) {
var selection = cm.getSelection();
cm.replaceSelection("##" + selection);
},
h3 : function() {
codeEditor.replaceSelection("###" + selection);
h3 : function(cm) {
var selection = cm.getSelection();
cm.replaceSelection("###" + selection);
},
h4 : function() {
codeEditor.replaceSelection("####" + selection);
h4 : function(cm) {
var selection = cm.getSelection();
cm.replaceSelection("####" + selection);
},
h5 : function() {
codeEditor.replaceSelection("#####" + selection);
h5 : function(cm) {
var selection = cm.getSelection();
cm.replaceSelection("#####" + selection);
},
h6 : function() {
codeEditor.replaceSelection("######" + selection);
h6 : function(cm) {
var selection = cm.getSelection();
cm.replaceSelection("######" + selection);
},
"list-ul" : function() {
"list-ul" : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
if (selection === "")
{
codeEditor.replaceSelection("- " + selection);
cm.replaceSelection("- " + selection);
}
else
{
@ -651,15 +673,17 @@
selectionText[i] = (selectionText[i] === "") ? "" : "- " + selectionText[i];
}
codeEditor.replaceSelection(selectionText.join("\n"));
cm.replaceSelection(selectionText.join("\n"));
}
},
"list-ol" : function() {
"list-ol" : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
if(selection === "")
{
codeEditor.replaceSelection("1. " + selection);
cm.replaceSelection("1. " + selection);
}
else
{
@ -670,15 +694,19 @@
selectionText[i] = (selectionText[i] === "") ? "" : (i+1) + ". " + selectionText[i];
}
codeEditor.replaceSelection(selectionText.join("\n"));
cm.replaceSelection(selectionText.join("\n"));
}
},
hr : function() {
codeEditor.replaceSelection("------------");
hr : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
cm.replaceSelection("------------");
},
link : function() {
link : function(cm) {
var selection = cm.getSelection();
var linkLang = lang.dialog.link;
var linkDialogName = classPrefix + "link-dialog", linkDialog;
@ -732,7 +760,7 @@
return false;
}
codeEditor.replaceSelection("[" + title + "](" + url + " \""+title+"\")");
cm.replaceSelection("[" + title + "](" + url + " \""+title+"\")");
this.hide().lockScreen(false).hideMask();
@ -748,9 +776,10 @@
}
},
anchor : function() {
var anchorLang = lang.dialog.anchor;
anchor : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
var anchorLang = lang.dialog.anchor;
var anchorDialogName = classPrefix + "anchor-dialog", anchorDialog;
if (editor.find("." + anchorDialogName).length > 0)
@ -815,10 +844,10 @@
return false;
}
codeEditor.replaceSelection("[" + title + "][" + name + "]\n[" + name + "]: " + url + "");
cm.replaceSelection("[" + title + "][" + name + "]\n[" + name + "]: " + url + "");
if (selection === "") {
codeEditor.setCursor(cursor.line, cursor.ch + 1);
cm.setCursor(cursor.line, cursor.ch + 1);
}
this.hide().lockScreen(false).hideMask();
@ -835,7 +864,9 @@
}
},
image : function() {
image : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
var imageLang = lang.dialog.image;
var iframeName = classPrefix + "image-iframe";
var imageDialogName = classPrefix + "image-dialog", imageDialog;
@ -908,15 +939,15 @@
if (link === "" || link === "http://")
{
codeEditor.replaceSelection("![" + alt + "](" + url + " \"" + alt + "\")");
cm.replaceSelection("![" + alt + "](" + url + " \"" + alt + "\")");
}
else
{
codeEditor.replaceSelection("[![" + alt + "](" + url + " \"" + alt + "\")](" + link + " \"" + alt + "\")");
cm.replaceSelection("[![" + alt + "](" + url + " \"" + alt + "\")](" + link + " \"" + alt + "\")");
}
if (alt === "") {
codeEditor.setCursor(cursor.line, cursor.ch + 2);
cm.setCursor(cursor.line, cursor.ch + 2);
}
this.hide().lockScreen(false).hideMask();
@ -983,23 +1014,27 @@
});
},
code : function() {
code : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
codeEditor.replaceSelection("`" + selection + "`");
cm.replaceSelection("`" + selection + "`");
if (selection === "") {
codeEditor.setCursor(cursor.line, cursor.ch + 1);
cm.setCursor(cursor.line, cursor.ch + 1);
}
},
"code-block-tab" : function() {
"code-block-tab" : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
var tabCodeBlockDialogName = classPrefix + "dialog-tab-code-block", tabCodeBlockDialog;
if (editor.find("." + tabCodeBlockDialogName).length > 0)
{
tabCodeBlockDialog = editor.find("." + tabCodeBlockDialogName);
tabCodeBlockDialog.find("textarea").val("");
tabCodeBlockDialog.find("textarea").val(selection);
dialogShowMask(tabCodeBlockDialog);
dialogLockScreen();
@ -1007,7 +1042,7 @@
}
else
{
var tabCodeBlockDialogHTML = "<textarea placeholder=\"coding now....\" style=\"width: 680px;height: 300px;\"></textarea>";
var tabCodeBlockDialogHTML = "<textarea placeholder=\"coding now....\" style=\"width: 680px;height: 300px;\">" + selection + "</textarea>";
tabCodeBlockDialog = _this.createDialog({
name : tabCodeBlockDialogName,
@ -1039,7 +1074,7 @@
codeTexts[i] = " " + codeTexts[i];
}
codeEditor.replaceSelection(codeTexts.join("\n"));
cm.replaceSelection(codeTexts.join("\n"));
this.hide().lockScreen(false).hideMask();
@ -1055,15 +1090,16 @@
}
},
"code-block" : function() {
"code-block" : function(cm) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
var codeBlockDialogName = classPrefix + "dialog-code-block", codeBlockDialog;
if (editor.find("." + codeBlockDialogName).length > 0)
{
codeBlockDialog = editor.find("." + codeBlockDialogName);
codeBlockDialog.find("option:first").attr("selected", "selected");
codeBlockDialog.find("textarea").val("");
codeBlockDialog.find("textarea").val(selection);
dialogShowMask(codeBlockDialog);
dialogLockScreen();
@ -1074,7 +1110,7 @@
var codeBlockDialogHTML = "<div class=\"" + classPrefix + "code-toolbar\">" +
lang.dialog.codeBlock.selectLabel + "<select><option selected=\"selected\" value=\"\">" + lang.dialog.codeBlock.selectDefaultText + "</option></select>" +
"</div>" +
"<textarea placeholder=\"coding now....\" style=\"width: 680px;height: 360px;\"></textarea>";
"<textarea placeholder=\"coding now....\" style=\"width: 680px;height: 360px;\">" + selection + "</textarea>";
codeBlockDialog = _this.createDialog({
name : codeBlockDialogName,
@ -1108,10 +1144,10 @@
langName = (langName === "other") ? "" : langName;
codeEditor.replaceSelection(["```" + langName, codeTexts, "```"].join("\n"));
cm.replaceSelection(["```" + langName, codeTexts, "```"].join("\n"));
if (langName === "") {
codeEditor.setCursor(cursor.line, cursor.ch + 3);
cm.setCursor(cursor.line, cursor.ch + 3);
}
this.hide().lockScreen(false).hideMask();
@ -1138,31 +1174,34 @@
}
},
datetime : function() {
var date = new Date();
var langName = settings.lang.name;
codeEditor.replaceSelection(editormd.dateFormat() + " " + editormd.dateFormat((langName === "zh-cn" || langName === "zh-tw") ? "cn-week-day" : "week-day"));
datetime : function(cm) {
var selection = cm.getSelection();
var date = new Date();
var langName = settings.lang.name;
var datefmt = editormd.dateFormat() + " " + editormd.dateFormat((langName === "zh-cn" || langName === "zh-tw") ? "cn-week-day" : "week-day");
cm.replaceSelection(datefmt);
},
watch : function() {
watch : function(cm) {
_this[_this.settings.watch ? "unwatch" : "watch"]();
},
preview : function() {
preview : function(cm) {
_this.previewing();
},
fullscreen : function() {
fullscreen : function(cm) {
_this.fullscreen();
},
clear : function() {
clear : function(cm) {
_this.clear();
},
info : function() {
info : function(cm) {
_this.showInfoDialog();
}
};
@ -1190,15 +1229,15 @@
var codeMirror = this.codeMirror;
var classPrefix = this.classPrefix;
var previewContainer = this.previewContainer;
var toolbarIcons = this.toolbarIcons = toolbar.find("." + classPrefix + "menu a");
var toolbarIconHandlers = _this.getToolbarHandles();
var toolbarIcons = this.toolbarIcons = toolbar.find("." + classPrefix + "menu a");
toolbarIcons.bind(editormd.mouseOrTouch("click", "touchend"), function(event) {
var icon = $(this).children(".fa");
var name = icon.attr("name");
var cursor = codeEditor.getCursor();
var selection = codeEditor.getSelection();
var icon = $(this).children(".fa");
var name = icon.attr("name");
var cursor = codeEditor.getCursor();
var selection = codeEditor.getSelection();
var toolbarIconHandlers = _this.getToolbarHandles();
if (name === "") {
return ;
@ -1208,7 +1247,7 @@
if (typeof toolbarIconHandlers[name] !== "undefined")
{
toolbarIconHandlers[name]();
toolbarIconHandlers[name](codeEditor);
}
else
{

81
src/scss/editormd.logo.scss

@ -0,0 +1,81 @@
@charset "UTF-8";
@import "lib/variables";
@import "lib/functions";
@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;
}

77
src/scss/editormd.scss

@ -41,82 +41,7 @@
}
}
@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;
}
@import "editormd.logo";
#{$prefix}user-unselect {
@include user-select(none);

Loading…
Cancel
Save