Use page Title in Gutenberg custom banner block

Question

I have created a custom banner image block for Gutenberg, which works great, but
I want to know if it is possible to use the page title as the current banner text
placeholder until it has been edited?

enter image description here

My Edit function is

 return [
            el('div', {className:'header-banner'},
                el(
                    element.Fragment,
                    null,
                    controls,
                    el( "div",{
                        className: 'banner-image',
                        style: { backgroundImage: 'url('+attributes.mediaURL+')' }
                    },
                    attributes.title || isSelected ?  el(RichText, {
                            key: 'editable',
                            tagName: "h1",
                            className: "banner-title",
                            //Can i add the page title in here if it is avaiable??
                            //placeholder: i18n.__('Write title…'),
                            value: attributes.title,
                            onChange: function onChange(value) {
                                return props.setAttributes({ title: value });
                            },
                            inlineToolbar: true
                        }) : null 

                    )
                )
            )//header-banner
        ];    

Thanks 🙂

0
Jim-miraidev 4 years 2020-03-03T15:50:52-05:00 0 Answers 101 views 0

Leave an answer

Browse
Browse