-
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
Compat: Disable wpautop in Classic Editor when post contains block #2708
Conversation
Could we also remove |
@iseulde Yes, I think so. This only achieves the |
I would do the latter. Would you be concerned with that? |
I think it is a simpler/performant approach, yes, but I'd want to confirm that it won't have any regressions for posts which were originally edited in the current editor expecting wpautop, then later edited in Gutenberg. Something like:
This would be treated as a "Gutenberg" post, and if disabling |
Hm, wouldn't those be wrapped in a freeform block? |
In addition to the classic editor, we need to consider posts that come in via xml-rpc, native apps, and the rest api. Gutenberg isn't the sole way people will edit content. I think a refined |
In that case, we need to think about how that might occur.
|
It would be parsed as a freeform block, but not explicitly wrapped with comment delimiters as of #2513. I don't know that there's any contention on the point of disabling the |
Sounds good, sorry for the distraction @aduth! |
Actually, let's just use #2736 as the canonical issue for tracking application of wpautop to Gutenberg posts.
Certainly not! I'd hoped to have been able to include the necessary changes here, but it's obviously a more complicated issue than I might have imagined, so needs additional discussion. |
This seems like the wrong approach, if you want to maintain compatibility with third-party tools and outside editors, since they will expect wpautop, and may either blindly insert content that requires it, or may convert existing paragraphs to line breaks, like how the current TinyMCE editor does. It seems like as fundamental a breaking change as replacing the entire format. |
Hi @gschoppe , thanks for the feedback. The changes here don't do more than disable the paragraph stripping enabled by default in the classic editor, thereby avoiding an issue where [Gutenberg] paragraph blocks were being mangled by the formatting. Ultimately, the result that reaches the front-end of a site is the same: paragraphed content, whether or not the existing post with blocks is edited in the classic editor or in Gutenberg. Later discussion here and the in-progress work in #2806 is more relevant to the application of automatic paragraphs. I'd considered (but not yet implemented) adding save-time hooks to normalize non-block content to paragraphs, meaning regardless if a third-party editor adds newline-separated content or explicit paragraph tags, the saved content would maintain the same format (with explicit paragraph tags). I will plan to circle back to that pull request in the next few days, and your feedback would be appreciated there. |
But this means that third-party editors will be unable to properly deal with content within Gutenberg blocks, and may attempt to normalize it to a removep state. Yes, this stops the TinyMCE editor from running removep, but it doesn't stop any third-party tools that emulates that functionality. As much as it is awful, wpautop is part of the current format standard for posts, and removing it in a piecemeal manner breaks compatibility with the current format. |
Do you have specific examples in mind of editors mimicking this behavior of removing paragraphs? Gutenberg will accommodate new incoming content additions quite well, even those added by existing editors (the current editor), plugins, or third-party tools. Handling automatic paragraphs poses some challenge, sure, but outside of hypotheticals, it is showing to be largely addressable. |
I'm working on getting a Mac test environment set up to compare some of the various blogging apps that export to WordPress (most of these are mac-only). I should have more detailed results soon. At a glance, I would expect that issues might crop up with software like the following:
All of these implement a WYSIWYG editor that saves to WordPress, and I believe most can pull posts in from WordPress to edit. As I said, I will have more data soon, but tools like this have a very high likelihood of reimplementing |
This pull request seeks to resolve an issue where saving a post which contains paragraph blocks in the current editor ("Classic Editor") will cause those blocks to become invalid when returning to the Gutenberg editor.
Implementation notes:
The reason that blocks become invalid is because by default, the current post editor will strip paragraph tags (the
removep
behavior). Since the Gutenberg editor expects these paragraph tags to exist, it will then flag these blocks as invalid (modified externally). The implementation here detects whether the post contains blocks (using the newgutenberg_post_has_blocks
introduced in #1797) and, if so, disables thewpautop
behavior for the Classic Editor.Testing instructions: