add attribute
This commit is contained in:
parent
407539444c
commit
18542739f7
26
src/index.js
26
src/index.js
|
@ -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>;
|
||||
);
|
||||
},
|
||||
} );
|
||||
|
|
Loading…
Reference in New Issue