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 { __ } 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',
@ -14,15 +15,28 @@ registerBlockType( '<NAMESPACE>/<SLUG>', {
html: false,
},
edit( props ) {
attributes: {
name: {
type: 'string',
source: 'text',
selector: 'p'
default: __('A default name', '<NAMESPACE>'), // FIXME replace <NAMESPACE>
},
}
edit( { attributes, className } ) {
return (
<p className={ props.className }>
{ __( 'Hello from the editor!', 'room-vw' ) }
<p className={ className }>
{ attributes.name }
</p>
);
},
save() {
return <p>{ __( 'Hello from the saved content!', 'room-vw' ) }</p>;
return (
<p>
{ attributes.name }
</p>;
);
},
} );