Merge pull request #353 from NextStepWebs/development

Development
master 1.11.0
Wes Cossick 8 years ago
commit 316b8a58f8

@ -1,5 +1,6 @@
language: node_js
node_js:
- '6'
- '5'
- '4'
- '0.12'

@ -20,11 +20,11 @@ Via [bower](https://www.bower.io).
bower install simplemde --save
```
Via [jsDelivr](http://www.jsdelivr.com/#!simplemde). *Please note, jsDelivr may take a few days to update to the latest release.*
Via [jsDelivr](https://www.jsdelivr.com/#!simplemde). *Please note, jsDelivr may take a few days to update to the latest release.*
```HTML
<link rel="stylesheet" href="//cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
<script src="//cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
```
## Quick start
@ -103,6 +103,7 @@ simplemde.value("This text will appear in the editor");
- **spellChecker**: If set to `false`, disable the spell checker. Defaults to `true`.
- **status**: If set to `false`, hide the status bar. Defaults to the array of built-in status bar items.
- Optionally, you can set an array of status bar items to include, and in what order. You can even define your own custom status bar items.
- **styleSelectedText**: If set to `false`, remove the `CodeMirror-selectedtext` class from selected lines. Defaults to `true`.
- **tabSize**: If set, customize the tab size. Defaults to `2`.
- **toolbar**: If set to `false`, hide the toolbar. Defaults to the [array of icons](#toolbar-icons).
- **toolbarTips**: If set to `false`, disable toolbar button tips. Defaults to `true`.
@ -170,6 +171,7 @@ var simplemde = new SimpleMDE({
el.innerHTML = ++this.keystrokes + " Keystrokes";
}
}], // Another optional usage, with a custom status bar item that counts keystrokes
styleSelectedText: false,
tabSize: 4,
toolbar: false,
toolbarTips: false,
@ -225,7 +227,7 @@ var simplemde = new SimpleMDE({
},
{
name: "custom",
action: customFunction(editor){
action: function customFunction(editor){
// Add your own code
},
className: "fa fa-star",
@ -324,6 +326,6 @@ simplemde.clearAutosavedValue(); // no returned value
```
## How it works
SimpleMDE began as an improvement of [lepture's Editor project](https://github.com/lepture/editor), but has now taken on an identity of its own. It is bundled with [CodeMirror](https://github.com/codemirror/codemirror) and depends on [Font Awesome](http://fortawesome.github.io/Font-Awesome/).
SimpleMDE began as an improvement of [lepture's Editor project](https://github.com/lepture/editor), but has now taken on an identity of its own. It is bundled with [CodeMirror](https://github.com/codemirror/codemirror) and depends on [Font Awesome](http://fontawesome.io).
CodeMirror is the backbone of the project and parses much of the Markdown syntax as it's being written. This allows us to add styles to the Markdown that's being written. Additionally, a toolbar and status bar have been added to the top and bottom, respectively. Previews are rendered by [Marked](https://github.com/chjj/marked) using GFM.

@ -1,25 +1,23 @@
{
"name": "simplemde",
"version": "1.10.1",
"homepage": "https://github.com/NextStepWebs/simplemde-markdown-editor",
"authors": [
"Wes Cossick"
],
"description": "A simple, beautiful, and embeddable JavaScript Markdown editor.",
"main": ["dist/simplemde.min.js", "dist/simplemde.min.css"],
"moduleType": [
"globals"
],
"keywords": [
"embeddable",
"markdown",
"editor",
"javascript",
"wysiwyg"
],
"license": "MIT",
"ignore": [
"node_modules",
"bower_components"
]
"name": "simplemde",
"version": "1.11.0",
"homepage": "https://github.com/NextStepWebs/simplemde-markdown-editor",
"authors": [
"Wes Cossick <https://wescossick.com>"
],
"description": "A simple, beautiful, and embeddable JavaScript Markdown editor.",
"main": ["src/js/simplemde.js", "src/css/simplemde.css"],
"keywords": [
"embeddable",
"markdown",
"editor",
"javascript",
"wysiwyg"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components"
]
}

@ -1,5 +1,5 @@
/**
* simplemde v1.10.1
* simplemde v1.11.0
* Copyright Next Step Webs, Inc.
* @link https://github.com/NextStepWebs/simplemde-markdown-editor
* @license MIT
@ -58,7 +58,7 @@
}
.cm-fat-cursor .CodeMirror-cursor {
width: auto;
border: 0;
border: 0 !important;
background: #7e7;
}
.cm-fat-cursor div.CodeMirror-cursors {
@ -197,6 +197,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
.CodeMirror-gutters {
position: absolute; left: 0; top: 0;
min-height: 100%;
z-index: 3;
}
.CodeMirror-gutter {
@ -251,6 +252,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
position: relative;
overflow: visible;
-webkit-tap-highlight-color: transparent;
-webkit-font-variant-ligatures: none;
font-variant-ligatures: none;
}
.CodeMirror-wrap pre {
word-wrap: break-word;
@ -669,5 +672,5 @@ span.CodeMirror-selectedtext { background: none; }
opacity: .5;
}
.CodeMirror .cm-spell-error:not(.cm-url):not(.cm-comment):not(.cm-tag):not(.cm-word) {
background: rgba(255, 0, 0, .15);
background: rgba(255, 0, 0, .15);
}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,6 +1,7 @@
"use strict";
var gulp = require("gulp"),
minifycss = require("gulp-minify-css"),
minifycss = require("gulp-clean-css"),
uglify = require("gulp-uglify"),
concat = require("gulp-concat"),
header = require("gulp-header"),
@ -8,11 +9,10 @@ var gulp = require("gulp"),
pkg = require("./package.json"),
debug = require("gulp-debug"),
eslint = require("gulp-eslint"),
prettify = require("gulp-jsbeautifier");
var browserify = require("browserify");
var source = require("vinyl-source-stream");
var rename = require("gulp-rename");
prettify = require("gulp-jsbeautifier"),
browserify = require("browserify"),
source = require("vinyl-source-stream"),
rename = require("gulp-rename");
var banner = ["/**",
" * <%= pkg.name %> v<%= pkg.version %>",
@ -45,10 +45,9 @@ gulp.task("lint", ["prettify-js"], function() {
function taskBrowserify(opts) {
return browserify("./src/js/simplemde.js", opts)
.bundle();
}
gulp.task("browserify:dev", ["lint"], function() {
gulp.task("browserify:debug", ["lint"], function() {
return taskBrowserify({debug:true, standalone:"SimpleMDE"})
.pipe(source("simplemde.debug.js"))
.pipe(buffer())
@ -56,7 +55,7 @@ gulp.task("browserify:dev", ["lint"], function() {
.pipe(gulp.dest("./debug/"));
});
gulp.task("browserify:min", ["lint"], function() {
gulp.task("browserify", ["lint"], function() {
return taskBrowserify({standalone:"SimpleMDE"})
.pipe(source("simplemde.js"))
.pipe(buffer())
@ -64,7 +63,7 @@ gulp.task("browserify:min", ["lint"], function() {
.pipe(gulp.dest("./debug/"));
});
gulp.task("scripts", ["browserify:dev", "browserify:min", "lint"], function() {
gulp.task("scripts", ["browserify:debug", "browserify", "lint"], function() {
var js_files = ["./debug/simplemde.js"];
return gulp.src(js_files)

@ -1,69 +1,48 @@
{
"name": "simplemde",
"version": "1.10.1",
"version": "1.11.0",
"description": "A simple, beautiful, and embeddable JavaScript Markdown editor. Features autosaving and spell checking.",
"keywords": [
"embeddable",
"markdown",
"editor",
"javascript",
"wysiwyg"
"embeddable",
"markdown",
"editor",
"javascript",
"wysiwyg"
],
"homepage": "https://github.com/NextStepWebs/simplemde-markdown-editor",
"main": "./src/js/simplemde.js",
"license": "MIT",
"company": "Next Step Webs, Inc.",
"author": {
"name": "Wes Cossick",
"url": "http://www.WesCossick.com"
"name": "Wes Cossick",
"url": "http://www.WesCossick.com"
},
"bugs": {
"url": "https://github.com/NextStepWebs/simplemde-markdown-editor/issues"
"url": "https://github.com/NextStepWebs/simplemde-markdown-editor/issues"
},
"dependencies": {
"codemirror": "codemirror/CodeMirror",
"codemirror-spell-checker": "nextstepwebs/codemirror-spell-checker",
"marked": "0.3.5"
"codemirror": "*",
"codemirror-spell-checker": "*",
"marked": "*"
},
"devDependencies": {
"browserify": "^11.2.0",
"browserify-shim": "^3.8.10",
"debug": "^2.2.0",
"eslint": "*",
"gulp": "*",
"gulp-concat": "*",
"gulp-debug": "^2.1.1",
"gulp-eslint": "*",
"gulp-header": "*",
"gulp-jsbeautifier": "*",
"gulp-minify-css": "^1.2.1",
"gulp-rename": "^1.2.2",
"gulp-uglify": "*",
"vinyl-source-stream": "*",
"vinyl-buffer": "*"
},
"browserify": {
"transform": [
"browserify-shim"
]
},
"browser": {
"spell-checker": "./node_modules/codemirror-spell-checker/src/js/spell-checker.js",
"typo": "./node_modules/codemirror-spell-checker/src/js/typo.js"
},
"browserify-shim": {
"spell-checker": {
"depends": [
"typo:Typo",
"codemirror:CodeMirror"
]
},
"typo": {
"exports": "Typo"
}
"browserify": "*",
"debug": "*",
"eslint": "*",
"gulp": "*",
"gulp-concat": "*",
"gulp-debug": "*",
"gulp-eslint": "*",
"gulp-header": "*",
"gulp-jsbeautifier": "*",
"gulp-clean-css": "*",
"gulp-rename": "*",
"gulp-uglify": "*",
"vinyl-source-stream": "*",
"vinyl-buffer": "*"
},
"repository": {
"type": "git",
"url": "https://github.com/NextStepWebs/simplemde-markdown-editor"
"type": "git",
"url": "https://github.com/NextStepWebs/simplemde-markdown-editor"
}
}

@ -7,9 +7,10 @@ require("codemirror/addon/display/fullscreen.js");
require("codemirror/mode/markdown/markdown.js");
require("codemirror/addon/mode/overlay.js");
require("codemirror/addon/display/placeholder.js");
require("codemirror/addon/selection/mark-selection.js");
require("codemirror/mode/gfm/gfm.js");
require("codemirror/mode/xml/xml.js");
require("spell-checker");
var CodeMirrorSpellChecker = require("codemirror-spell-checker");
var marked = require("marked");
@ -739,6 +740,9 @@ function toggleSideBySide(editor) {
} else {
cm.off("update", cm.sideBySideRenderingFunction);
}
// Refresh to fix selection being off (#309)
cm.refresh();
}
@ -1048,7 +1052,7 @@ function extend(target) {
/* The right word count in respect for CJK. */
function wordCount(data) {
var pattern = /[a-zA-Z0-9_\u0392-\u03c9]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/g;
var pattern = /[a-zA-Z0-9_\u0392-\u03c9\u0410-\u04F9]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/g;
var m = data.match(pattern);
var count = 0;
if(m === null) return count;
@ -1238,7 +1242,7 @@ var toolbarBuiltInButtons = {
var insertTexts = {
link: ["[", "](#url#)"],
image: ["![", "](#url#)"],
image: ["![](", "#url#)"],
table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],
horizontalRule: ["", "\n\n-----\n\n"]
};
@ -1465,6 +1469,10 @@ SimpleMDE.prototype.render = function(el) {
backdrop = options.parsingConfig;
backdrop.name = "gfm";
backdrop.gitHubSpice = false;
CodeMirrorSpellChecker({
codeMirrorInstance: CodeMirror
});
} else {
mode = options.parsingConfig;
mode.name = "gfm";
@ -1483,7 +1491,8 @@ SimpleMDE.prototype.render = function(el) {
extraKeys: keyMaps,
lineWrapping: (options.lineWrapping === false) ? false : true,
allowDropFileTypes: ["text/plain"],
placeholder: options.placeholder || el.getAttribute("placeholder") || ""
placeholder: options.placeholder || el.getAttribute("placeholder") || "",
styleSelectedText: (options.styleSelectedText != undefined) ? options.styleSelectedText : true
});
if(options.forceSync === true) {
@ -1508,6 +1517,13 @@ SimpleMDE.prototype.render = function(el) {
this.gui.sideBySide = this.createSideBySide();
this._rendered = this.element;
// Fixes CodeMirror bug (#344)
var temp_cm = this.codemirror;
setTimeout(function() {
temp_cm.refresh();
}.bind(temp_cm), 0);
};
// Safari, in Private Browsing Mode, looks like it supports localStorage but all calls to setItem throw QuotaExceededError. We're going to detect this and set a variable accordingly.
@ -1672,9 +1688,7 @@ SimpleMDE.prototype.createToolbar = function(items) {
var nonSeparatorIconsFollow = false;
for(var x = (i + 1); x < items.length; x++) {
console.log(x);
if(items[x] !== "|" && (!self.options.hideIcons || self.options.hideIcons.indexOf(items[x].name) == -1)) {
console.log(items[x]);
nonSeparatorIconsFollow = true;
}
}
@ -1696,7 +1710,8 @@ SimpleMDE.prototype.createToolbar = function(items) {
// bind events, special for info
if(item.action) {
if(typeof item.action === "function") {
el.onclick = function() {
el.onclick = function(e) {
e.preventDefault();
item.action(self);
};
} else if(typeof item.action === "string") {
@ -1767,14 +1782,14 @@ SimpleMDE.prototype.createStatusbar = function(status) {
if(name === "words") {
defaultValue = function(el) {
el.innerHTML = "0";
el.innerHTML = wordCount(cm.getValue());
};
onUpdate = function(el) {
el.innerHTML = wordCount(cm.getValue());
};
} else if(name === "lines") {
defaultValue = function(el) {
el.innerHTML = "0";
el.innerHTML = cm.lineCount();
};
onUpdate = function(el) {
el.innerHTML = cm.lineCount();
@ -1989,9 +2004,17 @@ SimpleMDE.prototype.toTextArea = function() {
var cm = this.codemirror;
var wrapper = cm.getWrapperElement();
wrapper.parentNode.removeChild(this.gui.toolbar);
wrapper.parentNode.removeChild(this.gui.statusbar);
wrapper.parentNode.removeChild(this.gui.sideBySide);
if(wrapper.parentNode) {
if(this.gui.toolbar) {
wrapper.parentNode.removeChild(this.gui.toolbar);
}
if(this.gui.statusbar) {
wrapper.parentNode.removeChild(this.gui.statusbar);
}
if(this.gui.sideBySide) {
wrapper.parentNode.removeChild(this.gui.sideBySide);
}
}
cm.toTextArea();

Loading…
Cancel
Save