From d963582f16fc572b1337e1dc4fdd76fe1ea261b3 Mon Sep 17 00:00:00 2001 From: Wes Cossick Date: Tue, 7 Jun 2016 21:53:23 -0500 Subject: [PATCH] Fix line and word count on init (#299) --- src/js/simplemde.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/js/simplemde.js b/src/js/simplemde.js index 5936b4f..e44caed 100644 --- a/src/js/simplemde.js +++ b/src/js/simplemde.js @@ -1052,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\u0410-\u04F9]]+|[\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; @@ -1517,8 +1517,8 @@ 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() { @@ -1782,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();