I'm facing a strange issue with the "core/paragraph" block :
An already-working "allowed_filter_types" (see code below), with core & custom blocks, starts bugging out the Gutenberg editor, once i add the 'core/paragraph' in the $allowed_blocks array.
My problem :
The block-appender at the bottom of the editor disappears, so i can't easily add a new block anymore.
The paragraph block itselft is working fine though.
I also have a custom container block, working fine.
But, in the same way, once i add "core/paragraph" in his allowed-blocks, the block-appender inside of it disappears as well.
Could anyone know where this could come from ?
(I'm building a theme from scratch, maybe i should call for this core/paragraph somewhere else first ? Didn't have to do so with the other core/blocks though.)
Thank you for reading, hope you can help !
Here is the code :
For the add_filter :
add_filter( "allowed_block_types", "filter_allowed_block_types", 10, 2 );
function filter_allowed_block_types( $allowed_blocks, $post ) {
if( $post->post_type == "my_post_type" ) {
$allowed_blocks = array(
"core/heading",
"core/image",
"core/gallery",
"core/video",
"core/paragraph",
'my-custom-container'
);
}
return $allowed_blocks;
}
For my custom container : (didn't add the attributes' stuff, working)
edit( { attributes, setAttributes } ) {
let allowedBlocks = [
'core/heading',
'core/paragraph',
'core/image',
'core/gallery',
'core-embed/instagram',
'core/video',
'core-embed/youtube',
'core-embed/vimeo'
];
return([
<div className={ type }>
<InnerBlocks allowedBlocks = { allowedBlocks } />
</div>
]);
},
save( { attributes } ) {
return (
<div className={ type }>
<InnerBlocks.Content />
</div>
);
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744647244a4585686.html
评论列表(0条)