classic-editor
classic-editor copied to clipboard
HTML stripped when switching between Visual & Text
Hi there, firstly if this is the wrong place to leave this then please let me know where else. The support forum just seemed full of people complaining about Gutenberg.
Setup
WP: 5.6.1 Plugin version: 1.6 Theme: any Other active plugins: no
Issue
I have the following code:
<span class="social-links"><a href="https://www.facebook.com/example/" data-platform="facebook" target="_blank"><i class="fa fa-facebook-square" aria-hidden="true"></i></a><a href="https://www.instagram.com/example/" target="_blank"><i class="fa fa-instagram" aria-hidden="true"></i></a></span>
Enter this into the 'Text' editor, then switch to 'Visual' and back again, it's all been wiped.
With the following code, which is identical except has code on separate lines:
<span class="social-links">
<a href="https://www.facebook.com/example/" data-platform="facebook" target="_blank">
<i class="fa fa-facebook-square" aria-hidden="true"></i>
</a>
<a href="https://www.instagram.com/example/" target="_blank">
<i class="fa fa-instagram" aria-hidden="true"></i>
</a>
</span>
Enter this into the 'Text' editor, then switch back to 'Visual'. The code still exists and has been modified to add rel="noopener"
(which is fine):
<span class="social-links">
<a href="https://www.facebook.com/example/" target="_blank" rel="noopener" data-platform="facebook">
<i class="fa fa-facebook-square" aria-hidden="true"></i>
</a>
<a href="https://www.instagram.com/example/" target="_blank" rel="noopener">
<i class="fa fa-instagram" aria-hidden="true"></i>
</a>
</span>
This unfortunately introduces line breaks into the page however. Putting new lines in different places leads to different results.
This is repeatable even using the 'link' button to first create a link from the text view, then switching back and forward.
Expected behaviour:
As far as I know, span
, a
, i
elements are all allowed. Pasting a code block containing allowed elements without a new line should not lead to them being stripped.
I've found that adding a comment into the <i>
element stops this behaviour, e.g.
<i class="fa fa-facebook-square" aria-hidden="true"><!-- Blank, here to stop code being stripped out when switching from text to visual modes in the editor --></i>
I usually use a
inside the tags in cases such as this where empty tags are being stripped.
I am extremely frustrated with this behavior, too. Isn't the whole point of the Text tab to allow entry of HTML? That something as simple as a non-breaking space (or multiple non-breaking spaces) gets stripped just for switching back to the Visual tab is not acceptable. Maybe on WordPress.com, but surely not on self-hosted sites.
I usually use a
inside the tags in cases such as this where empty tags are being stripped.
It is literally stripping out
when switching tabs - this is what brought me here. But it should not be stripping HTML entities or custom HTML at all.
I usually use a inside the tags in cases such as this
Yes, that should work.
literally stripping out when switching tabs
Yes, this has always been the behavior of the old editor, for over 15 years. It can be changed, but as far as I remember that would bring several other problems/edge cases.
Some of these seem to be (old) problems with how the TinyMCE editor is set in WP. A workaround may be to install a plugin that disables the "wpautop" feature (the code that removes the <p>
in the Text editor and re-adds them in the Visual).
However none of the problems described here are due to the Classic Editor plugin. Please search the WordPress support forum, or start new threads there as some may be fixable by plugins or have workarounds.
@azaozz they literally sent me HERE.
I see... That seems wrong though.
This is the development repository for the Classic Editor WP plugin. This plugin can hide the new block editor and unhide the old Edit Post screen which contains the old editor (TinyMCE). This plugin doesn't do anything else, it doesn't affect how the old editor works.
If there are problems with hiding/unhiding of the editors, first place to check would be the plugin's support forum: https://wordpress.org/support/plugin/classic-editor/. The GitHub issues are generally reserved for developers that want to contribute code or have ideas about how to improve the plugin, or for confirmed bugs that can be reproduced.
Maybe they just wanted to pass the buck.
On Sat, Apr 8, 2023, 7:42 PM Andrew Ozz @.***> wrote:
I see... That seems wrong though.
This is the development repository for the Classic Editor WP plugin. This plugin can hide the new block editor and unhide the old Edit Post screen which contains the old editor (TinyMCE). This plugin doesn't do anything else, it doesn't affect how the old editor works.
If there are problems with hiding/unhiding of the editors, first place to check would be the plugin's support forum: https://wordpress.org/support/plugin/classic-editor/. The GitHub issues are generally reserved for developers that want to contribute code or have ideas about how to improve the plugin, or for confirmed bugs that can be reproduced.
— Reply to this email directly, view it on GitHub https://github.com/WordPress/classic-editor/issues/155#issuecomment-1501008146, or unsubscribe https://github.com/notifications/unsubscribe-auth/AED7IPJMCORTUO2PXCMA6LTXAIAWZANCNFSM4XMEKM5Q . You are receiving this because you commented.Message ID: @.***>