Answer the question
In order to leave comments, you need to log in
CKEditor - if you enter only 1 space, then the getData() function will return an empty string. Can this be fixed somehow?
Hello. In my JS code, the number of characters entered by the user in CKEditor is counted and displayed on the screen.
If you enter only one space (and nothing else), then the getData method will return an empty string (hence, the number of characters in it is 0). If you then press the space again, for example (or enter any other character), then immediately 2 characters. It's not very pretty.
This happens not only with the getData method, but also if you take val() from the textarea to which the CKEditor is bound.
How to fix it?
Answer the question
In order to leave comments, you need to log in
You do not need editor.getData()
, firstly, it is quite heavy, and secondly, not for this task. You need something likeeditor.editable().getText()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question