admin管理员组

文章数量:1208155

So I have this block that I created using templates and InnerBlocks, it's a block that my authors will use to insert a Hero Image section at the top of the page.

export default function Edit() {
    const template = [
        [ 'core/cover', {}, [
            [ 'core/heading', { placeholder: 'Section title' } ],
            [ 'core/button', { placeholder: 'Call to action' } ],
        ] ],
    ];

    return (
        <InnerBlocks
            template={ template }
            templateLock='all'
        />
    );
}

It works fine, however, I want to disable some attributes from the Heading and Button child blocks, so that all the author does is enter content, no styling changes to the blocks.

Why do I need that? Because this section already has all the styling it needs, and I wouldn't want my authors to change some alignment or text color that would break the section styling.

Is there any way of doing this?

I tried this but didn't work:

const template = [
    [ 'core/cover', {}, [
        [ 'core/heading', { placeholder: 'Section title' } ],
        [ 'core/button', { placeholder: 'Call to action', supports: { align: false, ... } ],
    ] ],
];

本文标签: pluginsHow can I disable an attribute from a Gutenberg block included in a template via InnerBlocks