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

Only use rich text value internally to the RichText component #10439

Merged
merged 6 commits into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 1 addition & 12 deletions docs/reference/deprecated.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
Gutenberg's deprecation policy is intended to support backwards-compatibility for two minor releases, when possible. The current deprecations are listed below and are grouped by _the version at which they will be removed completely_. If your plugin depends on these behaviors, you must update to the recommended alternative before the noted version.

## 4.4.0

- The block attribute sources `children` and `node` have been removed. Please use the `rich-text` source instead. See the core blocks for examples.
- `wp.blocks.node.matcher` has been removed. Please use `wp.richTextValue.create` instead.
- `wp.blocks.node.toHTML` has been removed. Please use `wp.richTextValue.toHTMLString` instead.
- `wp.blocks.node.fromDOM` has been removed. Please use `wp.richTextValue.create` instead.
- `wp.blocks.children.toHTML` has been removed. Please use `wp.richTextValue.toHTMLString` instead.
- `wp.blocks.children.fromDOM` has been removed. Please use `wp.richTextValue.create` instead.
- `wp.blocks.children.concat` has been removed. Please use `wp.richTextValue.concat` instead.
- `wp.blocks.children.getChildrenArray` has been removed. Please use `wp.richTextValue.create` instead.
Gutenberg's deprecation policy is intended to support backwards-compatibility for two minor releases, when possible. The current deprecations are listed below and are grouped by _the version at which they will be removed completely_. If your plugin depends on these behaviors, you must update to the recommended alternative before the noted version.s
Copy link
Member Author

Choose a reason for hiding this comment

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

There's a trailing 's' here :)


## 4.2.0

Expand Down
31 changes: 0 additions & 31 deletions packages/blocks/src/api/children.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { castArray } from 'lodash';
/**
* WordPress dependencies
*/
import deprecated from '@wordpress/deprecated';
import { renderToString } from '@wordpress/element';

