-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add configuration option to skip autop on freeform blocks when parsing blocks #42623
Conversation
Size Change: +39 B (0%) Total Size: 1.26 MB
ℹ️ View Unchanged
|
Something to note - when working on this, I wondered how the site editor works. It turns out that the site editor supports inserting the classic block and has that configured as the freeform handler. However, inserting a classic block results in the block crashing - #23086. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also mentioned an alternative - #33832 (comment)
But this seems more complex
I agree that there might be a "better" solution out there, but I sort of like how this PR is minimally invasive. It's essentially an escape hatch for advanced users.
(I'll mark this approved, but would like to see the param renamed per my suggestion!)
It's way too late now, but in 2018 we could have let the parser assume that we want autop if and only if fallbackBlockName === 'core/freeform'
or something. :)
because the parser doesn't know the difference between a paste and a normal parse.
How is pasting generally handled in Widgets?
5337a73
to
f5299c9
Compare
Thanks for the review!
It uses the same raw handling code as other editors. This is where
So the suggestion (#33832 (comment)) is possible, but I'm not sure how useful it would be outside of the widgets editor. In contrast I think |
Nice, thanks for fixing this! But why |
What?
Fixes #33832
The widget editor has had a long standing issue in that the block parser runs
autoP
on its freeform content. The widget editor doesn't have a classic block, so it uses the HTML block as its freeform content handler.Unfortunately this results in paragraphs being automatically inserted into HTML block content.
Why?
The autop functionality was originally implemented to support the back compat of classic block content. The widget editor doesn't have a classic block and typically isn't used to manage post content / article style text, so the default behavior of the parser is meaningless.
How?
Adds an option to the parser. I think this is the lowest friction option.
This is a tricky issue to tackle because of the need for backwards compatibility. IMO the parser ideally wouldn't run
autoP
on content at all, this could have been part of the classic block from the start. But I don't think that can be changed now.Alternatives
This could also be part of the
setFreeformContentHandler
function:@noisysocks Also mentioned an alternative - #33832 (comment)
But this seems more complex, because the parser doesn't know the difference between a paste and a normal parse. 🤔
Testing Instructions
In trunk: Observe the Custom HTML code has additional paragraph and line break tags.
Screenshots or screencast
Meaningless screenshot:
