Skip to content

Commit 573a5a7

Browse files
committed
feat: add character count based on Ionaru#304
1 parent a6b121f commit 573a5a7

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

gulpfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ function lint() {
3636

3737
function scripts() {
3838
return browserify({entries: './src/js/easymde.js', standalone: 'EasyMDE'}).bundle()
39-
.pipe(source('easymde.min.js'))
39+
.pipe(source('easymde-custom.js'))
4040
.pipe(buffer())
41-
.pipe(terser())
41+
//.pipe(terser())
4242
.pipe(header(banner, {pkg: pkg}))
4343
.pipe(gulp.dest('./dist/'));
4444
}

src/js/easymde.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,9 @@ function EasyMDE(options) {
18011801

18021802
// Handle status bar
18031803
if (!Object.prototype.hasOwnProperty.call(options, 'status')) {
1804-
options.status = ['autosave', 'lines', 'words', 'cursor'];
1804+
// PATCH:
1805+
// https://github.com/Ionaru/easy-markdown-editor/pull/304/files#diff-819b920f90c798c48e6f526ad645b9abd97ea786e65615fdcb03de412d2fdc76R1680
1806+
options.status = ['autosave', 'lines', 'words', 'characters', 'cursor'];
18051807

18061808
if (options.uploadImage) {
18071809
options.status.unshift('upload-image');
@@ -2758,7 +2760,16 @@ EasyMDE.prototype.createStatusbar = function (status) {
27582760
} else {
27592761
var name = status[i];
27602762

2761-
if (name === 'words') {
2763+
// PATCH:
2764+
// https://github.com/Ionaru/easy-markdown-editor/pull/304/files#diff-819b920f90c798c48e6f526ad645b9abd97ea786e65615fdcb03de412d2fdc76R2593-R2600
2765+
if (name === 'characters') {
2766+
defaultValue = function (el) {
2767+
el.innerHTML = cm.getValue().length;
2768+
};
2769+
onUpdate = function (el) {
2770+
el.innerHTML = cm.getValue().length;
2771+
};
2772+
} else if (name === 'words') {
27622773
defaultValue = function (el) {
27632774
el.innerHTML = wordCount(cm.getValue());
27642775
};

0 commit comments

Comments
 (0)