-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Fix block parser to ignore whitespace between block grammar #33136
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
Conversation
|
Size Change: +821 B (0%) Total Size: 1.05 MB
ℹ️ View Unchanged
|
|
Unit tests are all passing locally...which is odd. |
|
@ellatrix Non urgent, but I wonder if at some point you could cast your eyes on this one and advise if you think it's sensible that the parser should not create a freeform content block when it encounters content that is purely whitespace between block definitions during parse? |
|
One counter-example that comes to mind is: Where I would maybe expect to have an empty paragraph or two between these blocks. I'm not sure how that would end up in my clipboard though. |
|
Closing this as it looks like #33164 fixed the issue. |
|
I'm actually going to reopen this to see if it's sensible that we should be creating random freeform blocks for completely empty whitespace. I've removed from Widgets board - which I should have done previously. Apologies @noisysocks. |
|
Thanks for the ping, @gziolo. I would recommend against this change. My reasons are:
document.body.innerHTML = `<div>
<p>p</p>
<div>
<p>sub</p>
</div>
</div>` |
|
Great. That's all I needed to know. Closing as not an Issue. |
Description
Fixes #33097.
If you paste the following into the Widgets Editor
...you will get some
wp:nullblocks inserted into your post. These will be marked asundefinedblocks.It looks as though the default block parser is treating newline characters as something to be made into a
core/freeformblock. However, in Widgets Editorcore/freeformhas been disabled in order to remove the usage of the Classic block and so we end up with acore/missingblock as a fallback.Nonetheless, it is completely valid that HTML in between block grammar should be converted into a freeform block, but we should not do this for empty whitespace.
This PR fixes this by checking whether the parsed "HTML" between blocks contains more than just whitespace. ONly then will it create a freeform block to represent it.
As a result, if you paste in the test data above it will not result in
wp:nullblocks being created.How has this been tested?
core/paragraphblock.Screenshots
Types of changes
Checklist:
*.native.jsfiles for terms that need renaming or removal).