Skip to content

Commit

Permalink
feat: add character count based on Ionaru#304
Browse files Browse the repository at this point in the history
  • Loading branch information
eykd committed Feb 11, 2025
1 parent a6b121f commit 573a5a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ function lint() {

function scripts() {
return browserify({entries: './src/js/easymde.js', standalone: 'EasyMDE'}).bundle()
.pipe(source('easymde.min.js'))
.pipe(source('easymde-custom.js'))
.pipe(buffer())
.pipe(terser())
//.pipe(terser())
.pipe(header(banner, {pkg: pkg}))
.pipe(gulp.dest('./dist/'));
}
Expand Down
15 changes: 13 additions & 2 deletions src/js/easymde.js
Original file line number Diff line number Diff line change
Expand Up @@ -1801,7 +1801,9 @@ function EasyMDE(options) {

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

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

if (name === 'words') {
// PATCH:
// https://github.com/Ionaru/easy-markdown-editor/pull/304/files#diff-819b920f90c798c48e6f526ad645b9abd97ea786e65615fdcb03de412d2fdc76R2593-R2600
if (name === 'characters') {
defaultValue = function (el) {
el.innerHTML = cm.getValue().length;
};
onUpdate = function (el) {
el.innerHTML = cm.getValue().length;
};
} else if (name === 'words') {
defaultValue = function (el) {
el.innerHTML = wordCount(cm.getValue());
};
Expand Down

0 comments on commit 573a5a7

Please sign in to comment.