Component toggle not toggling

I used this toggler to add a class to an element if checked. Maybe your goal is the same with a class for a larger font. I used it like this: checked: !!textSize, onChange: function(){ textSize ? props.setAttributes({ textSize: ” }) : props.setAttributes({ textSize: ‘ big’ }) } So textSize controls the checked status and … Read more

How to get access the ID of all posts of custom post type in Gutenberg editor

var el = wp.element.createElement var withSelect = wp.data.withSelect wp.blocks.registerBlockType(‘voucher/shortcode’, { title: ‘Voucher Shortcode’, icon: ‘smiley’, category: ‘common’, attributes: { category: { type: ‘string’, } }, edit: withSelect( function( select ) { var pages = select(‘core’).getEntityRecords(‘postType’, ‘voucher’, { per_page: -1 }); return { posts: pages }; } ) (function(props) { if ( ! props.posts ) { … Read more

Add custom html classes to gutenberg wrapper

Block Filters are used to customize the class that wordpress already adds using following format wp-block-[plugin_name]-[block-name]. You can access that using this.props.className. You can also add the additional classes using Advanced Panel which is present on right sidebar. In the end you can use React.js component state to define custom classes (pseudo code is given … Read more