最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

tinymce - HTML formatting issues when switching between editor tabs

programmeradmin1浏览0评论

In the WordPress admin panel, when switching between the "text" and "visual editor" tabs, my HTML formatting is completely lost. New lines are removed, and paragraph tags are shown in the "text" tab. When I select the "text" tab, and then refresh the page, the HTML remains formatted correctly. However, if I switch to the "Visual Editor" tab, and then back to the "text" tab, the formatting is incorrect (p tags are showing, new lines are not showing).

I'm also using the Classic Editor plugin. I also installed Advanced Editor Tools, hoping it would allow me to disable the functionality, but that hasn't worked either.

Using the same exact content, I tested this scenario on 2 of my other WordPress sites and do not have the same issue. Those sites also have the latest version of WordPress and the Classic Editor plugin installed.

I thought maybe wpautop had been disabled on the site, I went into functions.php and made sure that wpautop was not disabled anywhere in there. I even added this to the end of functions.php:

add_filter( 'the_content', 'wpautop');

I also tried disabling any plugins that I thought might be causing the issue. That didn't work either.

I've spent a few hours Googling and trying different things out. Any suggestions to help me debug this would be greatly appreciated.

In the WordPress admin panel, when switching between the "text" and "visual editor" tabs, my HTML formatting is completely lost. New lines are removed, and paragraph tags are shown in the "text" tab. When I select the "text" tab, and then refresh the page, the HTML remains formatted correctly. However, if I switch to the "Visual Editor" tab, and then back to the "text" tab, the formatting is incorrect (p tags are showing, new lines are not showing).

I'm also using the Classic Editor plugin. I also installed Advanced Editor Tools, hoping it would allow me to disable the functionality, but that hasn't worked either.

Using the same exact content, I tested this scenario on 2 of my other WordPress sites and do not have the same issue. Those sites also have the latest version of WordPress and the Classic Editor plugin installed.

I thought maybe wpautop had been disabled on the site, I went into functions.php and made sure that wpautop was not disabled anywhere in there. I even added this to the end of functions.php:

add_filter( 'the_content', 'wpautop');

I also tried disabling any plugins that I thought might be causing the issue. That didn't work either.

I've spent a few hours Googling and trying different things out. Any suggestions to help me debug this would be greatly appreciated.

Share Improve this question asked Mar 16, 2021 at 23:13 CharlesCharles 111 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 1

I was finally able to get this fixed after some more debugging. I had previously disabled TinyMCE emojis which is what was causing the issue.

After removing this code from functions.php the editor started working as it normally does.

function disable_emojis() {
    add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
}
add_action( 'init', 'disable_emojis' );
发布评论

评论列表(0)

  1. 暂无评论