Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Subheading block #9355

Merged
merged 2 commits into from
Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think deprecating blocks is special and we shouldn't remove it in 3.9.0. We may remove it later when we merge to Core or when we build a deprecated versions across blocks. So I'd suggested removing this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notably, the same kind of message was put in the 3.5.0 section for the Text Columns block, which is why I put this message here. I will remove my message and create a separate PR for removing the one that was created for the Text Columns block.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh maybe let's keep for now then for the sake of consistency. It could be argued that it "encourages" people to migrate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, that was fast! I actually pushed a commit to remove the message, but it looks like you merged the branch before I did that, so I guess I will just delete the branch now. 😛


## 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 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