[EDIT] Problem 3 is solved (just I must to remove source: 'text'
from attributes declaration to allow store data in the the block’s comment delimiter).
Following this tutorial I made a plugin for embed peertube video. My block is as simple as two fields (instance and ID). Here it is a working example. And here the plugin.
I have three problems:
- The TextControl fields are shown 100% wide, instead center in the column:
Once created, I can not remove the block in the editor
The block shows the video content in the front end but when I come back to the editor, the fields are not stored. First is shown this:
Second, if I try to recover block with this button, the fields are shown empty (as in the first image).
This is the edit function (also here in context):
import { TextControl } from '@wordpress/components';
export default function Edit( { attributes, className, setAttributes } ) {
return (
<div className={ className }>
<TextControl
label={ __( 'Identificador', 'peertube' ) }
value={ attributes.identificador }
onChange={ ( val ) => setAttributes( { identificador: val } ) }
/>
<TextControl
label={ __( 'Instancia', 'peertube' ) }
value={ attributes.instancia }
onChange={ ( val ) => setAttributes( { instancia: val } ) }
/>
</div>
);
}
Here the register block function (also here in context):
registerBlockType( 'e451/peertube', {
attributes: {
identificador: {
type: 'string',
source: 'text',
selector: 'div',
},
instancia: {
type: 'string',
source: 'text',
selector: 'div',
},
},
apiVersion: 2,
title: __( 'Peertube video', 'peertube' ),
description: __( 'Insertar contenido de peertube', 'peertube' ),
category: 'embed',
icon: 'video-alt3',
supports: {
// Removes support for an HTML mode.
html: false,
},
edit: Edit,
save,
} );
Any help appreciated.
src
of valueundefined/videos/embed/undefined
, sawhttps://video.nogafam.es/videos/embed/2e3d35ba-f42f-49be-8bc2-97a770785570
.