summernote / summernote

Super simple WYSIWYG editor
https://summernote.org
MIT License
11.39k stars 2.24k forks source link

Font Names dropdown getting reset #4633

Open Rishitasharma2001 opened 2 weeks ago

Rishitasharma2001 commented 2 weeks ago

Checklist

Steps to reproduce

1: Select some font name from the dropdown in the toolbar. 2: Type one sentence. 3: If you go to a new line, sometimes the font name is getting reset to 'Helvetica' even when the user didn't change it from the dropdown

Expected behavior

Ideally, the font which the user selects from the dropdown should be retained until and unless user changes it again.

Current behavior

Font name is automatically getting set to 'Helvetica' sometimes if we go to a new line.

Minimal example reproducing the issue

No response

Environment

1der1 commented 2 weeks ago

@Rishitasharma2001, can you give a reproducible example?

Rishitasharma2001 commented 2 weeks ago

If you see in the attached video I selected Arial Black as the font and if I move my cursor to 3rd or 4th line the font is getting reset to Helvetica Neue on its own. Ideally, until and unless user changes the font explicitly, it should stay as Arial black only (or whatever has been selected by the user). Don't move to 3rd or 4th line by pressing enter, bring the cursor instead there using keypad/mouse-click. If we move to the next line using enter, then font is getting retained.

https://github.com/summernote/summernote/assets/60786363/66c02e4b-10dd-40db-9135-5f21f9847096

1der1 commented 2 weeks ago

Thank you, @Rishitasharma2001.

I checked it and found that SN sometimes adds a new line (br tag) when you try to leave the edited area with the cursor:

The splitNode function calls the paddingBlankHTML function, which might add a blankHTML (<br>)

If the styling of the previous line is attached to a <br> instead of the parent element (usually a <p>), you add a piece of code without styling.

It is all related to emptyPara (<p><br></p>). SN depends on it, and there is a discussion: Do we still need emptyPara for focusing caret? #3016