Problem
I want to validate that a user has inputted actual text into the editor, ignoring html tags and whitespace.
Details
- I'm using the ReactJS SunEditor Component
- I'm using Typescript
Here's an example of the content when a user doesn't type in anything:
<p><br>
</p>
and another
<p> </p>
Attempted Solutions
I've tried putting a regex in the onChange event, but it's pretty clunky and probably won't take into account all the different ways non-textual content is represented; I need a better way.
const regex = /(<([^>]+)>)/ig;
Vague Ideas
I see that the SunEditor javascript api has a utility method, onlyZeroWidthSpace that returns a boolean; it may work, but I don't see how I can access it. I'm using Typescript, so maybe there's an issue there?
Thanks for your help!