Object type for block Attribute (Gutenberg)

Yes, there is. It will be like this: spacing: { type: ‘object’, default: { margin: { global: { …DIRECTIONS }, tablet: { …DIRECTIONS }, desktop: { …DIRECTIONS }, unit: ‘px’, size: 0, sync: false, syncTablet: false, syncDesktop: false }, padding: { global: { …DIRECTIONS }, tablet: { …DIRECTIONS }, desktop: { …DIRECTIONS }, unit: ‘px’, … Read more

How to allow your custom widget as block in gutemberg editor

I found the solution here and here. My OOP Code : Block_Type abstract Class Block_Type { public $handle; public $handle_editor; public $handle_block; private $editor_js_file; public $editor_js_file_path; private $editor_css_file; public $editor_css_file_path; private $css_file; public $css_file_path; public function __construct( $handle, $editor_js_file_path = null, $editor_css_file_path = null, $css_file_path = null ) { $this->handle = “h4a-” . $handle; $this->handle_editor … Read more

React to a change of the block alignment

Turns out that if one uses wp.data.subscribe, you’re able to intercept any change that occurr in the editor. As you can imagine, this is not very performant. So I’ve decided to create an extra hidden attribute that stores the old alignment value for the block, and fire the callback only when that attribute and the … Read more

How to enable Block Editor on the Posts page

There are two options: Easy (or without coding) In short, make sure the page has a non-empty content. Set the “Posts page” to none. Edit the page you wanted to be the posts page and enter any content — even a space () would be sufficient. Save the page. Now set the “Posts page” to … Read more

Unable to override MediaPlaceholder component

wp.blockEditor.MediaPlaceholder is not the class, it’s the following code in the Gutenberg/Block Editor’s media-placeholder file: export default compose( applyWithSelect, withFilters( ‘editor.MediaPlaceholder’ ), )( MediaPlaceholder ); Thus an infinite loop as the filter is applied constantly.

Trying to create a mouseover effect in html using Gutenberg editor

You were very close. You just had a single-quote swapped with a double-quote after the onmouseover. <figure class=”wp-block-image”> <img src=”https://website.com/wp-content/uploads/2019/08/image1.png” onmouseover=”this.src=”https://website.com//wp-content/uploads/2019/08/image2.png”;” onmouseout=”this.src=”https://website.com/wp-content/uploads/2019/08/image1.png”;” alt=”alttext” class=”wp-image-1111″/> </figure> I usually place semi-colons after the single-quotes to make it easier to tell when your quotes are balanced, whether Javascript requires it, or not.

Can Gutenberg be used as an editor on a page?

As Tammy states here: There is a plugin you may want to dig a little into https://github.com/tomjn/Frontenberg, this is purely a demonstration of putting Gutenberg on the front, not something that is planned yet. It may hold some insights though for you. Right now there is no option/shortcode to do this. That was written a … Read more

How to learn Gutenberg block development [closed]

The Block Editor Handbook offers the official documentation, along with some examples, including a Blocks Tutorial. It’s improving over time to include more and more information and examples. The JS for WP site offers some tutorials. The caveat is the Gutenberg Block Development course and the Advanced Gutenberg course were both created in the early … Read more