simplemde-markdown-editor
simplemde-markdown-editor copied to clipboard
"Character Counter" Missing
Description While setting up SimpleMDE, it appears that while a character counter is mentioned (and a style class is added for it in 1.10.0 / 6318fc1b193fc419a0aede13738b2be07355b16a), it was never actually implemented into the editor.
Attempting to add "characters" to status's array properly adds "characters: " to the status bar, however does not actually have any functionality associated with it, thus does not display numbers nor increase/decrease with input.
Example:
Setup:
var simplemde = new SimpleMDE({
autosave: "enabled",
toolbar: ["bold", "italic", "|", "link", "|", "preview"],
status: ["characters"],
});
Yes, the actual code seems to be missing. Fortunately it is relatively easy to add it yourself.
status: ["autosave", "lines", "words", "cursor", {
className: "characters",
defaultValue: function(el) {
el.innerHTML = "0";
},
onUpdate: function(el) {
el.innerHTML = simplemde.value().length;
}
}]
Not able to get reference to simplemde variable in this code ? Anything, I am missing?
Not able to get reference to simplemde variable in this code ? Anything, I am missing?
@mobeendude I actually have to select the div element to make this work:
onUpdate: function (el) {
el.innerHTML = document.querySelector(
"div.CodeMirror.cm-s-paper.CodeMirror-wrap").innerText.length;
}