This is still not very helpful. Firstly, it’s easier to copy-paste code than to take a screenshot and post that, and that would allow me to copy the code to try it out. Secondly, you don’t appear to have made any effort to reduce the code to the minimal complexity needed to reproduce the issue. Thirdly, could it be that you’re reusing ele (which isn’t defined in the visible code) for different markers? If so, since DOM elements can only be in the document once, that might cause the old marker to disappear when a new one is added.
I write a demo to show you my problem. I want to insert a node at the cursor and i hope this node behave like a single character.
But ,pressing the enter key while the cursor is in front of the inserted node deletes the following node.
You could insert an actual character and cover it with a replacing mark.
Also, I think using setBookmark instead of markText to create the widget results in slightly different behavior, which might actually be what you want here.