WIP: build project

pull/776/head
Nguyễn Đình Lĩnh 4 years ago
parent 6abda7ab68
commit f294b4d954

@ -2,7 +2,7 @@
var gulp = require("gulp"),
minifycss = require("gulp-clean-css"),
uglify = require("gulp-uglify"),
uglify = require("gulp-uglify-es").default,
concat = require("gulp-concat"),
header = require("gulp-header"),
buffer = require("vinyl-buffer"),
@ -22,48 +22,95 @@ var banner = ["/**",
" */",
""].join("\n");
gulp.task("prettify-js", [], function() {
// gulp.task("prettify-js", [], function() {
// return gulp.src("./src/js/simplemde.js")
// .pipe(prettify({js: {brace_style: "collapse", indent_char: "\t", indent_size: 1, max_preserve_newlines: 3, space_before_conditional: false}}))
// .pipe(gulp.dest("./src/js"));
// });
gulp.task("prettify-js", function(){
return gulp.src("./src/js/simplemde.js")
.pipe(prettify({js: {brace_style: "collapse", indent_char: "\t", indent_size: 1, max_preserve_newlines: 3, space_before_conditional: false}}))
.pipe(gulp.dest("./src/js"));
});
gulp.task("prettify-css", [], function() {
// gulp.task("prettify-css", [], function() {
// return gulp.src("./src/css/simplemde.css")
// .pipe(prettify({css: {indentChar: "\t", indentSize: 1}}))
// .pipe(gulp.dest("./src/css"));
// });
gulp.task("prettify-css", function(){
return gulp.src("./src/css/simplemde.css")
.pipe(prettify({css: {indentChar: "\t", indentSize: 1}}))
.pipe(gulp.dest("./src/css"));
});
gulp.task("lint", ["prettify-js"], function() {
gulp.src("./src/js/**/*.js")
// gulp.task("lint", ["prettify-js"], function() {
// gulp.src("./src/js/**/*.js")
// .pipe(debug())
// .pipe(eslint())
// .pipe(eslint.format())
// .pipe(eslint.failAfterError());
// });
gulp.task("lint", gulp.series("prettify-js", function(){
return gulp.src("./src/js/**/*.js")
.pipe(debug())
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
}));
function taskBrowserify(opts) {
return browserify("./src/js/simplemde.js", opts)
.bundle();
}
gulp.task("browserify:debug", ["lint"], function() {
// gulp.task("browserify:debug", ["lint"], function() {
// return taskBrowserify({debug:true, standalone:"SimpleMDE"})
// .pipe(source("simplemde.debug.js"))
// .pipe(buffer())
// .pipe(header(banner, {pkg: pkg}))
// .pipe(gulp.dest("./debug/"));
// });
gulp.task("browserify:debug", gulp.series("lint", function(){
return taskBrowserify({debug:true, standalone:"SimpleMDE"})
.pipe(source("simplemde.debug.js"))
.pipe(buffer())
.pipe(header(banner, {pkg: pkg}))
.pipe(gulp.dest("./debug/"));
});
}));
// gulp.task("browserify", ["lint"], function() {
// return taskBrowserify({standalone:"SimpleMDE"})
// .pipe(source("simplemde.js"))
// .pipe(buffer())
// .pipe(header(banner, {pkg: pkg}))
// .pipe(gulp.dest("./debug/"));
// });
gulp.task("browserify", ["lint"], function() {
gulp.task("browserify", gulp.series("lint", function(){
return taskBrowserify({standalone:"SimpleMDE"})
.pipe(source("simplemde.js"))
.pipe(buffer())
.pipe(header(banner, {pkg: pkg}))
.pipe(gulp.dest("./debug/"));
});
}));
// gulp.task("scripts", ["browserify:debug", "browserify", "lint"], function() {
// var js_files = ["./debug/simplemde.js"];
// return gulp.src(js_files)
// .pipe(concat("simplemde.min.js"))
// .pipe(uglify())
// .pipe(buffer())
// .pipe(header(banner, {pkg: pkg}))
// .pipe(gulp.dest("./dist/"));
// });
gulp.task("scripts", ["browserify:debug", "browserify", "lint"], function() {
gulp.task("scripts", gulp.series(gulp.parallel("browserify:debug", "browserify", "lint"), function(){
var js_files = ["./debug/simplemde.js"];
return gulp.src(js_files)
@ -72,9 +119,28 @@ gulp.task("scripts", ["browserify:debug", "browserify", "lint"], function() {
.pipe(buffer())
.pipe(header(banner, {pkg: pkg}))
.pipe(gulp.dest("./dist/"));
});
}));
gulp.task("styles", ["prettify-css"], function() {
// gulp.task("styles", ["prettify-css"], function() {
// var css_files = [
// "./node_modules/codemirror/lib/codemirror.css",
// "./src/css/*.css",
// "./node_modules/codemirror-spell-checker/src/css/spell-checker.css"
// ];
// return gulp.src(css_files)
// .pipe(concat("simplemde.css"))
// .pipe(buffer())
// .pipe(header(banner, {pkg: pkg}))
// .pipe(gulp.dest("./debug/"))
// .pipe(minifycss())
// .pipe(rename("simplemde.min.css"))
// .pipe(buffer())
// .pipe(header(banner, {pkg: pkg}))
// .pipe(gulp.dest("./dist/"));
// });
gulp.task("styles", gulp.series("prettify-css", function(){
var css_files = [
"./node_modules/codemirror/lib/codemirror.css",
"./src/css/*.css",
@ -91,6 +157,8 @@ gulp.task("styles", ["prettify-css"], function() {
.pipe(buffer())
.pipe(header(banner, {pkg: pkg}))
.pipe(gulp.dest("./dist/"));
});
}));
// gulp.task("default", ["scripts", "styles"]);
gulp.task("default", ["scripts", "styles"]);
gulp.task("default", gulp.series(gulp.parallel("scripts", "styles")));

6191
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -21,25 +21,25 @@
"url": "https://github.com/NextStepWebs/simplemde-markdown-editor/issues"
},
"dependencies": {
"codemirror": "*",
"codemirror-spell-checker": "*",
"marked": "*"
"codemirror": "^5.52.0",
"codemirror-spell-checker": "^1.1.2",
"marked": "^0.8.0"
},
"devDependencies": {
"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": "*"
"browserify": "^16.5.0",
"debug": "^4.1.1",
"eslint": "^6.8.0",
"gulp": "^4.0.2",
"gulp-concat": "^2.6.1",
"gulp-debug": "^4.0.0",
"gulp-eslint": "^6.0.0",
"gulp-header": "^2.0.9",
"gulp-jsbeautifier": "^3.0.1",
"gulp-clean-css": "^4.2.0",
"gulp-rename": "^2.0.0",
"gulp-uglify-es": "^2.0.0",
"vinyl-source-stream": "^2.0.0",
"vinyl-buffer": "^1.0.1"
},
"repository": {
"type": "git",

@ -118,8 +118,8 @@
.editor-toolbar a {
display: inline-block;
text-align: center;
text-decoration: none!important;
color: #2c3e50!important;
text-decoration: none !important;
color: #2c3e50 !important;
width: 30px;
height: 30px;
margin: 0;

@ -1,4 +1,3 @@
/*global require,module*/
"use strict";
var CodeMirror = require("codemirror");
require("codemirror/addon/edit/continuelist.js");
@ -72,7 +71,7 @@ var getBindingName = function(f) {
var isMobile = function() {
var check = false;
(function(a) {
if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true;
if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(a.substr(0, 4))) check = true;
})(navigator.userAgent || navigator.vendor || window.opera);
return check;
};
@ -171,7 +170,7 @@ function getState(cm, pos) {
ret.link = true;
} else if(data === "tag") {
ret.image = true;
} else if(data.match(/^header(\-[1-6])?$/)) {
} else if(data.match(/^header(-[1-6])?$/)) {
ret[data.replace("header", "heading")] = true;
}
}
@ -181,6 +180,36 @@ function getState(cm, pos) {
// Saved overflow setting
var saved_overflow = "";
var CLASS_FULL_SCREEN = "fullscreen";
var CLASS_ACTIVE = "active";
function setFullScreen(editor) {
// Set fullscreen
var cm = editor.codemirror;
saved_overflow = document.body.style.overflow;
document.body.style.overflow = "hidden";
// Update toolbar class
var wrap = cm.getWrapperElement();
wrap.previousSibling.classList.add(CLASS_FULL_SCREEN);
// Update toolbar button
var toolbarButton = editor.toolbarElements.fullscreen;
toolbarButton.classList.add(CLASS_ACTIVE);
}
function setNotFullScreen(editor) {
// Set fullscreen
var cm = editor.codemirror;
document.body.style.overflow = saved_overflow;
saved_overflow = "";
// Update toolbar class
var wrap = cm.getWrapperElement();
wrap.previousSibling.classList.remove(CLASS_FULL_SCREEN);
// Update toolbar button
var toolbarButton = editor.toolbarElements.fullscreen;
toolbarButton.classList.remove(CLASS_ACTIVE);
}
/**
* Toggle full screen of the editor.
@ -193,33 +222,11 @@ function toggleFullScreen(editor) {
// Prevent scrolling on body during fullscreen active
if(cm.getOption("fullScreen")) {
saved_overflow = document.body.style.overflow;
document.body.style.overflow = "hidden";
setFullScreen(editor);
} else {
document.body.style.overflow = saved_overflow;
setNotFullScreen(editor);
}
// Update toolbar class
var wrap = cm.getWrapperElement();
if(!/fullscreen/.test(wrap.previousSibling.className)) {
wrap.previousSibling.className += " fullscreen";
} else {
wrap.previousSibling.className = wrap.previousSibling.className.replace(/\s*fullscreen\b/, "");
}
// Update toolbar button
var toolbarButton = editor.toolbarElements.fullscreen;
if(!/active/.test(toolbarButton.className)) {
toolbarButton.className += " active";
} else {
toolbarButton.className = toolbarButton.className.replace(/\s*active\s*/g, "");
}
// Hide side by side if needed
var sidebyside = cm.getWrapperElement().nextSibling;
if(/editor-preview-active-side/.test(sidebyside.className))
@ -900,8 +907,8 @@ function _toggleLine(cm, name) {
var startPoint = cm.getCursor("start");
var endPoint = cm.getCursor("end");
var repl = {
"quote": /^(\s*)\>\s+/,
"unordered-list": /^(\s*)(\*|\-|\+)\s+/,
"quote": /^(\s*)>\s+/,
"unordered-list": /^(\s*)(\*|-|\+)\s+/,
"ordered-list": /^(\s*)\d+\.\s+/
};
var map = {
@ -1008,7 +1015,7 @@ function _cleanBlock(cm) {
for(var line = startPoint.line; line <= endPoint.line; line++) {
text = cm.getLine(line);
text = text.replace(/^[ ]*([# ]+|\*|\-|[> ]+|[0-9]+(.|\)))[ ]*/, "");
text = text.replace(/^[ ]*([# ]+|\*|-|[> ]+|[0-9]+(.|\)))[ ]*/, "");
cm.replaceRange(text, {
line: line,
@ -1023,6 +1030,7 @@ function _cleanBlock(cm) {
// Merge the properties of one object into another.
function _mergeProperties(target, source) {
for(var property in source) {
// eslint-disable-next-line no-prototype-builtins
if(source.hasOwnProperty(property)) {
if(source[property] instanceof Array) {
target[property] = source[property].concat(target[property] instanceof Array ? target[property] : []);
@ -1315,6 +1323,7 @@ function SimpleMDE(options) {
// Loop over the built in buttons, to get the preferred order
for(var key in toolbarBuiltInButtons) {
// eslint-disable-next-line no-prototype-builtins
if(toolbarBuiltInButtons.hasOwnProperty(key)) {
if(key.indexOf("separator-") != -1) {
options.toolbar.push("|");
@ -1329,6 +1338,7 @@ function SimpleMDE(options) {
// Handle status bar
// eslint-disable-next-line no-prototype-builtins
if(!options.hasOwnProperty("status")) {
options.status = ["autosave", "lines", "words", "cursor"];
}
@ -1532,7 +1542,7 @@ function isLocalStorageAvailable() {
try {
localStorage.setItem("smde_localStorage", 1);
localStorage.removeItem("smde_localStorage");
} catch(e) {
} catch (e) {
return false;
}
} else {

Loading…
Cancel
Save