Skip to content

Commit

Permalink
Deprecate Subheading block (#9355)
Browse files Browse the repository at this point in the history
* Deprecate Subheading block

* Keep custom CSS classes in Subheading→Paragraph transform
  • Loading branch information
ZebulanStanphill authored and youknowriad committed Aug 27, 2018
1 parent 349e892 commit 18f45f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
1 change: 1 addition & 0 deletions docs/reference/deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Gutenberg's deprecation policy is intended to support backwards-compatibility fo
- `wp.editor.getColorName` has been removed. Please use `wp.editor.getColorObjectByColorValue` instead.
- `wp.editor.getColorClass` has been renamed. Please use `wp.editor.getColorClassName` instead.
- `value` property in color objects passed by `wp.editor.withColors` has been removed. Please use color property instead.
- The Subheading block has been removed. Please use the Paragraph block instead.

## 3.8.0

Expand Down
30 changes: 12 additions & 18 deletions packages/block-library/src/subhead/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* WordPress dependencies
*/
import deprecated from '@wordpress/deprecated';
import { __ } from '@wordpress/i18n';
import { Fragment } from '@wordpress/element';
import { createBlock } from '@wordpress/blocks';
Expand All @@ -13,15 +14,17 @@ import {
export const name = 'core/subhead';

export const settings = {
title: __( 'Subheading' ),
title: __( 'Subheading (deprecated)' ),

description: __( 'What’s a subhead? Smaller than a headline, bigger than basic text.' ),
description: __( 'This block is deprecated. Please use the Paragraph block instead.' ),

icon: <svg role="img" aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7.1 6l-.5 3h4.5L9.4 19h3l1.8-10h4.5l.5-3H7.1z" /></svg>,

category: 'common',

supports: {
// Hide from inserter as this block is deprecated.
inserter: false,
multiple: false,
},

Expand All @@ -37,33 +40,24 @@ export const settings = {
},

transforms: {
from: [
{
type: 'block',
blocks: [ 'core/paragraph' ],
transform: ( { content } ) => {
return createBlock( 'core/subhead', {
content,
} );
},
},
],
to: [
{
type: 'block',
blocks: [ 'core/paragraph' ],
transform: ( { content } ) => {
return createBlock( 'core/paragraph', {
content,
} );
},
transform: ( attributes ) =>
createBlock( 'core/paragraph', attributes ),
},
],
},

edit( { attributes, setAttributes, className } ) {
const { align, content, placeholder } = attributes;

deprecated( 'The Subheading block', {
alternative: 'the Paragraph block',
plugin: 'Gutenberg',
} );

return (
<Fragment>
<BlockControls>
Expand Down

0 comments on commit 18f45f9

Please sign in to comment.