Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird HTML tags not removing properly #181

Closed
JohnKuan opened this issue Jan 11, 2024 · 1 comment · Fixed by #186
Closed

Weird HTML tags not removing properly #181

JohnKuan opened this issue Jan 11, 2024 · 1 comment · Fixed by #186

Comments

@JohnKuan
Copy link
Contributor

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?

@stevengharris
Copy link
Owner

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.

@stevengharris stevengharris linked a pull request Jan 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants