How to only enqueue block javascript on the frontend when its needed [duplicate]

To register scripts/styles conditionally if the page has a certain block you can follow the solution that @Will posted in the comments from a similar question. Copy/pasting with some modifications from that question: add_action( ‘enqueue_block_assets’, ‘myplugin_enqueue_if_block_is_present’ ); // Can only be loaded in the footer // add_action( ‘wp_enqueue_scripts’, ‘myplugin_enqueue_if_block_is_present’ ); // Can be loaded in … Read more

gutenberg block – how to force update after attribute changed?

In this instance, you are treating the asynchronous jQuery AJAX call as a synchronous function, resulting in getStoriesList() consistently returning undefined as the function returns immediately after dispatching the HTTP request; trying to access response.status should be consistently throwing ReferenceError: response is not defined. In almost all cases it is more ideal to access data … Read more

Activate Gutenberg in category-descriptions

This isn’t possible at the moment, Gutenberg is a post editor that relies on REST API endpoints, it’s not an arbitrary content area editor as TinyMCE is. Given some modification though it could be made to work with a custom data model and be a replacement, but it’s not a trivial task, and what’s involved … Read more

Blocks: set a default value for a TextControl

Try setting the default value in your attributes instead of on the TextControl. registerBlockType( ‘cgb/a11ytable’, { title: ‘Accessible Table’, icon: ‘screenoptions’, category: ‘common’, attributes: { numCols: { type: ‘number’, default: 2 // Added default value } }, edit: (props) => { const { attributes: { numCols }, className, setAttributes } = props; return [ el( … Read more

Proper, exhaustive documentation for wp.editor etc

I have gone through the implementation of all Gutenberg core blocks in start, so now if I have to know how to use something then I first find the closest core component which is implementing that and then looks at the documentation of that particular block via https://github.com/WordPress/gutenberg/tree/master/packages/block-library/src This process is solving problems for me … Read more

Are there ways to make the Gutenberg editor wider? And the HTML-block higher?

You have to enqueue first the style editor css function legit_block_editor_styles() { wp_enqueue_style( ‘legit-editor-styles’, get_theme_file_uri( ‘/style-editor.css’ ), false, ‘2.3’, ‘all’ );} add_action( ‘enqueue_block_editor_assets’, ‘legit_block_editor_styles’ ); Then you have to create that style-editor.css file inside your theme and then add this inside that file: .wp-block { max-width: 100%;}

Looking for all available options of Gutenberg Block

Option 1 Browse the block-library package in the Gutenberg’s GitHub repository, and find the block metadata in a JSON file named block.json of the specific block. For example, for the core/image block, you can find the metadata (e.g. all available/supported attributes) here: https://github.com/WordPress/gutenberg/blob/master/packages/block-library/src/image/block.json So basically, the URL format is: https://github.com/WordPress/gutenberg/blob/master/packages/block-library/src/{name}/block.json where {name} is the block … Read more