diff --git a/packages/rich-text/src/register-format-type.js b/packages/rich-text/src/register-format-type.js index b271091cbe6a0..8ea19a97f595f 100644 --- a/packages/rich-text/src/register-format-type.js +++ b/packages/rich-text/src/register-format-type.js @@ -82,7 +82,10 @@ export function registerFormatType( name, settings ) { richTextStore ).getFormatTypeForBareElement( settings.tagName ); - if ( formatTypeForBareElement ) { + if ( + formatTypeForBareElement && + formatTypeForBareElement.name !== 'core/unknown' + ) { window.console.error( `Format "${ formatTypeForBareElement.name }" is already registered to handle bare tag name "${ settings.tagName }".` ); diff --git a/packages/rich-text/src/test/register-format-type.js b/packages/rich-text/src/test/register-format-type.js index 0d044d28facfa..0f5c16eabf232 100644 --- a/packages/rich-text/src/test/register-format-type.js +++ b/packages/rich-text/src/test/register-format-type.js @@ -1,7 +1,7 @@ /** * WordPress dependencies */ -import { select } from '@wordpress/data'; +import { dispatch, select } from '@wordpress/data'; /** * Internal dependencies @@ -11,10 +11,21 @@ import { unregisterFormatType } from '../unregister-format-type'; import { getFormatType } from '../get-format-type'; import { store as richTextStore } from '../store'; +const UNKNOWN_FORMAT = { + name: 'core/unknown', + title: 'Clear Unknown Formatting', + tagName: '*', + className: null, + edit: () => null, +}; + describe( 'registerFormatType', () => { beforeAll( () => { // Initialize the rich-text store. require( '../store' ); + + // Register "core/unknown" format + dispatch( richTextStore ).addFormatTypes( UNKNOWN_FORMAT ); } ); afterEach( () => {