Skip to content
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

Handle invalid blocks without modifying their markup #1736

Closed
nylen opened this issue Jul 5, 2017 · 1 comment
Closed

Handle invalid blocks without modifying their markup #1736

nylen opened this issue Jul 5, 2017 · 1 comment
Assignees
Labels
[Feature] Blocks Overall functionality of blocks [Priority] High Used to indicate top priority items that need quick attention

Comments

@nylen
Copy link
Member

nylen commented Jul 5, 2017

We need to detect blocks with invalid markup (e.g. added classnames, added or removed tags).

One way to do this (idea from @mtias): Detect "invalid" blocks by re-serializing blocks that we see in the editor. If it changes beyond a certain threshold (e.g. whitespace doesn't matter), then show the block as a core/html block and highlight how the markup would be changed.

Like #1735 it is important that the default "save" operation not alter the markup inside the block.

@nylen nylen added [Feature] Blocks Overall functionality of blocks [Priority] High Used to indicate top priority items that need quick attention labels Jul 5, 2017
@afercia
Copy link
Contributor

afercia commented Jul 24, 2017

As an example: noticed during work on the Pullquote block, see #1987

When editing a post with a pullquote in the Classic editor, and then again in Gutenberg, the content gets lost. For example: inserted a pullquote with 2 paragraphs:

<blockquote class="wp-block-pullquote alignnone">
    <p>My quote</p>
    <p>with multiple par</p>
    <footer>my caption</footer>
</blockquote>

Saved, then opened the same post using the Classic editor, switched to text mode and the markup was changed to:

<!-- wp:core/pullquote -->
<blockquote class="wp-block-pullquote alignnone">My quote

with multiple par

<footer>my caption</footer></blockquote>
<!-- /wp:core/pullquote -->

This perfectly works in the Classic editor, but when editing again in Gutenberg, it doesn't of course and the content gets stripped out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks [Priority] High Used to indicate top priority items that need quick attention
Projects
None yet
Development

No branches or pull requests

3 participants