OscarGodson / EpicEditor

EpicEditor is an embeddable JavaScript Markdown editor with split fullscreen editing, live previewing, automatic draft saving, offline support, and more. For developers, it offers a robust API, can be easily themed, and allows you to swap out the bundled Markdown parser with anything you throw at it.
http://epiceditor.com
MIT License
4.25k stars 338 forks source link

Feature request: Max character limit / character counter #315

Open Kryptonit3-zz opened 10 years ago

Kryptonit3-zz commented 10 years ago

Would love to see a option for max character limit and a character counter

OscarGodson commented 10 years ago

I'd love to see this also for sure, but probably as an extension. Both of these things would be super simple, but so far the majority of implementations I've seen are in blogging engines and stuff, so max characters built in might not make sense since it'd be used so little overall. If you need help implementing this tho, let me know :) @famthegeek might be able to help too make this a script you can include.

Kryptonit3-zz commented 10 years ago

Attention: I have implemented this feature in an additional code,

refer to my wiki I made

https://github.com/OscarGodson/EpicEditor/wiki/Limiting-character-input-when-using-an-existing-textarea---using-jQuery

I will upload a video of it in action soon!

Kryptonit3-zz commented 10 years ago

Video uploaded. Refer to wiki link in previous post :)

Kryptonit3-zz commented 10 years ago

Apparently this has an issue with anything but plain text when reaching limit (aka text and markdown code) - if someone wants to modify the code please do to fix the problem.

OscarGodson commented 10 years ago

jQuery has a .text method right? Could you simply get the html with exportFile(name, 'html') and get the text of it with jQuery?

Kryptonit3-zz commented 10 years ago

you got me on the right path, i needed the text, not the HTML, so I will be changing this

var editorContent = editor.getElement('editor').body.innerHTML;

to this

var editorBody = editor.getElement('editor').body;
var editorContent = (editorBody.innerText || editorBody.textContent);

the || is for IE compatibility.

Wiki has been updated - https://github.com/OscarGodson/EpicEditor/wiki/Limiting-character-input-when-using-an-existing-textarea---using-jQuery

Thanks!