Replies: 1 comment
-
I wonder about this. It’s not clear to me why If you actually do need to insert it imperatively, start with // …admist your custom/tabs edit function…
const { insertBlock } = useDispatch(blockEditorStore);
const insertTabContent = () => {
const newBlock = createBlock( 'core/paragraph' , { placeholder: 'this is your tab content…' } );
insertBlock( newBlock, 0, clientIdOfTabBlock )
}
return (
// …amidst the inspector controls…
<Button onClick={ insertTabContent }>Content me</Button>
); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I developed two custom Gutenberg blocks -
custom/tabs
as the parent block, andcustom/tab
(which uses InnerBlock to add tab content) as the child block. I need to insert the child block using code, and I want to create a button in the Inspector control ofcustom/tabs
that allows me to add the child block without affecting the content of any already-addedcustom/tab
blocks.Beta Was this translation helpful? Give feedback.
All reactions