/**
Expand Down Expand Up @@ -45,12 +44,6 @@ export function getSerializeCapableElement( children ) {
* @return {Array<WPBlockNode>} An array of individual block nodes.
*/
function getChildrenArray( children ) {
deprecated( 'children and node source', {
alternative: 'rich-text source',
plugin: 'Gutenberg',
version: '4.4',
} );

// The fact that block children are compatible with the element serializer
// is merely an implementation detail that currently serves to be true, but
// should not be mistaken as being a guarantee on the external API.
Expand All @@ -66,12 +59,6 @@ function getChildrenArray( children ) {
* @return {WPBlockChildren} Concatenated block node.
*/
export function concat( ...blockNodes ) {
deprecated( 'wp.blocks.children.concat', {
alternative: 'wp.richText.concat',
plugin: 'Gutenberg',
version: '4.4',
} );

const result = [];
for ( let i = 0; i < blockNodes.length; i++ ) {
const blockNode = castArray( blockNodes[ i ] );
Expand Down Expand Up @@ -102,12 +89,6 @@ export function concat( ...blockNodes ) {
* @return {WPBlockChildren} Block children equivalent to DOM nodes.
*/
export function fromDOM( domNodes ) {
deprecated( 'wp.blocks.children.fromDom', {
alternative: 'wp.richText.create',
plugin: 'Gutenberg',
version: '4.4',
} );

const result = [];
for ( let i = 0; i < domNodes.length; i++ ) {
try {
Expand All @@ -128,12 +109,6 @@ export function fromDOM( domNodes ) {
* @return {string} String HTML representation of block node.
*/
export function toHTML( children ) {
deprecated( 'wp.blocks.children.toHTML', {
alternative: 'wp.richText.toHTMLString',
plugin: 'Gutenberg',
version: '4.4',
} );

const element = getSerializeCapableElement( children );

return renderToString( element );
Expand All @@ -148,12 +123,6 @@ export function toHTML( children ) {
* @return {Function} hpq matcher.
*/
export function matcher( selector ) {
deprecated( 'wp.blocks.children.matcher', {
hint: 'Use the rich-text source.',
plugin: 'Gutenberg',
version: '4.4',
} );

return ( domNode ) => {
let match = domNode;

Expand Down
7 changes: 0 additions & 7 deletions packages/blocks/src/api/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
* WordPress dependencies
*/
import { createHooks, applyFilters } from '@wordpress/hooks';
import deprecated from '@wordpress/deprecated';

/**
* Internal dependencies
Expand Down Expand Up @@ -52,12 +51,6 @@ export function createBlock( name, blockAttributes = {}, innerBlocks = [] ) {
}

if ( [ 'node', 'children' ].indexOf( schema.source ) !== -1 ) {
deprecated( `${ schema.source } source`, {
alternative: 'rich-text source',
plugin: 'Gutenberg',
version: '4.4',
} );

// Ensure value passed is always an array, which we're expecting in
// the RichText component to handle the deprecated value.
if ( typeof result[ key ] === 'string' ) {
Expand Down
29 changes: 0 additions & 29 deletions packages/blocks/src/api/node.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* WordPress dependencies
*/
import deprecated from '@wordpress/deprecated';

/**
* Internal dependencies
*/
Expand Down Expand Up @@ -34,12 +29,6 @@ const { TEXT_NODE, ELEMENT_NODE } = window.Node;
* @return {boolean} Whether node is of intended type.
*/
function isNodeOfType( node, type ) {
deprecated( 'wp.blocks.node.isNodeOfType', {
alternative: 'node.type',
plugin: 'Gutenberg',
version: '4.4',
} );

return node && node.type === type;
}

Expand Down Expand Up @@ -74,12 +63,6 @@ export function getNamedNodeMapAsObject( nodeMap ) {
* @return {WPBlockNode} Block node equivalent to DOM node.
*/
export function fromDOM( domNode ) {
deprecated( 'wp.blocks.node.fromDOM', {
alternative: 'wp.richText.create',
plugin: 'Gutenberg',
version: '4.4',
} );

if ( domNode.nodeType === TEXT_NODE ) {
return domNode.nodeValue;
}
Expand Down Expand Up @@ -108,12 +91,6 @@ export function fromDOM( domNode ) {
* @return {string} String HTML representation of block node.
*/
export function toHTML( node ) {
deprecated( 'wp.blocks.node.toHTML', {
alternative: 'wp.richText.toHTMLString',
plugin: 'Gutenberg',
version: '4.4',
} );

return children.toHTML( [ node ] );
}

Expand All @@ -126,12 +103,6 @@ export function toHTML( node ) {
* @return {Function} hpq matcher.
*/
export function matcher( selector ) {
deprecated( 'node source', {
alternative: 'rich-text source',
plugin: 'Gutenberg',
version: '4.4',
} );

return ( domNode ) => {
let match = domNode;

Expand Down
3 changes: 0 additions & 3 deletions packages/blocks/src/api/test/children.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ describe( 'concat', () => {
},
);

expect( console ).toHaveWarned();
expect( result ).toEqual( [
{
type: 'strong',
Expand Down Expand Up @@ -112,7 +111,6 @@ describe( 'toHTML', () => {

const html = toHTML( children );

expect( console ).toHaveWarned();
expect( html ).toBe( 'This is a <strong>test</strong>!' );
} );
} );
Expand All @@ -124,7 +122,6 @@ describe( 'fromDOM', () => {

const blockNode = fromDOM( node.childNodes );

expect( console ).toHaveWarned();
expect( blockNode ).toEqual( [
'This ',
{
Expand Down
1 change: 0 additions & 1 deletion packages/blocks/src/api/test/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ describe( 'block factory', () => {

const block = createBlock( 'core/test-block' );

expect( console ).toHaveWarned();
expect( block.attributes ).toEqual( {
content: [],
} );
Expand Down
3 changes: 0 additions & 3 deletions packages/blocks/src/api/test/matchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ describe( 'matchers', () => {
it( 'should return a source function', () => {
const source = sources.children();

expect( console ).toHaveWarned();
expect( typeof source ).toBe( 'function' );
} );

Expand All @@ -28,7 +27,6 @@ describe( 'matchers', () => {
const html = '<blockquote><p>A delicious sundae dessert</p></blockquote>';
const match = parse( html, sources.children() );

expect( console ).toHaveWarned();
expect( renderToString( match ) ).toBe( html );
} );
} );
Expand All @@ -37,7 +35,6 @@ describe( 'matchers', () => {
it( 'should return a source function', () => {
const source = sources.node();

expect( console ).toHaveWarned();
expect( typeof source ).toBe( 'function' );
} );

Expand Down
3 changes: 0 additions & 3 deletions packages/blocks/src/api/test/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ describe( 'toHTML', () => {

const html = toHTML( blockNode );

expect( console ).toHaveWarned();
expect( html ).toBe( '<strong class="is-extra-strong">This is a test</strong>' );
} );
} );
Expand All @@ -42,7 +41,6 @@ describe( 'fromDOM', () => {

const blockNode = fromDOM( node );

expect( console ).toHaveWarned();
expect( blockNode ).toBe( 'Hello world' );
} );

Expand All @@ -59,7 +57,6 @@ describe( 'fromDOM', () => {

const blockNode = fromDOM( node );

expect( console ).toHaveWarned();
expect( blockNode ).toEqual( {
type: 'strong',
props: {
Expand Down