gutenberg-blocks

How can I access the values of an inner block in Gutenberg?

☆樱花仙子☆ 提交于 2021-01-29 03:11:39
问题 I'm trying to build a custom block for Gutenberb. It is a carousel and uses child blocks (images). I'm trying to find a way to find out how many image-blocks were created inside to block so I can create slides for the carousel accordingly. In order to do that, I was thinking about taking the image url from each image block and store it in an array so then I can just map through the array to create each slide, but I have no idea how to access the url value from the child block. Any ideas? 回答1:

Update a specific property of an object attribute in a Wordpress Gutenberg block

不想你离开。 提交于 2021-01-28 02:07:58
问题 I have a custom Gutenberg block with an attribute: valuesObj: { type: 'object', default: {}, } I want to update a specific property within that object when an input is changed. So I have created a function that gets called from onChange on the component: <TextInput value={ valuesObj[index] } onChange={ (value) => this.onChangeValue(value, index) } /> This is the function that gets called: onChangeValue(value, index) { var newValuesObj = this.props.attributes.valuesObj; newValuesObj[index] =

WordPress Gutenberg: This block contains unexpected or invalid content

北战南征 提交于 2020-08-24 06:58:24
问题 I am creating very simple text block. The block works fine when I add this for the first time. If I refresh the page and try to edit the block it show me the message "This block contains unexpected or invalid content.". I have tried to disable htmlvalidation check but that doesn't help. Also, after I click on resolve: the current block and after conversion block contain same code. http://prntscr.com/lwv18b http://prntscr.com/lwv1e1 This is my index.js file code <pre> /** * Block dependencies

Wordpress Gutenberg block

孤街醉人 提交于 2019-12-24 10:41:07
问题 I have a problem with a custom block which send me an error when I reload the edition page. I don't understand what the problem is. In regards of the error, actual and expected are the same. Here the error : Block validation: Block validation failed for namespace/nottomiss ({object}). Expected: <div class="wp-block-utopiales-nottomiss"><p>label test</p><p>label test</p></div> Actual: <div class="wp-block-utopiales-nottomiss"><p>label test</p><p>title test</p></div> Here my code : const {

Gutenberg Block validation failed

我只是一个虾纸丫 提交于 2019-12-11 07:57:42
问题 I'm creating a custom Gutenberg block. It works fine on save and appears on the front end, but as soon I come back to it it reads. Block contains invalid or unexpected content When I go in to resolve the block, I get an extra figure inserted around my MediaUpload component. The console output shows the structure of block except with the text added in. I saw a similar issue where the HTML nodes of edit function didn't match up with save function HTML nodes. After seeing that, I doubled check