From d618f4be7cfd7809dbe3986cec57ce51cd5d246d Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Thu, 31 Aug 2017 08:45:23 -0400 Subject: [PATCH] Registration: Rename default block handlers as reflecting name --- blocks/api/index.js | 4 ++-- blocks/api/registration.js | 4 ++-- blocks/api/test/registration.js | 16 ++++++++-------- blocks/library/paragraph/index.js | 4 ++-- editor/modes/visual-editor/block-list.js | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/blocks/api/index.js b/blocks/api/index.js index b25e28735a5c8..c6445f4a65f02 100644 --- a/blocks/api/index.js +++ b/blocks/api/index.js @@ -14,8 +14,8 @@ export { unregisterBlockType, setUnknownTypeHandlerName, getUnknownTypeHandlerName, - setDefaultBlock, - getDefaultBlock, + setDefaultBlockName, + getDefaultBlockName, getBlockType, getBlockTypes, } from './registration'; diff --git a/blocks/api/registration.js b/blocks/api/registration.js index 689f9ffe297a0..2bf153fcd023d 100644 --- a/blocks/api/registration.js +++ b/blocks/api/registration.js @@ -140,7 +140,7 @@ export function getUnknownTypeHandlerName() { * * @param {string} name Block name */ -export function setDefaultBlock( name ) { +export function setDefaultBlockName( name ) { defaultBlockName = name; } @@ -149,7 +149,7 @@ export function setDefaultBlock( name ) { * * @return {?string} Blog name */ -export function getDefaultBlock() { +export function getDefaultBlockName() { return defaultBlockName; } diff --git a/blocks/api/test/registration.js b/blocks/api/test/registration.js index aa5838a66f916..c177deb4fa7c1 100644 --- a/blocks/api/test/registration.js +++ b/blocks/api/test/registration.js @@ -13,8 +13,8 @@ import { unregisterBlockType, setUnknownTypeHandlerName, getUnknownTypeHandlerName, - setDefaultBlock, - getDefaultBlock, + setDefaultBlockName, + getDefaultBlockName, getBlockType, getBlockTypes, } from '../registration'; @@ -33,7 +33,7 @@ describe( 'blocks', () => { unregisterBlockType( block.name ); } ); setUnknownTypeHandlerName( undefined ); - setDefaultBlock( undefined ); + setDefaultBlockName( undefined ); console.error = error; } ); @@ -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(); } ); } ); diff --git a/blocks/library/paragraph/index.js b/blocks/library/paragraph/index.js index 1bc423718d159..4f1cbc2c44f03 100644 --- a/blocks/library/paragraph/index.js +++ b/blocks/library/paragraph/index.js @@ -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'; @@ -195,4 +195,4 @@ registerBlockType( 'core/paragraph', { }, } ); -setDefaultBlock( 'core/paragraph' ); +setDefaultBlockName( 'core/paragraph' ); diff --git a/editor/modes/visual-editor/block-list.js b/editor/modes/visual-editor/block-list.js index 4295b4614a350..92cef516335cd 100644 --- a/editor/modes/visual-editor/block-list.js +++ b/editor/modes/visual-editor/block-list.js @@ -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'; @@ -195,7 +195,7 @@ class VisualEditorBlockList extends Component { } appendDefaultBlock() { - const newBlock = createBlock( getDefaultBlock() ); + const newBlock = createBlock( getDefaultBlockName() ); this.props.onInsertBlock( newBlock ); }