-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Inline HTML comments are removed when a Block is edited #13318
Comments
Flagging |
I'm not sure either. What's a good use case for allowing comments? If we allow the random comments, I think they should somehow be visualised in the visual editor. |
I don't have a good use case, per se. We're currently using HTML commands to mark specific text as "ignored":
I've also seen HTML comments used to store data within the post content.
Can you explain this thinking further? This would be a departure from the Classic Editor. |
It sounds like use cases that should be covered by rich text APIs in the future. You want to apply some meta info to some text. Or you want to store an object with data.
In the visual editor the comments would be invisible, so the user would be able to delete the comments without knowing. |
Cool. That could work although, importantly, we'd want to enrich the content server-side and then pass it to the client (not replicate our existing server-side logic in the client).
Isn't this the case in TinyMCE though? I think it's a reasonable expectation, given the semantic nature of HTML comments. |
I fully agree with @danielbachhuber on the HTML comments: these comments have been a genuine feature of HTML since the early days, and the block editor now deleting them arbitrarily / at will is utterly bad practice: you must not change the rules "just like that"! Yes, comments are invisible in the visual editor — as they are in the rendered page: that is the way they are meant to work. OK, making them visible (maybe optionally?) in the editor would be nice-to-have, but is not a prerequisite. I have a rather complex WP site with >500 posts and 1.5 million words — the only way I could make searching work robustly and efficiently was to hide specific search terms in HTML comments. If such comments are arbitrarily deleted, this not only defeats my search engine, but even just restoring such comments & search terms (and finding out that they are missing in first place!) is a real pain in the backside. Sure, I could put the search terms at the end of my posts, in a tiny and/or transparent font — but that is not only very clumsy, but again an enormous amount of work to retrofit to 500+ blog posts. the same would be true for putting them in a meta tag — plus, I don't know whether I could use local WP searches (in the WP posts listing, or in the user front end search tool) to look into meta tags. |
Or as a middle ground, add a |
I have now resorted to an HTML block consisting of inline HTML comment only. To me, this works for the purpose of embedding hidden search text in a blog post. That doesn't help, though, in hiding text within a paragraph. I often would like to do that in "live documents", i.e., blog posts that evolve over time, and where I'd like to embed text that I want to activate at a later stage, or which is still missing some information before it can be revealed, just as @danielbachhuber explained above. |
Describe the bug
If a Block has an inline HTML comment, the HTML comment is stripped out when the Block is modified.
Sample text:
To Reproduce
Steps to reproduce the behavior:
See GIF:
Expected behavior
My expected behavior is that the HTML comment persists when I edit the text.
In the scenario where I edit within the boundary of the HTML comment, my expected behavior is that the Block Editor would mirror the Classic Editor.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: