Skip to content

Commit

Permalink
Add deprecation message for wp.blocks.*
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed May 1, 2018
1 parent 3d65337 commit f87fa5e
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions editor/index.js
Original file line number Diff line number Diff line change
@@ -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 <WrappedComponent { ...this.props } />;
}
};
} );

0 comments on commit f87fa5e

Please sign in to comment.