mirror of
https://github.com/sparksuite/simplemde-markdown-editor.git
synced 2025-07-23 09:54:28 -06:00
Gulp now pretty formats JS and CSS
This commit is contained in:
parent
b43b99e50d
commit
8218391cfd
16
gulpfile.js
16
gulpfile.js
@ -4,7 +4,7 @@ var gulp = require('gulp'),
|
||||
concat = require('gulp-concat'),
|
||||
header = require('gulp-header'),
|
||||
pkg = require('./package.json'),
|
||||
beautify = require('gulp-beautify');
|
||||
prettify = require('gulp-jsbeautifier');
|
||||
|
||||
var banner = ['/**',
|
||||
' * <%= pkg.name %> v<%= pkg.version %>',
|
||||
@ -46,10 +46,16 @@ gulp.task('styles', function() {
|
||||
.pipe(gulp.dest('dist'));
|
||||
});
|
||||
|
||||
gulp.task('beautify', function() {
|
||||
gulp.task('prettify-js', function() {
|
||||
gulp.src('./src/js/simplemde.js')
|
||||
.pipe(beautify({indentSize: 4}))
|
||||
.pipe(gulp.dest('./src/js/test'))
|
||||
.pipe(prettify({js: {braceStyle: "collapse", indentChar: "\t", indentSize: 1, maxPreserveNewlines: 3, spaceBeforeConditional: false}}))
|
||||
.pipe(gulp.dest('./src/js'));
|
||||
});
|
||||
|
||||
gulp.task('default', ['scripts', 'styles', 'beautify']);
|
||||
gulp.task('prettify-css', function() {
|
||||
gulp.src('./src/css/simplemde.css')
|
||||
.pipe(prettify({css: {indentChar: "\t", indentSize: 1}}))
|
||||
.pipe(gulp.dest('./src/css'));
|
||||
});
|
||||
|
||||
gulp.task('default', ['scripts', 'styles', 'prettify-js', 'prettify-css']);
|
@ -20,7 +20,7 @@
|
||||
"gulp-uglify": "*",
|
||||
"gulp-concat": "*",
|
||||
"gulp-header": "*",
|
||||
"gulp-beautify": "*"
|
||||
"gulp-jsbeautifier": "*"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -43,7 +43,8 @@
|
||||
border-top-right-radius: 4px;
|
||||
}
|
||||
|
||||
.editor-toolbar:after, .editor-toolbar:before {
|
||||
.editor-toolbar:after,
|
||||
.editor-toolbar:before {
|
||||
display: block;
|
||||
content: ' ';
|
||||
height: 1px;
|
||||
@ -57,7 +58,9 @@
|
||||
margin-top: 8px
|
||||
}
|
||||
|
||||
.editor-toolbar:hover, .editor-wrapper input.title:focus, .editor-wrapper input.title:hover {
|
||||
.editor-toolbar:hover,
|
||||
.editor-wrapper input.title:focus,
|
||||
.editor-wrapper input.title:hover {
|
||||
opacity: .8
|
||||
}
|
||||
|
||||
@ -89,7 +92,8 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.editor-toolbar a.active, .editor-toolbar a:hover {
|
||||
.editor-toolbar a.active,
|
||||
.editor-toolbar a:hover {
|
||||
background: #fcfcfc;
|
||||
border-color: #95a5a6;
|
||||
}
|
||||
@ -191,16 +195,21 @@
|
||||
display: block
|
||||
}
|
||||
|
||||
.editor-preview>p, .editor-preview-side>p {
|
||||
.editor-preview>p,
|
||||
.editor-preview-side>p {
|
||||
margin-top: 0
|
||||
}
|
||||
|
||||
.editor-preview pre, .editor-preview-side pre {
|
||||
.editor-preview pre,
|
||||
.editor-preview-side pre {
|
||||
background: #eee;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.editor-preview table td, .editor-preview table th, .editor-preview-side table td, .editor-preview-side table th {
|
||||
.editor-preview table td,
|
||||
.editor-preview table th,
|
||||
.editor-preview-side table td,
|
||||
.editor-preview-side table th {
|
||||
border: 1px solid #ddd;
|
||||
padding: 5px;
|
||||
}
|
||||
|
@ -426,38 +426,29 @@ function _toggleHeading(cm, direction, size) {
|
||||
text = '#' + text;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
if(size == 1) {
|
||||
if(currHeadingLevel <= 0) {
|
||||
text = '# ' + text;
|
||||
}
|
||||
else if(currHeadingLevel == size){
|
||||
} else if(currHeadingLevel == size) {
|
||||
text = text.substr(currHeadingLevel + 1);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
text = '# ' + text.substr(currHeadingLevel + 1);
|
||||
}
|
||||
}
|
||||
else if(size == 2){
|
||||
} else if(size == 2) {
|
||||
if(currHeadingLevel <= 0) {
|
||||
text = '## ' + text;
|
||||
}
|
||||
else if(currHeadingLevel == size){
|
||||
} else if(currHeadingLevel == size) {
|
||||
text = text.substr(currHeadingLevel + 1);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
text = '## ' + text.substr(currHeadingLevel + 1);
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
if(currHeadingLevel <= 0) {
|
||||
text = '### ' + text;
|
||||
}
|
||||
else if(currHeadingLevel == size){
|
||||
} else if(currHeadingLevel == size) {
|
||||
text = text.substr(currHeadingLevel + 1);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
text = '### ' + text.substr(currHeadingLevel + 1);
|
||||
}
|
||||
}
|
||||
@ -913,7 +904,11 @@ SimpleMDE.prototype.createSidebyside = function() {
|
||||
var cScroll = false;
|
||||
var pScroll = false;
|
||||
cm.on('scroll', function(v) {
|
||||
if (cScroll){cScroll=false; return;}; pScroll=true;
|
||||
if(cScroll) {
|
||||
cScroll = false;
|
||||
return;
|
||||
};
|
||||
pScroll = true;
|
||||
height = v.getScrollInfo().height - v.getScrollInfo().clientHeight;
|
||||
ratio = parseFloat(v.getScrollInfo().top) / height;
|
||||
move = (preview.scrollHeight - preview.clientHeight) * ratio;
|
||||
@ -922,7 +917,11 @@ SimpleMDE.prototype.createSidebyside = function() {
|
||||
|
||||
// Syncs scroll preview -> editor
|
||||
preview.onscroll = function(v) {
|
||||
if (pScroll){pScroll=false; return;}; cScroll=true;
|
||||
if(pScroll) {
|
||||
pScroll = false;
|
||||
return;
|
||||
};
|
||||
cScroll = true;
|
||||
height = preview.scrollHeight - preview.clientHeight;
|
||||
ratio = parseFloat(preview.scrollTop) / height;
|
||||
move = (cm.getScrollInfo().height - cm.getScrollInfo().clientHeight) * ratio;
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user