so a week or so ago my hosting provider updated my version of Wordpress (I cannot control this) and on the edit side most of my Gutenberg blocks are broken. I knew this day would come but I was unaware of the Wordpress update with my host (I can't downgrade sadly and shouldn't do that even). Thus in the editor most of my blocks are giving the following warning in the console/browser dev tools.
wp.blockEditor.RichText multiline prop is deprecated since version 6.1 and will be removed in version 6.3. Please use nested blocks (InnerBlocks) instead. See: https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/nested-blocks-inner-blocks/
Okay, time to update my code. However I am unsure if using nested inner blocks are the solution to my problem. For example here is the edit side of one of my blocks, notice I have two RichText components within:
// edit.js file of Gutenberg Block
import {useBlockProps, RichText} from '@wordpress/block-editor';
import './editor.scss';
export default function Edit(probs) {
return (
<div {...useBlockProps()}>
<div className="testimonial">
<div className="testimonial__wrapper">
<div className="testimonial__header">
<i className="testimonial__quote__left"></i>
<RichText
tagName="blockquote"
value={probs.attributes.quote}
onChange={(content) => probs.setAttributes({ quote: content })}
placeholder='Enter Quote'
keepPlaceholderOnFocus={true}
/>
<i className="testimonial__quote__right"></i>
<RichText
tagName="figcaption"
value={probs.attributes.source}
onChange={(content) => probs.setAttributes({ source: content })}
placeholder='Enter Source'
keepPlaceholderOnFocus={true}
/>
</div>
</div>
</div>
</div>);
}
Now I can't replace these with InnerBlocks as Innerblocks can only be used once in a block
A block can render at most a single InnerBlocks and InnerBlocks.Content element in edit and save respectively. To create distinct arrangements of nested blocks, create a separate block type which renders its own InnerBlocks and assign as the sole allowedBlocks type.
Source: https://github.com/WordPress/gutenberg/tree/master/packages/block-editor/src/components/inner-blocks
Okay, but as I have HTML and styling wrapped around my RichText components I don't think I can use Nested Inner Blocks as the template attribute of the InnerBlock is in a JSON format and won't support the HTML (or so I believe, perhaps I am wrong). I thought about using Parent and Child blocks and I think this is unsuitable (I am still researching this). I thought about replacing the RichText components with simple HTML input fields and captureing the onChange event of the input values. Not a great solution due to styling and needing to break in the captured text. I am currently wondering if there is an alternative component I can use like "EditableText" but I am unsure if this is suitable or supported. I also noticed that using the same custom Gutenberg blocks on a local MAMP server using the same version of Wordpress I get no errors - only the hosted version errors.
So in short if anyone has ever encountered the same problem? having to replace multiple RichText components in a single block, I would be appreciative of any advice on how you solved this issue.
Many thanks in advance.