summernote: I have a problem with isEmpty to determine if the content isEmpty

IsEmpty. When i type space, the content of the $("#summernote").summernote("code") is <p>&nbsp</p>  or <p>&nbsp;&nbsp;&nbsp;</p>,that’s when i hit enter, the content of the $("#summernote").summernote("code") is <p>&nbsp;&nbsp;&nbsp;</p>or enter after entering a space,the content of the $("#summernote").summernote("code") is <p>&nbsp;&nbsp;&nbsp;</p><p><br></p>

There is a space when the check is not empty, how should I solve, help me, thank you @nsb @e2goon @BenJenkinson @dittos 1578451112(1) 1578451156(1)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

I wonder what is your check point for isEmpty?

Maybe if you want to check empty status, see below code .

var $tempElement = $('<div />').html($('.summernote').summernote('code'))
var isEmpty = $tempElement.text().trim().replace(/ \r\n\t/g, '') === ''

hi @fujilu

isEmpty method don’t check &nbsp;

Because &nbsp; is text node but not empty character.