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

[Blocks] Preserve source markup in invalid blocks #38460

Closed
wants to merge 2 commits into from

Commits on Feb 9, 2022

  1. [Blocks] Preserve source markup in invalid blocks

    Previously we have been re-generating a block's save content when
    we fail to properly validate that block. While this can work in many
    cases it breaks down quickly because of the invalidly-parsed attributes.
    
    Consider a list block whose `<ul>` tag has been removed. The block will
    fail to validate and then also fail to read the content of the list items
    because the CSS selector used to source the attribute won't work. The
    attribute for the list's content will be empty and `getSaveContent` will
    return an empty list, this despite the fact that the contents were largely
    fine in the post HTML when loaded.
    
    In this patch we're threading a new property into the block node called
    `sourceMarkup` whose purpose is to preserve the original HTML in a post
    so that we can choose to preserve that on save instead of corrupting or
    losing content through the HTML re-generation.
    
    With `sourceMarkup` we get a less-processed version of the source to
    relay into save which should eliminate a common point of frustration:
    saving a post erases content.
    dmsnell committed Feb 9, 2022
    Configuration menu
    Copy the full SHA
    62e8bdc View commit details
    Browse the repository at this point in the history
  2. Minimize size of change

    dmsnell committed Feb 9, 2022
    Configuration menu
    Copy the full SHA
    6b4cd10 View commit details
    Browse the repository at this point in the history