ckeditor icon indicating copy to clipboard operation
ckeditor copied to clipboard

word limit validation - account for new lines & nbsp

Open i-just opened this issue 9 months ago • 0 comments

Description

If you have a word limit set on a CKEditor field, we need to account for the fact that the words can be split with various tags and entities like  .

Currently, if you add a single word per line/paragraph, the word count will report the correct number of words, but the limit will treat them all as a single word.

To prevent that, we should first run the field value string via html_entity_decode so that things like   get converted, then insert a space between each closing and opening tag so that when we strip_tags, markup like this is treated as four words and not as a single one:

<p>one</p><p>two<br>three&nbsp;four</p>

Related issues

n/a

i-just avatar Mar 24 '25 15:03 i-just