Skip to content

Commit

Permalink
Use the new API for the video block
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed May 14, 2018
1 parent 32a6a17 commit 2412caf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
7 changes: 6 additions & 1 deletion core-blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
setUnknownTypeHandlerName,
} from '@wordpress/blocks';
import { deprecated } from '@wordpress/utils';
import { dispatch } from '@wordpress/data';

/**
* Internal dependencies
Expand Down Expand Up @@ -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 );
};
Expand Down
20 changes: 13 additions & 7 deletions core-blocks/video/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
},
Expand Down

0 comments on commit 2412caf

Please sign in to comment.