stevengharris/MarkupEditor

Weird HTML tags not removing properly

Closed this issue · 1 comments

HTML.tags.not.removed.properly.mp4

Hi @stevengharris,

Not sure if this was mentioned previously or it is a regression.
There are "" and duplication of the tags being added to an empty inner html.

Is this the expected html behavior for adding styles to the text?

Hmm, no, that doesn't seem quite right. There are in fact empty styled elements added when the caret is outside of a word. This is to support the case of "I want to bold what I'm typing next". I am mostly using hot-keys for it, so I'm doing something like "type normal text -> CTRL+B -> type bolded text -> CTRL+B -> type normal text". To make this happen, I have to create a styled element like <b></b>, but it has to contain a non-printing character to be able to select inside it. You can see this in markup.js occasionally as const emptyTextNode = document.createTextNode('\u200B');. I then select that text, which you cannot see on the screen, and when you type it's replaced. It does have a kind of weird side effect that if you never type into it, as you navigate using arrow keys, the cursor stops at the empty element, but I think this is actually okay and probably the correct behavior. All of these empty elements are stripped when you getHTML, because I think of them as transient editing artifacts.

All that is a long explanation that is probably only tangentially related to what you showed in the video. I will check it out, thanks.