diff --git a/core-blocks/test/full-content.js b/core-blocks/test/full-content.js index 78f04d0fae3d32..a76b37ad885275 100644 --- a/core-blocks/test/full-content.js +++ b/core-blocks/test/full-content.js @@ -87,8 +87,6 @@ function normalizeParsedBlocks( blocks ) { // Change client IDs to a predictable value block.clientId = '_clientId_' + index; - // TODO: Remove in 3.5 "UID" deprecation. - delete block.uid; // Walk each attribute and get a more concise representation of any // React elements diff --git a/edit-post/components/block-settings-menu/plugin-block-settings-menu-group.js b/edit-post/components/block-settings-menu/plugin-block-settings-menu-group.js index 2018035e92ff6b..24859cb92fcc3c 100644 --- a/edit-post/components/block-settings-menu/plugin-block-settings-menu-group.js +++ b/edit-post/components/block-settings-menu/plugin-block-settings-menu-group.js @@ -27,7 +27,7 @@ const PluginBlockSettingsMenuGroupSlot = ( { fillProps, selectedBlocks } ) => { }; PluginBlockSettingsMenuGroup.Slot = withSelect( ( select, { fillProps: { clientIds } } ) => ( { - selectedBlocks: select( 'core/editor' ).getBlocksByUID( clientIds ), + selectedBlocks: select( 'core/editor' ).getBlocksByClientId( clientIds ), } ) )( PluginBlockSettingsMenuGroupSlot ); export default PluginBlockSettingsMenuGroup; diff --git a/edit-post/components/block-settings-menu/plugin-block-settings-menu-item.js b/edit-post/components/block-settings-menu/plugin-block-settings-menu-item.js index 9fd8b376c1478c..50bd460a11624c 100644 --- a/edit-post/components/block-settings-menu/plugin-block-settings-menu-item.js +++ b/edit-post/components/block-settings-menu/plugin-block-settings-menu-item.js @@ -7,7 +7,7 @@ import { difference } from 'lodash'; * WordPress dependencies */ import { IconButton } from '@wordpress/components'; -import { compose } from '@wordpress/element'; +import { compose } from '@wordpress/compose'; /** * Internal dependencies diff --git a/lib/client-assets.php b/lib/client-assets.php index bcf6027e3877a1..3d9d1ca963c273 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -266,7 +266,7 @@ function gutenberg_register_scripts_and_styles() { wp_register_script( 'wp-utils', gutenberg_url( 'build/utils/index.js' ), - array( 'lodash', 'wp-api-fetch', 'wp-deprecated', 'wp-html-entities', 'wp-i18n', 'wp-editor' ), + array( 'lodash', 'wp-api-fetch', 'wp-data', 'wp-deprecated', 'wp-i18n', 'wp-editor' ), filemtime( gutenberg_dir_path() . 'build/utils/index.js' ), true ); @@ -322,7 +322,7 @@ function gutenberg_register_scripts_and_styles() { wp_register_script( 'wp-element', gutenberg_url( 'build/element/index.js' ), - array( 'react', 'react-dom', 'wp-is-shallow-equal', 'lodash', 'wp-deprecated' ), + array( 'react', 'react-dom', 'lodash' ), filemtime( gutenberg_dir_path() . 'build/element/index.js' ), true ); diff --git a/package-lock.json b/package-lock.json index 0e84731c3789d6..2c907e27b958c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2406,7 +2406,6 @@ "@wordpress/viewport": "file:packages/viewport", "@wordpress/wordcount": "file:packages/wordcount", "classnames": "^2.2.5", - "dom-react": "^2.2.1", "dom-scroll-into-view": "^1.2.1", "element-closest": "^2.0.2", "lodash": "^4.17.10", @@ -2425,8 +2424,6 @@ "version": "file:packages/element", "requires": { "@babel/runtime-corejs2": "7.0.0-beta.56", - "@wordpress/deprecated": "file:packages/deprecated", - "@wordpress/is-shallow-equal": "file:packages/is-shallow-equal", "lodash": "^4.17.10", "react": "^16.4.1", "react-dom": "^16.4.1" @@ -6632,11 +6629,6 @@ "esutils": "^2.0.2" } }, - "dom-react": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/dom-react/-/dom-react-2.2.1.tgz", - "integrity": "sha512-kqvoG+Q5oiJMQzQi245ZVA/X2Py2lBCebGcQzQeR51jOJqVghWBodKoJcitX8VRV+e6ku+9hRS+Bev/zmlSPsg==" - }, "dom-scroll-into-view": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/dom-scroll-into-view/-/dom-scroll-into-view-1.2.1.tgz", @@ -10652,6 +10644,16 @@ "source-map": "^0.5.7" } }, + "babel-jest": { + "version": "23.4.2", + "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-23.4.2.tgz", + "integrity": "sha512-wg1LJ2tzsafXqPFVgAsYsMCVD5U7kwJZAvbZIxVm27iOewsQw1BR7VZifDlMTEWVo3wasoPPyMdKXWCsfFPr3Q==", + "dev": true, + "requires": { + "babel-plugin-istanbul": "^4.1.6", + "babel-preset-jest": "^23.2.0" + } + }, "braces": { "version": "1.8.5", "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", @@ -12320,9 +12322,9 @@ "dev": true }, "kleur": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-1.0.1.tgz", - "integrity": "sha512-8srIZ5BK5PCJw1L/JN741xgNfSjuQNK9ImYbYzv7ZUD3WPfuywaY+yd7lQOphJ+2vwXnMLnRZoAh5X+orRt4LQ==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-2.0.1.tgz", + "integrity": "sha512-Zq/jyANIJ2uX8UZjWlqLwbyhcxSXJtT/Y89lClyeZd3l++3ztL1I5SSCYrbcbwSunTjC88N3WuMk0kRDQD6gzA==", "dev": true }, "known-css-properties": { @@ -16075,12 +16077,12 @@ "dev": true }, "prompts": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/prompts/-/prompts-0.1.12.tgz", - "integrity": "sha512-pgR1GE1JM8q8UsHVIgjdK62DPwvrf0kvaKWJ/mfMoCm2lwfIReX/giQ1p0AlMoUXNhQap/8UiOdqi3bOROm/eg==", + "version": "0.1.14", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-0.1.14.tgz", + "integrity": "sha512-rxkyiE9YH6zAz/rZpywySLKkpaj0NMVyNw1qhsubdbjjSgcayjTShDreZGlFMcGSu5sab3bAKPfFk78PB90+8w==", "dev": true, "requires": { - "kleur": "^1.0.0", + "kleur": "^2.0.1", "sisteransi": "^0.1.1" } }, diff --git a/packages/blocks/src/api/factory.js b/packages/blocks/src/api/factory.js index ef9de61959bd58..b7c7474f7dbc39 100644 --- a/packages/blocks/src/api/factory.js +++ b/packages/blocks/src/api/factory.js @@ -58,8 +58,6 @@ export function createBlock( name, blockAttributes = {}, innerBlocks = [] ) { // attributes, and their inner blocks. return { clientId, - // TODO: Remove from block interface in 3.5 "UID" deprecation. - uid: clientId, name, isValid: true, attributes, @@ -83,8 +81,6 @@ export function cloneBlock( block, mergeAttributes = {}, newInnerBlocks ) { return { ...block, clientId, - // TODO: Remove from block interface in 3.5 "UID" deprecation. - uid: uuid(), attributes: { ...block.attributes, ...mergeAttributes, diff --git a/packages/blocks/src/api/test/factory.js b/packages/blocks/src/api/test/factory.js index 12363de75f0723..c8fae328094527 100644 --- a/packages/blocks/src/api/test/factory.js +++ b/packages/blocks/src/api/test/factory.js @@ -1024,9 +1024,9 @@ describe( 'block factory', () => { const transformedBlocks = switchToBlockType( block, 'core/updated-text-block' ); - // Make sure the block UIDs are set as expected: the first + // Make sure the block client IDs are set as expected: the first // transformed block whose type matches the "destination" type gets - // to keep the existing block's UID. + // to keep the existing block's client ID. expect( transformedBlocks ).toHaveLength( 2 ); expect( transformedBlocks[ 0 ] ).toHaveProperty( 'clientId' ); expect( transformedBlocks[ 0 ].clientId ).not.toBe( block.clientId ); diff --git a/packages/components/src/deprecated.js b/packages/components/src/deprecated.js deleted file mode 100644 index 1f7714435ea6af..00000000000000 --- a/packages/components/src/deprecated.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * External dependencies - */ -import { mapValues } from 'lodash'; - -/** - * WordPress dependencies - */ -import { - ifCondition, - withGlobalEvents, - withInstanceId, - withSafeTimeout, - withState, -} from '@wordpress/compose'; -import deprecated from '@wordpress/deprecated'; - -const deprecatedFunctions = { - ifCondition, - withGlobalEvents, - withInstanceId, - withSafeTimeout, - withState, -}; - -export default mapValues( deprecatedFunctions, ( deprecatedFunction, key ) => { - return ( ...args ) => { - deprecated( 'wp.components.' + key, { - version: '3.5', - alternative: 'wp.compose.' + key, - } ); - - return deprecatedFunction( ...args ); - }; -} ); diff --git a/packages/components/src/index.js b/packages/components/src/index.js index ed5ccd81136fb1..182cb6e111c0d3 100644 --- a/packages/components/src/index.js +++ b/packages/components/src/index.js @@ -1,8 +1,3 @@ -/** - * Internal dependencies - */ -import deprecated from './deprecated'; - // Components // eslint-disable-next-line camelcase export { default as APIProvider, unstable__setApiSettings } from './higher-order/with-api-data/provider'; @@ -73,9 +68,3 @@ export { default as withFocusOutside } from './higher-order/with-focus-outside'; export { default as withFocusReturn } from './higher-order/with-focus-return'; export { default as withNotices } from './higher-order/with-notices'; export { default as withSpokenMessages } from './higher-order/with-spoken-messages'; - -export const ifCondition = deprecated.ifCondition; -export const withGlobalEvents = deprecated.withGlobalEvents; -export const withInstanceId = deprecated.withInstanceId; -export const withSafeTimeout = deprecated.withSafeTimeout; -export const withState = deprecated.withState; diff --git a/packages/compose/src/with-instance-id/README.md b/packages/compose/src/with-instance-id/README.md index 31dd5c3e845f26..c4cca426b107b1 100644 --- a/packages/compose/src/with-instance-id/README.md +++ b/packages/compose/src/with-instance-id/README.md @@ -10,7 +10,7 @@ Wrapping a component with `withInstanceId` provides a unique `instanceId` to ser /** * WordPress dependencies */ -import { withInstanceId } from '@wordpress/components'; +import { withInstanceId } from '@wordpress/compose'; function MyCustomElement( { instanceId } ) { return ( diff --git a/packages/compose/src/with-safe-timeout/README.md b/packages/compose/src/with-safe-timeout/README.md index 097e652b055b61..b397f7f173f8e4 100644 --- a/packages/compose/src/with-safe-timeout/README.md +++ b/packages/compose/src/with-safe-timeout/README.md @@ -9,7 +9,7 @@ withSafeTimeout /** * WordPress dependencies */ -import { withSafeTimeout } from '@wordpress/components'; +import { withSafeTimeout } from '@wordpress/compose'; function MyEffectfulComponent( { setTimeout } ) { return ( diff --git a/packages/editor/package.json b/packages/editor/package.json index 88cc8e12d4cd4b..d3d94984ce4d8a 100644 --- a/packages/editor/package.json +++ b/packages/editor/package.json @@ -43,7 +43,6 @@ "@wordpress/viewport": "file:../viewport", "@wordpress/wordcount": "file:../wordcount", "classnames": "^2.2.5", - "dom-react": "^2.2.1", "dom-scroll-into-view": "^1.2.1", "element-closest": "^2.0.2", "lodash": "^4.17.10", diff --git a/packages/editor/src/components/block-edit/index.js b/packages/editor/src/components/block-edit/index.js index d42f151da1a890..c4c78f906aef91 100644 --- a/packages/editor/src/components/block-edit/index.js +++ b/packages/editor/src/components/block-edit/index.js @@ -8,7 +8,6 @@ import { Component } from '@wordpress/element'; */ import Edit from './edit'; import { BlockEditContextProvider } from './context'; -import withDeprecatedUniqueId from '../with-deprecated-unique-id'; class BlockEdit extends Component { constructor( props ) { @@ -50,4 +49,4 @@ class BlockEdit extends Component { } } -export default withDeprecatedUniqueId( BlockEdit ); +export default BlockEdit; diff --git a/packages/editor/src/components/block-list/index.js b/packages/editor/src/components/block-list/index.js index 53f268ba871e1e..ed5c131cae9b2e 100644 --- a/packages/editor/src/components/block-list/index.js +++ b/packages/editor/src/components/block-list/index.js @@ -1,74 +1,18 @@ -/** - * External dependencies - */ -import { - reduce, - get, - map, -} from 'lodash'; - /** * WordPress dependencies */ -import { createElement } from '@wordpress/element'; import { withSelect } from '@wordpress/data'; -import deprecated from '@wordpress/deprecated'; /** * Internal dependencies */ import BlockListLayout from './layout'; -const UngroupedLayoutBlockList = withSelect( - ( select, ownProps ) => ( { - blockClientIds: select( 'core/editor' ).getBlockOrder( ownProps.rootClientId ), - } ) -)( BlockListLayout ); - -const GroupedLayoutBlockList = withSelect( - ( select, ownProps ) => ( { - blocks: select( 'core/editor' ).getBlocks( ownProps.rootClientId ), - } ), -)( ( { - blocks, - layouts, - ...props -} ) => map( layouts, ( layout ) => { - deprecated( 'grouped layout', { - alternative: 'intermediary nested inner blocks', - version: '3.5', - plugin: 'Gutenberg', - hint: 'See core Columns / Column block for reference implementation', - } ); - - // Filter blocks assigned to layout when rendering grouped layouts. - const layoutBlockClientIds = reduce( blocks, ( result, block ) => { - if ( get( block, [ 'attributes', 'layout' ] ) === layout.name ) { - result.push( block.clientId ); - } - - return result; - }, [] ); - - return ( - - ); -} ) ); - -const BlockList = ( props ) => createElement( - // BlockList can be provided with a layouts configuration, either grouped - // (blocks adjacent in markup) or ungrouped. This is inferred by the shape - // of the layouts configuration passed (grouped layout as array). - Array.isArray( props.layouts ) ? - GroupedLayoutBlockList : - UngroupedLayoutBlockList, - props -); +// TODO: This should be refactored to flatten BlockListLayout into this file. +export default withSelect( ( select, ownProps ) => { + const { getBlockOrder } = select( 'core/editor' ); -export default BlockList; + return { + blockClientIds: getBlockOrder( ownProps.rootClientId ), + }; +} )( BlockListLayout ); diff --git a/packages/editor/src/components/block-list/layout.js b/packages/editor/src/components/block-list/layout.js index e82b3c6f2602e9..59a9d8377875ac 100644 --- a/packages/editor/src/components/block-list/layout.js +++ b/packages/editor/src/components/block-list/layout.js @@ -27,7 +27,6 @@ import { compose } from '@wordpress/compose'; import BlockListBlock from './block'; import IgnoreNestedEvents from './ignore-nested-events'; import DefaultBlockAppender from '../default-block-appender'; -import withDeprecatedUniqueId from '../with-deprecated-unique-id'; class BlockListLayout extends Component { constructor( props ) { @@ -239,7 +238,6 @@ class BlockListLayout extends Component { } export default compose( [ - withDeprecatedUniqueId, withSelect( ( select, ownProps ) => { const { isSelectionEnabled, diff --git a/packages/editor/src/components/block-mover/index.js b/packages/editor/src/components/block-mover/index.js index f1c0af092de823..d28d131cbdfc6c 100644 --- a/packages/editor/src/components/block-mover/index.js +++ b/packages/editor/src/components/block-mover/index.js @@ -19,7 +19,6 @@ import { withInstanceId, compose } from '@wordpress/compose'; */ import { getBlockMoverDescription } from './mover-description'; import { upArrow, downArrow } from './arrows'; -import withDeprecatedUniqueId from '../with-deprecated-unique-id'; export class BlockMover extends Component { constructor() { @@ -107,7 +106,6 @@ export class BlockMover extends Component { } export default compose( - withDeprecatedUniqueId, withSelect( ( select, { clientIds, rootClientId } ) => { const { getBlock, getBlockIndex, getTemplateLock } = select( 'core/editor' ); const firstClientId = first( castArray( clientIds ) ); diff --git a/packages/editor/src/components/block-settings-menu/index.js b/packages/editor/src/components/block-settings-menu/index.js index 0b5c4d6cdb4338..bf7372600b7167 100644 --- a/packages/editor/src/components/block-settings-menu/index.js +++ b/packages/editor/src/components/block-settings-menu/index.js @@ -11,7 +11,6 @@ import { __ } from '@wordpress/i18n'; import { Component } from '@wordpress/element'; import { IconButton, Dropdown, NavigableMenu } from '@wordpress/components'; import { withDispatch } from '@wordpress/data'; -import { compose } from '@wordpress/compose'; /** * Internal dependencies @@ -25,7 +24,6 @@ import BlockHTMLConvertButton from './block-html-convert-button'; import BlockUnknownConvertButton from './block-unknown-convert-button'; import _BlockSettingsMenuFirstItem from './block-settings-menu-first-item'; import _BlockSettingsMenuPluginsExtension from './block-settings-menu-plugins-extension'; -import withDeprecatedUniqueId from '../with-deprecated-unique-id'; export class BlockSettingsMenu extends Component { constructor() { @@ -148,11 +146,8 @@ export class BlockSettingsMenu extends Component { } } -export default compose( [ - withDeprecatedUniqueId, - withDispatch( ( dispatch ) => ( { - onSelect( clientId ) { - dispatch( 'core/editor' ).selectBlock( clientId ); - }, - } ) ), -] )( BlockSettingsMenu ); +export default withDispatch( ( dispatch ) => ( { + onSelect( clientId ) { + dispatch( 'core/editor' ).selectBlock( clientId ); + }, +} ) )( BlockSettingsMenu ); diff --git a/packages/editor/src/components/block-title/index.js b/packages/editor/src/components/block-title/index.js index 5c729247d8a257..6629c167684370 100644 --- a/packages/editor/src/components/block-title/index.js +++ b/packages/editor/src/components/block-title/index.js @@ -3,12 +3,6 @@ */ import { withSelect } from '@wordpress/data'; import { getBlockType } from '@wordpress/blocks'; -import { compose } from '@wordpress/compose'; - -/** - * Internal dependencies - */ -import withDeprecatedUniqueId from '../with-deprecated-unique-id'; /** * Renders the block's configured title as a string, or empty if the title @@ -37,14 +31,11 @@ export function BlockTitle( { name } ) { return blockType.title; } -export default compose( [ - withDeprecatedUniqueId, - withSelect( ( select, ownProps ) => { - const { getBlockName } = select( 'core/editor' ); - const { clientId } = ownProps; +export default withSelect( ( select, ownProps ) => { + const { getBlockName } = select( 'core/editor' ); + const { clientId } = ownProps; - return { - name: getBlockName( clientId ), - }; - } ), -] )( BlockTitle ); + return { + name: getBlockName( clientId ), + }; +} )( BlockTitle ); diff --git a/packages/editor/src/components/default-block-appender/index.js b/packages/editor/src/components/default-block-appender/index.js index e0eb031c72a3be..fc8dd00203d93f 100644 --- a/packages/editor/src/components/default-block-appender/index.js +++ b/packages/editor/src/components/default-block-appender/index.js @@ -20,7 +20,6 @@ import { DotTip } from '@wordpress/nux'; import BlockDropZone from '../block-drop-zone'; import InserterWithShortcuts from '../inserter-with-shortcuts'; import Inserter from '../inserter'; -import withDeprecatedUniqueId from '../with-deprecated-unique-id'; export function DefaultBlockAppender( { isLocked, @@ -66,7 +65,6 @@ export function DefaultBlockAppender( { ); } export default compose( - withDeprecatedUniqueId, withSelect( ( select, ownProps ) => { const { getBlockCount, getBlock, getEditorSettings, getTemplateLock } = select( 'core/editor' ); const { isTipVisible } = select( 'core/nux' ); diff --git a/packages/editor/src/components/index.js b/packages/editor/src/components/index.js index 053df2136311db..3e909f4f784f62 100644 --- a/packages/editor/src/components/index.js +++ b/packages/editor/src/components/index.js @@ -22,7 +22,7 @@ export { default as RichText } from './rich-text'; export { default as RichTextProvider } from './rich-text/provider'; export { default as MediaPlaceholder } from './media-placeholder'; export { default as MediaUpload } from './media-upload'; -export { default as URLInput, UrlInput } from './url-input'; +export { default as URLInput } from './url-input'; export { default as URLInputButton } from './url-input/button'; // Post Related Components diff --git a/packages/editor/src/components/media-placeholder/index.js b/packages/editor/src/components/media-placeholder/index.js index 831280916abc69..f30e68d1cfb6e1 100644 --- a/packages/editor/src/components/media-placeholder/index.js +++ b/packages/editor/src/components/media-placeholder/index.js @@ -15,7 +15,6 @@ import { } from '@wordpress/components'; import { __, sprintf } from '@wordpress/i18n'; import { Component } from '@wordpress/element'; -import deprecated from '@wordpress/deprecated'; /** * Internal dependencies @@ -53,26 +52,8 @@ class MediaPlaceholder extends Component { onSubmitSrc( event ) { event.preventDefault(); - if ( this.state.src ) { - if ( this.props.onSelectUrl ) { - // TODO: In removing deprecation, ensure to simplify rendering - // to avoid checking for `onSelectUrl`. It also allows this - // function to be simplified to avoid truthiness test on - // `onSelectURL`, since it's required for the form invoking - // this function to be rendered at all. - deprecated( 'MediaPlaceholder `onSelectUrl` prop', { - alternative: '`onSelectURL` prop', - plugin: 'Gutenberg', - version: 'v3.5', - hint: 'The prop has been renamed.', - } ); - - this.props.onSelectUrl( this.state.src ); - } - - if ( this.props.onSelectURL ) { - this.props.onSelectURL( this.state.src ); - } + if ( this.state.src && this.props.onSelectURL ) { + this.props.onSelectURL( this.state.src ); } } @@ -101,7 +82,6 @@ class MediaPlaceholder extends Component { onSelect, value = {}, onSelectURL, - onSelectUrl, onHTMLDrop = noop, multiple = false, notices, @@ -120,7 +100,7 @@ class MediaPlaceholder extends Component { onFilesDrop={ this.onFilesUpload } onHTMLDrop={ onHTMLDrop } /> - { ( onSelectUrl || onSelectURL ) && ( + { onSelectURL && (
key.indexOf( 'data-mce-' ) === 0 ), - ...elementChildren - ); -} - /** * Given an HTMLElement from a TinyMCE editor body element, returns equivalent * WPBlockChildren value. The element may undergo some preprocessing to remove @@ -173,17 +127,6 @@ export function createBlockChildrenFromTinyMCEElement( element ) { }; } -/** - * Transforms an array of DOM Elements to their corresponding WP element. - * - * @param {Array} value DOM Elements. - * - * @return {WPElement} WP Element. - */ -export function domToElement( value ) { - return nodeListToReact( value || [], createTinyMCEElement ); -} - /** * Given an array of HTMLElement from a TinyMCE editor body element, returns an * equivalent WPBlockChildren value. The element may undergo some preprocessing @@ -247,9 +190,6 @@ export function domToFormat( value, format ) { case 'string': return domToString( value ); - case 'element': - return domToElement( value ); - case 'children': return domToBlockChildren( value ); } diff --git a/packages/editor/src/components/rich-text/index.js b/packages/editor/src/components/rich-text/index.js index e8c0e187c47d29..f4014adbd752f7 100644 --- a/packages/editor/src/components/rich-text/index.js +++ b/packages/editor/src/components/rich-text/index.js @@ -27,7 +27,6 @@ import { BACKSPACE, DELETE, ENTER, LEFT, RIGHT, rawShortcut } from '@wordpress/k import { Slot } from '@wordpress/components'; import { withSelect } from '@wordpress/data'; import { rawHandler, children } from '@wordpress/blocks'; -import deprecated from '@wordpress/deprecated'; import { withInstanceId, withSafeTimeout, compose } from '@wordpress/compose'; /** @@ -921,18 +920,6 @@ RichTextContainer.Content = ( { value, format, tagName: Tag, ...props } ) => { content = { value }; break; - case 'element': - // NOTE: In removing this, ensure to remove also every related - // function from `format.js`, including the `dom-react` dependency. - deprecated( 'RichText `element` format', { - version: '3.5', - plugin: 'Gutenberg', - alternative: 'the compatible `children` format', - } ); - - content = value; - break; - case 'children': content = { children.toHTML( value ) }; break; diff --git a/packages/editor/src/components/rich-text/test/__snapshots__/format.js.snap b/packages/editor/src/components/rich-text/test/__snapshots__/format.js.snap index 87da08bd7ecad1..f37c07abf9b01d 100644 --- a/packages/editor/src/components/rich-text/test/__snapshots__/format.js.snap +++ b/packages/editor/src/components/rich-text/test/__snapshots__/format.js.snap @@ -1,15 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`createTinyMCEElement should render a TinyMCE element 1`] = ` -
-

- Child -

-
-`; - exports[`domToBlockChildren should return the corresponding element 1`] = ` Array [ Object { @@ -30,15 +20,3 @@ Array [ }, ] `; - -exports[`domToElement should return the corresponding element 1`] = ` -Array [ -
- - content - -
, -] -`; diff --git a/packages/editor/src/components/rich-text/test/format.js b/packages/editor/src/components/rich-text/test/format.js index fd78aadcbf86ae..c55f2a54c24d0d 100644 --- a/packages/editor/src/components/rich-text/test/format.js +++ b/packages/editor/src/components/rich-text/test/format.js @@ -1,13 +1,3 @@ -/** - * External dependencies - */ -import { shallow } from 'enzyme'; - -/** - * WordPress dependencies - */ -import { createElement } from '@wordpress/element'; - /** * Internal dependencies */ @@ -16,10 +6,7 @@ import { isTinyMCEBogusElement, isTinyMCEBogusWrapperElement, getCleanTextNodeValue, - createTinyMCEElement, createBlockChildrenFromTinyMCEElement, - elementToString, - domToElement, domToBlockChildren, domToString, } from '../format'; @@ -104,66 +91,6 @@ describe( 'getCleanTextNodeValue', () => { } ); } ); -describe( 'createTinyMCEElement', () => { - const type = 'div'; - const children =

Child

; - - test( 'should return null', () => { - const props = { - 'data-mce-bogus': 'all', - }; - - expect( createTinyMCEElement( type, props, children ) ).toBeNull(); - } ); - - test( 'should return children', () => { - const props = { - 'data-mce-bogus': '', - }; - - const wrapper = createTinyMCEElement( type, props, children ); - expect( wrapper ).toEqual( [ children ] ); - } ); - - test( 'should render a TinyMCE element', () => { - const props = { - 'data-prop': 'hi', - }; - - const wrapper = shallow( createTinyMCEElement( type, props, children ) ); - expect( wrapper ).toMatchSnapshot(); - } ); -} ); - -describe( 'elementToString', () => { - test( 'should return an empty string for null element', () => { - expect( elementToString( null ) ).toBe( '' ); - } ); - - test( 'should return an empty string for an empty array', () => { - expect( elementToString( [] ) ).toBe( '' ); - } ); - - test( 'should return the HTML content ', () => { - const element = createElement( 'div', { className: 'container' }, - createElement( 'strong', {}, 'content' ) - ); - expect( elementToString( element ) ).toBe( '
content
' ); - } ); -} ); - -describe( 'domToElement', () => { - test( 'should return an empty array', () => { - expect( domToElement( [] ) ).toEqual( [] ); - } ); - - test( 'should return the corresponding element ', () => { - const domElement = document.createElement( 'div' ); - domElement.innerHTML = '
content
'; - expect( domToElement( domElement.childNodes ) ).toMatchSnapshot(); - } ); -} ); - describe( 'createBlockChildrenFromTinyMCEElement', () => { it( 'returns recusrively cleaned tinymce element as block children', () => { const element = document.createElement( 'div' ); diff --git a/packages/editor/src/components/url-input/index.js b/packages/editor/src/components/url-input/index.js index 1dc8de94f04820..2fddee9eb3a5d0 100644 --- a/packages/editor/src/components/url-input/index.js +++ b/packages/editor/src/components/url-input/index.js @@ -15,7 +15,6 @@ import { UP, DOWN, ENTER } from '@wordpress/keycodes'; import { Spinner, withSpokenMessages, Popover } from '@wordpress/components'; import { withInstanceId } from '@wordpress/compose'; import apiFetch from '@wordpress/api-fetch'; -import deprecated from '@wordpress/deprecated'; import { addQueryArgs } from '@wordpress/url'; // Since URLInput is rendered in the context of other inputs, but should be @@ -242,27 +241,4 @@ class URLInput extends Component { } } -// TODO: As part of deprecation of UrlInput, the temporary passthrough -// component needs access to the enhanced URLInput class, so it cannot be -// enhanced as part of its export default. Once the temporary passthrough is -// removed, this can be moved back to the export statement. -URLInput = withSpokenMessages( withInstanceId( URLInput ) ); - -export class UrlInput extends Component { - constructor() { - super( ...arguments ); - - deprecated( 'wp.editor.UrlInput', { - alternative: 'wp.editor.URLInput', - plugin: 'Gutenberg', - version: 'v3.5', - hint: 'The component has been renamed.', - } ); - } - - render() { - return ; - } -} - -export default URLInput; +export default withSpokenMessages( withInstanceId( URLInput ) ); diff --git a/packages/editor/src/components/with-deprecated-unique-id/index.js b/packages/editor/src/components/with-deprecated-unique-id/index.js deleted file mode 100644 index 3b49ec1225969b..00000000000000 --- a/packages/editor/src/components/with-deprecated-unique-id/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** - * External dependencies - */ -import { forOwn, compact, omit } from 'lodash'; - -/** - * WordPress dependencies - */ -import { createHigherOrderComponent } from '@wordpress/compose'; -import deprecated from '@wordpress/deprecated'; - -/** - * Set of deprecated UID props, where each key is the deprecated prop, its - * value the equivalent replacement. - * - * @type {Object} - */ -const DEPRECATED_UID_PROPS = { - lastBlockUID: 'lastBlockClientId', - rootUID: 'rootClientId', - uid: 'clientId', - uids: 'clientIds', -}; - -/** - * A higher-order component which replaces any instance of deprecated "UID" - * prop names with their updated equivalent prop, with a deprecated warning - * encouraging the developer to update their usage before its pending removal. - * - * @param {WPComponent} WrappedComponent Original component. - * - * @return {WPComponent} Enhanced component. - */ -export default createHigherOrderComponent( ( WrappedComponent ) => ( props ) => { - forOwn( DEPRECATED_UID_PROPS, ( replacement, prop ) => { - if ( ! props.hasOwnProperty( prop ) ) { - return; - } - - // Construct deprecated message, including original component's name - // if possible to retrieve. - const { name = WrappedComponent.displayName } = WrappedComponent; - const message = compact( [ - name, - `The \`${ prop }\` prop`, - ] ).join( ' ' ); - - deprecated( message, { - alternative: `the \`${ replacement }\` prop`, - plugin: 'Gutenberg', - version: 'v3.5', - } ); - - props = Object.assign( omit( props, prop ), { - [ replacement ]: props[ prop ], - } ); - } ); - - return ; -} ); diff --git a/packages/editor/src/store/selectors.js b/packages/editor/src/store/selectors.js index ffabf1c82f7019..05ce02ac882347 100644 --- a/packages/editor/src/store/selectors.js +++ b/packages/editor/src/store/selectors.js @@ -1185,9 +1185,7 @@ export function getBlockInsertionPoint( state ) { index = getBlockOrder( state ).length; } - // TODO: With deprecation of "UID" nomenclature in 3.5, ensure to remove - // the `rootUID` property here. - return { rootUID: rootClientId, rootClientId, layout, index }; + return { rootClientId, layout, index }; } /** @@ -1884,126 +1882,6 @@ export function canUserUseUnfilteredHTML( state ) { return has( getCurrentPost( state ), [ '_links', 'wp:action-unfiltered_html' ] ); } -export function getAdjacentBlockUid( state, startUID, modifier ) { - deprecated( 'getAdjacentBlockUid', { - alternative: 'getAdjacentBlockClientId', - version: 'v3.5', - plugin: 'Gutenberg', - } ); - - return getAdjacentBlockClientId( state, startUID, modifier ); -} - -export function getBlockRootUID( state, uid ) { - deprecated( 'getBlockRootUID', { - alternative: 'getBlockRootClientId', - version: 'v3.5', - plugin: 'Gutenberg', - } ); - - return getBlockRootClientId( state, uid ); -} - -export function getSelectedBlockUID( state ) { - deprecated( 'getSelectedBlockUID', { - alternative: 'getSelectedBlockClientId', - version: 'v3.5', - plugin: 'Gutenberg', - } ); - - return getSelectedBlockClientId( state ); -} - -export function getBlocksByUID( state, uids ) { - deprecated( 'getBlocksByUID', { - alternative: 'getBlocksByClientId', - version: 'v3.5', - plugin: 'Gutenberg', - } ); - - return getBlocksByClientId( state, uids ); -} - -export function getPreviousBlockUid( state, startUID ) { - deprecated( 'getPreviousBlockUid', { - alternative: 'getPreviousBlockClientId', - version: 'v3.5', - plugin: 'Gutenberg', - } ); - - return getPreviousBlockClientId( state, startUID ); -} - -export function getNextBlockUid( state, startUID ) { - deprecated( 'getNextBlockUid', { - alternative: 'getNextBlockClientId', - version: 'v3.5', - plugin: 'Gutenberg', - } ); - - return getNextBlockClientId( state, startUID ); -} - -export function getMultiSelectedBlockUids( state ) { - deprecated( 'getMultiSelectedBlockUids', { - alternative: 'getMultiSelectedBlockClientIds', - version: 'v3.5', - plugin: 'Gutenberg', - } ); - - return getMultiSelectedBlockClientIds( state ); -} - -export function getFirstMultiSelectedBlockUid( state ) { - deprecated( 'getFirstMultiSelectedBlockUid', { - alternative: 'getFirstMultiSelectedBlockClientId', - version: 'v3.5', - plugin: 'Gutenberg', - } ); - - return getFirstMultiSelectedBlockClientId( state ); -} - -export function getLastMultiSelectedBlockUid( state ) { - deprecated( 'getLastMultiSelectedBlockUid', { - alternative: 'getLastMultiSelectedBlockClientId', - version: 'v3.5', - plugin: 'Gutenberg', - } ); - - return getLastMultiSelectedBlockClientId( state ); -} - -export function getMultiSelectedBlocksStartUid( state ) { - deprecated( 'getMultiSelectedBlocksStartUid', { - alternative: 'getMultiSelectedBlocksStartClientId', - version: 'v3.5', - plugin: 'Gutenberg', - } ); - - return getMultiSelectedBlocksStartClientId( state ); -} - -export function getMultiSelectedBlocksEndUid( state ) { - deprecated( 'getMultiSelectedBlocksEndUid', { - alternative: 'getMultiSelectedBlocksEndClientId', - version: 'v3.5', - plugin: 'Gutenberg', - } ); - - return getMultiSelectedBlocksEndClientId( state ); -} - -export function getProvisionalBlockUID( state ) { - deprecated( 'getProvisionalBlockUID', { - alternative: 'getProvisionalBlockClientId', - version: 'v3.5', - plugin: 'Gutenberg', - } ); - - return getProvisionalBlockClientId( state ); -} - export function getSharedBlock( state, ref ) { deprecated( 'getSharedBlock', { alternative: 'getReusableBlock', diff --git a/packages/editor/src/store/test/selectors.js b/packages/editor/src/store/test/selectors.js index a1877d42fea629..33326dd179ba70 100644 --- a/packages/editor/src/store/test/selectors.js +++ b/packages/editor/src/store/test/selectors.js @@ -2553,8 +2553,6 @@ describe( 'selectors', () => { expect( getBlockInsertionPoint( state ) ).toEqual( { rootClientId: undefined, - // TODO: To be removed in 3.5 "UID" deprecation. - rootUID: undefined, layout: undefined, index: 1, } ); @@ -2587,8 +2585,6 @@ describe( 'selectors', () => { expect( getBlockInsertionPoint( state ) ).toEqual( { rootClientId: 'clientId1', - // TODO: To be removed in 3.5 "UID" deprecation. - rootUID: 'clientId1', layout: undefined, index: 1, } ); @@ -2619,8 +2615,6 @@ describe( 'selectors', () => { expect( getBlockInsertionPoint( state ) ).toEqual( { rootClientId: undefined, - // TODO: To be removed in 3.5 "UID" deprecation. - rootUID: undefined, layout: 'wide', index: 1, } ); @@ -2653,8 +2647,6 @@ describe( 'selectors', () => { expect( getBlockInsertionPoint( state ) ).toEqual( { rootClientId: undefined, - // TODO: To be removed in 3.5 "UID" deprecation. - rootUID: undefined, layout: undefined, index: 2, } ); @@ -2687,8 +2679,6 @@ describe( 'selectors', () => { expect( getBlockInsertionPoint( state ) ).toEqual( { rootClientId: undefined, - // TODO: To be removed in 3.5 "UID" deprecation. - rootUID: undefined, layout: undefined, index: 2, } ); diff --git a/packages/element/package.json b/packages/element/package.json index 8583e3b016e933..7a7a29a3fb28d8 100644 --- a/packages/element/package.json +++ b/packages/element/package.json @@ -22,8 +22,6 @@ "react-native": "src/index", "dependencies": { "@babel/runtime-corejs2": "7.0.0-beta.56", - "@wordpress/deprecated": "file:../deprecated", - "@wordpress/is-shallow-equal": "file:../is-shallow-equal", "lodash": "^4.17.10", "react": "^16.4.1", "react-dom": "^16.4.1" diff --git a/packages/element/src/deprecated.js b/packages/element/src/deprecated.js deleted file mode 100644 index 835d930955605b..00000000000000 --- a/packages/element/src/deprecated.js +++ /dev/null @@ -1,60 +0,0 @@ -/** - * External dependencies - */ -import { flowRight, upperFirst, camelCase } from 'lodash'; -import { Component } from 'react'; - -/** - * WordPress dependencies - */ -import deprecated from '@wordpress/deprecated'; -import isShallowEqual from '@wordpress/is-shallow-equal'; - -export function createHigherOrderComponent( mapComponentToEnhancedComponent, modifierName ) { - deprecated( 'wp.element.createHigherOrderComponent', { - version: '3.5', - alternative: 'wp.compose.createHigherOrderComponent', - } ); - - return ( OriginalComponent ) => { - const EnhancedComponent = mapComponentToEnhancedComponent( OriginalComponent ); - const { displayName = OriginalComponent.name || 'Component' } = OriginalComponent; - EnhancedComponent.displayName = `${ upperFirst( camelCase( modifierName ) ) }(${ displayName })`; - - return EnhancedComponent; - }; -} - -export const compose = ( ...args ) => { - deprecated( 'wp.element.compose', { - version: '3.5', - alternative: 'wp.compose.compose', - } ); - - return flowRight( ...args ); -}; - -export const pure = ( Wrapped ) => { - deprecated( 'wp.element.pure', { - version: '3.5', - alternative: 'wp.compose.pure', - } ); - - if ( Wrapped.prototype instanceof Component ) { - return class extends Wrapped { - shouldComponentUpdate( nextProps, nextState ) { - return ! isShallowEqual( nextProps, this.props ) || ! isShallowEqual( nextState, this.state ); - } - }; - } - - return class extends Component { - shouldComponentUpdate( nextProps ) { - return ! isShallowEqual( nextProps, this.props ); - } - - render() { - return ; - } - }; -}; diff --git a/packages/element/src/index.js b/packages/element/src/index.js index 866809c94ad1e4..b8369876e0215d 100644 --- a/packages/element/src/index.js +++ b/packages/element/src/index.js @@ -2,6 +2,3 @@ export * from './react'; export * from './react-platform'; export { default as renderToString } from './serialize'; export { default as RawHTML } from './raw-html'; - -// deprecated -export * from './deprecated'; diff --git a/test/e2e/specs/reusable-blocks.test.js b/test/e2e/specs/reusable-blocks.test.js index 64de7156542b00..412591396880ba 100644 --- a/test/e2e/specs/reusable-blocks.test.js +++ b/test/e2e/specs/reusable-blocks.test.js @@ -29,8 +29,8 @@ describe( 'Reusable Blocks', () => { // Remove all blocks from the post so that we're working with a clean slate await page.evaluate( () => { const blocks = wp.data.select( 'core/editor' ).getBlocks(); - const uids = blocks.map( ( block ) => block.uid ); - wp.data.dispatch( 'core/editor' ).removeBlocks( uids ); + const clientIds = blocks.map( ( block ) => block.clientId ); + wp.data.dispatch( 'core/editor' ).removeBlocks( clientIds ); } ); } ); diff --git a/test/integration/shortcode-converter.spec.js b/test/integration/shortcode-converter.spec.js index 87ad1c9929251c..285cb0d8e4a01a 100644 --- a/test/integration/shortcode-converter.spec.js +++ b/test/integration/shortcode-converter.spec.js @@ -30,8 +30,6 @@ describe( 'segmentHTMLToShortcodeBlock', () => { } ); // clientId will always be random. expectedBlock.clientId = transformed[ 1 ].clientId; - // TODO: Remove in 3.5 "UID" deprecation. - expectedBlock.uid = expectedBlock.clientId; expect( transformed[ 1 ] ).toEqual( expectedBlock ); expect( transformed[ 2 ] ).toBe( ` @@ -49,8 +47,6 @@ describe( 'segmentHTMLToShortcodeBlock', () => { } ); // clientId will always be random. firstExpectedBlock.clientId = transformed[ 1 ].clientId; - // TODO: Remove in 3.5 "UID" deprecation. - firstExpectedBlock.uid = firstExpectedBlock.clientId; expect( transformed[ 1 ] ).toEqual( firstExpectedBlock ); expect( transformed[ 2 ] ).toEqual( `

` ); @@ -59,8 +55,6 @@ describe( 'segmentHTMLToShortcodeBlock', () => { } ); // clientId will always be random. secondExpectedBlock.clientId = transformed[ 3 ].clientId; - // TODO: Remove in 3.5 "UID" deprecation. - secondExpectedBlock.uid = secondExpectedBlock.clientId; expect( transformed[ 3 ] ).toEqual( secondExpectedBlock ); expect( transformed[ 4 ] ).toEqual( '

' ); expect( transformed ).toHaveLength( 5 ); @@ -79,8 +73,6 @@ describe( 'segmentHTMLToShortcodeBlock', () => { } ); // clientId will always be random. firstExpectedBlock.clientId = transformed[ 1 ].clientId; - // TODO: Remove in 3.5 "UID" deprecation. - firstExpectedBlock.uid = firstExpectedBlock.clientId; expect( transformed[ 1 ] ).toEqual( firstExpectedBlock ); expect( transformed[ 2 ] ).toEqual( `

` ); @@ -89,8 +81,6 @@ describe( 'segmentHTMLToShortcodeBlock', () => { } ); // clientId will always be random. secondExpectedBlock.clientId = transformed[ 3 ].clientId; - // TODO: Remove in 3.5 "UID" deprecation. - secondExpectedBlock.uid = secondExpectedBlock.clientId; expect( transformed[ 3 ] ).toEqual( secondExpectedBlock ); expect( transformed[ 4 ] ).toEqual( `

` ); @@ -99,8 +89,6 @@ describe( 'segmentHTMLToShortcodeBlock', () => { } ); // clientId will always be random. thirdExpectedBlock.clientId = transformed[ 5 ].clientId; - // TODO: Remove in 3.5 "UID" deprecation. - thirdExpectedBlock.uid = thirdExpectedBlock.clientId; expect( transformed[ 5 ] ).toEqual( thirdExpectedBlock ); expect( transformed[ 6 ] ).toEqual( `

` ); @@ -109,8 +97,6 @@ describe( 'segmentHTMLToShortcodeBlock', () => { } ); // clientId will always be random. fourthExpectedBlock.clientId = transformed[ 7 ].clientId; - // TODO: Remove in 3.5 "UID" deprecation. - fourthExpectedBlock.uid = fourthExpectedBlock.clientId; expect( transformed[ 7 ] ).toEqual( fourthExpectedBlock ); expect( transformed[ 8 ] ).toEqual( '

' ); expect( transformed ).toHaveLength( 9 ); diff --git a/utils/deprecated.js b/utils/deprecated.js deleted file mode 100644 index 639fe9e65873a6..00000000000000 --- a/utils/deprecated.js +++ /dev/null @@ -1,48 +0,0 @@ -/** - * External dependencies - */ -import { groupBy } from 'lodash'; - -/** - * WordPress dependencies - */ -import { decodeEntities as decodeEntitiesSource } from '@wordpress/html-entities'; -import deprecated from '@wordpress/deprecated'; - -/** - * Returns terms in a tree form. - * - * @param {Array} flatTerms Array of terms in flat format. - * - * @return {Array} Array of terms in tree format. - */ -export function buildTermsTree( flatTerms ) { - deprecated( 'wp.utils.buildTermsTree', { - version: '3.5', - plugin: 'Gutenberg', - } ); - const termsByParent = groupBy( flatTerms, 'parent' ); - const fillWithChildren = ( terms ) => { - return terms.map( ( term ) => { - const children = termsByParent[ term.id ]; - return { - ...term, - children: children && children.length ? - fillWithChildren( children ) : - [], - }; - } ); - }; - - return fillWithChildren( termsByParent[ '0' ] || [] ); -} - -// entities -export function decodeEntities( html ) { - deprecated( 'wp.utils.decodeEntities', { - version: '3.5', - alternative: 'wp.htmlEntities.decodeEntities', - plugin: 'Gutenberg', - } ); - return decodeEntitiesSource( html ); -} diff --git a/utils/index.js b/utils/index.js index d206dc2362eea7..027b1e0484a3e3 100644 --- a/utils/index.js +++ b/utils/index.js @@ -1,3 +1,2 @@ // Deprecations -export * from './deprecated'; export * from './mediaupload';