add attribute

This commit is contained in:
Ray Elliott 2020-08-16 17:45:37 +01:00
parent 407539444c
commit 18542739f7
1 changed files with 20 additions and 6 deletions

View File

@ -4,8 +4,9 @@ import './editor.scss';
import { registerBlockType } from '@wordpress/blocks'; import { registerBlockType } from '@wordpress/blocks';
import { __ } from '@wordpress/i18n'; import { __ } from '@wordpress/i18n';
registerBlockType( '<NAMESPACE>/<SLUG>', {
title: __( '<BLOCK TITLE>', '<SLUG>' ), registerBlockType( '<NAMESPACE>/<SLUG>', { // FIXME replace <NAMESPACE>, <SLUG>, <BLOCK TITLE>
title: __( '<BLOCK TITLE>', '<SLUG>' ), // FIXME replace <BLOCK TITLE> ,<SLUG>
category: 'widgets', category: 'widgets',
@ -14,15 +15,28 @@ registerBlockType( '<NAMESPACE>/<SLUG>', {
html: false, html: false,
}, },
edit( props ) { attributes: {
name: {
type: 'string',
source: 'text',
selector: 'p'
default: __('A default name', '<NAMESPACE>'), // FIXME replace <NAMESPACE>
},
}
edit( { attributes, className } ) {
return ( return (
<p className={ props.className }> <p className={ className }>
{ __( 'Hello from the editor!', 'room-vw' ) } { attributes.name }
</p> </p>
); );
}, },
save() { save() {
return <p>{ __( 'Hello from the saved content!', 'room-vw' ) }</p>; return (
<p>
{ attributes.name }
</p>;
);
}, },
} ); } );