admin管理员组

文章数量:1125090

I have 2 custom blocks, "super-tabs" and "super-tab". Tabs has an inspector control that determines how many tab blocks will be in the tabs block. But when I change the number of tabs, it doesn't change the number of tab blocks. I can lock the innerblocks, but then I won't be able to edit the content of the super-tab block.

How can I have it so changing the number of tabs (numTabs) actually adds new tabs, but also allows them to be editable?

My code looks like this:

let defaultChildren = [];
for (let i = 1; i <= numTabs; i++) {
    defaultChildren.push(["super-tabs/super-tab", {}, [["core/paragraph",{content:'Tab'+i}]]]);
}

...

return wp.element.createElement(wp.blockEditor.InnerBlocks, {template: defaultChildren})

本文标签: block editorHow can I lock innerblocks but not it39s content