UNPKG

blockpluginwromo

Version:

Example block written with ESNext standard and JSX support – build step required.

67 lines (58 loc) 2.18 kB
/** * BLOCK: block-plugin-wromo * * Registering a basic block with Gutenberg. * Simple block, renders and saves the same content without any interactivity. */ /** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; import { registerBlockType } from '@wordpress/blocks'; import { RichText } from '@wordpress/block-editor'; import { Fragment } from '@wordpress/element'; /** * Internal dependencies */ import './editor.scss'; import './style.scss'; /** * Register: a Gutenberg Block. * * Registers a new block provided a unique name and an object defining its * behavior. Once registered, the block is made editor as an option to any * editor interface where blocks are implemented. * * @link https://wordpress.org/gutenberg/handbook/designers-developers/developers/tutorials/block-tutorial/creating-dynamic-blocks/ * @param {string} name Block name. * @param {Object} settings Block settings. * @return {?WPBlock} The block, if it has been successfully * registered; otherwise `undefined`. */ registerBlockType( 'create-block/block-plugin-wromo', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block. title: __( 'block-plugin-wromo' ), // Block title. icon: 'smiley', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/. category: 'common', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. keywords: [ __( 'block-plugin-wromo — CGB Block' ), __( 'CGB Example' ), __( 'create-guten-block' ), ], attributes: { content: { type: 'string', source: 'html', selector: 'div', }, }, /** * 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/ * * @return {Element} Element to render. */ edit: ( { attributes, className, setAttributes } ) => { const { content } = attributes;