scaffold-command/templates/block-index-js.mustache
2019-01-29 20:15:48 +05:30

84 lines
2.7 KiB
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

( function( wp ) {
/**
* Registers a new block provided a unique name and an object defining its behavior.
* @see https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/#registering-a-block
*/
var registerBlockType = wp.blocks.registerBlockType;
/**
* Returns a new element of given type. Element is an abstraction layer atop React.
* @see https://wordpress.org/gutenberg/handbook/designers-developers/developers/packages/packages-element/
*/
var el = wp.element.createElement;
/**
* Retrieves the translation of text.
* @see https://wordpress.org/gutenberg/handbook/designers-developers/developers/packages/packages-i18n/
*/
var __ = wp.i18n.__;
/**
* Every block starts by registering a new block type definition.
* @see https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/#registering-a-block
*/
registerBlockType( '{{namespace}}/{{slug}}', {
/**
* This is the display title for your block, which can be translated with `i18n` functions.
* The block inserter will show this name.
*/
title: __( '{{title_ucfirst_js}}', '{{namespace}}' ),
{{#dashicon}}
/**
* An icon property should be specified to make it easier to identify a block.
* These can be any of WordPress Dashicons, or a custom svg element.
*/
icon: '{{dashicon}}',
{{/dashicon}}
/**
* Blocks are grouped into categories to help users browse and discover them.
* The categories provided by core are `common`, `embed`, `formatting`, `layout` and `widgets`.
*/
category: '{{category}}',
/**
* Optional block extended support features.
*/
supports: {
// Removes support for an HTML mode.
html: false,
},
/**
* The edit function describes the structure of your block in the context of the editor.
* This represents what the editor will render when the block is used.
* @see https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#edit
*
* @param {Object} [props] Properties passed from the editor.
* @return {Element} Element to render.
*/
edit: function( props ) {
return el(
'p',
{ className: props.className },
__( 'Hello from the editor!', '{{namespace}}' )
);
},
/**
* The save function defines the way in which the different attributes should be combined
* into the final markup, which is then serialized by Gutenberg into `post_content`.
* @see https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#save
*
* @return {Element} Element to render.
*/
save: function() {
return el(
'p',
{},
__( 'Hello from the saved content!', '{{namespace}}' )
);
}
} );
} )(
window.wp
);