simplemde-markdown-editor icon indicating copy to clipboard operation
simplemde-markdown-editor copied to clipboard

"Character Counter" Missing

Open corsair opened this issue 7 years ago • 3 comments

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:

image

Setup:

var simplemde = new SimpleMDE({
  autosave: "enabled",
  toolbar: ["bold", "italic", "|", "link", "|", "preview"],
  status: ["characters"],
});

corsair avatar Jul 05 '17 23:07 corsair

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;
		}
	}]

Nrde avatar Aug 17 '17 07:08 Nrde

Not able to get reference to simplemde variable in this code ? Anything, I am missing?

mobeendude avatar Jul 03 '18 08:07 mobeendude

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;
              }

davuses avatar Sep 23 '20 11:09 davuses