From 18542739f76d7456d86840d84d058ed32a2da1d1 Mon Sep 17 00:00:00 2001 From: ray Date: Sun, 16 Aug 2020 17:45:37 +0100 Subject: [PATCH] add attribute --- src/index.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/index.js b/src/index.js index d91789f..79600f9 100644 --- a/src/index.js +++ b/src/index.js @@ -4,8 +4,9 @@ import './editor.scss'; import { registerBlockType } from '@wordpress/blocks'; import { __ } from '@wordpress/i18n'; -registerBlockType( '/', { - title: __( '', '' ), + +registerBlockType( '/', { // FIXME replace , , + title: __( '', '' ), // FIXME replace , category: 'widgets', @@ -14,15 +15,28 @@ registerBlockType( '/', { html: false, }, - edit( props ) { + attributes: { + name: { + type: 'string', + source: 'text', + selector: 'p' + default: __('A default name', ''), // FIXME replace + }, + } + + edit( { attributes, className } ) { return ( -

- { __( 'Hello from the editor!', 'room-vw' ) } +

+ { attributes.name }

); }, save() { - return

{ __( 'Hello from the saved content!', 'room-vw' ) }

; + return ( +

+ { attributes.name } +

; + ); }, } );