stevengharris/MarkupEditor

The styling('Bold', 'cursive') is reset with each new line.(After enter is pressed)

Opened this issue · 1 comments

Hello,

Thanks a lot for the amazing Markup editor. It's been incredibly helpful.
I've encountered a peculiar behavior I would like to share.
Whenever I press 'Enter' on my iOS device, the styling seems to reset. Is it intentional behavior? Has anyone else experienced a similar issue?

I've tested this issue on both iOS 16 and iOS 17, using both an iPad and an iPhone, and the problem persists across all devices.

Here is the attached video:
https://github.com/stevengharris/MarkupEditor/assets/141324357/535532c1-5414-48ff-9d89-9051565edccb

This is an oversight and should be fixed. Internally, I call B, I , etc "formats" to distinguish them from P, H1, etc, which I refer to as "styles". FWIW, the intended behavior is that Enter from H1 and any other "style" creates a new, empty P. But, if the Enter occurred within a formatted element, it should be producing an empty "format" inside of it so that subsequent typing is formatted the same way.

It does actually work correctly if you split an existing formatted element by pressing Enter. So, if you place your selection in a the middle of a bold word and press enter, the paragraph splits and the selection is in the 2nd part of the split bolded word, and typing produces bold text. This leads me to believe it will be fixable by just detecting the condition properly and letting the existing code that's working for this other case do the job. OTOH, the logic around capturing Enter is complex because it needs to do different things depending on the context. For example, Enter within a list produces a new list item, but at the last list item will outdent until it can't outdent any longer and produces a new P.