From 64aa61886383bbdd9a0aa501e12555dfddc0d597 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Tue, 1 May 2018 13:31:16 +0100 Subject: [PATCH] Add deprecation message for wp.blocks.* --- editor/index.js | 73 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/editor/index.js b/editor/index.js index d1a2e31e28acd..4b7b862d1b9e3 100644 --- a/editor/index.js +++ b/editor/index.js @@ -1,4 +1,77 @@ +/** + * External dependencies + */ +import { forEach } from 'lodash'; + +/** + * WordPress dependencies + */ +import { Component } from '@wordpress/element'; +import { deprecated } from '@wordpress/utils'; + import './store'; import './hooks'; export * from './components'; + +import { + Autocomplete, + AlignmentToolbar, + BlockAlignmentToolbar, + BlockControls, + BlockEdit, + BlockFormatControls, + BlockIcon, + ColorPalette, + ContrastChecker, + ImagePlaceholder, + InnerBlocks, + InspectorAdvancedControls, + InspectorControls, + PlainText, + RichText, + RichTextProvider, + MediaUpload, + UrlInput, + UrlInputButton, +} from './components'; + +const componentsToDepreacate = { + Autocomplete, + AlignmentToolbar, + BlockAlignmentToolbar, + BlockControls, + BlockEdit, + BlockFormatControls, + BlockIcon, + ColorPalette, + ContrastChecker, + ImagePlaceholder, + InnerBlocks, + InspectorAdvancedControls, + InspectorControls, + PlainText, + RichText, + RichTextProvider, + MediaUpload, + UrlInput, + UrlInputButton, +}; + +forEach( componentsToDepreacate, ( WrappedComponent, key ) => { + wp.blocks[ key ] = class extends Component { + constructor() { + super( ...arguments ); + + deprecated( 'wp.blocks.' + key, { + version: '3.1', + alternative: 'wp.editor.' + key, + plugin: 'Gutenberg', + } ); + } + + render() { + return ; + } + }; +} );