From 2412cafe407be0555936b14d74b71b129d8e6856 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 14 May 2018 10:00:26 +0100 Subject: [PATCH] Use the new API for the video block --- core-blocks/index.js | 7 ++++++- core-blocks/video/index.js | 20 +++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/core-blocks/index.js b/core-blocks/index.js index a6c83b08da036..d3a888838a37a 100644 --- a/core-blocks/index.js +++ b/core-blocks/index.js @@ -7,6 +7,7 @@ import { setUnknownTypeHandlerName, } from '@wordpress/blocks'; import { deprecated } from '@wordpress/utils'; +import { dispatch } from '@wordpress/data'; /** * Internal dependencies @@ -78,11 +79,15 @@ export const registerCoreBlocks = () => { table, textColumns, verse, - video, ].forEach( ( { name, settings } ) => { registerBlockType( name, settings ); } ); + [ video ].forEach( ( { name, definition, implementation } ) => { + dispatch( 'core/blocks' ).addBlockTypes( { name, ...definition } ); + dispatch( 'core/blocks' ).implementBlockTypes( { name, ...implementation } ); + } ); + setDefaultBlockName( paragraph.name ); setUnknownTypeHandlerName( freeform.name ); }; diff --git a/core-blocks/video/index.js b/core-blocks/video/index.js index 891ac72c6737d..db5e47c7e6f06 100644 --- a/core-blocks/video/index.js +++ b/core-blocks/video/index.js @@ -30,15 +30,10 @@ import './editor.scss'; export const name = 'core/video'; -export const settings = { +export const definition = { title: __( 'Video' ), - description: __( 'Embed an video file and a simple video player.' ), - - icon: 'format-video', - category: 'common', - attributes: { align: { type: 'string', @@ -48,12 +43,23 @@ export const settings = { }, src: { type: 'string', + }, + caption: { + type: 'array', + }, + }, +}; + +export const implementation = { + icon: 'format-video', + + attributes: { + src: { source: 'attribute', selector: 'video', attribute: 'src', }, caption: { - type: 'array', source: 'children', selector: 'figcaption', },