Enhancement Request: Add option to isEmpty
to consider whitespace as empty
#5413
Closed
indi-rin
started this conversation in
Feature Requests
Replies: 1 comment 4 replies
-
I would probably not have it be on the editor instance, but maybe as part of I would be willing to accept a PR that adds to the second parameter |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
It would be helpful if there was a way to have
editor.isEmpty
return true if the editor contains only whitespaces. Maybe something likeeditor.isEmpty({ ignoreWhitespace: true })
to support considering whitespace empty in addition to the existing behavior.Currently, we can't use
editor.isEmpty
and instead have to check and trim the content witheditor.getText() && editor().getText().trim().length > 0
. It's not a terrible workaround but it'd be nice if we were able to utilize the built-in feature!Use Case
I want to use this feature for cases where we process user input if there is text in the editor differently from if there is no text in the editor, and we don't consider whitespace to be text that can be processed.
(Also, while checking to see if this behavior was supported, I came across this StackOverflow from a year ago of other people asking about the same thing.)
Type
Other
Beta Was this translation helpful? Give feedback.
All reactions