Skip to content

Commit

Permalink
Merge pull request #2627 from WordPress/update/default-block-name
Browse files Browse the repository at this point in the history
Registration: Rename default block handlers as reflecting name
  • Loading branch information
aduth authored Sep 1, 2017
2 parents 02ab8ee + d618f4b commit 6e663a4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions blocks/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export {
unregisterBlockType,
setUnknownTypeHandlerName,
getUnknownTypeHandlerName,
setDefaultBlock,
getDefaultBlock,
setDefaultBlockName,
getDefaultBlockName,
getBlockType,
getBlockTypes,
} from './registration';
4 changes: 2 additions & 2 deletions blocks/api/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export function getUnknownTypeHandlerName() {
*
* @param {string} name Block name
*/
export function setDefaultBlock( name ) {
export function setDefaultBlockName( name ) {
defaultBlockName = name;
}

Expand All @@ -149,7 +149,7 @@ export function setDefaultBlock( name ) {
*
* @return {?string} Blog name
*/
export function getDefaultBlock() {
export function getDefaultBlockName() {
return defaultBlockName;
}

Expand Down
16 changes: 8 additions & 8 deletions blocks/api/test/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
unregisterBlockType,
setUnknownTypeHandlerName,
getUnknownTypeHandlerName,
setDefaultBlock,
getDefaultBlock,
setDefaultBlockName,
getDefaultBlockName,
getBlockType,
getBlockTypes,
} from '../registration';
Expand All @@ -33,7 +33,7 @@ describe( 'blocks', () => {
unregisterBlockType( block.name );
} );
setUnknownTypeHandlerName( undefined );
setDefaultBlock( undefined );
setDefaultBlockName( undefined );
console.error = error;
} );

Expand Down Expand Up @@ -155,17 +155,17 @@ describe( 'blocks', () => {
} );
} );

describe( 'setDefaultBlock()', () => {
describe( 'setDefaultBlockName()', () => {
it( 'assigns default block name', () => {
setDefaultBlock( 'core/test-block' );
setDefaultBlockName( 'core/test-block' );

expect( getDefaultBlock() ).toBe( 'core/test-block' );
expect( getDefaultBlockName() ).toBe( 'core/test-block' );
} );
} );

describe( 'getDefaultBlock()', () => {
describe( 'getDefaultBlockName()', () => {
it( 'defaults to undefined', () => {
expect( getDefaultBlock() ).toBeUndefined();
expect( getDefaultBlockName() ).toBeUndefined();
} );
} );

Expand Down
4 changes: 2 additions & 2 deletions blocks/library/paragraph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import classnames from 'classnames';
* Internal dependencies
*/
import './style.scss';
import { registerBlockType, createBlock, source, setDefaultBlock } from '../../api';
import { registerBlockType, createBlock, source, setDefaultBlockName } from '../../api';
import AlignmentToolbar from '../../alignment-toolbar';
import BlockAlignmentToolbar from '../../block-alignment-toolbar';
import BlockControls from '../../block-controls';
Expand Down Expand Up @@ -195,4 +195,4 @@ registerBlockType( 'core/paragraph', {
},
} );

setDefaultBlock( 'core/paragraph' );
setDefaultBlockName( 'core/paragraph' );
4 changes: 2 additions & 2 deletions editor/modes/visual-editor/block-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { throttle, reduce, noop } from 'lodash';
*/
import { __ } from '@wordpress/i18n';
import { Component } from '@wordpress/element';
import { serialize, getDefaultBlock, createBlock } from '@wordpress/blocks';
import { serialize, getDefaultBlockName, createBlock } from '@wordpress/blocks';
import { IconButton } from '@wordpress/components';
import { keycodes } from '@wordpress/utils';

Expand Down Expand Up @@ -195,7 +195,7 @@ class VisualEditorBlockList extends Component {
}

appendDefaultBlock() {
const newBlock = createBlock( getDefaultBlock() );
const newBlock = createBlock( getDefaultBlockName() );
this.props.onInsertBlock( newBlock );
}

Expand Down

0 comments on commit 6e663a4

Please sign in to comment.