WordPress-gutenberg – Block validation: Expected text

The problem is with your selectors:

attributes: {
    content: {
        type: 'string',
        source: 'html',
        selector: 'p',
    },
    content2:{
        type: 'string',
        source: 'html',
        selector: 'p',
    },
},

You’re only using p for both attributes.

When the block looks at the saved HTML to validate it, it checks to see if the value of the selectors matches the value of the attribute. If it doesn’t then the validation fails.

So given this HTML:

<div class="wp-block-protex-contact-g-block">
    <p class="prtx_contact_name">lkjhlkjhlkjh</p>
    <p class="prtx_contact_address">poiupoiupoiu</p>
</div>

It checks the value for content by looking for p, and it finds lkjhlkjhlkjh, which is the content of the first p tag. This is also the saved value for content, so things are looking good so far.

Then it looks for the value for content2 by also looking at the first p tag, since that’s the selector, and this also finds lkjhlkjhlkjh. However, the block thinks that the value for content2 is supposed to be poiupoiupoiu, so it thinks that the HTML has been saved incorrectly.

So you need to make sure that your selectors can be used to find the correct value in the HTML. You can do this by using the classes you’re already using on those paragraphs:

attributes: {
    content: {
        type: 'string',
        source: 'html',
        selector: 'p.prtx_contact_name',
    },
    content2:{
        type: 'string',
        source: 'html',
        selector: 'p.prtx_contact_address',
    },
},