Draft.js editor is empty

 contentState.hasText() && contentState.getPlainText().length > 0 

Check

  • Empty
  • White Space

Just use the hasText function on ContentState :

editorState.getCurrentContent().hasText()

export const isEmptyDraftJs = (rawState) => {
  if (!rawState || _.isEmpty(rawState)) { // filter undefined and {}
    return true;
  }
  const contentState = convertFromRaw(rawState);
  return !(contentState.hasText() && (contentState.getPlainText() !== ''));
};

I am not sure it is perfect but I use above code.

When you add just image, there is an space character so getPlainText() can filter only image draftJS.