wysihtml5
wysihtml5 copied to clipboard
Character Counter/Limit
Hi, i hope this is the place to post this.
Is there a character counter/limiter in wysihtml5 or are planning on adding one?
cheers, Phil
On a side note the Raptor Editor has a character limit plugin, which you can see here http://www.raptor-editor.com/demo/docking
Yeah thanks. But raptor doesn't play nice with older browsers as wysihtml5 does …
If there is a limitation in the backend, the user should see it in the frontend while she types. So I think a counter is a valid UX requirement for the common usecase of text lenght limitation. (What about a image count limitation then -- just kidding).
But I'd leave further requirements on word count and statistics to MS Word. Please.
Yep, Raptor is only just released. Post your issues/feature requests and we will give you priority support. It works well in IE 9, what are your other target browsers?
@Petah can you please use a different way for promoting your editor. Raptor looks nice. I especially like the "raptorize" option. Thanks.
@pimago Having a character limit option could be neat. A good approach would be to copy over the maxlength attribute from the original textarea and simulate its behavior. But what about images and similar objects?
Sorry Tiff, will do :)
@tiff that's what I am trying right know. Actually with several editors, but I cannot mange to workt it out. Then I stumpled upon wysihtml5, I thought it could do it.
In my case I don't need an image limit. I will keep a look on wysihtml5 until it features a counter :)
I was able to implement this for the "composer" area but am having issues in the html "textarea". What tag should I be looking at to count the value when I'm in the html "textarea"? Here is the current code:
var wysihtml5_max_length = 1000;
var wysihtml5_cur_length = 0;
function verifyWysihtml5CurLength()
{
wysihtml5_cur_length = document.getElementsByClassName('wysihtml5-sandbox')[0].contentWindow.document.body.innerHTML.length;
if (wysihtml5_cur_length > wysihtml5_max_length)
$("#wysihtml5_length_counter").html("<font style='color:red'>You've exceeded the maximum by " + (wysihtml5_cur_length - wysihtml5_max_length) + " characters. Anything past the limit will not be saved.</font>");
else
$("#wysihtml5_length_counter").html((wysihtml5_max_length - wysihtml5_cur_length) + " characters left.");
}
editor.on("aftercommand:composer", verifyWysihtml5CurLength);
editor.on("change:composer", verifyWysihtml5CurLength); //Works
editor.on("change:textarea", verifyWysihtml5CurLength); //Does not work
How to add Code? plz help me
Any word on this? Does anyone have a decent workaround?
@elsurudo this repo is not maintained any longer. I just opened an issue on the maintained version here: https://github.com/Voog/wysihtml/issues/149